From 1cc5cde00808701ae77eb2dd35dce8dbcf0082d7 Mon Sep 17 00:00:00 2001 From: "Sean B. Durkin" Date: Thu, 17 Nov 2016 12:08:22 +0000 Subject: [PATCH] TP LockBox 3 , version 3.7.0 --- .../COPYING.LESSER.txt | 336 +- COPYING.txt => LockBox3/COPYING.txt | 1354 +- .../How_to_build_LockBox3.txt | 94 +- .../umfmMakeSampleKey.dfm | 268 +- .../umfmMakeSampleKey.pas | 796 +- .../demo}/D2010+/umfmLockbox3_Demo.dfm | 3336 +- .../demo}/D2010+/umfmLockbox3_Demo.pas | 3578 +- .../demo}/D2010+/umfmRSA_Encryption_Demo.dfm | 164 +- .../demo}/D2010+/umfmRSA_Encryption_Demo.pas | 252 +- .../demo}/uDemoBlockModeCipher.pas | 124 +- {design => LockBox3/design}/Book.bmp | Bin {design => LockBox3/design}/Leaf.bmp | Bin {design => LockBox3/design}/Lock Box 9524.jpg | Bin {design => LockBox3/design}/LockBox3_Logo.jpg | Bin {design => LockBox3/design}/Oh.bmp | Bin .../design}/TPLB3.ComponentAbout.dfm | 10518 ++--- .../design}/TPLB3.ComponentAbout.pas | 1064 +- .../design}/TPLB3.ComponentEditors.pas | 970 +- .../design}/TPLB3.ComponentRegistration.pas | 92 +- .../design}/TPLB3.InfoUtils.pas | 238 +- .../design}/dclTP_LockBox3.dcr | Bin .../forms/d2005/uTPLb_ComponentAbout.dfm | 6370 +-- .../forms/d2005/uTPLb_ComponentAbout.pas | 1052 +- .../d2010/umfmUInt64_to_Int64_Converter.dfm | 638 +- .../d2010/umfmUInt64_to_Int64_Converter.pas | 562 +- .../forms/d7-/uTPLb_ComponentAbout.dfm | 6362 +-- .../forms/d7-/uTPLb_ComponentAbout.pas | 1052 +- {design => LockBox3/design}/pipe.bmp | Bin {design => LockBox3/design}/signature.bmp | Bin .../design}/umfmPrecompute.dfm | 142 +- .../design}/umfmPrecompute.pas | 662 +- .../D10_1Brln/LockBox_DUnitM_Tests.dpr | 63 + .../D10_1Brln/LockBox_DUnitM_Tests.dproj | 662 + .../D10_1Brln/LockBox_DUnitM_Tests.res | Bin 0 -> 2432 bytes .../packages/D10_1Brln}/Lockbox3_Demo.dpr | 32 +- .../packages/D10_1Brln/Lockbox3_Demo.dproj | 182 + LockBox3/packages/D10_1Brln/Lockbox3_Demo.res | Bin 0 -> 2372 bytes .../packages/D10_1Brln}/TP_LockBox3.dpk | 172 +- .../packages}/D10_1Brln/TP_LockBox3.dproj | 58 +- LockBox3/packages/D10_1Brln/TP_LockBox3.res | Bin 0 -> 652 bytes .../D10_1Brln/TP_LockBox3_D10_1Brln.groupproj | 72 + .../packages/D10_1Brln}/dclTP_LockBox3.dpk | 92 +- .../packages}/D10_1Brln/dclTP_LockBox3.dproj | 62 +- .../packages}/D10_1Brln/dclTP_LockBox3.res | Bin .../packages}/XE6/CSharpDemo.dpr | 30 +- .../packages}/XE6/LockBox_DUnit_Tests.dpr | 46 +- .../packages}/XE6/LockBox_DUnit_Tests.dproj | 298 +- .../packages}/XE6/LockBox_DUnit_Tests.res | Bin .../packages}/XE6/Lockbox3_Demo.dpr | 32 +- .../packages}/XE6/Lockbox3_Demo.dproj | 234 +- .../packages}/XE6/Lockbox3_Demo.res | Bin .../packages/XE6}/MakeSampleKey.dpr | 32 +- .../packages}/XE6/MakeSampleKey.dproj | 234 +- .../packages}/XE6/MakeSampleKey.res | Bin .../packages/XE6}/Precompute.dpr | 30 +- .../packages}/XE6/Precompute.dproj | 232 +- .../packages}/XE6/Precompute.res | Bin .../packages/XE6}/RSA_Encryption_Demo.dpr | 30 +- .../packages}/XE6/RSA_Encryption_Demo.dproj | 230 +- .../packages}/XE6/RSA_Encryption_Demo.res | Bin .../packages}/XE6/TP_LockBox3.dpk | 176 +- .../packages}/XE6/TP_LockBox3.dproj | 416 +- .../packages}/XE6/TP_LockBox3.res | Bin .../packages}/XE6/TP_LockBox3_XE6.groupproj | 216 +- .../packages/XE6}/dclTP_LockBox3.dpk | 2 +- .../packages}/XE6/dclTP_LockBox3.dproj | 362 +- .../packages}/XE6/dclTP_LockBox3.res | Bin .../packages}/XE7/CSharpDemo.dpr | 30 +- .../packages}/XE7/LockBox_DUnit_Tests.dpr | 46 +- .../packages}/XE7/LockBox_DUnit_Tests.dproj | 300 +- .../packages}/XE7/LockBox_DUnit_Tests.res | Bin LockBox3/packages/XE7/Lockbox3_Demo.dpr | 16 + .../packages}/XE7/Lockbox3_Demo.dproj | 920 +- .../packages}/XE7/Lockbox3_Demo.res | Bin .../packages/XE7}/MakeSampleKey.dpr | 32 +- .../packages}/XE7/MakeSampleKey.dproj | 238 +- .../packages}/XE7/MakeSampleKey.res | Bin .../packages}/XE7/Precompute.dpr | 30 +- .../packages}/XE7/Precompute.dproj | 236 +- .../packages}/XE7/Precompute.res | Bin .../packages/XE7}/RSA_Encryption_Demo.dpr | 30 +- .../packages}/XE7/RSA_Encryption_Demo.dproj | 232 +- .../packages}/XE7/RSA_Encryption_Demo.res | Bin .../packages/XE7}/TP_LockBox3.dpk | 0 .../packages}/XE7/TP_LockBox3.dproj | 1170 +- .../packages}/XE7/TP_LockBox3.res | Bin .../packages}/XE7/TP_LockBox3_XE7.groupproj | 216 +- .../packages}/XE7/dclTP_LockBox3.dpk | 92 +- .../packages}/XE7/dclTP_LockBox3.dproj | 385 +- .../packages}/XE7/dclTP_LockBox3.res | Bin LockBox3/packages/XE8/TP_LockBox3.dpk | 86 + LockBox3/packages/XE8/TP_LockBox3.dproj | 180 + .../packages/XE8}/TP_LockBox3.res | Bin .../packages/XE8/TP_LockBox3_XE8.groupproj | 2 +- LockBox3/packages/XE8/dclTP_LockBox3.dpk | 46 + LockBox3/packages/XE8/dclTP_LockBox3.dproj | 215 + LockBox3/packages/XE8/dclTP_LockBox3.res | Bin 0 -> 448 bytes .../packages}/d2010/LockBox_DUnit_Tests.dpr | 40 +- .../packages}/d2010/LockBox_DUnit_Tests.dproj | 214 +- .../packages}/d2010/LockBox_DUnit_Tests.res | Bin .../packages}/d2010/Lockbox3_Demo.dpr | 32 +- .../packages}/d2010/Lockbox3_Demo.dproj | 208 +- .../packages}/d2010/Lockbox3_Demo.res | Bin .../packages/d2010}/MakeSampleKey.dpr | 32 +- .../packages}/d2010/MakeSampleKey.dproj | 206 +- .../packages}/d2010/MakeSampleKey.res | Bin .../packages/d2010}/Precompute.dpr | 30 +- .../packages}/d2010/Precompute.dproj | 206 +- .../packages}/d2010/Precompute.res | Bin .../packages/d2010}/RSA_Encryption_Demo.dpr | 30 +- .../packages}/d2010/RSA_Encryption_Demo.dproj | 206 +- .../packages}/d2010/RSA_Encryption_Demo.res | Bin .../packages}/d2010/TP_LockBox3.dpk | 168 +- .../packages}/d2010/TP_LockBox3.dproj | 326 +- .../packages}/d2010/TP_LockBox3.res | Bin .../d2010/TP_LockBox3_d2010.groupproj | 220 +- .../d2010/UInt64_to_Int64_Convert_Utility.dpr | 28 +- .../UInt64_to_Int64_Convert_Utility.dproj | 206 +- .../d2010/UInt64_to_Int64_Convert_Utility.res | Bin .../packages}/d2010/dclTP_LockBox3.dpk | 86 +- .../packages}/d2010/dclTP_LockBox3.dproj | 234 +- .../packages}/d2010/dclTP_LockBox3.res | Bin .../resources}/acorn16x16.bmp | Bin {run => LockBox3/run}/TPLB3.AES.pas | 1618 +- {run => LockBox3/run}/TPLB3.Asymetric.pas | 1188 +- {run => LockBox3/run}/TPLB3.Base64.pas | 562 +- .../run}/TPLB3.BaseNonVisualComponent.pas | 138 +- {run => LockBox3/run}/TPLB3.BinaryUtils.pas | 278 +- {run => LockBox3/run}/TPLB3.BlockCipher.pas | 453 +- {run => LockBox3/run}/TPLB3.BlowFish.pas | 1691 +- {run => LockBox3/run}/TPLB3.CBC.pas | 364 +- {run => LockBox3/run}/TPLB3.CFB_8Bit.pas | 436 +- {run => LockBox3/run}/TPLB3.CFB_Block.pas | 308 +- {run => LockBox3/run}/TPLB3.CTR.pas | 348 +- {run => LockBox3/run}/TPLB3.CipherUtils.pas | 120 +- {run => LockBox3/run}/TPLB3.Codec.pas | 4339 +- {run => LockBox3/run}/TPLB3.CodecIntf.pas | 304 +- {run => LockBox3/run}/TPLB3.Common.inc | 82 +- {run => LockBox3/run}/TPLB3.Compatibility.pas | 96 +- {run => LockBox3/run}/TPLB3.Constants.pas | 120 +- .../run}/TPLB3.CryptographicLibrary.pas | 3084 +- .../run}/TPLB3.DCP.twofish_Modified.pas | 1158 +- {run => LockBox3/run}/TPLB3.DES.pas | 2780 +- {run => LockBox3/run}/TPLB3.Decorators.pas | 170 +- {run => LockBox3/run}/TPLB3.ECB.pas | 286 +- {run => LockBox3/run}/TPLB3.Hash.pas | 1554 +- {run => LockBox3/run}/TPLB3.HashDsc.pas | 136 +- {run => LockBox3/run}/TPLB3.HugeCardinal.pas | 4417 +- .../run}/TPLB3.HugeCardinalUtils.pas | 2070 +- {run => LockBox3/run}/TPLB3.I18n.pas | 240 +- {run => LockBox3/run}/TPLB3.IntegerUtils.pas | 606 +- {run => LockBox3/run}/TPLB3.MD5.pas | 666 +- .../run}/TPLB3.MemoryStreamPool.pas | 922 +- {run => LockBox3/run}/TPLB3.OFB.pas | 292 +- {run => LockBox3/run}/TPLB3.OpenSSL.pas | 5110 +-- {run => LockBox3/run}/TPLB3.PCBC.pas | 382 +- .../run}/TPLB3.PointerArithmetic.pas | 284 +- {run => LockBox3/run}/TPLB3.RSA_Engine.pas | 2154 +- .../run}/TPLB3.RSA_Primitives.pas | 2614 +- {run => LockBox3/run}/TPLB3.Random.pas | 582 +- {run => LockBox3/run}/TPLB3.SHA1.pas | 625 +- {run => LockBox3/run}/TPLB3.SHA2.pas | 2698 +- {run => LockBox3/run}/TPLB3.SVN_Keywords.pas | 84 +- {run => LockBox3/run}/TPLB3.Signatory.pas | 474 +- .../run}/TPLB3.SimpleBlockCipher.pas | 550 +- {run => LockBox3/run}/TPLB3.StreamCipher.pas | 336 +- {run => LockBox3/run}/TPLB3.StreamToBlock.pas | 3700 +- {run => LockBox3/run}/TPLB3.StreamUtils.pas | 1221 +- {run => LockBox3/run}/TPLB3.TDES.pas | 884 +- {run => LockBox3/run}/TPLB3.TwoFish.pas | 786 +- {run => LockBox3/run}/TPLB3.XXTEA.pas | 2126 +- .../run}/uTPLb_D7Compatibility.pas | 22 +- LockBox3/unit-tests/dunit-m/LICENSE.txt | 202 + .../VirtualTreeView/Common/Compilers.inc | 665 + .../VirtualTreeView/Common/Readme.txt | 3 + .../VirtualTreeView/Read me.txt | 1 + .../Source/DUnitM.VTAccessibility.pas | 774 + .../Source/DUnitM.VTAccessibilityFactory.pas | 169 + .../Source/DUnitM.VirtualTrees.pas | 36294 ++++++++++++++++ .../VirtualTreeView/Source/VTConfig.inc | 15 + .../VirtualTreeView/Source/VirtualTrees.res | Bin 0 -> 51972 bytes .../MPL2.0_LicenseTerms.txt | 373 + .../SBD.ServiceProvider.Internal.pas | 1512 + .../SBD.ServiceProvider.pas | 281 + .../unit-tests/dunit-m/includes/DUnitM.inc | 321 + .../dunit-m/run/DUnitM.Assertion.pas | 776 + .../dunit-m/run/DUnitM.BaseExecutive.pas | 204 + .../run/DUnitM.CommandLine.General.pas | 686 + .../dunit-m/run/DUnitM.DDExtensions.pas | 895 + .../dunit-m/run/DUnitM.Executive.pas | 91 + .../unit-tests/dunit-m/run/DUnitM.Fixture.pas | 1035 + .../dunit-m/run/DUnitM.GeneralCommandLine.pas | 7 + .../run/DUnitM.MemoryMonitor.Solution.pas | 171 + .../dunit-m/run/DUnitM.MemoryMonitor.pas | 83 + .../run/DUnitM.NUnit.Logger.Solution.pas | 341 + .../run/DUnitM.NUnit.LoggerUI.Solution.pas | 163 + .../unit-tests/dunit-m/run/DUnitM.NUnit.pas | 127 + .../DUnitM.NUnit25.ResultsLog.Solution.pas | 655 + .../dunit-m/run/DUnitM.RttiUtils.pas | 247 + .../dunit-m/run/DUnitM.RunInstance.pas | 453 + .../dunit-m/run/DUnitM.StringUtils.pas | 214 + .../dunit-m/run/DUnitM.TestCase.pas | 951 + .../dunit-m/run/DUnitM.TestCaseParameters.pas | 450 + .../dunit-m/run/DUnitM.TestCaseRound.pas | 497 + .../dunit-m/run/DUnitM.TestNode.pas | 494 + .../dunit-m/run/DUnitM.TestProcedure.pas | 419 + .../run/DUnitM.TestSuiteDxVirtualTree.dfm | 7 + .../run/DUnitM.TestSuiteDxVirtualTree.pas | 738 + .../run/DUnitM.UnitTestFramework.Solution.pas | 634 + .../dunit-m/run/DUnitM.UnitTestFramework.pas | 727 + .../dunit-m/run/DUnitM.ViewModel_Tree.pas | 128 + .../dunit-m/run/DUnitM.ViewModel_VCLForms.pas | 998 + .../dunit-m/run/DUnitM.XMLWriter.Solution.pas | 575 + .../dunit-m/run/DUnitM.XMLWriter.pas | 106 + .../DUnitM.dmVirtualTreeNonVisualSupport.dfm | 412 + .../DUnitM.dmVirtualTreeNonVisualSupport.pas | 85 + .../dunit-m/run/DUnitM.fmAboutDUnitM.dfm | 410 + .../dunit-m/run/DUnitM.fmAboutDUnitM.pas | 247 + .../dunit-m/run/DUnitX.ConsoleWriter.Base.pas | 210 + .../dunit-m/run/DUnitX.Windows.Console.pas | 249 + .../DunitM.CommandLine.Console.Solution.pas | 50 + .../dunit-m/run/DunitM.GUIRunnerForm.dfm | 565 + .../dunit-m/run/DunitM.GUIRunnerForm.pas | 716 + .../dunit-m/run/SBD.Environment.pas | 166 + .../unit-tests/dunit-m/run/SBD.Generics.pas | 520 + .../dunit-m/run/SBD.Messages.Solution.pas | 196 + .../unit-tests/dunit-m/run/SBD.Messages.pas | 169 + .../unit-tests/dunit-m/run/SBD.Utils.XML2.pas | 3569 ++ .../unit-tests/dunit-m/run/SampleTests.pas | 239 + .../test-suite/uLockBox_CipherTestCases.pas | 1312 + .../dunit-m/test-suite/uLockBox_Hashes.pas | 435 + .../uLockBox_HugeCardinalTestCases.pas | 605 + .../test-suite/uLockBox_OpenSSLTestCases.pas | 165 + .../test-suite/uLockBox_RSA_TestCases.pas | 511 + .../uLockBox_Signatory_TestCases.pas | 186 + .../dunit-m/test-suite/uLockBox_TestCases.pas | 113 + .../dunit/uLockBox_CipherTestCases.pas | 2146 +- .../unit-tests}/dunit/uLockBox_Hashes.pas | 524 +- .../dunit/uLockBox_HugeCardinalTestCases.pas | 1240 +- .../dunit/uLockBox_OpenSSLTestCases.pas | 346 +- .../dunit/uLockBox_RSA_TestCases.pas | 1040 +- .../dunit/uLockBox_Signatory_TestCases.pas | 408 +- .../unit-tests}/dunit/uLockBox_TestCases.pas | 472 +- .../unit-tests}/dunit/umfmLockboxTests.dfm | 154 +- .../unit-tests}/dunit/umfmLockboxTests.pas | 128 +- 245 files changed, 121812 insertions(+), 55709 deletions(-) rename COPYING.LESSER.txt => LockBox3/COPYING.LESSER.txt (97%) rename COPYING.txt => LockBox3/COPYING.txt (98%) rename How_to_build_LockBox3.txt => LockBox3/How_to_build_LockBox3.txt (97%) rename {ancillary-applications => LockBox3/ancillary-applications}/umfmMakeSampleKey.dfm (95%) rename {ancillary-applications => LockBox3/ancillary-applications}/umfmMakeSampleKey.pas (96%) rename {demo => LockBox3/demo}/D2010+/umfmLockbox3_Demo.dfm (96%) rename {demo => LockBox3/demo}/D2010+/umfmLockbox3_Demo.pas (96%) rename {demo => LockBox3/demo}/D2010+/umfmRSA_Encryption_Demo.dfm (96%) rename {demo => LockBox3/demo}/D2010+/umfmRSA_Encryption_Demo.pas (96%) rename {demo => LockBox3/demo}/uDemoBlockModeCipher.pas (94%) rename {design => LockBox3/design}/Book.bmp (100%) rename {design => LockBox3/design}/Leaf.bmp (100%) rename {design => LockBox3/design}/Lock Box 9524.jpg (100%) rename {design => LockBox3/design}/LockBox3_Logo.jpg (100%) rename {design => LockBox3/design}/Oh.bmp (100%) rename {design => LockBox3/design}/TPLB3.ComponentAbout.dfm (98%) rename {design => LockBox3/design}/TPLB3.ComponentAbout.pas (96%) rename {design => LockBox3/design}/TPLB3.ComponentEditors.pas (96%) rename {design => LockBox3/design}/TPLB3.ComponentRegistration.pas (97%) rename {design => LockBox3/design}/TPLB3.InfoUtils.pas (96%) rename {design => LockBox3/design}/dclTP_LockBox3.dcr (100%) rename {design => LockBox3/design}/forms/d2005/uTPLb_ComponentAbout.dfm (98%) rename {design => LockBox3/design}/forms/d2005/uTPLb_ComponentAbout.pas (96%) rename {design => LockBox3/design}/forms/d2010/umfmUInt64_to_Int64_Converter.dfm (97%) rename {design => LockBox3/design}/forms/d2010/umfmUInt64_to_Int64_Converter.pas (95%) rename {design => LockBox3/design}/forms/d7-/uTPLb_ComponentAbout.dfm (98%) rename {design => LockBox3/design}/forms/d7-/uTPLb_ComponentAbout.pas (96%) rename {design => LockBox3/design}/pipe.bmp (100%) rename {design => LockBox3/design}/signature.bmp (100%) rename {design => LockBox3/design}/umfmPrecompute.dfm (96%) rename {design => LockBox3/design}/umfmPrecompute.pas (97%) create mode 100644 LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dpr create mode 100644 LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dproj create mode 100644 LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.res rename {packages/XE7 => LockBox3/packages/D10_1Brln}/Lockbox3_Demo.dpr (96%) create mode 100644 LockBox3/packages/D10_1Brln/Lockbox3_Demo.dproj create mode 100644 LockBox3/packages/D10_1Brln/Lockbox3_Demo.res rename {packages/XE7 => LockBox3/packages/D10_1Brln}/TP_LockBox3.dpk (96%) rename {packages => LockBox3/packages}/D10_1Brln/TP_LockBox3.dproj (73%) create mode 100644 LockBox3/packages/D10_1Brln/TP_LockBox3.res create mode 100644 LockBox3/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj rename {packages/XE6 => LockBox3/packages/D10_1Brln}/dclTP_LockBox3.dpk (91%) rename {packages => LockBox3/packages}/D10_1Brln/dclTP_LockBox3.dproj (72%) rename {packages => LockBox3/packages}/D10_1Brln/dclTP_LockBox3.res (100%) rename {packages => LockBox3/packages}/XE6/CSharpDemo.dpr (95%) rename {packages => LockBox3/packages}/XE6/LockBox_DUnit_Tests.dpr (97%) rename {packages => LockBox3/packages}/XE6/LockBox_DUnit_Tests.dproj (98%) rename {packages => LockBox3/packages}/XE6/LockBox_DUnit_Tests.res (100%) rename {packages => LockBox3/packages}/XE6/Lockbox3_Demo.dpr (96%) rename {packages => LockBox3/packages}/XE6/Lockbox3_Demo.dproj (98%) rename {packages => LockBox3/packages}/XE6/Lockbox3_Demo.res (100%) rename {packages/XE7 => LockBox3/packages/XE6}/MakeSampleKey.dpr (96%) rename {packages => LockBox3/packages}/XE6/MakeSampleKey.dproj (98%) rename {packages => LockBox3/packages}/XE6/MakeSampleKey.res (100%) rename {packages/d2010 => LockBox3/packages/XE6}/Precompute.dpr (95%) rename {packages => LockBox3/packages}/XE6/Precompute.dproj (98%) rename {packages => LockBox3/packages}/XE6/Precompute.res (100%) rename {packages/d2010 => LockBox3/packages/XE6}/RSA_Encryption_Demo.dpr (96%) rename {packages => LockBox3/packages}/XE6/RSA_Encryption_Demo.dproj (98%) rename {packages => LockBox3/packages}/XE6/RSA_Encryption_Demo.res (100%) rename {packages => LockBox3/packages}/XE6/TP_LockBox3.dpk (97%) rename {packages => LockBox3/packages}/XE6/TP_LockBox3.dproj (98%) rename {packages => LockBox3/packages}/XE6/TP_LockBox3.res (100%) rename {packages => LockBox3/packages}/XE6/TP_LockBox3_XE6.groupproj (97%) rename {packages/D10_1Brln => LockBox3/packages/XE6}/dclTP_LockBox3.dpk (98%) rename {packages => LockBox3/packages}/XE6/dclTP_LockBox3.dproj (98%) rename {packages => LockBox3/packages}/XE6/dclTP_LockBox3.res (100%) rename {packages => LockBox3/packages}/XE7/CSharpDemo.dpr (95%) rename {packages => LockBox3/packages}/XE7/LockBox_DUnit_Tests.dpr (97%) rename {packages => LockBox3/packages}/XE7/LockBox_DUnit_Tests.dproj (98%) rename {packages => LockBox3/packages}/XE7/LockBox_DUnit_Tests.res (100%) create mode 100644 LockBox3/packages/XE7/Lockbox3_Demo.dpr rename {packages => LockBox3/packages}/XE7/Lockbox3_Demo.dproj (97%) rename {packages => LockBox3/packages}/XE7/Lockbox3_Demo.res (100%) rename {packages/d2010 => LockBox3/packages/XE7}/MakeSampleKey.dpr (96%) rename {packages => LockBox3/packages}/XE7/MakeSampleKey.dproj (98%) rename {packages => LockBox3/packages}/XE7/MakeSampleKey.res (100%) rename {packages => LockBox3/packages}/XE7/Precompute.dpr (95%) rename {packages => LockBox3/packages}/XE7/Precompute.dproj (98%) rename {packages => LockBox3/packages}/XE7/Precompute.res (100%) rename {packages/XE6 => LockBox3/packages/XE7}/RSA_Encryption_Demo.dpr (96%) rename {packages => LockBox3/packages}/XE7/RSA_Encryption_Demo.dproj (98%) rename {packages => LockBox3/packages}/XE7/RSA_Encryption_Demo.res (100%) rename {packages/D10_1Brln => LockBox3/packages/XE7}/TP_LockBox3.dpk (100%) rename {packages => LockBox3/packages}/XE7/TP_LockBox3.dproj (93%) rename {packages => LockBox3/packages}/XE7/TP_LockBox3.res (100%) rename {packages => LockBox3/packages}/XE7/TP_LockBox3_XE7.groupproj (97%) rename {packages => LockBox3/packages}/XE7/dclTP_LockBox3.dpk (95%) rename {packages => LockBox3/packages}/XE7/dclTP_LockBox3.dproj (93%) rename {packages => LockBox3/packages}/XE7/dclTP_LockBox3.res (100%) create mode 100644 LockBox3/packages/XE8/TP_LockBox3.dpk create mode 100644 LockBox3/packages/XE8/TP_LockBox3.dproj rename {packages/D10_1Brln => LockBox3/packages/XE8}/TP_LockBox3.res (100%) rename packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj => LockBox3/packages/XE8/TP_LockBox3_XE8.groupproj (96%) create mode 100644 LockBox3/packages/XE8/dclTP_LockBox3.dpk create mode 100644 LockBox3/packages/XE8/dclTP_LockBox3.dproj create mode 100644 LockBox3/packages/XE8/dclTP_LockBox3.res rename {packages => LockBox3/packages}/d2010/LockBox_DUnit_Tests.dpr (97%) rename {packages => LockBox3/packages}/d2010/LockBox_DUnit_Tests.dproj (97%) rename {packages => LockBox3/packages}/d2010/LockBox_DUnit_Tests.res (100%) rename {packages => LockBox3/packages}/d2010/Lockbox3_Demo.dpr (96%) rename {packages => LockBox3/packages}/d2010/Lockbox3_Demo.dproj (97%) rename {packages => LockBox3/packages}/d2010/Lockbox3_Demo.res (100%) rename {packages/XE6 => LockBox3/packages/d2010}/MakeSampleKey.dpr (96%) rename {packages => LockBox3/packages}/d2010/MakeSampleKey.dproj (97%) rename {packages => LockBox3/packages}/d2010/MakeSampleKey.res (100%) rename {packages/XE6 => LockBox3/packages/d2010}/Precompute.dpr (95%) rename {packages => LockBox3/packages}/d2010/Precompute.dproj (97%) rename {packages => LockBox3/packages}/d2010/Precompute.res (100%) rename {packages/XE7 => LockBox3/packages/d2010}/RSA_Encryption_Demo.dpr (96%) rename {packages => LockBox3/packages}/d2010/RSA_Encryption_Demo.dproj (97%) rename {packages => LockBox3/packages}/d2010/RSA_Encryption_Demo.res (100%) rename {packages => LockBox3/packages}/d2010/TP_LockBox3.dpk (97%) rename {packages => LockBox3/packages}/d2010/TP_LockBox3.dproj (97%) rename {packages => LockBox3/packages}/d2010/TP_LockBox3.res (100%) rename {packages => LockBox3/packages}/d2010/TP_LockBox3_d2010.groupproj (97%) rename {packages => LockBox3/packages}/d2010/UInt64_to_Int64_Convert_Utility.dpr (96%) rename {packages => LockBox3/packages}/d2010/UInt64_to_Int64_Convert_Utility.dproj (97%) rename {packages => LockBox3/packages}/d2010/UInt64_to_Int64_Convert_Utility.res (100%) rename {packages => LockBox3/packages}/d2010/dclTP_LockBox3.dpk (95%) rename {packages => LockBox3/packages}/d2010/dclTP_LockBox3.dproj (97%) rename {packages => LockBox3/packages}/d2010/dclTP_LockBox3.res (100%) rename {resources => LockBox3/resources}/acorn16x16.bmp (100%) rename {run => LockBox3/run}/TPLB3.AES.pas (96%) rename {run => LockBox3/run}/TPLB3.Asymetric.pas (96%) rename {run => LockBox3/run}/TPLB3.Base64.pas (96%) rename {run => LockBox3/run}/TPLB3.BaseNonVisualComponent.pas (97%) rename {run => LockBox3/run}/TPLB3.BinaryUtils.pas (96%) rename {run => LockBox3/run}/TPLB3.BlockCipher.pas (90%) rename {run => LockBox3/run}/TPLB3.BlowFish.pas (96%) rename {run => LockBox3/run}/TPLB3.CBC.pas (96%) rename {run => LockBox3/run}/TPLB3.CFB_8Bit.pas (96%) rename {run => LockBox3/run}/TPLB3.CFB_Block.pas (96%) rename {run => LockBox3/run}/TPLB3.CTR.pas (96%) rename {run => LockBox3/run}/TPLB3.CipherUtils.pas (96%) rename {run => LockBox3/run}/TPLB3.Codec.pas (95%) rename {run => LockBox3/run}/TPLB3.CodecIntf.pas (97%) rename {run => LockBox3/run}/TPLB3.Common.inc (96%) rename {run => LockBox3/run}/TPLB3.Compatibility.pas (95%) rename {run => LockBox3/run}/TPLB3.Constants.pas (97%) rename {run => LockBox3/run}/TPLB3.CryptographicLibrary.pas (96%) rename {run => LockBox3/run}/TPLB3.DCP.twofish_Modified.pas (97%) rename {run => LockBox3/run}/TPLB3.DES.pas (97%) rename {run => LockBox3/run}/TPLB3.Decorators.pas (96%) rename {run => LockBox3/run}/TPLB3.ECB.pas (96%) rename {run => LockBox3/run}/TPLB3.Hash.pas (95%) rename {run => LockBox3/run}/TPLB3.HashDsc.pas (97%) rename {run => LockBox3/run}/TPLB3.HugeCardinal.pas (96%) rename {run => LockBox3/run}/TPLB3.HugeCardinalUtils.pas (96%) rename {run => LockBox3/run}/TPLB3.I18n.pas (97%) rename {run => LockBox3/run}/TPLB3.IntegerUtils.pas (96%) rename {run => LockBox3/run}/TPLB3.MD5.pas (95%) rename {run => LockBox3/run}/TPLB3.MemoryStreamPool.pas (96%) rename {run => LockBox3/run}/TPLB3.OFB.pas (96%) rename {run => LockBox3/run}/TPLB3.OpenSSL.pas (96%) rename {run => LockBox3/run}/TPLB3.PCBC.pas (96%) rename {run => LockBox3/run}/TPLB3.PointerArithmetic.pas (97%) rename {run => LockBox3/run}/TPLB3.RSA_Engine.pas (96%) rename {run => LockBox3/run}/TPLB3.RSA_Primitives.pas (96%) rename {run => LockBox3/run}/TPLB3.Random.pas (95%) rename {run => LockBox3/run}/TPLB3.SHA1.pas (95%) rename {run => LockBox3/run}/TPLB3.SHA2.pas (96%) rename {run => LockBox3/run}/TPLB3.SVN_Keywords.pas (95%) rename {run => LockBox3/run}/TPLB3.Signatory.pas (96%) rename {run => LockBox3/run}/TPLB3.SimpleBlockCipher.pas (95%) rename {run => LockBox3/run}/TPLB3.StreamCipher.pas (97%) rename {run => LockBox3/run}/TPLB3.StreamToBlock.pas (81%) rename {run => LockBox3/run}/TPLB3.StreamUtils.pas (96%) rename {run => LockBox3/run}/TPLB3.TDES.pas (96%) rename {run => LockBox3/run}/TPLB3.TwoFish.pas (95%) rename {run => LockBox3/run}/TPLB3.XXTEA.pas (96%) rename {run => LockBox3/run}/uTPLb_D7Compatibility.pas (92%) create mode 100644 LockBox3/unit-tests/dunit-m/LICENSE.txt create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Compilers.inc create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Readme.txt create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Read me.txt create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibility.pas create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibilityFactory.pas create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VirtualTrees.pas create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VTConfig.inc create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VirtualTrees.res create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/MPL2.0_LicenseTerms.txt create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/SBD.ServiceProvider.Internal.pas create mode 100644 LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/SBD.ServiceProvider.pas create mode 100644 LockBox3/unit-tests/dunit-m/includes/DUnitM.inc create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.Assertion.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.BaseExecutive.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.CommandLine.General.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.DDExtensions.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.Executive.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.Fixture.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.GeneralCommandLine.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.Logger.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.LoggerUI.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit25.ResultsLog.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.RttiUtils.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.RunInstance.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.StringUtils.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestCase.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseParameters.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseRound.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestNode.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestProcedure.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.dfm create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_Tree.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_VCLForms.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.dfm create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.dfm create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitX.ConsoleWriter.Base.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DUnitX.Windows.Console.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DunitM.CommandLine.Console.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.dfm create mode 100644 LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SBD.Environment.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SBD.Generics.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SBD.Messages.Solution.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SBD.Messages.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SBD.Utils.XML2.pas create mode 100644 LockBox3/unit-tests/dunit-m/run/SampleTests.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_CipherTestCases.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Hashes.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_HugeCardinalTestCases.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_OpenSSLTestCases.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_RSA_TestCases.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Signatory_TestCases.pas create mode 100644 LockBox3/unit-tests/dunit-m/test-suite/uLockBox_TestCases.pas rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_CipherTestCases.pas (96%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_Hashes.pas (95%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_HugeCardinalTestCases.pas (96%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_OpenSSLTestCases.pas (96%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_RSA_TestCases.pas (96%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_Signatory_TestCases.pas (96%) rename {unit-tests => LockBox3/unit-tests}/dunit/uLockBox_TestCases.pas (95%) rename {unit-tests => LockBox3/unit-tests}/dunit/umfmLockboxTests.dfm (95%) rename {unit-tests => LockBox3/unit-tests}/dunit/umfmLockboxTests.pas (96%) diff --git a/COPYING.LESSER.txt b/LockBox3/COPYING.LESSER.txt similarity index 97% rename from COPYING.LESSER.txt rename to LockBox3/COPYING.LESSER.txt index 306854a..352e7cd 100644 --- a/COPYING.LESSER.txt +++ b/LockBox3/COPYING.LESSER.txt @@ -1,168 +1,168 @@ -TurboPower LockBox 3 is free software being offered under a dual -licensing scheme: LGPL3 or MPL1.1. This file describes the LGPL. - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. +TurboPower LockBox 3 is free software being offered under a dual +licensing scheme: LGPL3 or MPL1.1. This file describes the LGPL. + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/COPYING.txt b/LockBox3/COPYING.txt similarity index 98% rename from COPYING.txt rename to LockBox3/COPYING.txt index 0ea3747..28eea25 100644 --- a/COPYING.txt +++ b/LockBox3/COPYING.txt @@ -1,677 +1,677 @@ -TurboPower LockBox 3 is free software being offered under a dual -licensing scheme: LGPL3 or MPL1.1. This file describes the GPL base -part of LGPL. Also see the "COPYING LESSER.txt" file. - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +TurboPower LockBox 3 is free software being offered under a dual +licensing scheme: LGPL3 or MPL1.1. This file describes the GPL base +part of LGPL. Also see the "COPYING LESSER.txt" file. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/How_to_build_LockBox3.txt b/LockBox3/How_to_build_LockBox3.txt similarity index 97% rename from How_to_build_LockBox3.txt rename to LockBox3/How_to_build_LockBox3.txt index f6b23fb..59bd734 100644 --- a/How_to_build_LockBox3.txt +++ b/LockBox3/How_to_build_LockBox3.txt @@ -1,47 +1,47 @@ -How to Build TurboPower LockBox 3 -================================= - -To build TurboPower LockBox 3, follow these steps. - -1. Open up each of the projects and set the project options and directories - as you prefer for your development environment. (See notes about - Environment Variables below). - -2. Compile the main run-time package (TP_LockBox3.dproj) for each platform. Use the DEBUG config if you want to be able to step through the lockbox code at run-time, otherwise use the RELEASE config. - By default the dcu's will be placed in '..\..\work-products\ephemeral\dcu\XE7\$(Platform)' relative to the project head, but you can override this. - The default the dcp's will be placed as per your IDE settings (Tools | Options... | etc.), but you can override this. - -3. Take a note of the paths in step 2. Check that the output dcu's and dcp is where you expect them to be. If not already present, add the dcu path and the dcp path (but not the source path) to the - library path for each platform. You can also add the source path ('run' directory) to the IDE browsing path). - -4. Compile the main design-time package (dclTP_LockBox3.dproj). Use Win32 platform, RELEASE config. - If upgrading from a previous version, it is safer to uninstall the previous lockbox design-time package first. - -5. Install the main design-time package. - -6. Use and enjoy ! - - -Package, Application and Group heads -==================================== -Here is listed the package heads and their purposes. - -\packages\XE7\TP_LockBox3_XE7.groupproj - The project group for Delphi XE7 - -\packages\XE7\dclTP_LockBox3.dpk - The main design-time package for Delphi XE6 - -\packages\XE7\Lockbox3_Demo.dpr - The demonstration program for Delphi XE7 - -\packages\XE7\LockBox_DUnit_Tests.dpr - The D-Unit test suite running under Delphi 2010 without SmartInpect support. - -\packages\XE7\MakeSampleKey.dpr - A demonstration program for Delphi 2010 without SmartInspect, to create - an RSA key. - -\packages\XE7\Precompute.dpr - Program which show how the AES look-up tables were precomputed. - +How to Build TurboPower LockBox 3 +================================= + +To build TurboPower LockBox 3, follow these steps. + +1. Open up each of the projects and set the project options and directories + as you prefer for your development environment. (See notes about + Environment Variables below). + +2. Compile the main run-time package (TP_LockBox3.dproj) for each platform. Use the DEBUG config if you want to be able to step through the lockbox code at run-time, otherwise use the RELEASE config. + By default the dcu's will be placed in '..\..\work-products\ephemeral\dcu\XE7\$(Platform)' relative to the project head, but you can override this. + The default the dcp's will be placed as per your IDE settings (Tools | Options... | etc.), but you can override this. + +3. Take a note of the paths in step 2. Check that the output dcu's and dcp is where you expect them to be. If not already present, add the dcu path and the dcp path (but not the source path) to the + library path for each platform. You can also add the source path ('run' directory) to the IDE browsing path). + +4. Compile the main design-time package (dclTP_LockBox3.dproj). Use Win32 platform, RELEASE config. + If upgrading from a previous version, it is safer to uninstall the previous lockbox design-time package first. + +5. Install the main design-time package. + +6. Use and enjoy ! + + +Package, Application and Group heads +==================================== +Here is listed the package heads and their purposes. + +\packages\XE7\TP_LockBox3_XE7.groupproj + The project group for Delphi XE7 + +\packages\XE7\dclTP_LockBox3.dpk + The main design-time package for Delphi XE6 + +\packages\XE7\Lockbox3_Demo.dpr + The demonstration program for Delphi XE7 + +\packages\XE7\LockBox_DUnit_Tests.dpr + The D-Unit test suite running under Delphi 2010 without SmartInpect support. + +\packages\XE7\MakeSampleKey.dpr + A demonstration program for Delphi 2010 without SmartInspect, to create + an RSA key. + +\packages\XE7\Precompute.dpr + Program which show how the AES look-up tables were precomputed. + diff --git a/ancillary-applications/umfmMakeSampleKey.dfm b/LockBox3/ancillary-applications/umfmMakeSampleKey.dfm similarity index 95% rename from ancillary-applications/umfmMakeSampleKey.dfm rename to LockBox3/ancillary-applications/umfmMakeSampleKey.dfm index 862f98e..4cca660 100644 --- a/ancillary-applications/umfmMakeSampleKey.dfm +++ b/LockBox3/ancillary-applications/umfmMakeSampleKey.dfm @@ -1,134 +1,134 @@ -object mfmMakeSampleKey: TmfmMakeSampleKey - Left = 0 - Top = 0 - Caption = 'Make Sample Key' - ClientHeight = 294 - ClientWidth = 562 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - OnCreate = FormCreate - OnDestroy = FormDestroy - DesignSize = ( - 562 - 294) - PixelsPerInch = 96 - TextHeight = 13 - object lblCountPrimalityTests: TLabel - Left = 8 - Top = 102 - Width = 71 - Height = 13 - Caption = 'Primality tests:' - end - object lblCountPrimalityTestsValue: TLabel - Left = 85 - Top = 102 - Width = 6 - Height = 13 - Caption = '0' - end - object lblKeySize: TLabel - Left = 3 - Top = 0 - Width = 93 - Height = 13 - Caption = 'RSA key size (bits):' - FocusControl = edtKeySize - end - object btnGenRSA: TButton - Left = 8 - Top = 40 - Width = 121 - Height = 25 - Caption = 'Generate RSA key pair' - TabOrder = 0 - OnClick = btnGenRSAClick - end - object memoOutput: TMemo - Left = 135 - Top = 8 - Width = 419 - Height = 278 - Anchors = [akLeft, akTop, akRight, akBottom] - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [] - Lines.Strings = ( - '[Output goes here]') - ParentFont = False - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 1 - end - object btnGenAES256: TButton - Left = 8 - Top = 139 - Width = 121 - Height = 25 - Caption = 'Generate AES-256 key' - TabOrder = 2 - OnClick = btnGenAES256Click - end - object btnAbort: TButton - Left = 8 - Top = 71 - Width = 121 - Height = 25 - Caption = 'Abort RSA generation' - Enabled = False - TabOrder = 3 - OnClick = btnAbortClick - end - object edtKeySize: TEdit - Left = 74 - Top = 13 - Width = 39 - Height = 21 - TabOrder = 4 - Text = '1024' - end - object btnGenCompRSAKeys: TButton - Left = 8 - Top = 232 - Width = 105 - Height = 54 - Caption = 'Generate componentised RSA keys' - TabOrder = 5 - WordWrap = True - OnClick = btnGenCompRSAKeysClick - end - object CryptographicLibrary1: TCryptographicLibrary - Left = 184 - Top = 240 - end - object Codec1: TCodec - AsymetricKeySizeInBits = 1024 - AdvancedOptions2 = [] - CryptoLibrary = CryptographicLibrary1 - OnProgress = Codec1Progress - Left = 288 - Top = 240 - StreamCipherId = 'native.RSA' - BlockCipherId = '' - ChainId = 'native.ECB' - end - object Hash1: THash - CryptoLibrary = CryptographicLibrary1 - Left = 168 - Top = 192 - HashId = 'native.hash.MD5' - end - object Signatory1: TSignatory - Codec = Codec1 - Left = 376 - Top = 240 - end -end +object mfmMakeSampleKey: TmfmMakeSampleKey + Left = 0 + Top = 0 + Caption = 'Make Sample Key' + ClientHeight = 294 + ClientWidth = 562 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + OnCreate = FormCreate + OnDestroy = FormDestroy + DesignSize = ( + 562 + 294) + PixelsPerInch = 96 + TextHeight = 13 + object lblCountPrimalityTests: TLabel + Left = 8 + Top = 102 + Width = 71 + Height = 13 + Caption = 'Primality tests:' + end + object lblCountPrimalityTestsValue: TLabel + Left = 85 + Top = 102 + Width = 6 + Height = 13 + Caption = '0' + end + object lblKeySize: TLabel + Left = 3 + Top = 0 + Width = 93 + Height = 13 + Caption = 'RSA key size (bits):' + FocusControl = edtKeySize + end + object btnGenRSA: TButton + Left = 8 + Top = 40 + Width = 121 + Height = 25 + Caption = 'Generate RSA key pair' + TabOrder = 0 + OnClick = btnGenRSAClick + end + object memoOutput: TMemo + Left = 135 + Top = 8 + Width = 419 + Height = 278 + Anchors = [akLeft, akTop, akRight, akBottom] + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + '[Output goes here]') + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 1 + end + object btnGenAES256: TButton + Left = 8 + Top = 139 + Width = 121 + Height = 25 + Caption = 'Generate AES-256 key' + TabOrder = 2 + OnClick = btnGenAES256Click + end + object btnAbort: TButton + Left = 8 + Top = 71 + Width = 121 + Height = 25 + Caption = 'Abort RSA generation' + Enabled = False + TabOrder = 3 + OnClick = btnAbortClick + end + object edtKeySize: TEdit + Left = 74 + Top = 13 + Width = 39 + Height = 21 + TabOrder = 4 + Text = '1024' + end + object btnGenCompRSAKeys: TButton + Left = 8 + Top = 232 + Width = 105 + Height = 54 + Caption = 'Generate componentised RSA keys' + TabOrder = 5 + WordWrap = True + OnClick = btnGenCompRSAKeysClick + end + object CryptographicLibrary1: TCryptographicLibrary + Left = 184 + Top = 240 + end + object Codec1: TCodec + AsymetricKeySizeInBits = 1024 + AdvancedOptions2 = [] + CryptoLibrary = CryptographicLibrary1 + OnProgress = Codec1Progress + Left = 288 + Top = 240 + StreamCipherId = 'native.RSA' + BlockCipherId = '' + ChainId = 'native.ECB' + end + object Hash1: THash + CryptoLibrary = CryptographicLibrary1 + Left = 168 + Top = 192 + HashId = 'native.hash.MD5' + end + object Signatory1: TSignatory + Codec = Codec1 + Left = 376 + Top = 240 + end +end diff --git a/ancillary-applications/umfmMakeSampleKey.pas b/LockBox3/ancillary-applications/umfmMakeSampleKey.pas similarity index 96% rename from ancillary-applications/umfmMakeSampleKey.pas rename to LockBox3/ancillary-applications/umfmMakeSampleKey.pas index 8d29fd0..abdae00 100644 --- a/ancillary-applications/umfmMakeSampleKey.pas +++ b/LockBox3/ancillary-applications/umfmMakeSampleKey.pas @@ -1,398 +1,398 @@ -unit umfmMakeSampleKey; - -interface - -uses - Windows, Messages, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, TPLB3.MemoryStreamPool, TPLB3.Signatory, TPLB3.Codec, - TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, TPLB3.Hash; - -type - TmfmMakeSampleKey = class(TForm) - btnGenRSA: TButton; - memoOutput: TMemo; - btnGenAES256: TButton; - btnAbort: TButton; - lblCountPrimalityTests: TLabel; - lblCountPrimalityTestsValue: TLabel; - lblKeySize: TLabel; - edtKeySize: TEdit; - CryptographicLibrary1: TCryptographicLibrary; - Codec1: TCodec; - btnGenCompRSAKeys: TButton; - Hash1: THash; - Signatory1: TSignatory; - procedure btnGenRSAClick(Sender: TObject); - procedure btnGenAES256Click(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormDestroy(Sender: TObject); - procedure btnAbortClick(Sender: TObject); - procedure btnGenCompRSAKeysClick(Sender: TObject); - function Codec1Progress(Sender: TObject; - CountBytesProcessed: Int64): Boolean; - - private - FPool: IMemoryStreamPool; - FNumbersTested: integer; - FwasAborted: boolean; - FisGeneratingKeys: boolean; - - procedure GenRSA_Progress( - Sender: TObject; BitsProcessed, TotalBits: int64; - var doAbort: boolean); - - procedure GenRSA_TPrimalityTestNotice( CountPrimalityTests: integer); - - procedure Put( const Line: string); - procedure PutFmt( const Line: string; const Args: array of const); - procedure SetNumbersTested( Value: integer); - - public - property PrimalityTestCount: integer read FNumbersTested - write SetNumbersTested; - end; - -var - mfmMakeSampleKey: TmfmMakeSampleKey; - -implementation - - - - - - - - - - - - - - - -uses SysUtils, TPLB3.RSA_Primitives, TPLB3.HugeCardinalUtils, - TPLB3.HugeCardinal, TPLB3.StreamUtils, TPLB3.AES, TPLB3.HashDsc, - TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Random, - TPLB3.Asymetric, TPLB3.Constants, StrUtils; -{$R *.dfm} - -const - MinBits = 256; - MaxBits = 4096; - - -procedure TmfmMakeSampleKey.FormCreate( Sender: TObject); -begin -FPool := NewPool; -FwasAborted := False; -FNumbersTested := 0; -memoOutput.Clear; -FisGeneratingKeys := False -end; - -procedure TmfmMakeSampleKey.FormDestroy( Sender: TObject); -begin -FPool := nil -end; - - -procedure TmfmMakeSampleKey.btnGenRSAClick( Sender: TObject); -var - RequiredBitLengthOfN: integer; - N, e, d, Totient: THugeCardinal; - S: TDateTime; - LocalNumbersTested: integer; - LocalWasAborted: boolean; - Secs: integer; - Tmp: TStream; - Code: integer; - p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. - - procedure ReportHugeCardinal( const Label1: string; Value: THugeCardinal); - var - B64: ansistring; - begin - Tmp.Size := 0; - Value.StreamOut( LittleEndien, Tmp, (Value.BitLength + 7) div 8); - B64 := Stream_to_Base64( Tmp); - PutFmt( '%s (little-endien; base64) = "%s";', [Label1, B64]); - Put( '') - end; - -begin -FwasAborted := False; -LocalWasAborted := False; -FNumbersTested := 0; -LocalNumbersTested := 0; -btnAbort.Enabled := True; -Val( edtKeySize.Text, RequiredBitLengthOfN, Code); -if (edtKeySize.Text='') or (Code <> 0) or - (RequiredBitLengthOfN < MinBits) or - (RequiredBitLengthOfN > MaxBits) then - begin - PutFmt( 'Key size ("%s") invalid or out of range.', - [edtKeySize.Text]); - PutFmt( 'Correct range is %d bits to %d bits.', - [MinBits, MaxBits]); - exit - end; -Tmp := FPool.NewMemoryStream( 0); -try -PutFmt( 'Now generating an RSA-%d key pair', [RequiredBitLengthOfN]); -S := Now; -Compute_RSA_Fundamentals_2Factors( - RequiredBitLengthOfN, StandardExponent, - N, e, d, Totient, - p, q, dp, dq, qinv, - GenRSA_Progress, GenRSA_TPrimalityTestNotice, - 5, FPool, - LocalNumbersTested, LocalWasAborted); -if LocalWasAborted then - Put( 'Generation aborted by user.') - else - begin - Put( 'Generation completed.'); - Secs := Round( (Now - S) * SecsPerDay); - PutFmt( 'Generation took %ds.', [Secs]); - PutFmt( '%d primality tests were conducted to reach this goal,', [LocalNumbersTested]); - PutFmt( 'at a rate of %.1f tests per second.', [LocalNumbersTested / Secs]); - Put( ''); - PutFmt( 'n has %d bits.', [N.BitLength]); - PutFmt( 'e has %d bits.', [e.BitLength]); - PutFmt( 'd has %d bits.', [d.BitLength]); - ReportHugeCardinal( 'n', n); - ReportHugeCardinal( 'e', e); - PutFmt( 'e (decimal) = %d', [StandardExponent]); - Put( ''); - ReportHugeCardinal( 'd', d); - Put( '') - end; -finally -Tmp.Free; -btnAbort.Enabled := False; -N.Free; -e.Free; -d.Free; -Totient.Free; -p.Free; q.Free; dp.Free; dq.Free; qinv.Free; -end end; - - -function RsaEncString( const PublicKey: ansistring; const SrcString : String): ansistring; -var - Codec : TCodec; - wasAborted: boolean; - KeyPair: TAsymetricKeyPair; - KeyAsStream : TMemoryStream; - Key: TSymetricKey; - lib : TCryptographicLibrary; -begin - result := ''; - Codec := TCodec.Create(Nil); - lib := TCryptographicLibrary.Create(Nil); - try - //0. Reset - Codec.Reset; - Codec.CryptoLibrary := lib; - Codec.ChainModeId := ECB_ProgId; - - //1. Set the cipher to RSA encryption. - Codec.StreamCipherId := RSA_ProgId; - - //2. Load our pre-fabricated public key. - KeyAsStream := TMemoryStream.Create; - try - Base64_to_stream(PublicKey, KeyAsStream); - KeyAsStream.Position := 0; - Codec.AsymetricKeySizeInBits := 512; - Key := Codec.Asymetric_Engine.CreateFromStream(KeyAsStream, [partPublic]); - - //3. Now set the key. - Codec.InitFromKey(Key); - finally - KeyAsStream.Free; - end; - Codec.EncryptString( SrcString, result); - finally - lib.Free; - Codec.Free; - end; -end; - -function RsaDecString(const PrivateKey, SrcString : AnsiString): string; -var - Codec : TCodec; - wasAborted: boolean; - KeyPair: TAsymetricKeyPair; - KeyAsStream : TMemoryStream; - Key: TSymetricKey; - lib : TCryptographicLibrary; -begin - result := ''; - Codec := TCodec.Create(Nil); - lib := TCryptographicLibrary.Create(Nil); - try - //0. Reset - Codec.Reset; - Codec.CryptoLibrary := lib; - Codec.ChainModeId := ECB_ProgId; - - //1. Set the cipher to RSA encryption. - Codec.StreamCipherId := RSA_ProgId; - - //2. Load our pre-fabricated private key. - KeyAsStream := TMemoryStream.Create; - try - Base64_to_stream(PrivateKey, KeyAsStream); - KeyAsStream.Position := 0; - Codec.AsymetricKeySizeInBits := 512; - Key := Codec.Asymetric_Engine.CreateFromStream(KeyAsStream, [partPrivate]); - - //3. Now set the key. - Codec.InitFromKey(Key); - finally - KeyAsStream.Free; - end; - - Codec.DecryptString( result, SrcString); - finally - lib.Free; - Codec.Free; - end; -end; - - -procedure TmfmMakeSampleKey.btnGenCompRSAKeysClick( Sender: TObject); -var - Mem: TStream; - RequiredBitLengthOfN, Code: integer; - PublicKey, PrivateKey: ansistring; - Plaintext, Reconstruct: string; - Ciphertext: ansistring; - Ok: boolean; -begin -FisGeneratingKeys := True; -Mem := TMemoryStream.Create; -try - Val( edtKeySize.Text, RequiredBitLengthOfN, Code); - if (edtKeySize.Text='') or (Code <> 0) then - begin - Put( ''); - exit; - end; - if RequiredBitLengthOfN < MinBits then - RequiredBitLengthOfN := MinBits; - if RequiredBitLengthOfN > MaxBits then - RequiredBitLengthOfN := MaxBits; - PutFmt( 'Generating two key pairs of size %d.', [RequiredBitLengthOfN]); - Signatory1.Codec.AsymetricKeySizeInBits := RequiredBitLengthOfN; - Signatory1.GenerateKeys; - Signatory1.StoreKeysToStream( Mem, [partPublic]); - PublicKey := Stream_to_Base64( Mem); - PutFmt( 'Public key = "%s"', [PublicKey]); - Mem.Size := 0; - Signatory1.StoreKeysToStream( Mem, [partPrivate]); - PrivateKey := Stream_to_Base64( Mem); - PutFmt( 'Private key = "%s"', [PrivateKey]); -finally - FisGeneratingKeys := False; - Mem.Free -end; -Put( 'Now performing a general inversion test (self-test)...'); -try - Plaintext := 'Your lip''s are smoother than vasoline.'; - Ciphertext := RsaEncString( PublicKey, Plaintext); - Reconstruct := RsaDecString( PrivateKey, Ciphertext); - Ok := Reconstruct = Plaintext; -except - Ok := False - end; -PutFmt( 'Self-test result = %s', [IfThen( Ok, 'Pass', 'Fail')]) -end; - - -function TmfmMakeSampleKey.Codec1Progress( - Sender: TObject; CountBytesProcessed: Int64): Boolean; -begin -result := True; -if FisGeneratingKeys then - GenRSA_TPrimalityTestNotice( - Codec1.FGenerateAsymetricKeyPairProgress_CountPrimalityTests) -end; - - -procedure TmfmMakeSampleKey.GenRSA_Progress( - Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); -begin -Application.ProcessMessages; -doAbort := FwasAborted -end; - -procedure TmfmMakeSampleKey.GenRSA_TPrimalityTestNotice( - CountPrimalityTests: integer); -begin -Application.ProcessMessages; -PrimalityTestCount := CountPrimalityTests -end; - -procedure TmfmMakeSampleKey.Put(const Line: string); -begin -memoOutput.Lines.Add( Line) -end; - - - -procedure TmfmMakeSampleKey.PutFmt( - const Line: string; const Args: array of const); -begin -Put( Format( Line, Args)) -end; - - - -procedure TmfmMakeSampleKey.SetNumbersTested( Value: integer); -begin -FNumbersTested := Value; -lblCountPrimalityTestsValue.Caption := Format( '%d', [FNumbersTested]) -end; - - -procedure TmfmMakeSampleKey.btnAbortClick( Sender: TObject); -begin -FwasAborted := True; -(Sender as TButton).Enabled := False -end; - - - -procedure TmfmMakeSampleKey.btnGenAES256Click( Sender: TObject); -var - AES: IBlockCipher; - KeyStream: TMemoryStream; - Tmp: TStream; - Key: TSymetricKey; - KeySize: integer; - -begin -KeyStream := nil; -Tmp := nil; -Key := nil; -KeySize := 256; -AES := TAES.Create( KeySize) as IBlockCipher; -try -KeyStream := FPool.NewMemoryStream( AES.KeySize div 8); -RandomFillStream( KeyStream); -KeyStream.Position := 0; -Key := AES.GenerateKey( KeyStream); -Tmp := FPool.NewMemoryStream( 0); -Key.SaveToStream( Tmp); -PutFmt( 'AES-%d key (base64) = "%s";', [KeySize, Stream_to_Base64( Tmp)]); -finally -Tmp.Free; -Key.Free; -KeyStream.Free -end end; - - -end. +unit umfmMakeSampleKey; + +interface + +uses + Windows, Messages, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, TPLB3.MemoryStreamPool, TPLB3.Signatory, TPLB3.Codec, + TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, TPLB3.Hash; + +type + TmfmMakeSampleKey = class(TForm) + btnGenRSA: TButton; + memoOutput: TMemo; + btnGenAES256: TButton; + btnAbort: TButton; + lblCountPrimalityTests: TLabel; + lblCountPrimalityTestsValue: TLabel; + lblKeySize: TLabel; + edtKeySize: TEdit; + CryptographicLibrary1: TCryptographicLibrary; + Codec1: TCodec; + btnGenCompRSAKeys: TButton; + Hash1: THash; + Signatory1: TSignatory; + procedure btnGenRSAClick(Sender: TObject); + procedure btnGenAES256Click(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure btnAbortClick(Sender: TObject); + procedure btnGenCompRSAKeysClick(Sender: TObject); + function Codec1Progress(Sender: TObject; + CountBytesProcessed: Int64): Boolean; + + private + FPool: IMemoryStreamPool; + FNumbersTested: integer; + FwasAborted: boolean; + FisGeneratingKeys: boolean; + + procedure GenRSA_Progress( + Sender: TObject; BitsProcessed, TotalBits: int64; + var doAbort: boolean); + + procedure GenRSA_TPrimalityTestNotice( CountPrimalityTests: integer); + + procedure Put( const Line: string); + procedure PutFmt( const Line: string; const Args: array of const); + procedure SetNumbersTested( Value: integer); + + public + property PrimalityTestCount: integer read FNumbersTested + write SetNumbersTested; + end; + +var + mfmMakeSampleKey: TmfmMakeSampleKey; + +implementation + + + + + + + + + + + + + + + +uses SysUtils, TPLB3.RSA_Primitives, TPLB3.HugeCardinalUtils, + TPLB3.HugeCardinal, TPLB3.StreamUtils, TPLB3.AES, TPLB3.HashDsc, + TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Random, + TPLB3.Asymetric, TPLB3.Constants, StrUtils; +{$R *.dfm} + +const + MinBits = 256; + MaxBits = 4096; + + +procedure TmfmMakeSampleKey.FormCreate( Sender: TObject); +begin +FPool := NewPool; +FwasAborted := False; +FNumbersTested := 0; +memoOutput.Clear; +FisGeneratingKeys := False +end; + +procedure TmfmMakeSampleKey.FormDestroy( Sender: TObject); +begin +FPool := nil +end; + + +procedure TmfmMakeSampleKey.btnGenRSAClick( Sender: TObject); +var + RequiredBitLengthOfN: integer; + N, e, d, Totient: THugeCardinal; + S: TDateTime; + LocalNumbersTested: integer; + LocalWasAborted: boolean; + Secs: integer; + Tmp: TStream; + Code: integer; + p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. + + procedure ReportHugeCardinal( const Label1: string; Value: THugeCardinal); + var + B64: ansistring; + begin + Tmp.Size := 0; + Value.StreamOut( LittleEndien, Tmp, (Value.BitLength + 7) div 8); + B64 := Stream_to_Base64( Tmp); + PutFmt( '%s (little-endien; base64) = "%s";', [Label1, B64]); + Put( '') + end; + +begin +FwasAborted := False; +LocalWasAborted := False; +FNumbersTested := 0; +LocalNumbersTested := 0; +btnAbort.Enabled := True; +Val( edtKeySize.Text, RequiredBitLengthOfN, Code); +if (edtKeySize.Text='') or (Code <> 0) or + (RequiredBitLengthOfN < MinBits) or + (RequiredBitLengthOfN > MaxBits) then + begin + PutFmt( 'Key size ("%s") invalid or out of range.', + [edtKeySize.Text]); + PutFmt( 'Correct range is %d bits to %d bits.', + [MinBits, MaxBits]); + exit + end; +Tmp := FPool.NewMemoryStream( 0); +try +PutFmt( 'Now generating an RSA-%d key pair', [RequiredBitLengthOfN]); +S := Now; +Compute_RSA_Fundamentals_2Factors( + RequiredBitLengthOfN, StandardExponent, + N, e, d, Totient, + p, q, dp, dq, qinv, + GenRSA_Progress, GenRSA_TPrimalityTestNotice, + 5, FPool, + LocalNumbersTested, LocalWasAborted); +if LocalWasAborted then + Put( 'Generation aborted by user.') + else + begin + Put( 'Generation completed.'); + Secs := Round( (Now - S) * SecsPerDay); + PutFmt( 'Generation took %ds.', [Secs]); + PutFmt( '%d primality tests were conducted to reach this goal,', [LocalNumbersTested]); + PutFmt( 'at a rate of %.1f tests per second.', [LocalNumbersTested / Secs]); + Put( ''); + PutFmt( 'n has %d bits.', [N.BitLength]); + PutFmt( 'e has %d bits.', [e.BitLength]); + PutFmt( 'd has %d bits.', [d.BitLength]); + ReportHugeCardinal( 'n', n); + ReportHugeCardinal( 'e', e); + PutFmt( 'e (decimal) = %d', [StandardExponent]); + Put( ''); + ReportHugeCardinal( 'd', d); + Put( '') + end; +finally +Tmp.Free; +btnAbort.Enabled := False; +N.Free; +e.Free; +d.Free; +Totient.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +end end; + + +function RsaEncString( const PublicKey: ansistring; const SrcString : String): ansistring; +var + Codec : TCodec; + wasAborted: boolean; + KeyPair: TAsymetricKeyPair; + KeyAsStream : TMemoryStream; + Key: TSymetricKey; + lib : TCryptographicLibrary; +begin + result := ''; + Codec := TCodec.Create(Nil); + lib := TCryptographicLibrary.Create(Nil); + try + //0. Reset + Codec.Reset; + Codec.CryptoLibrary := lib; + Codec.ChainModeId := ECB_ProgId; + + //1. Set the cipher to RSA encryption. + Codec.StreamCipherId := RSA_ProgId; + + //2. Load our pre-fabricated public key. + KeyAsStream := TMemoryStream.Create; + try + Base64_to_stream(PublicKey, KeyAsStream); + KeyAsStream.Position := 0; + Codec.AsymetricKeySizeInBits := 512; + Key := Codec.Asymetric_Engine.CreateFromStream(KeyAsStream, [partPublic]); + + //3. Now set the key. + Codec.InitFromKey(Key); + finally + KeyAsStream.Free; + end; + Codec.EncryptString( SrcString, result); + finally + lib.Free; + Codec.Free; + end; +end; + +function RsaDecString(const PrivateKey, SrcString : AnsiString): string; +var + Codec : TCodec; + wasAborted: boolean; + KeyPair: TAsymetricKeyPair; + KeyAsStream : TMemoryStream; + Key: TSymetricKey; + lib : TCryptographicLibrary; +begin + result := ''; + Codec := TCodec.Create(Nil); + lib := TCryptographicLibrary.Create(Nil); + try + //0. Reset + Codec.Reset; + Codec.CryptoLibrary := lib; + Codec.ChainModeId := ECB_ProgId; + + //1. Set the cipher to RSA encryption. + Codec.StreamCipherId := RSA_ProgId; + + //2. Load our pre-fabricated private key. + KeyAsStream := TMemoryStream.Create; + try + Base64_to_stream(PrivateKey, KeyAsStream); + KeyAsStream.Position := 0; + Codec.AsymetricKeySizeInBits := 512; + Key := Codec.Asymetric_Engine.CreateFromStream(KeyAsStream, [partPrivate]); + + //3. Now set the key. + Codec.InitFromKey(Key); + finally + KeyAsStream.Free; + end; + + Codec.DecryptString( result, SrcString); + finally + lib.Free; + Codec.Free; + end; +end; + + +procedure TmfmMakeSampleKey.btnGenCompRSAKeysClick( Sender: TObject); +var + Mem: TStream; + RequiredBitLengthOfN, Code: integer; + PublicKey, PrivateKey: ansistring; + Plaintext, Reconstruct: string; + Ciphertext: ansistring; + Ok: boolean; +begin +FisGeneratingKeys := True; +Mem := TMemoryStream.Create; +try + Val( edtKeySize.Text, RequiredBitLengthOfN, Code); + if (edtKeySize.Text='') or (Code <> 0) then + begin + Put( ''); + exit; + end; + if RequiredBitLengthOfN < MinBits then + RequiredBitLengthOfN := MinBits; + if RequiredBitLengthOfN > MaxBits then + RequiredBitLengthOfN := MaxBits; + PutFmt( 'Generating two key pairs of size %d.', [RequiredBitLengthOfN]); + Signatory1.Codec.AsymetricKeySizeInBits := RequiredBitLengthOfN; + Signatory1.GenerateKeys; + Signatory1.StoreKeysToStream( Mem, [partPublic]); + PublicKey := Stream_to_Base64( Mem); + PutFmt( 'Public key = "%s"', [PublicKey]); + Mem.Size := 0; + Signatory1.StoreKeysToStream( Mem, [partPrivate]); + PrivateKey := Stream_to_Base64( Mem); + PutFmt( 'Private key = "%s"', [PrivateKey]); +finally + FisGeneratingKeys := False; + Mem.Free +end; +Put( 'Now performing a general inversion test (self-test)...'); +try + Plaintext := 'Your lip''s are smoother than vasoline.'; + Ciphertext := RsaEncString( PublicKey, Plaintext); + Reconstruct := RsaDecString( PrivateKey, Ciphertext); + Ok := Reconstruct = Plaintext; +except + Ok := False + end; +PutFmt( 'Self-test result = %s', [IfThen( Ok, 'Pass', 'Fail')]) +end; + + +function TmfmMakeSampleKey.Codec1Progress( + Sender: TObject; CountBytesProcessed: Int64): Boolean; +begin +result := True; +if FisGeneratingKeys then + GenRSA_TPrimalityTestNotice( + Codec1.FGenerateAsymetricKeyPairProgress_CountPrimalityTests) +end; + + +procedure TmfmMakeSampleKey.GenRSA_Progress( + Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); +begin +Application.ProcessMessages; +doAbort := FwasAborted +end; + +procedure TmfmMakeSampleKey.GenRSA_TPrimalityTestNotice( + CountPrimalityTests: integer); +begin +Application.ProcessMessages; +PrimalityTestCount := CountPrimalityTests +end; + +procedure TmfmMakeSampleKey.Put(const Line: string); +begin +memoOutput.Lines.Add( Line) +end; + + + +procedure TmfmMakeSampleKey.PutFmt( + const Line: string; const Args: array of const); +begin +Put( Format( Line, Args)) +end; + + + +procedure TmfmMakeSampleKey.SetNumbersTested( Value: integer); +begin +FNumbersTested := Value; +lblCountPrimalityTestsValue.Caption := Format( '%d', [FNumbersTested]) +end; + + +procedure TmfmMakeSampleKey.btnAbortClick( Sender: TObject); +begin +FwasAborted := True; +(Sender as TButton).Enabled := False +end; + + + +procedure TmfmMakeSampleKey.btnGenAES256Click( Sender: TObject); +var + AES: IBlockCipher; + KeyStream: TMemoryStream; + Tmp: TStream; + Key: TSymetricKey; + KeySize: integer; + +begin +KeyStream := nil; +Tmp := nil; +Key := nil; +KeySize := 256; +AES := TAES.Create( KeySize) as IBlockCipher; +try +KeyStream := FPool.NewMemoryStream( AES.KeySize div 8); +RandomFillStream( KeyStream); +KeyStream.Position := 0; +Key := AES.GenerateKey( KeyStream); +Tmp := FPool.NewMemoryStream( 0); +Key.SaveToStream( Tmp); +PutFmt( 'AES-%d key (base64) = "%s";', [KeySize, Stream_to_Base64( Tmp)]); +finally +Tmp.Free; +Key.Free; +KeyStream.Free +end end; + + +end. diff --git a/demo/D2010+/umfmLockbox3_Demo.dfm b/LockBox3/demo/D2010+/umfmLockbox3_Demo.dfm similarity index 96% rename from demo/D2010+/umfmLockbox3_Demo.dfm rename to LockBox3/demo/D2010+/umfmLockbox3_Demo.dfm index 074516d..d520bfe 100644 --- a/demo/D2010+/umfmLockbox3_Demo.dfm +++ b/LockBox3/demo/D2010+/umfmLockbox3_Demo.dfm @@ -1,1658 +1,1678 @@ -object mfmLockbox3_Demo: TmfmLockbox3_Demo - Left = 0 - Top = 0 - Caption = 'Lockbox 3 Demonstration Program' - ClientHeight = 569 - ClientWidth = 763 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poDesktopCenter - Scaled = False - OnCreate = FormCreate - OnDestroy = FormDestroy - PixelsPerInch = 96 - TextHeight = 13 - object memoLog: TMemo - Left = 520 - Top = 0 - Width = 243 - Height = 569 - Align = alRight - Color = clInfoBk - Lines.Strings = ( - '[Output log goes here.]') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object pcClient: TPageControl - Left = 0 - Top = 0 - Width = 520 - Height = 569 - ActivePage = tbSignature - Align = alClient - MultiLine = True - TabOrder = 1 - object tbSymetric: TTabSheet - Caption = '1. Symetric basics' - DesignSize = ( - 512 - 523) - object lblPlaintextFile: TLabel - Left = 3 - Top = 152 - Width = 46 - Height = 13 - Caption = 'Plaintext:' - FocusControl = edtPlaintextFile - end - object lblCiphertextFile: TLabel - Left = 3 - Top = 176 - Width = 55 - Height = 13 - Caption = 'Ciphertext:' - FocusControl = edtCiphertextFile - end - object lblReconPlaintext: TLabel - Left = 9 - Top = 253 - Width = 73 - Height = 26 - Caption = 'Reconstructed plaintext:' - FocusControl = edtReconPlaintext - WordWrap = True - end - object shDivider_SymetricEncrypt: TShape - Left = 4 - Top = 234 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object shDivider_SymetricDecrypt: TShape - Left = 4 - Top = 311 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object edtPlaintextFile: TButtonedEdit - Left = 64 - Top = 149 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 0 - Text = '' - OnRightButtonClick = edtPlaintextFileRightButtonClick - end - object edtCiphertextFile: TButtonedEdit - Left = 64 - Top = 176 - Width = 446 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 1 - Text = '' - OnRightButtonClick = edtCiphertextFileRightButtonClick - end - object rgCipher: TRadioGroup - Left = 3 - Top = 16 - Width = 118 - Height = 127 - Caption = 'Cipher' - ItemIndex = 0 - Items.Strings = ( - 'AES-128' - 'AES-192' - 'AES-256' - 'DES' - '3DES (KO 1)' - '3DES (KO 2)' - 'Blowfish' - 'Twofish' - 'XXTEA') - TabOrder = 2 - OnClick = rgCipherClick - end - object rgChain: TRadioGroup - Left = 127 - Top = 16 - Width = 161 - Height = 127 - Caption = 'Chaining mode' - Columns = 2 - ItemIndex = 1 - Items.Strings = ( - 'ECB' - 'CBC' - 'PCBC' - 'CFB' - 'CFB 8-bit' - 'CTR' - 'OFB') - TabOrder = 3 - OnClick = rgChainClick - end - object lblPassword: TLabeledEdit - Left = 294 - Top = 32 - Width = 215 - Height = 21 - Anchors = [akLeft, akTop, akRight] - EditLabel.Width = 50 - EditLabel.Height = 13 - EditLabel.Caption = 'Password:' - TabOrder = 4 - Text = 'I love LockBox 3' - OnExit = lblPasswordExit - end - object btnSymetricEncrypt: TButton - Left = 160 - Top = 203 - Width = 75 - Height = 25 - Action = actEncryptSymetric - TabOrder = 5 - end - object edtReconPlaintext: TButtonedEdit - Left = 90 - Top = 250 - Width = 420 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 6 - Text = '' - OnRightButtonClick = edtReconPlaintextRightButtonClick - end - object btnSymetricDecrypt: TButton - Left = 160 - Top = 280 - Width = 75 - Height = 25 - Action = actSymetricDecrypt - TabOrder = 7 - end - object btnSymetricCompare: TButton - Left = 160 - Top = 344 - Width = 179 - Height = 25 - Action = actSymetricCompare - TabOrder = 8 - end - object btnSymetricEncrypt_Abort: TButton - Left = 264 - Top = 203 - Width = 75 - Height = 25 - Action = actSymetricEncrypt_Abort - TabOrder = 9 - end - object btnSymetricDecrypt_Abort: TButton - Left = 264 - Top = 280 - Width = 75 - Height = 25 - Action = actSymetricDecrypt_Abort - TabOrder = 10 - end - object pbarSymetric: TProgressBar - Left = 0 - Top = 502 - Width = 512 - Height = 21 - Align = alBottom - TabOrder = 11 - end - end - object tbSeeding: TTabSheet - Caption = '2. Seeding' - ImageIndex = 1 - object bvlScriblePad: TBevel - Left = 4 - Top = 342 - Width = 506 - Height = 147 - end - object lblCurrentSeedLabel: TLabel - Left = 3 - Top = 184 - Width = 243 - Height = 13 - Caption = 'Current seed (unsigned 64 bit big-endien heximal):' - end - object lblCurrentSeed: TLabel - Left = 252 - Top = 184 - Width = 144 - Height = 16 - Caption = 'FFFFFFFFFFFFFFFF' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -16 - Font.Name = 'Courier' - Font.Style = [] - ParentFont = False - end - object imgScribblePad: TImage - Left = 16 - Top = 352 - Width = 481 - Height = 121 - OnMouseMove = imgScribblePadMouseMove - end - object memoInstructions: TMemo - Left = 3 - Top = 3 - Width = 422 - Height = 175 - Color = clInfoBk - Lines.Strings = ( - - 'TurboPower LockBox 3 has good strong pseudo-random number genera' + - 'tor,' - - '(PRNG) which is used extensivley by most of the functions of the' + - ' library.' - - 'The PRNG is based on a seed. A PRGN is only as strong as the ent' + - 'ropy' - 'in its seed, so how you seed the library is important.' - '' - - 'By default, TPLB3 is seeded by MS CryptoAPI. However if your app' + - 'lication' - - 'requires independance from black boxes, you may prefer to roll y' + - 'our own' - 'seed. This would normally be done at program start-up time.' - '' - - 'The scribble-pad for seeding is not formally a part of TPLB3. It' + - 's just' - - 'a simple example of how you can roll your own seed. Adapt as you' + - 'r problem' - 'requires.' - '' - '') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object rgSeedingMethod: TRadioGroup - Left = 4 - Top = 215 - Width = 505 - Height = 90 - Caption = 'Seeding method' - ItemIndex = 0 - Items.Strings = ( - - 'Microsoft CryptoAPI (RtlGenRandom function. Ref: http://en.wikip' + - 'edia.org/wiki/CryptGenRandom)' - 'Your input (unsigned 64 bit big-endien hex):' - 'True random using the Scrible pad below') - TabOrder = 1 - end - object btnSetSeed: TButton - Left = 200 - Top = 311 - Width = 75 - Height = 25 - Action = actSetSeed - TabOrder = 2 - end - object btnAbortScribble: TButton - Left = 404 - Top = 495 - Width = 105 - Height = 25 - Action = actAbortScribble - TabOrder = 3 - end - object pbarScribblePad: TProgressBar - Left = 3 - Top = 495 - Width = 395 - Height = 17 - TabOrder = 4 - end - object edtUserInputSeed: TEdit - Left = 252 - Top = 256 - Width = 121 - Height = 21 - TabOrder = 5 - Text = 'FFFFFFFFFFFFFFFF' - end - end - object tbSymetricExtent: TTabSheet - Caption = '3. Symetric extensions' - ImageIndex = 2 - DesignSize = ( - 512 - 523) - object Label1: TLabel - Left = 0 - Top = 248 - Width = 46 - Height = 13 - Caption = 'Plaintext:' - FocusControl = edtCustomBlockPlaintextFile - end - object Label2: TLabel - Left = 0 - Top = 272 - Width = 55 - Height = 13 - Caption = 'Ciphertext:' - FocusControl = edtCustomBlockCiphertextFile - end - object Shape1: TShape - Left = 1 - Top = 330 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object Label3: TLabel - Left = 3 - Top = 340 - Width = 73 - Height = 26 - Caption = 'Reconstructed plaintext:' - FocusControl = edtCustomBlockReconPlaintext - WordWrap = True - end - object Shape2: TShape - Left = 1 - Top = 295 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object Label4: TLabel - Left = 3 - Top = 3 - Width = 470 - Height = 29 - Caption = 'Easy-peasy custom block-mode ciphers' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -24 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object rgCustomBlockChain: TRadioGroup - Left = 100 - Top = 136 - Width = 161 - Height = 89 - Caption = 'Chaining mode' - Columns = 2 - ItemIndex = 1 - Items.Strings = ( - 'ECB' - 'CBC' - 'PCBC' - 'CFB' - 'CFB 8-bit' - 'CTR' - 'OFB') - TabOrder = 0 - OnClick = rgChainClick - end - object lblCustomBlockPassword: TLabeledEdit - Left = 277 - Top = 152 - Width = 229 - Height = 21 - Anchors = [akLeft, akTop, akRight] - EditLabel.Width = 50 - EditLabel.Height = 13 - EditLabel.Caption = 'Password:' - TabOrder = 1 - Text = 'I love LockBox 3' - OnExit = lblPasswordExit - end - object edtCustomBlockPlaintextFile: TButtonedEdit - Left = 61 - Top = 245 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 2 - Text = '' - OnRightButtonClick = edtCustomBlockPlaintextFileRightButtonClick - end - object edtCustomBlockCiphertextFile: TButtonedEdit - Left = 61 - Top = 272 - Width = 446 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 3 - Text = '' - OnRightButtonClick = edtCustomBlockCiphertextFileRightButtonClick - end - object Button1: TButton - Left = 157 - Top = 299 - Width = 75 - Height = 25 - Action = actCustomBlockEncrypt - TabOrder = 4 - end - object Button2: TButton - Left = 261 - Top = 299 - Width = 75 - Height = 25 - Action = actCustomBlockEncryptAbort - TabOrder = 5 - end - object edtCustomBlockReconPlaintext: TButtonedEdit - Left = 87 - Top = 346 - Width = 420 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 6 - Text = '' - OnRightButtonClick = edtCustomBlockReconPlaintextRightButtonClick - end - object Button3: TButton - Left = 157 - Top = 376 - Width = 75 - Height = 25 - Action = actCustomBlockDecrypt - TabOrder = 7 - end - object Button4: TButton - Left = 261 - Top = 376 - Width = 75 - Height = 25 - Action = actCustomBlockDecryptAbort - TabOrder = 8 - end - object Button5: TButton - Left = 157 - Top = 440 - Width = 179 - Height = 25 - Action = actCustomBlockSymetricCompare - TabOrder = 9 - end - object pbarCustom: TProgressBar - Left = 0 - Top = 502 - Width = 512 - Height = 21 - Align = alBottom - TabOrder = 10 - end - object memoCustomBlockInstruction: TMemo - Left = 3 - Top = 36 - Width = 503 - Height = 94 - Color = clInfoBk - Lines.Strings = ( - - 'You can extend LockBox'#39's collection of stream ciphers simply by ' + - 'defining an invertable block ' - - 'transform. This page uses a Caesar cipher block transform (sourc' + - 'e code is in unit' - 'uDemoBlockModeCipher).' - '' - - 'With the tranform defined, all the normal block mode features (c' + - 'hoice of block chaining modes,' - 'auto-salting) come free.' - '' - '') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 11 - end - end - object tbKeyGen: TTabSheet - Caption = '4. RSA - Key generation and storage' - ImageIndex = 3 - DesignSize = ( - 512 - 523) - object Shape3: TShape - Left = 3 - Top = 82 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object lblKeyStorageFile: TLabel - Left = 3 - Top = 104 - Width = 41 - Height = 13 - Caption = 'Key File:' - FocusControl = edtKeyStorageFile - end - object lblPrimalityTests: TLabel - Left = 16 - Top = 64 - Width = 140 - Height = 13 - Caption = 'Primality tests conducted = 0' - end - object btnRSAGen: TButton - Left = 3 - Top = 32 - Width = 174 - Height = 25 - Action = actRSAGen - TabOrder = 0 - end - object btnAbortGen: TButton - Left = 224 - Top = 32 - Width = 129 - Height = 25 - Action = actAbortRSAGen - TabOrder = 1 - end - object edtKeyStorageFile: TButtonedEdit - Left = 63 - Top = 101 - Width = 446 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 2 - Text = '' - OnRightButtonClick = edtKeyStorageFileRightButtonClick - end - object btnStoreFullKey: TButton - Left = 40 - Top = 144 - Width = 89 - Height = 25 - Action = actStoreFullKey - TabOrder = 3 - end - object btnPublicStore: TButton - Left = 135 - Top = 144 - Width = 98 - Height = 25 - Action = actStorePublicKey - TabOrder = 4 - end - object btnLoadFullKey: TButton - Left = 296 - Top = 144 - Width = 98 - Height = 25 - Action = actLoadFullKey - TabOrder = 5 - end - object btnPublicLoad: TButton - Left = 400 - Top = 144 - Width = 97 - Height = 25 - Action = actLoadPublicKey - TabOrder = 6 - end - end - object tbSignature: TTabSheet - Caption = '5. RSA - Signature && Verification' - ImageIndex = 4 - DesignSize = ( - 512 - 523) - object lblRSAPlaintextFile: TLabel - Left = 3 - Top = 6 - Width = 46 - Height = 13 - Caption = 'Plaintext:' - FocusControl = edtRSAPlaintextFile - end - object lblRSACiphertextFile: TLabel - Left = 3 - Top = 30 - Width = 55 - Height = 13 - Caption = 'Ciphertext:' - FocusControl = edtRSACiphertextFile - end - object shDivider_RSAEncrypt: TShape - Left = 4 - Top = 53 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object lblRSAReconFile: TLabel - Left = 6 - Top = 98 - Width = 73 - Height = 26 - Caption = 'Reconstructed plaintext:' - FocusControl = edtRSAReconFile - WordWrap = True - end - object shDivider_RSASign: TShape - Left = 3 - Top = 245 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object Label9: TLabel - Left = 8 - Top = 270 - Width = 52 - Height = 13 - Caption = 'Document:' - FocusControl = edtRSADocumentFile - end - object lblRSADocumentFile: TLabel - Left = 8 - Top = 294 - Width = 50 - Height = 13 - Caption = 'Signature:' - FocusControl = edtRSASignatureFile - end - object edtRSAPlaintextFile: TButtonedEdit - Left = 64 - Top = 3 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 0 - Text = '' - OnRightButtonClick = edtRSAPlaintextFileRightButtonClick - end - object edtRSACiphertextFile: TButtonedEdit - Left = 64 - Top = 30 - Width = 446 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 1 - Text = '' - OnRightButtonClick = edtRSACiphertextFileRightButtonClick - end - object btnRSAEncrypt: TButton - Left = 160 - Top = 57 - Width = 75 - Height = 25 - Action = actRSAEncrypt - TabOrder = 2 - end - object btnRSAEncryptAbort: TButton - Left = 264 - Top = 57 - Width = 75 - Height = 25 - Action = actRSAEncryptAbort - TabOrder = 3 - end - object edtRSAReconFile: TButtonedEdit - Left = 90 - Top = 104 - Width = 420 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 4 - Text = '' - OnRightButtonClick = edtRSAReconFileRightButtonClick - end - object btnRSADecrypt: TButton - Left = 160 - Top = 134 - Width = 75 - Height = 25 - Action = actRSADecrypt - TabOrder = 5 - end - object btnRSADecryptAbort: TButton - Left = 264 - Top = 134 - Width = 75 - Height = 25 - Action = actRSADecryptAbort - TabOrder = 6 - end - object btnRSACompare: TButton - Left = 160 - Top = 198 - Width = 179 - Height = 25 - Action = actRSACompare - TabOrder = 7 - end - object pbarRSA: TProgressBar - Left = 0 - Top = 502 - Width = 512 - Height = 21 - Align = alBottom - TabOrder = 8 - end - object edtRSADocumentFile: TButtonedEdit - Left = 64 - Top = 267 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 9 - Text = '' - OnRightButtonClick = edtRSADocumentFileRightButtonClick - end - object edtRSASignatureFile: TButtonedEdit - Left = 63 - Top = 294 - Width = 446 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 10 - Text = '' - OnRightButtonClick = edtRSASignatureFileRightButtonClick - end - object btnSign: TButton - Left = 90 - Top = 321 - Width = 75 - Height = 25 - Action = actSign - TabOrder = 11 - end - object btnSignVerifyAbort: TButton - Left = 365 - Top = 321 - Width = 75 - Height = 25 - Action = actSignVerifyAbort - TabOrder = 12 - end - object btnVerify: TButton - Left = 208 - Top = 321 - Width = 75 - Height = 25 - Action = actVerify - TabOrder = 13 - end - end - object tbHashes: TTabSheet - Caption = '6. Hashes' - ImageIndex = 5 - DesignSize = ( - 512 - 523) - object lblHashSourceFile: TLabel - Left = 3 - Top = 6 - Width = 54 - Height = 13 - Caption = 'Source file:' - FocusControl = edtHashSourceFile - end - object lblHashSourceString: TLabel - Left = 3 - Top = 144 - Width = 71 - Height = 13 - Caption = 'String to hash:' - FocusControl = edtHashSource - end - object edtHashSourceFile: TButtonedEdit - Left = 64 - Top = 3 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 0 - Text = '' - OnRightButtonClick = edtHashSourceFileRightButtonClick - end - object btnHash: TButton - Left = 112 - Top = 57 - Width = 123 - Height = 25 - Action = actHash - TabOrder = 1 - end - object btnHashAbort: TButton - Left = 264 - Top = 57 - Width = 75 - Height = 25 - Action = actAbortHash - TabOrder = 2 - end - object edtHashSource: TEdit - Left = 80 - Top = 144 - Width = 298 - Height = 21 - Anchors = [akLeft, akTop, akRight] - TabOrder = 3 - Text = 'abc' - end - object rgHashSource: TRadioGroup - Left = 384 - Top = 144 - Width = 126 - Height = 65 - Anchors = [akTop, akRight] - Caption = 'This string is of type ...' - ItemIndex = 0 - Items.Strings = ( - 'Ansistring' - 'UTF-16') - TabOrder = 4 - end - object btnComputeHash: TButton - Left = 80 - Top = 184 - Width = 241 - Height = 25 - Caption = 'Compute SHA-384 hash of above string' - TabOrder = 5 - OnClick = btnComputeHashClick - end - end - object tbOpenSSL: TTabSheet - Caption = '7. RSA via OpenSSL' - ImageIndex = 6 - DesignSize = ( - 512 - 523) - object lblOpenSSLDocument: TLabel - Left = 3 - Top = 400 - Width = 52 - Height = 13 - Caption = 'Document:' - FocusControl = edtOpenSSLDocument - end - object lblOpenSSLSignature: TLabel - Left = 3 - Top = 427 - Width = 50 - Height = 13 - Caption = 'Signature:' - FocusControl = edtOpenSSLSignature - end - object sepOpenSSLLibeay32: TShape - Left = 4 - Top = 130 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object Shape4: TShape - Left = 4 - Top = 244 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object Shape5: TShape - Left = 3 - Top = 348 - Width = 506 - Height = 4 - Anchors = [akLeft, akTop, akRight] - Brush.Color = clBlack - end - object btnOpenSSLLoadLib: TButton - Left = 103 - Top = 75 - Width = 75 - Height = 25 - Action = actOpenSSLLoadLib - TabOrder = 0 - end - object edtOpenSSLLibPath: TLabeledEdit - Left = 3 - Top = 48 - Width = 506 - Height = 21 - Anchors = [akLeft, akTop, akRight] - EditLabel.Width = 276 - EditLabel.Height = 13 - EditLabel.Caption = 'Path to libeay32.dll (leave empty to search system path):' - TabOrder = 1 - Text = 'V:\projects\openssl\win32 binaries\bin' - end - object btnOpenSSLUnloadLib: TButton - Left = 199 - Top = 75 - Width = 75 - Height = 25 - Action = actOpenSSLUnloadLib - TabOrder = 2 - end - object btnOpenSSLGenKey: TButton - Left = 3 - Top = 176 - Width = 205 - Height = 25 - Action = actOpenSSLGenKey - TabOrder = 3 - end - object btnOpenSSLLoadPrivateKey: TButton - Left = 239 - Top = 176 - Width = 107 - Height = 25 - Action = actOpenSSLLoadPrivateKey - TabOrder = 4 - end - object btnOpenSSLLoadPublicKey: TButton - Left = 376 - Top = 176 - Width = 121 - Height = 25 - Action = actOpenSSLLoadPublicKey - TabOrder = 5 - end - object btnOpenSSLSavePrivateKey: TButton - Left = 239 - Top = 296 - Width = 107 - Height = 25 - Action = actOpenSSLSavePrivateKey - TabOrder = 6 - end - object btnOpenSSLSavePublicKey: TButton - Left = 376 - Top = 296 - Width = 121 - Height = 25 - Action = actOpenSSLSavePublicKey - TabOrder = 7 - end - object edtOpenSSLDocument: TButtonedEdit - Left = 64 - Top = 397 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 8 - Text = '' - OnRightButtonClick = edtOpenSSLDocumentRightButtonClick - end - object btnOpenSSLSign: TButton - Left = 239 - Top = 472 - Width = 107 - Height = 25 - Action = actOpenSSLSign - TabOrder = 9 - end - object btnOpenSSLVerify: TButton - Left = 376 - Top = 472 - Width = 121 - Height = 25 - Action = actOpenSSLVerify - TabOrder = 10 - end - object edtOpenSSLSignature: TButtonedEdit - Left = 65 - Top = 424 - Width = 445 - Height = 21 - Anchors = [akLeft, akTop, akRight] - HideSelection = False - Images = imglstActionGlyphs_16x16 - RightButton.ImageIndex = 0 - RightButton.Visible = True - TabOrder = 11 - Text = '' - OnRightButtonClick = edtOpenSSLSignatureRightButtonClick - end - object rgOpenSSLHash: TRadioGroup - Left = 0 - Top = 451 - Width = 157 - Height = 57 - Caption = 'Hash for document' - ItemIndex = 0 - Items.Strings = ( - 'SHA-1' - 'MD5') - TabOrder = 12 - end - object pnlOpenSSLLibSection: TPanel - Left = 3 - Top = 3 - Width = 294 - Height = 22 - Caption = 'Linking to the OpenSSL library (libeay32.dll)' - Color = clMoneyGreen - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentBackground = False - ParentFont = False - TabOrder = 13 - end - object pnlOpenSSLKeyAcquisitionHeading: TPanel - Left = 3 - Top = 140 - Width = 294 - Height = 22 - Caption = 'Key acquisition' - Color = clMoneyGreen - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentBackground = False - ParentFont = False - TabOrder = 14 - end - object pnlOpenSSLKeySaving: TPanel - Left = 3 - Top = 255 - Width = 294 - Height = 22 - Caption = 'Key saving' - Color = clMoneyGreen - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentBackground = False - ParentFont = False - TabOrder = 15 - end - object pnlOpenSSLSignatureAndVerification: TPanel - Left = 3 - Top = 358 - Width = 294 - Height = 22 - Caption = 'Signature && Verification' - Color = clMoneyGreen - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentBackground = False - ParentFont = False - TabOrder = 16 - end - end - end - object actmngrMainDemoActions: TActionManager - Images = imglstActionGlyphs_16x16 - Left = 576 - Top = 32 - StyleName = 'Platform Default' - object actSelectPlaintext: TFileOpen - Category = 'Symetrics' - Caption = 'Plaintext' - Dialog.Options = [ofReadOnly, ofHideReadOnly, ofFileMustExist, ofEnableSizing] - Dialog.Title = 'Select plaintext file' - Hint = 'Plaintext|Selects an existing plaintext file' - ImageIndex = 0 - end - object actSelectCiphertext: TFileOpen - Category = 'Symetrics' - Caption = 'Ciphertext' - Dialog.Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] - Dialog.Title = 'Select ciphertext file' - Hint = 'Ciphertext|Selects output ciphertext file' - ImageIndex = 0 - end - object actSelectReconstructed: TFileOpen - Category = 'Symetrics' - Caption = 'ReconstructedPlaintext' - Hint = 'Open|Opens an existing file' - ImageIndex = 0 - end - object actEncryptSymetric: TAction - Category = 'Symetrics' - Caption = 'Encrypt' - OnExecute = actEncryptSymetricExecute - OnUpdate = actEncryptSymetricUpdate - end - object actSymetricEncrypt_Abort: TAction - Category = 'Symetrics' - Caption = 'Abort' - OnExecute = actSymetricEncrypt_AbortExecute - OnUpdate = actSymetricEncrypt_AbortUpdate - end - object actSymetricDecrypt: TAction - Category = 'Symetrics' - Caption = 'Decrypt' - OnExecute = actSymetricDecryptExecute - OnUpdate = actEncryptSymetricUpdate - end - object actSymetricDecrypt_Abort: TAction - Category = 'Symetrics' - Caption = 'Abort' - OnExecute = actSymetricDecrypt_AbortExecute - OnUpdate = actSymetricDecrypt_AbortUpdate - end - object actSymetricCompare: TAction - Category = 'Symetrics' - Caption = 'Compare with original' - OnExecute = actSymetricCompareExecute - OnUpdate = actEncryptSymetricUpdate - end - object actSetSeed: TAction - Category = 'Seeding' - Caption = 'Set Seed' - ImageIndex = 1 - OnExecute = actSetSeedExecute - OnUpdate = actEncryptSymetricUpdate - end - object actAbortScribble: TAction - Category = 'Seeding' - Caption = 'Abort scribble' - OnExecute = actAbortScribbleExecute - OnUpdate = actAbortScribbleUpdate - end - object actCustomBlockEncrypt: TAction - Category = 'CustomBlock' - Caption = 'Encrypt' - OnExecute = actCustomBlockEncryptExecute - OnUpdate = actEncryptSymetricUpdate - end - object actCustomBlockEncryptAbort: TAction - Category = 'CustomBlock' - Caption = 'Abort' - OnExecute = actCustomBlockEncryptAbortExecute - OnUpdate = actCustomBlockEncryptAbortUpdate - end - object actCustomBlockDecrypt: TAction - Category = 'CustomBlock' - Caption = 'Decrypt' - OnExecute = actCustomBlockDecryptExecute - OnUpdate = actEncryptSymetricUpdate - end - object actCustomBlockDecryptAbort: TAction - Category = 'CustomBlock' - Caption = 'Abort' - OnExecute = actCustomBlockDecryptAbortExecute - OnUpdate = actCustomBlockDecryptAbortUpdate - end - object actCustomBlockSymetricCompare: TAction - Category = 'CustomBlock' - Caption = 'Compare with original' - OnExecute = actCustomBlockSymetricCompareExecute - OnUpdate = actEncryptSymetricUpdate - end - object actRSAGen: TAction - Category = 'RSA Generation' - Caption = 'Generate 1024 bit RSA keys' - OnExecute = actRSAGenExecute - OnUpdate = actRSAGenUpdate - end - object actAbortRSAGen: TAction - Category = 'RSA Generation' - Caption = 'Abort generation' - OnExecute = actAbortRSAGenExecute - OnUpdate = actAbortRSAGenUpdate - end - object actStoreFullKey: TAction - Category = 'RSA Generation' - Caption = 'Store Both Keys' - OnExecute = actStoreFullKeyExecute - OnUpdate = actStoreFullKeyUpdate - end - object actSelectKeyFile: TFileOpen - Category = 'RSA Generation' - Caption = '&Open...' - Hint = 'Open|Opens an existing file' - ImageIndex = 2 - ShortCut = 16463 - end - object actLoadFullKey: TAction - Category = 'RSA Generation' - Caption = 'Load Both Keys' - OnExecute = actLoadFullKeyExecute - OnUpdate = actLoadFullKeyUpdate - end - object actStorePublicKey: TAction - Category = 'RSA Generation' - Caption = 'Store Public Key' - OnExecute = actStorePublicKeyExecute - OnUpdate = actStorePublicKeyUpdate - end - object actLoadPublicKey: TAction - Category = 'RSA Generation' - Caption = 'Load Public Key' - OnExecute = actLoadPublicKeyExecute - OnUpdate = actLoadPublicKeyUpdate - end - object actRSAEncrypt: TAction - Category = 'RSA Signature Verification' - Caption = 'Encrypt' - OnExecute = actRSAEncryptExecute - OnUpdate = actRSAEncryptUpdate - end - object actRSAEncryptAbort: TAction - Category = 'RSA Signature Verification' - Caption = 'Abort' - OnExecute = actRSAEncryptAbortExecute - OnUpdate = actRSAEncryptAbortUpdate - end - object actRSADecrypt: TAction - Category = 'RSA Signature Verification' - Caption = 'Decrypt' - OnExecute = actRSADecryptExecute - OnUpdate = actRSADecryptUpdate - end - object actRSADecryptAbort: TAction - Category = 'RSA Signature Verification' - Caption = 'Abort' - OnExecute = actRSADecryptAbortExecute - OnUpdate = actRSADecryptAbortUpdate - end - object actRSACompare: TAction - Category = 'RSA Signature Verification' - Caption = 'Compare with original' - OnExecute = actRSACompareExecute - OnUpdate = actRSACompareUpdate - end - object actSign: TAction - Category = 'RSA Signature Verification' - Caption = 'Sign' - OnExecute = actSignExecute - OnUpdate = actSignUpdate - end - object actVerify: TAction - Category = 'RSA Signature Verification' - Caption = 'Verify' - OnExecute = actVerifyExecute - OnUpdate = actVerifyUpdate - end - object actSignVerifyAbort: TAction - Category = 'RSA Signature Verification' - Caption = 'Abort' - OnExecute = actSignVerifyAbortExecute - OnUpdate = actSignVerifyAbortUpdate - end - object actHash: TAction - Category = 'Hash' - Caption = 'Hash with SHA-1' - OnExecute = actHashExecute - end - object actAbortHash: TAction - Category = 'Hash' - Caption = 'Abort' - OnExecute = actAbortHashExecute - OnUpdate = actAbortHashUpdate - end - object actOpenSSLLoadLib: TAction - Category = 'OpenSSL' - Caption = 'Load library' - OnExecute = actOpenSSLLoadLibExecute - OnUpdate = actOpenSSLLoadLibUpdate - end - object actOpenSSLUnloadLib: TAction - Category = 'OpenSSL' - Caption = 'Unload library' - OnExecute = actOpenSSLUnloadLibExecute - OnUpdate = actOpenSSLUnloadLibUpdate - end - object actOpenSSLGenKey: TAction - Category = 'OpenSSL' - Caption = 'Generate a 2048 bit key pair' - OnExecute = actOpenSSLGenKeyExecute - OnUpdate = actOpenSSLGenKeyUpdate - end - object actOpenSSLLoadPrivateKey: TAction - Category = 'OpenSSL' - Caption = 'Load private key' - OnExecute = actOpenSSLLoadPrivateKeyExecute - OnUpdate = actOpenSSLLoadPrivateKeyUpdate - end - object actOpenSSLLoadPublicKey: TAction - Category = 'OpenSSL' - Caption = 'Load public key' - OnExecute = actOpenSSLLoadPublicKeyExecute - OnUpdate = actOpenSSLLoadPublicKeyUpdate - end - object actOpenSSLSavePrivateKey: TAction - Category = 'OpenSSL' - Caption = 'Save private key' - OnExecute = actOpenSSLSavePrivateKeyExecute - OnUpdate = actOpenSSLSavePrivateKeyUpdate - end - object actOpenSSLSavePublicKey: TAction - Category = 'OpenSSL' - Caption = 'Save public key' - OnExecute = actOpenSSLSavePublicKeyExecute - OnUpdate = actOpenSSLSavePublicKeyUpdate - end - object actOpenSSLSign: TAction - Category = 'OpenSSL' - Caption = 'Sign' - OnExecute = actOpenSSLSignExecute - OnUpdate = actOpenSSLSignUpdate - end - object actOpenSSLVerify: TAction - Category = 'OpenSSL' - Caption = 'Verify' - OnExecute = actOpenSSLVerifyExecute - OnUpdate = actOpenSSLVerifyUpdate - end - end - object imglstActionGlyphs_16x16: TImageList - Left = 576 - Top = 88 - Bitmap = { - 494C010103000A000C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 - 0000000000003600000028000000400000001000000001002000000000000010 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000004080FF004080FF004080FF004080FF004080FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000004080FF004080FF004080FF004080FF004080FF004080FF000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000008080000080 - 8000008080000080800000808000008080000080800000808000008080000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF000000 - 0000000000000000000000000000000000000000000000000000008080000080 - 8000008080000080800000808000008080000080800000808000008080000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000FFFF00000000000080 - 8000008080000080800000808000008080000080800000808000008080000080 - 8000000000000000000000000000000000000000000000000000000000000000 - 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF000000 - 0000000000000000000000000000000000000000000000FFFF00000000000080 - 8000008080000080800000808000008080000080800000808000008080000080 - 8000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF0000FFFF000000 - 0000008080000080800000808000008080000080800000808000008080000080 - 8000008080000000000000000000000000000000000000000000000000000000 - 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF004080 - FF000000000000000000000000000000000000000000FFFFFF0000FFFF000000 - 0000008080000080800000808000008080000080800000808000008080000080 - 8000008080000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF - FF00000000000080800000808000008080000080800000808000008080000080 - 8000008080000080800000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000004080 - FF00000000000000000000000000000000000000000000FFFF00FFFFFF0000FF - FF00000000000080800000808000008080000080800000808000008080000080 - 8000008080000080800000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF - FF0000FFFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000004080000040800000408000004080000040800000408000004080000000 - 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF - FF0000FFFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF - FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00000000000000 - 0000000000000000000000000000000000000000000000408000004080000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 8000004080000040800000000000000000000000000000FFFF00FFFFFF0000FF - FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF - FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000 - 0000000000000000000000000000000000000000000000408000004080000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 80000040800000408000004080000000000000000000FFFFFF0000FFFF00FFFF - FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000408000004080000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 8000004080000040800000000000000000000000000000FFFF00FFFFFF0000FF - FF00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000004080000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 8000004080000040800000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 8000004080000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000040 - 8000004080000040800000408000004080000040800000408000004080000040 - 8000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000424D3E000000000000003E000000 - 2800000040000000100000000100010000000000800000000000000000000000 - 000000000000000000000000FFFFFF00FFFFF80FFFFF0000FFFFF00FFFFF0000 - 001FE00F001F0000000FE00F000F00000007E007000700000003E00700030000 - 0001E007000100000000800300000000001F0000001F0000001F0000001F0000 - 001F0000001F00008FF100018FF10000FFF98001FFF90000FF75C003FF750000 - FF8FC007FF8F0000FFFFFF9FFFFF000000000000000000000000000000000000 - 000000000000} - end - object CryptographicLibrary1: TCryptographicLibrary - Left = 592 - Top = 192 - end - object codecMainDemo: TCodec - AsymetricKeySizeInBits = 1024 - AdvancedOptions2 = [] - CryptoLibrary = CryptographicLibrary1 - OnProgress = codecMainDemoProgress - Left = 592 - Top = 264 - StreamCipherId = 'native.XXTEA.Large.Littleend' - BlockCipherId = '' - ChainId = 'native.CBC' - end - object ScribbleHash: THash - CryptoLibrary = CryptographicLibrary1 - OnProgress = ScribbleHashProgress - Left = 664 - Top = 264 - HashId = 'native.hash.SHA-1' - end - object codecCustomBlock: TCodec - AsymetricKeySizeInBits = 1024 - AdvancedOptions2 = [] - CryptoLibrary = CryptographicLibrary1 - OnProgress = codecMainDemoProgress - Left = 592 - Top = 320 - StreamCipherId = 'native.StreamToBlock' - BlockCipherId = 'native.AES-256' - ChainId = 'native.CFB' - end - object Signatory1: TSignatory - Codec = codecRSA - Left = 624 - Top = 408 - end - object codecRSA: TCodec - AsymetricKeySizeInBits = 1024 - AdvancedOptions2 = [] - CryptoLibrary = CryptographicLibrary1 - OnProgress = codecMainDemoProgress - Left = 568 - Top = 408 - StreamCipherId = 'native.RSA' - BlockCipherId = '' - ChainId = 'native.CBC' - end - object StringHash: THash - CryptoLibrary = CryptographicLibrary1 - Left = 680 - Top = 192 - HashId = 'native.hash.SHA-384' - end - object Sig: TOpenSSL_Signatory - LibPath = 'V:\projects\openssl\win32 binaries' - LibName = 'libeay32.dll' - RequiredVersion = '1.0.0.0' - OnProgress = SigProgress - AsymetricKeySizeInBits = 2048 - PrivateKeyStorageCipher = cipher_InTheClear - Left = 688 - Top = 408 - end - object dlgOpenPEM: TOpenDialog - DefaultExt = 'PEM' - Filter = 'PEM file|*.PEM|Any file|*.*' - Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing] - Left = 560 - Top = 472 - end - object dlgSavePEM: TSaveDialog - DefaultExt = 'PEM' - Filter = 'PEM file|*.PEM|Any file|*.*' - Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] - Left = 648 - Top = 472 - end -end +object mfmLockbox3_Demo: TmfmLockbox3_Demo + Left = 0 + Top = 0 + Caption = 'Lockbox 3 Demonstration Program' + ClientHeight = 569 + ClientWidth = 763 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poDesktopCenter + Scaled = False + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object memoLog: TMemo + Left = 520 + Top = 0 + Width = 243 + Height = 569 + Align = alRight + Color = clInfoBk + Lines.Strings = ( + '[Output log goes here.]') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object pcClient: TPageControl + Left = 0 + Top = 0 + Width = 520 + Height = 569 + ActivePage = tbSymetric + Align = alClient + MultiLine = True + TabOrder = 1 + object tbSymetric: TTabSheet + Caption = '1. Symetric basics' + DesignSize = ( + 512 + 523) + object lblPlaintextFile: TLabel + Left = 3 + Top = 152 + Width = 46 + Height = 13 + Caption = 'Plaintext:' + FocusControl = edtPlaintextFile + end + object lblCiphertextFile: TLabel + Left = 3 + Top = 176 + Width = 55 + Height = 13 + Caption = 'Ciphertext:' + FocusControl = edtCiphertextFile + end + object lblReconPlaintext: TLabel + Left = 9 + Top = 253 + Width = 73 + Height = 26 + Caption = 'Reconstructed plaintext:' + FocusControl = edtReconPlaintext + WordWrap = True + end + object shDivider_SymetricEncrypt: TShape + Left = 4 + Top = 234 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object shDivider_SymetricDecrypt: TShape + Left = 4 + Top = 311 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object edtPlaintextFile: TButtonedEdit + Left = 64 + Top = 149 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 0 + Text = '' + OnRightButtonClick = edtPlaintextFileRightButtonClick + end + object edtCiphertextFile: TButtonedEdit + Left = 64 + Top = 176 + Width = 446 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 1 + Text = '' + OnRightButtonClick = edtCiphertextFileRightButtonClick + end + object rgCipher: TRadioGroup + Left = 3 + Top = 16 + Width = 118 + Height = 127 + Caption = 'Cipher' + ItemIndex = 0 + Items.Strings = ( + 'AES-128' + 'AES-192' + 'AES-256' + 'DES' + '3DES (KO 1)' + '3DES (KO 2)' + 'Blowfish' + 'Twofish' + 'XXTEA') + TabOrder = 2 + OnClick = rgCipherClick + end + object rgChain: TRadioGroup + Left = 127 + Top = 16 + Width = 161 + Height = 127 + Caption = 'Chaining mode' + Columns = 2 + ItemIndex = 1 + Items.Strings = ( + 'ECB' + 'CBC' + 'PCBC' + 'CFB' + 'CFB 8-bit' + 'CTR' + 'OFB') + TabOrder = 3 + OnClick = rgChainClick + end + object lblPassword: TLabeledEdit + Left = 294 + Top = 32 + Width = 215 + Height = 21 + Anchors = [akLeft, akTop, akRight] + EditLabel.Width = 50 + EditLabel.Height = 13 + EditLabel.Caption = 'Password:' + TabOrder = 4 + Text = 'I love LockBox 3' + OnExit = lblPasswordExit + end + object btnSymetricEncrypt: TButton + Left = 160 + Top = 203 + Width = 75 + Height = 25 + Action = actEncryptSymetric + TabOrder = 5 + end + object edtReconPlaintext: TButtonedEdit + Left = 90 + Top = 250 + Width = 420 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 6 + Text = '' + OnRightButtonClick = edtReconPlaintextRightButtonClick + end + object btnSymetricDecrypt: TButton + Left = 160 + Top = 280 + Width = 75 + Height = 25 + Action = actSymetricDecrypt + TabOrder = 7 + end + object btnSymetricCompare: TButton + Left = 160 + Top = 344 + Width = 179 + Height = 25 + Action = actSymetricCompare + TabOrder = 8 + end + object btnSymetricEncrypt_Abort: TButton + Left = 264 + Top = 203 + Width = 75 + Height = 25 + Action = actSymetricEncrypt_Abort + TabOrder = 9 + end + object btnSymetricDecrypt_Abort: TButton + Left = 264 + Top = 280 + Width = 75 + Height = 25 + Action = actSymetricDecrypt_Abort + TabOrder = 10 + end + object pbarSymetric: TProgressBar + Left = 0 + Top = 502 + Width = 512 + Height = 21 + Align = alBottom + TabOrder = 11 + end + end + object tbSeeding: TTabSheet + Caption = '2. Seeding' + ImageIndex = 1 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + object bvlScriblePad: TBevel + Left = 4 + Top = 342 + Width = 506 + Height = 147 + end + object lblCurrentSeedLabel: TLabel + Left = 3 + Top = 184 + Width = 243 + Height = 13 + Caption = 'Current seed (unsigned 64 bit big-endien heximal):' + end + object lblCurrentSeed: TLabel + Left = 252 + Top = 184 + Width = 144 + Height = 16 + Caption = 'FFFFFFFFFFFFFFFF' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -16 + Font.Name = 'Courier' + Font.Style = [] + ParentFont = False + end + object imgScribblePad: TImage + Left = 16 + Top = 352 + Width = 481 + Height = 121 + OnMouseMove = imgScribblePadMouseMove + end + object memoInstructions: TMemo + Left = 3 + Top = 3 + Width = 422 + Height = 175 + Color = clInfoBk + Lines.Strings = ( + + 'TurboPower LockBox 3 has good strong pseudo-random number genera' + + 'tor,' + + '(PRNG) which is used extensivley by most of the functions of the' + + ' library.' + + 'The PRNG is based on a seed. A PRGN is only as strong as the ent' + + 'ropy' + 'in its seed, so how you seed the library is important.' + '' + + 'By default, TPLB3 is seeded by MS CryptoAPI. However if your app' + + 'lication' + + 'requires independance from black boxes, you may prefer to roll y' + + 'our own' + 'seed. This would normally be done at program start-up time.' + '' + + 'The scribble-pad for seeding is not formally a part of TPLB3. It' + + 's just' + + 'a simple example of how you can roll your own seed. Adapt as you' + + 'r problem' + 'requires.' + '' + '') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object rgSeedingMethod: TRadioGroup + Left = 4 + Top = 215 + Width = 505 + Height = 90 + Caption = 'Seeding method' + ItemIndex = 0 + Items.Strings = ( + + 'Microsoft CryptoAPI (RtlGenRandom function. Ref: http://en.wikip' + + 'edia.org/wiki/CryptGenRandom)' + 'Your input (unsigned 64 bit big-endien hex):' + 'True random using the Scrible pad below') + TabOrder = 1 + end + object btnSetSeed: TButton + Left = 200 + Top = 311 + Width = 75 + Height = 25 + Action = actSetSeed + TabOrder = 2 + end + object btnAbortScribble: TButton + Left = 404 + Top = 495 + Width = 105 + Height = 25 + Action = actAbortScribble + TabOrder = 3 + end + object pbarScribblePad: TProgressBar + Left = 3 + Top = 495 + Width = 395 + Height = 17 + TabOrder = 4 + end + object edtUserInputSeed: TEdit + Left = 252 + Top = 256 + Width = 121 + Height = 21 + TabOrder = 5 + Text = 'FFFFFFFFFFFFFFFF' + end + end + object tbSymetricExtent: TTabSheet + Caption = '3. Symetric extensions' + ImageIndex = 2 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + DesignSize = ( + 512 + 523) + object Label1: TLabel + Left = 0 + Top = 248 + Width = 46 + Height = 13 + Caption = 'Plaintext:' + FocusControl = edtCustomBlockPlaintextFile + end + object Label2: TLabel + Left = 0 + Top = 272 + Width = 55 + Height = 13 + Caption = 'Ciphertext:' + FocusControl = edtCustomBlockCiphertextFile + end + object Shape1: TShape + Left = 1 + Top = 330 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object Label3: TLabel + Left = 3 + Top = 340 + Width = 73 + Height = 26 + Caption = 'Reconstructed plaintext:' + FocusControl = edtCustomBlockReconPlaintext + WordWrap = True + end + object Shape2: TShape + Left = 1 + Top = 295 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object Label4: TLabel + Left = 3 + Top = 3 + Width = 470 + Height = 29 + Caption = 'Easy-peasy custom block-mode ciphers' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -24 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object rgCustomBlockChain: TRadioGroup + Left = 100 + Top = 136 + Width = 161 + Height = 89 + Caption = 'Chaining mode' + Columns = 2 + ItemIndex = 1 + Items.Strings = ( + 'ECB' + 'CBC' + 'PCBC' + 'CFB' + 'CFB 8-bit' + 'CTR' + 'OFB') + TabOrder = 0 + OnClick = rgChainClick + end + object lblCustomBlockPassword: TLabeledEdit + Left = 277 + Top = 152 + Width = 229 + Height = 21 + Anchors = [akLeft, akTop, akRight] + EditLabel.Width = 50 + EditLabel.Height = 13 + EditLabel.Caption = 'Password:' + TabOrder = 1 + Text = 'I love LockBox 3' + OnExit = lblPasswordExit + end + object edtCustomBlockPlaintextFile: TButtonedEdit + Left = 61 + Top = 245 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 2 + Text = '' + OnRightButtonClick = edtCustomBlockPlaintextFileRightButtonClick + end + object edtCustomBlockCiphertextFile: TButtonedEdit + Left = 61 + Top = 272 + Width = 446 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 3 + Text = '' + OnRightButtonClick = edtCustomBlockCiphertextFileRightButtonClick + end + object Button1: TButton + Left = 157 + Top = 299 + Width = 75 + Height = 25 + Action = actCustomBlockEncrypt + TabOrder = 4 + end + object Button2: TButton + Left = 261 + Top = 299 + Width = 75 + Height = 25 + Action = actCustomBlockEncryptAbort + TabOrder = 5 + end + object edtCustomBlockReconPlaintext: TButtonedEdit + Left = 87 + Top = 346 + Width = 420 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 6 + Text = '' + OnRightButtonClick = edtCustomBlockReconPlaintextRightButtonClick + end + object Button3: TButton + Left = 157 + Top = 376 + Width = 75 + Height = 25 + Action = actCustomBlockDecrypt + TabOrder = 7 + end + object Button4: TButton + Left = 261 + Top = 376 + Width = 75 + Height = 25 + Action = actCustomBlockDecryptAbort + TabOrder = 8 + end + object Button5: TButton + Left = 157 + Top = 440 + Width = 179 + Height = 25 + Action = actCustomBlockSymetricCompare + TabOrder = 9 + end + object pbarCustom: TProgressBar + Left = 0 + Top = 502 + Width = 512 + Height = 21 + Align = alBottom + TabOrder = 10 + end + object memoCustomBlockInstruction: TMemo + Left = 3 + Top = 36 + Width = 503 + Height = 94 + Color = clInfoBk + Lines.Strings = ( + + 'You can extend LockBox'#39's collection of stream ciphers simply by ' + + 'defining an invertable block ' + + 'transform. This page uses a Caesar cipher block transform (sourc' + + 'e code is in unit' + 'uDemoBlockModeCipher).' + '' + + 'With the tranform defined, all the normal block mode features (c' + + 'hoice of block chaining modes,' + 'auto-salting) come free.' + '' + '') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 11 + end + end + object tbKeyGen: TTabSheet + Caption = '4. RSA - Key generation and storage' + ImageIndex = 3 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + DesignSize = ( + 512 + 523) + object Shape3: TShape + Left = 3 + Top = 82 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object lblKeyStorageFile: TLabel + Left = 3 + Top = 104 + Width = 41 + Height = 13 + Caption = 'Key File:' + FocusControl = edtKeyStorageFile + end + object lblPrimalityTests: TLabel + Left = 16 + Top = 64 + Width = 140 + Height = 13 + Caption = 'Primality tests conducted = 0' + end + object btnRSAGen: TButton + Left = 3 + Top = 32 + Width = 174 + Height = 25 + Action = actRSAGen + TabOrder = 0 + end + object btnAbortGen: TButton + Left = 224 + Top = 32 + Width = 129 + Height = 25 + Action = actAbortRSAGen + TabOrder = 1 + end + object edtKeyStorageFile: TButtonedEdit + Left = 63 + Top = 101 + Width = 446 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 2 + Text = '' + OnRightButtonClick = edtKeyStorageFileRightButtonClick + end + object btnStoreFullKey: TButton + Left = 40 + Top = 144 + Width = 89 + Height = 25 + Action = actStoreFullKey + TabOrder = 3 + end + object btnPublicStore: TButton + Left = 135 + Top = 144 + Width = 98 + Height = 25 + Action = actStorePublicKey + TabOrder = 4 + end + object btnLoadFullKey: TButton + Left = 296 + Top = 144 + Width = 98 + Height = 25 + Action = actLoadFullKey + TabOrder = 5 + end + object btnPublicLoad: TButton + Left = 400 + Top = 144 + Width = 97 + Height = 25 + Action = actLoadPublicKey + TabOrder = 6 + end + end + object tbSignature: TTabSheet + Caption = '5. RSA - Signature && Verification' + ImageIndex = 4 + DesignSize = ( + 512 + 523) + object lblRSAPlaintextFile: TLabel + Left = 3 + Top = 6 + Width = 46 + Height = 13 + Caption = 'Plaintext:' + FocusControl = edtRSAPlaintextFile + end + object lblRSACiphertextFile: TLabel + Left = 3 + Top = 30 + Width = 55 + Height = 13 + Caption = 'Ciphertext:' + FocusControl = edtRSACiphertextFile + end + object shDivider_RSAEncrypt: TShape + Left = 4 + Top = 53 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object lblRSAReconFile: TLabel + Left = 6 + Top = 98 + Width = 73 + Height = 26 + Caption = 'Reconstructed plaintext:' + FocusControl = edtRSAReconFile + WordWrap = True + end + object shDivider_RSASign: TShape + Left = 3 + Top = 245 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object Label9: TLabel + Left = 8 + Top = 270 + Width = 52 + Height = 13 + Caption = 'Document:' + FocusControl = edtRSADocumentFile + end + object lblRSADocumentFile: TLabel + Left = 8 + Top = 294 + Width = 50 + Height = 13 + Caption = 'Signature:' + FocusControl = edtRSASignatureFile + end + object edtRSAPlaintextFile: TButtonedEdit + Left = 64 + Top = 3 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 0 + Text = '' + OnRightButtonClick = edtRSAPlaintextFileRightButtonClick + end + object edtRSACiphertextFile: TButtonedEdit + Left = 64 + Top = 30 + Width = 446 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 1 + Text = '' + OnRightButtonClick = edtRSACiphertextFileRightButtonClick + end + object btnRSAEncrypt: TButton + Left = 160 + Top = 57 + Width = 75 + Height = 25 + Action = actRSAEncrypt + TabOrder = 2 + end + object btnRSAEncryptAbort: TButton + Left = 264 + Top = 57 + Width = 75 + Height = 25 + Action = actRSAEncryptAbort + TabOrder = 3 + end + object edtRSAReconFile: TButtonedEdit + Left = 90 + Top = 104 + Width = 420 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 4 + Text = '' + OnRightButtonClick = edtRSAReconFileRightButtonClick + end + object btnRSADecrypt: TButton + Left = 160 + Top = 134 + Width = 75 + Height = 25 + Action = actRSADecrypt + TabOrder = 5 + end + object btnRSADecryptAbort: TButton + Left = 264 + Top = 134 + Width = 75 + Height = 25 + Action = actRSADecryptAbort + TabOrder = 6 + end + object btnRSACompare: TButton + Left = 160 + Top = 198 + Width = 179 + Height = 25 + Action = actRSACompare + TabOrder = 7 + end + object pbarRSA: TProgressBar + Left = 0 + Top = 502 + Width = 512 + Height = 21 + Align = alBottom + TabOrder = 8 + end + object edtRSADocumentFile: TButtonedEdit + Left = 64 + Top = 267 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 9 + Text = '' + OnRightButtonClick = edtRSADocumentFileRightButtonClick + end + object edtRSASignatureFile: TButtonedEdit + Left = 63 + Top = 294 + Width = 446 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 10 + Text = '' + OnRightButtonClick = edtRSASignatureFileRightButtonClick + end + object btnSign: TButton + Left = 90 + Top = 321 + Width = 75 + Height = 25 + Action = actSign + TabOrder = 11 + end + object btnSignVerifyAbort: TButton + Left = 365 + Top = 321 + Width = 75 + Height = 25 + Action = actSignVerifyAbort + TabOrder = 12 + end + object btnVerify: TButton + Left = 208 + Top = 321 + Width = 75 + Height = 25 + Action = actVerify + TabOrder = 13 + end + end + object tbHashes: TTabSheet + Caption = '6. Hashes' + ImageIndex = 5 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + DesignSize = ( + 512 + 523) + object lblHashSourceFile: TLabel + Left = 3 + Top = 6 + Width = 54 + Height = 13 + Caption = 'Source file:' + FocusControl = edtHashSourceFile + end + object lblHashSourceString: TLabel + Left = 3 + Top = 144 + Width = 71 + Height = 13 + Caption = 'String to hash:' + FocusControl = edtHashSource + end + object edtHashSourceFile: TButtonedEdit + Left = 64 + Top = 3 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 0 + Text = '' + OnRightButtonClick = edtHashSourceFileRightButtonClick + end + object btnHash: TButton + Left = 112 + Top = 57 + Width = 123 + Height = 25 + Action = actHash + TabOrder = 1 + end + object btnHashAbort: TButton + Left = 264 + Top = 57 + Width = 75 + Height = 25 + Action = actAbortHash + TabOrder = 2 + end + object edtHashSource: TEdit + Left = 80 + Top = 144 + Width = 298 + Height = 21 + Anchors = [akLeft, akTop, akRight] + TabOrder = 3 + Text = 'abc' + end + object rgHashSource: TRadioGroup + Left = 384 + Top = 144 + Width = 126 + Height = 65 + Anchors = [akTop, akRight] + Caption = 'This string is of type ...' + ItemIndex = 0 + Items.Strings = ( + 'Ansistring' + 'UTF-16') + TabOrder = 4 + end + object btnComputeHash: TButton + Left = 80 + Top = 184 + Width = 241 + Height = 25 + Caption = 'Compute SHA-384 hash of above string' + TabOrder = 5 + OnClick = btnComputeHashClick + end + end + object tbOpenSSL: TTabSheet + Caption = '7. RSA via OpenSSL' + ImageIndex = 6 + ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + DesignSize = ( + 512 + 523) + object lblOpenSSLDocument: TLabel + Left = 3 + Top = 400 + Width = 52 + Height = 13 + Caption = 'Document:' + FocusControl = edtOpenSSLDocument + end + object lblOpenSSLSignature: TLabel + Left = 3 + Top = 427 + Width = 50 + Height = 13 + Caption = 'Signature:' + FocusControl = edtOpenSSLSignature + end + object sepOpenSSLLibeay32: TShape + Left = 4 + Top = 130 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object Shape4: TShape + Left = 4 + Top = 244 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object Shape5: TShape + Left = 3 + Top = 348 + Width = 506 + Height = 4 + Anchors = [akLeft, akTop, akRight] + Brush.Color = clBlack + end + object btnOpenSSLLoadLib: TButton + Left = 103 + Top = 75 + Width = 75 + Height = 25 + Action = actOpenSSLLoadLib + TabOrder = 0 + end + object edtOpenSSLLibPath: TLabeledEdit + Left = 3 + Top = 48 + Width = 506 + Height = 21 + Anchors = [akLeft, akTop, akRight] + EditLabel.Width = 276 + EditLabel.Height = 13 + EditLabel.Caption = 'Path to libeay32.dll (leave empty to search system path):' + TabOrder = 1 + Text = 'V:\projects\openssl\win32 binaries\bin' + end + object btnOpenSSLUnloadLib: TButton + Left = 199 + Top = 75 + Width = 75 + Height = 25 + Action = actOpenSSLUnloadLib + TabOrder = 2 + end + object btnOpenSSLGenKey: TButton + Left = 3 + Top = 176 + Width = 205 + Height = 25 + Action = actOpenSSLGenKey + TabOrder = 3 + end + object btnOpenSSLLoadPrivateKey: TButton + Left = 239 + Top = 176 + Width = 107 + Height = 25 + Action = actOpenSSLLoadPrivateKey + TabOrder = 4 + end + object btnOpenSSLLoadPublicKey: TButton + Left = 376 + Top = 176 + Width = 121 + Height = 25 + Action = actOpenSSLLoadPublicKey + TabOrder = 5 + end + object btnOpenSSLSavePrivateKey: TButton + Left = 239 + Top = 296 + Width = 107 + Height = 25 + Action = actOpenSSLSavePrivateKey + TabOrder = 6 + end + object btnOpenSSLSavePublicKey: TButton + Left = 376 + Top = 296 + Width = 121 + Height = 25 + Action = actOpenSSLSavePublicKey + TabOrder = 7 + end + object edtOpenSSLDocument: TButtonedEdit + Left = 64 + Top = 397 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 8 + Text = '' + OnRightButtonClick = edtOpenSSLDocumentRightButtonClick + end + object btnOpenSSLSign: TButton + Left = 239 + Top = 472 + Width = 107 + Height = 25 + Action = actOpenSSLSign + TabOrder = 9 + end + object btnOpenSSLVerify: TButton + Left = 376 + Top = 472 + Width = 121 + Height = 25 + Action = actOpenSSLVerify + TabOrder = 10 + end + object edtOpenSSLSignature: TButtonedEdit + Left = 65 + Top = 424 + Width = 445 + Height = 21 + Anchors = [akLeft, akTop, akRight] + HideSelection = False + Images = imglstActionGlyphs_16x16 + RightButton.ImageIndex = 0 + RightButton.Visible = True + TabOrder = 11 + Text = '' + OnRightButtonClick = edtOpenSSLSignatureRightButtonClick + end + object rgOpenSSLHash: TRadioGroup + Left = 0 + Top = 451 + Width = 157 + Height = 57 + Caption = 'Hash for document' + ItemIndex = 0 + Items.Strings = ( + 'SHA-1' + 'MD5') + TabOrder = 12 + end + object pnlOpenSSLLibSection: TPanel + Left = 3 + Top = 3 + Width = 294 + Height = 22 + Caption = 'Linking to the OpenSSL library (libeay32.dll)' + Color = clMoneyGreen + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentBackground = False + ParentFont = False + TabOrder = 13 + end + object pnlOpenSSLKeyAcquisitionHeading: TPanel + Left = 3 + Top = 140 + Width = 294 + Height = 22 + Caption = 'Key acquisition' + Color = clMoneyGreen + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentBackground = False + ParentFont = False + TabOrder = 14 + end + object pnlOpenSSLKeySaving: TPanel + Left = 3 + Top = 255 + Width = 294 + Height = 22 + Caption = 'Key saving' + Color = clMoneyGreen + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentBackground = False + ParentFont = False + TabOrder = 15 + end + object pnlOpenSSLSignatureAndVerification: TPanel + Left = 3 + Top = 358 + Width = 294 + Height = 22 + Caption = 'Signature && Verification' + Color = clMoneyGreen + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentBackground = False + ParentFont = False + TabOrder = 16 + end + end + end + object actmngrMainDemoActions: TActionManager + Images = imglstActionGlyphs_16x16 + Left = 576 + Top = 32 + StyleName = 'Platform Default' + object actSelectPlaintext: TFileOpen + Category = 'Symetrics' + Caption = 'Plaintext' + Dialog.Options = [ofReadOnly, ofHideReadOnly, ofFileMustExist, ofEnableSizing] + Dialog.Title = 'Select plaintext file' + Hint = 'Plaintext|Selects an existing plaintext file' + ImageIndex = 0 + end + object actSelectCiphertext: TFileOpen + Category = 'Symetrics' + Caption = 'Ciphertext' + Dialog.Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] + Dialog.Title = 'Select ciphertext file' + Hint = 'Ciphertext|Selects output ciphertext file' + ImageIndex = 0 + end + object actSelectReconstructed: TFileOpen + Category = 'Symetrics' + Caption = 'ReconstructedPlaintext' + Hint = 'Open|Opens an existing file' + ImageIndex = 0 + end + object actEncryptSymetric: TAction + Category = 'Symetrics' + Caption = 'Encrypt' + OnExecute = actEncryptSymetricExecute + OnUpdate = actEncryptSymetricUpdate + end + object actSymetricEncrypt_Abort: TAction + Category = 'Symetrics' + Caption = 'Abort' + OnExecute = actSymetricEncrypt_AbortExecute + OnUpdate = actSymetricEncrypt_AbortUpdate + end + object actSymetricDecrypt: TAction + Category = 'Symetrics' + Caption = 'Decrypt' + OnExecute = actSymetricDecryptExecute + OnUpdate = actEncryptSymetricUpdate + end + object actSymetricDecrypt_Abort: TAction + Category = 'Symetrics' + Caption = 'Abort' + OnExecute = actSymetricDecrypt_AbortExecute + OnUpdate = actSymetricDecrypt_AbortUpdate + end + object actSymetricCompare: TAction + Category = 'Symetrics' + Caption = 'Compare with original' + OnExecute = actSymetricCompareExecute + OnUpdate = actEncryptSymetricUpdate + end + object actSetSeed: TAction + Category = 'Seeding' + Caption = 'Set Seed' + ImageIndex = 1 + OnExecute = actSetSeedExecute + OnUpdate = actEncryptSymetricUpdate + end + object actAbortScribble: TAction + Category = 'Seeding' + Caption = 'Abort scribble' + OnExecute = actAbortScribbleExecute + OnUpdate = actAbortScribbleUpdate + end + object actCustomBlockEncrypt: TAction + Category = 'CustomBlock' + Caption = 'Encrypt' + OnExecute = actCustomBlockEncryptExecute + OnUpdate = actEncryptSymetricUpdate + end + object actCustomBlockEncryptAbort: TAction + Category = 'CustomBlock' + Caption = 'Abort' + OnExecute = actCustomBlockEncryptAbortExecute + OnUpdate = actCustomBlockEncryptAbortUpdate + end + object actCustomBlockDecrypt: TAction + Category = 'CustomBlock' + Caption = 'Decrypt' + OnExecute = actCustomBlockDecryptExecute + OnUpdate = actEncryptSymetricUpdate + end + object actCustomBlockDecryptAbort: TAction + Category = 'CustomBlock' + Caption = 'Abort' + OnExecute = actCustomBlockDecryptAbortExecute + OnUpdate = actCustomBlockDecryptAbortUpdate + end + object actCustomBlockSymetricCompare: TAction + Category = 'CustomBlock' + Caption = 'Compare with original' + OnExecute = actCustomBlockSymetricCompareExecute + OnUpdate = actEncryptSymetricUpdate + end + object actRSAGen: TAction + Category = 'RSA Generation' + Caption = 'Generate 1024 bit RSA keys' + OnExecute = actRSAGenExecute + OnUpdate = actRSAGenUpdate + end + object actAbortRSAGen: TAction + Category = 'RSA Generation' + Caption = 'Abort generation' + OnExecute = actAbortRSAGenExecute + OnUpdate = actAbortRSAGenUpdate + end + object actStoreFullKey: TAction + Category = 'RSA Generation' + Caption = 'Store Both Keys' + OnExecute = actStoreFullKeyExecute + OnUpdate = actStoreFullKeyUpdate + end + object actSelectKeyFile: TFileOpen + Category = 'RSA Generation' + Caption = '&Open...' + Hint = 'Open|Opens an existing file' + ImageIndex = 2 + ShortCut = 16463 + end + object actLoadFullKey: TAction + Category = 'RSA Generation' + Caption = 'Load Both Keys' + OnExecute = actLoadFullKeyExecute + OnUpdate = actLoadFullKeyUpdate + end + object actStorePublicKey: TAction + Category = 'RSA Generation' + Caption = 'Store Public Key' + OnExecute = actStorePublicKeyExecute + OnUpdate = actStorePublicKeyUpdate + end + object actLoadPublicKey: TAction + Category = 'RSA Generation' + Caption = 'Load Public Key' + OnExecute = actLoadPublicKeyExecute + OnUpdate = actLoadPublicKeyUpdate + end + object actRSAEncrypt: TAction + Category = 'RSA Signature Verification' + Caption = 'Encrypt' + OnExecute = actRSAEncryptExecute + OnUpdate = actRSAEncryptUpdate + end + object actRSAEncryptAbort: TAction + Category = 'RSA Signature Verification' + Caption = 'Abort' + OnExecute = actRSAEncryptAbortExecute + OnUpdate = actRSAEncryptAbortUpdate + end + object actRSADecrypt: TAction + Category = 'RSA Signature Verification' + Caption = 'Decrypt' + OnExecute = actRSADecryptExecute + OnUpdate = actRSADecryptUpdate + end + object actRSADecryptAbort: TAction + Category = 'RSA Signature Verification' + Caption = 'Abort' + OnExecute = actRSADecryptAbortExecute + OnUpdate = actRSADecryptAbortUpdate + end + object actRSACompare: TAction + Category = 'RSA Signature Verification' + Caption = 'Compare with original' + OnExecute = actRSACompareExecute + OnUpdate = actRSACompareUpdate + end + object actSign: TAction + Category = 'RSA Signature Verification' + Caption = 'Sign' + OnExecute = actSignExecute + OnUpdate = actSignUpdate + end + object actVerify: TAction + Category = 'RSA Signature Verification' + Caption = 'Verify' + OnExecute = actVerifyExecute + OnUpdate = actVerifyUpdate + end + object actSignVerifyAbort: TAction + Category = 'RSA Signature Verification' + Caption = 'Abort' + OnExecute = actSignVerifyAbortExecute + OnUpdate = actSignVerifyAbortUpdate + end + object actHash: TAction + Category = 'Hash' + Caption = 'Hash with SHA-1' + OnExecute = actHashExecute + end + object actAbortHash: TAction + Category = 'Hash' + Caption = 'Abort' + OnExecute = actAbortHashExecute + OnUpdate = actAbortHashUpdate + end + object actOpenSSLLoadLib: TAction + Category = 'OpenSSL' + Caption = 'Load library' + OnExecute = actOpenSSLLoadLibExecute + OnUpdate = actOpenSSLLoadLibUpdate + end + object actOpenSSLUnloadLib: TAction + Category = 'OpenSSL' + Caption = 'Unload library' + OnExecute = actOpenSSLUnloadLibExecute + OnUpdate = actOpenSSLUnloadLibUpdate + end + object actOpenSSLGenKey: TAction + Category = 'OpenSSL' + Caption = 'Generate a 2048 bit key pair' + OnExecute = actOpenSSLGenKeyExecute + OnUpdate = actOpenSSLGenKeyUpdate + end + object actOpenSSLLoadPrivateKey: TAction + Category = 'OpenSSL' + Caption = 'Load private key' + OnExecute = actOpenSSLLoadPrivateKeyExecute + OnUpdate = actOpenSSLLoadPrivateKeyUpdate + end + object actOpenSSLLoadPublicKey: TAction + Category = 'OpenSSL' + Caption = 'Load public key' + OnExecute = actOpenSSLLoadPublicKeyExecute + OnUpdate = actOpenSSLLoadPublicKeyUpdate + end + object actOpenSSLSavePrivateKey: TAction + Category = 'OpenSSL' + Caption = 'Save private key' + OnExecute = actOpenSSLSavePrivateKeyExecute + OnUpdate = actOpenSSLSavePrivateKeyUpdate + end + object actOpenSSLSavePublicKey: TAction + Category = 'OpenSSL' + Caption = 'Save public key' + OnExecute = actOpenSSLSavePublicKeyExecute + OnUpdate = actOpenSSLSavePublicKeyUpdate + end + object actOpenSSLSign: TAction + Category = 'OpenSSL' + Caption = 'Sign' + OnExecute = actOpenSSLSignExecute + OnUpdate = actOpenSSLSignUpdate + end + object actOpenSSLVerify: TAction + Category = 'OpenSSL' + Caption = 'Verify' + OnExecute = actOpenSSLVerifyExecute + OnUpdate = actOpenSSLVerifyUpdate + end + end + object imglstActionGlyphs_16x16: TImageList + Left = 576 + Top = 88 + Bitmap = { + 494C010103000A00100010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000001000000001002000000000000010 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000004080FF004080FF004080FF004080FF004080FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000004080FF004080FF004080FF004080FF004080FF004080FF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000008080000080 + 8000008080000080800000808000008080000080800000808000008080000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF000000 + 0000000000000000000000000000000000000000000000000000008080000080 + 8000008080000080800000808000008080000080800000808000008080000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000FFFF00000000000080 + 8000008080000080800000808000008080000080800000808000008080000080 + 8000000000000000000000000000000000000000000000000000000000000000 + 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF000000 + 0000000000000000000000000000000000000000000000FFFF00000000000080 + 8000008080000080800000808000008080000080800000808000008080000080 + 8000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF0000FFFF000000 + 0000008080000080800000808000008080000080800000808000008080000080 + 8000008080000000000000000000000000000000000000000000000000000000 + 00004080FF004080FF004080FF004080FF004080FF004080FF004080FF004080 + FF000000000000000000000000000000000000000000FFFFFF0000FFFF000000 + 0000008080000080800000808000008080000080800000808000008080000080 + 8000008080000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF + FF00000000000080800000808000008080000080800000808000008080000080 + 8000008080000080800000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000004080 + FF00000000000000000000000000000000000000000000FFFF00FFFFFF0000FF + FF00000000000080800000808000008080000080800000808000008080000080 + 8000008080000080800000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF + FF0000FFFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000004080000040800000408000004080000040800000408000004080000000 + 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF + FF0000FFFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF + FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00000000000000 + 0000000000000000000000000000000000000000000000408000004080000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000004080000040800000000000000000000000000000FFFF00FFFFFF0000FF + FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FFFFFF0000FFFF00FFFF + FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000 + 0000000000000000000000000000000000000000000000408000004080000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 80000040800000408000004080000000000000000000FFFFFF0000FFFF00FFFF + FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000FFFF00FFFFFF0000FF + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000408000004080000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000004080000040800000000000000000000000000000FFFF00FFFFFF0000FF + FF00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000004080000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000004080000040800000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000004080000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000040 + 8000004080000040800000408000004080000040800000408000004080000040 + 8000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000100000000100010000000000800000000000000000000000 + 000000000000000000000000FFFFFF00FFFFF80FFFFF0000FFFFF00FFFFF0000 + 001FE00F001F0000000FE00F000F00000007E007000700000003E00700030000 + 0001E007000100000000800300000000001F0000001F0000001F0000001F0000 + 001F0000001F00008FF100018FF10000FFF98001FFF90000FF75C003FF750000 + FF8FC007FF8F0000FFFFFF9FFFFF000000000000000000000000000000000000 + 000000000000} + end + object CryptographicLibrary1: TCryptographicLibrary + Left = 592 + Top = 192 + end + object codecMainDemo: TCodec + AsymetricKeySizeInBits = 1024 + AdvancedOptions2 = [] + CryptoLibrary = CryptographicLibrary1 + OnProgress = codecMainDemoProgress + Left = 592 + Top = 264 + StreamCipherId = 'native.XXTEA.Large.Littleend' + BlockCipherId = '' + ChainId = 'native.CBC' + end + object ScribbleHash: THash + CryptoLibrary = CryptographicLibrary1 + OnProgress = ScribbleHashProgress + Left = 664 + Top = 264 + HashId = 'native.hash.SHA-1' + end + object codecCustomBlock: TCodec + AsymetricKeySizeInBits = 1024 + AdvancedOptions2 = [] + CryptoLibrary = CryptographicLibrary1 + OnProgress = codecMainDemoProgress + Left = 592 + Top = 320 + StreamCipherId = 'native.StreamToBlock' + BlockCipherId = 'native.AES-256' + ChainId = 'native.CFB' + end + object Signatory1: TSignatory + Codec = codecRSA + Left = 624 + Top = 408 + end + object codecRSA: TCodec + AsymetricKeySizeInBits = 1024 + AdvancedOptions2 = [] + CryptoLibrary = CryptographicLibrary1 + OnProgress = codecMainDemoProgress + Left = 568 + Top = 408 + StreamCipherId = 'native.RSA' + BlockCipherId = '' + ChainId = 'native.CBC' + end + object StringHash: THash + CryptoLibrary = CryptographicLibrary1 + Left = 680 + Top = 192 + HashId = 'native.hash.SHA-384' + end + object Sig: TOpenSSL_Signatory + LibPath = 'V:\projects\openssl\win32 binaries' + LibName = 'libeay32.dll' + RequiredVersion = '1.0.0.0' + OnProgress = SigProgress + AsymetricKeySizeInBits = 2048 + PrivateKeyStorageCipher = cipher_InTheClear + Left = 688 + Top = 408 + end + object dlgOpenPEM: TOpenDialog + DefaultExt = 'PEM' + Filter = 'PEM file|*.PEM|Any file|*.*' + Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing] + Left = 560 + Top = 472 + end + object dlgSavePEM: TSaveDialog + DefaultExt = 'PEM' + Filter = 'PEM file|*.PEM|Any file|*.*' + Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] + Left = 648 + Top = 472 + end +end diff --git a/demo/D2010+/umfmLockbox3_Demo.pas b/LockBox3/demo/D2010+/umfmLockbox3_Demo.pas similarity index 96% rename from demo/D2010+/umfmLockbox3_Demo.pas rename to LockBox3/demo/D2010+/umfmLockbox3_Demo.pas index 23d8967..277a371 100644 --- a/demo/D2010+/umfmLockbox3_Demo.pas +++ b/LockBox3/demo/D2010+/umfmLockbox3_Demo.pas @@ -1,1789 +1,1789 @@ -unit umfmLockbox3_Demo; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, ComCtrls, ActnList, StdActns, ImgList, - PlatformDefaultStyleActnCtrls, ActnMan, ExtCtrls, - TPLB3.Signatory, TPLB3.OpenSSL, TPLB3.Hash, - TPLB3.Codec, TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, - System.Actions; - -type - TOperation = ( opIdle, opSymetricEncrypt, opSymetricDecrypt, - opSymetricCompare, opScribble, - opCustomBlockSymetricEncrypt, - opCustomBlockSymetricDecrypt, opRSAGen, opRSAEncrypt, opRSADecrypt, opSign, - opVerify, opHash, opOpenSSL ); - - TmfmLockbox3_Demo = class( TForm ) - memoLog: TMemo; - actmngrMainDemoActions: TActionManager; - imglstActionGlyphs_16x16: TImageList; - actSelectPlaintext: TFileOpen; - actSelectCiphertext: TFileOpen; - CryptographicLibrary1: TCryptographicLibrary; - codecMainDemo: TCodec; - actEncryptSymetric: TAction; - actSymetricEncrypt_Abort: TAction; - actSymetricDecrypt: TAction; - actSymetricDecrypt_Abort: TAction; - actSymetricCompare: TAction; - actSelectReconstructed: TFileOpen; - actSetSeed: TAction; - ScribbleHash: THash; - actAbortScribble: TAction; - actCustomBlockEncrypt: TAction; - codecCustomBlock: TCodec; - actCustomBlockEncryptAbort: TAction; - actCustomBlockDecrypt: TAction; - actCustomBlockDecryptAbort: TAction; - actCustomBlockSymetricCompare: TAction; - Signatory1: TSignatory; - codecRSA: TCodec; - actRSAGen: TAction; - actAbortRSAGen: TAction; - actStoreFullKey: TAction; - actSelectKeyFile: TFileOpen; - actLoadFullKey: TAction; - actStorePublicKey: TAction; - actLoadPublicKey: TAction; - actRSAEncrypt: TAction; - actRSAEncryptAbort: TAction; - actRSADecrypt: TAction; - actRSADecryptAbort: TAction; - actRSACompare: TAction; - actSign: TAction; - actVerify: TAction; - actSignVerifyAbort: TAction; - actHash: TAction; - actAbortHash: TAction; - StringHash: THash; - pcClient: TPageControl; - tbSymetric: TTabSheet; - lblPlaintextFile: TLabel; - lblCiphertextFile: TLabel; - lblReconPlaintext: TLabel; - shDivider_SymetricEncrypt: TShape; - shDivider_SymetricDecrypt: TShape; - edtPlaintextFile: TButtonedEdit; - edtCiphertextFile: TButtonedEdit; - rgCipher: TRadioGroup; - rgChain: TRadioGroup; - lblPassword: TLabeledEdit; - btnSymetricEncrypt: TButton; - edtReconPlaintext: TButtonedEdit; - btnSymetricDecrypt: TButton; - btnSymetricCompare: TButton; - btnSymetricEncrypt_Abort: TButton; - btnSymetricDecrypt_Abort: TButton; - pbarSymetric: TProgressBar; - tbSeeding: TTabSheet; - bvlScriblePad: TBevel; - lblCurrentSeedLabel: TLabel; - lblCurrentSeed: TLabel; - imgScribblePad: TImage; - memoInstructions: TMemo; - rgSeedingMethod: TRadioGroup; - btnSetSeed: TButton; - btnAbortScribble: TButton; - pbarScribblePad: TProgressBar; - edtUserInputSeed: TEdit; - tbSymetricExtent: TTabSheet; - Label1: TLabel; - Label2: TLabel; - Shape1: TShape; - Label3: TLabel; - Shape2: TShape; - Label4: TLabel; - rgCustomBlockChain: TRadioGroup; - lblCustomBlockPassword: TLabeledEdit; - edtCustomBlockPlaintextFile: TButtonedEdit; - edtCustomBlockCiphertextFile: TButtonedEdit; - Button1: TButton; - Button2: TButton; - edtCustomBlockReconPlaintext: TButtonedEdit; - Button3: TButton; - Button4: TButton; - Button5: TButton; - pbarCustom: TProgressBar; - memoCustomBlockInstruction: TMemo; - tbKeyGen: TTabSheet; - Shape3: TShape; - lblKeyStorageFile: TLabel; - lblPrimalityTests: TLabel; - btnRSAGen: TButton; - btnAbortGen: TButton; - edtKeyStorageFile: TButtonedEdit; - btnStoreFullKey: TButton; - btnPublicStore: TButton; - btnLoadFullKey: TButton; - btnPublicLoad: TButton; - tbSignature: TTabSheet; - lblRSAPlaintextFile: TLabel; - lblRSACiphertextFile: TLabel; - shDivider_RSAEncrypt: TShape; - lblRSAReconFile: TLabel; - shDivider_RSASign: TShape; - Label9: TLabel; - lblRSADocumentFile: TLabel; - edtRSAPlaintextFile: TButtonedEdit; - edtRSACiphertextFile: TButtonedEdit; - btnRSAEncrypt: TButton; - btnRSAEncryptAbort: TButton; - edtRSAReconFile: TButtonedEdit; - btnRSADecrypt: TButton; - btnRSADecryptAbort: TButton; - btnRSACompare: TButton; - pbarRSA: TProgressBar; - edtRSADocumentFile: TButtonedEdit; - edtRSASignatureFile: TButtonedEdit; - btnSign: TButton; - btnSignVerifyAbort: TButton; - btnVerify: TButton; - tbHashes: TTabSheet; - lblHashSourceFile: TLabel; - lblHashSourceString: TLabel; - edtHashSourceFile: TButtonedEdit; - btnHash: TButton; - btnHashAbort: TButton; - edtHashSource: TEdit; - rgHashSource: TRadioGroup; - btnComputeHash: TButton; - tbOpenSSL: TTabSheet; - Sig: TOpenSSL_Signatory; - btnOpenSSLLoadLib: TButton; - edtOpenSSLLibPath: TLabeledEdit; - btnOpenSSLUnloadLib: TButton; - btnOpenSSLGenKey: TButton; - btnOpenSSLLoadPrivateKey: TButton; - btnOpenSSLLoadPublicKey: TButton; - btnOpenSSLSavePrivateKey: TButton; - btnOpenSSLSavePublicKey: TButton; - lblOpenSSLDocument: TLabel; - edtOpenSSLDocument: TButtonedEdit; - btnOpenSSLSign: TButton; - btnOpenSSLVerify: TButton; - lblOpenSSLSignature: TLabel; - edtOpenSSLSignature: TButtonedEdit; - rgOpenSSLHash: TRadioGroup; - sepOpenSSLLibeay32: TShape; - Shape4: TShape; - pnlOpenSSLLibSection: TPanel; - pnlOpenSSLKeyAcquisitionHeading: TPanel; - pnlOpenSSLKeySaving: TPanel; - Shape5: TShape; - pnlOpenSSLSignatureAndVerification: TPanel; - actOpenSSLLoadLib: TAction; - actOpenSSLUnloadLib: TAction; - actOpenSSLGenKey: TAction; - actOpenSSLLoadPrivateKey: TAction; - actOpenSSLLoadPublicKey: TAction; - actOpenSSLSavePrivateKey: TAction; - actOpenSSLSavePublicKey: TAction; - actOpenSSLSign: TAction; - actOpenSSLVerify: TAction; - dlgOpenPEM: TOpenDialog; - dlgSavePEM: TSaveDialog; - procedure FormCreate( Sender: TObject ); - procedure edtPlaintextFileRightButtonClick( Sender: TObject ); - procedure edtCiphertextFileRightButtonClick( Sender: TObject ); - function codecMainDemoProgress( Sender: TObject; - CountBytesProcessed: Int64 ): Boolean; - procedure actEncryptSymetricExecute( Sender: TObject ); - procedure actSymetricEncrypt_AbortExecute( Sender: TObject ); - procedure actSymetricEncrypt_AbortUpdate( Sender: TObject ); - procedure actSymetricDecryptExecute( Sender: TObject ); - procedure actSymetricDecrypt_AbortExecute( Sender: TObject ); - procedure actSymetricDecrypt_AbortUpdate( Sender: TObject ); - procedure rgCipherClick( Sender: TObject ); - procedure rgChainClick( Sender: TObject ); - procedure lblPasswordExit( Sender: TObject ); - procedure edtReconPlaintextRightButtonClick( Sender: TObject ); - procedure actEncryptSymetricUpdate( Sender: TObject ); - procedure actSymetricCompareExecute( Sender: TObject ); - procedure actSetSeedExecute( Sender: TObject ); - procedure imgScribblePadMouseMove( Sender: TObject; Shift: TShiftState; - X, Y: Integer ); - procedure FormDestroy( Sender: TObject ); - procedure actAbortScribbleExecute( Sender: TObject ); - procedure actAbortScribbleUpdate( Sender: TObject ); - procedure actCustomBlockEncryptExecute( Sender: TObject ); - procedure actCustomBlockEncryptAbortExecute( Sender: TObject ); - procedure actCustomBlockEncryptAbortUpdate( Sender: TObject ); - procedure edtCustomBlockPlaintextFileRightButtonClick( Sender: TObject ); - procedure edtCustomBlockCiphertextFileRightButtonClick( Sender: TObject ); - procedure edtCustomBlockReconPlaintextRightButtonClick( Sender: TObject ); - procedure actCustomBlockDecryptExecute( Sender: TObject ); - procedure actCustomBlockDecryptAbortExecute( Sender: TObject ); - procedure actCustomBlockDecryptAbortUpdate( Sender: TObject ); - procedure actCustomBlockSymetricCompareExecute( Sender: TObject ); - procedure actRSAGenExecute( Sender: TObject ); - procedure actRSAGenUpdate( Sender: TObject ); - procedure actAbortRSAGenExecute( Sender: TObject ); - procedure actAbortRSAGenUpdate( Sender: TObject ); - procedure actStoreFullKeyExecute( Sender: TObject ); - procedure edtKeyStorageFileRightButtonClick( Sender: TObject ); - procedure actStoreFullKeyUpdate( Sender: TObject ); - procedure actLoadFullKeyExecute( Sender: TObject ); - procedure actLoadFullKeyUpdate( Sender: TObject ); - procedure actStorePublicKeyExecute( Sender: TObject ); - procedure actStorePublicKeyUpdate( Sender: TObject ); - procedure actLoadPublicKeyExecute( Sender: TObject ); - procedure actLoadPublicKeyUpdate( Sender: TObject ); - procedure edtRSAPlaintextFileRightButtonClick( Sender: TObject ); - procedure edtRSACiphertextFileRightButtonClick( Sender: TObject ); - procedure edtRSAReconFileRightButtonClick( Sender: TObject ); - procedure edtHashSourceFileRightButtonClick( Sender: TObject ); - procedure actRSAEncryptExecute( Sender: TObject ); - procedure actRSAEncryptUpdate( Sender: TObject ); - procedure actRSAEncryptAbortExecute( Sender: TObject ); - procedure actRSAEncryptAbortUpdate( Sender: TObject ); - procedure actRSADecryptExecute( Sender: TObject ); - procedure actRSADecryptUpdate( Sender: TObject ); - procedure actRSADecryptAbortExecute( Sender: TObject ); - procedure actRSADecryptAbortUpdate( Sender: TObject ); - procedure actRSACompareExecute( Sender: TObject ); - procedure actRSACompareUpdate( Sender: TObject ); - procedure actSignExecute( Sender: TObject ); - procedure actSignUpdate( Sender: TObject ); - procedure actVerifyExecute( Sender: TObject ); - procedure actVerifyUpdate( Sender: TObject ); - procedure actSignVerifyAbortExecute( Sender: TObject ); - procedure actSignVerifyAbortUpdate( Sender: TObject ); - procedure edtRSADocumentFileRightButtonClick( Sender: TObject ); - procedure edtRSASignatureFileRightButtonClick( Sender: TObject ); - procedure actHashExecute( Sender: TObject ); - procedure actAbortHashExecute( Sender: TObject ); - procedure actAbortHashUpdate( Sender: TObject ); - function ScribbleHashProgress( Sender: TObject; - CountBytesProcessed: Int64 ): Boolean; - procedure btnComputeHashClick( Sender: TObject ); - procedure actOpenSSLLoadLibExecute( Sender: TObject ); - procedure actOpenSSLLoadLibUpdate( Sender: TObject ); - procedure actOpenSSLUnloadLibExecute( Sender: TObject ); - procedure actOpenSSLUnloadLibUpdate( Sender: TObject ); - procedure actOpenSSLGenKeyExecute( Sender: TObject ); - procedure actOpenSSLGenKeyUpdate( Sender: TObject ); - procedure actOpenSSLLoadPrivateKeyExecute( Sender: TObject ); - procedure actOpenSSLLoadPrivateKeyUpdate( Sender: TObject ); - procedure actOpenSSLLoadPublicKeyExecute( Sender: TObject ); - procedure actOpenSSLLoadPublicKeyUpdate( Sender: TObject ); - procedure actOpenSSLSavePrivateKeyExecute( Sender: TObject ); - procedure actOpenSSLSavePrivateKeyUpdate( Sender: TObject ); - procedure actOpenSSLSavePublicKeyExecute( Sender: TObject ); - procedure actOpenSSLSavePublicKeyUpdate( Sender: TObject ); - procedure actOpenSSLSignExecute( Sender: TObject ); - procedure actOpenSSLSignUpdate( Sender: TObject ); - procedure actOpenSSLVerifyExecute( Sender: TObject ); - procedure actOpenSSLVerifyUpdate( Sender: TObject ); - procedure edtOpenSSLDocumentRightButtonClick( Sender: TObject ); - procedure edtOpenSSLSignatureRightButtonClick( Sender: TObject ); - function SigProgress( Sender: TObject; p1, p2: Integer ): Boolean; - - private - FOp: TOperation; - // FCountBytesProcessed: int64; - // FEstimatedWorkLoad: int64; - FdidPressAbortEncrypt: Boolean; - FScribblePad_EntropyBag: TStream; - FBusyObj: TObject; // TBusy - FSaveCursor: TCursor; - pressedAbortHash: Boolean; - - procedure SetOp( NewOp: TOperation ); - procedure SetSeed_MSCryptAPI; - procedure SetSeed_UserInput( const UserInputSeedAsString: string ); - procedure SetSeed_ScribblePad_Begin; - function GetDisplayedRSeed: Int64; - procedure SetDisplayedRSeed( Value: Int64 ); - function Busy: IInterface; - procedure ChangeBusy( isEntering: Boolean ); - procedure PutLinuxLines( const Value: string ); - - // procedure BuildPermuteTable( const OrderOfBattle: string); - - public - procedure Log( const Line: string ); - procedure LogFmt( const Line: string; const Args: array of const ); - - property CurrentOperation: TOperation read FOp write SetOp; - property DisplayedRandSeed - : Int64 read GetDisplayedRSeed write SetDisplayedRSeed; - end; - -var - mfmLockbox3_Demo: TmfmLockbox3_Demo; - -implementation - -uses TPLB3.Random, uDemoBlockModeCipher, TPLB3.Constants, TPLB3.Asymetric, - TPLB3.StreamUtils, TPLB3.StreamCipher, TPLB3.CodecIntf, - TPLB3.DES, TPLB3.StreamToBlock, TPLB3.AES, TPLB3.CBC, - - TPLB3.XXTEA, Types; -{$R *.dfm} - -procedure TmfmLockbox3_Demo.FormCreate( Sender: TObject ); -begin - FOp := opIdle; - FdidPressAbortEncrypt := False; - memoLog.Clear; - Log( 'Welcome to the LockBox 3 Demonstration Program.' ); - codecMainDemo.StreamCipherId := BlockCipher_ProgId; - codecMainDemo.Password := lblPassword.Text; - rgChainClick( nil ); - rgCipherClick( nil ); - FScribblePad_EntropyBag := TMemoryStream.Create; - TDemoBlockModeCipher.SelfRegister( CryptographicLibrary1 ) -end; - -procedure TmfmLockbox3_Demo.FormDestroy( Sender: TObject ); -begin - FScribblePad_EntropyBag.Free -end; - -function TmfmLockbox3_Demo.GetDisplayedRSeed: Int64; -var - s: string; - Code: Integer; -begin - s := '$' + Trim( edtUserInputSeed.Text ); - Val( s, result, Code ); - if Code <> 0 then - begin - LogFmt( '"%s" is not a valid hexidecimal integer.', - [edtUserInputSeed.Text] ); - result := 0 - end -end; - -procedure TmfmLockbox3_Demo.imgScribblePadMouseMove( Sender: TObject; - Shift: TShiftState; X, Y: Integer ); -var - Now1: TDateTime; - NewSeed: Int64; - R: TRandomStream; - - procedure ConsumeEntropy( const Data; DataSize: Integer ); - var - P: Integer; - begin - FScribblePad_EntropyBag.Write( Data, DataSize ); - P := FScribblePad_EntropyBag.Size div 100; - if pbarScribblePad.Position <> P then - pbarScribblePad.Position := P - end; - -begin - if FOp <> opScribble then - exit; - imgScribblePad.Picture.Bitmap.Canvas.LineTo( X, Y ); - Now1 := Now; - ConsumeEntropy( Now1, SizeOf( Now1 ) ); - ConsumeEntropy( X, SizeOf( X ) ); - ConsumeEntropy( Y, SizeOf( Y ) ); - if pbarScribblePad.Position < 100 then - exit; - pbarScribblePad.Visible := False; - ScribbleHash.HashStream( FScribblePad_EntropyBag ); - FScribblePad_EntropyBag.Size := 0; - ScribbleHash.HashOutputValue.Read( NewSeed, SizeOf( NewSeed ) ); - ScribbleHash.Burn; - R := TRandomStream.Instance; - R.Seed := NewSeed; - DisplayedRandSeed := NewSeed; - imgScribblePad.Cursor := crDefault; - LogFmt( 'The PRNG seed has been set to $%16x .', [NewSeed] ); - FOp := opIdle -end; - -procedure TmfmLockbox3_Demo.lblPasswordExit( Sender: TObject ); -begin - if codecMainDemo.Password <> lblPassword.Text then - codecMainDemo.Password := lblPassword.Text -end; - -procedure TmfmLockbox3_Demo.edtPlaintextFileRightButtonClick( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtPlaintextFile.Text := s; - edtCiphertextFile.Text := s + '_enc'; - edtReconPlaintext.Text := s + '_rcn'; - end -end; - -procedure TmfmLockbox3_Demo.edtReconPlaintextRightButtonClick - ( Sender: TObject ); -begin - if actSelectReconstructed.Execute then - edtReconPlaintext.Text := actSelectReconstructed.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.actAbortScribbleExecute( Sender: TObject ); -begin - pbarScribblePad.Visible := False; - FScribblePad_EntropyBag.Size := 0; - ScribbleHash.Burn; - Log( 'Scribble operation aborted at user request.' ); - FOp := opIdle -end; - -procedure TmfmLockbox3_Demo.actAbortScribbleUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := FOp = opScribble -end; - -const - ChainIds: array [0 .. 6] of string = ( ECB_ProgId, CBC_ProgId, PCBC_ProgId, - CFB_ProgId, CFB8bit_ProgId, CTR_ProgId, OFB_ProgId ); - -procedure TmfmLockbox3_Demo.actCustomBlockDecryptAbortExecute - ( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actCustomBlockDecryptAbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opCustomBlockSymetricDecrypt ) and - ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actCustomBlockDecryptExecute( Sender: TObject ); -begin - Busy; - CurrentOperation := opCustomBlockSymetricDecrypt; - FdidPressAbortEncrypt := False; - codecCustomBlock.StreamCipherId := BlockCipher_ProgId; - codecCustomBlock.ChainModeId := ChainIds[rgCustomBlockChain.ItemIndex]; - codecCustomBlock.BlockCipherId := DemoProgId; - codecCustomBlock.Password := lblCustomBlockPassword.Text; - codecCustomBlock.DecryptFile( edtCustomBlockReconPlaintext.Text, - edtCustomBlockCiphertextFile.Text ); - if codecCustomBlock.isUserAborted then - Log( 'Decryption operation aborted by user.' ) - else - LogFmt( 'Decryption succeeded. %d bytes processed.', - [codecCustomBlock.CountBytesProcessed] ); - codecCustomBlock.Reset; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actCustomBlockEncryptAbortExecute - ( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actCustomBlockEncryptAbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opCustomBlockSymetricEncrypt ) and - ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actCustomBlockEncryptExecute( Sender: TObject ); -begin - Busy; - CurrentOperation := opCustomBlockSymetricEncrypt; - FdidPressAbortEncrypt := False; - codecCustomBlock.StreamCipherId := BlockCipher_ProgId; - codecCustomBlock.ChainModeId := ChainIds[rgCustomBlockChain.ItemIndex]; - codecCustomBlock.BlockCipherId := DemoProgId; - codecCustomBlock.Password := lblCustomBlockPassword.Text; - codecCustomBlock.EncryptFile( edtCustomBlockPlaintextFile.Text, - edtCustomBlockCiphertextFile.Text ); - if codecCustomBlock.isUserAborted then - Log( 'Encryption operation aborted by user.' ) - else - LogFmt( 'Encryption succeeded. %d bytes processed.', - [codecCustomBlock.CountBytesProcessed] ); - codecCustomBlock.Reset; - CurrentOperation := opIdle; -end; - -function CompareFiles( const FN1, FN2: string ): Boolean; -const - BufferSizeInBytes = 1024; -var - Stream1, Stream2: TStream; - Buffer1, Buffer2: rawbytestring; - Count1, Count2, L: Integer; -begin - Stream1 := TFileStream.Create( FN1, fmOpenRead ); - Stream2 := TFileStream.Create( FN2, fmOpenRead ); - try - result := Stream1.Size = Stream2.Size; - L := BufferSizeInBytes; - SetLength( Buffer1, L ); - SetLength( Buffer2, L ); - if result then - repeat - Count1 := Stream1.Read( Buffer1[1], L ); - Count2 := Stream2.Read( Buffer2[1], L ); - result := ( Count1 = Count2 ) and CompareMem( PAnsiChar( Buffer1 ), - PAnsiChar( Buffer2 ), Count1 ); - Application.ProcessMessages - until ( not result ) or ( Count1 < L ) finally Stream1.Free; - Stream2.Free - end -end; - -procedure TmfmLockbox3_Demo.actCustomBlockSymetricCompareExecute - ( Sender: TObject ); -var - isSame: Boolean; -begin - try - isSame := CompareFiles( edtCustomBlockPlaintextFile.Text, - edtCustomBlockReconPlaintext.Text ); - if isSame then - Log( - 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) - else - Log( 'Failure! The reconstructed plaintext differs from the original.' ) - except on E: Exception do LogFmt( - 'Exception (%s) occurred during file comparison.'#13#10 + '%s', - [E.ClassName, E.Message] ) - end -end; - -procedure TmfmLockbox3_Demo.actEncryptSymetricExecute( Sender: TObject ); -var - Sz: Int64; -begin - Busy; - Sz := TPLB3.StreamUtils.FileSize( edtPlaintextFile.Text ); - CurrentOperation := opSymetricEncrypt; - try - FdidPressAbortEncrypt := False; - LogFmt - ( 'Encrypting file "%s" to "%s" using %s cipher and %s chaining mode.', [edtPlaintextFile.Text, edtCiphertextFile.Text, codecMainDemo.Cipher, codecMainDemo.ChainMode] ); - LogFmt( 'Plaintext size = %d bytes.', [Sz] ); - - codecMainDemo.EncryptFile( edtPlaintextFile.Text, edtCiphertextFile.Text ); - - if codecMainDemo.isUserAborted then - Log( 'Encryption operation aborted by user.' ) - else - LogFmt( 'Encryption succeeded. %d bytes processed.', - [codecMainDemo.CountBytesProcessed] ) - except on E: EFCreateError do LogFmt - ( 'Cannot create ciphertext file "%s".', [edtCiphertextFile.Text] ); - on E: Exception - do - if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', - E.Message ) = 1 ) then - LogFmt( 'Cannot open plaintext file "%s".', [edtPlaintextFile.Text] ) - else - LogFmt( '%s: %s', [E.ClassName, E.Message] ) - end; - if codecMainDemo.isUserAborted then - begin - end - else if codecMainDemo.Speed >= 0 then - LogFmt( 'Speed of encryption was %d KiB per second.', - [codecMainDemo.Speed] ); - codecMainDemo.Reset; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actEncryptSymetricUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := CurrentOperation = opIdle -end; - -procedure TmfmLockbox3_Demo.actSetSeedExecute( Sender: TObject ); -begin - case rgSeedingMethod.ItemIndex of - 0: - SetSeed_MSCryptAPI; - 1: - SetSeed_UserInput( edtUserInputSeed.Text ); - 2: - SetSeed_ScribblePad_Begin; - end -end; - -procedure TmfmLockbox3_Demo.SetSeed_MSCryptAPI; -var - R: TRandomStream; -begin - R := TRandomStream.Instance; - R.Randomize; - DisplayedRandSeed := R.Seed; - LogFmt( 'MS Crypt API gave us a random seed of $%16x .', [DisplayedRandSeed] ) -end; - -procedure TmfmLockbox3_Demo.SetSeed_UserInput - ( const UserInputSeedAsString: string ); -var - R: TRandomStream; -begin - R := TRandomStream.Instance; - R.Seed := DisplayedRandSeed; - LogFmt( 'The PRNG seed has been set to $%16x .', [R.Seed] ) -end; - -procedure TmfmLockbox3_Demo.SetSeed_ScribblePad_Begin; -var - R: TRect; -begin - FOp := opScribble; - R := imgScribblePad.ClientRect; - with imgScribblePad.Picture.Bitmap do - begin - Width := R.Right - R.Left; - Height := R.Bottom - R.Top; - Canvas.Pen.Color := clBlack; - Canvas.Brush.Color := clWhite; - Canvas.Rectangle( R ) - end; - pbarScribblePad.Position := 0; - pbarScribblePad.Visible := True; - imgScribblePad.Cursor := crCross; -end; - -procedure TmfmLockbox3_Demo.actSymetricCompareExecute( Sender: TObject ); -var - isSame: Boolean; -begin - try - isSame := CompareFiles( edtPlaintextFile.Text, edtReconPlaintext.Text ); - if isSame then - Log( - 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) - else - Log( 'Failure! The reconstructed plaintext differs from the original.' ) - except on E: Exception do LogFmt( - 'Exception (%s) occurred during file comparison.'#13#10 + '%s', - [E.ClassName, E.Message] ) - end -end; - -procedure TmfmLockbox3_Demo.actSymetricDecryptExecute( Sender: TObject ); -begin - Busy; - CurrentOperation := opSymetricDecrypt; - try - FdidPressAbortEncrypt := False; - LogFmt - ( 'Decrypting file "%s" to "%s" using %s cipher and %s chaining mode.', [edtCiphertextFile.Text, edtReconPlaintext.Text, codecMainDemo.Cipher, codecMainDemo.ChainMode] ); - LogFmt( 'Ciphertext size = %d bytes.', - [TPLB3.StreamUtils.FileSize( edtCiphertextFile.Text )] ); - - codecMainDemo.DecryptFile( edtReconPlaintext.Text, edtCiphertextFile.Text ); - - if codecMainDemo.isUserAborted then - Log( 'Decryption operation aborted by user.' ) - else - LogFmt( 'Decryption succeeded. %d bytes processed.', - [codecMainDemo.CountBytesProcessed] ) - except on E: EFCreateError do LogFmt( - 'Cannot create reconstructed plaintext file "%s".', - [edtReconPlaintext.Text] ); - on E: Exception - do - if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', - E.Message ) = 1 ) then - LogFmt( 'Cannot open ciphertext file "%s".', [edtCiphertextFile.Text] ) - else - LogFmt( '%s: %s', [E.ClassName, E.Message] ) - end; - if codecMainDemo.isUserAborted then - begin - end // codecMainDemo.Reset - else if codecMainDemo.Speed >= 0 then - LogFmt( 'Speed of decryption was %d KiB per second.', - [codecMainDemo.Speed] ); - codecMainDemo.Reset; - CurrentOperation := opIdle; -end; - -procedure TmfmLockbox3_Demo.actSymetricDecrypt_AbortExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actSymetricDecrypt_AbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opSymetricDecrypt ) and ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actSymetricEncrypt_AbortExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actSymetricEncrypt_AbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opSymetricEncrypt ) and ( not FdidPressAbortEncrypt ) -end; - -type - TBusy = class( TInterfacedObject ) - private - FOwner: TmfmLockbox3_Demo; - public - constructor Create( Owner1: TmfmLockbox3_Demo ); - destructor Destroy; override; - end; - -function TmfmLockbox3_Demo.Busy: IInterface; -begin - result := nil; - if Supports( FBusyObj, IInterface, result ) then - exit; - TBusy.Create( self ); - Supports( FBusyObj, IInterface, result ) -end; - -procedure TmfmLockbox3_Demo.PutLinuxLines( const Value: string ); -var - s: string; - P: Integer; -begin - s := Value; - while s <> '' do - begin - P := Pos( #10, s ); - if P > 0 then - begin - Log( Copy( s, 1, P - 1 ) ); - Delete( s, 1, P ) - end - else - begin - Log( s ); - s := '' - end; - end -end; - -procedure TmfmLockbox3_Demo.edtRSACiphertextFileRightButtonClick - ( Sender: TObject ); -begin - if actSelectCiphertext.Execute then - edtRSACiphertextFile.Text := actSelectCiphertext.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.edtRSAPlaintextFileRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtRSAPlaintextFile.Text := s; - edtRSACiphertextFile.Text := s + '_enc'; - edtRSAReconFile.Text := s + '_rcn'; - end -end; - -procedure TmfmLockbox3_Demo.edtRSAReconFileRightButtonClick( Sender: TObject ); -begin - if actSelectReconstructed.Execute then - edtRSAReconFile.Text := actSelectReconstructed.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.edtKeyStorageFileRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectKeyFile.Execute then - begin - s := actSelectKeyFile.Dialog.FileName; - edtKeyStorageFile.Text := s; - end -end; - -constructor TBusy.Create( Owner1: TmfmLockbox3_Demo ); -begin - FOwner := Owner1; - FOwner.FBusyObj := self; - FOwner.ChangeBusy( True ) -end; - -destructor TBusy.Destroy; -begin - FOwner.FBusyObj := nil; - FOwner.ChangeBusy( False ); - inherited -end; - -procedure TmfmLockbox3_Demo.ChangeBusy( isEntering: Boolean ); -begin - if isEntering then - begin - FSaveCursor := Screen.Cursor; - Screen.Cursor := crHourGlass - end - else - Screen.Cursor := FSaveCursor -end; - -function TmfmLockbox3_Demo.codecMainDemoProgress( Sender: TObject; - CountBytesProcessed: Int64 ): Boolean; -var - j: Integer; -begin - if Sender = codecMainDemo then - begin - if ( pbarSymetric.Max = 0 ) and ( codecMainDemo.EstimatedWorkLoad > 0 ) then - pbarSymetric.Max := codecMainDemo.EstimatedWorkLoad; - pbarSymetric.Position := codecMainDemo.CountBytesProcessed; - end - - else if Sender = codecCustomBlock then - begin - if ( pbarCustom.Max = 0 ) and ( codecCustomBlock.EstimatedWorkLoad > 0 ) - then - pbarCustom.Max := codecCustomBlock.EstimatedWorkLoad; - pbarCustom.Position := codecCustomBlock.CountBytesProcessed - end - - else if ( Sender = codecRSA ) and ( CurrentOperation = opRSAGen ) then - begin - j := codecRSA.FGenerateAsymetricKeyPairProgress_CountPrimalityTests; - lblPrimalityTests.Caption := Format( 'Primality tests conducted = %d', [j] ) - end - - else if ( Sender = codecRSA ) and ( CurrentOperation in [opRSAEncrypt, - opRSADecrypt] ) then - begin - if ( pbarRSA.Max = 0 ) and ( codecRSA.EstimatedWorkLoad > 0 ) then - pbarRSA.Max := codecRSA.EstimatedWorkLoad; - pbarRSA.Position := codecRSA.CountBytesProcessed - end - - else if ( Sender = Signatory1 ) and ( CurrentOperation in [opSign, - opVerify] ) then - begin - if ( pbarRSA.Max = 0 ) and ( codecRSA.EstimatedWorkLoad > 0 ) then - pbarRSA.Max := codecRSA.EstimatedWorkLoad; - pbarRSA.Position := CountBytesProcessed - end; - - result := not FdidPressAbortEncrypt; - Application.ProcessMessages; - UpdateActions -end; - -procedure TmfmLockbox3_Demo.edtCiphertextFileRightButtonClick - ( Sender: TObject ); -begin - if actSelectCiphertext.Execute then - edtCiphertextFile.Text := actSelectCiphertext.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.edtCustomBlockCiphertextFileRightButtonClick - ( Sender: TObject ); -begin - if actSelectCiphertext.Execute then - edtCustomBlockCiphertextFile.Text := actSelectCiphertext.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.edtCustomBlockPlaintextFileRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtCustomBlockPlaintextFile.Text := s; - edtCustomBlockCiphertextFile.Text := s + '_enc'; - edtCustomBlockReconPlaintext.Text := s + '_rcn'; - end -end; - -procedure TmfmLockbox3_Demo.edtCustomBlockReconPlaintextRightButtonClick - ( Sender: TObject ); -begin - if actSelectReconstructed.Execute then - edtCustomBlockReconPlaintext.Text := actSelectReconstructed.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.edtHashSourceFileRightButtonClick - ( Sender: TObject ); -begin - if actSelectPlaintext.Execute then - edtHashSourceFile.Text := actSelectPlaintext.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.Log( const Line: string ); -begin - memoLog.Lines.Add( Line ) -end; - -procedure TmfmLockbox3_Demo.LogFmt( const Line: string; - const Args: array of const ); -begin - Log( Format( Line, Args ) ) -end; - -procedure TmfmLockbox3_Demo.rgChainClick( Sender: TObject ); -begin - codecMainDemo.ChainModeId := ChainIds[rgChain.ItemIndex] -end; - -procedure TmfmLockbox3_Demo.rgCipherClick( Sender: TObject ); -const - CipherIds: array [0 .. 8] of string = ( 'native.AES-128', 'native.AES-192', - 'native.AES-256', 'native.DES', 'native.3DES.1', 'native.3DES.2', - 'native.Blowfish', 'native.Twofish', 'native.XXTEA.Large.Littleend' ); -begin - case rgCipher.ItemIndex of - 0 .. 7: // Block ciphers - begin - codecMainDemo.StreamCipherId := BlockCipher_ProgId; - codecMainDemo.BlockCipherId := CipherIds[rgCipher.ItemIndex] - end; - - 8: // Stream ciphers - codecMainDemo.StreamCipherId := CipherIds[rgCipher.ItemIndex] - end -end; - -procedure TmfmLockbox3_Demo.SetDisplayedRSeed( Value: Int64 ); -begin - edtUserInputSeed.Text := Trim( Format( '%16x', [Value] ) ) -end; - -procedure TmfmLockbox3_Demo.SetOp( NewOp: TOperation ); -begin - if FOp = NewOp then - exit; - FOp := NewOp; - if FOp <> opIdle then - begin - pbarSymetric.Max := 0; - pbarCustom.Max := 0 - end - else - begin - // tbd - end; -end; - -procedure TmfmLockbox3_Demo.actRSAGenExecute( Sender: TObject ); -begin - Busy; - Log( 'Generating RSA keys' ); - LogFmt( 'Two key pairs will be created, each of %d bits.', - [Signatory1.Codec.AsymetricKeySizeInBits] ); - FdidPressAbortEncrypt := False; - lblPrimalityTests.Caption := 'Primality tests conducted = 0'; - CurrentOperation := opRSAGen; - if Signatory1.GenerateKeys then - Log( 'Done. RSA keys successfully created.' ) - else if Signatory1.Codec.isUserAborted then - Log( 'Aborted at user request.' ) - else - Log( 'Failed.' ); - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actRSAGenUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := FOp = opIdle -end; - -procedure TmfmLockbox3_Demo.actAbortRSAGenExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actAbortRSAGenUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opRSAGen ) and ( not FdidPressAbortEncrypt ) -end; - -const - FileStreamModes: array [Boolean] of word = ( fmCreate, fmOpenReadWrite ); - -procedure TmfmLockbox3_Demo.actStoreFullKeyExecute( Sender: TObject ); -// For first the CryptoKeys and then the Signing Keys, -// store n, e and d. -var - s: string; - Store: TStream; - Mode: word; -begin - s := edtKeyStorageFile.Text; - Mode := FileStreamModes[FileExists( s )]; - try - Store := TFileStream.Create( s, Mode ); - try - if Mode = fmOpenReadWrite then - Store.Size := 0; - Signatory1.StoreKeysToStream( Store, [partPublic, partPrivate] ); - LogFmt( 'Crypto & Signing keys, both public and private parts,' + - ' stored in file "%s".', [s] ); - finally - Store.Free - end - except - LogFmt( 'Unable to open file "%s".', [s] ); - end -end; - -procedure TmfmLockbox3_Demo.actStoreFullKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opIdle ) and Signatory1.Can_SaveKeys - ( [partPublic, partPrivate] ) -end; - -procedure TmfmLockbox3_Demo.actLoadFullKeyExecute( Sender: TObject ); -// For first the CryptoKeys and then the Signing Keys, -// load n, e and d. -var - s: string; - Store: TStream; - Source: ansistring; -begin - s := edtKeyStorageFile.Text; - try - Store := TFileStream.Create( s, fmOpenRead ); - Source := Stream_to_Base64( Store ); - Store.Position := 0; - try - Signatory1.LoadKeysFromStream( Store, [partPublic, partPrivate] ); - LogFmt( 'Crypto & Signing keys, both public and private parts,' + - ' loaded from file "%s".', [s] ); - finally - Store.Free - end - except - LogFmt( 'Unable to open file "%s".', [s] ); - end; -end; - -procedure TmfmLockbox3_Demo.actLoadFullKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actLoadPublicKeyExecute( Sender: TObject ); -// For first the CryptoKeys and then the Signing Keys, -// load n and e. d should be cleared. -var - s: string; - Store: TStream; -begin - s := edtKeyStorageFile.Text; - try - Store := TFileStream.Create( s, fmOpenRead ); - try - Signatory1.LoadKeysFromStream( Store, [partPublic] ); - LogFmt( 'Crypto & Signing keys, public parts only,' + - ' loaded from file "%s".', [s] ); - finally - Store.Free - end - except - LogFmt( 'Unable to open file "%s".', [s] ); - end -end; - -procedure TmfmLockbox3_Demo.actLoadPublicKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actStorePublicKeyExecute( Sender: TObject ); -// For first the CryptoKeys and then the Signing Keys, -// store n and e. -var - s: string; - Store: TStream; - Mode: word; -begin - s := edtKeyStorageFile.Text; - Mode := FileStreamModes[FileExists( s )]; - try - Store := TFileStream.Create( s, Mode ); - try - if Mode = fmOpenReadWrite then - Store.Size := 0; - Signatory1.StoreKeysToStream( Store, [partPublic] ); - LogFmt( 'Crypto & Signing public keys stored in file "%s".', [s] ); - finally - Store.Free - end - except - LogFmt( 'Unable to open file "%s".', [s] ); - end -end; - -procedure TmfmLockbox3_Demo.actStorePublicKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opIdle ) and Signatory1.Can_SaveKeys - ( [partPublic] ) -end; - -procedure TmfmLockbox3_Demo.actRSAEncryptExecute( Sender: TObject ); -var - Sz: Int64; -begin - Busy; - Sz := TPLB3.StreamUtils.FileSize( edtRSAPlaintextFile.Text ); - CurrentOperation := opRSAEncrypt; - try - FdidPressAbortEncrypt := False; - LogFmt( 'Encrypting file "%s" to "%s" using %s cipher.', - [edtRSAPlaintextFile.Text, edtRSACiphertextFile.Text, codecRSA.Cipher] ); - LogFmt( 'Plaintext size = %d bytes.', [Sz] ); - - pbarRSA.Max := 0; - codecRSA.EncryptFile( edtRSAPlaintextFile.Text, edtRSACiphertextFile.Text ); - - if codecRSA.isUserAborted then - Log( 'Encryption operation aborted by user.' ) - else - LogFmt( 'Encryption succeeded. %d bytes processed.', - [codecRSA.CountBytesProcessed] ) except on E: EFCreateError do LogFmt - ( 'Cannot create ciphertext file "%s".', [edtRSACiphertextFile.Text] ); - on E: Exception - do - if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', - E.Message ) = 1 ) then - LogFmt( 'Cannot open plaintext file "%s".', [edtRSAPlaintextFile.Text] ) - else - LogFmt( '%s: %s', [E.ClassName, E.Message] ) - end; - if codecRSA.isUserAborted then - begin - end - else if codecRSA.Speed >= 0 then - LogFmt( 'Speed of encryption was %d KiB per second.', [codecRSA.Speed] ); - codecRSA.Reset; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actRSAEncryptUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opIdle ) and ( codecRSA.Mode = cmIdle ) and - ( partPublic in Signatory1.HasParts ) -end; - -procedure TmfmLockbox3_Demo.actRSAEncryptAbortExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actRSAEncryptAbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opRSAEncrypt ) and ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actRSACompareExecute( Sender: TObject ); -var - isSame: Boolean; -begin - try - isSame := CompareFiles( edtRSAPlaintextFile.Text, edtRSAReconFile.Text ); - if isSame then - Log( - 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) - else - Log( 'Failure! The reconstructed plaintext differs from the original.' ) - except on E: Exception do LogFmt( - 'Exception (%s) occurred during file comparison.'#13#10 + '%s', - [E.ClassName, E.Message] ) - end -end; - -procedure TmfmLockbox3_Demo.actRSACompareUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := CurrentOperation = opIdle -end; - -procedure TmfmLockbox3_Demo.actRSADecryptAbortExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actRSADecryptAbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opRSADecrypt ) and ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actRSADecryptExecute( Sender: TObject ); -begin - Busy; - CurrentOperation := opRSADecrypt; - try - FdidPressAbortEncrypt := False; - LogFmt( 'Decrypting file "%s" to "%s" using %s cipher.', - [edtRSACiphertextFile.Text, edtRSAReconFile.Text, codecRSA.Cipher] ); - LogFmt( 'Ciphertext size = %d bytes.', - [TPLB3.StreamUtils.FileSize( edtRSACiphertextFile.Text )] ); - - pbarRSA.Max := 0; - codecRSA.DecryptFile( edtRSAReconFile.Text, edtRSACiphertextFile.Text ); - - if codecRSA.isUserAborted then - Log( 'Decryption operation aborted by user.' ) - else - LogFmt( 'Decryption succeeded. %d bytes processed.', - [codecRSA.CountBytesProcessed] ) except on E: EFCreateError do LogFmt - ( 'Cannot create reconstructed plaintext file "%s".', - [edtRSAReconFile.Text] ); - on E: Exception - do - if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', - E.Message ) = 1 ) then - LogFmt( 'Cannot open ciphertext file "%s".', [edtRSACiphertextFile.Text] ) - else - LogFmt( '%s: %s', [E.ClassName, E.Message] ) - end; - if codecRSA.isUserAborted then - begin - end // codecRSA.Reset - else if codecRSA.Speed >= 0 then - LogFmt( 'Speed of decryption was %d KiB per second.', - [codecRSA.Speed] ); - codecRSA.Reset; - CurrentOperation := opIdle; -end; - -procedure TmfmLockbox3_Demo.actRSADecryptUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opIdle ) and ( codecRSA.Mode = cmIdle ) and - ( partPrivate in Signatory1.HasParts ) -end; -{$HINTS OFF} - -procedure TmfmLockbox3_Demo.actSignExecute( Sender: TObject ); -var - Sz: Int64; - wasAborted: Boolean; - DocumentStream, SignatureStream: TStream; - DestinFileMode: word; -begin - Busy; - Sz := TPLB3.StreamUtils.FileSize( edtRSADocumentFile.Text ); - CurrentOperation := opSign; - try - FdidPressAbortEncrypt := False; - LogFmt( 'Signing file "%s" into "%s".', [edtRSADocumentFile.Text, - edtRSASignatureFile.Text] ); - LogFmt( 'Document size = %d bytes.', [Sz] ); - - wasAborted := False; - pbarRSA.Max := 0; - DocumentStream := nil; - SignatureStream := nil; - DocumentStream := TFileStream.Create( edtRSADocumentFile.Text, fmOpenRead ); - DestinFileMode := FileStreamModes[FileExists( edtRSASignatureFile.Text )]; - try - SignatureStream := TFileStream.Create( edtRSASignatureFile.Text, - DestinFileMode ); - try - if DestinFileMode = FileStreamModes[True] then - SignatureStream.Size := 0; - wasAborted := not Signatory1.Sign( DocumentStream, SignatureStream ); - finally - SignatureStream.Free - end; - finally - DocumentStream.Free; - end; - if wasAborted then - Log( 'Signature operation aborted by user.' ) - else - Log( 'Signing succeeded.' ) except on E: EFCreateError do LogFmt - ( 'Cannot create signature file "%s".', [edtRSASignatureFile.Text] ); - on E: Exception - do - if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', - E.Message ) = 1 ) then - LogFmt( 'Cannot open document "%s".', [edtRSADocumentFile.Text] ) - else - LogFmt( '%s: %s', [E.ClassName, E.Message] ) - end; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.edtRSADocumentFileRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtRSADocumentFile.Text := s; - edtRSASignatureFile.Text := s + '_sig'; - end -end; - -procedure TmfmLockbox3_Demo.edtRSASignatureFileRightButtonClick - ( Sender: TObject ); -begin - if actSelectCiphertext.Execute then - edtRSASignatureFile.Text := actSelectCiphertext.Dialog.FileName -end; - -procedure TmfmLockbox3_Demo.actSignUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opIdle ) and ( partPrivate in Signatory1.HasParts ) -end; - -procedure TmfmLockbox3_Demo.actVerifyExecute( Sender: TObject ); -var - Sz: Int64; - wasAborted: Boolean; - DocumentStream, SignatureStream: TStream; - Res: TVerifyResult; -begin - Busy; - Sz := TPLB3.StreamUtils.FileSize( edtRSADocumentFile.Text ); - CurrentOperation := opVerify; - try - FdidPressAbortEncrypt := False; - LogFmt( 'Verifying signature file "%s" as "%s".', [edtRSADocumentFile.Text, - edtRSASignatureFile.Text] ); - LogFmt( 'Document size = %d bytes.', [Sz] ); - - wasAborted := False; - pbarRSA.Max := 0; - DocumentStream := nil; - SignatureStream := nil; - DocumentStream := TFileStream.Create( edtRSADocumentFile.Text, fmOpenRead ); - try - SignatureStream := TFileStream.Create( edtRSASignatureFile.Text, - fmOpenRead ); - try - Res := Signatory1.Verify( DocumentStream, SignatureStream ) - finally SignatureStream.Free - end; - finally - DocumentStream.Free; - end; - case Res of - vPass: - Log( 'Signature valid.' ); - vFail: - Log( 'Signature invalid.' ); - vUserAbort: - Log( 'Verification aborted by user.' ) - end; - except - Log( 'Error' ); - end; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actVerifyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp = opIdle ) and ( partPrivate in Signatory1.HasParts ) -end; -{$WARNINGS OFF} - -procedure TmfmLockbox3_Demo.btnComputeHashClick( Sender: TObject ); -var - a: string; - s: string; - HashWord: uint32; - Xfer: Integer; -begin - if rgHashSource.ItemIndex <= 0 then - begin - a := edtHashSource.Text; - StringHash.HashString( a, TEncoding.UTF8); - LogFmt - ( 'SHA-384 of utf-8 string ''%s'' rendered in little-endien base64 is:', - [a] ) - end - else - begin - s := edtHashSource.Text; - StringHash.HashString( s ); -{$IFDEF UNICODE} - LogFmt( 'SHA-384 of UTF-16 ''%s'' rendered in little-endien base64 is:', - [s] ) -{$ELSE} - Log( 'This compiler does not support UTF-16.' ); - LogFmt - ( 'SHA-384 of ansistring ''%s'' rendered in little-endien heximal is:', [s] ) -{$ENDIF} - end; - a := '$'; - repeat - HashWord := 0; - Xfer := StringHash.HashOutputValue.Read( HashWord, SizeOf( HashWord ) ); - if Xfer = 0 then - break; - if a <> '$' then - a := a + ' '; - a := a + Format( Format( '%%.%dx', [Xfer * 2] ), [HashWord] ) - until Xfer < SizeOf( HashWord ); - LogFmt( 'Hash = %s', [a] ) -end; - -procedure TmfmLockbox3_Demo.actSignVerifyAbortExecute( Sender: TObject ); -begin - FdidPressAbortEncrypt := True -end; - -procedure TmfmLockbox3_Demo.actSignVerifyAbortUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( FOp in [opSign, opVerify] ) and ( not FdidPressAbortEncrypt ) -end; - -procedure TmfmLockbox3_Demo.actHashExecute( Sender: TObject ); -var - aByte: byte; - s: string; -begin - Busy; - CurrentOperation := opHash; - pressedAbortHash := False; - try - ScribbleHash.HashFile( edtHashSourceFile.Text ); - s := ''; - while ScribbleHash.HashOutputValue.Read( aByte, 1 ) = 1 do - s := s + Format( '%.2x', [aByte] ) finally CurrentOperation := opIdle - end; - ScribbleHash.Burn; - if ScribbleHash.isUserAborted then - Log( 'Hashing operation aborted by user.' ) - else - LogFmt( 'SHA-1 digest (little-endien) is $%s', [s] ) -end; - -procedure TmfmLockbox3_Demo.actAbortHashExecute( Sender: TObject ); -begin - pressedAbortHash := True -end; - -procedure TmfmLockbox3_Demo.actAbortHashUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( CurrentOperation = opHash ) and ( not pressedAbortHash ) -end; - -function TmfmLockbox3_Demo.ScribbleHashProgress( Sender: TObject; - CountBytesProcessed: Int64 ): Boolean; -begin - result := True; - Application.ProcessMessages; - if ( CurrentOperation = opHash ) and pressedAbortHash then - result := False -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadLibExecute( Sender: TObject ); -begin - Sig.LibPath := edtOpenSSLLibPath.Text; - Sig.Clear; - Sig.isLoaded := True; - if Sig.isLoaded then - begin - Log( 'The OpenSSL library libeay32.dll was loaded successfully.' ); - LogFmt( 'libeay32.dll version is %d.%d.%d.%d', [Sig.MajorV, Sig.MinorV, - Sig.ReleaseV, Sig.BuildV] ) - end - else - begin - Log( 'Failed to load library.' ); - case Sig.Err of - erLoadFailed, erException: - Log( Sig.ErrMsg ); - erVersionTooLow: - begin - Log( - 'Found libeay32.dll, but it was too lowly versioned. Update your OpenSSL binaries!' ); - LogFmt( 'Required version is %s', [Sig.RequiredVersion] ) - end; - erSignatureAbsent: - Log( 'Found libeay32.dll, but the API access seemed to be absent.' ); - end - end; -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadLibUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( not Sig.isLoaded ) and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLUnloadLibExecute( Sender: TObject ); -begin - Sig.isLoaded := False; - Log( 'libeay32.dll unloaded successfully.' ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLUnloadLibUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLGenKeyExecute( Sender: TObject ); -begin - Sig.AsymetricKeySizeInBits := 2048; - CurrentOperation := opOpenSSL; - if Sig.GenerateKeys then - PutLinuxLines( Sig.Print ) - else - Log( Sig.ErrMsg ); - CurrentOperation := opIdle -end; - -function TmfmLockbox3_Demo.SigProgress( Sender: TObject; - p1, p2: Integer ): Boolean; -begin - result := True; - LogFmt( 'OpenSSL progress event: p1=%d; p2=%d', [p1, p2] ); - Application.ProcessMessages -end; - -procedure TmfmLockbox3_Demo.actOpenSSLGenKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadPrivateKeyExecute( Sender: TObject ); -var - Store: TStream; -begin - dlgOpenPEM.Title := 'Select private key file in PEM format to open'; - if not dlgOpenPEM.Execute then - exit; - try - Store := TFileStream.Create( dlgOpenPEM.FileName, fmOpenRead ); - try - Sig.LoadKeysFromStream( Store, [partPrivate, partPublic] ) - finally Store.Free - end; - Log( 'Private key (together with public key) successfully loaded.' ) - except on E: Exception - do Log( E.Message ) - end -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadPrivateKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadPublicKeyExecute( Sender: TObject ); -var - Store: TStream; -begin - dlgOpenPEM.Title := 'Select public key file in PEM format to open'; - if not dlgOpenPEM.Execute then - exit; - try - Store := TFileStream.Create( dlgOpenPEM.FileName, fmOpenRead ); - try - Sig.LoadKeysFromStream( Store, [partPublic] ) finally Store.Free - end; - Log( 'Public key (without private key) successfully loaded.' ) - except on E: Exception - do Log( E.Message ) - end -end; - -procedure TmfmLockbox3_Demo.actOpenSSLLoadPublicKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSavePrivateKeyExecute( Sender: TObject ); -var - Store: TStream; - doesPreExist: Boolean; -begin - dlgSavePEM.Title := 'Select private key file in PEM format to save to'; - if not dlgSavePEM.Execute then - exit; - try - doesPreExist := FileExists( dlgSavePEM.FileName ); - Store := TFileStream.Create( dlgSavePEM.FileName, - FileStreamModes[doesPreExist] ); - try - if doesPreExist then - Store.Size := 0; - Sig.StoreKeysToStream( Store, [partPrivate, partPublic] ) - finally Store.Free - end; - Log( 'Private key (together with public key) successfully saved to file.' ) - except on E: Exception - do Log( E.Message ) - end -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSavePrivateKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := partPrivate in Sig.HasParts -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSavePublicKeyExecute( Sender: TObject ); -var - Store: TStream; - doesPreExist: Boolean; -begin - dlgSavePEM.Title := 'Select public key file in PEM format to save to'; - if not dlgSavePEM.Execute then - exit; - try - doesPreExist := FileExists( dlgSavePEM.FileName ); - Store := TFileStream.Create( dlgSavePEM.FileName, - FileStreamModes[doesPreExist] ); - try - if doesPreExist then - Store.Size := 0; - Sig.StoreKeysToStream( Store, [partPublic] ) finally Store.Free - end; - Log( 'Public key (without private key) successfully saved to file.' ) - except on E: Exception - do Log( E.Message ) - end -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSavePublicKeyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := partPublic in Sig.HasParts -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSignExecute( Sender: TObject ); -var - PreHash: TSigHashKind; - HashedDocument, Signature: TStream; - doesPreExist: Boolean; - Len: Integer; - sSignature: utf8string; -begin - if rgOpenSSLHash.ItemIndex = 0 then - begin - PreHash := hshSHA1; - ScribbleHash.HashId := SHA1_ProgId - end - else - begin - PreHash := hshMD5; - ScribbleHash.HashId := MD5_ProgId - end; - try - ScribbleHash.HashFile( edtOpenSSLDocument.Text ); - HashedDocument := TMemoryStream.Create; - Signature := nil; - CurrentOperation := opOpenSSL; - try - HashedDocument.CopyFrom( ScribbleHash.HashOutputValue, 0 ); - ScribbleHash.HashId := SHA1_ProgId; - HashedDocument.Position := 0; - doesPreExist := FileExists( edtOpenSSLSignature.Text ); - Signature := TFileStream.Create( edtOpenSSLSignature.Text, - FileStreamModes[doesPreExist] ); - if doesPreExist then - Signature.Size := 0; - if Sig.Sign( PreHash, HashedDocument, Signature ) then - begin - Signature.Position := 0; - Len := Signature.Size; - SetLength( sSignature, Len ); - if Len > 0 then - Signature.Read( sSignature[1], Len ); - FreeAndNil( Signature ); - Log( 'Signature successfully saved to file.' ) - end - else - Log( Sig.ErrMsg ) finally HashedDocument.Free; - Signature.Free - end - except - on E: Exception do - Log( E.Message ) - end; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actOpenSSLSignUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( partPrivate in Sig.HasParts ) and - ( edtOpenSSLDocument.Text <> '' ) and ( edtOpenSSLSignature.Text <> '' ) - and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.actOpenSSLVerifyExecute( Sender: TObject ); -var - PreHash: TSigHashKind; - HashedDocument, Signature: TStream; - doesPreExist: Boolean; - Len: Integer; - sSignature: utf8string; -begin - if rgOpenSSLHash.ItemIndex = 0 then - begin - PreHash := hshSHA1; - ScribbleHash.HashId := SHA1_ProgId - end - else - begin - PreHash := hshMD5; - ScribbleHash.HashId := MD5_ProgId - end; - try - ScribbleHash.HashFile( edtOpenSSLDocument.Text ); - HashedDocument := TMemoryStream.Create; - Signature := nil; - CurrentOperation := opOpenSSL; - try - HashedDocument.CopyFrom( ScribbleHash.HashOutputValue, 0 ); - ScribbleHash.HashId := SHA1_ProgId; - HashedDocument.Position := 0; - Signature := TFileStream.Create( edtOpenSSLSignature.Text, fmOpenRead ); - if Sig.Verify( PreHash, HashedDocument, Signature ) = vPass then - Log( 'Signature verification PASSED.' ) - else - Log( 'Signature verification FAILED.' ) finally HashedDocument.Free; - Signature.Free - end - except - on E: Exception do - Log( E.Message ) - end; - CurrentOperation := opIdle -end; - -procedure TmfmLockbox3_Demo.actOpenSSLVerifyUpdate( Sender: TObject ); -begin ( Sender as TAction ) - .Enabled := ( partPublic in Sig.HasParts ) and - ( edtOpenSSLDocument.Text <> '' ) and ( edtOpenSSLSignature.Text <> '' ) - and ( CurrentOperation = opIdle ) -end; - -procedure TmfmLockbox3_Demo.edtOpenSSLDocumentRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtOpenSSLDocument.Text := s; - edtOpenSSLSignature.Text := s + '_sig'; - end -end; - -procedure TmfmLockbox3_Demo.edtOpenSSLSignatureRightButtonClick - ( Sender: TObject ); -var - s: string; -begin - if actSelectPlaintext.Execute then - begin - s := actSelectPlaintext.Dialog.FileName; - edtOpenSSLSignature.Text := s - end -end; - -end. +unit umfmLockbox3_Demo; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, ComCtrls, ActnList, StdActns, ImgList, + PlatformDefaultStyleActnCtrls, ActnMan, ExtCtrls, + TPLB3.Signatory, TPLB3.OpenSSL, TPLB3.Hash, + TPLB3.Codec, TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, + System.Actions, System.ImageList; + +type + TOperation = ( opIdle, opSymetricEncrypt, opSymetricDecrypt, + opSymetricCompare, opScribble, + opCustomBlockSymetricEncrypt, + opCustomBlockSymetricDecrypt, opRSAGen, opRSAEncrypt, opRSADecrypt, opSign, + opVerify, opHash, opOpenSSL ); + + TmfmLockbox3_Demo = class( TForm ) + memoLog: TMemo; + actmngrMainDemoActions: TActionManager; + imglstActionGlyphs_16x16: TImageList; + actSelectPlaintext: TFileOpen; + actSelectCiphertext: TFileOpen; + CryptographicLibrary1: TCryptographicLibrary; + codecMainDemo: TCodec; + actEncryptSymetric: TAction; + actSymetricEncrypt_Abort: TAction; + actSymetricDecrypt: TAction; + actSymetricDecrypt_Abort: TAction; + actSymetricCompare: TAction; + actSelectReconstructed: TFileOpen; + actSetSeed: TAction; + ScribbleHash: THash; + actAbortScribble: TAction; + actCustomBlockEncrypt: TAction; + codecCustomBlock: TCodec; + actCustomBlockEncryptAbort: TAction; + actCustomBlockDecrypt: TAction; + actCustomBlockDecryptAbort: TAction; + actCustomBlockSymetricCompare: TAction; + Signatory1: TSignatory; + codecRSA: TCodec; + actRSAGen: TAction; + actAbortRSAGen: TAction; + actStoreFullKey: TAction; + actSelectKeyFile: TFileOpen; + actLoadFullKey: TAction; + actStorePublicKey: TAction; + actLoadPublicKey: TAction; + actRSAEncrypt: TAction; + actRSAEncryptAbort: TAction; + actRSADecrypt: TAction; + actRSADecryptAbort: TAction; + actRSACompare: TAction; + actSign: TAction; + actVerify: TAction; + actSignVerifyAbort: TAction; + actHash: TAction; + actAbortHash: TAction; + StringHash: THash; + pcClient: TPageControl; + tbSymetric: TTabSheet; + lblPlaintextFile: TLabel; + lblCiphertextFile: TLabel; + lblReconPlaintext: TLabel; + shDivider_SymetricEncrypt: TShape; + shDivider_SymetricDecrypt: TShape; + edtPlaintextFile: TButtonedEdit; + edtCiphertextFile: TButtonedEdit; + rgCipher: TRadioGroup; + rgChain: TRadioGroup; + lblPassword: TLabeledEdit; + btnSymetricEncrypt: TButton; + edtReconPlaintext: TButtonedEdit; + btnSymetricDecrypt: TButton; + btnSymetricCompare: TButton; + btnSymetricEncrypt_Abort: TButton; + btnSymetricDecrypt_Abort: TButton; + pbarSymetric: TProgressBar; + tbSeeding: TTabSheet; + bvlScriblePad: TBevel; + lblCurrentSeedLabel: TLabel; + lblCurrentSeed: TLabel; + imgScribblePad: TImage; + memoInstructions: TMemo; + rgSeedingMethod: TRadioGroup; + btnSetSeed: TButton; + btnAbortScribble: TButton; + pbarScribblePad: TProgressBar; + edtUserInputSeed: TEdit; + tbSymetricExtent: TTabSheet; + Label1: TLabel; + Label2: TLabel; + Shape1: TShape; + Label3: TLabel; + Shape2: TShape; + Label4: TLabel; + rgCustomBlockChain: TRadioGroup; + lblCustomBlockPassword: TLabeledEdit; + edtCustomBlockPlaintextFile: TButtonedEdit; + edtCustomBlockCiphertextFile: TButtonedEdit; + Button1: TButton; + Button2: TButton; + edtCustomBlockReconPlaintext: TButtonedEdit; + Button3: TButton; + Button4: TButton; + Button5: TButton; + pbarCustom: TProgressBar; + memoCustomBlockInstruction: TMemo; + tbKeyGen: TTabSheet; + Shape3: TShape; + lblKeyStorageFile: TLabel; + lblPrimalityTests: TLabel; + btnRSAGen: TButton; + btnAbortGen: TButton; + edtKeyStorageFile: TButtonedEdit; + btnStoreFullKey: TButton; + btnPublicStore: TButton; + btnLoadFullKey: TButton; + btnPublicLoad: TButton; + tbSignature: TTabSheet; + lblRSAPlaintextFile: TLabel; + lblRSACiphertextFile: TLabel; + shDivider_RSAEncrypt: TShape; + lblRSAReconFile: TLabel; + shDivider_RSASign: TShape; + Label9: TLabel; + lblRSADocumentFile: TLabel; + edtRSAPlaintextFile: TButtonedEdit; + edtRSACiphertextFile: TButtonedEdit; + btnRSAEncrypt: TButton; + btnRSAEncryptAbort: TButton; + edtRSAReconFile: TButtonedEdit; + btnRSADecrypt: TButton; + btnRSADecryptAbort: TButton; + btnRSACompare: TButton; + pbarRSA: TProgressBar; + edtRSADocumentFile: TButtonedEdit; + edtRSASignatureFile: TButtonedEdit; + btnSign: TButton; + btnSignVerifyAbort: TButton; + btnVerify: TButton; + tbHashes: TTabSheet; + lblHashSourceFile: TLabel; + lblHashSourceString: TLabel; + edtHashSourceFile: TButtonedEdit; + btnHash: TButton; + btnHashAbort: TButton; + edtHashSource: TEdit; + rgHashSource: TRadioGroup; + btnComputeHash: TButton; + tbOpenSSL: TTabSheet; + Sig: TOpenSSL_Signatory; + btnOpenSSLLoadLib: TButton; + edtOpenSSLLibPath: TLabeledEdit; + btnOpenSSLUnloadLib: TButton; + btnOpenSSLGenKey: TButton; + btnOpenSSLLoadPrivateKey: TButton; + btnOpenSSLLoadPublicKey: TButton; + btnOpenSSLSavePrivateKey: TButton; + btnOpenSSLSavePublicKey: TButton; + lblOpenSSLDocument: TLabel; + edtOpenSSLDocument: TButtonedEdit; + btnOpenSSLSign: TButton; + btnOpenSSLVerify: TButton; + lblOpenSSLSignature: TLabel; + edtOpenSSLSignature: TButtonedEdit; + rgOpenSSLHash: TRadioGroup; + sepOpenSSLLibeay32: TShape; + Shape4: TShape; + pnlOpenSSLLibSection: TPanel; + pnlOpenSSLKeyAcquisitionHeading: TPanel; + pnlOpenSSLKeySaving: TPanel; + Shape5: TShape; + pnlOpenSSLSignatureAndVerification: TPanel; + actOpenSSLLoadLib: TAction; + actOpenSSLUnloadLib: TAction; + actOpenSSLGenKey: TAction; + actOpenSSLLoadPrivateKey: TAction; + actOpenSSLLoadPublicKey: TAction; + actOpenSSLSavePrivateKey: TAction; + actOpenSSLSavePublicKey: TAction; + actOpenSSLSign: TAction; + actOpenSSLVerify: TAction; + dlgOpenPEM: TOpenDialog; + dlgSavePEM: TSaveDialog; + procedure FormCreate( Sender: TObject ); + procedure edtPlaintextFileRightButtonClick( Sender: TObject ); + procedure edtCiphertextFileRightButtonClick( Sender: TObject ); + function codecMainDemoProgress( Sender: TObject; + CountBytesProcessed: Int64 ): Boolean; + procedure actEncryptSymetricExecute( Sender: TObject ); + procedure actSymetricEncrypt_AbortExecute( Sender: TObject ); + procedure actSymetricEncrypt_AbortUpdate( Sender: TObject ); + procedure actSymetricDecryptExecute( Sender: TObject ); + procedure actSymetricDecrypt_AbortExecute( Sender: TObject ); + procedure actSymetricDecrypt_AbortUpdate( Sender: TObject ); + procedure rgCipherClick( Sender: TObject ); + procedure rgChainClick( Sender: TObject ); + procedure lblPasswordExit( Sender: TObject ); + procedure edtReconPlaintextRightButtonClick( Sender: TObject ); + procedure actEncryptSymetricUpdate( Sender: TObject ); + procedure actSymetricCompareExecute( Sender: TObject ); + procedure actSetSeedExecute( Sender: TObject ); + procedure imgScribblePadMouseMove( Sender: TObject; Shift: TShiftState; + X, Y: Integer ); + procedure FormDestroy( Sender: TObject ); + procedure actAbortScribbleExecute( Sender: TObject ); + procedure actAbortScribbleUpdate( Sender: TObject ); + procedure actCustomBlockEncryptExecute( Sender: TObject ); + procedure actCustomBlockEncryptAbortExecute( Sender: TObject ); + procedure actCustomBlockEncryptAbortUpdate( Sender: TObject ); + procedure edtCustomBlockPlaintextFileRightButtonClick( Sender: TObject ); + procedure edtCustomBlockCiphertextFileRightButtonClick( Sender: TObject ); + procedure edtCustomBlockReconPlaintextRightButtonClick( Sender: TObject ); + procedure actCustomBlockDecryptExecute( Sender: TObject ); + procedure actCustomBlockDecryptAbortExecute( Sender: TObject ); + procedure actCustomBlockDecryptAbortUpdate( Sender: TObject ); + procedure actCustomBlockSymetricCompareExecute( Sender: TObject ); + procedure actRSAGenExecute( Sender: TObject ); + procedure actRSAGenUpdate( Sender: TObject ); + procedure actAbortRSAGenExecute( Sender: TObject ); + procedure actAbortRSAGenUpdate( Sender: TObject ); + procedure actStoreFullKeyExecute( Sender: TObject ); + procedure edtKeyStorageFileRightButtonClick( Sender: TObject ); + procedure actStoreFullKeyUpdate( Sender: TObject ); + procedure actLoadFullKeyExecute( Sender: TObject ); + procedure actLoadFullKeyUpdate( Sender: TObject ); + procedure actStorePublicKeyExecute( Sender: TObject ); + procedure actStorePublicKeyUpdate( Sender: TObject ); + procedure actLoadPublicKeyExecute( Sender: TObject ); + procedure actLoadPublicKeyUpdate( Sender: TObject ); + procedure edtRSAPlaintextFileRightButtonClick( Sender: TObject ); + procedure edtRSACiphertextFileRightButtonClick( Sender: TObject ); + procedure edtRSAReconFileRightButtonClick( Sender: TObject ); + procedure edtHashSourceFileRightButtonClick( Sender: TObject ); + procedure actRSAEncryptExecute( Sender: TObject ); + procedure actRSAEncryptUpdate( Sender: TObject ); + procedure actRSAEncryptAbortExecute( Sender: TObject ); + procedure actRSAEncryptAbortUpdate( Sender: TObject ); + procedure actRSADecryptExecute( Sender: TObject ); + procedure actRSADecryptUpdate( Sender: TObject ); + procedure actRSADecryptAbortExecute( Sender: TObject ); + procedure actRSADecryptAbortUpdate( Sender: TObject ); + procedure actRSACompareExecute( Sender: TObject ); + procedure actRSACompareUpdate( Sender: TObject ); + procedure actSignExecute( Sender: TObject ); + procedure actSignUpdate( Sender: TObject ); + procedure actVerifyExecute( Sender: TObject ); + procedure actVerifyUpdate( Sender: TObject ); + procedure actSignVerifyAbortExecute( Sender: TObject ); + procedure actSignVerifyAbortUpdate( Sender: TObject ); + procedure edtRSADocumentFileRightButtonClick( Sender: TObject ); + procedure edtRSASignatureFileRightButtonClick( Sender: TObject ); + procedure actHashExecute( Sender: TObject ); + procedure actAbortHashExecute( Sender: TObject ); + procedure actAbortHashUpdate( Sender: TObject ); + function ScribbleHashProgress( Sender: TObject; + CountBytesProcessed: Int64 ): Boolean; + procedure btnComputeHashClick( Sender: TObject ); + procedure actOpenSSLLoadLibExecute( Sender: TObject ); + procedure actOpenSSLLoadLibUpdate( Sender: TObject ); + procedure actOpenSSLUnloadLibExecute( Sender: TObject ); + procedure actOpenSSLUnloadLibUpdate( Sender: TObject ); + procedure actOpenSSLGenKeyExecute( Sender: TObject ); + procedure actOpenSSLGenKeyUpdate( Sender: TObject ); + procedure actOpenSSLLoadPrivateKeyExecute( Sender: TObject ); + procedure actOpenSSLLoadPrivateKeyUpdate( Sender: TObject ); + procedure actOpenSSLLoadPublicKeyExecute( Sender: TObject ); + procedure actOpenSSLLoadPublicKeyUpdate( Sender: TObject ); + procedure actOpenSSLSavePrivateKeyExecute( Sender: TObject ); + procedure actOpenSSLSavePrivateKeyUpdate( Sender: TObject ); + procedure actOpenSSLSavePublicKeyExecute( Sender: TObject ); + procedure actOpenSSLSavePublicKeyUpdate( Sender: TObject ); + procedure actOpenSSLSignExecute( Sender: TObject ); + procedure actOpenSSLSignUpdate( Sender: TObject ); + procedure actOpenSSLVerifyExecute( Sender: TObject ); + procedure actOpenSSLVerifyUpdate( Sender: TObject ); + procedure edtOpenSSLDocumentRightButtonClick( Sender: TObject ); + procedure edtOpenSSLSignatureRightButtonClick( Sender: TObject ); + function SigProgress( Sender: TObject; p1, p2: Integer ): Boolean; + + private + FOp: TOperation; + // FCountBytesProcessed: int64; + // FEstimatedWorkLoad: int64; + FdidPressAbortEncrypt: Boolean; + FScribblePad_EntropyBag: TStream; + FBusyObj: TObject; // TBusy + FSaveCursor: TCursor; + pressedAbortHash: Boolean; + + procedure SetOp( NewOp: TOperation ); + procedure SetSeed_MSCryptAPI; + procedure SetSeed_UserInput( const UserInputSeedAsString: string ); + procedure SetSeed_ScribblePad_Begin; + function GetDisplayedRSeed: Int64; + procedure SetDisplayedRSeed( Value: Int64 ); + function Busy: IInterface; + procedure ChangeBusy( isEntering: Boolean ); + procedure PutLinuxLines( const Value: string ); + + // procedure BuildPermuteTable( const OrderOfBattle: string); + + public + procedure Log( const Line: string ); + procedure LogFmt( const Line: string; const Args: array of const ); + + property CurrentOperation: TOperation read FOp write SetOp; + property DisplayedRandSeed + : Int64 read GetDisplayedRSeed write SetDisplayedRSeed; + end; + +var + mfmLockbox3_Demo: TmfmLockbox3_Demo; + +implementation + +uses TPLB3.Random, uDemoBlockModeCipher, TPLB3.Constants, TPLB3.Asymetric, + TPLB3.StreamUtils, TPLB3.StreamCipher, TPLB3.CodecIntf, + TPLB3.DES, TPLB3.StreamToBlock, TPLB3.AES, TPLB3.CBC, + + TPLB3.XXTEA, Types; +{$R *.dfm} + +procedure TmfmLockbox3_Demo.FormCreate( Sender: TObject ); +begin + FOp := opIdle; + FdidPressAbortEncrypt := False; + memoLog.Clear; + Log( 'Welcome to the LockBox 3 Demonstration Program.' ); + codecMainDemo.StreamCipherId := BlockCipher_ProgId; + codecMainDemo.Password := lblPassword.Text; + rgChainClick( nil ); + rgCipherClick( nil ); + FScribblePad_EntropyBag := TMemoryStream.Create; + TDemoBlockModeCipher.SelfRegister( CryptographicLibrary1 ) +end; + +procedure TmfmLockbox3_Demo.FormDestroy( Sender: TObject ); +begin + FScribblePad_EntropyBag.Free +end; + +function TmfmLockbox3_Demo.GetDisplayedRSeed: Int64; +var + s: string; + Code: Integer; +begin + s := '$' + Trim( edtUserInputSeed.Text ); + Val( s, result, Code ); + if Code <> 0 then + begin + LogFmt( '"%s" is not a valid hexidecimal integer.', + [edtUserInputSeed.Text] ); + result := 0 + end +end; + +procedure TmfmLockbox3_Demo.imgScribblePadMouseMove( Sender: TObject; + Shift: TShiftState; X, Y: Integer ); +var + Now1: TDateTime; + NewSeed: Int64; + R: TRandomStream; + + procedure ConsumeEntropy( const Data; DataSize: Integer ); + var + P: Integer; + begin + FScribblePad_EntropyBag.Write( Data, DataSize ); + P := FScribblePad_EntropyBag.Size div 100; + if pbarScribblePad.Position <> P then + pbarScribblePad.Position := P + end; + +begin + if FOp <> opScribble then + exit; + imgScribblePad.Picture.Bitmap.Canvas.LineTo( X, Y ); + Now1 := Now; + ConsumeEntropy( Now1, SizeOf( Now1 ) ); + ConsumeEntropy( X, SizeOf( X ) ); + ConsumeEntropy( Y, SizeOf( Y ) ); + if pbarScribblePad.Position < 100 then + exit; + pbarScribblePad.Visible := False; + ScribbleHash.HashStream( FScribblePad_EntropyBag ); + FScribblePad_EntropyBag.Size := 0; + ScribbleHash.HashOutputValue.Read( NewSeed, SizeOf( NewSeed ) ); + ScribbleHash.Burn; + R := TRandomStream.Instance; + R.Seed := NewSeed; + DisplayedRandSeed := NewSeed; + imgScribblePad.Cursor := crDefault; + LogFmt( 'The PRNG seed has been set to $%16x .', [NewSeed] ); + FOp := opIdle +end; + +procedure TmfmLockbox3_Demo.lblPasswordExit( Sender: TObject ); +begin + if codecMainDemo.Password <> lblPassword.Text then + codecMainDemo.Password := lblPassword.Text +end; + +procedure TmfmLockbox3_Demo.edtPlaintextFileRightButtonClick( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtPlaintextFile.Text := s; + edtCiphertextFile.Text := s + '_enc'; + edtReconPlaintext.Text := s + '_rcn'; + end +end; + +procedure TmfmLockbox3_Demo.edtReconPlaintextRightButtonClick + ( Sender: TObject ); +begin + if actSelectReconstructed.Execute then + edtReconPlaintext.Text := actSelectReconstructed.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.actAbortScribbleExecute( Sender: TObject ); +begin + pbarScribblePad.Visible := False; + FScribblePad_EntropyBag.Size := 0; + ScribbleHash.Burn; + Log( 'Scribble operation aborted at user request.' ); + FOp := opIdle +end; + +procedure TmfmLockbox3_Demo.actAbortScribbleUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := FOp = opScribble +end; + +const + ChainIds: array [0 .. 6] of string = ( ECB_ProgId, CBC_ProgId, PCBC_ProgId, + CFB_ProgId, CFB8bit_ProgId, CTR_ProgId, OFB_ProgId ); + +procedure TmfmLockbox3_Demo.actCustomBlockDecryptAbortExecute + ( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actCustomBlockDecryptAbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opCustomBlockSymetricDecrypt ) and + ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actCustomBlockDecryptExecute( Sender: TObject ); +begin + Busy; + CurrentOperation := opCustomBlockSymetricDecrypt; + FdidPressAbortEncrypt := False; + codecCustomBlock.StreamCipherId := BlockCipher_ProgId; + codecCustomBlock.ChainModeId := ChainIds[rgCustomBlockChain.ItemIndex]; + codecCustomBlock.BlockCipherId := DemoProgId; + codecCustomBlock.Password := lblCustomBlockPassword.Text; + codecCustomBlock.DecryptFile( edtCustomBlockReconPlaintext.Text, + edtCustomBlockCiphertextFile.Text ); + if codecCustomBlock.isUserAborted then + Log( 'Decryption operation aborted by user.' ) + else + LogFmt( 'Decryption succeeded. %d bytes processed.', + [codecCustomBlock.CountBytesProcessed] ); + codecCustomBlock.Reset; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actCustomBlockEncryptAbortExecute + ( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actCustomBlockEncryptAbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opCustomBlockSymetricEncrypt ) and + ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actCustomBlockEncryptExecute( Sender: TObject ); +begin + Busy; + CurrentOperation := opCustomBlockSymetricEncrypt; + FdidPressAbortEncrypt := False; + codecCustomBlock.StreamCipherId := BlockCipher_ProgId; + codecCustomBlock.ChainModeId := ChainIds[rgCustomBlockChain.ItemIndex]; + codecCustomBlock.BlockCipherId := DemoProgId; + codecCustomBlock.Password := lblCustomBlockPassword.Text; + codecCustomBlock.EncryptFile( edtCustomBlockPlaintextFile.Text, + edtCustomBlockCiphertextFile.Text ); + if codecCustomBlock.isUserAborted then + Log( 'Encryption operation aborted by user.' ) + else + LogFmt( 'Encryption succeeded. %d bytes processed.', + [codecCustomBlock.CountBytesProcessed] ); + codecCustomBlock.Reset; + CurrentOperation := opIdle; +end; + +function CompareFiles( const FN1, FN2: string ): Boolean; +const + BufferSizeInBytes = 1024; +var + Stream1, Stream2: TStream; + Buffer1, Buffer2: rawbytestring; + Count1, Count2, L: Integer; +begin + Stream1 := TFileStream.Create( FN1, fmOpenRead ); + Stream2 := TFileStream.Create( FN2, fmOpenRead ); + try + result := Stream1.Size = Stream2.Size; + L := BufferSizeInBytes; + SetLength( Buffer1, L ); + SetLength( Buffer2, L ); + if result then + repeat + Count1 := Stream1.Read( Buffer1[1], L ); + Count2 := Stream2.Read( Buffer2[1], L ); + result := ( Count1 = Count2 ) and CompareMem( PAnsiChar( Buffer1 ), + PAnsiChar( Buffer2 ), Count1 ); + Application.ProcessMessages + until ( not result ) or ( Count1 < L ) finally Stream1.Free; + Stream2.Free + end +end; + +procedure TmfmLockbox3_Demo.actCustomBlockSymetricCompareExecute + ( Sender: TObject ); +var + isSame: Boolean; +begin + try + isSame := CompareFiles( edtCustomBlockPlaintextFile.Text, + edtCustomBlockReconPlaintext.Text ); + if isSame then + Log( + 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) + else + Log( 'Failure! The reconstructed plaintext differs from the original.' ) + except on E: Exception do LogFmt( + 'Exception (%s) occurred during file comparison.'#13#10 + '%s', + [E.ClassName, E.Message] ) + end +end; + +procedure TmfmLockbox3_Demo.actEncryptSymetricExecute( Sender: TObject ); +var + Sz: Int64; +begin + Busy; + Sz := TPLB3.StreamUtils.FileSize( edtPlaintextFile.Text ); + CurrentOperation := opSymetricEncrypt; + try + FdidPressAbortEncrypt := False; + LogFmt + ( 'Encrypting file "%s" to "%s" using %s cipher and %s chaining mode.', [edtPlaintextFile.Text, edtCiphertextFile.Text, codecMainDemo.Cipher, codecMainDemo.ChainMode] ); + LogFmt( 'Plaintext size = %d bytes.', [Sz] ); + + codecMainDemo.EncryptFile( edtPlaintextFile.Text, edtCiphertextFile.Text ); + + if codecMainDemo.isUserAborted then + Log( 'Encryption operation aborted by user.' ) + else + LogFmt( 'Encryption succeeded. %d bytes processed.', + [codecMainDemo.CountBytesProcessed] ) + except on E: EFCreateError do LogFmt + ( 'Cannot create ciphertext file "%s".', [edtCiphertextFile.Text] ); + on E: Exception + do + if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', + E.Message ) = 1 ) then + LogFmt( 'Cannot open plaintext file "%s".', [edtPlaintextFile.Text] ) + else + LogFmt( '%s: %s', [E.ClassName, E.Message] ) + end; + if codecMainDemo.isUserAborted then + begin + end + else if codecMainDemo.Speed >= 0 then + LogFmt( 'Speed of encryption was %d KiB per second.', + [codecMainDemo.Speed] ); + codecMainDemo.Reset; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actEncryptSymetricUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := CurrentOperation = opIdle +end; + +procedure TmfmLockbox3_Demo.actSetSeedExecute( Sender: TObject ); +begin + case rgSeedingMethod.ItemIndex of + 0: + SetSeed_MSCryptAPI; + 1: + SetSeed_UserInput( edtUserInputSeed.Text ); + 2: + SetSeed_ScribblePad_Begin; + end +end; + +procedure TmfmLockbox3_Demo.SetSeed_MSCryptAPI; +var + R: TRandomStream; +begin + R := TRandomStream.Instance; + R.Randomize; + DisplayedRandSeed := R.Seed; + LogFmt( 'MS Crypt API gave us a random seed of $%16x .', [DisplayedRandSeed] ) +end; + +procedure TmfmLockbox3_Demo.SetSeed_UserInput + ( const UserInputSeedAsString: string ); +var + R: TRandomStream; +begin + R := TRandomStream.Instance; + R.Seed := DisplayedRandSeed; + LogFmt( 'The PRNG seed has been set to $%16x .', [R.Seed] ) +end; + +procedure TmfmLockbox3_Demo.SetSeed_ScribblePad_Begin; +var + R: TRect; +begin + FOp := opScribble; + R := imgScribblePad.ClientRect; + with imgScribblePad.Picture.Bitmap do + begin + Width := R.Right - R.Left; + Height := R.Bottom - R.Top; + Canvas.Pen.Color := clBlack; + Canvas.Brush.Color := clWhite; + Canvas.Rectangle( R ) + end; + pbarScribblePad.Position := 0; + pbarScribblePad.Visible := True; + imgScribblePad.Cursor := crCross; +end; + +procedure TmfmLockbox3_Demo.actSymetricCompareExecute( Sender: TObject ); +var + isSame: Boolean; +begin + try + isSame := CompareFiles( edtPlaintextFile.Text, edtReconPlaintext.Text ); + if isSame then + Log( + 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) + else + Log( 'Failure! The reconstructed plaintext differs from the original.' ) + except on E: Exception do LogFmt( + 'Exception (%s) occurred during file comparison.'#13#10 + '%s', + [E.ClassName, E.Message] ) + end +end; + +procedure TmfmLockbox3_Demo.actSymetricDecryptExecute( Sender: TObject ); +begin + Busy; + CurrentOperation := opSymetricDecrypt; + try + FdidPressAbortEncrypt := False; + LogFmt + ( 'Decrypting file "%s" to "%s" using %s cipher and %s chaining mode.', [edtCiphertextFile.Text, edtReconPlaintext.Text, codecMainDemo.Cipher, codecMainDemo.ChainMode] ); + LogFmt( 'Ciphertext size = %d bytes.', + [TPLB3.StreamUtils.FileSize( edtCiphertextFile.Text )] ); + + codecMainDemo.DecryptFile( edtReconPlaintext.Text, edtCiphertextFile.Text ); + + if codecMainDemo.isUserAborted then + Log( 'Decryption operation aborted by user.' ) + else + LogFmt( 'Decryption succeeded. %d bytes processed.', + [codecMainDemo.CountBytesProcessed] ) + except on E: EFCreateError do LogFmt( + 'Cannot create reconstructed plaintext file "%s".', + [edtReconPlaintext.Text] ); + on E: Exception + do + if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', + E.Message ) = 1 ) then + LogFmt( 'Cannot open ciphertext file "%s".', [edtCiphertextFile.Text] ) + else + LogFmt( '%s: %s', [E.ClassName, E.Message] ) + end; + if codecMainDemo.isUserAborted then + begin + end // codecMainDemo.Reset + else if codecMainDemo.Speed >= 0 then + LogFmt( 'Speed of decryption was %d KiB per second.', + [codecMainDemo.Speed] ); + codecMainDemo.Reset; + CurrentOperation := opIdle; +end; + +procedure TmfmLockbox3_Demo.actSymetricDecrypt_AbortExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actSymetricDecrypt_AbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opSymetricDecrypt ) and ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actSymetricEncrypt_AbortExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actSymetricEncrypt_AbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opSymetricEncrypt ) and ( not FdidPressAbortEncrypt ) +end; + +type + TBusy = class( TInterfacedObject ) + private + FOwner: TmfmLockbox3_Demo; + public + constructor Create( Owner1: TmfmLockbox3_Demo ); + destructor Destroy; override; + end; + +function TmfmLockbox3_Demo.Busy: IInterface; +begin + result := nil; + if Supports( FBusyObj, IInterface, result ) then + exit; + TBusy.Create( self ); + Supports( FBusyObj, IInterface, result ) +end; + +procedure TmfmLockbox3_Demo.PutLinuxLines( const Value: string ); +var + s: string; + P: Integer; +begin + s := Value; + while s <> '' do + begin + P := Pos( #10, s ); + if P > 0 then + begin + Log( Copy( s, 1, P - 1 ) ); + Delete( s, 1, P ) + end + else + begin + Log( s ); + s := '' + end; + end +end; + +procedure TmfmLockbox3_Demo.edtRSACiphertextFileRightButtonClick + ( Sender: TObject ); +begin + if actSelectCiphertext.Execute then + edtRSACiphertextFile.Text := actSelectCiphertext.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.edtRSAPlaintextFileRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtRSAPlaintextFile.Text := s; + edtRSACiphertextFile.Text := s + '_enc'; + edtRSAReconFile.Text := s + '_rcn'; + end +end; + +procedure TmfmLockbox3_Demo.edtRSAReconFileRightButtonClick( Sender: TObject ); +begin + if actSelectReconstructed.Execute then + edtRSAReconFile.Text := actSelectReconstructed.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.edtKeyStorageFileRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectKeyFile.Execute then + begin + s := actSelectKeyFile.Dialog.FileName; + edtKeyStorageFile.Text := s; + end +end; + +constructor TBusy.Create( Owner1: TmfmLockbox3_Demo ); +begin + FOwner := Owner1; + FOwner.FBusyObj := self; + FOwner.ChangeBusy( True ) +end; + +destructor TBusy.Destroy; +begin + FOwner.FBusyObj := nil; + FOwner.ChangeBusy( False ); + inherited +end; + +procedure TmfmLockbox3_Demo.ChangeBusy( isEntering: Boolean ); +begin + if isEntering then + begin + FSaveCursor := Screen.Cursor; + Screen.Cursor := crHourGlass + end + else + Screen.Cursor := FSaveCursor +end; + +function TmfmLockbox3_Demo.codecMainDemoProgress( Sender: TObject; + CountBytesProcessed: Int64 ): Boolean; +var + j: Integer; +begin + if Sender = codecMainDemo then + begin + if ( pbarSymetric.Max = 0 ) and ( codecMainDemo.EstimatedWorkLoad > 0 ) then + pbarSymetric.Max := codecMainDemo.EstimatedWorkLoad; + pbarSymetric.Position := codecMainDemo.CountBytesProcessed; + end + + else if Sender = codecCustomBlock then + begin + if ( pbarCustom.Max = 0 ) and ( codecCustomBlock.EstimatedWorkLoad > 0 ) + then + pbarCustom.Max := codecCustomBlock.EstimatedWorkLoad; + pbarCustom.Position := codecCustomBlock.CountBytesProcessed + end + + else if ( Sender = codecRSA ) and ( CurrentOperation = opRSAGen ) then + begin + j := codecRSA.FGenerateAsymetricKeyPairProgress_CountPrimalityTests; + lblPrimalityTests.Caption := Format( 'Primality tests conducted = %d', [j] ) + end + + else if ( Sender = codecRSA ) and ( CurrentOperation in [opRSAEncrypt, + opRSADecrypt] ) then + begin + if ( pbarRSA.Max = 0 ) and ( codecRSA.EstimatedWorkLoad > 0 ) then + pbarRSA.Max := codecRSA.EstimatedWorkLoad; + pbarRSA.Position := codecRSA.CountBytesProcessed + end + + else if ( Sender = Signatory1 ) and ( CurrentOperation in [opSign, + opVerify] ) then + begin + if ( pbarRSA.Max = 0 ) and ( codecRSA.EstimatedWorkLoad > 0 ) then + pbarRSA.Max := codecRSA.EstimatedWorkLoad; + pbarRSA.Position := CountBytesProcessed + end; + + result := not FdidPressAbortEncrypt; + Application.ProcessMessages; + UpdateActions +end; + +procedure TmfmLockbox3_Demo.edtCiphertextFileRightButtonClick + ( Sender: TObject ); +begin + if actSelectCiphertext.Execute then + edtCiphertextFile.Text := actSelectCiphertext.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.edtCustomBlockCiphertextFileRightButtonClick + ( Sender: TObject ); +begin + if actSelectCiphertext.Execute then + edtCustomBlockCiphertextFile.Text := actSelectCiphertext.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.edtCustomBlockPlaintextFileRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtCustomBlockPlaintextFile.Text := s; + edtCustomBlockCiphertextFile.Text := s + '_enc'; + edtCustomBlockReconPlaintext.Text := s + '_rcn'; + end +end; + +procedure TmfmLockbox3_Demo.edtCustomBlockReconPlaintextRightButtonClick + ( Sender: TObject ); +begin + if actSelectReconstructed.Execute then + edtCustomBlockReconPlaintext.Text := actSelectReconstructed.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.edtHashSourceFileRightButtonClick + ( Sender: TObject ); +begin + if actSelectPlaintext.Execute then + edtHashSourceFile.Text := actSelectPlaintext.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.Log( const Line: string ); +begin + memoLog.Lines.Add( Line ) +end; + +procedure TmfmLockbox3_Demo.LogFmt( const Line: string; + const Args: array of const ); +begin + Log( Format( Line, Args ) ) +end; + +procedure TmfmLockbox3_Demo.rgChainClick( Sender: TObject ); +begin + codecMainDemo.ChainModeId := ChainIds[rgChain.ItemIndex] +end; + +procedure TmfmLockbox3_Demo.rgCipherClick( Sender: TObject ); +const + CipherIds: array [0 .. 8] of string = ( 'native.AES-128', 'native.AES-192', + 'native.AES-256', 'native.DES', 'native.3DES.1', 'native.3DES.2', + 'native.Blowfish', 'native.Twofish', 'native.XXTEA.Large.Littleend' ); +begin + case rgCipher.ItemIndex of + 0 .. 7: // Block ciphers + begin + codecMainDemo.StreamCipherId := BlockCipher_ProgId; + codecMainDemo.BlockCipherId := CipherIds[rgCipher.ItemIndex] + end; + + 8: // Stream ciphers + codecMainDemo.StreamCipherId := CipherIds[rgCipher.ItemIndex] + end +end; + +procedure TmfmLockbox3_Demo.SetDisplayedRSeed( Value: Int64 ); +begin + edtUserInputSeed.Text := Trim( Format( '%16x', [Value] ) ) +end; + +procedure TmfmLockbox3_Demo.SetOp( NewOp: TOperation ); +begin + if FOp = NewOp then + exit; + FOp := NewOp; + if FOp <> opIdle then + begin + pbarSymetric.Max := 0; + pbarCustom.Max := 0 + end + else + begin + // tbd + end; +end; + +procedure TmfmLockbox3_Demo.actRSAGenExecute( Sender: TObject ); +begin + Busy; + Log( 'Generating RSA keys' ); + LogFmt( 'Two key pairs will be created, each of %d bits.', + [Signatory1.Codec.AsymetricKeySizeInBits] ); + FdidPressAbortEncrypt := False; + lblPrimalityTests.Caption := 'Primality tests conducted = 0'; + CurrentOperation := opRSAGen; + if Signatory1.GenerateKeys then + Log( 'Done. RSA keys successfully created.' ) + else if Signatory1.Codec.isUserAborted then + Log( 'Aborted at user request.' ) + else + Log( 'Failed.' ); + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actRSAGenUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := FOp = opIdle +end; + +procedure TmfmLockbox3_Demo.actAbortRSAGenExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actAbortRSAGenUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opRSAGen ) and ( not FdidPressAbortEncrypt ) +end; + +const + FileStreamModes: array [Boolean] of word = ( fmCreate, fmOpenReadWrite ); + +procedure TmfmLockbox3_Demo.actStoreFullKeyExecute( Sender: TObject ); +// For first the CryptoKeys and then the Signing Keys, +// store n, e and d. +var + s: string; + Store: TStream; + Mode: word; +begin + s := edtKeyStorageFile.Text; + Mode := FileStreamModes[FileExists( s )]; + try + Store := TFileStream.Create( s, Mode ); + try + if Mode = fmOpenReadWrite then + Store.Size := 0; + Signatory1.StoreKeysToStream( Store, [partPublic, partPrivate] ); + LogFmt( 'Crypto & Signing keys, both public and private parts,' + + ' stored in file "%s".', [s] ); + finally + Store.Free + end + except + LogFmt( 'Unable to open file "%s".', [s] ); + end +end; + +procedure TmfmLockbox3_Demo.actStoreFullKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opIdle ) and Signatory1.Can_SaveKeys + ( [partPublic, partPrivate] ) +end; + +procedure TmfmLockbox3_Demo.actLoadFullKeyExecute( Sender: TObject ); +// For first the CryptoKeys and then the Signing Keys, +// load n, e and d. +var + s: string; + Store: TStream; + Source: ansistring; +begin + s := edtKeyStorageFile.Text; + try + Store := TFileStream.Create( s, fmOpenRead ); + Source := Stream_to_Base64( Store ); + Store.Position := 0; + try + Signatory1.LoadKeysFromStream( Store, [partPublic, partPrivate] ); + LogFmt( 'Crypto & Signing keys, both public and private parts,' + + ' loaded from file "%s".', [s] ); + finally + Store.Free + end + except + LogFmt( 'Unable to open file "%s".', [s] ); + end; +end; + +procedure TmfmLockbox3_Demo.actLoadFullKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actLoadPublicKeyExecute( Sender: TObject ); +// For first the CryptoKeys and then the Signing Keys, +// load n and e. d should be cleared. +var + s: string; + Store: TStream; +begin + s := edtKeyStorageFile.Text; + try + Store := TFileStream.Create( s, fmOpenRead ); + try + Signatory1.LoadKeysFromStream( Store, [partPublic] ); + LogFmt( 'Crypto & Signing keys, public parts only,' + + ' loaded from file "%s".', [s] ); + finally + Store.Free + end + except + LogFmt( 'Unable to open file "%s".', [s] ); + end +end; + +procedure TmfmLockbox3_Demo.actLoadPublicKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actStorePublicKeyExecute( Sender: TObject ); +// For first the CryptoKeys and then the Signing Keys, +// store n and e. +var + s: string; + Store: TStream; + Mode: word; +begin + s := edtKeyStorageFile.Text; + Mode := FileStreamModes[FileExists( s )]; + try + Store := TFileStream.Create( s, Mode ); + try + if Mode = fmOpenReadWrite then + Store.Size := 0; + Signatory1.StoreKeysToStream( Store, [partPublic] ); + LogFmt( 'Crypto & Signing public keys stored in file "%s".', [s] ); + finally + Store.Free + end + except + LogFmt( 'Unable to open file "%s".', [s] ); + end +end; + +procedure TmfmLockbox3_Demo.actStorePublicKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opIdle ) and Signatory1.Can_SaveKeys + ( [partPublic] ) +end; + +procedure TmfmLockbox3_Demo.actRSAEncryptExecute( Sender: TObject ); +var + Sz: Int64; +begin + Busy; + Sz := TPLB3.StreamUtils.FileSize( edtRSAPlaintextFile.Text ); + CurrentOperation := opRSAEncrypt; + try + FdidPressAbortEncrypt := False; + LogFmt( 'Encrypting file "%s" to "%s" using %s cipher.', + [edtRSAPlaintextFile.Text, edtRSACiphertextFile.Text, codecRSA.Cipher] ); + LogFmt( 'Plaintext size = %d bytes.', [Sz] ); + + pbarRSA.Max := 0; + codecRSA.EncryptFile( edtRSAPlaintextFile.Text, edtRSACiphertextFile.Text ); + + if codecRSA.isUserAborted then + Log( 'Encryption operation aborted by user.' ) + else + LogFmt( 'Encryption succeeded. %d bytes processed.', + [codecRSA.CountBytesProcessed] ) except on E: EFCreateError do LogFmt + ( 'Cannot create ciphertext file "%s".', [edtRSACiphertextFile.Text] ); + on E: Exception + do + if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', + E.Message ) = 1 ) then + LogFmt( 'Cannot open plaintext file "%s".', [edtRSAPlaintextFile.Text] ) + else + LogFmt( '%s: %s', [E.ClassName, E.Message] ) + end; + if codecRSA.isUserAborted then + begin + end + else if codecRSA.Speed >= 0 then + LogFmt( 'Speed of encryption was %d KiB per second.', [codecRSA.Speed] ); + codecRSA.Reset; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actRSAEncryptUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opIdle ) and ( codecRSA.Mode = cmIdle ) and + ( partPublic in Signatory1.HasParts ) +end; + +procedure TmfmLockbox3_Demo.actRSAEncryptAbortExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actRSAEncryptAbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opRSAEncrypt ) and ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actRSACompareExecute( Sender: TObject ); +var + isSame: Boolean; +begin + try + isSame := CompareFiles( edtRSAPlaintextFile.Text, edtRSAReconFile.Text ); + if isSame then + Log( + 'Success! The reconstructed plaintext is a faithfull copy of the original.' ) + else + Log( 'Failure! The reconstructed plaintext differs from the original.' ) + except on E: Exception do LogFmt( + 'Exception (%s) occurred during file comparison.'#13#10 + '%s', + [E.ClassName, E.Message] ) + end +end; + +procedure TmfmLockbox3_Demo.actRSACompareUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := CurrentOperation = opIdle +end; + +procedure TmfmLockbox3_Demo.actRSADecryptAbortExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actRSADecryptAbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opRSADecrypt ) and ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actRSADecryptExecute( Sender: TObject ); +begin + Busy; + CurrentOperation := opRSADecrypt; + try + FdidPressAbortEncrypt := False; + LogFmt( 'Decrypting file "%s" to "%s" using %s cipher.', + [edtRSACiphertextFile.Text, edtRSAReconFile.Text, codecRSA.Cipher] ); + LogFmt( 'Ciphertext size = %d bytes.', + [TPLB3.StreamUtils.FileSize( edtRSACiphertextFile.Text )] ); + + pbarRSA.Max := 0; + codecRSA.DecryptFile( edtRSAReconFile.Text, edtRSACiphertextFile.Text ); + + if codecRSA.isUserAborted then + Log( 'Decryption operation aborted by user.' ) + else + LogFmt( 'Decryption succeeded. %d bytes processed.', + [codecRSA.CountBytesProcessed] ) except on E: EFCreateError do LogFmt + ( 'Cannot create reconstructed plaintext file "%s".', + [edtRSAReconFile.Text] ); + on E: Exception + do + if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', + E.Message ) = 1 ) then + LogFmt( 'Cannot open ciphertext file "%s".', [edtRSACiphertextFile.Text] ) + else + LogFmt( '%s: %s', [E.ClassName, E.Message] ) + end; + if codecRSA.isUserAborted then + begin + end // codecRSA.Reset + else if codecRSA.Speed >= 0 then + LogFmt( 'Speed of decryption was %d KiB per second.', + [codecRSA.Speed] ); + codecRSA.Reset; + CurrentOperation := opIdle; +end; + +procedure TmfmLockbox3_Demo.actRSADecryptUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opIdle ) and ( codecRSA.Mode = cmIdle ) and + ( partPrivate in Signatory1.HasParts ) +end; +{$HINTS OFF} + +procedure TmfmLockbox3_Demo.actSignExecute( Sender: TObject ); +var + Sz: Int64; + wasAborted: Boolean; + DocumentStream, SignatureStream: TStream; + DestinFileMode: word; +begin + Busy; + Sz := TPLB3.StreamUtils.FileSize( edtRSADocumentFile.Text ); + CurrentOperation := opSign; + try + FdidPressAbortEncrypt := False; + LogFmt( 'Signing file "%s" into "%s".', [edtRSADocumentFile.Text, + edtRSASignatureFile.Text] ); + LogFmt( 'Document size = %d bytes.', [Sz] ); + + wasAborted := False; + pbarRSA.Max := 0; + DocumentStream := nil; + SignatureStream := nil; + DocumentStream := TFileStream.Create( edtRSADocumentFile.Text, fmOpenRead ); + DestinFileMode := FileStreamModes[FileExists( edtRSASignatureFile.Text )]; + try + SignatureStream := TFileStream.Create( edtRSASignatureFile.Text, + DestinFileMode ); + try + if DestinFileMode = FileStreamModes[True] then + SignatureStream.Size := 0; + wasAborted := not Signatory1.Sign( DocumentStream, SignatureStream ); + finally + SignatureStream.Free + end; + finally + DocumentStream.Free; + end; + if wasAborted then + Log( 'Signature operation aborted by user.' ) + else + Log( 'Signing succeeded.' ) except on E: EFCreateError do LogFmt + ( 'Cannot create signature file "%s".', [edtRSASignatureFile.Text] ); + on E: Exception + do + if ( E.ClassType = EFOpenError ) and ( Pos( 'Cannot open file', + E.Message ) = 1 ) then + LogFmt( 'Cannot open document "%s".', [edtRSADocumentFile.Text] ) + else + LogFmt( '%s: %s', [E.ClassName, E.Message] ) + end; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.edtRSADocumentFileRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtRSADocumentFile.Text := s; + edtRSASignatureFile.Text := s + '_sig'; + end +end; + +procedure TmfmLockbox3_Demo.edtRSASignatureFileRightButtonClick + ( Sender: TObject ); +begin + if actSelectCiphertext.Execute then + edtRSASignatureFile.Text := actSelectCiphertext.Dialog.FileName +end; + +procedure TmfmLockbox3_Demo.actSignUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opIdle ) and ( partPrivate in Signatory1.HasParts ) +end; + +procedure TmfmLockbox3_Demo.actVerifyExecute( Sender: TObject ); +var + Sz: Int64; + wasAborted: Boolean; + DocumentStream, SignatureStream: TStream; + Res: TVerifyResult; +begin + Busy; + Sz := TPLB3.StreamUtils.FileSize( edtRSADocumentFile.Text ); + CurrentOperation := opVerify; + try + FdidPressAbortEncrypt := False; + LogFmt( 'Verifying signature file "%s" as "%s".', [edtRSADocumentFile.Text, + edtRSASignatureFile.Text] ); + LogFmt( 'Document size = %d bytes.', [Sz] ); + + wasAborted := False; + pbarRSA.Max := 0; + DocumentStream := nil; + SignatureStream := nil; + DocumentStream := TFileStream.Create( edtRSADocumentFile.Text, fmOpenRead ); + try + SignatureStream := TFileStream.Create( edtRSASignatureFile.Text, + fmOpenRead ); + try + Res := Signatory1.Verify( DocumentStream, SignatureStream ) + finally SignatureStream.Free + end; + finally + DocumentStream.Free; + end; + case Res of + vPass: + Log( 'Signature valid.' ); + vFail: + Log( 'Signature invalid.' ); + vUserAbort: + Log( 'Verification aborted by user.' ) + end; + except + Log( 'Error' ); + end; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actVerifyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp = opIdle ) and ( partPrivate in Signatory1.HasParts ) +end; +{$WARNINGS OFF} + +procedure TmfmLockbox3_Demo.btnComputeHashClick( Sender: TObject ); +var + a: string; + s: string; + HashWord: uint32; + Xfer: Integer; +begin + if rgHashSource.ItemIndex <= 0 then + begin + a := edtHashSource.Text; + StringHash.HashString( a, TEncoding.UTF8); + LogFmt + ( 'SHA-384 of utf-8 string ''%s'' rendered in little-endien base64 is:', + [a] ) + end + else + begin + s := edtHashSource.Text; + StringHash.HashString( s ); +{$IFDEF UNICODE} + LogFmt( 'SHA-384 of UTF-16 ''%s'' rendered in little-endien base64 is:', + [s] ) +{$ELSE} + Log( 'This compiler does not support UTF-16.' ); + LogFmt + ( 'SHA-384 of ansistring ''%s'' rendered in little-endien heximal is:', [s] ) +{$ENDIF} + end; + a := '$'; + repeat + HashWord := 0; + Xfer := StringHash.HashOutputValue.Read( HashWord, SizeOf( HashWord ) ); + if Xfer = 0 then + break; + if a <> '$' then + a := a + ' '; + a := a + Format( Format( '%%.%dx', [Xfer * 2] ), [HashWord] ) + until Xfer < SizeOf( HashWord ); + LogFmt( 'Hash = %s', [a] ) +end; + +procedure TmfmLockbox3_Demo.actSignVerifyAbortExecute( Sender: TObject ); +begin + FdidPressAbortEncrypt := True +end; + +procedure TmfmLockbox3_Demo.actSignVerifyAbortUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( FOp in [opSign, opVerify] ) and ( not FdidPressAbortEncrypt ) +end; + +procedure TmfmLockbox3_Demo.actHashExecute( Sender: TObject ); +var + aByte: byte; + s: string; +begin + Busy; + CurrentOperation := opHash; + pressedAbortHash := False; + try + ScribbleHash.HashFile( edtHashSourceFile.Text ); + s := ''; + while ScribbleHash.HashOutputValue.Read( aByte, 1 ) = 1 do + s := s + Format( '%.2x', [aByte] ) finally CurrentOperation := opIdle + end; + ScribbleHash.Burn; + if ScribbleHash.isUserAborted then + Log( 'Hashing operation aborted by user.' ) + else + LogFmt( 'SHA-1 digest (little-endien) is $%s', [s] ) +end; + +procedure TmfmLockbox3_Demo.actAbortHashExecute( Sender: TObject ); +begin + pressedAbortHash := True +end; + +procedure TmfmLockbox3_Demo.actAbortHashUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( CurrentOperation = opHash ) and ( not pressedAbortHash ) +end; + +function TmfmLockbox3_Demo.ScribbleHashProgress( Sender: TObject; + CountBytesProcessed: Int64 ): Boolean; +begin + result := True; + Application.ProcessMessages; + if ( CurrentOperation = opHash ) and pressedAbortHash then + result := False +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadLibExecute( Sender: TObject ); +begin + Sig.LibPath := edtOpenSSLLibPath.Text; + Sig.Clear; + Sig.isLoaded := True; + if Sig.isLoaded then + begin + Log( 'The OpenSSL library libeay32.dll was loaded successfully.' ); + LogFmt( 'libeay32.dll version is %d.%d.%d.%d', [Sig.MajorV, Sig.MinorV, + Sig.ReleaseV, Sig.BuildV] ) + end + else + begin + Log( 'Failed to load library.' ); + case Sig.Err of + erLoadFailed, erException: + Log( Sig.ErrMsg ); + erVersionTooLow: + begin + Log( + 'Found libeay32.dll, but it was too lowly versioned. Update your OpenSSL binaries!' ); + LogFmt( 'Required version is %s', [Sig.RequiredVersion] ) + end; + erSignatureAbsent: + Log( 'Found libeay32.dll, but the API access seemed to be absent.' ); + end + end; +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadLibUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( not Sig.isLoaded ) and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLUnloadLibExecute( Sender: TObject ); +begin + Sig.isLoaded := False; + Log( 'libeay32.dll unloaded successfully.' ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLUnloadLibUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLGenKeyExecute( Sender: TObject ); +begin + Sig.AsymetricKeySizeInBits := 2048; + CurrentOperation := opOpenSSL; + if Sig.GenerateKeys then + PutLinuxLines( Sig.Print ) + else + Log( Sig.ErrMsg ); + CurrentOperation := opIdle +end; + +function TmfmLockbox3_Demo.SigProgress( Sender: TObject; + p1, p2: Integer ): Boolean; +begin + result := True; + LogFmt( 'OpenSSL progress event: p1=%d; p2=%d', [p1, p2] ); + Application.ProcessMessages +end; + +procedure TmfmLockbox3_Demo.actOpenSSLGenKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadPrivateKeyExecute( Sender: TObject ); +var + Store: TStream; +begin + dlgOpenPEM.Title := 'Select private key file in PEM format to open'; + if not dlgOpenPEM.Execute then + exit; + try + Store := TFileStream.Create( dlgOpenPEM.FileName, fmOpenRead ); + try + Sig.LoadKeysFromStream( Store, [partPrivate, partPublic] ) + finally Store.Free + end; + Log( 'Private key (together with public key) successfully loaded.' ) + except on E: Exception + do Log( E.Message ) + end +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadPrivateKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadPublicKeyExecute( Sender: TObject ); +var + Store: TStream; +begin + dlgOpenPEM.Title := 'Select public key file in PEM format to open'; + if not dlgOpenPEM.Execute then + exit; + try + Store := TFileStream.Create( dlgOpenPEM.FileName, fmOpenRead ); + try + Sig.LoadKeysFromStream( Store, [partPublic] ) finally Store.Free + end; + Log( 'Public key (without private key) successfully loaded.' ) + except on E: Exception + do Log( E.Message ) + end +end; + +procedure TmfmLockbox3_Demo.actOpenSSLLoadPublicKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := Sig.isLoaded and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSavePrivateKeyExecute( Sender: TObject ); +var + Store: TStream; + doesPreExist: Boolean; +begin + dlgSavePEM.Title := 'Select private key file in PEM format to save to'; + if not dlgSavePEM.Execute then + exit; + try + doesPreExist := FileExists( dlgSavePEM.FileName ); + Store := TFileStream.Create( dlgSavePEM.FileName, + FileStreamModes[doesPreExist] ); + try + if doesPreExist then + Store.Size := 0; + Sig.StoreKeysToStream( Store, [partPrivate, partPublic] ) + finally Store.Free + end; + Log( 'Private key (together with public key) successfully saved to file.' ) + except on E: Exception + do Log( E.Message ) + end +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSavePrivateKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := partPrivate in Sig.HasParts +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSavePublicKeyExecute( Sender: TObject ); +var + Store: TStream; + doesPreExist: Boolean; +begin + dlgSavePEM.Title := 'Select public key file in PEM format to save to'; + if not dlgSavePEM.Execute then + exit; + try + doesPreExist := FileExists( dlgSavePEM.FileName ); + Store := TFileStream.Create( dlgSavePEM.FileName, + FileStreamModes[doesPreExist] ); + try + if doesPreExist then + Store.Size := 0; + Sig.StoreKeysToStream( Store, [partPublic] ) finally Store.Free + end; + Log( 'Public key (without private key) successfully saved to file.' ) + except on E: Exception + do Log( E.Message ) + end +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSavePublicKeyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := partPublic in Sig.HasParts +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSignExecute( Sender: TObject ); +var + PreHash: TSigHashKind; + HashedDocument, Signature: TStream; + doesPreExist: Boolean; + Len: Integer; + sSignature: utf8string; +begin + if rgOpenSSLHash.ItemIndex = 0 then + begin + PreHash := hshSHA1; + ScribbleHash.HashId := SHA1_ProgId + end + else + begin + PreHash := hshMD5; + ScribbleHash.HashId := MD5_ProgId + end; + try + ScribbleHash.HashFile( edtOpenSSLDocument.Text ); + HashedDocument := TMemoryStream.Create; + Signature := nil; + CurrentOperation := opOpenSSL; + try + HashedDocument.CopyFrom( ScribbleHash.HashOutputValue, 0 ); + ScribbleHash.HashId := SHA1_ProgId; + HashedDocument.Position := 0; + doesPreExist := FileExists( edtOpenSSLSignature.Text ); + Signature := TFileStream.Create( edtOpenSSLSignature.Text, + FileStreamModes[doesPreExist] ); + if doesPreExist then + Signature.Size := 0; + if Sig.Sign( PreHash, HashedDocument, Signature ) then + begin + Signature.Position := 0; + Len := Signature.Size; + SetLength( sSignature, Len ); + if Len > 0 then + Signature.Read( sSignature[1], Len ); + FreeAndNil( Signature ); + Log( 'Signature successfully saved to file.' ) + end + else + Log( Sig.ErrMsg ) finally HashedDocument.Free; + Signature.Free + end + except + on E: Exception do + Log( E.Message ) + end; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actOpenSSLSignUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( partPrivate in Sig.HasParts ) and + ( edtOpenSSLDocument.Text <> '' ) and ( edtOpenSSLSignature.Text <> '' ) + and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.actOpenSSLVerifyExecute( Sender: TObject ); +var + PreHash: TSigHashKind; + HashedDocument, Signature: TStream; + doesPreExist: Boolean; + Len: Integer; + sSignature: utf8string; +begin + if rgOpenSSLHash.ItemIndex = 0 then + begin + PreHash := hshSHA1; + ScribbleHash.HashId := SHA1_ProgId + end + else + begin + PreHash := hshMD5; + ScribbleHash.HashId := MD5_ProgId + end; + try + ScribbleHash.HashFile( edtOpenSSLDocument.Text ); + HashedDocument := TMemoryStream.Create; + Signature := nil; + CurrentOperation := opOpenSSL; + try + HashedDocument.CopyFrom( ScribbleHash.HashOutputValue, 0 ); + ScribbleHash.HashId := SHA1_ProgId; + HashedDocument.Position := 0; + Signature := TFileStream.Create( edtOpenSSLSignature.Text, fmOpenRead ); + if Sig.Verify( PreHash, HashedDocument, Signature ) = vPass then + Log( 'Signature verification PASSED.' ) + else + Log( 'Signature verification FAILED.' ) finally HashedDocument.Free; + Signature.Free + end + except + on E: Exception do + Log( E.Message ) + end; + CurrentOperation := opIdle +end; + +procedure TmfmLockbox3_Demo.actOpenSSLVerifyUpdate( Sender: TObject ); +begin ( Sender as TAction ) + .Enabled := ( partPublic in Sig.HasParts ) and + ( edtOpenSSLDocument.Text <> '' ) and ( edtOpenSSLSignature.Text <> '' ) + and ( CurrentOperation = opIdle ) +end; + +procedure TmfmLockbox3_Demo.edtOpenSSLDocumentRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtOpenSSLDocument.Text := s; + edtOpenSSLSignature.Text := s + '_sig'; + end +end; + +procedure TmfmLockbox3_Demo.edtOpenSSLSignatureRightButtonClick + ( Sender: TObject ); +var + s: string; +begin + if actSelectPlaintext.Execute then + begin + s := actSelectPlaintext.Dialog.FileName; + edtOpenSSLSignature.Text := s + end +end; + +end. diff --git a/demo/D2010+/umfmRSA_Encryption_Demo.dfm b/LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.dfm similarity index 96% rename from demo/D2010+/umfmRSA_Encryption_Demo.dfm rename to LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.dfm index e9cf5ae..5ca7fe1 100644 --- a/demo/D2010+/umfmRSA_Encryption_Demo.dfm +++ b/LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.dfm @@ -1,82 +1,82 @@ -object mfmRSA_Encryption_Demo: TmfmRSA_Encryption_Demo - Left = 0 - Top = 0 - Caption = 'RSA Encryption Demonstration Program' - ClientHeight = 294 - ClientWidth = 370 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poDesktopCenter - DesignSize = ( - 370 - 294) - PixelsPerInch = 96 - TextHeight = 13 - object memoIntro: TMemo - Left = 0 - Top = 0 - Width = 370 - Height = 113 - Anchors = [akLeft, akTop, akRight] - Color = clInfoBk - Lines.Strings = ( - 'This program demonstrates how to set the encryption cipher' - - 'at run-time. Pressing the button below triggers the following ac' + - 'tions:' - ' * Set the cipher to RSA;' - ' * Load the public part only of a pre-fabricated key-pair' - - ' (actually two of them; one for crypto purposes, and another ' + - 'for' - ' signatory purposes);' - ' * Point to some pre-fabricated data (this text); and then' - ' * Encrypt it.') - ReadOnly = True - TabOrder = 0 - end - object btnEncrypt: TButton - Left = 96 - Top = 119 - Width = 137 - Height = 25 - Caption = 'Encrypt some stuff!' - TabOrder = 1 - OnClick = btnEncryptClick - end - object memoResults: TMemo - Left = 0 - Top = 150 - Width = 370 - Height = 147 - Anchors = [akLeft, akRight, akBottom] - Lines.Strings = ( - '[Results will go here.]') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 2 - end - object DynamicallySetCodec: TCodec - AsymetricKeySizeInBits = 1024 - AdvancedOptions2 = [] - CryptoLibrary = libDemoLib - Left = 104 - Top = 208 - StreamCipherId = 'native.StreamToBlock' - BlockCipherId = 'native.AES-192' - ChainId = 'native.CTR' - end - object libDemoLib: TCryptographicLibrary - Left = 200 - Top = 208 - end - object dlgOpenPlainOrCipher: TOpenDialog - Left = 272 - Top = 136 - end -end +object mfmRSA_Encryption_Demo: TmfmRSA_Encryption_Demo + Left = 0 + Top = 0 + Caption = 'RSA Encryption Demonstration Program' + ClientHeight = 294 + ClientWidth = 370 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poDesktopCenter + DesignSize = ( + 370 + 294) + PixelsPerInch = 96 + TextHeight = 13 + object memoIntro: TMemo + Left = 0 + Top = 0 + Width = 370 + Height = 113 + Anchors = [akLeft, akTop, akRight] + Color = clInfoBk + Lines.Strings = ( + 'This program demonstrates how to set the encryption cipher' + + 'at run-time. Pressing the button below triggers the following ac' + + 'tions:' + ' * Set the cipher to RSA;' + ' * Load the public part only of a pre-fabricated key-pair' + + ' (actually two of them; one for crypto purposes, and another ' + + 'for' + ' signatory purposes);' + ' * Point to some pre-fabricated data (this text); and then' + ' * Encrypt it.') + ReadOnly = True + TabOrder = 0 + end + object btnEncrypt: TButton + Left = 96 + Top = 119 + Width = 137 + Height = 25 + Caption = 'Encrypt some stuff!' + TabOrder = 1 + OnClick = btnEncryptClick + end + object memoResults: TMemo + Left = 0 + Top = 150 + Width = 370 + Height = 147 + Anchors = [akLeft, akRight, akBottom] + Lines.Strings = ( + '[Results will go here.]') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 2 + end + object DynamicallySetCodec: TCodec + AsymetricKeySizeInBits = 1024 + AdvancedOptions2 = [] + CryptoLibrary = libDemoLib + Left = 104 + Top = 208 + StreamCipherId = 'native.StreamToBlock' + BlockCipherId = 'native.AES-192' + ChainId = 'native.CTR' + end + object libDemoLib: TCryptographicLibrary + Left = 200 + Top = 208 + end + object dlgOpenPlainOrCipher: TOpenDialog + Left = 272 + Top = 136 + end +end diff --git a/demo/D2010+/umfmRSA_Encryption_Demo.pas b/LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.pas similarity index 96% rename from demo/D2010+/umfmRSA_Encryption_Demo.pas rename to LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.pas index b0216ec..d218744 100644 --- a/demo/D2010+/umfmRSA_Encryption_Demo.pas +++ b/LockBox3/demo/D2010+/umfmRSA_Encryption_Demo.pas @@ -1,126 +1,126 @@ -unit umfmRSA_Encryption_Demo; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, TPLB3.CryptographicLibrary, TPLB3.BaseNonVisualComponent, - TPLB3.Codec; - -type - TmfmRSA_Encryption_Demo = class(TForm) - memoIntro: TMemo; - btnEncrypt: TButton; - memoResults: TMemo; - DynamicallySetCodec: TCodec; - libDemoLib: TCryptographicLibrary; - dlgOpenPlainOrCipher: TOpenDialog; - procedure btnEncryptClick(Sender: TObject); - private - procedure Put( const Line: string); - procedure PutFmt( const Line: string; const Args: array of const); - function AcquireFileName( const Caption1: string; var FileName: string): boolean; - public - { Public declarations } - end; - -var - mfmRSA_Encryption_Demo: TmfmRSA_Encryption_Demo; - -implementation - - - - - -uses TPLB3.Constants, TPLB3.StreamUtils, TPLB3.StreamCipher, TPLB3.Asymetric; -{$R *.dfm} - - -const - // The following is a pre-fabricated 1500 bit RSA public key. - Publickey_1500 = 'vAAAAEXsjaGiTaZSBxjbOpnTX3P23p4aWPWIfkNhDfWFdYNayJHLV3SSpJ' + - 'fdiqdn8i9hOmEvrRMgkRvgsJD94jx3k/JaSd2fy3vAIFCIxCj8aRs1hPcKsbg5t0bmKH' + - 'g49EwEip0cW28zpluW7kgpc8sCceLRJc+OcND7zUQovTp2vcwFNkjIKGk+TzgHxn89Dl' + - 'q4CbY9t/+T3Gk+efmpLqOuncl4yl7036jh7HCy8vUgmRQHwpqfpVHv8tR2J+wKAwAAAA' + - 'EAAbwAAADtbflNMDB277HW0mRJzs6nTK4GvQiGLPIZXb1AnDKpJOZhWXl11YniNRiejI' + - 'SyYWB2597wZlg65FLLJ4Cf3Y9nHmTxYx1BFRFrpfPMqcH6cmX1TfojEkb9BtlKPm0dBp' + - 'QHI18RDdgEnyjrB8npfO1hzXMKHJTmN6D3dNVB6me0RiZLuymNkF8WfLTyFNQFNBXiOc' + - 'ZVJmAPV8VC+e9wEfnqVa9Dy0Lwwa6cVmHhbKy8G7zgJHfJIqbwU0KYBwMAAAABAAE='; - - // The following is a pre-fabricated 256 bit RSA public key. - Publickey_256 = 'IAAAAFN453IaHapERm49PdBuLY7Hp92Ubkv9OKf8/Hkv4DpsAwAAAA' + - 'EAASAAAAArTvJefuXtDOe75oA+UXeLqzb0OV2dobAgvYoLkN7NaAMAAAABAAE='; - - -procedure TmfmRSA_Encryption_Demo.Put( const Line: string); -begin -memoResults.Lines.Add( Line) -end; - - -procedure TmfmRSA_Encryption_Demo.PutFmt( - const Line: string; const Args: array of const); -begin -Put( Format( Line, Args)) -end; - - -function TmfmRSA_Encryption_Demo.AcquireFileName( const Caption1: string; var FileName: string): boolean; -begin -dlgOpenPlainOrCipher.Title := Caption1; -result := dlgOpenPlainOrCipher.Execute; -if result then - FileName := dlgOpenPlainOrCipher.FileName -end; - -procedure TmfmRSA_Encryption_Demo.btnEncryptClick( Sender: TObject); -var - KeyAsStream: TStream; - Key: TSymetricKey; - Ciphertext: utf8string; - PlaintextFileName: string; - CiphertextFileName: string; -begin -// Prepare. -memoResults.Clear; -DynamicallySetCodec.Reset; - -// Set the cipher to RSA encryption. -DynamicallySetCodec.StreamCipherId := RSA_ProgId; - -// Load our pre-fabricated public key. -KeyAsStream := TMemoryStream.Create; -try - Base64_to_stream( Publickey_1500, KeyAsStream); - KeyAsStream.Position := 0; - Key := DynamicallySetCodec.Asymetric_Engine - .CreateFromStream( KeyAsStream, [partPublic]); -finally - KeyAsStream.Free; - end; - -// Now set the key. -DynamicallySetCodec.InitFromKey( Key); - -if (not AcquireFileName( 'Plaintext', PlaintextFileName)) and - (not AcquireFileName( 'Ciphertext', CiphertextFileName)) then exit; - -try - DynamicallySetCodec.EncryptFile( PlaintextFileName, CiphertextFileName); - PutFmt( 'File succesfully encrypted to %s', [CiphertextFileName]) -except - begin - PutFmt( 'Encryption failed at %d plaintext bytes processed, ' + - 'probably due to a file access error.', - [DynamicallySetCodec.CountBytesProcessed]); - DynamicallySetCodec.Reset - end end; - -// Burn baby! Burn! -if Ciphertext <> '' then - BurnMemory( Ciphertext[1], Length( Ciphertext) * SizeOf( Char)); -DynamicallySetCodec.Burn -end; - -end. +unit umfmRSA_Encryption_Demo; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, TPLB3.CryptographicLibrary, TPLB3.BaseNonVisualComponent, + TPLB3.Codec; + +type + TmfmRSA_Encryption_Demo = class(TForm) + memoIntro: TMemo; + btnEncrypt: TButton; + memoResults: TMemo; + DynamicallySetCodec: TCodec; + libDemoLib: TCryptographicLibrary; + dlgOpenPlainOrCipher: TOpenDialog; + procedure btnEncryptClick(Sender: TObject); + private + procedure Put( const Line: string); + procedure PutFmt( const Line: string; const Args: array of const); + function AcquireFileName( const Caption1: string; var FileName: string): boolean; + public + { Public declarations } + end; + +var + mfmRSA_Encryption_Demo: TmfmRSA_Encryption_Demo; + +implementation + + + + + +uses TPLB3.Constants, TPLB3.StreamUtils, TPLB3.StreamCipher, TPLB3.Asymetric; +{$R *.dfm} + + +const + // The following is a pre-fabricated 1500 bit RSA public key. + Publickey_1500 = 'vAAAAEXsjaGiTaZSBxjbOpnTX3P23p4aWPWIfkNhDfWFdYNayJHLV3SSpJ' + + 'fdiqdn8i9hOmEvrRMgkRvgsJD94jx3k/JaSd2fy3vAIFCIxCj8aRs1hPcKsbg5t0bmKH' + + 'g49EwEip0cW28zpluW7kgpc8sCceLRJc+OcND7zUQovTp2vcwFNkjIKGk+TzgHxn89Dl' + + 'q4CbY9t/+T3Gk+efmpLqOuncl4yl7036jh7HCy8vUgmRQHwpqfpVHv8tR2J+wKAwAAAA' + + 'EAAbwAAADtbflNMDB277HW0mRJzs6nTK4GvQiGLPIZXb1AnDKpJOZhWXl11YniNRiejI' + + 'SyYWB2597wZlg65FLLJ4Cf3Y9nHmTxYx1BFRFrpfPMqcH6cmX1TfojEkb9BtlKPm0dBp' + + 'QHI18RDdgEnyjrB8npfO1hzXMKHJTmN6D3dNVB6me0RiZLuymNkF8WfLTyFNQFNBXiOc' + + 'ZVJmAPV8VC+e9wEfnqVa9Dy0Lwwa6cVmHhbKy8G7zgJHfJIqbwU0KYBwMAAAABAAE='; + + // The following is a pre-fabricated 256 bit RSA public key. + Publickey_256 = 'IAAAAFN453IaHapERm49PdBuLY7Hp92Ubkv9OKf8/Hkv4DpsAwAAAA' + + 'EAASAAAAArTvJefuXtDOe75oA+UXeLqzb0OV2dobAgvYoLkN7NaAMAAAABAAE='; + + +procedure TmfmRSA_Encryption_Demo.Put( const Line: string); +begin +memoResults.Lines.Add( Line) +end; + + +procedure TmfmRSA_Encryption_Demo.PutFmt( + const Line: string; const Args: array of const); +begin +Put( Format( Line, Args)) +end; + + +function TmfmRSA_Encryption_Demo.AcquireFileName( const Caption1: string; var FileName: string): boolean; +begin +dlgOpenPlainOrCipher.Title := Caption1; +result := dlgOpenPlainOrCipher.Execute; +if result then + FileName := dlgOpenPlainOrCipher.FileName +end; + +procedure TmfmRSA_Encryption_Demo.btnEncryptClick( Sender: TObject); +var + KeyAsStream: TStream; + Key: TSymetricKey; + Ciphertext: utf8string; + PlaintextFileName: string; + CiphertextFileName: string; +begin +// Prepare. +memoResults.Clear; +DynamicallySetCodec.Reset; + +// Set the cipher to RSA encryption. +DynamicallySetCodec.StreamCipherId := RSA_ProgId; + +// Load our pre-fabricated public key. +KeyAsStream := TMemoryStream.Create; +try + Base64_to_stream( Publickey_1500, KeyAsStream); + KeyAsStream.Position := 0; + Key := DynamicallySetCodec.Asymetric_Engine + .CreateFromStream( KeyAsStream, [partPublic]); +finally + KeyAsStream.Free; + end; + +// Now set the key. +DynamicallySetCodec.InitFromKey( Key); + +if (not AcquireFileName( 'Plaintext', PlaintextFileName)) and + (not AcquireFileName( 'Ciphertext', CiphertextFileName)) then exit; + +try + DynamicallySetCodec.EncryptFile( PlaintextFileName, CiphertextFileName); + PutFmt( 'File succesfully encrypted to %s', [CiphertextFileName]) +except + begin + PutFmt( 'Encryption failed at %d plaintext bytes processed, ' + + 'probably due to a file access error.', + [DynamicallySetCodec.CountBytesProcessed]); + DynamicallySetCodec.Reset + end end; + +// Burn baby! Burn! +if Ciphertext <> '' then + BurnMemory( Ciphertext[1], Length( Ciphertext) * SizeOf( Char)); +DynamicallySetCodec.Burn +end; + +end. diff --git a/demo/uDemoBlockModeCipher.pas b/LockBox3/demo/uDemoBlockModeCipher.pas similarity index 94% rename from demo/uDemoBlockModeCipher.pas rename to LockBox3/demo/uDemoBlockModeCipher.pas index 60cd61d..2c3b250 100644 --- a/demo/uDemoBlockModeCipher.pas +++ b/LockBox3/demo/uDemoBlockModeCipher.pas @@ -1,62 +1,62 @@ -unit uDemoBlockModeCipher; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher, SysUtils, - TPLB3.SimpleBlockCipher, TPLB3.CryptographicLibrary; - -const - - DemoProgId = 'SBD.Demo1'; - DemoBlockSize = 10; - -type -TDemoBlockModeCipher = class( TSimpleBlockCipher) - protected - function Encrypt( - const Buffer: TBytes; - Key: TSimpleBlockCipherKey; - doEncrypt: boolean): TBytes; override; - - public - class procedure SelfRegister( Lib: TCryptographicLibrary); - end; - - - - -implementation - - - - - - - - -{ TDemoBlockModeCipher } - -function TDemoBlockModeCipher.Encrypt( - const Buffer: TBytes; - Key: TSimpleBlockCipherKey; doEncrypt: boolean): TBytes; -var - j: integer; -begin -SetLength( result, DemoBlockSize); -for j := 0 to DemoBlockSize - 1 do - result[ j] := byte( Buffer[ j]) xor byte( Key.FKeyData[ j]) -end; - - - - - - - -class procedure TDemoBlockModeCipher.SelfRegister( Lib: TCryptographicLibrary); -begin -Lib.RegisterSimpleBlockTransform( - self, DemoProgId, 'Demo block transform', - [afCryptographicallyWeak, afForTestOnly, - afForRunTimeOnly, afOpenSourceSoftware], DemoBlockSize) -end; - -end. +unit uDemoBlockModeCipher; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher, SysUtils, + TPLB3.SimpleBlockCipher, TPLB3.CryptographicLibrary; + +const + + DemoProgId = 'SBD.Demo1'; + DemoBlockSize = 10; + +type +TDemoBlockModeCipher = class( TSimpleBlockCipher) + protected + function Encrypt( + const Buffer: TBytes; + Key: TSimpleBlockCipherKey; + doEncrypt: boolean): TBytes; override; + + public + class procedure SelfRegister( Lib: TCryptographicLibrary); + end; + + + + +implementation + + + + + + + + +{ TDemoBlockModeCipher } + +function TDemoBlockModeCipher.Encrypt( + const Buffer: TBytes; + Key: TSimpleBlockCipherKey; doEncrypt: boolean): TBytes; +var + j: integer; +begin +SetLength( result, DemoBlockSize); +for j := 0 to DemoBlockSize - 1 do + result[ j] := byte( Buffer[ j]) xor byte( Key.FKeyData[ j]) +end; + + + + + + + +class procedure TDemoBlockModeCipher.SelfRegister( Lib: TCryptographicLibrary); +begin +Lib.RegisterSimpleBlockTransform( + self, DemoProgId, 'Demo block transform', + [afCryptographicallyWeak, afForTestOnly, + afForRunTimeOnly, afOpenSourceSoftware], DemoBlockSize) +end; + +end. diff --git a/design/Book.bmp b/LockBox3/design/Book.bmp similarity index 100% rename from design/Book.bmp rename to LockBox3/design/Book.bmp diff --git a/design/Leaf.bmp b/LockBox3/design/Leaf.bmp similarity index 100% rename from design/Leaf.bmp rename to LockBox3/design/Leaf.bmp diff --git a/design/Lock Box 9524.jpg b/LockBox3/design/Lock Box 9524.jpg similarity index 100% rename from design/Lock Box 9524.jpg rename to LockBox3/design/Lock Box 9524.jpg diff --git a/design/LockBox3_Logo.jpg b/LockBox3/design/LockBox3_Logo.jpg similarity index 100% rename from design/LockBox3_Logo.jpg rename to LockBox3/design/LockBox3_Logo.jpg diff --git a/design/Oh.bmp b/LockBox3/design/Oh.bmp similarity index 100% rename from design/Oh.bmp rename to LockBox3/design/Oh.bmp diff --git a/design/TPLB3.ComponentAbout.dfm b/LockBox3/design/TPLB3.ComponentAbout.dfm similarity index 98% rename from design/TPLB3.ComponentAbout.dfm rename to LockBox3/design/TPLB3.ComponentAbout.dfm index ad5d282..8201c90 100644 --- a/design/TPLB3.ComponentAbout.dfm +++ b/LockBox3/design/TPLB3.ComponentAbout.dfm @@ -1,5259 +1,5259 @@ -object TPLb_fmComponentAbout: TTPLb_fmComponentAbout - Left = 0 - Top = 0 - Caption = 'Component About' - ClientHeight = 442 - ClientWidth = 640 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - OnCreate = FormCreate - DesignSize = ( - 640 - 442) - PixelsPerInch = 96 - TextHeight = 13 - object pnlAbout: TPanel - Left = 0 - Top = 0 - Width = 641 - Height = 410 - Anchors = [akLeft, akTop, akRight, akBottom] - Caption = 'About Box to be developed!' - TabOrder = 0 - object pgAboutContent: TPageControl - Left = 1 - Top = 1 - Width = 639 - Height = 408 - ActivePage = tsMain - Align = alClient - TabOrder = 0 - object tsMain: TTabSheet - Caption = 'Main' - DesignSize = ( - 631 - 380) - object Image1: TImage - Left = 0 - Top = 0 - Width = 225 - Height = 329 - Picture.Data = { - 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 - 480000FFE1004045786966000049492A0008000000010069870400010000001A - 000000000000000100869202000B0000002C000000000000004170706C654D61 - 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 - 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 - 50504C0000000049454320735247420000000000000000000000000000F6D600 - 0100000000D32D48502020000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000116370727400 - 0001500000003364657363000001840000007377747074000001F80000001462 - 6B70740000020C000000147258595A00000220000000146758595A0000023400 - 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 - 0002BC0000007976756564000003380000008676696577000003C0000000246C - 756D69000003E4000000146D656173000003F800000024746563680000041C00 - 00000C72545243000004280000080C67545243000004280000080C6254524300 - 0004280000080C7465787400000000436F707972696768742028632920313939 - 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 - 00000000000019735247422049454336313936362D322E312039393132303300 - 0000000000000000000019735247422049454336313936362D322E3120393931 - 3230330000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000058595A20000000000000F3510001000000 - 0116CC58595A200000000000000000000000000000000058595A200000000000 - 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 - 595A2000000000000024A000000F840000B6CF64657363000000000000000549 - 4543200000000000000000000000054945432000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000064657363000000000000001F73 - 524742204945432036313936362D322E31207352474220393931323033000000 - 00000000000000001F73524742204945432036313936362D322E312073524742 - 2039393132303300000000000000000000000000000000000000000000000000 - 00000000000000000000000000000064657363000000000000002C5265666572 - 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 - 36362D322E3100000000000000000000002C5265666572656E63652056696577 - 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 - 0000000000000000000000000000000000000000000000766965770000000000 - 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 - 000000004C09560050000000571FE76D65617300000000000000010000000000 - 00000000000000000000000000028F0000000273696720000000004352542063 - 757276000000000000040000000005000A000F00140019001E00230028002D00 - 320037003B00400045004A004F00540059005E00630068006D00720077007C00 - 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 - D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 - 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 - 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 - 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 - B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 - 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 - 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 - 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 - 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 - 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 - 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 - 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A - F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C - 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E - 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F - CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 - AA11C911E81207122612451264128412A312C312E31303132313431363138313 - A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 - BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 - F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A - 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C - CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F - 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 - 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 - 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 - 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B - 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E - 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 - F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 - 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 - 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D - 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 - 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 - 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 - A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E - 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 - C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 - 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C - 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 - A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 - E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C - 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 - F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 - B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D - A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 - BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 - FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 - 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 - 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D - D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 - C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB - E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 - 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA - B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 - 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA - 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 - 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA - 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 - DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB - 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 - 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD - 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 - 0202020202040303020305040505050404040506070605050706040406090607 - 08080808080506090A09080A07080808FFDB0043010101010202020402020408 - 0504050808080808080808080808080808080808080808080808080808080808 - 080808080808080808080808080808080808080808FFC0001108014A00EA0301 - 2200021101031101FFC4001F0000010501010101010100000000000000000102 - 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 - 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 - 627282090A161718191A25262728292A3435363738393A434445464748494A53 - 5455565758595A636465666768696A737475767778797A838485868788898A92 - 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 - C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA - FFC4001F0100030101010101010101010000000000000102030405060708090A - 0BFFC400B5110002010204040304070504040001027700010203110405213106 - 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 - F11718191A262728292A35363738393A434445464748494A535455565758595A - 636465666768696A737475767778797A82838485868788898A92939495969798 - 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 - D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 - 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F - B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 - 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C - D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 - C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 - DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 - 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C - 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D - B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D - FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB - 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 - 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 - ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB - AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F - 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 - EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 - DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F - 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 - 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 - C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB - 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 - 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 - A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 - 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA - 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 - D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 - 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 - 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 - 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D - 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D - 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E - BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 - 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 - B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 - 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF - 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF - B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 - 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 - 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 - 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 - 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E - DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 - EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 - 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 - C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 - 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 - 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 - 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 - 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 - 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 - 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 - E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE - AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 - 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 - 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC - AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC - 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 - EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 - 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE - 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 - 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A - 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C - FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 - 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E - 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 - 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC - 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 - 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A - BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF - FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB - 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 - 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 - 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 - DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 - 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 - 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 - 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A - BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F - 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B - E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C - 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 - 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A - 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 - 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD - 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 - A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 - C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D - C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC - B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE - 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 - B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 - 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 - 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 - 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 - B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 - 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 - 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 - 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A - BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D - 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 - 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 - 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D - FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 - 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 - 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 - BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 - 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 - B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 - 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 - D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E - F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F - B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B - 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 - E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A - BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 - DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 - D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF - C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF - 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 - D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 - 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 - 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D - B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 - 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB - E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 - C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 - 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 - ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 - E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 - 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 - 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 - D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 - 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 - B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 - 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E - C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A - F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 - 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 - 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C - D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 - C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 - 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 - 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 - 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 - B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 - EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F - D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 - 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 - 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 - F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 - 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 - 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD - B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 - 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 - 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 - CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 - 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 - F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 - 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F - 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 - 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A - FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A - EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D - 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F - 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B - E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 - 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD - FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA - E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 - F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 - 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 - 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 - 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 - 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 - FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 - 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB - 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 - F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 - CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 - 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 - 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 - BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 - DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 - ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 - 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 - 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF - 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA - EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 - 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 - 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 - 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 - FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB - 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 - D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB - 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED - 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 - 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD - 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 - B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 - 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 - 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C - 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 - A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC - 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 - 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC - D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 - 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C - 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 - FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B - CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 - 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E - 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 - B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 - AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 - C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 - FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 - 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 - 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE - 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 - 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 - 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 - F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 - 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC - 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 - 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD - E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 - 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B - E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA - DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 - 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 - DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 - 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 - D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 - FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B - F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 - E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF - 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B - 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 - 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 - 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 - 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 - 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F - C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 - B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 - 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 - 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E - 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC - FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F - A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B - 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 - E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F - 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C - F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C - 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE - 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 - 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D - D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 - 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 - 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 - 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA - E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 - F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF - 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 - E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F - 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 - 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 - BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B - C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 - B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 - 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F - 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F - C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 - 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 - 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 - 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 - 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F - ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C - C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B - F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B - 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF - AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA - 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 - 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 - EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 - 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 - 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D - 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C - C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 - EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 - 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 - BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 - 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF - 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 - 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 - 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 - 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 - 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 - 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 - 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E - CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 - D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 - 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 - 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F - B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB - 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F - 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 - 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B - 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 - 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF - 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B - E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B - 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA - 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 - DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 - 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A - F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC - 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D - 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 - DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF - 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED - 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B - F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 - DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 - D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B - F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 - 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 - 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E - 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E - 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B - E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F - 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 - 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 - C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 - 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD - 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE - 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 - F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E - 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC - 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 - D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE - BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C - 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 - D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E - 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 - 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 - A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC - E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E - 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 - B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 - 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 - 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B - B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB - FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 - C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA - D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C - 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED - C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 - 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 - 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B - 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 - 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 - 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 - 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F - 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 - 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD - 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A - CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC - 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 - 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF - C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E - 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 - F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF - D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 - 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 - C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC - 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 - 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF - 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 - 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE - DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 - AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 - C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 - FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF - 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F - 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 - A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F - E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 - 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 - F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 - C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE - 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 - 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 - 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 - C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E - 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 - 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA - AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 - E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 - 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD - 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 - FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 - 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 - E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 - 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 - E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 - 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB - 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED - 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C - DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 - DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 - 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D - FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F - 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 - 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 - 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 - FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 - E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF - E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC - 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 - A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF - BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 - C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 - D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 - 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 - 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 - 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F - F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 - B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 - BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 - FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 - 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF - 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED - CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 - 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF - 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D - 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A - BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 - 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 - 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 - 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 - F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B - 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 - E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C - 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF - B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 - A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 - 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 - 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 - 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A - 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A - CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D - 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F - 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 - FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C - 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 - E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 - EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF - 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 - DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 - DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 - FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC - 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 - B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 - 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 - FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 - 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 - 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D - BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 - 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C - 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA - B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 - 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA - 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE - D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 - C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 - DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC - F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 - 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD - 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 - 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD - 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA - C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE - CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 - 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB - DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA - BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 - 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A - E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 - 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 - 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 - 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 - 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F - FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 - 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D - FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D - C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F - 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED - 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 - BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 - AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 - E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD - D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 - 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 - 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB - 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 - 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 - CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 - 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B - 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E - 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 - 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 - F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C - F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 - E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 - 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B - 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 - D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 - C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD - EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF - 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 - F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F - 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 - 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 - 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 - FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 - DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 - 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E - D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 - 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 - F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F - 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 - 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E - 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 - A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 - E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 - 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 - 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 - 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 - 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E - 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 - 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD - B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 - A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C - 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 - E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E - 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F - ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E - F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD - 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B - C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 - A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 - A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 - 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 - 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 - 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A - 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E - D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D - 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA - C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF - 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E - DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A - 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 - 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A - 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB - 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA - 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF - 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F - 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 - FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF - C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C - 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 - 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 - 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 - DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB - D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 - ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 - 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 - BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 - 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF - 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 - 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 - 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 - 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 - 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 - D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D - 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF - ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B - 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 - EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D - C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 - 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F - B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 - 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D - A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 - 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 - 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 - D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 - 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 - A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 - D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 - D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 - DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B - 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D - 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 - FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F - 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 - 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B - 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E - AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 - C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 - F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 - 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB - C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 - 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F - C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 - 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA - 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F - B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C - AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 - 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F - BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 - A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD - 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA - 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B - 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE - 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 - 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 - D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 - FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 - 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA - 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 - 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 - 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 - 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD - 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF - 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D - F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA - AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 - 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 - 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 - 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 - 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE - EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 - 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 - 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 - 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 - BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C - C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 - E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 - 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E - 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 - 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA - 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 - 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C - 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 - 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 - BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 - DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E - 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 - 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 - 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 - 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 - 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 - 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 - 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 - C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 - 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 - 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 - 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 - 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 - 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 - F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 - 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 - 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 - B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 - 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB - 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF - 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F - CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 - F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 - 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC - 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 - 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 - 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 - DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 - 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC - 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB - 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 - C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 - 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 - A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 - 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 - 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 - 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 - 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 - BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A - EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 - D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 - 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 - EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C - 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 - 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 - 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 - 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 - F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D - 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C - 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 - 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F - 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 - DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF - 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B - 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC - B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 - F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 - 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB - 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C - D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 - CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E - 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 - 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A - AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 - AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF - 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 - 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 - 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E - 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 - BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 - F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E - 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 - 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B - 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 - 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 - 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 - 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED - 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D - 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 - F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 - 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA - 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E - 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 - F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F - B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC - 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B - 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 - 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 - 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C - 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 - 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF - 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 - AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE - F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A - 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 - 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 - 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 - AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 - B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 - CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D - 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 - 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 - 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 - D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF - 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A - 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 - DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD - A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 - 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 - E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E - 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 - A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 - F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC - CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF - 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 - D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE - AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 - EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 - 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 - 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 - 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 - 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 - 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED - 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 - A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F - 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 - C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 - 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F - E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 - F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F - D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F - AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED - 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F - B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 - 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 - 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 - DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 - F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 - 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 - 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 - 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B - 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 - C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 - 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C - 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 - 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 - 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C - BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 - B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 - F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 - 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D - F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A - F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 - 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 - F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC - 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 - 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D - DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 - 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 - F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 - 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B - 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E - D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B - 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F - 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 - 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D - 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 - BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 - 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 - CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E - 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 - B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 - B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 - C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 - 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 - 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF - 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 - 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B - 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F - 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 - 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA - 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 - D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 - B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 - 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C - BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E - 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 - D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 - BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 - DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 - B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE - 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 - 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 - D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B - 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 - 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB - F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 - 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A - CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 - C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 - 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 - D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D - 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 - CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F - 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E - 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB - 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 - B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 - BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 - 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 - 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F - 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 - D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 - FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 - 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 - 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB - E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 - 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 - F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 - D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 - 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D - 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 - 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 - FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E - A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE - 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC - 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 - 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB - 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 - B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 - 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB - B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 - 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 - 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 - 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E - 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 - 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 - FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED - 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 - 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 - 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 - F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 - 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 - 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E - 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F - 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 - FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 - 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 - 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF - 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 - 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 - EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D - 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D - F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 - 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 - 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA - 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB - 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 - 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 - F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 - F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 - F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF - F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 - 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 - B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 - DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E - CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 - 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 - AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 - 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C - 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB - CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C - 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 - 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B - 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 - AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B - 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA - 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 - C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 - 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 - 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 - 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 - 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E - 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 - D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F - 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E - 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D - 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 - 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 - 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 - 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B - EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 - 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F - C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 - 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 - 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 - B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE - 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A - 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F - 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE - 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB - 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 - B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 - 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC - D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 - 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 - 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 - AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF - 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 - 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 - D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 - 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 - 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D - 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 - 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E - 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E - DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 - 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 - B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 - B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 - E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 - F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 - A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 - 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B - 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 - 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF - 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 - 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 - BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 - 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 - F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B - A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 - 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC - BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A - F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 - 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 - 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB - CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 - A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C - 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 - 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 - CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 - 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE - 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F - 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF - 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 - F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB - 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F - 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 - AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 - CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 - ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 - 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F - 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF - 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B - 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 - E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E - 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C - 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 - 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 - 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF - E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B - 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC - 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C - 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 - 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 - C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 - 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D - 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 - 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 - F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 - AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F - 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 - 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 - 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 - DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF - 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 - 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B - FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 - 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD - 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 - C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F - C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 - 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A - FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC - 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E - 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 - BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 - E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 - C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 - E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 - FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 - 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 - 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A - 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F - 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 - 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B - 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 - 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 - D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 - EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 - ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 - E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC - 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB - E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 - 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 - 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 - FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 - B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 - FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD - ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF - 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 - BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C - D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 - BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA - B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 - BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 - 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 - 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 - A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 - 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E - FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 - B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E - 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 - 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 - 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E - D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 - 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 - 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED - AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 - BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD - 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 - 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E - 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF - B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 - E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C - CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 - 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED - 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B - B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 - A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 - 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A - B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 - FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF - F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA - 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 - FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 - 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B - B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D - 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 - 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 - 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E - 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 - BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 - 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB - 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 - C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 - C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 - EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 - BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 - 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 - F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 - C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 - BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 - F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 - F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 - 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 - 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB - 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 - 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 - F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 - 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 - 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D - EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 - 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 - 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 - 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA - D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E - F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A - E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 - B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A - A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 - 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA - 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F - F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 - AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 - 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE - 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 - 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 - 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 - C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 - FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB - 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 - 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 - CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 - 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB - D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A - 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 - 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 - 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC - C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 - D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 - F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 - 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 - BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 - 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 - 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D - 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C - 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 - 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF - B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 - 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE - 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 - 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED - 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 - F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B - B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC - E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB - 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 - 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D - BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC - D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB - 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D - D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB - 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 - F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F - 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D - 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 - F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD - E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C - 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 - 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 - A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB - E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 - 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC - 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 - DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 - 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 - 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 - FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 - 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD - 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 - E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 - 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 - 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 - AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F - 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C - 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 - 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 - C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 - C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 - E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD - 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 - D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 - 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 - F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F - 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 - 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE - 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 - C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D - 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE - 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D - 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C - D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF - AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 - 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 - 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 - C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F - 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A - CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 - 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C - 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA - B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 - 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 - 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 - 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE - BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF - 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 - 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E - 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF - 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 - A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 - DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 - FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC - 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 - DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 - D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 - 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 - 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 - 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF - C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A - FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 - 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 - 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F - DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB - B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 - 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 - 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 - 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 - B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 - 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 - BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 - 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 - FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC - D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED - 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 - FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C - 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 - B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 - AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E - 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 - 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 - 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 - FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C - 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 - F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C - EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF - 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 - 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 - 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF - 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB - 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C - 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 - 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE - FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC - AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 - 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F - 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A - 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A - 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 - F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B - 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 - 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED - E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D - AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD - E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 - 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD - 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 - BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 - B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 - 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB - F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F - 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 - DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F - D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A - F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F - 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 - 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 - F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 - A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 - 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 - EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C - D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F - F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 - D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC - 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 - 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 - CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 - 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 - C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF - 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 - 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 - C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A - 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 - 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F - 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 - B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 - E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E - 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 - B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D - F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 - 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F - 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 - 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D - 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 - 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 - 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 - 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A - 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC - BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 - 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA - 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 - D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 - FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 - DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 - B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 - B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 - 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 - 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 - 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB - D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 - BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C - D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 - 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D - F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F - 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E - 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 - F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A - 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D - 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC - 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 - FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 - 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC - 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E - EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 - 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 - 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 - 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 - CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE - 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 - D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C - 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D - C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF - BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 - 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 - 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF - 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF - 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA - 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 - 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 - 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 - D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 - 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF - 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE - BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE - ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 - C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E - 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 - FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A - F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 - FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B - 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA - 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF - 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 - 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 - 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D - ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 - C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 - 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C - 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 - 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA - D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 - F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B - 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 - 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B - C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 - DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 - 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F - 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F - EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 - 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE - D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E - BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF - 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E - D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 - 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 - 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 - EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E - 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 - DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 - B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC - C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C - FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 - 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 - EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 - DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C - 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 - D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F - ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC - FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 - 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 - 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B - 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B - DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 - 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB - EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 - F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C - 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E - E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE - 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 - F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 - AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 - 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B - AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 - D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 - 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D - 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 - BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A - F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 - F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 - B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 - E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 - 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE - B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 - 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B - 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 - 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 - FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 - 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A - 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE - 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 - 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 - BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 - 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 - D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 - FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 - 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 - 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A - BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 - EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 - B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D - DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E - E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C - 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 - 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F - CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C - 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 - B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB - 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 - F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F - 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 - CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF - 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 - 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 - 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F - C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 - CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 - 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F - 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 - 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 - 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A - 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D - F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 - BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 - E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F - 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 - F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 - 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F - 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 - 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 - 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C - F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F - 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 - F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A - D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF - DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 - C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 - 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE - 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 - AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 - CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C - 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 - 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F - C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 - 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 - 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE - 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 - 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB - D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF - 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 - 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA - 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 - 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC - 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 - 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 - B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F - 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC - D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 - 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 - ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B - D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 - ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 - 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B - E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B - 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE - 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B - E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 - 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 - B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 - 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 - 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 - CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 - 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 - D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 - 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC - 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B - 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD - 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 - B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C - F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 - 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 - 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 - 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 - D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 - 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 - AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 - AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B - A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 - 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 - A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B - 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE - B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 - BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE - BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A - B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 - 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 - 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B - 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 - 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F - 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 - 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF - 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C - 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 - FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 - 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 - 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 - 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE - 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 - 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B - 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E - F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 - 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 - 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 - 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 - 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 - A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 - 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 - 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 - 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF - 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 - FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E - E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 - 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B - D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 - 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 - 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C - 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C - 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 - F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B - 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 - E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E - 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 - 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA - 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B - C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B - 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF - 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB - DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 - 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E - 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 - E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 - D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 - ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE - 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 - C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F - 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E - 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD - D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 - C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB - 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 - 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 - EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA - BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A - B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 - 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 - 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB - 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA - CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D - 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C - 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 - 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 - 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A - 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 - 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B - F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 - 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 - 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A - 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 - A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 - C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 - B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 - 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 - AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 - C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 - B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 - 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F - 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 - B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 - 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 - 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 - DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F - 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F - 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 - E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 - BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 - BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 - 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B - D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E - F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 - 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F - 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 - C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D - F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 - 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC - 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E - CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A - 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F - 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 - 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 - 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D - E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 - 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 - D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F - 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 - A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 - B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A - 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD - B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 - B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 - AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 - 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB - 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F - 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E - 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 - 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 - ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC - EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 - B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 - 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD - 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 - 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C - E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 - 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA - B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 - 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 - C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 - 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 - 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E - 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 - 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 - AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 - 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F - 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA - DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 - 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB - 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F - 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C - E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 - 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 - A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 - 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 - C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 - 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC - 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE - EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 - 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A - 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 - 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB - C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F - D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F - C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B - 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA - F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 - 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 - 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 - 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF - E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 - 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 - F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A - 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE - 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 - BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C - 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 - 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 - 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 - A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 - 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 - 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 - 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B - 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C - 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE - 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC - 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 - C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 - D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 - 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B - F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 - 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 - 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E - 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 - 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF - A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE - 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E - 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 - D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 - 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 - DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 - F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 - 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F - 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 - 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 - 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 - 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 - EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 - E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 - A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF - F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC - EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 - 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 - 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 - C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A - D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 - EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 - 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB - 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA - B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C - 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 - 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 - 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 - D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A - FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 - D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F - E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD - BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 - FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 - 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA - 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 - D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 - 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 - C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E - 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF - DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 - 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B - B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F - 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 - B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E - 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE - EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 - 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 - FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 - CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F - 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED - FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 - 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF - B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 - 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED - 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E - 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE - 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B - 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 - D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 - F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 - 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 - F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 - 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 - 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 - A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 - 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C - D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 - 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 - 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 - 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 - B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC - 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 - 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 - 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 - A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 - 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF - C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C - C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 - B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 - 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 - 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF - 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 - ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 - 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC - 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF - 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 - 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F - 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 - FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F - 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 - 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 - A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA - 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 - A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 - 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F - 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF - 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 - C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 - 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 - F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 - F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 - E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F - 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D - A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF - B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B - 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 - 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A - D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 - 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 - C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 - 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 - C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 - 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 - 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D - 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 - 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 - 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 - BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 - 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 - F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C - 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F - C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF - A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 - D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 - 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 - C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 - EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 - C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 - 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B - FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 - 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 - BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D - 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 - 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 - 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC - D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 - 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD - 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 - 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 - E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 - AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B - AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 - B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C - 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF - CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B - C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD - 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 - DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB - F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 - 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 - AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 - B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 - B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE - BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C - 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED - 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 - BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A - F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 - EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 - 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E - F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 - AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 - C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C - 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 - 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F - ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 - E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F - 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 - 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 - EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 - ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 - 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 - 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 - EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 - 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 - BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 - 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 - 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D - 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B - 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF - 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C - 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E - 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 - 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F - B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C - 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 - 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 - 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B - BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F - 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB - 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 - 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 - 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 - EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 - 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 - 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 - EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A - 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A - 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 - E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A - B5BF6F91D5F50E66B9A5D0FFD9} - end - object lblTitle: TLabel - Left = 231 - Top = 3 - Width = 402 - Height = 62 - Anchors = [akLeft, akTop, akRight] - AutoSize = False - Caption = 'TurboPower LockBox 3' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -33 - Font.Name = 'Lucida Sans' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - Transparent = False - WordWrap = True - end - object Label1: TLabel - Left = 231 - Top = 65 - Width = 400 - Height = 137 - AutoSize = False - Caption = - 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + - 'is to provide basic cryptographic functionality, implemented nat' + - 'ively as a white box.'#13#10'Block mode ciphers include AES, Blowfish,' + - ' Twofish, DES, 3DES and XXTEA. Hashes include MD5, SHA-1 and the' + - ' SHA-2 family. Chaining modes include ECB, CBC, PCBC, CFB, CFB-8' + - 'Bit, OFB and CTR. The source code is highly readable and underst' + - 'andable. Salting is provided where it is needed, transparently. ' + - 'The design is very extensible. Extending the range of ciphers an' + - 'd hashes can be done cheaply, easily and quickly.' - WordWrap = True - end - object lblRunTimeVersion: TLabel - Left = 231 - Top = 208 - Width = 78 - Height = 13 - Caption = 'run-time version' - end - object lblDesignTimeVersion: TLabel - Left = 231 - Top = 224 - Width = 93 - Height = 13 - Caption = 'design-time version' - end - object lblLogoAttribution: TLabel - Left = 0 - Top = 330 - Width = 614 - Height = 47 - AutoSize = False - Caption = - 'The above photo was sourced from http://www.flickr.com/photos/ml' + - 'iu92/3146549932 and has been copied with the kind permission of ' + - 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + - ' under the Creative Commons license (http://creativecommons.org/' + - 'licenses/by-nc-sa/2.0/deed.en).' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - WordWrap = True - end - object Memo1: TMemo - Left = 231 - Top = 243 - Width = 194 - Height = 86 - Color = clInfoBk - Lines.Strings = ( - 'TPLB3 is free and open source ' - 'software. It is made available for ' - 'use and copying by an LGPL or an' - 'MPL license at your choice. ' - 'Refer to the "Statement of copying' - 'permission" tab for details.') - ReadOnly = True - TabOrder = 0 - end - end - object tsWelcome: TTabSheet - Caption = 'Welcome' - ImageIndex = 1 - object browserIntro: TWebBrowser - Left = 104 - Top = 0 - Width = 527 - Height = 380 - Align = alRight - TabOrder = 0 - ControlData = { - 4C00000078360000462700000000000000000000000000000000000000000000 - 000000004C000000000000000000000001000000E0D057007335CF11AE690800 - 2B2E126208000000000000004C0000000114020000000000C000000000000046 - 8000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000100000000000000000000000000000000000000} - end - object memoWelcomeInstructions: TMemo - Left = 0 - Top = 0 - Width = 104 - Height = 377 - BorderStyle = bsNone - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'The video to the ' - 'right requires an ' - 'internet connection ' - 'and Adobe Flash ' - 'Player 10 to be ' - 'installed, in order to ' - 'play.' - '' - 'The video is hosted ' - 'on YouTube. If you ' - 'are on a corporate ' - 'network and having ' - 'trouble accessing ' - 'the video, check ' - 'your firewall ' - 'configuration for ' - 'access to ' - 'www.youtube.com .') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsProject: TTabSheet - Caption = 'Project' - ImageIndex = 2 - object Label4: TLabel - Left = 0 - Top = 3 - Width = 323 - Height = 30 - Caption = 'This product has been brought to you by ...' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -27 - Font.Name = 'Script' - Font.Style = [fsBold] - ParentFont = False - end - object lblWebsite: TLabel - Left = 3 - Top = 312 - Width = 221 - Height = 13 - Caption = 'https://code.google.com/p/tplockbox/' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - end - object Memo2: TMemo - Left = 3 - Top = 32 - Width = 614 - Height = 217 - Color = clInfoBk - Lines.Strings = ( - - 'The TPLB3 product is produced under the organisational umbrella ' + - 'of the TurboPower LockBox project. This project has no ' - - 'legal incorporation. It is an informal organisation with no defi' + - 'ned membership. The TPLB3 product is owned by the ' - 'individual contributors to its parts.' - '' - - 'LockBox was originally produced and released by TurboPower Softw' + - 'are Company as a commercial product. Versions 1 and' - - '2 of the product were commericial and were released in the perio' + - 'd from 1997 to 2002. The copyright holder was' - - 'TurboPower Software Company. Version 2 source code was donated t' + - 'o the the TurboPower LockBox SourceForge project' - 'under an MPL 1.1 license, which is free and open-source license.' - '' - - 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + - 'rivative work of LockBox 2 and does not share any' - - 'common code, but the mission of the library remains the same. An' + - ' exception is the unit TPLB3.DCP.twofish_Modified' - - 'which is a modified version of a file from David Barton'#39's DCPCry' + - 'pt package. The original unit of this was' - 'developed by David Barton.') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object lblWebLabel: TStaticText - Left = 3 - Top = 295 - Width = 174 - Height = 17 - Caption = 'TPLB3 on GoogleCode is located at:' - TabOrder = 1 - end - end - object tsCopyLeft: TTabSheet - Caption = 'Statement of copying permission' - ImageIndex = 3 - DesignSize = ( - 631 - 380) - object Label7: TLabel - Left = 3 - Top = 3 - Width = 370 - Height = 13 - Caption = - 'Copyright 2009..2014 Sean B. Durkin (except for portions marked ' + - 'otherwise)' - end - object Label8: TLabel - Left = 3 - Top = 18 - Width = 614 - Height = 24 - Caption = - 'The below copyright applies to all the source code and compiled ' + - 'binaries of the TPBL3 project, except the TPLB3.DCP.twofish_Modi' + - 'fied unit which comes with its own statement of copying permissi' + - 'on in its header comment.' - WordWrap = True - end - object Label9: TLabel - Left = 8 - Top = 48 - Width = 190 - Height = 13 - Caption = 'Statement of copying permission:' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object Memo3: TMemo - Left = 2 - Top = 67 - Width = 625 - Height = 246 - Anchors = [akLeft, akTop, akRight] - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [] - Lines.Strings = ( - - 'This component library is part of TurboPower LockBox 3. TurboPow' + - 'er LockBox ' - '3' - - 'is free software being offered under a dual licensing scheme: LG' + - 'PL3 or ' - 'MPL1.1.' - '' - - 'The contents of this library are subject to the Mozilla Public L' + - 'icense ' - '(MPL)' - - 'Version 1.1 (the "License"); you may not use this file except in' + - ' compliance' - 'with the License. You may obtain a copy of the License at' - 'http://www.mozilla.org/MPL/' - '' - - 'Alternatively, you may redistribute it and/or modify it under th' + - 'e terms of' - - 'the GNU Lesser General Public License (LGPL) as published by the' + - ' Free ' - 'Software' - - 'Foundation, either version 3 of the License, or (at your option)' + - ' any later' - 'version.' - '' - - 'You should have received a copy of the Lesser GNU General Public' + - ' License' - 'along with TurboPower LockBox 3. If not, see ' - '.' - '' - - 'TurboPower LockBox is distributed in the hope that it will be us' + - 'eful,' - 'but WITHOUT ANY WARRANTY; without even the implied warranty of' - - 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + - ' to LGPL,' - - 'see the GNU Lesser General Public License for more details. In r' + - 'elation to ' - 'MPL,' - - 'see the MPL License for the specific language governing rights a' + - 'nd ' - 'limitations' - 'under the License.' - '' - - 'The Initial Developer of the Original Code for TurboPower LockBo' + - 'x version 2' - 'and earlier was TurboPower Software.' - '') - ParentFont = False - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - end - object tsAuthors: TTabSheet - Caption = 'Authors' - ImageIndex = 4 - DesignSize = ( - 631 - 380) - object Bevel1: TBevel - Left = 328 - Top = 16 - Width = 281 - Height = 257 - end - object imgAuthorPic: TImage - Left = 336 - Top = 24 - Width = 265 - Height = 233 - Stretch = True - end - object lblAuthorEmail: TLabel - Left = 328 - Top = 293 - Width = 150 - Height = 13 - Caption = 'email: sean@seanbdurkin.id.au' - end - object lblAuthorWeb: TLabel - Left = 328 - Top = 312 - Width = 173 - Height = 13 - Caption = 'web: http:\\www.seanbdurkin.id.au' - end - object Label12: TLabel - Left = 175 - Top = 135 - Width = 135 - Height = 13 - Caption = 'Select author to see details.' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - end - object imgSean: TImage - Left = 175 - Top = 312 - Width = 66 - Height = 65 - Center = True - Picture.Data = { - 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 - 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 - 696E6720494A47204A50454720763632292C207175616C697479203D2038350A - FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 - 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E - 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 - 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 - 00B5100002010303020403050504040000017D01020300041105122131410613 - 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 - 262728292A3435363738393A434445464748494A535455565758595A63646566 - 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 - A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 - DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 - 01010101010000000000000102030405060708090A0BFFC400B5110002010204 - 0403040705040400010277000102031104052131061241510761711322328108 - 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 - 363738393A434445464748494A535455565758595A636465666768696A737475 - 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA - B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 - E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 - AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF - 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 - D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 - 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 - CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 - 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E - 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 - CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 - C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA - 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 - 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 - F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF - 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 - 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 - E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 - AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 - 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 - 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F - A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 - B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F - FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B - A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 - 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE - 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 - D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB - 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 - 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 - 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C - 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE - 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B - E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 - F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 - 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 - 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 - E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 - C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A - CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 - B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 - 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 - 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C - 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C - DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC - B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 - 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA - 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 - 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A - 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 - EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 - 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 - 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 - 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 - 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 - 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C - D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 - 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 - 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC - B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 - B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 - AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 - 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F - 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 - DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C - F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C - 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 - 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 - 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 - 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 - 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 - 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 - ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A - B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 - 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD - 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 - 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 - CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB - BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E - F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F - 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 - C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 - EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 - 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 - FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 - 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB - 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 - 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD - C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 - B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 - CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF - 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE - E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA - EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 - B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 - CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 - DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 - 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 - 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F - 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C - 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D - 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 - 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 - 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE - 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E - 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 - D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 - 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A - 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 - 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 - F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 - 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 - 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 - A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 - ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F - A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 - 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 - 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 - 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 - 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 - F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 - 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 - C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E - B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C - AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 - 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E - FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 - 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 - 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B - 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F - EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C - 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 - 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD - 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D - 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 - 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 - FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 - 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 - 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B - FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D - B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 - 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 - B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 - 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F - 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F - F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF - 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 - A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 - 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 - DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 - FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD - 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 - CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 - 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 - BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 - B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D - FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 - 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 - C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A - 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 - 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 - B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 - BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 - 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 - 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB - 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 - 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C - 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 - 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 - BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C - 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 - 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 - 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 - 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 - DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 - 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 - AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD - 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 - 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF - 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C - DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 - 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A - B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 - C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 - F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E - 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 - C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC - 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 - 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB - B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 - 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E - EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 - 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 - 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA - 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C - D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E - 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A - 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 - F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE - 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 - 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 - 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF - 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD - 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE - BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C - 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C - AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 - CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 - 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB - 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 - 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 - A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A - 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 - B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D - 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E - 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 - FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B - 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C - 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 - D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA - 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 - 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 - 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D - FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 - 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 - E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A - 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 - 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A - A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 - 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 - EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 - 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B - 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 - 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 - 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F - A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A - CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B - 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 - 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E - 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 - 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F - 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D - 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA - 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E - 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 - F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 - 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 - 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 - 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A - 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 - 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B - 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 - 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 - 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 - A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 - 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 - AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F - 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C - DA66209F4EF451457D427A1E3D8FFFD9} - Visible = False - end - object imgNick: TImage - Left = 247 - Top = 312 - Width = 66 - Height = 65 - Picture.Data = { - 0A544A504547496D616765A3040100FFD8FFE000104A46494600010101004800 - 480000FFE116CB4578696600004D4D002A0000000800000000000E0002020100 - 04000000010000002C02020004000000010000169700000000FFD8FFE000104A - 46494600010100000100010000FFDB004300080606070605080707070909080A - 0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837 - 292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D - 1832211C21323232323232323232323232323232323232323232323232323232 - 3232323232323232323232323232323232323232323232FFC000110800AC00C4 - 03012200021101031101FFC4001F000001050101010101010000000000000000 - 0102030405060708090A0BFFC400B5100002010303020403050504040000017D - 01020300041105122131410613516107227114328191A1082342B1C11552D1F0 - 2433627282090A161718191A25262728292A3435363738393A43444546474849 - 4A535455565758595A636465666768696A737475767778797A83848586878889 - 8A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5 - C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8 - F9FAFFC4001F0100030101010101010101010000000000000102030405060708 - 090A0BFFC400B511000201020404030407050404000102770001020311040521 - 31061241510761711322328108144291A1B1C109233352F0156272D10A162434 - E125F11718191A262728292A35363738393A434445464748494A535455565758 - 595A636465666768696A737475767778797A82838485868788898A9293949596 - 9798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2 - D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C0301 - 0002110311003F00F9FEA582468D89538C8A8A9CBD681ADCB5F6890FF11FCE97 - CE73FC7FAD57A2A6C5DD96448DFF003D47E748656FF9E99AAF45160B93195BFB - D49E6B7AD474502B8FF35BD6956439EB51E2B46D34E9580774201F51D281AD49 - A4D30B595B5CC7730CAF3062F1267745838C371DFAD356D0C31906272FEB569A - E3EC69B633C8EA4018AA726A52BB6598E3EB45C76B15C5AB2B64E4006B47CF8C - 5B88D41DF8C64554BAD44CE8154638E4D544793230C3F3A4099D459EAD7496CB - 179FB557E5FA56A58EB37568A803875F475C061EC6B0B4FF0037682FB0E7A071 - 9071F5A9A448E5326D1B1D4EEF2F1C63DAA1D2835AA378E22A45DD33D57C15AA - C17FABC6A08494F543D7F0A6F8BBFE435273FC47F9D79C69BAB7D8FCA9D19924 - 89B2B327047F9F4ADF3E268F5D9C3BBAF9FF00C58FE2F715C95A87247DDD8EFC - 3E27DA54F7B7B1D3942D1AFF00BA29863C0AB2B810A03DC52040475AF3AE7A64 - 49F2EDCF7A97690F8E7A52018700D4D903B526333B5118D32EFF00EB8BFF00E8 - 26BC0EBDFF0054FF00906DD1FF00A60FFF00A09AF00AF4B2FDA478D9AEF0F985 - 14515E89E485393AD369CBD681A1F451D293348A168A28A0028A334A064E2802 - C59A8F3959802AA7383D0D75B14CB7364E4A33955C9DB8C03D81FE7F857220ED - C0538ADCB68AFC5AA5BC7191E660ED51C91EF5372919B78FF3152DD0F4CD67B9 - EC0569DEDB4703156915DFB953900FD6A8088BC8028247B0A103191AB13D33ED - 532C68EDC650FBF6A96581A373B87BF152DBA7230508CF393FD3AFE5405872DB - 4A24F2FCF0BDD595B0AC7EBC63F1AD9D2ED2F962699631344548001CB29F6FCB - A53DADADADEC952E24DC8C721930E07D33D3F3ACD25612765CB283D09CA9C7F5 - A603E5BB48E09044192463F3C65783EFF5ACE86E5E0B94990E194E46296E4BEE - 0CD2EFE3EF77155973D49C8F4A4D5C69D9DCF69D1F528F55D362B98CF3B4065F - EEB77AD30B8419AF37F03EB42D2ECE9F2F114E7E539FBADFFD7AF4A382BF4AF1 - 6BD3F6736BA1F4187ABED69A7D7A8D551BB25A9CEB81C3511AEDCE4D3A41C1C1 - AC0E8296A43FE2557793FF002C1FFF004135F3F57D03AA0C69575FF5C1FF00F4 - 135F3F57A797ED23C7CD7787CC28A28AF44F2429C83269B52C033250C6B7342D - 74F49D4162D45C5A5B228588B3499C62AF59ABCBFB98701C83824E00ACA695A2 - 7620FCDC8CD6316DCB73A24A318AD0BB61A425E297DCDB47502B56C7C376B716 - 124CDB8957201CF6A83C25A8470DE4B04DF764438FAD7436B3A43A64A9900991 - B815CD88A9522DA5E47561A9D2924DF99CC4FA45BA03B4107EB59263D9230FEE - D747732824D61DE00AE71DEB6A5293DCC2B422B61FA6C314D740CEDB635193EA - 4F603DEB7B06EB72C22479253CED3DBB006B9EB21E64CB18EAC4007DCD7AF784 - 34586D70427CC40C93D4D5CE7CA854A9B99C941E03D4EEA107C9603D1DB18AD1 - B2F8717B14C1E500277C7F857AF470858C71C5598E206B0F6B2674FB0823C9AE - 7C051CD112CEB1B81F2F18CD7312F862E2C6E592455609CE7D457D06601C8DB9 - AC6D6FC3D1DED948D02059954ECF4FA1A235249EA12A506B43C4EF2D7ECCCAAE - A3C97FE1CF047D7EB5CFDEA4493B0466D9FC3CE715D96BFA0DEC282FA1573129 - C4C8465A3FF15F7AA179E11964B18EF2D6412C6E3240EC6B7F6B139DD096A71C - 4FBD380E29D3DBBDBC855C10475149110C707A77AB3026B662B2AB0EA0E4115E - D9A74A66D36090F568C1CFE15E230E3781EFD6BD8FC3ACAFA1DA6D39C20AE0C7 - 2F7533D3CB9EB246A27CCFD6A47C6F18CD314150C714F272B9AF34F58A5AA8CE - 99767FE983FF00E826BE7DAFA0754C9D2EEFFEB8BFF235F3F57A797ED23C7CD7 - 787CC28A28AF44F2429C8482714DA72F2681A2CAC8C107CC79A63F228E4F4E95 - 66EA38120B6F2F7798533267A673C629228AB0CAD6F32C8A7906B55669D6D04F - E6E15C93B6B2185755069F1BF8521B99432A6F2A1C7F7B19028E54F705271D8C - 437649E58FE551CD207C60E4D5B78D6372A5318F5AAB738560400062B38DBA1A - 4AFD4B9E1E8BCCD5ADD08FF9680D7BC699088F630E80578AF83A0F3B54327511 - 906BDBB4B6591179AE7AF772B1D985D20D9D0C4498C55A88657DEABC38C75157 - 1233B722A12366D080041D726949007D6A68ADCB9CB1C0F534DBB96DAD93324C - 8ABEAC7157CAEC67CCAE674B14786528083C10475AC2BCD2ADA3B5748230A0F4 - 03A0AD4B8D774B50DB6E6373E8A7359E356B1B81812804F63D454383358C933C - 87C4DA0DC0BA9265819D4F24A5716C9B19971EDCF5AFA12F6D926898AFA715E3 - 5E2DB1FB26AAC55300F5ADA9546FDD672E22924B9D1851F079AF55F04CCB2682 - 802905188AF34B1B496FAE63B7810BC8E70AA075AF5DD1BC3B3787B4F48A63B9 - A41B8FB1EE2B2C659D335CBD3F697E86BC786539E79A7150463A54511C2FBD48 - 4E71CD7947B051D50634CBBFFAE2FF00FA09AF9F2BE82D5011A7DD8FFA60FF00 - FA09AF9F6BD3CBF691E466BBC3E61451457A279214F8C12491DA99562DC0F267 - 27B28C7E74017B40B15D575FD3F4F793CB5B9B98E22C7B6E6033FAD743F1362D - 2EDBC757B69A3E3EC76EB1C4B8391B820DDFAD72B612982EA39D4E0C6C181F70 - 69B7370D73752CEE72D239627EB4ADD4AEA44DD2BBFB78205F04E8DE701BE7BC - 2067FBB8EBE95C0B74AEC2FB577BBF0AF8774D8E08C35AC8CD919CBE4E79A101 - D5FC42F0859683E258ED6D4830496C92AE7AF39073F8A93F8D711A9E8ACE8860 - 009E411563C4DA86AFAC6AED7F74B246BB5634405B0AA06005CF41ED544C57B1 - 90C23B90179C9271587B1A8A574CE85561C9CB244FE1669AD26BB40A565000C1 - 1C8EB5DAE9F65ADDD2868E79211EA24C03593A44F06A5E30FB4EDF92EE25661F - ED6307F5AEA5A1D461D5459C60FD940CEF4E5B1EC2A252F78E8A705CB627B57D - 7F4F9B33DC09A2EF86E6BB6D335A5B8882ABFCC7822B8DB0D3FC42E76DD9436C - AE78214330EDFC3C559B1B396DB5B802F04BFCC149C7F9C5449B4CDA114D1DC5 - F5F3AC38071C76AE17558A1D46E3FD2AEA560BC05535D96A686501471918CD73 - E7472C16311B065393823E6FAFAD4B9C932A308B5A98F0FF00C239659569C090 - 100892719C9F6CD5D88E952B6C87CA07DB073566EBC1F617F76F7976B2F9CC54 - 90170A4A8C0240E2AFC1E1EB21746E7ECEBE69EB2B2FCCD5737A68C882B3D511 - 496ED1C21B39523818AF38F1DE9E7E5B8C020F06BD6AF554C2547615C4F89E11 - 3698E366E2071FCAB38CB964997287341A0F00F8456D2D5F51F2CF98F10F2D9C - 76233C7A7F5AE8359B8DD25B43B79111763F538FE86B6F4A952C745B68A40F24 - A91A86C2F4E2B9AD5678E5D465087EE205E3B7538FD6A310FDD6CD70CACEC411 - 1CE391CD498E6A1460B8E3A5488E18D79E7715355E74EBB3FF004C5FFF004135 - F3E57BF6A67FD02F7FEB8BFF00E826BC06BD3CBF691E3E69BC7E61451457A279 - 4152C47F7722FAE3F9D4552C2769CFA1140D1645BB244598115596BA79B4BBD5 - F0A26B72D93FD92699A28E7CF1902B985EB4BA21F5D053D2B52EAE5A1B2B1087 - 0CA0915987A55EBA4F316CD338CAE29C419A76C2F753879BA5E0F491B1534675 - 3B89A4B64BA07E5C105B834E7D008782DE3BB0A594B127A5577D16E63BB302DD - A13B776EDD8045501DC785F458A1D26DAE642A2F6D6765250E728D8E0D77F6D0 - 24E564C61877AF23F085F5EE9F71F6572B25ADD49B493D5587715ECBA615F292 - B86B2B4CF4F0ED4A08BEB1054E4926B2E38F76BD18F4C9FD2B6C1C1F6AC984EF - D7770181D0567637D8D4B9211B07A536DF065F50697538245C646370C8AA5079 - 96D77113282A7EF29ED43BDC71B729BC23C74A8E64C2F03148B764107B1A6CD3 - AB77AA76B1924EE67CAA79CD72D7EC1679011C2F6AEA269393ED5CAEA5FEBD98 - F4622B291AC7732F50F8B7630466D2C2C27FB629D84CC46D561C763CD2E8E659 - AC5AE6E4EE9E7732393EF5E75A9E9262F124A720879C9FD735EA56C823B2541C - 70054E2ACA114BA860DCA5393974254233F853E3181B854698F5A941E38AE13D - 0286A9C69D77EF0BFF00E826BC06BDF352C369F77CFF00CB17FF00D04D781D7A - 597ED23C8CD778FCC28A28AF44F2429C8719A6D39680359F58D41B418F4B6B99 - 4D8A486458777CA18F7C5662D4EAF9B765278C1C5575EB432BA8F3D2AECAC8F2 - DA89495400648AA24D5C98069A28C9E02F3490336638B4A6B941F6B976907249 - C62892DF4D33B05BE90018C1FBD9ACF1F6359A58F286355CAB9EA4FA5432450B - 5B2CCAC048D9CA0FE1AAB81B5631DADBCD0CE9A812D1CA1821079C1AF67D1AE4 - B40C464851BB03D2BC53FB16D0582DCACF26FD992BC75AF50F03EB31CB67693B - 302197CB93DBFC9AE6C447667661256BA3A57D5D802BB3E63C605568E7BB5BA8 - E78622707E604F515A3AA69D0CD1B141863CABAF06B9ED31FCABBF26F6FAE635 - C901C1047B76AC4EC49B8DCE8E7BEB9BDDA8D0CA147072314A2CE787962A323D - 31C5598A0B7DA1DF5D063DDD957763EBFF00D6A8AE67D1A163E599AF65DD91BC - 92318F7E2AADD4949BD237FB8A53EA0B668449709C7607273F41535A35E4CC8C - 4108DCE1BD2A3B4B41712ACD24291AAF288AB803DEB566944109618CE3005437 - 729C5C5DFA945DB2EF9ED581ABFDDF7CD6B990A444B75639358779279F761073 - F4ACDA1C5DD9C8CDA735D78BDD88FDDA0573F5C575C0E131DB15C978935E6D03 - 56611DAACAF2203966C018A9BC37E2A3AC48D6F7491C33F54099C30F4E7BD655 - 69D49479EDA236A3569425ECEFAB674801C1229E9BF340E3D6979CFCA3F1AE43 - B0A37C3FE25F7B9FF9E2FF00FA09AF05AF7CBFE74BBC38C7EE5FF91AF03AF4F0 - 1B48F2334DE3F30A28A2BD03C90A72D369E83E463E98A009A37DA8E38E411CD4 - 6B4A837B84040C9EF4636B153838E38A4F62BA887A55D91916EE32DF7768CD52 - 356A48A49AF512242EF818503AD340CB1349626EA76585D622BFBB5CE706984D - B7D8D3CBDC26C1F333D0F3C62A66926865B9F3ECBE79131865C6CF71505CEFFB - 25B86B5310507F798C6FA4C0BD21B1FECC528C45CF42371E957FC1DAF0D3AECD - A4ED88253F292780D5566BAB36D092116656703FD6ECFEB5807AD29453562E33 - 717747D23A66A5F688444CC18819539EA2924B1579CB81F78D791F857C573D84 - F05ADF31DB9063909EDE86BD8E1BD8DE157421B3C8E6B8AA45C59EA51ACA5AC5 - D8B16F14516D2C8A48FF0066B44C6B390E500FA0C0AAD01F322DEC40A937BF97 - BD1C6CF4EF4D36D1529EB76C94000F1D2AB5DCCA48048C2F351CF7A238D8935C - EDC5FDC5E4E6DED11A491BAEDE83EB51A8B993D89B50D4429D91FCCC7B0A9B4E - D35E188DCDC0FDE37201AB7A5787D6D7F7F7444939FC96AAF8BF5F83C3FA53CC - E434EFF2C31E7963FE02A249BD114A4A2AECF2FF00885E536AB1286FDE804903 - D3DEB97B69E4B69E39A262AE8C1948F5A2EAE66BDB992E6772F2C8C5998D442B - D0A70E5828B3CBA9539E6E68F5ED0F568F57D3527520483E5917FBA6B4092383 - 5E59E19D64693A9ABCB215B77F964EFF00435E9116AB617255A2BC81C3740241 - 9FCABC9C45074E7A2D0F6F0B885561EF3D43522469975EF0BFFE826BC12BDE75 - 33FF0012DBAC73FB97FF00D04D783575603691C39A6F1F98514515E81E5053D1 - B08E31D6994AB400E53CD3853075A7AD265210F5157EDE59A3D523781774A3EE - 8AA1FC63EB5692E1EDAFC4D1FDE53919A680D6B89756B9BB9736EDE632057555 - ED4DD42F2F6FED56DDECCA880F2554F14D4F11DDADEFDAB085F6ED231C5363D7 - A741719507CFFBD45D0C9A7D5E597461686D36A00079983585D5AB624D70C9A5 - 7D84C0A063EF66B1FA9E29302EDF46765B286C9F2C1E3B5767E12F13DFAA7D85 - 90DC796B9520FCD8AE3A5904810E31B542D4DA3DFB69DABC1720F0AD86F707AD - 2A8B9932A94B9648F5E83C5EAABB278A6423F859714F8FC43733FEEEDADE4909 - FE1519FD055EB351288E78F0C8E01C1AE92D4650055FCB8AE1E7F23D2E4F339D - 834BD5B5370D763ECB0F751F78FF008575163A74165088A08C228EB8EA7DC9AB - 31C6481922A4B89ED74EB492EEEA558A18D7733B9E052BB61A22B6A1776DA569 - F35EDDC8B1C110DCCC7FCF5AF9E3C4DAF4FE23D665BC972B18F9618C9FB89D85 - 6CF8E3C6D71E28BB3041BA2D3236CA467AB9FEF37F876AE38D7552A5CBABDCE2 - AD579B45B001410314D2D8A03E78ADCC06ED2CFB7F3A9FCA58D433BE3D3151EE - 0BD3AD34E4753405CBE9ADEA36F6D24315DCA22652A51B0C318F7AE66B518128 - DF4ACBA9514B6413949D936145145510152C2AAC4867DBC7A5454E4EA68635B8 - AEBB5B8391D8D2A60F538A770D1B0EE391518F4A43D894AC60821F77E14E91D1 - A42C33CD46071F8525031F914E542E320714B1C25F93C2D4A401C0E828023113 - 77C0152AC71A0DE49CFBD2A0DC79E83AD3646DC4E3EEFA53480954AB8CB0C03D - C76A6B47DC74A8A391A36C8FC47AD6DA4B6E103050411E9406E7A37C3CD596FB - 4B5B591B32C3F2F3DC76AF49B5B718C826BC0FC2F7A34ED7A2911B114870457B - F69EE1A24607218020D7154A694EE7752A8E502CC92C1656D25CDCC8B1C31AEE - 6773800578578EFC6573E29BC105A064D3A16FDDA9E371FEF1F7FE55DEFC5B6B - 81E1DB458F77D9DAE312853D783B73EDD6BC719C4631C56F469AB7318569B6EC - 5558254C8247B8ED51B29EA3A54ECF95DCDC2FA7AD57794B302BC63A56E738DC - 51823A75A9171276F9BD3D69784E7BF6A431A1446327EF52282ED40F98E4D584 - 1B1738E4F4A006BA8489C01CED3935835D1B058E072464953815CE5364B0A28A - 290829CBD4D368140128383C5376F34DA327D682AE4A095E952C50EE42E4640A - AB93EB5A968001B3F85979A40860395E2998E69E83871E8680053183FCB1003F - 8BAD418CD4EC06DA8E813186A689885033C5458A9507CA29816EDEE1A299241D - 50838AF61B2F881A5699E1F8243299E7D985817EF647AFA578EC31AB4809AB52 - 008BF28C544A9A96E690A8E3B1ADE23F17EA7E22B8DF77294814E63B743F22FF - 0089F735CFEECF27F2A69E492793EF4A06466AD24968436DBBB1AC59F93D2929 - CDD299400A0E0EEE98A19CC8FB88C7B521A7C6A3AD201C8B938EDDEA6C85F98F - 7E829B08F973EA69C066673FDC031ED4C41238489D9CF2548FFEB0AE7AB56E18 - B48C0F450401595484C28A28A047FFD9FFE20C584943435F50524F46494C4500 - 010100000C484C696E6F021000006D6E74725247422058595A2007CE00020009 - 000600310000616373704D534654000000004945432073524742000000000000 - 0000000000000000F6D6000100000000D32D4850202000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000001163707274000001500000003364657363000001840000006C7774 - 7074000001F000000014626B707400000204000000147258595A000002180000 - 00146758595A0000022C000000146258595A0000024000000014646D6E640000 - 025400000070646D6464000002C400000088767565640000034C000000867669 - 6577000003D4000000246C756D69000003F8000000146D6561730000040C0000 - 002474656368000004300000000C725452430000043C0000080C675452430000 - 043C0000080C625452430000043C0000080C7465787400000000436F70797269 - 676874202863292031393938204865776C6574742D5061636B61726420436F6D - 70616E790000646573630000000000000012735247422049454336313936362D - 322E31000000000000000000000012735247422049454336313936362D322E31 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000058595A20000000000000F3510001 - 0000000116CC58595A200000000000000000000000000000000058595A200000 - 000000006FA2000038F50000039058595A2000000000000062990000B7850000 - 18DA58595A2000000000000024A000000F840000B6CF64657363000000000000 - 001649454320687474703A2F2F7777772E6965632E6368000000000000000000 - 00001649454320687474703A2F2F7777772E6965632E63680000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000064657363000000000000002E4945432036313936362D322E3120 - 44656661756C742052474220636F6C6F7572207370616365202D207352474200 - 000000000000000000002E4945432036313936362D322E312044656661756C74 - 2052474220636F6C6F7572207370616365202D20735247420000000000000000 - 000000000000000000000000000064657363000000000000002C526566657265 - 6E63652056696577696E6720436F6E646974696F6E20696E2049454336313936 - 362D322E3100000000000000000000002C5265666572656E6365205669657769 - 6E6720436F6E646974696F6E20696E2049454336313936362D322E3100000000 - 0000000000000000000000000000000000000000000076696577000000000013 - A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A200000 - 0000004C09560050000000571FE76D6561730000000000000001000000000000 - 000000000000000000000000028F000000027369672000000000435254206375 - 7276000000000000040000000005000A000F00140019001E00230028002D0032 - 0037003B00400045004A004F00540059005E00630068006D00720077007C0081 - 0086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00D0 - 00D500DB00E000E500EB00F000F600FB01010107010D01130119011F0125012B - 01320138013E0145014C0152015901600167016E0175017C0183018B0192019A - 01A101A901B101B901C101C901D101D901E101E901F201FA0203020C0214021D - 0226022F02380241024B0254025D02670271027A0284028E029802A202AC02B6 - 02C102CB02D502E002EB02F50300030B03160321032D03380343034F035A0366 - 0372037E038A039603A203AE03BA03C703D303E003EC03F9040604130420042D - 043B0448045504630471047E048C049A04A804B604C404D304E104F004FE050D - 051C052B053A05490558056705770586059605A605B505C505D505E505F60606 - 06160627063706480659066A067B068C069D06AF06C006D106E306F507070719 - 072B073D074F076107740786079907AC07BF07D207E507F8080B081F08320846 - 085A086E0882089608AA08BE08D208E708FB09100925093A094F09640979098F - 09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0AF3 - 0B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C75 - 0C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E13 - 0E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30FCF - 0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11AA - 11C911E81207122612451264128412A312C312E31303132313431363138313A4 - 13C513E5140614271449146A148B14AD14CE14F01512153415561578159B15BD - 15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217F7 - 181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A51 - 1A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31CCC - 1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F69 - 1F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB2227 - 2255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA2509 - 25382568259725C725F726272657268726B726E827182749277A27AB27DC280D - 283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B36 - 2B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E82 - 2EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31F2 - 322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D3587 - 35C235FD3637367236AE36E937243760379C37D738143850388C38C839053942 - 397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D22 - 3D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E74129 - 416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE45124555 - 459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349A9 - 49F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E25 - 4E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52C7 - 5313535F53AA53F65442548F54DB5528557555C2560F565C56A956F757445792 - 57E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C86 - 5CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61A2 - 61F56249629C62F06343639763EB6440649464E9653D659265E7663D669266E8 - 673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C57 - 6CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571F0 - 724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677B3 - 7811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417DA1 - 7E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783BA - 841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989FE - 8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E9006906E - 90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F970A - 977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649DD2 - 9E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4C7 - A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75ABE9 - AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B338 - B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBAB5 - BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C25F - C2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA38 - CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED23F - D2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA76 - DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2DB - E363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB70 - EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F434 - F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD29 - FDBAFE4BFEDCFF6DFFFFFFDB0043000101010101010101010101010101010101 - 0101010101010101010101010101010101010101010101010101010101010101 - 010101010101010101010101010101FFDB004301010101010101010101010101 - 0101010101010101010101010101010101010101010101010101010101010101 - 0101010101010101010101010101010101010101FFC200110800E90109030111 - 00021101031101FFC4001E000000060301010000000000000000000000030405 - 0607010208090AFFC4001C010001050101010000000000000000000000010203 - 0405060708FFDA000C03010002100310000001F9FF0000132A7AC723F226E8A6 - 229422792321CDC2B755686928576EE1632689A324F1CD3F492CAE7FB29541A1 - 79F23DDF7AB63AFA1BB5760F4AFB46D12AD56D91D616E1AA48FF009ECFA83E28 - C2800000718ED1A4996A6E3B66AEA89AC8CC22069ABD4D63EC7658B79EF8D233 - 61B58C4FD18FB41EF9BCB1B556BBDB59FB57979B7B23173DD04CE859463F56BD - E228CE546A25F9E6FA83E2BC28000005F1DA3476A1B0651702654086CC7EEA97 - B2D97DAF62B122872C7892146D5562DC2F74B49560E5435273BD87A2FE41EEB6 - 0665F58D54892382334452477CEE7D41F16E14000002F8ED1A3B5001B0000010 - D992485ABD2AEB49627F3E3608ED8AE9463F453BA123E3D92F475A1215544EAD - E07F71F01EADDE9E6DEB6E912A547BA2350B64D9AEF9D4FA93E2BC28000005D1 - DA39AE2D4D837170A98172886B247B827B295CAD25802C1149607914C8A59548 - B783C87C6257157B119D166D4357D98F0AFA466142F20495F1B1B624DA35FF00 - 3AFF0052FC5585000000B59656C529CC9524F01D13DF2ADD4F244DF35750395C - 33F48BEC16D29D20CB5F7243A154AD791D9AB6E4AB4B451C5046814A6AAA63BB - 3F88F4DF46FC9BD9303D7C68955E9DB27CEAFD4BF15E1400000486A685E5CC76 - 8D56B3E29AB91D3BE7BE9D66F23D9549D67194BF5BC656FB9CFCC075CF15CE99 - C4E9BA3E8EA4C5924BAA68401AFE33EBF8980E961534C8EA12B3539AE0C7EA8B - 7760F57EBF7887D105B249042D40AF25927CE87D4FF15E14000004E3376AE1E7 - BAAA8BA7E3986ED4EECF25F689A733D452DD6F195CF45CDD47D0F28E492FA2FC - DFA0FA7BCFEFD8D2B1DDF12F588A1FCF9333CC4D0C88439B4C6973F47EA73E63 - 55D11F62656F7B21E0DF4AAF60AE309472225F9D9FA97E2CC28000007BAD7A53 - 5EDB1DCA4C52436051D39D656CB63552CD0C17471DF193FB59E7BEC7D771A4FE - CC2FD3D5552B15AC25C725735AED1AD9E84B10F939DAF97565252C092886DFB4 - 3E01F504F284E78108E6E26F9D1FA93E2DC28000005F1D874649BCCD6F81C925 - 83A2675ABB234CC47334B0CF60BDEE479C7AEDFD236C7BD0BE58AEB1D1EEF8C4 - 4AC35E787436EA6AF738CAFD1F32FAEF2F85DECF728E5F5EBC2FE97B8B1355E1 - 8278DCD6E9BE743EA5F8B70A000001D23B4AA29ACF9A0AB629924907A17A29CC - 9C4748D1662AF75733A2333A2F59F8EF49EA0B79F604CE9A58A4E12D77ED0CAA - 12B4F4DBD6134B66439DA09F36EF973D3F0FC69D0719DE58BDD7A0FE53ECED3C - FE939B0351AC6DB3F3ADF537C5985000000E314F388A6F4A8AFE54AD94F243E9 - EDB5E96E1BA3E03E63BEE78EDF80B0E4B3D1B06C5A2D6DB99FB5DD35EDDA16E8 - 50D52FF2A3A3B12CD39253BEBAA4ABAB58E2DD1CCE50DBE73DB7E6FD16AEE43A - 483F35BAF0C698234B6D7CE97D4BF16E14000004A9933DABA5EB1D535ED96E8B - D2B911E32ED71BD3DEB0EB5C90AD8EC0C6EADD2ED07F7C6939EEBFD1DD1E7799 - 313A581E857AB7B2F3B9662F49D1B81AF2721E6DAFA2CDD1F2FE88457B877CE3 - D31A71B41F1A8635B1C5B3F3C3F517C5D850000012C64B895CD50B8E8E6C3A3E - 8BD1AF2A91F16AEEC35D6F721E81E9172DD548AFB2DE794BE3ED7616CE341F3B - 5004CAFE3EF1A88A582C36F9EE85F9868E659D69FC75E73DEC9F2F44D473A361 - 8E967E7ABEA1F8BB0A0000025B5AF486E4703AED52C9F71B61E9553E19AC3910 - C1FE8BF15E93D3DCDF5173587C8A46D07527E96D1CD8366EB4A248AC3D9C3113 - 6134B46135E7E72A37B9977397E58D2C3F44BC53DF56C53B834523585B63E7A3 - EA1F8BB0A0000026F4756DED8CFE7AA322C8A639CD995FAB69CAF4F03E2AC5BF - F0FA5F5EF86F50BEEE357ACD41C75FA36CD6A771F79EEE456DDDC45F35787E76 - 942E039BE95FE03DFE5AB07D4F4E7C73DD930E7346E44604B1F3DBF507C5B850 - 00000F50D8EEA5ABC16EB6AE2995B9B2DB705C133A4719016A9B058F65FCC3DB - 7A3E77E256532B53AB7432E8EA7B425AF257B12A5470C5E81A19529DAD778FB4 - A94373EEF66F9F7A2B62C9B20B86B4ACFF003EBF4E7C5985000000E315993DB8 - E2B5645914AA9C921B504E6474898E6868B9E7A55E71EBFDA4D7525665774B56 - 5AC12B9D85C2EAE9B03EC33D8F1110AECA9EADDE674D095F1FD9D819B68A47EE - AAA46B6B66F9F1FA77E2EC28000005D1CF2595B1A8E459148B5CD7DB50C85257 - 0886C55E9EB6C9A719DF7AFF008DD1B0335F986C5EEBEBDCACD9EE85D5DA8D66 - E9DBC62570CAF1D4868AADA513CED3F2FF00D0BC9FB1F83F4CEADE0FD21422A6 - 0D9AFF009E6FA7BE30C2800000708E67FB091FAEF551CEB5F13D588A568ED229 - 1B096DC57D5542DFB2BC6FA975435D5757E92657AD5ABA7CC6F9929F49E7BA2A - D5B5A9B81CD5435F1526F0FF00D9BE7F7A65AF597C1BE909F636F9605249F3E1 - F4E7C6185000000ECC9F2F54F0AA96CABA58B123260D73B9243E23A06E3F98A8 - B6F3CEDDF5E392F47E8CC9D771BB13D5FAAF351E9A17C0E4A94246F591CFD319 - 36BCBAE8F92F387D0FCD8C16EAE77ABF547C2BE8A48F9098E5F9F6FA73E2EC28 - 000007A497572EF1BB48A55B344FF2167BC490C9046B6ECB2DE65A2F76B096F6 - 76AFB57C47A5D9CA49ACD2DAED581D6B144D2D1BB235E82A73F225BCFF000CBD - 1FCB497B4B6BB753A9383F47BA79BEBAF6E4BBDF073E8FF8EF0A000001C1B268 - AF358E3639154F03839F610E35A30B4984A948D574EAFC31888E9AC6EA3B4303 - AB9435A7A3ED5AD67ABE9589CB1D079A9FCECF7FE755EE851390D11CD8D4902B - 72E56B864A764CD00000003DB2870A992191C8B26816B9D743E4737B48692379 - CAF9EB30B91971AA886CFB4FE5BED775C05D16A1923A27F5851D8CCF9FDED789 - E69D6CC2950B13229E3494548D5298B5649400000001532629EC52C90C6C8E0F - 8896CBBC52000E32C4C3D250E53646352B3D34E23D1BD19E57A4B4EEC13296B9 - 36B37E7D3B6E2F9CF4F35331E950246EC2ECE6AB6BD3A2BBAA51C51000000095 - D3D362B14CB723CC56B423207045CA8FB21BB5AED20D92C5208E539527B4743D - E6F3CF4ABFED533E5AFE0F769C572CEB656A8AD6C540C7128B911C01B9AE7F91 - AB1E73D434C0000001C23B4BDA334B02C73CC8A62816048C710F6AB6BC4B0B33 - 47172DE4E9D918CF54B8AEF7D1CA9639BB5713C32ECF93671891AE8EA26AD1D8 - 5C22B6355CDCD76557779CC305300000005F1DA34548E88E47A947A9093A3C95 - 690E47195B1D5680C04858F79493B3F9DE9FD89C4DDF2AFA7E478477B152A2B7 - 3585A2E07390D6B63D62B1E6455E2AD0E678698000000286CDBA3F743710B0B2 - 1D335A21AA8581CE1A08F6789D4761CE08B308A79A35F5A5BA842B731BF51480 - C3421A2851D2447A7B11B5CD4C752ECA60000001B8EC8E02015534B3CB4815BA - 39366811ED6445AA16A3C395D9CF9F4AD6D52315D0C994F8D5B4356A86B881AF - 2F452AAB518AA54AE615AE1B58000FFFC4003110000104020103030303040300 - 0300000002010304050006110712131420211022311532341623334124304208 - 3543FFDA0008010100010502FA3739D16FD6BCB9EA9FC4912573C93315F938B2 - 1DCF3967A82CF5059E72CAC8B3ED665853D956CD8D123B60FB2A6ED635D8E4F3 - 645BADDAAC998716F2D5B995BB93469D3720767752B9FD52879F466DF2BD9C63 - 7F09C721FB9B1E13DC8BF1CE772E790F3C879DC59CE7CFD451496A987624927A - 22ABF2AB7B86343798912DB171A94DF35E6C3B8B13D28479CE01E81B5C8D2ADB - 78B58B6AFEB9F7447438C50C514F1B4DFF006FC2283C705ED4FC7FD088A4B51A - AC872318041C9EF12113D9EADC21C6D1A238322BE3B472D971EB517BC4CC8B16 - E156EE52223DA84807EA95C5CF8E1CE31178C555C2FDFED1FC7FD105A427AA6C - B94D8BE1C904DF7386A9801DD8DF7B42D331DF35AF162442D726487AD06E6A63 - D94E88F34E1292F4AB68104E31533B07050150DB4E7B5117DA9F8F78A72A8BE3 - 4D7E7AC3952DF9D6CFC883D986DF04ADAA3682B9105B756BEB09D85269EC6B9D - 72C2ED45C377CC246B94F396B27D1DA43BBAF3F9C680949457B5DE7B8BE17DA3 - 88DBA79E8A5F1E371305A7C91BA7B479A5AA9E984CB818C8718DB66EB9162351 - 21CAB6762B5223487161D59BAF39AE4AF42F57488AEC36651BB3A5BEFB535895 - 5D853E5773EEABAA1CE0AFCF4AB607A1D82AF00AE7DC3DCAD8F0AAEAAAB9ED8E - 2A4B0194ED976BE3C4058929CAC58B594911BFE9B96DA22DCB48A05F68D14866 - 14C62C254E9341D30B0B2C0E8F55E31D26A5657FA2C1B2D8B45AEB007B534AEC - BE66135965290D979E71CCFCA87CE7FBD2DFF4F7A8A9DA8BF7A2F009CA61AA77 - 7B608A6426A5589494269F71F253A5B86AC74F852819D7E63E3CCBFEE03EBC9C - 3713BF49D7586069E2A037E344C6DB42CF0A262B3CA6EFAA7AA81B569AFCBADD - 7F506B6AAEBFD42C2A4CC3C4AD1738EF8D0B5B51FD523F06D360BDE26BDC6BF2 - 5F3EE6DF214667C9630D54B0B9CA7B6F40D357360DC772C5C733D43A6923299B - F2C8D7A02857D512A0297C3409C76B8A58E222B695709971CD1AA62596EB4E08 - C5AD678DEECEC7139E61AA0BB48BDF58CFDC5E211520555E3EFF006B7F2A659E - 377C4A9F1FEED233E15090DD54F46F8A2A266ACCF9ECE811123D78FC82728CFC - 229634D9AA9B448AE345CBC8A2B6F085FCD9345A8943B0D39D3CB41C015CD2CD - 4F5D8EBF3C8E11FC77727ED6BE33B79C94FCC8BAE67FEE78855EA129879A0F95 - 179500FA6B1464CEA29AC8AC290C7631223B82D31E516A2F761BD0A28DE6FBAC - D4B8E7542A9E52DECBD433B0B16193980759EA8551FA9690B3A57D387B617A7D - 3B54CF31CA27383C2E71C3DED4E4475BA97360BDFF00E55556B1AEEC39FF00E9 - B43116168FD59E9955D1E8A346D65DD1498EF74F9F72314562EEC0D8D3F6C602 - 8ACB62AB76AAF45F646798C7BC96EBD8FEBD48FBF0A8B5061BEEA868598B1CCE - 4C6763A7526A4A441D33526F6097169D6822EC938645F37CAE70B838BF25ED98 - DF8C35E92E41B8DE76191B3ED389FE5EB559EBFF00A1F54BAB0761A944BEB978 - 359BB32D9682A5B89BFBB319D4325EED2ABE0C6D8626C8FD7CD995EFFD9FA6DE - 32FC933A79013364E97D8DE5D43E99B8DD56B3AE7E98970DA76EC7142455F436 - 0B2D4DB660462D92F7DB362821CA227FE44D7C9ED9E5DEB1CBC68A4A4789FE4D - 84D0DF7DBD55F0AD8744EA5B40A28F5D42DD87EBB794EC5D41AFD52964C50A5A - D06A74002B2F848AE4464C22D3C47442B4047F4A5EE797C613055D6ECC5143A7 - 158753557CFB54B0AB65BB3E00FCE1F7228F3E20E50BDA0C9CB7DD88AC309F9C - 04FEEED0FA93B46CC79073A9EA22B35DAED6CF85A8B15E5A154979461C76F870 - 5481E0E6F640883092079AFE50BC7DD84D280CA045C743B52DD789FB1757364E - 9E97F5B6CDD44B68ADA33044973F738A8898BFBFDB0A4FA672C01B8F4E9F46FF - 00CFB00F7CB4D55E8B4E5A4DE351C28EE1C89D3DD92D75E728107B58E15B43FB - 54BCB7D25B238C719E71FA53970E67AEE14E509049731D7394B9E564F54AA0A7 - C3E99572A5DF1C4604C1C3FC22773BED12FBBA8DD5C7379D293E8C7F22E3B9CB - 0907B5AC033DCC2303DB0B31A2D85BB11B59B0EF16E5832DC8B3685A3B0661CC - FD763A573960EA13323B71BB64E0EF3B7199ADCA688FB92DC53B374534D6FA71 - 05C2714914508D151E54557109B8BF72FB47F321A4F4C3F4613FBF60A6DCCFEA - 2BD931DDDBAE3D18EE9682DB7BB588C5D0ACFD5D459D5C82196FFA47195A1923 - 1AA2190470A4AB1498D492B39D66D052D0CA262430DC1848BFF1AE9C416F6786 - B2359D7E084180BF8044CF18A628878E38F67B93F2269E04CFF513E65C85F2D9 - 4E9D1D164CF82F5B49F48735E894271BA5772CAE6B56ADD8575FD7B52E3D3FA2 - A599013A733723DAE8D52CD96E72266554071D7811106D5E5932243EA036D2BC - 8F6CC0E46D6656F5B6C92E9DEE0E5AB7F3C261239E36FE47DCC3CA2D0FD227F2 - DCFF00ECAE99A5074A15415ECB6596DF974D56DD3D15C9EBF75ADDF81804D6E6 - B2FD58FA881045B4AF7188A3E95953E3B55C77C2D3A62016B6C0D650543F60EE - EAD81D7B8CA332214C7E14AD5AFD9D8EA554917955CEEE17DBC705DDF68FD21F - F32612FAB9116214A728A30EC321B26A5CDD39D8D507F9D2B7793AD48D4F6162 - 628809880C7256DA06CBD6B79E50CB2B0445B8BFE328757976666D36C33D61DD - 4183FA697B2B9AEDB09B6E303F83E3BFDAFF00DA4C1023AEAB64F6415FF990E1 - B7637375A7A56140D3E5CCB3B2AD72B2CA753EC8C539E57C409B234DDBA46AB6 - 9597AD58C4AA36B99366087225415199681184A6585D4AA0D1A3C0240411EAB6 - FACE9958F3CF497953E9DDC66BFD559F5F1A0755E8DE721DAD65A27B5D715CC1 - 5C4FA42FE531E739F631763326C768A4CB0FD6DF7E46CDB148845F9D7C00EC1F - 605C93A26C37912537B959C1273A8292858BBBEB3281A5EC768E555444AA8C2D - 66D5B0D66A34BB4EC73F6CBCE31309130C57198C878E1466F3BBEEF6FF00A4C4 - FCAFE207F261C95876169B92D925BEEA36506C36C62755C9DB2A1EA42FDD46EB - 6C4C2E132B673B5D6358E85AD65483078D1270DA190B71972E6DEB35AAAEA4F5 - 22C7A81679CE29E777760A2229385CF3C622AFBBFD60E1640FE428FDFECED22C - 618EC0700B851E17A337BEA20C66D5321A976B484596D6F5BADD57527A9D6FBD - 5836E36E2292A2A973F44F8CE4DD52E1B440EEC6E37B865FF69C0EDC1FC8CD51 - CF39A1790F9525C1E497C2D6234C8E3644286FFF00718F271E85E73351B57F5D - BEA09F1E7468E88433A6C3A7AFEA5F51A7F506CD2B2326132CA090FDA6D282F1 - 9D8A6ABDAD0A724AC33F0284E97B53F1FE4679FA2FEDC69A27891A6D94C643BC - A498AE16447FD3BFEADA14944D4ACE8FDC7AD810D73AE4C4877A75CFDAE48C5F - B31D795C569C56D147E3946C7E495B0E5557BD50C630FB53F025DAAA38298A7F - 6B51D5C40410073113157C2D7D17187CD005D54CE90DA2B16D2B63AAA3AFEA1F - 5B6CF6A6DD9044BDE2DE111BCBC267E323BC8CA2929927DA808A00840C8B48BE - 4F6A1677E77A679073BB9588C83B19BE509CFCA22E3AAA63C7CAE2A6369F0A25 - C56BD323BF79756F7B20DC52C4F8C51E54BE3EA4AAAAD8F38D8F71FC0A35E435 - 932B95FF00A58FF343FE51FF0030FF002987F8FF00D2FD07F687ED6BF6CAFDF8 - 1F92C3C5CFF58391FF0012BF8A7FB1BFDFF5FFC4004A11000102040303080804 - 0206090500000001021100030421123141055171101322326181B1F006142042 - 5291A1C12362D1E172F10733538292B215243543637383A2D21625303474FFDA - 0008010301013F01E4975B509972D21764A1291C02401AEE8F5DAA57BF1EB355 - F1F8C7AC561B24A95FC2BC3F378C75A33337FC621532A9BA4A98DF994088E727 - 7C7E118E67C6231CDFED04635C7E27C63CF7473CA96063214FD557C180955FFC - 70804BE1BB1C2A57C4A0007F934613918E66EFFA4225A8105258EFEE8289A410 - 5618820DF422F9DBE768A6F4BB6952D348A694A79525387A32A9A6E5FC42F141 - E96D626B973D53A9553A6652E6279B95F390D141E98D3A96997B4E5A68D4B602 - 6CAC53A92613A85075A316612BC81631E96CE95328A7CC92A0A94AA5250410C4 - 62402CDDAE3C6F1E8B7FB1E97FE49FF32E24E5E77C0B08CCB403A427AD07A2B8 - 97D61C478FB49EAA780F08D3CEF873BCFCCC0277C39DF072873BFD84A1E04804 - 32998E692035F370CD761F48712C604212D9B848173C387D6095EF278BB0E178 - 330E594059DE7B43C2660B3FDA094AB5B1D34852ECC521F807F9C52D6D5D1DE5 - 4D9890A174A662D208DCA0921C761891E904D34D328A78FC1521424A07525E35 - 95AF0A3AA9C530A96A60312C959E9178F4653FFB54912E6208E6E590C4745DDD - 3D9BC8D5E24E3E67A5985AC38CD9C59FB3484971033E42A6CADE318947373DA7 - F9421DC71F693D54F01E1EC3987E5610CF944B013C7CF7466062BFD3C1A145BA - B6B71BF7FF0028E71435FA0FD20A9F3F3E7E51A5F2F3DF9C5B778FEBC814165F - EB167FDFC882082543DE0C75B77E5C45E3D18F49E76C89A24CDFC5A198A65CB2 - 7A72D6C1A6215FD61B3744A8A031385C98D9B3D15343267CA51526715A89B31B - 8602D98BE2DD096194025E348680FE40896E543F88788F693D54F01E1ED8E494 - FAC602E0EE8BB31FA42CA536BF7C294F9400F09DCD686E408DEA0385A010E41D - 2DC5B5EF8040516FAF0861D6163A287592FBB4EE68FE8FB6F282D5B166ACAB1A - 41A30AD169C7CE25DC0E9BA741D584E7929CA7176258B149EDDDD902F0E5B4F3 - DF0F098943A4388F11ED27AA9E03C22DBF948E4B6FE44DE1A12E6DA414ABAA2F - DBE5E1528FBD9FDA0CB684A483DDFA404B96CA02144E8C2EEF053DB0424E8DDF - FB430DD0D7CE1CBF9EF8D9958686B24554BFEB64A84C49766096C45D8E9F38D9 - BB4A4ED5A2955B4CAC68A84059DE958B2C1EFBE912EC4BFCBCFE9072CA067161 - AC4AEB0E23EDED24D858E43C2132E6AFAB2D47BA3D4EAF3E696C332D611CDCC7 - 6636D77C2654E520AF99998467D17CB5B6912B656D19F205449A49CB92729813 - D12DDA7583B3AB92312A9D60768854A988EBA0A78C2059E074A108B6E852D491 - D1B9EC8227ACE22C2CCD9181266A88E89F184504E29709F1FD21745353D7494A - 7537F39B0812B05C12C54CDDB0A0791E1E05E12482C3521FF86EEDE7F7F40F6B - 4D913CECC73CCD4133102CC89A0A435CB84602AC9CE26B6B033EDB8863BE3583 - 12BAC9E23DA920932C01984F808D9D292123A01D8E7C4F9EE8DA1B54CB54CA79 - 587094842FF29722109F569B244D230A969BF58F4C8DCFFB6B1B4F667A9FA3D5 - 3572A438325231A4A0363CC87CDBB23D19A4963D12A1482A5032D730A94C6E46 - 5DDDF15C865A9994028D9B3BC6D8403709BEAD059288963EB012B5A912929249 - 616F368A4F47FA095D41C0A372970752D93E6967FE70363520BAA599AD67709B - 6E63F3EFDF03675320F42560DEE417DDF7F394A91213EE8CB77085D049A84290 - 5030AC69D67171617EB01A5BBA2BF65AA41504CB5759D2C1F15EC52D9826C1B3 - 574738969C534A77598EFDDDBC22649988EB215F2821B4E4467DD17C4FBE3D15 - 9BCD6DAA1512C39C00FF007B2FAC039712FF0028711A8856B127AC9E23DAA261 - 81446494F808A4F59AD28A4A418A7CE0B1270DCA7082560EBF9B8189F2D52EA0 - CA98B0A509AB1357A624FEF685AD6B5395174ABA1DD60DE314FB6A4D6FF47957 - 4AB5A3D629502517231118BADBFF002C6C3AC452FA25412CA938952ED7D1A2BA - A012AC9CAA2BB0AD06FEE9F08999E1897D6074702362ECC44B4A67CC4622B4A5 - 771D5C4317DE14DC3F6B4066B6F85F9FA409801CF48E70B62C64019E1EB36B87 - B59C0ED8504562A58C6B96B4A93CD15580E90E89ECF787E78DABB0C28FAC5320 - CB983FAD0325FE795BD4758A5D954B5D4E79D9CB973BE0575BE59C57EC93498E - CAC2951014475802589E22FF00AC285E07DA3E18D80A09DAB444903F1A5DDFB6 - 00B77BF71198E537CA257593C47B52A69484F601E112EBA7CA5266D2CD54A9E8 - 7C2416627ACDFDD855F128972B254A27E226F0A7E8B7C4045157AE968EAE9497 - 44DCC6FD721147E9154229A5D29056940E821F210BDA536697E658E84A842AA6 - 7281709639DE26F5FE714A9C6A4A37CD478C534B12E4CB1FF0D1FE511312C4C2 - 4744F1FB085A8BF65FED0A521AC3A5097BEE84965248D140FC883056A9A19E29 - 9489466239A4E322C62BA499F4AB51969703E79C5649C3315662F9777CE0C6BD - F14C52274B2B514212B415293D60310CA284BD1D1AA5AB9C92AA7410B25D47A3 - AC18784E908EB0E23C7DA469C390C33A44332A124F381B3684499AB4BBB76C7A - BCC17C795F4831B293CE55C91F9842BA28969F85291F2105506265DBBFED1CD8 - CCC2D48482F9421528DE13390984A90BE944B54B62951C6FEEEEECFB456EC7A3 - AD4BA65044C62EAE197808DA541EA13D72F163BE27EF21BFED86700C4B1D2EE8 - F473FD8F45FF00E697F683A437221371C47B48C877724C72B4274F3FA4160B61 - DF0BEB1E07C0C6065B9B5D2071E62DF5FAC291365C9A613141415225361EFCFC - EE8C2B2081130E15618F4625F3D578C8B0F3DD13E62425B1A6C1A11504A8A429 - 2477429640B973A42EA5495241162FF689B5400241E93583C3D5CF5151043757 - 7342672E50216A1DBC23D7710C29BC489DEEC20E1BC499BD34F68DFDD1E96493 - CFC958198BB0ED57EB1282D419B22B6E3668F46B63256135B5D2C9283D04B58B - 1198D6366CF13E98E0484225E14848B7641CD3C390C20AAD6DDE3ED24D870108 - BA83AACD7F0896B2BA85DDD21396815727835A19862D4C2B3B67BF5B868593CE - 4B9414E56136C527448904F47F13A24E2DC72D6364CB556ED19B44AEA4896C94 - FC424912D412F95FF13BF0EE895B0259521225B38C8B377F646D5D8B5B4F3EA9 - 7CDFE048595A9691D208FCADA708F4766190B9C904BE1710535F52F8716F7730 - 8D9BB44A9D151817F0151D37DF58A7A5AE968C35252B38894A93AD92C93DF7EF - 85531CE7CB0141D801A41A395327270FC4E47608F532A2508B0FD33856C40B75 - 2C05339E2D76EF856CFA5A6E9629283F0CC6B44BA1512F8A5ABF85A5FF0095E1 - 52E6237B26D99395B89E3AE7120B907CE663D25A654EA34AD03A4824E2D5A361 - 6CF44F33674E09C34EB96A6500CB279C74F6BE1BFD63654F95311532F0250AE6 - D66521980296603B18131B0BFF00AF37506A1452AFF86B4E2923FC0EAE3DB061 - CF2249717D47B43DDE0215D176DD14E8C017BD4B24F6D84359A2CE0F7FC8889A - B96AA94302E81318FF00D5C5F37B8FDA29AAE653D5AAA65A942680B0540DC898 - D8DF4B90E2D637CCC23D2ADA09CE74CB5B24E5F2F3BE28BD259D5155225CF658 - 9F33D5958908638FAA48C2C5B7FD6367D28A7DBD3A9163A2544376379ED8E769 - A85079D9A65B9607038FE1B8BEE7CE2A76E53A0CC972A44DE74CBC685E04AF24 - 82F86C43E7D2277800346CBDB1EB011CE22A4998E4FE089894DDBFDD24603D17 - E91B06EC808064BDD4159624DC36631300731603A3ABBC00AF5CC1926E72D5C7 - D19E29932E585A97A0D33DC08E04827B1E2A558E9662255489735616844F5499 - 8AC2A52484D93D0B120BB77C566C5A854F2B9FB51133FE8D40FA255F68A1D9F2 - 2952E2A2AD4AD30B87EE07ED1327A39A4A50EE1090715D44801F13DF11D7B5E2 - 9B13F644E9699B29685074996BB6F514908F9298DA114C29A9EB0A9625A64D72 - 912C92C1469D08212F99C6A9AADFF411B2A72A7CF4CF6524CC0B4CC090D2F094 - 91D13BCDB716D63652132E8E5048674A02FF008D08293FA6E82FA4618F79BCE7 - 09CC711ED22E444CD3BA127914972901EF682FCE1B0B3F1B9784B8562DF17DFD - D095A9250A4965209524FE6D0F11A4502A6CCDA145B4943F0EBC209537F50B36 - 29997B3E9E4414A2662973D226252A2C9501663DD136595B34892B4A4614A972 - C294DBAF66D32C80892272073680108C44E048C290ECE401ADB3BE97804A653A - 892A6F794A57893F48C38A763D41EE844D52540BB79EDDFF00CA2A16A6E8CC58 - 0A1FD5E2694E77A736DE32689AA50EB4B96BFE14BFDE39DF85D3C1FEF08483D2 - 2497BDFB6F080127B213D209E3F6FDE26ECF4295CDA93CE6126624CDBA02D572 - B56152138CD807072844D974FD7C2942713B06E900E1BDD39365946CC257454E - BD26E39DDBF885DB85ADE319468728D5E139A788F6A924AE72B080D677CFE968 - A9499730CB39A59FE40FDE1102159A38FDA1CF38A277B47DE32EDE4F472A25CC - D9689665F38A9751816B7FECAF2CE0C26F35D874BA1F9F285CB057B9C93DBF6D - F0538430565D9FBC20B1BDE0ADD246F1F2F3F68945E6AAD95BEB01218151C235 - B3F0D77C55E032D576E81BEBD53A4098A4964CC6ED21FE8E204C4A8B0F1FDA25 - 65968DF28C7D9125C273F789FA0B37779D7D24DA2AA05D32D5225D473AA98909 - 98A5A529C212A7E82863E07E71B2ABEB76F6D2A5A498B4CA91326213CD499679 - B424FBD84ADCB0DEA19C499625224CA4864CB97CC81FF2CB63FEFE6DA6F3C990 - 801E139A788F1F6A86A0D3B9CDC59B3C9AEEDF48A852E7554C24A42884ACBBE4 - CDBBF2F07298486B6E1E2C7EEDC6042ACC771EF8C3D22FA97838ACC6DE7B0C0E - D878F47369AA9AAA5D214FE1D654CB21BDD32B2C5933F662EF89AAC4AED24F0E - EF221C855FB32E1DD0A6B36E7F1852B3BE432E314D325F3A41500545C039E7FB - C2662103130381ACBC8B96EDC9DE368991512D3CD029205D998F60BFE99C2A95 - 245B3DD08A632D761080C966BC2AC13BFF0078A6538E1FA47A694EF474750C30 - 2272C7E6E9A2D6666B7C51FD1DD2739B6254C203264CC507D1496009EF3A6905 - B1B8EAD8FCC31FAFD21C11947CE06E84A4829E23C7DA94F98BFD3C616959AB5A - D990650482E3AC4859B3BFBA2EC05FB2067E75B9F9124774085E51AF2DA29E67 - 37532A6A4FF5381438955FC889253365CA98938B1210ADDD600EA071CA178428 - 924016FA01F7FDA25CD96B517506167B989802669505383C74FE7FA41A5C55A2 - A39C0900658C0D5272246E854E9641C6B02C1B3C278ADB08DFD250736172206D - 14CB584896541C74824A80BE654014803524B0CC9689F598558A5DE61C907A2F - C0AB083DC6246D4055D21FF6AFFF001896D3658988BBA428E9D600E4A6DF1308 - E71B8784492065A8FD63D2497CEEC59A19CCB295E967206ADBE3FA3CD9864C99 - B5B31187AF2E5A894DDC025802559EAC0401643E78595C5FCE501A1A309C4ED6 - 7EC8490E388F6A4650AEB1E3F6102042F28D6045B4F18C3A4754288EB61430D4 - B1BDB5EDB5846C7A8E729A9EE18CA94905C3157363A20EAAEC178DA844D3CD25 - 452433AB42E01CF2D7E714B4782503CEF473528A983DB5C859A11453266332E6 - 2542CEC41DECCCFF004EC856C95E27698FA93296B4F7324B5F5D038D6266CA9C - A6E693354AD344661DD2AE8F55D9F566BB44DA1912918955D48152C81325F3E9 - 510AFEC969925452A575425B11C92926C65D3C89B37D5E87FD6D6538A7282932 - 68E40FF8D52A266CB037B2445452C9912F0250E7E201FEA3F58A598A4CBC2159 - 000DF260DDCDF4D614A755AF7D2FE6D1257D248CFF0058AD91EB7413E4A41519 - A25259231104CC4E897DDA450D3CBA3A5A690818304AC0A06CA5ADC7BA6E4E9C - 6039511AA7AC3E13B95B8F18CA1CC3F61F942334F11E3ED49C8F7F842BACAF3A - 08107483941CE1373091D28F7FBE0F5879D23D15ABE7254DA25938E5FE2CB3BA - 59F7BFBA7A11540A996AB12CFD86CE3BA367D4733CD8641E974C2C3A70587D8C - 6D3D83535B8AA762818E625E72094A545407E1FAA951641BCDE75B3FC37CA174 - 9E9ED220CA97236C258D9A4AE7050BD84C4A70AD26C700CDB17BA63FF4CFA79B - 5954F36A115124A0B8F5EAA914630A412A3CD965A3A20D8E67A21B14527A0B81 - 4A9DB5B6B8654D973BD5E882E6635CB505F3666CDE89C446179770FD18A81494 - 294516CD4A29253E232A48E70A95FDB4E51E94F987E207027268A956286C12C1 - 4E6A009E24424E101F32FE314A8720F6FE9156572286A27CA239D93255390921 - 0B04CA18DCCA98C95B36F0D151E9AFA4F54512C6D5AAA696B49382984BA6080B - CC912B13B8B26FD668F41BD29995E8FF0046D74D9936AE583EAF51315316BA94 - 20625A5648C2572C0C449BB467CA8EB0E23DA444D17F9780F3F384DBE51A42B2 - 30323E77C4BD7CEB07ED127A7365A55047FAD265F3679B33CB9EE8A5A9FF0047 - D689B2C34B4ACA783168A59926B25A67A0F5D2FF002B421B114FBC16E3E42287 - 6BAE930A56A5A0698756CDF838F998ADDBB4EB49526A27CB5D9CA2CAC3770FB8 - 962DD822B6B515180FAE55CCFCAA6292D7B8ECEB0ED6308AD9B325E042428331 - 2AEB01BF88F1848575950B85870DD91225AD396B121225A712BAC49F930FDE27 - F4E96B1D785069A63FCADF785A30CD998541482B5371C59C52D44FA59F2EA699 - 7CDCF92A0B96BDCA07C0E47B1E3D1DDB9236E6CD955125425CF0305653EA99C8 - 031848FEC88E9CB3F01C198819461EC8466388F6A56BE74855CC08D20C1CED00 - 3081977420DC29D8DEFAEBAC73B50162FABBBEBBF7BF6C28953E2D492468E4B9 - FAC6C7DB6BD9B35089EA98BA55D8F4D479A73EE02593A9B35CC499F4D3B0CC94 - A4A82EF2D56C587F32B3C4EFABE508E6D600535BB05FF937D62752C959E9616C - EE036EFBC2E5C8961E526505272381219FA2741A1312821C28F3618825827211 - 36A909EDE261730AFAA1B844B486E97D610B486F0D3E5FA718E702F092F65325 - 2323DAADE076DB38F4A76F9932D7B268549E794099F39070912ED89216963AE4 - F0CCCCD81AC7DE277AB79CF383D555DBA259B7E91E8A6DD9FB13694A9DD134B5 - 089722A50A2E9C38AEA527AA4A2EA048706FDB0898898996A94714B5E29885EF - 4298CBBEA0DC8E1C890E53C465C7DA49C396E8E91F2212FAC13610F78673BA31 - 5F0EFE4106F9BC089870CB513DD1B176B4DA35CB429D72A629DBE15164E6CEC0 - 2459DB56B989754A50410B170FEEEBA65A7F38A9AB5A51A9BB7D1512E72A64B5 - 8BB966EE20FDA39E9C85328921EC2C3C2254C54C377D60CEC23A1D6F3BED099A - 4E7ADCF13C225E1CC5B7DCC6D5DB52F66C9510419F3105082C0E1771D52E927B - 4A6264D54E5A9530952F115295912557D1ADD9976465DFE72C87740316188B94 - 820E23D8431B696DDDD78D83FD20D66CF912A96BA965D65348972E4D3992AF57 - 9A9972834B0A54C713308CCF5D5AA8E714BFD246C99EAC1514B5145BE628A67C - BEF08C0A1DD8E3676D3D9FB41226D156D34F4D9F0CC9683F299392BFFB0FB4D6 - 19E5D9FA40CA042838103331F38003C16E4006AFC953FD501BCFDE25A7A09B9B - 061D9DB1B0AA6A9737D55044C2CE82B25ECF6CC023BA153AA50C99F46754AD41 - DB1E81373EE851BBC05B164499892AF887446BB81FAEEED8099EBFF772FE4AFF - 00CA24D39CD41B85BC5E112827A572772AE3C20A921CD9F36D22A2B514D29736 - 69094B13D1B5F2C399B96B718ADAB9959379C5B61FF769BD90E48C4EA3D3B972 - 1ACD6DE6D7DF00F2151B861E7BE016D13DEEA63BC05123E8606F21D5F1F4B177 - 5F0A7FB894C4B38158D365E931CE2FF103ED7BA3BBC21E13785160235848BE7C - 8DDB186087D6044E4A96948032D612E80018A59E6454C89E92A0A97312404AB0 - BA5FA6E58E568A69D2AA24CB9D6C3342577388380DB87C46F134CA7660DC3B20 - 197760C1A0AD2323F485D4066C3F5FDA27D4A10852C9C210EFDDBB7C6D3DA5EB - B30A10FEAE0860FD650480559599408D5F3B3C0BC2A05A1E1FEB0D02006F698E - 1058B5BC39110B36162203BBE12D0905E1B95C6E868058B185BBC10F61659EA9 - 3901EF3EBB9ADBE3D16AEE7E8954C544AE9CE24E57960E15017CDD693B981BEF - 252A3770DBF73663B1EDBDE2611EE90DAF6EFF00A42D405E2A2A5325254B2C3F - CDC3C88AFDA336A964394A12A525237A52583B387667D338C4E726E1979FBC08 - 569C99186CA008118BDA4D47E1251CD8B2121F7B067FBC2F376607CF8C24B178 - 455E1052652564B5F77F382B2A2FF4F3E78C056F8710E21C431851B40737F945 - B5852496C3DB1B2AAD7B3AB25AD27A2AE82F82949727E50A5B9B754CB4E03F12 - 090A7E2E38FCE26288D6274E025E22580DF1B42B955842524F368BA4DC3F7791 - 0C33399B9E3006ECA1D8C3BC0E410E21DE0DBDA4F553C078410E238C22FCAD0C - 391C43B93B9E38403037C1E92C0DFAEED5FE8236655AA7D0A1EEBA73849DE9EA - 8F1F2F0545DF717F946D62B5532F096E1C8D020C0E4105B7F226CD19E7F5F693 - D54F01E1C852610087E510AFB184E907D8130C27531E8ECDC46649F8DD81D708 - 2B3C5825F80BF64F5CB94933164096332E2E075803BD9ED15FB4B9C4AE5D3870 - F6C5E6FCA7381C86041CC7FF00085D85B48E7239CF378E738FD631BB46696805 - AD0AD613A461EC83CA9E4953D725626CB514AD0E52416CC149BEE209046A9244 - 545754D49C53265CF4548169784D8912F20B6F78646F07907B472E4EAFB69E43 - C8207DBEF03AC3BFC2179F74274EFF00BC1F3F48D7BE3F68107EE7915A777DA3 - 4EF99E02341DF1AFCFC613D61FC31FBF22A041EB726BF3856B08CBBFD8FFC400 - 4811000103020303090506040305090000000100021103210412314151610510 - 1322327181A1F02091B1C1D10623425262E1147282F13392B224435373A21516 - 303563B3C3D2D3FFDA0008010201013F01E6761E897389A6649249E24AE8680F - F74574387DD978234B0C35EB2C985FCAB261B63106D1D8D83F0595BE82C8DE0A - 1BEBFB733690A951A46CED37F3EEF24F805D9ADF946E1BBDF2534D3BCF08F345 - FBB459C1374E2DCAE8D60C6CBC5AFB2FB762ADC8386C4D635DCE6F4875FBE72C - 47D9DA1FC3163A8D5A76FC0FFF00F5958BFB355D8D3530958566B75A5521B51B - 1F803AC1D96225B63122C5721D17D3C6D01529BA93C625B998EBB8751DA9E221 - C3810B94FF00F37C6FFCDFFE362C776DBFD5F25A294744EFAA6EC4743DC50F64 - F316B4EAD07BC02B233F2B7DC116B7F2B7DC135AD9EC8F7050370F7281B87BB9 - A06E1EE46CBA4248C92D2DD1CD395C3B88BF9A9A77355CE73E75712E27BCBA49 - DABEE0F640E320796EE2831BC0DBD59399C164236FBBFBA6C8BDE77CDFDE8520 - D103F65568D0AE4B6AB01224071682446E24582ADC894D952862A8805E1F99C4 - 34667112D6E6204986F5413A36068B94DAF6729625D558417563B356C003BF4F - 75B62C7B9BD20CBC75D9A68A5123D053EAE9DCC743DC50F64FB31CC79A4A7532 - E020EC129FD4B36C77EBF141BF9BAC7D6E41A3721D5D11D54A109DD4ECFD7E29 - D2402770D8377726BDC2F3C741B2C3646CFAAE5AE4AA78EA6FAB49AD6626C5B5 - 25C43CC996B8125ADE04341F25CAF45F4714693DB95CC1D60759B4F81D9C1658 - 450D53A10D88E87B8AFDFD93ED9E69854EA03213CFE11A6C275FA264C5F7FD13 - 444A7181CD75A26E6E053E43475760532C16837B78AFCCD37CDB0E9B63C45D7D - B1E467BA9B3946882EA8C25B58BA082C311A0065A018BF78474E13653CC42692 - 9CE371C0AFDFD92A6FA29E0BC103CE53BAA25129BD5BC4CF185FAB4E1AE9C507 - 34A6B827191BBD78299B2062DE128095A180E9E31FBACF574CD986E8FDD199BE - A8EF58EC3BB1785AD433435F4DD9AD9A360701224F0912B94B095F93B16EC3D7 - 6E5CA4E53F9C1B8781DDA893AEA8EBCD28593B69E050F64C5CC85D253172F017 - F158690DE940274BEA56666931DEBA5A41C1A6A3412607155B94B0342B1C3D4C - 4536D56C4B677A18EC29B0AAD3DC754DAAC78EA994F70214231036F720D93C14 - 34680C7AE2B3B364FAF14FAECD01B833EEF1EE4CACD3E87D53483081DE80817D - 5496DC2926E754544C1FCA418DE3682BED8726D1AF44E35A2F421BD6ED1A6419 - D241707445F4DBB11ED1034474E77687B8FC10F66B400EBED2B1B51D261F698D - 7430B0DC9C2A369D5ACF70CA73B76CE9B93C3ABD2AFD14F4949931D99006C275 - D3417E0B03CACEAFCBB4306E74B8553D43234F25F69F1557FEF46261C5AD63DA - C807E4B01565ADB9ECEB75C9AE379748D9EBC536489D8A4013B1748C01CF26C2 - 75903E0B13CAF95CE149D26DB0EE1BC2772BE21C6E366F471F54E9B75F927D7A - EED1C41EF54F175A8B866792758BC697BE93171C6DB960ABB2B52654CE351336 - 83FAA74F1559C1B4E46B1A6D8DF1AC71D1748C7685079D398ADEB97A99A9C998 - A004F527DCAA08A8FF0077B910611E67CF915FBFB3883DBEF3F12B11530F870E - C4627AB4A9B9BD2077E327B31FE9EF1EFC3BD956853A8C6C31CD058DFD274F8A - 6B58C1980EF1BE41B2ADC915307F6EF0B8A635C285679A9FA4123B3BA572FE11 - F89FB518BA8D692D15360F3F9AC1E1B286F705861932DF6854FB0AA59A46D5CA - 18E2D6BA9B6DAB67BAC849BCCDF5F150A141404F699C018D371F037EE0A95476 - 18BD80E7A6F6BB3C1B17C1CA4700627B9613950E6C955E1C47F86E71FF00A6AF - E9DCB118E7E1EB40BB275D8B0D8E6D588209201D77840E6BA3CDCAAD73B01880 - 0127A3758772AD6A8EFE63E4B35B98277C8FC17EFECD4A41D3DE9D84A35699A7 - 5A9B5D4CBA08317819C13E253000CA795B95A1A200D80181DCA764F1588C2D3A - D89A58B23AD44FC8858CE42A0EAEEC486C3AB75A553C03582E3B29B4DADD8A9F - 65620C07BB734AC6D6CD51FB7AEEF89549DD51E3F14DBC2609941BC116844083 - DCB264766557A47F69D2B0158D3AAD6F87C9507C8D7673D69E89F0039D91F941 - D09CA572966662AAB3241355E6A5B43368F60E87B8AFDFD928EAA9765FDC87CC - AFC2E554CD1603C0FB954C4B3341BC6C431148D832E6C9AB1872D2ABFCA55413 - 51E6357B8F99541B74D6FC5346AAFB1369BCA7D272349E9D4DED4F1518E0F6AC - 2F2A626996E69CBFBAC357FE2180F1F903F340C8237277D7E0BED008E54C45BF - 11474E73D93DC57EFECBB6F77C970D8A4745946F27C87D16C1C16C7777CC2A95 - 1CCA6C6E406CF9B0D33FAF92A2F654AD8BCAD7362A99CDF24D2D045F6854EEDB - 7BD72B3A199778286173389CAE3249DBB5330ED68BB0A6D26ECB26D19D153C36 - 630EB017F309BD0B1994C1D13E936A1195A50C19557081BB556A7123C3E4AAB4 - C8E0B90AA660F1C7E410B5CF158FC6CE6A349D0F363DCB97F0EFA58B617B81CC - 098DA9DB79F63BBBEABF7F648B9BAACE3470F88AC0672CA151CD6C6D8863B507 - B71241B366EA931EC6D3CF98CE1D8E25D725FD60F3FE691FD3087D57E13DD6EF - 9552A4D361CD01A1CF27F4FF00891FD43A8371702B1D887E0E8D0C51D31E2ABD - D3A50A8C21CC1DC58EE84EFA8D2FDAAAF2EBC13F78DDBF0D755C95CAF87AF4A8 - 035A935CF606712FDFDE572A303C31D3B7E698EA14DAD9CB6006CEE4EE50E4E6 - 487819BBBDDE50AAE2F08E334F4DFC6FE5099896C9CAF3C44C7AE2BF89EAFCE7 - D7A09D8D6B0E6378FECBFEDAC469469372FE271D8DDA4F70BA663B16F19B2547 - 0FFD390AAF283FF131DE6BF88CE6F69B8FA2C49CBA1DD7F05C85896D2AE5AED1 - FA03A4FA01728E2EAD26B59444B9D9A780EAA736A33134AA54EB0AA7A327582E - 07BF423DEBED290EC5537ED14E9B63739CC2F71F08828F39D0F715FBFB42932B - 7DDD412CA87A37004B65860C7560EA267C36AC4C0AD5036C348DC00D07AD649B - 93CC34F11F34DCC194E466B5205BBC7450F1EF589E480F2D6D6C4F4B8505C686 - 13A21349CF398E7ABDB734490333B86E4EFB2F80A8731A54FDEEFAAABF676861 - E974B4DAD68A4ECCC026C7DF7F158AAC4E018F1FE203D63B23BB44D3FC6598E8 - 3B4CAA7C88F34CD5AAF6B98D7B5B16FC5C7558AE4A6522431CD190005B9DA24C - 669EB5F4205AD629D22A65CB94B4D88734E6FF002EE8DBBEDB54FF00B3DEE75F - 23F5559F503D8583313363A1B1B7ADAB06407B1F5A9110F667A02B53EB343813 - 209CC4113617D82EB0D8DA794369614B1BC23E2562F18E78B61F0B3FCCA1F51E - 5CF00758986E82FA08D40F455664858771A759AE060836F71553107F8BC3CCB8 - 3B0ECCD0DB0353579DD111F258CA5D11E8F28B3DB55AFCC5D9B71826DAECB2E5 - 9717E36A875F2416F026C74E1A7922147310329EE5FBFB2E80A90900EE39BC76 - 2AB7A8E3BEE798687C3E2AA5368E8082E12D93A7D138D23F89DA5ECDEB77CB67 - DD09A29668330377AF7AAACA591C2E43B61885880D0CAF861DA6B4933B05F458 - 72FA125B37B8F56F564CC5BC8CA6B54826489B4ECD8AA39955D9EA75DD96333B - 5B4D935A3F89765102469E288193BD54A4DA8234CBA458EBBD50A2C2497D263D - C3FDE16CD48E0ED8775A414D14C7FC56F73DC9D45D33F2108DB60F5E29FD6047 - C11EABA771F84FD53314F75DA60F46CA640639D2D68396E349933E10853AB529 - 97439EFD8EA8746CCE502D03DE572B107946BE5BC06877F370475E6CA9D607BB - DAC4D56D26C93A988D3EAB0C73D063C0B19FF511F24E17279B5B6F855FB3486E - 62A6D999F7A7318D121F33C3F742931ECBD4F2FDD72CD1E8F1B54B6AE5765BF5 - 2735B4ED5BCD35DA48F09D3C935AD378F0F246222238A601D269B45F7EBC13AC - C95D37588037DE7C772C33DC1E3AB3D61F1EE44753388EE8F9FAF927B5C04A70 - 9927D1596E4CF8782ADDAF5BEEB923054F15D237A4A94F280E3908BEB675BE07 - 7EF5CA14E9F26E06B621A5CF7369FE3744CDB583DFA70555E6A577B89BB9C5EE - 3AE69F846FDA9DCEEB83DC87B38BA1D365122C64CEE541D87A583A34DA731C95 - 0CB72916A867F166D5DF9761E12ED5DDE799BA855EFD17742148B29198B8B44C - F9808E1EA905D6883693F45D155CB6F9AE58C19A945D5CC74AD17378F0B2698B - 9DB7408D89C2C9996788D7F6FDF827B1E69E60D2469E53DD0853A85F2045CF6B - B8EBAAA199925C4784F7C5E1371074BAA957A89EEDBE3FB20FCD9B2F9A7D9F7D - ABECED48C5D7A676B078F697DB1AFD1F26F46DB17C0E1B4EF9D9B94CBA7788F1 - 0883C39CE87B8AFDFD97EA7F5372F7480151C28A34A97DE1740AE743AD4AA1C0 - 6724BCDA449DD73BDFABB8C91726DE37E66EAAB19E8C0D47ADA9FD2E411F16DB - CD1FE232F54CDAF7FAA6BABE55543AAE1AA0733B4C765F01E5E4557965578D21 - EE1E7A2A7B1550ED80FA94C68206690E1B329F8C70F52BA73D0F46046D060DED - 1BB8A6D170971F746FF5B553C2B5E1C74B14DC2FAB2AD867319D583FD4CFFECA - A0CD9A35048777837E06378B1D8A98CAD9DF37F2595C5E330D5DC34B715C92EE - 8F955B2603A9BDBBEF2D8D257DB3C6E77370C0DDB78BEE3B74DBBD4767CF9A14 - 2A8065B6E5FBFB2EED0F5B911F70C3C0FF00A8A3CCDED37BD55D5A51A8E80034 - 99D802E9DC1AE218E8D260E507BE210C53F2FE1F5C153C5B880D7068191C0E6B - 7C7D68B94E9457792226A3CC47EA26DEF5866ED3EAFF00546B1CD95ADD3645CF - 18D638EFF14E7D611F765BDED227C90AAFD0E56F7C04DAB17796651A891BADE7 - 08D4A9D62CA6F8BE8C711B76C29A9F8A69DE3AFD4BEC07345F86BC174AD79825 - D1E4AA06B418133E6A3A9BB5F8A23AED813173C3E8995452C60766021AF32480 - 26DB4AE52AF57178AA955D99DD62D1627E12B64ECDFB3D8A9D9F0FAA1EC95D63 - 4DA07AEB14E046BB44F3304B8275DC070F82A8E2D2DCBAFAF92354123FE1E8E1 - C4FEE9C187B28B69EEF25CB787FBF0E8B1263DF3F354A5B6DD3F34E243F38D96 - FAFC532A0A85BD23A234F1FEC9AFC10307ACE8DBE08E2B06CEC8B8D32893EEEE - BF75D57C4E7EC536F7B8E570E200D48D637A7567D6B4EA0D5FF2D935A9CECCEC - BBADEEB2ABD591BBFBA69B39CA816E231EDA5504B09CA5BBE48DBEB72A3F6579 - 02865A8EE4EC33DF973BCD72FAA2F1D9602329248BEE96AFB5BF67A9E11E71F8 - 16B6961DE5A2B5065A9D12E30C807F31461B63AECE66B93F4F02BF7F65DB561C - F511339BC79A9F6C2776DBE7DCB1218DCBD17F57CFD5D39B4FA50D1FE196DFBE - 3EBDCAA65633AA8D360C3B5CD588A031545F4DDA9EB37D7AE2ABB1ECAAD6BFF0 - 98F3FA2AA5B94FADC866B74659C43F6EE8F3F2541F5A60E1A9981ACF11F554EA - D616E869B4FE62781FDC2AD673CBEA9133D56F65DFA7B8E89CF8ECA6B913049E - 253C0A864E9FD962B1047DD51B98BFBC8F92C0F5319463B4E7F5FDE227CD5271 - 34A903F902AF4A9D7A3528D5134AAB4B1E37B5C2085CB7C915B9231D5683FF00 - C32ECD4EB6CA945D39698FE4D14337F31D0F7143D97265818F5AADFE3CCDED04 - E3D609D120693AECD554A4C6D66D30E969124F1F7A7340744C8DDAA761A19D57 - 9CBF967ABFE598F25A1EEB2C6F273714D2E680D78BE66801C4F7813E6557A352 - 907676F64C69AFEA3BF6A7120CC69A7054715523AA5DDD27DE9952A54B3B3771 - 27BF7F8AC43AA09686EB23C8AA74DEED6DCC5AE71D480276EAAA986E51AF9A70 - 2CCC76BED9B6B62E20EA249D8BECDF22D4C4D518CC43603740E121DAF58876BA - 0BAE03B22C1188BC8DD1ACEC85F687916872CE072800622835CEA6ECA33C8BC0 - 3AF5B6C1BA734B5F503DA19518EEB3223290632C6837C42246E4743DC50F6613 - 22E13A2F1CCDD565CCE0155A105B7F5EBD6C4DC3926336DF57D53E9F46FD651A - 7558DEDCB77437E9F34753DEB0D4CD4786ECDDFDBEAB94F00DAC2A7546667575 - 777EC3ADF6EBE17AF850D9639B975DF7F79D9F3584A0C61B3A7ABA788F5E28BB - 2556DAD79FF294594AA364360C6F3AFBD3A9468BA3CA7ADA7ADAAA38090DB0BF - 1F8CFAF14F8024892572772554E51AF71F72D83505C6702F1985C7F4906EA952 - 65263594DB929B5B95AD1368D6E4927C49510206F950AF3235DE45BDC2172C7D - 87C3632AD4C461311FC0E22BBFA4ACEAC4D6A4F7FE9A6D32C9DC328E0B13F60F - 94A9B3EE71187C43BF4E6A5FFB9982C672763F024B31185A835EB963C8EFEA45 - 90F666E858CEF4EF921AA6274E611AA7B6A9B9D9A45BE653456A77CA7C7F64FE - 91DD623E8BF88A9963A3EAF71F5E4BC97270FF006800E8584F8895547DF3CDEE - 493BB77BBEBAAE52C3D10C154B6DD7CE6D6D2367A84DA7877B7352AED6DF4312 - 8B1BA9AB4CC6C6EBBB7959E8B7F1BBDE23E1F0557123F0F9AA959EEEADA384CF - C55EDE7BD50C33F155994A9025D3B74FAAC1615985A591B21DF8CDBB50018B0E - AEE17EF51B3728442201B112375FE441F34D60F0DD6B78C66F792881FDE0FC93 - DAD7769AD77F331A4F98F686A799DF2410B1089CAE053B104C5B2C719F904EC5 - 666E5B77FA846BB0B72E51DF2BA7674796D28DC92B04F14EB7484F65A446F9E3 - B3DC9C733DC7F51588A7D3D17D23A16993AC7C3558AA270F88AAD198758D8122 - DBFE1F254F3878BBB6DCF71598ED28772C97999F054D8EA8453634B9EF758016 - 8DF3DDB217277268C13017106B6A5D9632DC90353368DC8FF7E277ACCB32D565 - 5308DFDB9B9E677C934710A620EC4F70744156DEA02025419E0A165394458ED3 - EF434B7A2AF078C6BE2BED2E0FA3AA310C80D363AC924131A7E94D7BACE6C94C - BB492D3316F04D6AA1877D4A829B7AC4EED1BDEB93F93DB83A521AD7567412F2 - 0C09B98912A23F7D78F9CC70479C294EFDD0BACBC3DA340E7738543771746E93 - 29A604137088CC13B0F26CF2D2BA38B1766459C56450506AD9298D9D74D89D03 - ABB9411665C6A7BFD041A4919EC20C2C761462F09569BC75DA73B3C1AE1AFF00 - 52A743A273D8E1763B4F25961BA6A08546839E435AD92745C9BC9CDC234B9ED1 - D2BFB5798F113E4B2C782308B516A82A0A82A093C1342807DA2B6A09C6CB8EDE - 71CD126362FD20585815082245913736906C780DFE4B9470CDA58A2E160F93DF - 6F45340320F70E2B92CB4629A1E10D512A513CE74574D0B6C0B95A779D9ED1E6 - 08F39D13762726B7D9D87DCB96E9F51B53F2C7FD4E0DF0D6CA8B0D580D049302 - D789582E4FE8DECA8EDD7E73AF3822F3B910759B6E410D11EAF5B6EE42E336EF - 5FDFDA850B2ACA88B2636C8B6EA13966E3CC34E729F866566965412D3123C411 - E60154703470A65B4C09DB1A2EAFA9E63CEEE61AA1AAD2EA27AFEBE28E9FF845 - 37E88E89BF24FF005E48687D6E5B3DC869CC3E9CC3D7BC2ABD81FCAE5B4F31E6 - 28A08E899A8EF4FF00C3E3F05F80FF00CB5F88787C4FB1FFC4004F1000020102 - 0305030806060901050900000102030411001221051322314151617110143242 - 8191B1F02023526272A1061533C1D1E124304353738292A2B2073463B3C2F125 - 35445474A3A4D2E2FFDA0008010100063F02F24681DB86345E67905031E949EF - 3FFA639C9EFC7F698FED7DFF00FF0058D4BFFAB1A93FEAC75F79C7F3F2D36CAD - 9D48D5DB4368CD1D3D1D3C594CD24CED658E3B90013CD8B3050A0B3B2A0BE2A7 - 6757D14D495B4731A7AA8265CA6198287C8CD7DD9BC6CB229562AF1B2488CD1B - AB9DE4B3A89AE32A8BB01AEBD3C2F6BE1DD4E604DEE3B3C39DB0AD27A04DAF72 - 06BEDB6BD3052195C36878643A7BBADFB3B311C0922AA449915418124E801937 - F47521B3DEEA1756D755C19A56855A60B94CEAA8834F5DA1318B74FD981F0C08 - 36941E6ADC96A51B7D4525F915940B8BF7E9E188B779195DD0E6537074E8C342 - 3F7E98A807FBE97FE7894FDFFDD8EBE4BDF4C5C31C76E0788FA43C07939E3D2C - 733EF38E67DFF46C31055453CB4F530BACB04D0B14923914E851908756EF50DD - E0A360CFB41AAAAAB266DF4B533643248DAE7CF24F2BADDAF636CB75195D4DF4 - 3929D7293A0CE845C35F54B7D58D6CAF0B96500F57CCAB28BC2D9B72533EF11A - 4D7779866DE22DC840CA05EE6E5794B68C696B30FBDD6DC29C20F2B8BE2E54DE - FDA7FF00D89C34492D646244B148D63AA53C4328DCCC73B72E1CBC4CCE020163 - 9E27825A5DA9155476464A6929DE291778B96396030CE244394E4AB8619267E0 - 10346A65C7D7320859B2E43983B359AEAB2106D2A9D489F808F45D893882795A - 4AFD88CC9E710C4BFD328E3BB5E710370B2C0BAC8699D859247758A3532E3CF6 - 8A649A0A866923955D5B32C873A1BA923552A45890C2C4137C49F8CE063973C6 - 51A6A7E38CBCC1EBD98B69DF803BC7C7E90F01FD4D8620AA9784D410D1A65CCD - 1C6F97732140D9DCC9E985456BA34590333C9E6CF1C4BBD9F51BD20660D6BE40 - ED9E3193D26E14637214EAB20E295A57B7A59EEA2FEA8372580FB5A66E6974CA - CE486F70EDBFB3DE3B70D1E6B06B02BAF2FE3CFDE71C4BEDED03BF417B0F13DE - 4E1784EBD159873F10FCBBB01B7AA248E42DBAAA4969E5E25CA6188A554B14AA - 8406125E966B3B5C5565CA9FFB2261BC59048B4F26E9999726731EF847179DC9 - 97D342AB69C4F24376A96941DA4B4E8166C8B5305CDA4B24684C2B99B332CB69 - B7EB965A6764124686DBC8B69D1BBC91B001240D631D445942A48AB709511598 - 266C82A5544C99CC73449BAA84229A663BC8D4F02487D29A05B928588CCF0DEC - C5988E79B02A15B3248EC51D7911A5BE4FC71DA2FA616F816EA71CF4ECC73F66 - 17C47D21E1FD4A1600A67035D158E86D99B840B6A737081CF4C34ACAB3D44ACD - 0D2A71E79A43BB45215644DDC0A8377146A22448C4B9D86EEE4AAD38A7829E9D - 523DEE669E5792CD2D44CDBB5FAD9E57DFB7ECA3C8F1A41F519035EE0FBCDB53 - A7A4D6FF0051C5BA30FBBAFB89FCB51E4E286EB20B02F7B684162962BC5EA1CD - 9C056E59AC7017F637CB737BF336B88C6ED980EAB1076163C0FCB0B4F513C555 - 4ACEAAB5D42D39A75B9F4DA29E922AC5E1B96866A582A2C2F90D8C6CD4B4F2C0 - E532D424B4EF14EA55B2E49A32804A2039904B61F54FF555514754AB4D8A46DA - 74AEE28F2D23ED0862CB99721969E9EB40CD179D531DFAC32092582B693EA229 - 1C53CD1C4B35146F048F185AFE22E8F3EF34A860C380CA0C6730DD966CD19DE9 - CCF26626FDB6FDDCF9F33EFC4BB02B26204EFBDA066D6D20FDA407AFD601BC8C - F6875EAB61DF800F418BE6D3170DA769C5C1C2F75BE3F48787F5006028FE44F8 - 7B31E722369AB978A17DE345E6EF981DEEF51D644BDB2B98D849BB73BB68E648 - EA2200BBBB3E7E10A4DC6B648D2103228BB121515156FEAD931CFD9D96F0D0FC - F4B1C5B11F0DACBE9746BF6F6116B76DB9E39B7F9731F781F36C08B74F3290D6 - F375DEB067D339A667166E5FB19E0BD85EF9729952ABCDA58DAD12C55F0D5415 - 50F264969EBA97202E81B7924153BF8E40A37F4554129CB29A73BC5428F0D56C - DA8859E1CF94C322CF04B2C7C57FA9929EAE65794AA87DE7062344AC9EA234DE - 4516FDCA33A1733346DBF2DC0B25E430485A359EED1E66CED872AAD0CC6F9E20 - 39F09DE8C96D436B742387D971EA9BF675D74C5257C1FB5A59925B36ABC26E56 - D7B104020E29368D1B868A45E25F5A2947A70C83A3A1E7DA2C468705B90B63F3 - E58207438161D9817ED1F1FA434C70C6E7D98BEE24EDF47A63D038BA44EC0732 - 05C604F1D1CCD11E4E0698D69DC62D2295F1C13DD858E35CCEE728EDD4FCF51E - 38D9FB3E3A5CCF5519ABAD9E528BBE1999C04257790D053884455754ADAB8A91 - 1BC42438F30D9743251C2EA629EAE0465ACADD32901E532BC74E480FBA589642 - 0B23902CAA1A38EA82FAED51AF1FAD66DDA2E5ECBEA3D624F115568A492F6D63 - E97EA0D883E16D741A1E6A06E5110B4B90F14AFA017213D6D19594B59583F61B - 2E659A03F76F70C3B2C57FE571F885B1115920DE2BA08DF770D2D56F5DD0461E - B84314D2C8E4A6E8D4D4C8A11594BC113313B8DA4F92A4A189A68E14A7926DDA - 15A6924D1A11508DF5323451D33843F5EF26F649F1FD3292685E501A9EA02C94 - F9F855B7F4EC02C5517564CFA7144EB206CD32B9E39A537B3659540570C4CA8C - E847186CFBD52411F58590AE6D6EC329BE843126DD16E75B0E97E2173C479E3A - FB75FCF1D8DF3F1EB83B1A450D4D5E7347A8FABA98E3F759D16DD38801E3EEC0 - D2FCF0CDAFB0E34BE9CEF81A751F1FA496EEFDD8170A3D831550468AC1C6E95A - C387B72F79EDF773C53A4A51F7991997D2B2BFDAEFF1C354C50A6465CDE88B1D - 35C531FB485CF75EFA618779C5C7E5E385F9D79FC9C455D3C22A771AC748FAA5 - 4CB63BB8E5BDC345BCB3488EAE9222E491191DC62A238D8CF5B59BB8AA2A0C26 - 5967443085829865731411EE6386921CB1D3D3D24490A8CA72015156ED4ABC21 - 69E50951294205EF6CB1A37AA138D97AC84A8C21964A89081A23B1DC275CDB95 - C888FA1E25011EFAC4BA0C2B84FAC560C2CAAB1DED661A01746D0E4CB919B35D - 006CB82E94908916CB1EE0A460A264CC8C1D35CF663AB70DAC2CB752CB3ECA96 - 1322155757862841B1D5665DE344C786489A4CFF005C8038904CC30ED25C4F4E - E53366C909A67668AF51ABE416646955CBD30A694ABC8409515053CBBC795D95 - E9EAC79BD453B41B9DD7D6477A2943A284A7576A9963B115015A3A392A569089 - 1596D712831659329259951CC41E22CEAB2A46BE710B5DE28DDDB0049662A4F1 - 1D5B9B31BB1D4DD98939AE6FCEEA00C69CBB3E40F9EDE78F7E2E71412194A2EF - D15EDA12A5941047CDFD6C0E2B8207B716C10074EFC6BCEFF9601EF1F1FA4A4F - 62FC06051512869E557B6A142AAADDD998D800075C4B1BFA7148C8D6D7890D8E - B8CC492D7E7D74C08AE3CEA9C1420EBE883CEFDDDB8A68C9E228491A73386F13 - 86FCB1AEBAFF002C1D2FC3921E7659242AA5CDB9D94B65D742437318A590C579 - 5F74CF265B1CECC8353CC8D4E55D72FB30BA5F5ECC036E761F9E2FD98E5D79F7 - 9B8FDF87465E57B761B00D7B1F68B72D313566CD410D7D2DAA52555073EEF387 - 474F4648A485E5464906564629D96976CEC58A655A31BEDAFB1B52F416D1EB28 - 7D2924D9C198839496A3613C7511412AD4C34737F4B99EBE9633956E8AD0E562 - 489222099212A1B895A26DE1B00D91CE0ACF111672A1B2928C3D564956F1C8AC - 2D6E21272CF1A1397C9617CF9805ECD7F3B836B74B330C294D6E8A48EC7B59BB - B53C5D9AD8682C285DADFF006B841F02C35F7DB1111FDDAFBFF8E34E98607D96 - C0EFBE3BF32FFC87D25B760F8603C32B4521565CCA6CD95B422E3B461989B937 - 249E649E64F92A612CCAB32FAA3D6B587C6C711A4B1964CBC0735B87A7E58F40 - EBF787F1C5B27E63F8E1BED5FF002EBEDC411F32D3A7FA6F8A7CABC7B95E5D0F - 03291F85ADDBA6BAD8DE3E9A72F9F9BE3517B63963ECC7AEBDFDDE18EDFE63BE - F8CA78895B58F2D47A3D74C6F0411EF16C165B5A4CAA32A8CCB6F5380FDA5003 - 75BC9B4F65C71D0BCDACD1C51AEE4B736312D83439F892458CEE6452B786EA77 - 932344F244D0BABAD95F2A316BB730E0C66EEAC8926BC82DF36274664056E57F - EF4AF80608F6D72B65935F475392CD71C4351D003A9B73F01A74BE0F5D4F7698 - 88972833A92C0D8ADBA83D0F7E28A5DEEF8353C4778350FC235F6FAD7EB83CB9 - 74D717BDF17B78635FB4BFF21F497D9E469B2B6EFF00679ADC398F4CDCAF6E9E - 4F9EDC51488A774E00B8ED112DFE381C605D411E975FCB17DE7E67F8E0976D2E - 476F2C40145F2B03FEEBF2C402DEA20FF68C770183A74C711ECC698245F5D7E7 - B390F6EBD717BF3E9F275C1C65E87E7F9FB71722C7B45AFF009DFC2C430F1C4C - CF06EE52AE5268C056BEBCF565397C2D6E56E8F0925A3CC7293D35B053E23504 - 0D4106D63E4B0D7C3E4786366F080053275BFA22DE1FBC72270C7B702D8E4799 - E4700763AFC7E95FBBF8601E87DF8A3D9D2D398A1ABA87AE495975945C22953D - 9C045C731987A37F20F11F118D83B45E6A698D5B55D2F9965324E81A9786531C - C1A0B69E9C604803A1BE6B5A039AEAD0A9FC23A03E1CB0473C588CE01E5722E7 - 5E76D6DDA0653DF895C800A32F6F2B7CFF003C46924A99870E5BEBA0FDD6B777 - 6036C0E24170A6D997372D34BF5B697D49E5842B22BABF2286E1BBBF8FE76B1C - 700BDC5F43817F44733D39F6FC474C642573EA331FDC7D55BF5D09C3A5456AEF - 06BBB8F8DBC4F2CA33680300CDC9012080E29A9AADD95CA8CCB113985AE32ACA - 5AD72002DA3310109E2CA52A61521FD045169D08F559239A6B9D18E8AD63656C - A49CBBBDD491C83D10F94175EB78D25778B4F565B31E6233865E7726DF69791E - 204291DF6F1D70B6163FD9917BBAF451D3422CA09B11617BBE32D89C878B5CBA - 5EDCF5CA7F1781E58A7DAFB46178764AB3180B0506B9A2207D521BE68849A192 - C138582E720E5F358386378B788B6032DDD91940500001A33D3AE0F5F21EFC73 - F587C7E90EF03E18D8DB0E291629B6BED5D9DB2A191FD08E5DA3590D1C6EDDCA - F2A9FE78FD0EFD1BFD1B8A0857647E89C7156C703A337055CD4744F58C9A3D79 - 8E8A5352CC04AD7479471A7917F12FC71FF4ED9D29055D5D63BB6685D2A8D334 - 53D98CBA8786CAA45E3D332EECE8DBCFFA7FB77662C77DA14B4F4FB619E39967 - AAABDA54236BD3D4DA6B340B0AC3594C6131A36EC53F02CA272DE80F62E2A9D2 - 326189F3161EAAB6A3DD7009C6D229E988E2CBD4DDB7A390D79E5BF86251B89E - 7DE5C09117772477EA0AC6DEC19CBFDC0B7BEF291DE27D1B7A6ACEB96EC9A02A - 7303BB3AAA712A91637C04DAE9215121977824661998FD61B5EE1CDCC85A2D0C - 994C91E53266531CB7B8B5C1F0BF5F9BE0FA22E09BEA6FECE9DE7D9865DFB47C - 24DEE326834E13753C5662185AC0AB5D4D81A8DA3552C8F2B92F964D65274BAA - 913492C9934CDC4FAFD5EEAEE58E5D985CAEAD3CE58735BB2FD7CB18B9576CF1 - E504EBA76304A6681641AFD5FA6B6CB7BC6C78140B12D7047A46D6C2B53BAE6D - 151A1B462D6D07D5119C5ADA1EED791C5A47CD75CD720A9BF7F165EEE42FCF0F - 5053388FD2B730BC8653639483EB81A0B8E204C6C73C3256CAB5714468E99D23 - 9AA91A2DF79C4AF22388299088D2B9DC69BE410113BAB6362410D8C1471434AD - 91422B7D5A8B841AA8775E598D835B33DB362B69547FEEEA5A28656EDA89A235 - 935BBAF3AF872E871981181827BB0ADF7C0FA547F7E9607FF544A7F7E36657C5 - 2490C945B428AAE296125648A4A6A88E78DE37162922BC60AB83743661CB1B5B - 6CD44D5133D54E486A9977B22A0F453380A32AF450155792A85B7913F1AFFC86 - 3FE9927E8FCE249E9F663CB596A18A91A093774263576440D5326F3CED59CDFF - 0066245BF9C313FA09FA23B1B684F5BB3F63ECFA7A8AA9EB688415AF5D153C94 - B047BD4AE9A296969696A1A9E08FCD29E584476796A830906F12780006C43BE4 - 6E9D0E36426D95A49F6649B42963AF472851E079550E71EB2F102C3AA838DAFB - 24848E17ABA85544F4238D99E58A351F7032A0D74E56BE1A3AADCC5701E19255 - 3A826C4A655FAD0B7D42F174D3149B565D995F36CBAC91929EA564828D2A0AF1 - 5E389D65AA58C85932B4F1C4582678CB0BE2A69E9299E9C51C6924B2A6D6D935 - D4AE1F28BC73564D43E712233956860653C0E39A39C412433B4F493CA6DF572C - 4532DED749466B388D805E7C99599594847F5B28B9EEB6B8A68958A43212646B - E5D337A17B1D5B976F2D35C4622863F360E9BEB5729AF9029B98C65A79453A1E - 15326576B191A31139063DA759B121A3A3D9F57454D179A560ABAD9A94D379BE - 76A5AAF3490EF26309769E4992A2447A849572B138A2A392A65D9D514AAEB36D - 1A095A0AAAECF2C92059E366A8A678E2BAA45BE85E40AAB665D6351BC9EA2AB2 - E825A97059CF32C72850B76BF2007776961CCF5C4F1B0D4C641240B7B74ECEEE - 98FD20863A5529FAD25877C10993CDE30606CCE4DAD4F3C37551FDFB272C9878 - D994491323A2DF898A10C02F6DEC3BB1B6E7FEF6B882475DD41142397608C639 - F33D0E17BF0DE18D4F261F1FA5463ECD0518FF00F1E3C5C73BDC7B35C331E658 - DFC91FE35FF90C6C013B668922E57D5574E11FC3A6118545499825963223B2B7 - D9BF65F15A2BEA24A7B545A1DD056B8B75F9EDC34DB36BA49AA6E3859426EECD - A3061D6FF0C7E8EEDF9E26DC6DCA71BAA8B1C8F574D39A7AC42DFDE678E4603D - 2DD5B9DB102CB04733C251D73ADF87436EDD4761188E0AB81E4A75CADE6B5153 - 34B4CAC2EA185348CD106552C14E5BA86396D7C2C54B490C314688AAB1C62288 - 64B2A68B619422AC7A7AB6ECE2855B55F3A823893D10A0CAA247F1711951D72F - 79B954F56D61EEEB878E640EA412A3C703790AB91D6E77A9AE8035FA7C9C658A - 796253EA33230F0E34BDFF00862F24AD201AF2197FDBA62C3A7C70C1BA8C3C2D - D4107BFA62B521A99165A9DA35D2C93C49F58F1D44E6A103B1CE5644DEB21950 - A93AB686C4556D7ACAC748E963CEE93CAD267B68A8A5EF26776B08D431BB91C3 - 6E495F28224AF967AA2B7BDB7F2B3A8BDB5B290A0F60C5B5F0C017D2FEDC3635 - FB7F4A345E94B4E3FD3047841605F2C8C48E9DDFCF07C7C91FE35F8E28D469BB - 817A9E7F2716AA7DDC7601A4D58AFDEB5F0D251ED1158CC1B34790A15163C5CF - C30924DB560A36E6D14A1C93DF7BEB88B6524915736C4DA152F0CE1336426A05 - 707566E24B198A5D7D2E57B36153282B957FF4C5F74BE27418005828BDEDF1E9 - 8A64E82A636F62007E36C2F873C14275C5C6B7ECECECC0E11AF3E1CB6D7B8378 - E35D3DFF00BF1E382353CF0E3A643EFD711D2ECC836654D257894E4AE86A1DE1 - 9A2CAAD223D3D553DC3F0DD5AFE8E845ED88576CD76742E8128618DA0A185646 - D4C34F98E67B5C09E669A60A720932800411A8CAB122A0D3EC8B7E585EBDB81D - 57B797917F17D22D6D4C10807B2F1A0FDF8D9D553D14F1BD751D43C129528938 - DFBC5BD466FDA461E378F32E99D585F3291E587FC44F8E29D47AD1A8F8624AC3 - 54BC69198C27A599B92916B7B7363CE04D115DD176025B1C96CDCB1E751ACC69 - 63BDE550C516DCFDD6C7EAC9E1153B33F48E44A50F9C2BD3546758C4A2E35537 - B489A5C6A1837A4BE18D2C3969F3DB825AD6E4301C7A19EC83F09C8DEF643CB0 - A40240035C70165BF55E7ADB9F873EDC5453CEFBC8F76B246CDCD4E7C96F03C2 - D626E38B5C5C81DDF36C73E7F3CB17E830E795AE07CFB0E0C9F74EBE071B2AA1 - 394525525BB73393A72B9E1E58DEB268B19605C1E4BA023B3B7DB809D87976F9 - 35B60F8617C47C7E929EC48BFDA8BF3F9E3F41BF45E4D8B47B3C7E88ECB868FC - F6294C92D5B41454FB386EA110431D153C91D24734B4E9BD569373631AD2A87F - 241FE2A7FCB14CB15DA421557F15F4C474F2C4FE6CB92DF5472F09D38B97B707 - 308DA3DC91A327A197F10E9DD8929C475090C8AD9D024994DF9E96E58A546A3F - A8A5A88AA11CC4732B472093367CBDA35EEC538162B2C2B203D6C56FEF1F1C0D - E3AA0FBC40EBA0F1B63461AE805AC4DB5EE3CBA629679D904425CAD203E8EF2F - 94BEB6011ACC5B35BAB009738DC968B230DE06D0B1D3A35F9708D30650E63899 - 8D92255799F95B331E1894762DDDB84875F44BCD9A4925E799CDAEA3390BD56C - 35B8B92DCFC3249ECD2FC8F31E3F231BBCB9FA819ECF6EA403607BB5E5869232 - 74E16537BA35F553CF5B75BFB70FD97F81E9EF1EFC3B765FF2FE3859D0912535 - 70CAD7B595A62ADFED637B6B6B8D6F6C546D17F4252C919F68CC05F5B0D3B796 - 8716D74F2B76DB0B7D3887C7E97B17FE031148AD9AD102FF0076E6DF1F2C3FE2 - 2FC7092ABD9E30AC83D6B86B8B63737A9952C2EBC4DA0EED34B8C1A7928C2A08 - F26F374411D05CF6F8E326F9ED90A7AA787DA3E6F8F34CDC194AFECD39303D6D - 8D91599B96E924E5E84D6049FC135E3B76E23A988E65DDA955274BDCE6FF00C8 - 33760B5F5371FACDA5A407D032691DC5C68EA5938869CD4E115F68C125CA9FDA - 20E2FCBB7DF88F71B599236D0410D4A14CA74CAB7CE45C35B246553519579E24 - F3CDA29BBE22AB23091D9FD5501107BF88F3C65A0D97B42A73234A1BCDB71118 - 54714A93563D3C2D1F40C8F63C9416363BC8F65C54CF2E414CB5150AF55333E6 - E1DC25C048C00F2BB542E45923E6CD971BFDB532D4D54995F2C4BB9A78B99648 - A2CC58AEB60D50647BF37B1B0D39B12DA77F2EFE5F0BE14F56B9D3BF5FE186F0 - F9F0E2B0FF0030ED18A8840CD9A5423C77D1DADEEFCF14B4F1A0511C6B7B76DB - 53ED3D7C8735C7663966C1E57B1D303C47EEFA5FE51FF0189332E6BC361C4C32 - 9CC35B02072B8D6FCFCB4E0F2DEAE3B42DF9F863678A16787240A954541177CD - C5E3FC7102A3B7EAC26113A9CC33D87D612BCF5C40D4E079A1ACE0BFF759B406 - FD3C70952B434C6B322AE930CC01D2E621606D8DA5B19D8288A69776A3FF0096 - A8626EBFE0CF9997ECB3260D2D4303534E376D7EACB6B3AF607D0E2446512155 - 6D39E65B5B4E9F9621157B369AB68D269AEFB88DE6DCCF7DFC538CA44EAA6E69 - DC2ABA979B3B98D93734F2BC7474F9610AF1ACD53459244296695229200588BD - DE4CCEE38A4C54C7494E259499944D0412D4CAE8EC5900AE96E72B008546FF00 - 762CA74B5F0B16CAD99E670F9A3D3EF2AD409C2BEED62DC470CA517200746793 - 392BC29BB60E6B6B8B4B390A164998BBD97B49F547AA328B666CC0966BF70C2C - 284E488F10B9E7CCFCF6DB0072B651CBB85F5EDD39FB3AE162049663CBC2FF00 - 90BFBED8AC912C25585A58AE2F678AEEA48EC397023FD7153027D9A52B4A2DE3 - 0AA31F6938FD4FB567326D18573D2D44A6F25542ABC68EDA679A21720B6AF15C - 9B98CDF97518B5B058E42FC5C2BA0FBA0B7877614B68C72FF3FA5FE44FF8AE2A - 16C0E686DAF4E2BF969FFC4186FF0037FC71B37F564B2346F045E7F9FD49EE37 - B94F4F5BBAD88A8D2AB2ECC62B9EA2F7CB74D788F7E97C47045219205A991639 - 41F4E3CDA35FBF10ED48A4A84A899D21DDEFC642C746E1D5F41D79620AF8CB6E - D1DA3A85075929DCD9FC596C245FBEA3BEF4FB468E51224888E721D1D38581E7 - CFA8FBDA61655F45E342B9755B7E2D390B61CAE81DAE05865BF4EEEDE9D7B70A - 92450B2A9F5AC58F67AA6DD9E9619121A7E3CE173C2732A8248CBD99336A48E2 - BDFBC160335EE4102C82D6B8B7CDC0EEC698638627D26D59AFAEBAE9F37D7C30 - CA08BF6733AF43DE35F0C356540611DEFA8E63A20EEFB44778E78A98F4DDAD3C - A3A5AD90ADEDD962C3BC5F1322C8B2A248CAAEBC98063622E07FEBECBC1574CE - 639E9E4596275E6AE86E3F98EA34E588EBA3B095488AAE01AEE2A00D47F86DE9 - 444F35D2E595EDCB07C3118E86DF91FA56ED8623FF00DB438EBCBE47960FC789 - 0DF5CFCF1434D0546659529C4F2B65B4524994372B68B7EB81B1E3DA119A72EA - 3CF742B6299EE7A69CB9E1E9B7DBC104C614901E1215AD9877606D35DA8CCA21 - 59774E8E14661D0DED9BBEDCBAF9169EA19A4D9B23EA399A72C7565ED8FAB274 - 3C49AE60EB145324B4F57109A0606E09B02F623C735BB4DF198D88B8ECD7BEDF - 3CB165B66BDCE5EDEBF3ECC13AE9D4DCFC6FD7F3D7ADF1907BBC7E7D82C3B31C - FB41EFFE38299B5BDCF4D17E75FCF1BB8CDDB4D01F8F75FBF9F78C79EED0568A - 1BE658082AEDCF59336B1ADC7A24676FB96D443100B1AA65B28B5FB0787E7CB1 - 27E8CECC706AD947EB49D187F4588FA34684729E64D673FD942447ABC8DBAF22 - 4AC58D0D4E486B6306F78C9D2603FBC809CCBD4AE78F40FA0951C3A48A1E375D - 432B282ACA7A8606E08E77BE2FE3E384ECE9EFE7F4A3EFA5A7FF00C14C219137 - 91E6E24B95CEBD56E2C47B083DE39E1CC31EEE2CC7225C9CABD9766727DAC4F7 - F922FC588E96490C4934A559C0B91E03144B156890D64C224DE26EF779880189 - BF7DF153402A917CD48CF522E52EC38796B7E986A12F9DD5C0CF6CA1AE79EB83 - 3CB5E24A258436EB39B85B7A392DD31F1C2D3B9B6F0100FD93D0E23A6A894BD0 - C75275D4EE18315629FF00752AFA6A3935A403439A29A295595E30C1838B10C0 - 1E7A0EDF8F6E2F23A7B1BB83137BEBD74B73074C4650709FB3700EA41F40A96D - 0117E4001A936C2BC0151B40EABC7C44F69516CA973A82DCF9E98E26E22A7283 - D3A6805B4171D7BBB6CD43B22233CC7F6D30B08208DB32EF269BD141A3597591 - 882B123CA0295AADA4DE7D5C2CEA003B988DFF00B3562189BFF692656D01554D - 41B05B723940CA0765FED1F1D319299925DBDB49186CFA7395FCDD3D17DA3529 - ADA184F0C31B7FDA2A2D18531C750D14B513C8F34F3C8F34D2C8D99E49647679 - 1DD8EACCECC5998EAC4DCEBF422A2DA1451D7534091C54ED1B8A69E28A345445 - 2776D1C8AAA00D515F4D5CE37757495B461CDB7B68AA234BDF89C2324B947DC8 - E463F63092505753D4A9B691CAA5C0FBF17ED636FBAEA0FD28C91E8451C7EC44 - 0A3E181DD7F2C7EDC0F36244E64E020DB8AFD310256F9C3926D05DB3711FB1CF - 5F861E711D5D389594BC8CAC73B0F4493DBD97EE3C8E176956C33E7FAB227788 - 8536F4753C3AF8E1A09C48699E3CB7319CA52D6BDC0B79103B65508E491CF45C - 4D94931EF1ECC799E23F9F6E1764D1CE278CA33414F2BE43C36CD146E6CB6CBC - 4A1CE51C4335B4C65DA3B36AE9B91BB691903A09748645B9E68EC3C74C011A15 - B1BE635108EBA83973B5813A72E5CBB48D99492D532D81F338EAAAC29BFA5214 - 40139EA5ECBDB6180FB6EA3CC21278A189A396B5C7D80C9BCA58108E526F2A58 - 72787A85A5A38529A1E7963BBC8EC7D27964625A49185AECF736B2F25C69C23F - 3F9FDD8A9DB7B565C94D4DA2C6A7EBEAEA1C1DCD1D32E99E79C83945C2AA079A - 42B0C723AD6EDBDA2DF5D54FF571024C5494B1F0D35241703EAA9E3B28360D23 - E79E4BCB2C8CDE5CBD4FC31CFBC83616F0E648EFC14541238E679018BDAC79F6 - 7F3F6FD21E1F413DBF0C2D4DB31865CF94F23638A4FE8AB03D33AB8643CEDDD7 - C454490345972EF4E6BEF0AFBEC314FB3F232984202C4DD5B28B5AD6D31FAB96 - 1996414CB18F44A671A5F517B1D4F3F234B35F76B0C834E65996CA3DB8240B6A - 74F1D7F7E292BA2243534E9269D403C6BFE65CC2D8A7ACA6B3E78D5C28EBA5F8 - 181F4B5E46DD96E5819E08738B5F791266E5CF55D7B8E001616E59797CF2E581 - 656FCAC7DFA7E78D5BDDFBFE462AF6BED6AB8E8E868E2CF3CD25EE491648A25F - 4E59A67B253D3C61A599C858D5DCE0359A8B61D13B8D97B32FAA6994D5561439 - 25AE957D222F15347FD1E9EE37B3547D0CC71C0D63CB4ECEB8EFEB8F9D3BBE90 - F0FA03F0B7C30C7EF1F8FD1D1588EDB6333596FD5B9780EDE98074D7958FCEBD - DE49364CCDF5B48DF577D6F0BF127FA7893FCA3B4E0697079597BC1C6B18BE9A - 803F86069A7CF762AF6C6D7AA5A5A0A28B7B348D7B93982C71431E8D2D44D294 - 8608938E4924545D58119A7614BB2A8A67FD5DB26239A2A546E0DF54B7FF0015 - B41E3E19AA1B823BC90D347146640C42D83DEC3ECBF87D973CF2F5BF093ADB91 - 1DC7CB72716E9DDD98B03738BE333E83E3F4963DC41A22AE6CBC5A2817F1C023 - 93790FD442D7ED4E58120015BEE8031CFC8147536C65BBFE2B8F85BF7E39173F - 7BE360319B9F455E40FEECABD717F4B273FBFDC3B16DA0F7E3341678E5041CEA - AE076AD8FA0EBCB30B1FB38D2337EE1F3F1C53CFC4833AC7283A13131B1BEBD3 - 983DD6EA710CF1B0292A02397500DBAF2F1C0B7662B36A6D09B7147414F25554 - 4BCF24512E66396E0B1E8A83D362105C90319698C949B028646FD59487982432 - 35755AA48D1C9B42642CA32BBC743031A7A69242D515358CD2BB1361D8A34F01 - C58BBAE55F5215E6D6F59BA9F0E9DD8BC82C3A393774ECCE4FA69F789CE073CF - A91F9823911DBE45517EFF000E5FC719579FE78F1EBF3D719DBD01ADFED7F2C2 - FF00B476F79EEFA43C30CBEB29B8F0EBE55F9D7C961FE63D98E01C5F69B56FE0 - 07900E43524FDD1A9F9EDC055E434F1B76FCEBCCF3180311CA6F96F6917B50E8 - 74E571CC785B0AEBAA95045BC30248F4923E7CC122FCAFD7BB0291DFEB235575 - 075ED5603F0C8AC2DE1DB803BB1B44C09BC48AB3674D571D8B67A65AA41CBB12 - A1A9E53D823BE846331E016E5CBF2EF279606973EA275BFDA6FDC0F2E7CF96F2 - 5399CFE5DCBFBF1DD8CADC7176754EF5FE1F03CC1F494F26E98BF5F9B60DF527 - 5C5BA0D5BE7BFE7AE0463D11E97F0E5FC7F867B5CE802E99BB95475EFEF39BE9 - 0F018BF94269CEF7B717BF198E89CBDBEFFCF0153D11EFEF27BCF97EFCB7FF00 - 474F6137C76F9563BF08E5DD7E9DFDC3A6B816C6E15F2BA36F952FAC90B9093A - AF6956DD4807451236B86DA7B62BA0A1A4880CF2CCF6CCD6BEEA24D649EA1B5D - DD3C2B24D25B857151B1B61AB6CBFD1E7FAB999C0FD63B5D032F0CF62E296999 - B953539695D2FE713C913BD3C7D4BF4EC4EFEC2DDFD3A12717E6E7A9C6A74F8E - 34F2112DCC4D7B8B5ECD6D08E5F3E18BF6FE58BE3EF31FCFA7CF6E2EDCF4B0F5 - 9DFD541DC7D2EEEDC67948DFF33F62990F4FC47BF5EFFEA396391C72F661E122 - D2840E9EDE63E17C146E63CAB750320CBA7517275FA0A7BB19D39FE47D9882BA - 8DE5A5A882412452268CB2210432F2B8D3505B8BD16BF26159B7368CF572A822 - 357F42056CB78E969621153D32B644CDBB419C80CF99B8B1F56328E599AD9BF2 - 002F801E37C75BF5EBE4D3CBDDD9E4ED55D4E0CAFA2AA963EFD7DBD9E18F3823 - 89895A646F441E6D2B74B20D4F7D946371135D41FAC92FC52BFDA3FB80D07F55 - 1FE2184FC1FC30DEDC1F2FB3CABE1818F763DF8F6E0F8F93DDF41B12FE1FDE70 - 7F1C7FF9F0BFFD037FE2E078FD0FFFC400271001000202010303050101010000 - 00000001112100314151617181A1F02091B1C1E1D110F1FFDA0008010100013F - 21FF0084481001028DF01D3DB246E7B47F9FC37DF06FF666817EBFDCED0F2B22 - D1F553C9BE3D73DC9953EBED8F5F143AFCF1C4C81DFE29E362EA9AC001FAD1CE - 84926437AC0070CAA1C19A2A2361AAA9C4ACDD09124BD06F501B69C770D8F642 - 52CDAB75ADE41C2D0F8808FC1DC94C3BF394118275F4BE98BD514422F5C7B5A4 - 5030749E2A574694E46FEA98415012369272204C352E18471901E3F8C8206D7A - 483F78BA078C604BFD99CD1D079786FB2464AB88C090996956ABA1C77C0842F7 - 7AFE71DFD2C7E73B64F0EB8F0E7417BFFB9DABD4C79BEE324F2FDF3CBDDFF97C - CE1006D898AC02AB679304248C590380260296CC279152576CB12B82A78C4827 - 40395B0384478A623735994259C70A488849345318A2C688CB7390EC40DDB72D - F50C724BBC65FC2062641021809E45802C29CEECE5EC5C6C6073470D4204956D - AC35C0A8F8806CDAF1268A03588B7A333C478C19C2F01C9243E34E498F61EFFE - E020B3F08C840A5056DBFDCB04E622E9CAF5ECE4040F50047B738932CFD0C77F - 4D7E2564E5FBE19CE2E099393860557416B9B0738DC414B4E6B166454019056A - 114C3451A7395D4D24DD11B50B52A9B12128441622884C2F098410A310C3904A - 30432ACAC869C9108567AE5B740B317E1172D6825080814B4A653686253D7210 - B65B299429C702C2315A4B150642265ED862DA229620DB51E19722FD89A7CFC5 - 01002C888BCA9E77733065A8A210A0D13CA26C60B2C323B0269A022ABF6FACE7 - 0504CF5F1F3B6114DDB3C9BA35FDC4812815E9DBC7A6889C243717A75CCFF7D3 - 9C257A7EC7C8C77F4FB07E33DF1FFAFF00D3F386E5DA82B3E005F859629C25DF - AA629080B04A8061357B5688538488958C914F26B66C9023700825CCE30E9708 - 41F25918491433789A71AFC4573F2335CB853B321B0A64880CC77214A876A227 - 28090861A6D802CE9F5394A2C887DBB8F91E16B38CCC6F1E3D29723956738C38 - E5CB215250F20ACC30C8669C97D6362026D646006012B56BE9308422649A88E1 - 1BBBDF8C8743B13C6FC74FDE5A26856E24E1FC4996F52D1068EB11850B45841E - 2B54F7C1033687564538EFE9F68FC6158B38673F431BB58FBE2707E1D8455537 - 5373158A92B1CC57CAB0034E38BA3E00C054DF052D531CE80D891233B38593C4 - F69C0B00A98DF5F9EB9B53D108574BD40CD0069C1C47710A2EA03ABB4DAB50A2 - 2610370DC7C2219439D9F38DDBDE766D7C6CB5C5F121ED98857B37329B964121 - 6A1F609734C6C7CCA4C325A52CCC830582848940AA17B750A9D35792F0C2E139 - C01859A78DE6C267678D81AE96C1B896E6A7A7B601250B9744F9E4C83A20109E - 3A7F982344408EEEDD76C9C87FE3C77F4CA2C68CF6496CE584604950774EB78E - F0C5358EF72943CA64CD9E06513A97B3858B172259E7D32FCBD431D37BDE2248 - 821DD99D75D6242206A706AE08E5A09618059E11DA159A4155E31907B323C898 - 076D9CD2A080CE4C8A42A34F389BBEEA8A4E4044B524140C44603C402E868C6A - E606897048264EC6A2A8A30E7DDA282421C2645302837B4AE18C11972E12D5FD - F01046E18AE2C618C9E0B8581D2239080E36A22034D6CD6E994D8607091E7F74 - 35E87AB6EA0F4169F3F87664B323A0D0469C3E56C94A18095784BF6EC7CE9814 - 585821DBBBBF5C2A4EB68D46CF9C62A6E4097C7EF0820E91F0C77F4900E37312 - 6A0B40EBF1FBE4A97D8684E9823A484E56C41C30B680929A88B0DBCC62381823 - 0AFA3937D725F21088424D24504EAA3206100507FE7EB158C40CC0DCA1ABEA64 - 074280E823EE894F0DE0C815642F70A1A0CCA434D004B2ABC54213C647B8B6F0 - E049957450296F9FA7261AA64E8B38E685E3123EDA127961A09BD0D18FD4A864 - 8E643AA92340AD94A465891AC7189D190CE70D1D2F20CEBF9A6CCC6802259198 - E4215726302A113040ED8B8D2E1903C64E847519F3EA58454C2A24251CC2036C - 0B1F61F7EF923154A87A6EBE6B0024C8D13012467BC08C24CA41998410BBD96E - 244581757BEB890330DABD00ACB94EA05ED4BB4ED9A23C3CC0C77F490BD0C7DC - C73FCCDBF791F55751982321CC98501905A6CDCBD726940BB3A2217515F6F38F - 1489A84D1496B44B3CCE42B8C0D01D4506E088E98A62ECDE40352FFAAC78948D - D0B0F0E0AC82450267909C44160244648B222EB26599E00CD12C143C8C925049 - FB95AEE7DB26249102CCD63D2D13A4AE4ECA5DB704ACC7ABF8C482C90A6D30E2 - B3B5DF6C0888DC24A1920A0F6A54E53A39140AE26463AB81D78F27E4E1CFB819 - 87A456EE057C632928C15F2229295909AC5C0CF13CCFB53FE66B16C483296453 - 4D72A19CE53AE980325B4D8841D4301A00E046883C40553E1C5E50F96044C569 - 7C4CE278A0EC99FBE684C3E66019ED063046E8386237E27DFC60584C0FF0F1DF - D249541A9E077FD62EB65744B2818E0D3CC9593D8E59320F2155DAFB5604CE3F - 5ECE449059BB0BA8824C2B94BC83767AB986FAF3961E01E1E43EC78E7248336C - BD2BF1C50F684705BEE4F5E35CE4AC68FD6199E6D8D254F391B1662111526486 - 0AB5C98189EA15A1C56AF9EBD246141A092362C90F821AE5CBF45849D16DFC1E - 308A9A5770D42E084CF9EB5B2205AD1C733084276FBD8C8649332DCB83589747 - 26F35C2BA33A416A3896C60A007A7A1026A18573AD226D0809A08512BB1710C5 - CDC8111B070C653211CA02548B1B63B64614392EE8C4C7255331CBBDAC5461B4 - B18C28F6429BD437861006E881A293B24AA520AC75CF817D3DF2677B8E66EB59 - 5402E4EFBEBD3224A5C783BFA421FF00C119641C56455AA26B9BE2526EF5C930 - 4C39B3F0C3A80D012ADD55F61D09A4CDCB5BB24A7A49C5ED188E2D7C17BFD3F9 - D520727931255FAE3C495C4D30BF83133DF559ACE22351021A863D3594A384BD - E78F39088425BBF9AC922CF09882A110DD953C79C4A1F1AF3C9FE77DD5ED6490 - E9A26BB2A382A75692B2BB078628EA3BE99A073F3C63447076FC4D91C384D4B1 - F2E18AC1629225D94BC4AC444AA2B2672E210DF1177347D4907681561088481C - AF70C0C543E19E3C648203231262C89783CBAA561820701D83A6CEF5CC314011 - CAFD371FAC100AC2D6EE6CF8E048922CF076C4C143427836D18EFE9A1E83EF81 - C976C45D375FDEBCC0C7559935C1675A20670E232243AE335E631882322B285A - CB961D1012CDF390109AA8ED31E688BB0ABEF31FF98B076D1A941022B909A0D2 - 40FADDAD7B2CEFF660E43B8816F4180B6E4D949404B2210DA299D832020240C3 - 04F0E4C8DDB615C6922C80923038185991DC5EBDE0249910770D05F349D14ADC - 0AE11286300BC8D25A7320317A4E508974C94B6A39FF001A60CA634156333212 - 42B8214A4340E09E05C2CD9D724D5AC4A4598334EE9731A6A64190D036EC64C4 - 30CB537712C88B411165F5AA64C702021BDC1BC258B8E50F5E701DB4CACF7064 - 6174F37BC01D4E41164EA788FF007783204B6EBE7CEB813B107BE26193F6F4C7 - 7F484922A77191ED97D8D0C092E59009620298BEB192D1A849399CD3ED81AE6C - AB711E0BFEFA63317126C9E6AC848733017D148B9F5C780E616150AD80961371 - 4F1E93964D74AC3442D21C204998CD8A6550014995000D5A0188818F205125F1 - 24659260E504E6BA0C7400B04D5BD80D8703039193E42E654B1A095A22C97543 - 61E8048857247655EEA21382A466D55D24D980D962E55519C158C2D6D01E0082 - 7776506F10C3D0A8C25D0E7A0DA98A5FF043980100398024101056022299B4D6 - 42DDC15C951B0825C86BC92E19C12F7502992D06E6302103747228425D291967 - 4C85A1660403DDEBAB74D6104F5363B90188EBD5C504A2C6CE375921E228F7B9 - C028374A965ADC63BFA625476398FF00B6111DD52E8401C16C1C005F4B8C219D - 2FD0019B2F09C3602CC4D13DA77A92A4D84BCCDF656841A04CC3AA792EDECF62 - D4B31B231429005844665EFE9185ADFDA728D2D8A1325864BC0CE62069443811 - 3642044228AEC1B190A706C39095558E50B8C335C0C354CF2B6C2C1901D2B66B - 07F148CE4F10EAAD1AA6EECEA0C54B1BC02AEAD5A5789A43D46234BAA7330232 - D980D24E5BC6820FCDFEDC1349DD98A6C042132F14D4D9D1FC05BA13A5000CAA - 10027BAA37211C7DFBE0BC9946110C1522EC50C1893343E408FA28BD16B33641 - D49A8453760783A7088B7BAA01910236C2F4651ABE4156F039133EEA5AD7F726 - ED22F06FEF8812443268818EFE9E8AFA940E7F5EC98E98FECA8BBACFEF0D60C3 - 013A3795940E89425343580758EC0207D8DC253C63701123113190788869E580 - 9D249A0541D09BE98E616A2CADD4E148AC6806228208322A78128CCD2358A430 - 4D381BE5E2966380DF022838762824DB31C16564084C8BD99609985C357E15DA - 08FB3B418894111321224B07135A751234140280890070AAA630D7509D6B6226 - 3A8845400D82E628BEEE69821E661BBFD4658B324C2DC569F9CE012D5D12CC69 - DF6EFAC2803EAB129728B062064CCD128B8955214B06838331B6410890483060 - 494327A8AFEE054DD1C87A47DA5F6AC7699810395663F17ED841C233D604D63B - FA43596CB8093155075C4929B7081DDAD7E19F23AC7FB86B11EF97B73AC51096 - 25F114A8D4E4E9461084880948F062DB51472C2C3B9DB8CADD1056A0240E0989 - EF85091709FBAA890477667048974C0148D9133CBC1C16BA22369B920661E1DF - B67126262260B028A3523CCE3385D6A681E8A5E4EF861CBF79FEC7DEB1357B05 - F57F1BF0D738F54BB12CCB6B8EEC911975E842459A323A22ADBBB5CC15D10FDC - F8BE4459D9AECF33F6E23A6084832BF12FAF57F13927D4B3D447D9339BD99A08 - C18245999146D8725CC224DAC00C94554F94AC1D2A47338252C64D0209E81147 - 42F185B52C783517F7C3946B83E7F98E02A2B233A4FCFB463BFA42C128496A52 - 969002DDB582CAF3310405966EE0CC73D3DC37EBED9C1970F94726443EACA3AF - BE5BC589208C99966C97613035664A0298402D7117A8A31E971925D6E3A81B37 - 975D9F0F579D4DAC03170469AE57FD72263C0957DE3CBD72A564A1A41DD5ED4D - 61D2845049332C5D0500D64958052C737BF91DB2248CC0A4017616875691C839 - 4C4EF05B57814C5D204C9C9B53F9986FB8EB152DE5BE79A81A9B8F3B7051DB45 - FA1E97FCC1E20075AB7CCC1E4EF06571EFA53F7CC6F37EC0A4A4D4BA280EE652 - 07082999C27647648129E10671E99A176EEFEE33874FF278ECE088128D7F6B78 - C7580A7F51EFED84892367A3CFC31DFD31F4E1E6796483AD3531050C8361C501 - D04ABBF34F8F78F9F7C359041E7F0322883A6944E1D79C8745720304D03024B0 - 2C26158564E9B991599D12D6E50C5770890D961CDBEFDF289959DAE0F1C06E47 - 6652CD48A08EFA03D30BCCD419454C0BD0839E0B269ABA90D883DE30FF003210 - CDD5641A960504AC00592E20111D645DA9672F94816BBD7245280CE701A3D955 - 72D82700934D3883365034910A369B8B88A5AC9A215D85C8DD42972BCD906141 - 652F812493569C4D7D9736C9E7C9D0530CC7442624756D24B25E39C478B9DF42 - AC1143700A427390900A1522305CCB16A51D81094486D39C5309032BE7CE4257 - 772F5D611CF57BD3E951C6251EE550D44FCE31DFD269C7E2C17020DEAA4F485C - EAFA6523B7C8CE324F97C3DF094DC20AC0D74F4C22A50F39C4B6420114FC6305 - 21C42044E94C1B77E96A9222D803921863DD7193F17916C0B1939DE87A61DF34 - AA83BE110ACAD0E8C961E8884D64D0B280891C3138A7B5EB1E82128AC86E1C7A - 0B8332DA68D9B1742A8460885CB982AF1080A4AC32151700244B2F4A64B8E6D3 - 3E73DC70838210B07AD6286F376F30D4D32B368016CF2CE0C2A4B4603FD50A42 - 346E5C0473C94AA66E84E8920E70C15D2A363333D4D27F29D3D454EBA5B5531D - 3079B20227626A1BC9EF82EFA7AF23DCE4C73349128F1BFD62863652EA3CEBAD - 60290E6E453C6F972C218A3CCE1DFD2F1B03E4AD888A05A006D4E5E27E73FBCF - 8FBE75813FDF02162083482BBE49AC3A6C5C0494F34567080F11E1DE2254B3CA - F6C84BC135121B75826DE706AF6B381494444B1012B562B35B41A7EDB3670DA2 - 31C04A7046EC08F03D2F2372BC8914468B0C368916F1CACC9E5CCEAC48B77AE5 - 45532DAD3122992C1E67F70E48A87EF8CBC84B30642EDD28D8A10F5959B4C628 - D324D72B83907B4ECF9CBD4CD2162010BA0B88A3A8530655C87951C812361E6F - 066AD549995DE5088CC601797E401584A4D24A2EB1B8F5069310EA85CA9B988C - 74C8914E6D034A26E5B216819839E2B59B2C10E8AB83E6F014C61A8361A79320 - EAE55DB80B07877862F1DFD2113E6FBAE132349DE1ABCEBEF835E8FAE4B962F9 - 5E1031DC586E59577F385519A9CC0A4B93C290C85CFD0A9CC429AD7D4E31B517 - 021F31037DEB2CE3642AD082CB240F4C78C728C0D4A382F3D7E0CD7B57A43B5E - 04AB70C5F18176EC8D711C6223A7A84AAF5752E51119124088955E4268122CDC - 272A4689824090D30274031414EB2482D16D5D409240100046A000FE79724189 - 662665520210BB93D715689D9DF63D56A787005928C60369941B542116CADD4C - 29CA741B2B7C96B075D14E5AC21445BB14448717D074A7894226DE43C4B08A7A - 68907DCA8D08A148BCAFA32E91F0F359136280222E6F97DA0C76172AFF003268 - 517B4FF71DFD32FF00D03FB992902158C3126E5D488AD670FF00978FA7F0E47C - 89024CEE3733AFC18825A02A94C08A5DA9C37831C5D10DD5987DF013C5AE42F6 - 10BCBBC0B5B5800B13B842C30D8B6CACFAE01FA124116D99561EE2C28C811B96 - 6A4ED0F209673AF585B94C9A882F965C624602424104298992626ECA692E8A10 - C24090CEC42CBDC8862419C350042DCF1AA235046501F506585A4CD3A129810D - 0DA7B84A4333B5E8BA26CA6106D849B72F3A1B6F242005CE8920A3746C10C8B1 - 3093511041526F68E0E4C87400592A4A1135FC7047CF9D5FBBD70C7D38B811AD - 6D5C986C9C3AE54AEC45853103915472BBFE18ACD842D170B78BFBE3BFA6DF5F - 7B33E44281AE1CDC82A7A06A3EC79B7C8C7AAAEB49B72C7A4BD9BCE44054E029 - CAE0A0465B02AFA2A8E9D721F58036821C10906BB7539E7F3A2200461DCEDEBD - 525EAB9F440512F55D5CE3D65F8FE6318B1F0452ACF11E2EF0A254245AA12C86 - 333CD06221FC80128134219B2103869802618399D80E72C890184206D584CE0F - 379C0655B16A16EC6E166C4C9C2578C10D3B90B1371A385DED75053B488CC2F0 - DAB3AEAA53704E2245CA20C682286201892B652AEF01C5A700568083248B0F64 - 6C090E84494F5FB0E74735BDE07662B7AAEDDFA77C3827589287893335CD9E15 - 21E000CA659C4149C6418C549D2268684D8563BFA6240428E543CA05EFA8CBBE - 4F3F6F7CDFD7FBFBC7587A9B5ECE40D164D0D329EDD70A51E731D0A245888691 - 39118663432723C04642481C9254C6124B897CB9315939803884490ADD9393F5 - 38FBF55E4B40ED858EF188C4E25161B22C253B406D3262EEFB410531445AF015 - 608C80A76D81074ABB31DF21190DE679A058CA8C2B0255861A522AAC60B80BE0 - 0F4C7A0B5832D303B455A10C43C826E2800282CFC5C92E5794267A4303D8C10C - EBAC14C573FE6D5067002A2617D4F83DF0092E7AEED18963692431C06F5BDE18 - 5E43482B5D86E14BF6D3842B28EAADC742DC6A865841F08FE96A3E97D87E0C77 - 9B89D38E3127C7F9F0C4601048AC33C6286D21DA37244C1A4AC3C3B6A98AF6F5 - 021D48425AC9A11204225DE3D4C818666AE210EA04DBED7169A97E5418B45080 - 6112E9544C7DB0ADE225CABDC02FB675FEB71FD949447332438A78C8DA425CC2 - 5BDC8CF2E56328E484935CD035CCC4E034460CB4471D5E4E37162D087730EF49 - 1F75A195249E8203C927C4754E49C8D4DB0C95AA16E18CC8DC293430AB2E0B87 - 5ED95CB67F75918576DFF31C58C73C1F25F7E338A92EE6CD1349D9C6C3CA4112 - F40089E7D32242F35D9D1CC73BFAA3ED1F6CE715FDB111BF958197D1E72E42DA - FDD37F47EB3748521A74D9262485666857544AD84225DC5E6D81B241FD753B4B - 8D60D64C7C38EC6C07229FA78479408D1E0124BCCE92BD7014D2B13B38547898 - 32D088698FD00C8E39B5B8798F44DD4D6186B35028A1CEA44B64243D0287C06C - 82881832140D84239219F4F9E990B93B881983D8BC21444A7AAD6BC6E706A665 - F9D326487897830E3C59CEBA3A6FBFA7D47392DED76164BC4ACEF2A6D90F8A7A - F38D075113CC91AFD5E455580A9975274FC9C2E1813123BD47B6F1694155662D - EEF9C532EF9CE5CF806A7A6A6779D58EAA4D130D412F73D759C6A69640CF03E2 - FAE30D0D358DCBA1E28C43BC665AA97A11BF443C3D4E235AA9458525E034AAA1 - 711CAED13F69A4066A1D6F1DE4D71055A02F31DF0E446B1E11322DBC952990D0 - BE01AC96D3C44C8D2186DE70447EB671501105E05D7C1B085A42D2332E6EDD5B - 850230938944EC245149B155A7283049A759C35B182BA122417804E30EBA3398 - 627D465ED0E6CE99154CED085E523D278C0B821A3D9D4EE97BEB0B8508E84DDE - F4DB4CE2052371CEC71CA6622A583A9F53FB2FC195EE8B170F9FD108F3F9BC02 - 64E41EB0F38B473EBF1DB25C7138170D18D4A22BB8DFE71BB64648B08A8F082C - 9B675FBDE24E3411A097A5164D50C5470518E1C7B2AB8E4305A0B219D6E79F97 - 9670621600273575CACCC28D4C782234D43DF72CE52F50C880A682B16BAF3385 - 3F33E4889FEEFA1A35860C451439DFFEE33A1AAA7A89B54888981C08D76A004E - 8000980425580972E15D27A834851F824530C293EC8B7E09861CAF0E3685391D - 626BB7A646293ADF2B6C758C6D1C23103492576E63F335BC9DE5588D90B08D54 - BC7972651225CC701D75FE628F13C07075975CEA4D052A633098351AB453C9DE - B24DC94F2C65725E4B25154891F4FC674C480D223E113F78D2BD6FC62188C481 - 1C1699EF8FD6246016512B2B0A441CA6EEF5843441E4948E537ED19C3EFEF922 - 65FF000299EF2954545CF35592C4AC9E5EAF488CDAB7FF000B8689D7D4054249 - 90B42A89D227ACB37D4AF4930070542554886127402C45C246D5CFD5A19154C6 - 025B8418CE76E5C4A2B74E35D0FBCE8928907092D9AAEFA9D1D327147AC9F03A - F92E81069FF7181AB44FFCCB2C15848013B6ABB3895F4A4380D9191EF34FC303 - 1C47CC243E06879380AFB06D12EA5AD98812E239C87EA21071364AD247E9500E - 81875139F3BFCCFF00DAFE644224AD0DBE3AB9B077AE6F054A7537C639A3A0F1 - 769D6FC60D7A41386E33569245C0B6E262830AA7CC78B8C3D3EDE71314E0427B - 66D0812E9F22AEDB9E9D4603265F5250A9021C97080421C71C2D26633229A12F - 0929CC401E443A8301525EA3B5FDF2C1F3881022BAEFE6F0A3C616CB9B17C3E7 - 193A528E0F6F43377A6DC4809CF3ADCD4C602288074449775AE839518526ED3B - 01A962F8602A3199AA7A8CA455D8A621993E93FE99F0FD73DE3F39F77FB67BF7 - F39AFF00CCDB3C7CE3A7CB9EC39F89F8CF9FD73F27EF86DC7B37EF367D7F19B6 - 343E75C3E3EF9FDFC39F8DCF7DC7E67AE3E4BA33DE7F27D1FFDA000C03010002 - 00030000001002028416D643B1A559EA97A9000F347CBB638DCEEFD0E81B8800 - 1D1579C5F8A4CA4DB0FD1AA000F24903853C1C8F2383823480039B058DDCFAD0 - 5E509A7F7A000074EAD3E421297D894C0068000A282BA22F7E494364086B2000 - 425C3D500488415F8C4BE68002F80EF9DA2D9251186C98AA000F27074E6EB368 - B09A8864E800063C45AF535E9CB2DE028A2000A9013228F8248CAA733E168000 - 7F99C1230E7E741E53A51200077DAD169F89E9E9267C44C8002175CBF968EC79 - 83595D9710008B36702D0E930B5FB882588002660F14E68E890DCF356FAA0003 - C6D4F868DC874B38DEC2C8003BA710E07C7E363CC212DAA000E49FB08D853767 - 3E7136128001BF4833C6D49976DBEEA961000F8B72E2DACFFE34A44D5F840012 - 69C979C8D0BD966ADAF60000A42514079E92F53020302C00019A1D76AEF2F0E1 - 68A73A98000BB47865B29B805A57086D80003BC04A92CA3B29810F792B0000E4 - B106974925FDE1435D880003EAF6FC02002D89E092114000080CE847D12A568E - 29321F000FFFC400271101010002020102060301010000000000011121310041 - 5161718191A1B1C1F01020D1E1F1FFDA0008010301013F10FE219CF6B830D740 - 346B9A13BF9FBA2B8F1FF380627288DF2F63DE1875786E3B7807834B329D1CBA - E5630DE6ADFAF9ECE69059A727A29BEA75B38C7C7BAFBAEDD3E8B35C66DEE983 - 18DFA7E09E39FF00B673DCF93CAF200E4194F472D7BF2010D0D5C301B6B275A8 - DE134D7061201DE02FA6EF0120E4C7E7E54F438A69ACE2FCD1F4C4B3DD39B503 - 930321AECA53C2B8DCE17DAF4110658B0B9C1DE0E3C62EB0C402929F9DF1BE27 - E0C2A6582D8790CD981C72E3408151CD2F7163451182A65D884CEA649A041D5F - B13A13C6B3E7AECE7D97EEE3C9661CFC7833C3B42F476A0EFDBD0EDE41236CF5 - BA7DCC7FEDE1B3B5A7EFDBEDCC6C6BCFAF7D9893BEF8AA797E1C29E17FAFE8BC - 3862CC3E4C3F173FE797D9E32D4EB2B5EF4B92F737DF1422937154BE73C6D666 - 4930DF7DB85E284523B1547E0F21E0F91C8783E472BE5F9BC27A15CB41DF7EAB - FB9DC299C30620A6B00D1100D0E1191754E074868BADBBBCD89BA12E8DA0ACB3 - C166F9B25CAD28F78C3AF86F727062B2C514751CB0CFBFAD62570252BD325475 - 4CB882EB070041EC682B65051C47CCC3AE0825BB5C6824298C33533EA5243AD8 - C301C96DB186F63887218740037004A8C508A040341252883C8DBC39105B3108 - 20D4850B0A81978F15B3DDF3EBBCE79A9D39C9875E48F3D7B3B767ADFCF2814A - E928B59EA7C73C59426742E6F6FA9F8AAEDE2A2A33A5F4F6BFDBF45E1CAC971F - AFF029A79EB7D0FF0038A70BF43F8329EE73D2FABFEF033FAFAA4E1193A0374E - B31FABADBC0A01426E20A1E0842C2CCDCD2698B24BB9722542010745C2AF1024 - 67AD92F791BFB7825490FAC006CC4EA7D8E71CCB017B9AD24C8824489E354E0E - A45C6FB637EEDFC7850833EA7C9EBD3E5398E01C224EE3A9317D7D78C26F6ED4 - DE59633700068009C40D5C8B091305181912B2BB9659A081C030020E3AB430CA - D589A0302814A44BB46208C2E575EEFE31A1F3501F268C4F87A72D6BEBE3A53F - 7BEB7C435993E3EB835F8BBECE5F73E81EE87D3F49374E0D624FAEA9E7E33FB7 - E8BC3FBEC7B9F7FE006C02E7399DFAC85C9B9D4E280C6087CA5ADD13AD7BF2C6 - 2050CABF7327E78842A95A3792081E34E775E0E1D6DBB8EBE3BEBC23CBA57068 - EF21923F8F49C6D164B546E2BBF7E478FABD6BE5C48CFCDFAC3EC706F6ADA43B - F38BD4A1346786494684CA142A2611C132EC9551A8CC2A380C81DDF3F7E16800 - A60A40DAA09D9E3B81013AD9AD8990D786B8631C46C0FC91853419720903B978 - C4BDD678F5F0E9A7104687A3E6FEA706A18CA79FF78B783AF8EF7C0A16DBD2D3 - FB7E8BC392331E917EDC674DF589F7FE205B6FEF9E13B67C2F12314F889C188F - 86F04AEA33CFF9C01A3F7E3789DA41A80EB1810D81DBD86B934315F0C37A0A97 - 42D0B79D14450C2E4E773771BC62D38CB1DDF5D4F2E32B0AF7AE38A0D523EBB6 - A33DFB9E78C49CAC53B059B1D1BD73181640AC19D4BA2CD7AF5CCF7B753D3DFF - 001CBD1FCD67870EFD03D3BE3102201BDC257173B87B539B920C4258E3BBF1CF - 0020D2673B7350B34193743897209B2849A8B591303434CC2A7438D962A4128A - CC71B81B9F2EE6D8E1F3D830C38C561ADE2E33E39A3DCE19306CFDDFAFC39EE7 - FDBF5F8E3853C7F564CC61AB70C9158BAB3E78E2D885C791AD5B07D37A539612 - C545019CBAF9FAF046190A5523087ADC4D3F1E422A355119426782E5CE38299D - 5FB288430F0F25F6C2009D34DFAFC7E059C16709F99C7BD0759F1BD63AE1D0C7 - BE3C7BF9E23A116AE9401483B8650661D7250379408B61685DBD1711F0382514 - B0153008D54F5714CF0C16EA8E0B37DE7A6436D9C8A2E164AC6D733183682E78 - D289A9981D23265649EB95E543C229AD211C1869F0D10C8BC51D7FD931E2FE38 - B3A7E5FBEFEA675C0AC8994ACF57CD9D18CACCE788148FD3FDE4B66C33718BD3 - 9B9EBADF30E800D17B080C2A16C1F3A3877A09E84210421022CA5014590E0714 - B913A4BD77AF1FA97F7FCE02036D3EFEDCA2E067AB757538C43CB75E47D749F3 - 9FD8CCA611B6E6F2D7307D3DA84D4080A084B32779C6D3B11C29011545432016 - 38C30E33F046884D86BBAE302037C7A36B9E22A44895AC914791E862B9950B92 - A4CB5EA858C8990084A859BF5818ABC3519940040F530E07B761354781E5CEB4 - E0B6B3D7D71C45933A7C673CCCAC8E8CBADAE599EA273411450DC158D817B987 - 89C830121D281C3722202C3C30445D054611C4C9F34C30E0395706AED5753084 - 5CCD92700520A0528651289480AB05192C20540C0D3998BD8D386E4C9481B645 - 7223761B4EF9AD0861A4674A532B2D973904E6664231348F62748E3ACF33DEFF - 0071F0D7102AFF00D538821A46EE73E0CCD5F458F61A954A2E92005E86061B87 - 0057A704CE463D9BF4D873D6F3E7F73C5186A9E7CFAFE26F88CAEF06FC7FCE29 - F09F78FE9E3FB3409A73DCA19F275D6C72F2A34C5C0D06C15898A5292EA45542 - 0357050F82DF072CB1117CA89F061B26738389D8ACA70463A0CAF5F486B5AE4D - 50C45C889E7E3CC9010CBA2B9339E8DDBD6321D85AECB48CF467D26E89A51AA0 - 5338898F9764C67BE9994641D9590F55EBB4CF1C70A9910C6AE3091D62B216A8 - 180068C044B263E1B716A6C433A3630F5F1EFBF88F23B323AC423F21EDF24810 - D52F547A757FF77CD43CB7A7109CDB86AB07794B8BC86D9E7627AD8E673367A0 - BDE19EC9F137C311A34002EA615DF7AE2C86450452BD21316BBE105443ABF2FC - 70A3530A8FC4FF003E9CB9CB49AEB2413D7FDC98E0F866A042BCB09DBD5DF2C5 - 22B3F5244EC5C6E13C8CE1B3DCFBF100A1AF5F1E296EBFC71F3DEBFB0A168C4F - 42066E837E426B89682F09625702C1C65C4E35AFBF4356F96A2BEABC30865261 - 708D71D63DBCF5682F99540A0C95C9A2F9730E4A039E232F6483A865EF1CDE0F - 6A45F457C6A1970790420228C09B363B7B3BEB99A99CE99EFD39EAA30ED20A11 - F1E2666B1C212021E09E87A78CB6F0C044D934D059E6E75DF044D37FA3B16FC7 - 5B9C20343C1CFC4C759C699E6DDEC650EBB3E72E2FC646AB462DF807CD44F8F4 - 728028593627D8E5AD4932D301318F18EFC775FD92285B96D48CCF977E9CAAA3 - 4B303688DC5D42C7039613E9B494687470B0AE3336221D814C61ADD7AD9C34F6 - 7DCDDFAFD33CA6408B0B58F59E86578464159002EECB0CB6CB7A511DCBDCF073 - 3C4DFAFF00870CCBD7F3C9CECA1F47F6D3D9FB1FC5E3C5FDFCF3E047EBF097DA - F18192A7DCC7C3EDC0B7A4EF667E3AF972F304C613DDB2621DE6B3A1128A0A3B - 0653FCF3E9CCDF63F29F73F5E63EEACF9B1BEC91B953056730CC195EA07DCDF7 - 6240E60EF4FC3DBEBE38C6F4499FDC6F820CB63BFD4F4C9BF1C0FBC4834DEEC8 - 6C3A338C77C5C8897BDA1BF89ED7BE1F814C9DB4C984F337133931C03FF01EB3 - EF67DBC1B07A5718F87C1CAE5F638C22078C0FAB4991E64DB8890D2192116BC5 - 3D31AE32991012027BA902B113DB090132BDBD4F4FD6F185A6B26774FD3D7D39 - 597A6FB0FA3FEF0D47BFE38311C613CFF9FC756F8BB7279224F87D7FB7D37D87 - F0C16122B9ED897E699DB8D1C34150F8309F3C367E3814C7B7DA27E386C8152A - 03B54CA6D926D9BCB19D84A552B3B74AD52366120D222A3A4EB1D0DD9E97965E - ECD4C7FD5D17BCC0B7444651EBC61ED977B99A83C92592581235B7DB7933DE9D - 6072D83BCCABE2E306329A1554600481DE68AE34F7D1C212598C7B3D7BF7A72E - 952926BD01DB89A665D3785824D444A653E730CC692A1DF4404B4220CA3B0819 - 87819A145EC7CE6D8A7BB215C9C916EDDE5B92BE957FC26F035B1DCC39F4DD6F - 9E3645463B58B4EF0026FE7DCC288E056F10DCFAB733C0672EC1B50CB7360065 - 1C785DD86AA2056810471199E63D05C40680060744D4F87EC7A7F0D123D0FD5E - 4CBA28DB946BDCC0F53A1FEC8419FE07EFD77C0A50A22937170E7D1B5758E6A0 - 386C264C643E1EDB5332AAD5EF0CDFC5FB72AB21501A3A0B4DB6BFEF1C5160E3 - 960DB51410C04AF4F2DA006812B2DCD4F025518210CEC298DCB35D55B990273E - 802B25D2E077BEB8F80DE5C94DDE96C99CC3C70384AA321170B9728DD86DE186 - 2390128918400E3639B7849B51AB409550039326646F10004864166B202C2EC8 - 1421C4C5A08006834EDA80330AE4B66C0030102868EAC4EAEF3C2A29520A4617 - 42441522E676D2A736B7A306930DDD7BCE2D4BB95B76E6D62751D12DAE45A590 - 0992A8E9258E48AB0A54410C18C0CF1AABE59CC88780620650A16B9EF5DF0B38 - 9E61497150C5EFC3823C772190808A804FB72ECE4F3683273112700BB3C58BD8 - 33D39EA71572F0C241E84D99C4FED7474E2EEC7B4F438DA7820E760E2DCD5719 - A6CEADE23AAAA11EF431C1E5E00D887957EABC4A9A32F7698FC77AF3C270144C - 800648A2532898800D4FDB12C0AA87022904504500A2B58507BCB36B3A481482 - 05BB91816545655569394A8B364A37BF358400E4A639603281508ECA82DF08D7 - 3F12444E94E40912196A5A505681A254C8478A1A3D4D8981C0D0998A121D6000 - 0533C80E5517794BA3115595828815BA0340DCF10B2B0D8AFE58812744E22B9C - D4CD1CC077D468E8E430D7E86403F01937399CC40B112749AB7DB3BCA15C5E08 - 522F7B8B72E9D78E18CB378526234AB0B3A44CA1BF312EE87398284122004086 - 4A46E156509B12A9C5800A2AD532B48CC2014317813901E3C7C5DF46BD7CC152 - A4A5CBFE7265D0EBE4F7E65D77E054FED48490027834B6952BF8C4E5FA3F0B3E - DF3F6BCB018D757783EDF0F18E190F538C805A91C861A4C5A77897DC19F56441 - 36E35CE4338A060E078D88EB1BC9DDEF34BBF4548F4468233A4951D6E9E97306 - 06186B2A9B9E6493233824EC14A564E5896DCD6D8CB7C601B0342A27C81CDE50 - 948ECF3A2844C09456BCBF888258A18183BB03402F46156F1995C7C057750891 - A41247289BA54718C5432702507182E1C22558C2B58D4209249A05814128AA28 - D048D78D67B772977726EBD03164E40A203AC7F0A7F56F33A6EF16AAE8CB7DFB - 5B9E48840E2F772A49DBED7131C97196C4D8C003ECB65131AEE69938A82AA058 - B12A6EE7192999555189CA14E142BC520061D0421E0E96B16A4E0C74E32BF990 - F7C704A4A05D6354E7CCFA6EF36BF4A777F3F1FED76C030E58B9F201A5C75B4B - 3B4D53A38AEC133DDE687B3F739A1EC7DB95618DF57B7A9FF785970BD31B6373 - E3DE28B7686258A55D6F3254FAFAEF8E474A5D6AE699D6A63CEB90F07C8E0CCB - DE41C925329266A8609454852870B6D5F5404B2986CC80620C39714996E3DD9C - 6B872C1A841D826E9EB4B980C924687A72E316DF2740D71CCC09DB0E3AC75866 - 70E5E5EE8943797A22B416F7D8070182008C9B140890EAF9DBA5660388F87741 - 2BABF02A7081AD91CB730D393B6C7DEF2D9C001B9180B21B97D7CE38E53B606F - ACD4E9BD9C90014D53C62CBC5CB5B93811038F6630A280C425016E56FB896321 - E94122C083CEE61EC727D0651CFD4E2513CF2285A4531AC6BDBB9E57CF20B666 - 6BFEF1D693AFE0F6E2D57CB7FAD2233EF0201024D3496B9EAFC43800CCDF3889 - 0C035A3678A151518C0A1664C402142BA1EC7DB999ECB33A44C757DD38DBA124 - 0BAAA5EA87AB33EDC1408294547BD193D6BB7BB7880C2BE990F6B3EDC9F0FD3F - DE13C71F106AAD63B25632708A84499975B1630AC29A3D6790269BCD523763BD - 6ADD18E1D48A7EAAB1630C81871C13534112B0C862E9DBB92E502F9890647615 - B414A5774E355B44033690AD0A010B0CF1D28404E0E8C87510382E39081B5A8A - EFB2DC19BE66C670855CF5EE12431ACBB09B2F245060348080B9AA649AC68728 - 008E96E93387874969A931B251B9575ACB772BBCCCB0EB99644815C516CF6A86 - 041D0494CCAA1C4218D14E0F705D4180462AAA6E67333986DC72E2237D17E8BE - DEFC5B80A7053CFC7CF317CD7E1A3F75CB026355F578FED24AEA4A424BB14BA4 - DE259C5D2C2AD0D983461048B5244151A9EEE5F306B6311E2109D05E6D3D4C7E - FBF193E67FBBFAFF0004EFCE7DB93CDFDF871A40A5C49040EF0B1056F5C8F82A - C56598CC89085D209C41A04AB32060E83014EBA4520CA8803431017147457BCB - C6F59D011F317D1A10630C61D60A0AC81929EEC3831C3540954CD1D06222802E - 6663045140EC0618C401E4A41B47BB6E4A9D8764E07B133563C1911AC25334C6 - 78622756851322D41296865E5C4803D1D80EAF78F4F5871C6A021B8BD243E340 - CB3A8F8BB593403506B9C59871C9383582CC0610174E46354C0B7CA60A4D313D - C87485A2252B8D38F6C427A37E1C0F9F189BF7CFE1E60F90A3801325BED8E284 - 7A34F93C9F7EBFB2CB3A5C5092373E99F62B81E7D0BF6F7FD9CD89E7AF78DFB7 - 31B7164B8BBD710B88E4D271815863743CFCFDBE3C15097CFB7236217C14FCAE - 73CDB2CD9266F896DF4E28B85416B0A039419848785AABB5305680510CE662B3 - 940DA4614930C0C8AE08969C584E83A8A1489DD753D69683CC2B7135491B4A6D - 9E02B8E88E3BC03C3A018305417A0CA6213019496678789B713BF911AEC36680 - E567B5A84EF34CACB05478F8CFAD71A5A1317143D5891918A0340862E41276A0 - AC115E958438190B83C98788736404064676EF0CC3EF12C78E08E53807919AC0 - 7260DA1BF6C359AA0147516A615AA1D5500565AA5EE847D24396BC3D5C7DF9EB - 5F402BED8E5DF92ABB7AF5BB9F3DF277F9E788F7CFDFD35C76F7FD7EA7EEE7E1 - BE63EE1AE5BBECFDCE69EDFC1CDDF0FBF357B7FBC386CC3FAFEFD670EE0D32E3 - 278C6C13CE6E5CE39DCF66BFDFDEBCF3EF3D7A5C7021CA3DB8539A48088C601D - CCD5A30E8533957020926AF2021210D90F86DF2E5D78E3118A8611240E057182 - 150448C388B0410B2A925C172810D8531D05522C117363840A582BF66485273C - E4510EE5D8AA655437C8EE21E321D4ECC62ACD50BC4EE056A81CCF2F58B78CAD - 9AAFA8DB3A977EDD01E42BD3229EBAEBCB2835D815378A0C0652B4D353B281B2 - 2833912C92F1C566061164685A63CC38266ECF2E7AF6FD391D4CF8FE3ED33CE7 - FB75F63ECF2A5E93D84C8BF293C706027C93BFD32F5C323D8FB73E8B9F7BF7E3 - 7F8BEEE5443753DCD7A1C77E9205D650F09E81FE70B24208A642BB277737CE2D - 318453C54635601409262BC220A54372EF4DC221BC39F46F691D14045A6E8E8D - 9D22A28C428B8A4C9718424C866F3457263452BA8CBB70C14028111EB3DC5190 - 405203C284B81104410A4525F556F0C86828B803CD452A4DEFD70A249D6B4FBF - B72109A5357D2EAE4AFBF7C809412999628E70851248EA3CBCE48BD4973E5768 - FA6F8B1A60D654C954D7A31BF3CC712E5EC9FA374A632F353218B482B0005776 - 0CBC86EAC41C886934F1EC105079BF1E4F979EFCFF00BFEF3F3BF8F3DFFACA54 - A597285EB7F0F0F00963261CE278707EF8C6FF000FC9C718F83F1C594B8C63AF - 6CE3D751EF38E0C08299981DF897D77737BE65067B6DAE55BE5EDF4C139B3BCF - E70EF63EA710321C0A871001A6677D7C4522A88A78D1B54231DA51D27166AB76 - A98934E4B671E294D085AB15559B45B7270F4072A909DDD3522964E4897D9456 - 0CD151617057BA90C128520C88889D949837AE6094401508A6648C8A28937485 - 442551B83C0C994301C0A59D050D785F03E6EBACEFC4FB1DE24D257C4D66B096 - D59AC91DCA8CCF58B9F5E179083085197222197A1DACE5833C160D0C35750084 - 4668E880022B5C2A3110C68F43594EA464E5368ED965CE584455590451118BDF - A3C5BC76013AAC4606128AF0CB4402E2609C040E200D72BE5F9BCC5A97C474F1 - B6E3BF9678EDF77FA88222E5A6D01723F88BF1E2A28E1D7D1E3A98C7BDDF333D - A7A6B1E31C953021F435FBE38D2FB7A637B9D7FE5E1366BCD3E59C7DBDF94159 - 30587C4B2F588E7BD4E5418F53CDD7A2BF0CEFBE36531187C4FF00B5B4FC35D4 - 93C29D4E90F9F79DF343D8FB70FA56CE63BB1C61175B0D710BC92440E2506C04 - 5B9784468281581D90630EF289EA80683006DC9A9318DB989B38A84669B8E921 - BC231CDBC11C9E402DB3014C9DB7162A8EC4834C38842CBDEAF971BE1B02AD21 - 71D40743B08DEEF0A23380006C5700AE6000B8C6D2C0A3C8EF68A9B999B7D721 - AE455EA41B8B109881088A4B45711563D9CDCB100C94C2AB9517D12FB00388A5 - CCCE8C26475F0CE1BC62C4405722094A494096A008302205079753246D8F18CE - 941049A9D8DF3A661C0B65646541B7199086C38EDF77F718F97F5450721E8C99 - 0D8EA7DDE6ACF9FBFA7377DBF27010DC1D4ECF5F6E416AE3CCDC7C7E3802CC1F - 2263E98E4451F8CA7C7F7BE30C2C75ABEF707C71C09AFAFF00E7A73B5079C1E2 - 5B67DFD3983593AF6EBC75E9CCFCEABB604C53C35C390F88389820830AC336DD - E9020703348CE9D944143010C5C9C2C6C002BB8142A59301E783D509CC195061 - 0430CA9B200D817392CF45F3175C2A23B4C5AC63439EDECEDA28D076183D00F4 - 469EC38E0C814A0602E701903603AEF9237634914C34CCAC4178AAF66231A6AD - AC03803178550176F18D4F9F116335FE7051A7154532223AFCBF77104E198C47 - 8001A3904306251628018898F9227CEBAB38078FC8016D10088E9CEA6F7FD5FA - 3C09026BD7D78E964C27DB9A15B3EDC4AE298EBD8F5388054E1DDF1EFF00EFE4 - E2DCF6971B3C6FDB9EEFA7FDE2C44626AFC7ACA6FBB9BC100B6015DB0DB73F3E - 60289E8DA8C907A7BF0E0BC01590BB986CFB6FBE23070140C0C00922B5D17991 - 82E835B0A0B93210C222F25AC26A0162449A68170E73DF144C09B5CC1AC03C4C - 55EFC73151B9C65F02DECACB7D9E62E03CE33CEB59E16F5AE3E789495C869705 - 3092E31799A86558BD1D040D26500515DF734C03075884CEB9D3E3F8E2AB2E27 - 0B426FD7FE71A4C76EF53AFC70A16C9E9FF7876FC39428EFD3B34FE3FB699032 - 4C2784BD67DB8341F3C514DADC1BEB3F4CF8E40547426E4312F93706E381A856 - 0530C993BFA4F5E18298477A7F0E791E0F9721E0F91C8783E473F5072DC92393 - DB7E3C709A084C05820F71DBBC9E2F06494424160ACBEBDAFADD71038A28996C - C0D3642D526284E81AA42B6967441310E3826C09130B6773A0D0A60D3C3C0C34 - 588846295AC697B0CA0A964CC726FCE8F3D19CBC6AA432CD3216957A2F6756F5 - 7233AAA523385531538E6213285E81418E42B8D9976B35DD5F7D7EFF00BD0F23 - 37E1ADF015870ECEAEBE5CA5D31E7D7BD7EF5C4046649F7E08466EFDB91E1FDF - 8FF63B9E5A45434EB330737CF45BCF6808CC6755D1FBEB90BB7575F1DF89D9EF - C0B0806C7710132ACB1064856B60066C0637334BEBEFDB892603BC169EA5C7EC - E7ADF47FCE7ADF47FCE7ADF47FCE7A5F53FDE004364205C8643AF63DB7CC6823 - B09D626F3EF0BE3861923E0CFE1EEF1402AC2A8419EDD5D773888438D530F033 - 8F57B2B39BB914ACA09D10119B6017116BC6495A8DFADFAD73C427C26A46F85D - B3C68D4C70ECB02A760A896F603384E597B0C0ECD4C336BAC7233A34EBFD4CFA - 7141E3FEEFDCFD9D6BF4DBE6FF00E7EEB881CF8FF38E55F3C8A5D7121CF4F4FF - 009C1445CE8B35BEFAE0763E517FB7E8BC39687134DD7767BAF4BEE5E0A5D1EB - 5921935DD3806A6621738DBAFCCDCE00049F9F77F7E9FC094C33B9F37A7880B6 - 6195333E1D5FAFAF0CEB3ED9E21B4CE37E78E4B451E92B9306C0F9F1C3133D16 - 6B3E9972FAE77C2C8ADB62AB1860CF7E3D7D787274CB7A91FDFF00DE1454000D - FDC7487529785968BB2A445CF635BC70EA0B054C487EA46E29E8F101CD735AF8 - 5F593CC8D9FC295C76BFAF1000A0F85F8F02B8CE3AF7FF00BF9E14B44F7E286F - DB82A1FBAE027974533F4E391EF0FDB992B1BF1D8CEFDBE7DE783698677593AD - F78F9CD75FD7F45E1C4638E9FF003EF8E215097D1DFC9E650399A1F5F4E23EA7 - 1215C1E746759E6BDEDFD3D3FEF353FE1D7D7C73F37E79AFC7DFFF003F4EFF00 - 999BDC9F9E489D49AF3E34F8737C699CDD5CC42CF47D3C49CA16F4010D81AE42 - 8008C05E0159AB800A93160055BE56F04EAEF02F82936DF9C1BE53C9F33AFF00 - 3F8D9FBD1CD7E3FE7F05403CFEFEEB779B9FBD73EA1FC7EFDF94CE4F3BEA197F - 7539BD7F7602300DBD070C0D9E417D7F7BFF0023CBF35F49C5F95F0FCE6F8940 - 6E7CBBFDEA79C9C317411CE5C18EFC79F0F28AED4F8FF98E6DECFC73F37E78BF - 57C73F7E08A7853E4FF3DBE1F9E2C9EF31D7AF334A61F440261CB41B784C0939 - 06D86A9B0B49C873AFC7F1FC687B1F6FEDB3DB9BE75FAF527E275ADE67F7EDF0 - FCFF001A3ECFDBF8D8F73EFCDCF77DDFC135FB3EEF36F7FD9C6BF07EFC7EDF1E - 3BF87D87363DCFBF3B7E9AFE37F7FDFC9C73FA3D787D9F779F56FC70D7C7EE7F - 8E9F1FC7363DCFBF35FB7E1FE0FBFF002E6DECFC737FBBEC7F4FFFC400281101 - 0100020201030305010101000000000111213100415161718191B1F01020A1C1 - D1E1F130FFDA0008010201013F10FD19A30E228577DAA9FD70C6C87B779F53BE - 5BEEA67D7F3C3DF3422B5D4F4C1C4A6FED67DBBFEB94D97DA5266A7F0FDB8707 - C2331EC3D730016DDEF7D4FA89E76BF9E79EA7F0FF0079F8CFF7858A030D38D7 - DFE25F4E10D1BEE7B80EE2043C77D01822D5C33027A83006F9B9E7CDAEF5FA4C - F6F9E08A2D1F3F7CBF07AF10058CDC7CFB6FCDE0D19DFA0CD90174602EC0A4E0 - 763A8D3DBB3D33DE381A157527A564CB93CB7C8ABC35C7538028244E330781F0 - 55D37B0C9DC712DD2C7E11F15EF36EDC77B1BCFE2FCB9174EFCF16931F9F3CD9 - CD7E3EC39A7BBFBE7E63C3CC81F37EEFEDD9F77EFF00A6452D55278A8B3D2F3F - 0AFEB8793BBF29EBC0083BB0BFAF6E7FE63FCE337C0F4FF3F4FF00CC7F9CCEAE - 035A93D9FA7533E8F11CB2EB5195581AC1067C154653494E481949A6CB389876 - 3633B301CB396F1BB8554034210308E103AD635BD66401E801337D0DE1CFA647 - 9B142345024CD1284C2277935C0D90F22AEEB576F6E3C18E5B224084C316421A - D18D6474B0686F53B843A09310C625E26C9591988A280A1837EED44416738645 - 6A0E82399312CA9D00587766E57817609D4CFDDE04A11C6403D194CFE67BE4BD - ADEBB7823FE6FD78960AEFCF5E2F8CFB77C0863AD3823E704B9F1CFCC7879A7C - BF77F6ECFBBF7FD883B380321FCBFA68FB3F6FD3567F83891814C0762CB30E67 - 4E34EF94A74D9DA97546DCE3A35CC0284CD818F100611D79E2EB44F0CF7B907A - DF0F6251339C33A4F4F724E25AB5BE222BAF2FC5E558B8B1C1AEF5FD70CE8F25 - 58EF79C786467019A71D674F34BFCEC33D0A4C3671650AD057D5AA8F7785901A - 25416923A01A32D42B78760D0A08589B90152B219B481007920190ADB72EF302 - C8ACDDC6FD7C79FF0039AFE63D7FAF9FAEAC5CEB9859319DA97A0AC77EBEB627 - 1DCB35FE2FA73F21E386BE7EE7F6ECFBBF7FDFA3ECFDBF44698D31A4C4F68079 - DFB7284B0C31C9D6364A7D7E397A221F2173547C90C0041CD789AEE6184C48B7 - E758F1C2C1DCDFA5F4F5FF009ABEB159FC2FF5C50CFD71AF6DE3853D22970DCB - 97C50B96FB7802A54F5FF9FF00780ECF72FDC75E9FCAF1B0BD8056EA841878B7 - 14CE797986D882653E303D4A5F55482403D514B0094CAC617B7999900005A4FD - B59968F1AAC008F258DAF79D4084B99C52467C7FEBFA022E703EDCA010F3AEF2 - CDBF9FC1241D146E99D9B9BF9E1AF9FB9FDBB3EEFDF8B11D266ED41C13D67AF1 - 44C9C75D7A6B82A3A2687BFE3946493F3C7EBA3ECFDB83C8F4D74BEBE394C49F - 3C45F94D80B9E877F4F4E31558BAEAD3C2D95A62E5ED168B8638B5F3D79FFBCC - A95D6234DFA36FCCE0C1D1B5C5C30CECDB8F0E355A448E16B80CEA66A078CDEB - 936154D99A92B86BAB5AF9CF2073AFCF3FD711B01D40C3D911F66F7394C08605 - 102816AC0D8149759A248760EB06D855DAC37AED24C3325EE527AC3FD9DF1844 - C25A30C06966452DC7147820B87E210B90418AC71000546E5267C77F19F638B0 - B3F3F1E3749B3CFD7AFF00DD3C543B87F53D786990E8DF4BF84E645F2BF77F6E - 04205C56E1C9A98CF7D3C76F5AAE7C63A6CB875E3823220A01490DD5EBAF6ECB - 2BE80F91F9E2685ACA52F88B832E2C3178EEC0519E89417E83AC64E32AF0A430 - D62CFF0021BEB8B93A3A94A779FF00CD6DE3101A2F8F53CFCFB72FC9FCFF009C - 4470A02659851B323FDCBC451D661CBA17F96FCEFCBA63B2CCBE70A10EE66E24 - E0555819A1EBD88DDF1E38C01D08A18089F26BFDE3785A51CAB69D2EB77D7985 - 211C5B7CC366F5ACBEA70CB099338933F27D2E4C710C95994A97D1632FA6B898 - 155EBAA6FC297DBD751D122D9A9307C409E9C704CE43DB7FF389A14C334CA640 - EB26CB175C8848860DA184594139082ED100B732FE03AF979B3F3BE2C86738C7 - 5CCFC7B7F77FAE60141736F3DBE0FAFDF4F97EEFED4D90A2C3395C2E5DFF00E1 - 38F6690A6C0724C632530D65BCD0A1FB14592994C6FD75C82120A1A6B80236A5 - 2691E2538BA95A264289653C968F10968501CC762825A5264A8F1109D0B4929E - 33DDF3F12F234C03937384D4EC360DF178F2986977D47393C4B8F69C584E1B63 - CA5344236192D7B753D63C17234600D1281E6C7CBBDC742C58B2A5A66FE7A706 - 54DAC9ECAF4095CE26470D8DAAAEE111B4DDC28EA119B3895588348B2A182436 - 800A8E4D808AA142900796B219565E03C469175121B48E1587BC92B733D23F44 - BF1B7538A58A0C306850A3E40778EE3A5ADFB7373DBFB78241E64F8797784028 - 5A2E5718AF5AF843A093E5147AC4D98F0CC72C331BD9E4F5E068F855D624CFAE - 0BE7AE08E4CFE7AF33B8BFE14EFAF4C47D186BE7EE7F6BC1A93C66E46CF1D192 - DCDE0CD926021AABD4534819E24B3E7610D9B569DBD573C2C41B1BAD08EE95CF - 67B1C6200D0470A9D046E58565E02A8D11209A7803A39D2ADE257424D3D30FAF - A9DE4C9C760C117365638D59DFF5CA8F8BDFF3BDF7CC9310B34F79759F2FCF10 - 32540995295B9BBD90C7539B8AD286DA93A3463589DEF86518494EDC6BCCFEEC - F3CA8266DD642487BF931FDA35C38164DEB59DFF003ED9E68212220541F42413 - BC8F4F1B5A0C87941633D80F3DB7941AD8E01B6922F9E1214F2CFD8EE69C9002 - A4D96AF382A664F3731B8F8CF27837B3B3AFF1E6E7B7F6FE8C3C48156560378B - 7FEE5CE914C11DE09AB43D9C3ECB4CC6B02E4FCCCC7D0E3A7D9E042277FD1F98 - E675D853C5FF00BFA38DF0D7CFDCFED553329F9AE3BCFAE3AC4D9EB45F310063 - 101035DF0C0009A0E021850D43DBB50E883D88A533E25F5F8E75A9981767D53B - 84EFD5E127554ECDB54DE282D7B14E28706593A30CA9FC11F276B101126334F6 - AEFC1885BC89BFF6CF1E9F12F083991D6CB9C637209837C710D6592F51F195CD - C1AEEC33330F2575B3AFCDA699C61C60C687B3F30A84942E71BF1E9EDC25DB5D - 5F279BC81DBAC2F89E01F2CFAD31CF18C8AAF662967D9EAF210761A7EB0867BF - B3D0EC519DB77FD3F09E431C72A911542CCB6F52BBA6306A0A0CD61A630E5DE7 - 1DCFE78B55F5EFD87F81391F0FD39B9C1085181BFC677E789145463358330A4A - 47D309FAA86D0F7E7E73C3C35F3F73FB767DDFBF367C7D8E67DA5FD275F6C5C7 - 2E9F731B6CF5FC7D71EA017DBFF7F3C1E04043E0F7E3E7E0E04101235B9A317B - CF9C71402201CE1703AE9479B3EDFD9CB299D14C4C3E8FB5EF1432B29E43B59E - FDBF9E45B346AFF7ED7CECD729AD74EEE09F5F9EB79E4B6AB2FBE7E7E7EDAE38 - 6D5663C47FB9F987D470F475E719EB3D7C72F7CEE39F4EABBB9D6FD39E339F53 - 5E989F59F5719C31FC53EAFA3FEE5299532F59F91F9C5E01AAB05C6909E30E23 - E7E3866BA43EE3A6D748CCEEEB9E88675D8FCF51BD8F053D87D79F5FCFC71518 - 1BBD55F18EFBF3E6F367E77C74CFD3FF0040F4FBFC65F4E1AF9FB9FDBAFBDC55 - 6B4919E77EFBFE33C013B5C4D94274B7A3E7AED807AB7D67F2F1715958666707 - FB8AD35D82005528A050DBE0D10DA0CA7E973031F3D04E81DEB3C0C55D1B1C81 - 5B7CE4F1B6E301CE8F96BCF7F70C72F8A344658B4DE7DF50FA353970C1161344 - F5F506D202852AE1BB627C4BD3326F89284D91BB866B9EF3986A7830E6C0BDEE - CF7EF81510475903C4D2B9C797815D024AA893E88DAC0F2638AC7142BACB2A07 - 572E30658DE3BA3A0C3F4FFC67F7B6F273F7D6F39C3B8DE410C0BA745CBE095C - E2138087735AF367CBF394C52A2A823743AE2AE4CB83D870A1E816DF31C1EC1F - C9E7853CAA5688473846A0E4C6339E22518594C6ADCB9DDA89E97981EEFEFF00 - 48783E9CCFAC225F061E9C35F3F73FB59C8DB8F4F1BF1CBE1A94C2C1000C10D3 - 0178EE92940BD2C53E8003056907CDBBDD3FDFF77918EE5589CA4513D609A597 - C71D9417AE05426D2ACF44DE18B5746A241A0100A51803C0A425C3A51845E8C4 - C5C716520648A51DECCE6CECC030220AB84FC7BFB4E0143008220233E087A476 - F095A00619506180B5A387C71332440012AA60291E9E1E411CA681DCC5F44F0C - 3AE6055471EA11C671997E4B4D5DAE4A0AB9F0A5AB1F4333A082C6029660AE0B - 2F20F6270184BD22E3C6339DEB4E4244476992BA7CB2BEBB23B9CC4121C1320E - 4C3BCC7CEA67809122E0DB426B5F38D79CA1D40A0CA058E2C0B13078E25F7086 - 28E5662D7CEF60DE636850D2CCAE5920E4018EC44BE8364F1DC3BA3275CC87EB - FDFEA0C61E87B3C35F3F73FB55AEB6F479F6E10A86B803D207B81C3517346042 - 2C00C960ED92A050800068B3E65FB1CA60749A184B63BCCD673F0D65CF944A40 - C0D2EA166B959E1B94001601401C59091A5DE0A554936FC3A33395F88F365B55 - 3486286344D274B944C185C2064D1DF538CAE7C12965496456EBBEAF121C3405 - 56180C2845492600E3EA905CD8025088EC2DD79759EE8528B1424CED518E1029 - 811809047114CBB8E18EC2928CFF002CAE4C589E0630F1A68A1510E1B6B88707 - 0C0CA63281A947D33EBC8BC19810670EA301C93F839A90060BA6B0E80AD42F68 - 554543CBE251B6C27A4F5E28F1D52F61888D4AD35471B5ADCC01DBE0C2300066 - 64BC4A08237316280D020287131C63E108C01F02EC068069C2A9D7120B9C1F6E - F9F9FE73E506FC70D7CFDCFED2146AE514DB9431EDE738E5AEE51348C0774C68 - 455DEB8C076E0582E217A81DBEADC1C7170632F1854F59C39D113521617D501B - 01E06125C226150A23BC9285833886834500874D113100107E7968CB56C8E408 - 1F5CC065CC97123CD8280218D2D23626924C3AB94168905922896F61E0508051 - 61059AC01347A3A102B352309024816E4DAF981D4D2800B988065D9E1EA5E551 - AC227525A402B37A45C71C215927A0CF2C1943E696931A1A229A9C32A2009109 - 9D095D05F6B71BD47A9AE31205F00233A218F4718D6B8569985C653186047AC3 - FBE25A248CC347ADEAE3824E884EB4C9C5C8AB8D1813384E439D2E4379460A20 - 0348CA8670208D43073909625B4D089901291317DE6AF699EECFE7D38E44F3C8 - F2FF001FE1F7E79BC3DEECEFE7FE2EF86BE5FBBFB4099C0AC3A732BCC0BA3C73 - 421A1A381C0C0DADA602C442DA1BC4EB33F887B7E811D685DCCF8EFEA71BB658 - AE9C1318963A5DF4990093BE8B16757D7427B79CE4066137F56F39F1759E6080 - C6F79AB134F44B6CDC5AC13EA146D25E23F4E4978C30AB478BB4C6675AE0C63B - E5A9E50732F82EB192E120B958FA10F17BFAC4BA0F28D4DBA604EFC2E264E332 - 3AC87447F26F8C5AAE1E88E9E41E74DB33C52619458486353099EB8E800A0E15 - 37468F0CA1E719E3B1E741ABEB9732B740C9BE0681558F4ABBC6BF989D871972 - 6C489A04B5EF364EBDE1401264C790B5F5F96D6B7E78C958622F5D212E0C45E1 - 586535E008B95690034650329F243A05DD8EC0C80B6FA7BFAFA7E77FA98CC55E - B31F1C109E14FA2FED94008693045541219DF9C42CB8404CA90CDB103624BC35 - 0E834832941067B87339F7C7B43FBBCDAF08B3704D7AF8E33077B9816D5DE3AF - 3E9E1C6F286A94550B7D9F4CE2AAEB13224E8C6BADFB3C1B1322355E709134AE - 662C3AE2AB930420F2CE9BC92DBA5E1205D004A554129E651623978E0033E3C5 - E9FC78C45076BD4EBCE6FA783D000BDA1AE6E08B691B061DA31AE31837B53EC2 - 2DDA11CC4F54406876605F60CD85914A52A1724C0208A44C68B95808804C7461 - 3EE17D26F4F5CB619C7D31EAF747593406842996C5C9DBE86E3C5C5E04A8006E - 1706A2BEF43BE2C39542684BE6635EAEA3C662E363243419F503137E616518B4 - 9A0E2981448B2003670B6750B84A2AEE0CF2FB77CA6DF272D87463C1F9BFD7C2 - 9EC787C2F0D7CFDCFEDCC76A4468A35C2697795C41E6DA8C22DEC83A9280119C - 5DB32834258D00BB894EF3CF4F9FADFF00BCD66EE03CE4C78FAF3B9654C1ADE6 - 0A6133E9970952C25A974E937CC0B9BCB3709220905488A4A43321171C5EE8E4 - 313EE4A78D7F271A62A0185115F11B8BB1DC3852090073818415206B18A4B8E2 - B0EDB80F4875E653133EDC400E50703928DB8F38BE2E1CAD6C392B778231DA9B - 9DA899C8FA8895ACB0E7B367683597B3224D8212DD184971C70B42828582C4D1 - 535BAFA6008D0F19FE39C1D62638B1D15C6AB7344F5A12865D29098D6A2822A0 - 2105602922B2B70230D8BA550A23709ABC50C1585F40D306AEF3E672B3C98071 - 10216B940B95B6983AC22614EB0666415659938491B0631B4FE7F9D6F8944F3C - 9F2FF1FE727CBFC7F9C0A80AF43D8BE3DFD35DF0D7CFDCFEDCE03BD85934718B - FD79E106CB9032D0C20AEBA96E3C71A8DB4132279F3D7B63E6F3B7D8FEFF00DE - 3F9871210581D2F478F399E7ABCC306D9571740D61ACE2E302338014AE070C07 - 88B7C16F315B74533A30AADCF5EF33C4B7B10028E1622E811D8318E32CA3E85A - 4425982208C1AEF86B2A0298C208C5338483E6F7CA8374108360852D03A3A41C - 6AE8BAC89AA1658CB29AED3910CE49D7998AE617D03224CA985EA806739D7A5B - BE0943285812B04633DC2769C1CB8C31B97A4CA69E4185CC056F5523D3A313BD - 629398545A20ED911CAD11A6EDF5E261886B2225784C4CE4BD71DA94602C2996 - 184197ABE1E21465150100805EB35347893CD5028568E480E9409AE02802A500 - 649B074A771C77CA6A97C5FD22E85F8E4E02399ED0F7F71F9F539A7CBF77F6EC - FBBF7E3446443D3E5E97BEBAC70DF2FE55C3F4FD3E667E7DB933FCBE7F869BE7 - 38EF81540C8780B5CF709EA612C78EC1D7A8B46B375BBBBA1E6B20CEA52E317D - 1DFF0058E4E7783289E7DFBD67703810A15C18D403B183D84DD0204F6CBC0AAF - 7905DE2B92639D5B06386D5FECC9AF32F14505BB6405818A47D6BD4BD00A4150 - 115F9498CD7E025564439D0C2A25297204543840C07065076C9A48180578E556 - 41EFBEF7E932FBEF67A629FC06CFBFF91371789EE7DB30EFDAB0640B07141797 - 0266B9B6C38FDA4A3D746AD9B71D433E1C63774826464B0C8EFA2071E5816B85 - D0985E04834E0ABE4521CD92A06D71D9928416EC69ECC2E49FECD71C0BE07899 - D757F3627D327C6EFC59FF00BC35F3F73FB76F67F47228F472C3CAFB3DE9F9E5 - 883BFC7F957D5E79F5E7F34FB9CAC65A4F716F4F5E9FEF12DCB28CE1E9BC6F3E - 5D996CDC0AB82D4BEA887AB80D838C6778EBE3460D666A7DB11F7CF64CB14758 - CF49CC131A3E72A2E999DE44305905DCED0E020EBD13A8BB5E274DBEDD7D137A - F506E68AB45B215272CC72A628EF89DA406858C4C19134F0ECE615390000E4DC - D908A0A7CE6321356039389B15D28B33C7ED97D5F9C6FF0007882673ABE7D193 - FCE46303837B5778FAFA718CE2671D03D7C6EEFCF416D022DDA3CE2518F4318E - 155A041D251E8A9A8F6E721A201F0D2C0758E9F9BC74C4FED806F74FA5EB8CA2 - AE87304694641A4D3AE3D14F5977F4BFA7E43C3CD3E5FBBFB631AEEFF1BE60B0 - C68C197A1ED9C661E31D7BFECFD08400CF58E20B5B10CF9647D3CF1A3250A0A2 - B2D25C63181DDD71131F6880165AB5C4D5F8A4C654A6063D3721FC0FBF0B2FC1 - 9656D623937163D4E2526E826102802440300486396E4CC063188DC4D99A2222 - 79152984EC47670AE585D706308DC872659700C2A6E5BA92D67482037A20640D - 1BC3989D44265210C30A509824250A6164D0030C58313D57D358BC2B057BA7B6 - BC6FCFD2709D12FC67E334E2768281102C5C46E6D1A61A6C95C8114664282855 - C97C9EB9E4D164FAD1F2001567D6BCB9FC4F0D5011E610A5C6CE49A34E680D43 - 41098D4E06AC0152800D2323EA64CBCA32BEC09C5A4421005A372D5461935718 - 086085B8BA24C066A07CFF009BF8BCFCA7879A1F3F77F6A1DF1D31421338106B - 32DA9D6FC9C218C23DAE73DABD49E9C0A87AFF001F99E1A1F0FF004FFCFF0076 - 71CBE51CFB3F9758B937C14C17C373170B9DF507D4E25C243BAE737C1ECE3381 - C17AE0BBABE263D5CBAF43A4F9447B0CD5523EBE82971FC87DF8AC731B917785 - 87319DB3353939A0980A1E2169E4512AA0E2814A2D6E40FA9874F924220402B2 - 98CB6A562790BE89C8C06620A23B18A57C27B970544B92AAA36D415643D31E13 - 787825CA630D33134FAF5C9050E3854EBB0DCFA78339600930B5902C8D338DEE - D5CF036008D7194D099C1F77CF0813AD4D518B3B6AC42C90FD00A283298D5DBA - F7CD4E190BDE72AB5738CF9E5619634D39F6CFF24E06B87829CB199111931EB7 - 3C1B88E47AAC4AA0E2B95C50F695D61B927B04F7DF10AF047C29175D8C1434DC - 687CFDDF39FAFED128E8BF7F7E0A05B1475827BFF3C12EF6DFCF141EF3EB8E6D - F2FDB818DF84EF3A6663DC4F737C2017C3BA91DE4F090F69C6262F821BF50CFE - 27B5E148A6754DBC2AEEED295799EEBCB218E9B0C74A7EDC5AA842ACF17AEB5A - D1C05E6AE261412901029976DC1C2CC518A655C0D90099BE4202935083A7319A - 5ADB485822F153232686F08062C3D19566216AFB2BAC45D0A2B3A745E0DB9360 - 54977747B297AF52B92EBB330398957ADFAE34A4CA82811918AC10D1289EB845 - 064815290CABAFE32F96725509A0412A92565CDFE364C12D652C444A02959550 - 9221D2A7CCFF00312727CBFC7F9C00B9FCF8FF0038020422903F3EB181F4E066 - F693196CD837DACF08D15CE03F33578EBD0B8BC125BB9F434A90BE338BFBBEEB - EE7E9DFDDFDF0D6F8FEEF319BABE9D78CF1C2CCACD5F4B1FCF9E559AF5FEBF2F - AFAEE410A10068C8E3330B98DC2DEB9800B7CABEA43C1D8F854BC6C155874F7D - 433D5B9B9DA8BD415F1B6EBAE069BD9FFEE3255F39C006E013EB4CA1A19F1BB4 - E08C2E4051530A3B16EC3097970E80014DEA83413E54398412D514B9A9A6827A - 6F88EF58CC2799ABBFF4B34EEED5CD745CDA61F71EBCBC23CE14A2E9DD7C67FE - E27C58A216452CB9309DB33C63AC8289CC0E10B3232710A32332B765F45C133A - DAF3D9FCFF00CE7B3F9FF9CB89266DDF4FB73DDFC7FDE3381DCB7D57BFF781AC - EDAE37F98FA716CC689F6FA6BF700CC3BD279F59FF00BFA77EBFF5CA588E3191 - B9C6433C68C257A47DB3398E18F29DFB57F3DB8D121F416BFC72190D7ABFEF03 - 01719D7D3B7FEC7805DF666EFF003BDE6715B34E8EE3ABFDEF822852D3031016 - 549E866ECCF01A2F9428AF6F49FDF180A021285F442A673A9EB78C506B1D01A0 - CD237E9406F60400594469E99B95D261C92442520C45B6963D83318E5A610DE7 - BF561F983A78088C05CA9DB94F341C6BAE1507A80480C285C081C48C0A6320A5 - 04357C1496306410B8275E3F5511FCD702B339F6FF007833D61AF6CE3DF8BA0F - 82F7CF63F8FDC1886F814C5CD966B41121C9171658E6ACF7C6DF3EFC085C3A75 - E9E3FA720C6704D80502C71B7D7FA53BBCA4BE3A54064B832B26B1ED0E02129E - F2FD927F9C10D1B3D7FE1C2C63B3B3846C0F4F5F2FDB3C40A043D33ED37C2944 - 60D131298754FA7DD5319190BB2EF3DAFCCF1CA50132388A9018C83EAEDBC623 - 0C046ACE85D422F9EB87E9EACA87ED0F4B66E3B0642E1C195CC9BB6A862371C2 - EA42808EC732D25F7EE7234350268CEECC1983EDDDEB26B0577183F606DCBC81 - 07000C741036750EBC4381016F9C27FE78C7FED7387E51FF003F9E3121E7BF6F - 5E7A5FC9FEF3D2FE4FF790CCD67AE350D22E42F6DAFDFC5B9E5B7DEDF421F7F7 - FB1C3105EBF3277FBB67DDFBF0336631E72C0FEBF1E4426BEBEB9DF08A117A29 - 9E6C16D46EE63FBFF9DFE8B32F363DEFC6F8A1B67093353B94F5BD7A7C3C5406 - 1EEC0C08E5299BF3BD598CB3373DFF00EEBE670A563F3FF7AFA1E9E20C8A08FA - 6BF3E3BEA1A05732282AF4105EAF2442C3ABA49BC0F6EB33C01818417C31E378 - 3C2F8E86E20657076EE7BC667C19E4196263C67D4FC8F1F30C1759AF4FB77391 - 32839A77B7FAF1BFE78838493D1CF1576FE9424F267E7F31CCBCA7CBC4EC6285 - 9F5FA538E327A02DF529E9FE714831D1A2BE1F53BF2187BFDDB3EEFDFF004606 - 50CF6878E3191196C47C63F4DEB3CDD9FF00B9E6DECFEB9D3E7FAE642F8FA7CF - 9EBEBBE385F467F3FAA35C3B7F3F9E2A42C4AEB69F5D6B9138A65850D9A769A7 - 1713338B2081349416509457D1E14A54B5B3115531E2687CA61DB3CF29E4FAF3 - 67C7D8FD143687BF0EE06C1ADD27D27E5E2145690DFE3E72CCCF8E6AFBFF0047 - 3158EDF3E03FAE8DDE002BDEB2FD03D7D4718C3C45B872DC19188952E21171AC - FEE4AAE73EDFE717D24F5FFCE3964AF92CF9D704584F77DFDF8B566BABBFA183 - 7FD71AF597BF063F8B351A6F0F0231DFC89D7B7E3EA4A375E9FF0079D3E7FAE7 - E53FE72DCF9CFD79ABE7EEFEA1403CFD08FE7FCCF2663EFC64B9961033549C7C - 63A914C8FBE2E18A555ABF37BD68473F54633167E9B3EEFDFF005E9F3FD7E9AB - E7ECF347BF2FC19FA67987F877AF5FC665BCDDF1F72FFCFF00E5A9EFFD3CDFE7 - EE79BBE3EE73AFB3FAE6CFB7F7CFF1DE1FB7FA7357CFDDFD377DBECFD36FA70F - C978E1FC5FE7E9B3EEFDFF004D4F7FE9E6CFBBF7E6C7B9F7E6EF8FB9CFC8F439 - F6799F87D0FDB4FFC40028100101010002020104030101000301000001112100 - 314151617181B1F02091A1C11030D1E1F1FFDA0008010100013F10FF00C1D357 - 42D360040220498722E74A9C2E7C46F857CB9525FB2786218F9EBC6A78BCD7F7 - F1B134C4EBAF969E3AE25B9373DFA6BF1F5CECC470EC2B0D234AA3557CAEF116 - 7AEBA9211DE841D48D6714B59EAB43201309F7DBF4E04896778CFDDE741DFF00 - 8F8FDFF379DA54887BED8606EFF5FF00A040B0A00B195035D6BE54246427EC61 - 984811101E54136B0B86A5457580E022DCEA22028A9512BCDD0251AEB0F374CC - 938224251052523CA06A705C2D0844331E59F6262895358BD10015879BE9BC30 - 21C6F01C04281905CB14A0B1445490C83246312264B41DE9D5E4A9A3A12C5FF4 - D6781F8795A246D8AE3DDF1EBCE6F838EAAA9167DC7A14DAFBAEF82BB523632F - 03341F80BB4E23100BB18ABDC23E1DEC66DBCDB55439581E90EE0F05A000A2B3 - 53D1A5204081F4BCEEFB7E0FE3B8D020A64219E2758E75C8E96FCACF9F7FF787 - A0B1ED004F30963A997EFC052BCC9D3E0FF59C13367AA7E1178E055F67E7AB87 - C1FD7005E8F97F9C34AA47B299DE1FE715053D7F73DFD3821B879B77FBE37A2A - B41ABB7243ECCE24DDE56781022DB8D14575E02DC789E28E1C2C18F02DD0238C - B1CB0857F6A8E20A1AF2F05790107B571406038A094A4606D682C7B1D885BC27 - EB7DCE14B0026FFF0021C9DCC0466408239721FDE5B4C3EA98D808C851CA702F - 02FF005FBF3EF7F4E8D090331264223A089789401304E884A1D8B54749A8AE57 - 8555F5DCE4002CCA2BBACF2B6ED7B2F35BA8408124495D8D054D9C0090880BC6 - 808745DB4492A080464512362F6ADA817A0E094D4142AC849D639E7ED39DDF6F - C1FC4AA70ECC711FF39492E7A9F7FAF042FA61C3CFD77AF3C40EFA7F4E644EA9 - 3F5E4AD72FAF9FA5E4C7CDBDFEFAE18D5B4F7D53D67BE434D9F476FD0CE2C878 - 0E82C0EFAD5F00B7821B323045D15CE5802726B0B161D13AE5046C3368F250F1 - A5B3390069CACF24828967576732F41FCED4EFF49C1D2F228B04BA5899443406 - 498795BC543923856104B28407AE088CBC92D9A19E56A4472F55C02045C8022F - B445622374DEBF0971FDCDC870DE5C663F93F955831A5E11E5DCCB30EA6B8091 - 1AC1CF5429D05840681D891FD8C4C50AC0441175B610EEB4F7D160E713A62B44 - 209A87FA785B47097C8F0EAD058000AAD10927C0F34F90299B05A44F56758877 - 5737A1A59D5E777DBF07F144D92A5F707E386F47E5F8E3443CDBBFE5F8E0ABA1 - D327D4F97855025EE3EB823D8DF5EFC9CFDFDF7C73BCBD5CBC01257FB49FFF00 - 67D78A892D3F2629DF10E790A8FD852A428C09781F75142C7BD51B85B958B9BB - 3A5AE11446217C8E600488111609A944B6085AD623B3C11348E01A698622F7BE - E219B039DF09060868A2261A40B72E11C04868184809FCC3247D101895912A98 - D515B78970BEB8D030E04C106D4E4D15E4B37178BB9720133414A40BAC4390CA - AA78648704F9828AEA0BA31168F609E9E19BCEAD26CCA609D08F66A2A23103A1 - 209D4F425F63E53FBB2CC08C528C16B4CD38F7C20A14A9A66174D2F7170709A9 - 80120045D86874CE777DBF07F134ECFF00E9714F7E12A4EDBD57E9DFCFC7012F - A62FDFBD9EFF00FDE219DE13F1BDFC7FBC10A9D59E7BF9CE3AAFB57822A7AFDF - F3CF1D97C49F6EB83AD08FBADFB493CDECE595469420A60B48D025A1AC160692 - DCC0CF4F22146A8AF3447F536348B123D422880628D0DEFD67D045480B6117C6 - 8A28051E0481829578B6B407AAC001B01D3A0D866916BDE4E695D4508C740240 - 43380C628BAB17A48BF00B43B22B596A90617D0689FA7B8650871770F385E189 - 95060C80572210F5F410A6E14BB6DC058FC8C92714CA2B280882E38BC0C60394 - 038908410025004223593337CF8E3CACD1D8B947121F307A794AC907006C4110 - 56291545D83DD22AC869169D30C36EF27B0EC8D5E9F2743E737B779DDF6FC1FC - 54BE130AC8485DF8F8DF8177C401F3C905CDBD446B2F1C8872CA01445522DD19 - 1E58DA28B8A785F09E6C97E6715A174761827E2FD459DB7D6B9CE4A829401BD6 - 8708201421C91BDC27FC8C1D1CA448B100AC3E11F649CA34912AB80668EC78A6 - D4E3212CC20624761587408C24DE9A63C2F3462330656C7E633354BC956EDD67 - 1EC221A70AFC47B22AA21662C53F12F730ACFA7AC74541C0E01E161E88763692 - 648EE68D1739F2D8E1DD0A5BAB4849DC040E2AFCB1E0B619F2728E2D7916D372 - 5B54021A874F26CC1588004BC55AD1B9204102AA4F98218ED5228E9CE770ADE0 - 85168200445091ABC714B8A78CA32802870B9AF030765EA1D9F00474C009DC2A - 41DAB44100C4217038E1A380151546AC0A9720B2A1F4943088422770E86DAB85 - 09521400DFA35609EA29DEF3BBEDF83F88A05888238268CEDDF13E4A21A00371 - 0A410C835D254CA2F49D808ED70894CC00BC6411A0520150D8AB15A4C0E16ADB - 2C25201462299D82064F92286C145C15E1D061214DB931BD26AF5C2D38C034C8 - 0A53D98473846A240AC148E0C305008608C5A8643B3CB038A901D7E504F4A26F - 958F6B283818B25DCA8E42D7B64646EC21F0D10F09DE5563A64675CE1B7071AA - 0C74DB0A4147917F9B79C63089A6137AD12ED527FE6CD1726C5AD6FC1463AF83 - C11D8024A8DC4FD407C3BC3835714048BEC885C57481340558C4AC68085CCF42 - 8B12B932B1C0888475C1BA20A3D95576809274F92A1B410CFE1396206036736E - 53EADA5752B5D4AF9E326380255D7BA8B04603881C91D12942F746CC5C1DAE6F - 2E8D4A9055D0D44ECF95D7867421DED46F1759D7DBDF3BBEDF83F8C02D170AB0 - C5D1ED77C499C28C64F1E3BBAD0B42F11F1547552223948C8740489E4309284A - 08804B1EEB258DC3BDA69301149BC3A17CAD4808BA08C140D8A205B10316E839 - 2C1D2457B7843582ABE944D8E8BB1D2F807804C32404DD074360EB03894C8B40 - 3543624782F0E83F280214285EDB90BD051C2144D24255C0B3A57048C0606003 - 0C4181671802890D70219E45D8E7C70B53603B8229694AB5D900E14E0BE3771B - A8A00DE1BF02C7B8D681490CF0F6700CA173CA1262CD294E3C488E8732AE510B - E3326544055C56852EAA1898BC9E0625F3077B046912695048F9260707005AA7 - 34C168A858BF00DF180C7A622C038481A89ED74A911AB8C549EC0AA8A1235521 - BAF47A72C34F5D359D6D7B1318609F23DC89533A115D452983928AAC84A5A7A8 - F43127561E8BCEEFB7E0FE2DFB05014076A1A82CF2C25E185365FD85956BD02A - 8F6A82355EB59566A2DC1B21A2BFDFA7E5323F1E0E4BA5EB1AC866A68C909441 - BC8D2D1ED08D80682528437251028D554880F92E80E1071545FC3B4E04422EF7 - BC35601B2CCB5DDC40884528E1A7C562C25AC221583244220CC31023535BC180 - 4E04465A30ECA2529D26A0064E0DB4AD22486888030276200640541DB1AA255E - 89D2B6E41EC460624A8D2925A00D2F08376862A2CA8C3C0120C4470846AE0A8C - 4A1321DA414C54DF63894968C36E344FA77287049478EA8B75C19EA3F904AF40 - AA910828C461B800C9CC3A92C8820A90613A022DA80694E830D66A74A220367E - 945315021F0042887B617CA65B1CA9BFB8C3107370A6BA3E7588D6BBC2097B41 - 45D0F5C37657B9CC723C81EB0C4E975F8E411D1810A8A4A2E47475A74873BBED - F83F88B4A14E74017C5964A0DD6701BE1147940FEB6FDBE0397301894338D505 - A13025ED4AC3C75EB7D77D7DB84822351653A76CF1E1FA3787B246374A10AB14 - 11C2383884124C504E242AAA296398621809814946A848A00EF5386B94B3BD90 - C1093545E81E081D30C379704906A79161E24610000E80880950C04CB2B8414D - 0F66B369A6BA820B0C286A5AC600766AEDD41C40A1CA8C8E8C2A435C0F9482CA - 8442F759407D8BB708705B514CC9A2A1621171AA1400D708EA740831878E7B15 - 3E50EA42E0F5A5BF7910618B85A9625730C6F3C16908676E984A846740715F51 - EE68253C92629CC3CC018C144010649B60505205D8B442A46B8D1CA9C3458066 - 422425A0F0D5BCAAA4262D5012A2082515E323264BB03C47D6603AB93882800E - 5B45042089E5DAFA3943B0883BF20734CDB6F5B74952BBA069F74123DFC47BBE - DF83F8B17F7BABA44BEA7B3CCCDE10515E8A3953AF94128231C04DE6676B7526 - 935092961F1DFEFA0F9BF1D64ED15ECD0D2F9D1C7F1C1B1D42A705647D1E2077 - 211A092D4BD30AC229C2817110309C58B625627A543FD0D5152B604DE0019CCA - 723200A80A95080207B3ADB22037621D9707AC79A6589BDCD495B984B66540AA - 5CA13451C091BADE1C0A2900015170CE17F052F05AC450A60584AF8277FC08CC - 4F41D140838E84D1D214E0B79F56C163405988591B6DB384F484AD1C7C410657 - 90D07865CC0CF0594323C037403300C9BEC011AF86A800116D7CEA881669EA3A - CB0F814F48471197402D8486ECEF7DC1AB0AC596931C3C54E927150F5691E8DA - 3D844B167305AB40E826E8DCF06CF2E053452980B55DF7B75FEF0D24A0881086 - 236B218106ECBDDF6FC1FC56914D3E73CB8C25EB3E9CA9B5301E21A124CA9054 - 1624750E1D918873D9CD49D47EDF53D71A03549515A00AB80035405423C49C43 - FA68B7972D1EFED5E9DCD203CFE171CC86F60A42BF0479F27919CCD3302C1661 - 4861A0222399D646E4F8070212856CDAC306BE012628A152F69578A378A6F62D - 1671170BFB8D8D70736174C022A002F0F2D7E41001052AE01A05030001340881 - 9E6FE3DA74D6A7AF2B6ACFCE576C7BBE78492B3452730090CD4016DA09C00778 - CAE834955EC641E1455E89E2AF953BD4046972724545521BDE42D078D0E046D3 - 8662A4ACEDD3C72A103897204D358A05C758F904451F130804D3574F0A343BB0 - 8F7C81456814E9F4E1B7A89AEF02432E84014077B0ACFF00BCA3934219A15299 - 27B8F453BBEDF83F8E58AAC28BDDEE257A56BE38EB8B2F6F968F4DA4E79518C3 - 7460A0D0411028FEE7E3E1E4010B4006B60640428055386E203B1E52B0238BFF - 000276312945892693A022847E36BCE3F0491C1CBFAEEDF11EA5990011332A04 - D4E9EF49345C1C3E286FF3004615BB7637C5A8A4DF0B9A1001914781B2CBB1CA - 51C9991BBEDA110E69C1BFC8A20654D612F00A7932BB1D316ABE59AA140BCF1B - BC3A0B419FFDCBB29F3CB278A50E691E0A18841BD9B4612707D459EB1B24151C - 1986EE7500BE42965431AAB1244623368F04D4C52BF3D6A2D36E7D22E53596C7 - 509F715261542D055282B14E58A1000F23523A6A50CA2BE70EC4D796BDEB377C - 1E54CBA5B3AED100D711D300BE53CD72E3CB094DA11021EC8C7D29829CEEFB7E - 0FE280B4E11A0CC56E8E81E13CD9081374B0E8457844353A6EF104B89DB5BFA5 - 1B5CD5E74B2EFCFA3D27AE508CDF27643BEBD64E10D2E2EA36D0250A0E94D769 - 6B8EA02F1C2051C0409A424DBA2301403603B986BA14132818D69C1B119D0F01 - 66A015C1068BD091955A70109529579C8621E20EF7AE09C3FA8822B704CE0783 - A82308FD2606A4B39E794C92EA0AFBA9490331410F819828C48411868C4F2705 - C2CDD22A6A1798928C26101E160404708200F065365A2621A8845F883B490E06 - B7AEEC718E083ADEE770A14013202F89A682A2D82DD7C04B4624D595463C1C99 - AE515805900B7309C81AAB8B613A669C3D0FA874D48EC768204700804B4AEC91 - 47EE7778DF8421520B009F02450AAE51FF00A3645A3D94DF18F2EDB469E984B0 - 317C7A4CEFBBEDF83F898FA5C34DD023412C99AC6DAF30D644740AC2821BC481 - 54522FA0BAFAFDC976F3A3E9CF107D8BCBD89FE4F7CB664824C74C125BD680A0 - 418E545C8024C23255C5E0710614D495D82865C393334685CAC263282B4C456A - F8844648E4BB38384C470BA1B8109892DE3A9E91466F80488E20F05012008006 - 4112000040C88727E50F013613A3EC2FBD0ED29889A40955D85A570BC3140090 - 4203D1E01890294426640B8A56035B635B6453A795A081652345A885BC83C21E - 513AA7D24D1747173B64AB101E9EE2D1745A2F9E21918BC05043B4C53B6A093C - B05330D5453DD20DF9B38274FA4A00006395C080A51BD43944056DBBE447D843 - 6AA84170314019C73D4114B8824C010C56AAF19BA010D536DE1475AB252B2F00 - 31D25F34EEFF00FAE06C100517BC41A1F53C8DBCEEFB7E0FE32468F08C1DA08C - 2802F1B87199DB8A636E180B034025654438CECCF081CE82672C6FBFBF0AC33C - C750047ED61B66F9E5B401A1940BD13ABB9E271BD138BD5246A015695C909A02 - 34B90D16B02451A458230105C243080E22A85720691645431741C5FF00AA0040 - 10000E8980829C15E500458258E8B7463D311974748A03E7282E836701C44202 - A8A2F24002760586242E07B2106C01102BC2E9EAED2C23144022088F06D9EDA8 - 0DB5A14DC2400821326689912B09894904C214081D57CC820ADA0828664A062A - AA3A68E89FD88385151F03009565A6276157197186DA811645D8A28B42AEAEBC - 3B266D148310A1E54085948C6BC574A9608083844180486851EB3AE2A85EC105 - 12093E80CF34E816C9068159E9A00F452D215E8D5565E0ECD01DA554CC5560A9 - 83536A8A58AB8AEF4AE1CEEFB7E0FE27490340E09145EB57000F055C8E589757 - 507FA2163203E7B278F5478D37DA18ADFDFDFD9C2D3E5F73A5D3E17AFB78E07A - A6C01B6D02888852B2F1AC1477D7B0E0C8008336E0E08DA82D8462917026B4B4 - 7AA0CA81037B38112825841051069D81780C217347351B095695B1E3FAD6F991 - 4210115A50E67A974D07D1215E92F795423A854DEC96A0B9CB3266638624D1B7 - 86205BC2F35C6408A56F07500EA5AC948712384C82F331903CA076A36EB1D650 - CCFE0021C0268007C0AF17A2C44124820A32E9EB89A0108543427A241B0A13C2 - C16E6A135280A81A7120863E2EBAF7BA812671C0E68DA96E9330D7128786F42A - 5B9071529E445F5E209544EE015ECF4840678F7C6C95C3045884F61F03E73154 - 34438C276060AD559E738F86122D798BB234BF3DA73BBEDF83F8A22A86E9A9A5 - 86C3FAFEF991A3295305EA125053548876A29E9174784CA63DE70D159F3D74F3 - B2A1A3401022F850079743BE205F1498F581887BC20D1E4128AC260211828C8A - B41E0E6390050EFA84358714FD89DA5358588FB52E13B86E62C5B3C522141D93 - 5CC9A075C4AD040E2A2C783F478A882698B0388F0BD3C1898D7E14712935FDB4 - AAB6053770E24CD02B9DC8B04CFDC18700BCCBC740183015C8D0E3CDBB93630A - 731229A219769427F01E78FB0F02D0B503449071532EA203048982A5C3D2E188 - 5D0341E14D0A02839ACB2A65150403509C318ECE263658530192424AA0C8EDF8 - 06AAC9B46B26085D71A84EC51894761943C82943C8519206F6560CB3E48938E4 - F198D41A13571F57C3C6709D736025566D313C0EEA14493AA86C292DD571275C - EEFB7E0FE2A0DE9CFA747D3CDF89F40958106B806C08CB31112BA141E83B5D40 - BA0AD53CF53842C649EF121F545A57C716B27305241E18417418CE0E00408631 - DE211A53C9C573930DA4059025C1112E0F2EDECF1205C0F48F0FC55A233548D5 - 540AE4635A035CC50A104A2B710708E710954C514985E115C95D4A207024588A - 210B1605624169A735A335C7324E4AA6C9011354F623CD565C08E40564124806 - E43E31B6355A6D3185DC209C0401A6C3CE01D702CBA5301E0D3A21B62880300B - 6CA288D49A5064DA0C621302C0B3EEBB4D58324C6854015AD31435536112EE1C - 7435258CAFC02B1E97064E08D122D46EDE4C2F14B290245351CDFB7434114168 - 10E81161905464F1CB52B7C02B9450EC2A683C0D2C26D07E22224ED7EFDDF6FC - 1FC5903DFF004C4EFA5197FA380BA1F39D644A0453C3DA3C9625449808DCD9D9 - 9C807E677FDDEB92EA33FD4D4BFB9C4DC78B15269052A062EDF7D57341E9BC1A - 8514509C08E69299240E89161D9684EA070211026770A96694E0CE4EC850D95D - 1383D591451C5A2BAB58DC1B47101106A60D3C8A0A9185E1B9702C58055C1681 - 4766718B7582A001205C416B54E2DCA964C84C03922C349FB91D08A69AF074AA - 749220192913E5C019404005D45030678072CA1667438384637D9AF7CA92F2B8 - 55299A2092060E2378BF100C6BA05B23AAE5149968C077A401982A5C814D2DB2 - 600AF581851657847E2D8948A206F83AB16F938E5F76F17AAF024A72A8502929 - C215895BA455D0F5020EDB6FC733184F69A027692037E219C075A2BEC49A6DA4 - DE89E479DDF6FC1FC5256838F5E107EECED8DBC028C58A68511C0BB8924E3C7D - 40CE943E3E21DFACCE360AE367C4E60028AA999A536F93A7E463C759A0686020 - 08042C0A0901808AE0211A00EA8B5A4158811515E3694A44A9727D4520C02248 - 5F0144F2CD48B26524C4006721514A1AABA558DBB61F438D20CAAA7E901CB83D - 91C137BC63C407105EDD12E2DD8226462D1D5096046CA5612193CC820E066D0D - B09E10AC69048588552BAF406DB3820CAA08AF492E456B521C22140BC5444481 - 53A00401018E2C12252A5491623030BB81D6F4C03CC7836263F137FF0068AA92 - 5604C194590A8B9A3BCD44BE0B80CAAB45F3D54EDF1FD883AAC11286398FB3C9 - D31EFB384366E196CD591AC578C15723589E1A811788652C0955829A556668AE - EB7AE384C4E322507A5009B7CBC73BBEDF83F8A47EC83145B06F712CF490488B - D582160096F1E008782AE53C70A829810614F2AC2E42FD3CBF5E4160875E00D0 - 5B83283DF4704B02172A44290342A10E1745935330132600FC845431B0292F42 - B7B8E363FAEED0800BED00259C330DCB0458EC3A58556FCAEA794A5969470DF4 - EF19362430533D4846940F42821D1CEA00E4B64489CF308F924CDF3078F04C43 - CB40C5627453821628E8EAEB1954C4E43C36E85B72044A2C6415B256EC008A6C - 90A0A8B64E54F4CB0BEC98BC082AC258CC870553F99C80D0C07A50606244740A - 0A38BD5C24FE54212E1DC40FC8340B47D043940C52AAFB7D676CF07AFF00793A - 89FDB06BF1D77E738C6149D2A2DA1208F838C4BC5DC1D7D3F5C726DA7151F193 - 20ACB580151C09D04CAA22FD704A292F77DBF07F1A9095716C5584192D619CDA - 5DA7C697B66C049FD89DA6CA6BDD57E935671C4FC7EFEFBE22C2A547C3761D65 - 64EDE4B13BCBBB5C2BE61DC768E50ABB419D0BAA0FB1413727963601B5810207 - A759F27F5C00021A4E803B8EB3F88630F81645A12E98F72AEF5B3FEF0F9B7434 - 86133A1F029A2CA0912E9130A0A20790E174944DC5CC61C3399FB3ECF5301251 - C48949F729F4D09A25949E4CD418246F083195DF443984A820BC34206F3FD69D - 3ECCA6E28D71E985A8AA158CDD51A805855239DAF837302E4BB139D6CA644C37 - C68DE0A0EAB278FF0087C70C7639325DC29DE712234C760FC765FB9C3032A459 - 406C140960A0BE38720EA5CC1620A6728EC2717461CA4064553AC7489A2071A3 - C14D0C62494DB58FF2AFABF53F11FBF247DA807D44BF6B7E64E489D07DFA7AB7 - F3C247E4F33F7E7E39805C5F2DC7E9FDF10FE0C63A3CD36F97AE4AB9AC37B679 - FD0042D0700B1F5E1D19603523836A7FA85AA3472D8F86AD45028379C0F20817 - 5C40A7A5858599053D00780C38351519287045662B57B7156A974302DA21246E - 014E45F77DADA08F7D4090A24CF54039428A5AF5A882D3F21AF0FB124468AE45 - 2C960008173128142F805B7D5372CF54BB2835206B91B2B833098FB5651CE16E - EDE191F4023E809DC7271A716832F073A0A30C96F8FEBDFF00FBF0E6F573BFFE - F3F7E382876A967807A018F5BF1F48B110E792FB5613AB2799E1E46A801C0424 - 1DC74CD53C15D6C89A0BAB82C8C3BAAB78A1634AFC901682C7691127126C02D9 - ECEC5A2D0B8CCFE4CAB23A90C6FB65EBA373E8A60FFBE9FB7AF33E78005713EC - 8ABF617F671C207BF3F3C2CC5E9F269C313EF9F74E35117E8A8C50589A658D38 - 2A8821B6E3FD3A70694BC2EAF4C87A9DFE7846CD759E3C6FF7CA869E8AC80346 - F6289DB0DE5F948D3409A89525B74BCD192E09128D60122A509489CB415370AD - 983F7DBE5C9CBA1C6695C696E42EE1A707C45D1B56A116936B4E9C3EAD15B580 - 8213C5D00A6F13E88302A5D008094DDEDE1F7D9C252AD178D4E5183FB5DEA75A - D0E3A2358E764D94728836082E1471040C511146522E9441CE2802C9D0F2B7CF - C3C7C78E2862005DBE3E83EF968984C926BA0275F6179308E1A5247C1745A828 - 39162592912A442C6279DD43273B92751EC951F25ECF19C68005AC961574EA50 - A506294FE307C543B924C67352C3385603B6EB70363EEA91F7C64BDC350089AB - 28DA22C4671A52690613304354DAB38C2D3CE062010231F067BAB9300988AACA - 46AA0255F8E265AA50CB0021D752E7BE120711CA763E501114F277C1BCBF1BC2 - 6452028005521CBE69A9923542D348845478D773262CA147F6BA6EA935ED4390 - 6DC8A9807445AE4A9CA81D2A024A5900B92053DC070054F3082F02CCD8F8A516 - 6A56A45068291A0D59D48051D9C3B2A566E88280753CC0C46148445314D8EE0C - 3990A47C9C390DFA9C28519FCD0D710C842B478311B3B6B854846A1643BC8702 - C863A7CCE92312913898083C6294E957D8DDB4A2283672752544CFFBF6E15C8A - 25EE2AC145BD0A00788C845D00514C95540AF5C0383D74C500B4C750145401E8 - 000470C5742F2021803EB87E8346081240D1DB0B04FE329D63E6EE17FDCE44E0 - 89136848CA505750CCA9C497403F50A21D6F5D67E589CB208A1DBBF7D78DEAF1 - 213126250A20FBD9199F1C8353C4D277D1D77F0FC9DF11054C6EB20300007660 - 4510108ADC3A755A515D700060AA585B6FC69730861C46490442D34445584198 - A317D5423060AE5C958A6E702880461D8D080EFD7435BAF2B8F28C9EECDAA4B8 - 2009CE3242A8C983E4848A1C5647040A2EC2002866B5C2AF181CD25AEAE03481 - E0D88011714177AED467D34E36636ED70F181C20738971248DD414C828813081 - 47647CD412D47803CB9B3B1638241205001224877DAE1255010A51068587A20B - A728C970910A8EE8213C1831288B2D12151228033D398113B2840AB1B1291544 - 100CE1A8AA010F4503090C433937412034E808219148664E048123B6119DA099 - 3804C72389EF8E2C44813FE426A587CDFE78D9005F63A033B40B7AEA3BC86002 - 405817E6FF005E3E9C0C5533CBFF003DF4F683792719C215023CC88F9679560A - DEA5632958283301E0C0901423C80003500308E358F82BEA87F1F9F5C683CDBF - 0789F5F9E068638885810268740C6A38A34C0B0341A0457427C4E0282BAD7B7C - 4613207BCDAEF1017B663EBC1D4F3FBD711C1C5045A916214C92E39565064A49 - 662480142748ADE018114BCED559F387866AED33A03F726D932D2DAA7E7450D5 - E6E2823C6D0107B5480140C50008C94229901203ECEDEA837881175821052564 - D3161DA2BC04020005D7CD5D527BF10CDBD3B0254196025FA8FC7738DE40FAC7 - 4B1ACA155D50F1436C1BD88428B13551ECE0AE372814453EE8331F083E260A01 - 68F7C20F4C2099B38C1E02D03A01712232C78E0A155EA2F46F6A8187F2B03202 - 11F4074E7084A8F35EFD787ACE512E00BBA9761E6EC2BBE7D060053E5BEBEDE0 - 5D8C1151EE27D032FB3CA2A5210A461AC74D9DB82F83237198EC773F2AEFAD53 - A3A5AD533EF3BF7BB88D1300DCEBFBF5C1F459C08A650BDA020B0B3832D1548F - 9F93E02C3DCC9C22C41B3E55E7EBF9E0B625F1FDB7BFF383220BB7498F8B77A9 - D670BA46AC2114B913AD2530F0CF60B9A63666AE30E06E4ED4BB40513625E2A0 - 88415491C8DDACA138C94569A0069C67A4FA8F240D2E1222B775D3444F31F7C3 - DDD843C867824CA2B92CEB229519E3352F6F6F57888164CBFDECF7FBD7090203 - 7BA7AAB988F51DDAF2A6D140A1E57789D1BEB8C2322AB206C079211A50792C04 - AD5404DA8CEB05A6D919D61ACAAE1A348811EFD955038FA082C1CFF27A1F43F1 - FF00BD8FA9F9E7E8BD3FF2B7E83DF3FAAF7E7E9F779F91FC3CFF0053F27FE2FD - C7A79FB9F5CFF77E2E747D3F1E3BFF005CE7FD4FC9CFD87AE3FC5CBA3F5D1CFD - 1F5E3B783B38BF47EBFF00C0C8B8F03FFFD9} - Stretch = True - Visible = False - end - object Memo4: TMemo - Left = 8 - Top = 8 - Width = 161 - Height = 369 - Anchors = [akLeft, akTop, akBottom] - Lines.Strings = ( - 'To the right is a list of authors ' - 'and contributors to ' - 'TurboPower LockBox 3.' - 'Not included are the authors ' - 'of LockBox 1 & 2, as there is ' - 'no common' - 'copyrightable content ' - 'between them and LockBox 3.' - '' - 'The LockBox 3 project ' - 'welcomes any contributions. If ' - 'you wish to contribute,' - 'and your contributions are ' - 'accepted, your details can, if ' - 'you request, be' - 'added to this list of authors.') - TabOrder = 0 - end - object lbxAuthors: TListBox - Left = 175 - Top = 8 - Width = 138 - Height = 121 - ItemHeight = 13 - Items.Strings = ( - 'Sean B. Durkin' - 'David Barton' - 'Nick Chevsky') - TabOrder = 1 - OnClick = lbxAuthorsClick - end - end - object tsSupport: TTabSheet - Caption = 'Support' - ImageIndex = 5 - object memoSupport: TMemo - Left = 3 - Top = 24 - Width = 286 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'Support can be obtained through the ' - 'forums at:' - 'http://lockbox.seanbdurkin.id.au/tiki-f' - 'orums.php') - ParentFont = False - ReadOnly = True - TabOrder = 0 - end - object memoHelp: TMemo - Left = 295 - Top = 24 - Width = 333 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'User help for this component suite' - 'can be found at' - 'http://lockbox.seanbdurkin.id.au/LB3Help_H' - 'ome .' - 'If the help is still partially' - 'under construction, please either be' - 'patient, or offer your own content.' - '') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsAlgorithms: TTabSheet - Caption = 'Algorithms' - ImageIndex = 6 - object Panel1: TPanel - Left = 3 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 0 - object Label13: TLabel - Left = 16 - Top = 0 - Width = 116 - Height = 13 - Caption = 'About selected Hash' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblHashDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label15: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblHashDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashWikipediaURL: TLabel - Left = 16 - Top = 136 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lblHashDigestSize: TLabel - Left = 16 - Top = 184 - Width = 97 - Height = 13 - Caption = 'Digest size = 64 bits' - end - object lbxHashFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - object pnlCipherDescription: TPanel - Left = 299 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 1 - object Label20: TLabel - Left = 16 - Top = 0 - Width = 124 - Height = 13 - Caption = 'About selected Cipher' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblCipherDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label22: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblCipherDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherWikipediaURL: TLabel - Left = 16 - Top = 141 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lbxCipherFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - object memoExtraCipherDescription: TMemo - Left = 16 - Top = 192 - Width = 233 - Height = 89 - Lines.Strings = ( - 'Extra Cipher Description') - ParentColor = True - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 1 - Visible = False - end - end - object Panel3: TPanel - Left = 3 - Top = 231 - Width = 270 - Height = 146 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 2 - object Label27: TLabel - Left = 16 - Top = 0 - Width = 170 - Height = 13 - Caption = 'About selected Chaining Mode' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblChainName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label29: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblChainWikipedia: TLabel - Left = 16 - Top = 120 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lbxChainFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - end - end - end - object btnClose: TButton - Left = 280 - Top = 416 - Width = 75 - Height = 25 - Anchors = [akLeft, akBottom] - Caption = 'Close' - ModalResult = 1 - TabOrder = 1 - end -end +object TPLb_fmComponentAbout: TTPLb_fmComponentAbout + Left = 0 + Top = 0 + Caption = 'Component About' + ClientHeight = 442 + ClientWidth = 640 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + OnCreate = FormCreate + DesignSize = ( + 640 + 442) + PixelsPerInch = 96 + TextHeight = 13 + object pnlAbout: TPanel + Left = 0 + Top = 0 + Width = 641 + Height = 410 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'About Box to be developed!' + TabOrder = 0 + object pgAboutContent: TPageControl + Left = 1 + Top = 1 + Width = 639 + Height = 408 + ActivePage = tsMain + Align = alClient + TabOrder = 0 + object tsMain: TTabSheet + Caption = 'Main' + DesignSize = ( + 631 + 380) + object Image1: TImage + Left = 0 + Top = 0 + Width = 225 + Height = 329 + Picture.Data = { + 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 + 480000FFE1004045786966000049492A0008000000010069870400010000001A + 000000000000000100869202000B0000002C000000000000004170706C654D61 + 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 + 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 + 50504C0000000049454320735247420000000000000000000000000000F6D600 + 0100000000D32D48502020000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000116370727400 + 0001500000003364657363000001840000007377747074000001F80000001462 + 6B70740000020C000000147258595A00000220000000146758595A0000023400 + 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 + 0002BC0000007976756564000003380000008676696577000003C0000000246C + 756D69000003E4000000146D656173000003F800000024746563680000041C00 + 00000C72545243000004280000080C67545243000004280000080C6254524300 + 0004280000080C7465787400000000436F707972696768742028632920313939 + 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 + 00000000000019735247422049454336313936362D322E312039393132303300 + 0000000000000000000019735247422049454336313936362D322E3120393931 + 3230330000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000058595A20000000000000F3510001000000 + 0116CC58595A200000000000000000000000000000000058595A200000000000 + 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 + 595A2000000000000024A000000F840000B6CF64657363000000000000000549 + 4543200000000000000000000000054945432000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000064657363000000000000001F73 + 524742204945432036313936362D322E31207352474220393931323033000000 + 00000000000000001F73524742204945432036313936362D322E312073524742 + 2039393132303300000000000000000000000000000000000000000000000000 + 00000000000000000000000000000064657363000000000000002C5265666572 + 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 + 36362D322E3100000000000000000000002C5265666572656E63652056696577 + 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 + 0000000000000000000000000000000000000000000000766965770000000000 + 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 + 000000004C09560050000000571FE76D65617300000000000000010000000000 + 00000000000000000000000000028F0000000273696720000000004352542063 + 757276000000000000040000000005000A000F00140019001E00230028002D00 + 320037003B00400045004A004F00540059005E00630068006D00720077007C00 + 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 + D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 + 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 + 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 + 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 + B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 + 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 + 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 + 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 + 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 + 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 + 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 + 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A + F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C + 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E + 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F + CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 + AA11C911E81207122612451264128412A312C312E31303132313431363138313 + A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 + BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 + F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A + 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C + CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F + 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 + 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 + 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 + 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B + 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E + 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 + F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 + 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 + 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D + 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 + 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 + 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 + A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E + 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 + C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 + 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C + 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 + A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 + E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C + 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 + F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 + B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D + A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 + BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 + FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 + 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 + 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D + D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 + C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB + E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 + 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA + B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 + 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA + 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 + 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA + 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 + DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB + 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 + 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD + 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 + 0202020202040303020305040505050404040506070605050706040406090607 + 08080808080506090A09080A07080808FFDB0043010101010202020402020408 + 0504050808080808080808080808080808080808080808080808080808080808 + 080808080808080808080808080808080808080808FFC0001108014A00EA0301 + 2200021101031101FFC4001F0000010501010101010100000000000000000102 + 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 + 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 + 627282090A161718191A25262728292A3435363738393A434445464748494A53 + 5455565758595A636465666768696A737475767778797A838485868788898A92 + 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 + C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA + FFC4001F0100030101010101010101010000000000000102030405060708090A + 0BFFC400B5110002010204040304070504040001027700010203110405213106 + 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 + F11718191A262728292A35363738393A434445464748494A535455565758595A + 636465666768696A737475767778797A82838485868788898A92939495969798 + 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 + D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 + 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F + B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 + 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C + D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 + C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 + DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 + 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C + 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D + B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D + FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB + 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 + 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 + ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB + AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F + 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 + EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 + DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F + 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 + 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 + C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB + 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 + 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 + A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 + 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA + 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 + D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 + 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 + 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 + 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D + 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D + 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E + BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 + 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 + B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 + 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF + 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF + B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 + 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 + 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 + 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 + 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E + DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 + EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 + 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 + C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 + 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 + 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 + 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 + 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 + 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 + 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 + E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE + AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 + 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 + 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC + AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC + 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 + EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 + 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE + 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 + 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A + 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C + FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 + 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E + 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 + 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC + 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 + 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A + BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF + FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB + 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 + 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 + 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 + DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 + 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 + 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 + 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A + BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F + 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B + E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C + 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 + 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A + 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 + 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD + 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 + A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 + C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D + C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC + B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE + 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 + B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 + 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 + 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 + 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 + B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 + 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 + 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 + 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A + BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D + 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 + 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 + 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D + FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 + 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 + 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 + BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 + 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 + B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 + 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 + D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E + F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F + B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B + 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 + E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A + BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 + DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 + D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF + C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF + 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 + D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 + 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 + 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D + B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 + 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB + E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 + C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 + 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 + ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 + E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 + 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 + 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 + D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 + 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 + B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 + 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E + C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A + F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 + 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 + 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C + D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 + C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 + 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 + 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 + 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 + B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 + EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F + D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 + 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 + 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 + F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 + 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 + 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD + B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 + 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 + 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 + CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 + 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 + F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 + 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F + 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 + 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A + FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A + EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D + 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F + 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B + E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 + 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD + FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA + E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 + F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 + 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 + 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 + 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 + 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 + FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 + 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB + 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 + F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 + CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 + 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 + 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 + BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 + DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 + ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 + 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 + 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF + 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA + EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 + 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 + 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 + 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 + FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB + 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 + D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB + 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED + 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 + 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD + 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 + B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 + 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 + 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C + 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 + A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC + 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 + 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC + D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 + 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C + 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 + FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B + CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 + 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E + 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 + B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 + AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 + C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 + FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 + 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 + 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE + 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 + 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 + 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 + F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 + 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC + 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 + 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD + E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 + 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B + E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA + DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 + 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 + DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 + 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 + D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 + FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B + F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 + E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF + 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B + 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 + 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 + 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 + 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 + 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F + C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 + B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 + 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 + 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E + 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC + FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F + A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B + 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 + E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F + 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C + F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C + 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE + 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 + 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D + D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 + 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 + 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 + 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA + E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 + F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF + 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 + E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F + 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 + 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 + BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B + C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 + B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 + 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F + 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F + C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 + 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 + 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 + 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 + 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F + ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C + C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B + F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B + 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF + AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA + 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 + 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 + EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 + 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 + 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D + 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C + C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 + EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 + 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 + BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 + 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF + 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 + 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 + 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 + 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 + 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 + 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 + 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E + CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 + D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 + 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 + 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F + B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB + 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F + 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 + 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B + 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 + 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF + 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B + E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B + 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA + 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 + DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 + 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A + F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC + 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D + 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 + DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF + 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED + 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B + F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 + DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 + D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B + F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 + 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 + 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E + 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E + 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B + E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F + 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 + 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 + C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 + 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD + 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE + 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 + F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E + 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC + 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 + D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE + BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C + 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 + D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E + 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 + 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 + A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC + E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E + 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 + B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 + 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 + 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B + B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB + FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 + C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA + D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C + 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED + C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 + 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 + 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B + 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 + 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 + 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 + 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F + 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 + 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD + 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A + CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC + 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 + 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF + C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E + 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 + F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF + D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 + 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 + C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC + 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 + 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF + 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 + 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE + DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 + AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 + C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 + FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF + 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F + 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 + A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F + E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 + 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 + F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 + C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE + 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 + 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 + 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 + C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E + 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 + 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA + AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 + E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 + 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD + 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 + FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 + 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 + E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 + 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 + E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 + 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB + 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED + 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C + DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 + DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 + 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D + FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F + 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 + 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 + 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 + FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 + E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF + E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC + 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 + A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF + BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 + C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 + D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 + 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 + 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 + 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F + F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 + B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 + BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 + FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 + 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF + 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED + CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 + 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF + 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D + 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A + BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 + 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 + 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 + 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 + F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B + 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 + E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C + 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF + B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 + A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 + 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 + 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 + 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A + 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A + CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D + 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F + 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 + FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C + 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 + E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 + EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF + 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 + DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 + DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 + FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC + 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 + B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 + 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 + FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 + 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 + 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D + BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 + 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C + 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA + B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 + 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA + 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE + D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 + C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 + DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC + F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 + 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD + 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 + 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD + 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA + C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE + CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 + 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB + DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA + BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 + 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A + E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 + 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 + 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 + 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 + 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F + FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 + 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D + FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D + C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F + 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED + 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 + BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 + AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 + E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD + D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 + 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 + 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB + 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 + 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 + CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 + 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B + 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E + 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 + 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 + F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C + F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 + E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 + 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B + 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 + D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 + C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD + EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF + 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 + F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F + 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 + 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 + 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 + FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 + DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 + 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E + D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 + 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 + F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F + 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 + 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E + 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 + A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 + E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 + 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 + 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 + 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 + 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E + 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 + 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD + B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 + A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C + 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 + E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E + 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F + ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E + F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD + 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B + C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 + A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 + A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 + 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 + 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 + 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A + 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E + D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D + 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA + C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF + 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E + DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A + 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 + 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A + 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB + 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA + 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF + 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F + 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 + FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF + C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C + 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 + 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 + 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 + DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB + D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 + ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 + 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 + BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 + 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF + 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 + 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 + 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 + 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 + 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 + D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D + 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF + ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B + 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 + EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D + C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 + 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F + B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 + 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D + A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 + 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 + 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 + D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 + 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 + A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 + D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 + D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 + DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B + 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D + 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 + FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F + 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 + 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B + 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E + AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 + C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 + F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 + 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB + C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 + 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F + C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 + 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA + 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F + B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C + AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 + 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F + BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 + A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD + 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA + 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B + 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE + 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 + 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 + D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 + FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 + 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA + 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 + 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 + 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 + 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD + 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF + 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D + F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA + AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 + 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 + 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 + 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 + 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE + EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 + 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 + 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 + 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 + BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C + C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 + E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 + 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E + 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 + 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA + 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 + 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C + 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 + 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 + BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 + DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E + 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 + 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 + 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 + 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 + 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 + 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 + 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 + C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 + 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 + 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 + 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 + 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 + 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 + F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 + 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 + 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 + B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 + 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB + 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF + 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F + CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 + F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 + 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC + 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 + 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 + 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 + DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 + 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC + 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB + 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 + C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 + 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 + A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 + 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 + 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 + 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 + 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 + BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A + EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 + D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 + 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 + EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C + 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 + 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 + 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 + 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 + F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D + 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C + 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 + 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F + 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 + DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF + 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B + 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC + B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 + F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 + 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB + 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C + D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 + CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E + 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 + 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A + AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 + AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF + 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 + 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 + 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E + 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 + BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 + F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E + 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 + 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B + 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 + 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 + 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 + 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED + 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D + 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 + F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 + 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA + 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E + 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 + F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F + B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC + 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B + 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 + 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 + 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C + 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 + 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF + 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 + AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE + F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A + 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 + 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 + 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 + AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 + B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 + CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D + 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 + 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 + 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 + D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF + 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A + 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 + DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD + A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 + 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 + E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E + 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 + A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 + F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC + CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF + 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 + D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE + AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 + EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 + 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 + 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 + 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 + 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 + 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED + 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 + A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F + 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 + C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 + 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F + E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 + F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F + D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F + AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED + 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F + B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 + 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 + 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 + DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 + F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 + 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 + 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 + 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B + 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 + C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 + 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C + 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 + 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 + 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C + BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 + B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 + F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 + 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D + F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A + F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 + 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 + F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC + 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 + 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D + DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 + 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 + F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 + 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B + 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E + D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B + 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F + 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 + 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D + 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 + BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 + 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 + CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E + 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 + B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 + B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 + C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 + 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 + 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF + 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 + 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B + 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F + 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 + 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA + 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 + D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 + B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 + 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C + BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E + 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 + D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 + BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 + DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 + B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE + 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 + 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 + D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B + 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 + 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB + F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 + 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A + CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 + C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 + 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 + D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D + 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 + CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F + 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E + 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB + 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 + B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 + BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 + 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 + 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F + 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 + D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 + FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 + 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 + 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB + E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 + 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 + F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 + D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 + 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D + 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 + 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 + FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E + A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE + 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC + 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 + 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB + 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 + B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 + 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB + B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 + 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 + 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 + 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E + 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 + 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 + FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED + 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 + 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 + 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 + F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 + 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 + 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E + 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F + 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 + FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 + 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 + 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF + 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 + 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 + EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D + 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D + F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 + 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 + 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA + 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB + 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 + 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 + F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 + F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 + F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF + F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 + 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 + B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 + DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E + CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 + 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 + AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 + 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C + 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB + CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C + 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 + 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B + 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 + AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B + 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA + 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 + C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 + 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 + 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 + 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 + 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E + 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 + D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F + 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E + 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D + 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 + 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 + 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 + 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B + EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 + 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F + C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 + 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 + 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 + B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE + 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A + 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F + 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE + 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB + 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 + B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 + 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC + D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 + 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 + 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 + AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF + 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 + 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 + D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 + 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 + 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D + 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 + 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E + 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E + DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 + 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 + B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 + B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 + E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 + F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 + A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 + 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B + 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 + 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF + 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 + 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 + BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 + 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 + F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B + A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 + 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC + BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A + F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 + 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 + 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB + CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 + A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C + 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 + 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 + CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 + 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE + 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F + 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF + 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 + F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB + 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F + 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 + AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 + CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 + ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 + 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F + 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF + 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B + 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 + E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E + 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C + 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 + 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 + 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF + E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B + 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC + 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C + 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 + 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 + C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 + 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D + 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 + 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 + F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 + AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F + 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 + 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 + 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 + DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF + 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 + 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B + FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 + 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD + 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 + C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F + C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 + 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A + FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC + 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E + 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 + BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 + E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 + C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 + E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 + FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 + 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 + 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A + 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F + 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 + 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B + 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 + 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 + D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 + EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 + ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 + E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC + 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB + E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 + 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 + 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 + FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 + B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 + FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD + ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF + 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 + BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C + D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 + BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA + B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 + BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 + 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 + 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 + A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 + 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E + FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 + B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E + 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 + 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 + 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E + D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 + 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 + 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED + AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 + BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD + 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 + 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E + 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF + B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 + E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C + CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 + 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED + 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B + B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 + A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 + 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A + B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 + FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF + F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA + 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 + FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 + 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B + B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D + 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 + 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 + 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E + 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 + BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 + 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB + 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 + C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 + C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 + EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 + BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 + 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 + F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 + C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 + BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 + F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 + F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 + 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 + 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB + 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 + 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 + F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 + 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 + 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D + EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 + 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 + 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 + 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA + D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E + F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A + E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 + B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A + A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 + 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA + 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F + F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 + AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 + 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE + 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 + 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 + 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 + C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 + FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB + 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 + 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 + CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 + 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB + D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A + 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 + 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 + 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC + C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 + D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 + F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 + 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 + BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 + 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 + 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D + 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C + 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 + 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF + B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 + 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE + 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 + 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED + 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 + F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B + B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC + E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB + 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 + 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D + BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC + D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB + 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D + D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB + 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 + F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F + 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D + 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 + F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD + E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C + 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 + 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 + A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB + E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 + 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC + 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 + DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 + 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 + 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 + FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 + 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD + 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 + E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 + 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 + 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 + AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F + 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C + 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 + 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 + C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 + C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 + E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD + 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 + D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 + 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 + F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F + 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 + 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE + 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 + C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D + 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE + 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D + 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C + D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF + AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 + 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 + 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 + C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F + 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A + CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 + 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C + 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA + B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 + 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 + 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 + 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE + BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF + 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 + 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E + 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF + 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 + A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 + DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 + FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC + 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 + DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 + D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 + 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 + 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 + 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF + C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A + FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 + 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 + 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F + DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB + B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 + 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 + 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 + 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 + B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 + 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 + BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 + 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 + FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC + D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED + 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 + FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C + 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 + B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 + AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E + 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 + 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 + 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 + FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C + 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 + F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C + EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF + 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 + 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 + 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF + 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB + 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C + 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 + 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE + FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC + AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 + 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F + 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A + 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A + 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 + F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B + 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 + 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED + E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D + AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD + E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 + 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD + 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 + BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 + B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 + 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB + F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F + 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 + DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F + D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A + F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F + 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 + 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 + F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 + A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 + 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 + EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C + D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F + F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 + D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC + 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 + 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 + CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 + 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 + C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF + 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 + 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 + C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A + 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 + 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F + 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 + B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 + E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E + 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 + B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D + F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 + 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F + 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 + 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D + 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 + 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 + 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 + 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A + 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC + BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 + 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA + 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 + D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 + FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 + DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 + B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 + B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 + 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 + 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 + 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB + D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 + BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C + D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 + 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D + F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F + 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E + 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 + F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A + 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D + 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC + 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 + FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 + 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC + 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E + EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 + 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 + 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 + 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 + CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE + 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 + D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C + 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D + C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF + BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 + 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 + 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF + 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF + 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA + 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 + 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 + 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 + D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 + 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF + 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE + BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE + ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 + C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E + 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 + FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A + F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 + FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B + 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA + 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF + 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 + 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 + 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D + ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 + C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 + 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C + 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 + 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA + D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 + F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B + 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 + 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B + C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 + DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 + 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F + 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F + EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 + 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE + D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E + BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF + 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E + D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 + 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 + 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 + EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E + 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 + DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 + B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC + C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C + FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 + 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 + EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 + DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C + 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 + D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F + ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC + FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 + 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 + 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B + 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B + DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 + 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB + EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 + F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C + 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E + E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE + 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 + F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 + AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 + 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B + AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 + D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 + 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D + 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 + BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A + F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 + F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 + B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 + E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 + 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE + B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 + 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B + 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 + 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 + FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 + 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A + 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE + 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 + 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 + BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 + 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 + D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 + FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 + 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 + 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A + BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 + EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 + B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D + DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E + E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C + 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 + 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F + CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C + 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 + B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB + 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 + F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F + 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 + CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF + 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 + 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 + 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F + C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 + CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 + 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F + 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 + 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 + 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A + 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D + F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 + BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 + E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F + 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 + F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 + 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F + 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 + 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 + 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C + F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F + 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 + F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A + D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF + DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 + C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 + 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE + 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 + AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 + CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C + 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 + 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F + C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 + 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 + 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE + 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 + 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB + D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF + 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 + 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA + 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 + 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC + 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 + 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 + B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F + 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC + D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 + 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 + ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B + D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 + ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 + 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B + E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B + 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE + 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B + E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 + 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 + B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 + 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 + 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 + CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 + 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 + D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 + 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC + 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B + 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD + 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 + B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C + F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 + 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 + 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 + 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 + D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 + 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 + AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 + AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B + A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 + 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 + A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B + 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE + B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 + BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE + BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A + B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 + 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 + 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B + 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 + 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F + 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 + 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF + 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C + 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 + FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 + 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 + 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 + 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE + 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 + 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B + 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E + F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 + 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 + 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 + 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 + 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 + A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 + 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 + 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 + 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF + 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 + FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E + E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 + 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B + D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 + 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 + 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C + 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C + 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 + F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B + 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 + E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E + 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 + 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA + 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B + C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B + 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF + 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB + DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 + 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E + 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 + E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 + D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 + ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE + 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 + C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F + 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E + 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD + D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 + C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB + 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 + 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 + EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA + BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A + B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 + 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 + 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB + 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA + CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D + 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C + 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 + 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 + 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A + 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 + 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B + F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 + 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 + 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A + 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 + A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 + C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 + B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 + 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 + AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 + C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 + B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 + 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F + 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 + B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 + 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 + 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 + DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F + 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F + 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 + E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 + BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 + BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 + 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B + D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E + F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 + 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F + 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 + C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D + F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 + 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC + 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E + CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A + 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F + 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 + 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 + 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D + E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 + 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 + D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F + 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 + A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 + B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A + 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD + B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 + B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 + AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 + 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB + 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F + 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E + 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 + 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 + ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC + EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 + B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 + 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD + 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 + 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C + E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 + 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA + B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 + 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 + C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 + 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 + 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E + 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 + 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 + AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 + 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F + 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA + DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 + 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB + 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F + 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C + E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 + 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 + A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 + 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 + C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 + 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC + 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE + EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 + 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A + 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 + 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB + C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F + D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F + C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B + 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA + F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 + 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 + 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 + 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF + E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 + 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 + F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A + 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE + 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 + BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C + 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 + 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 + 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 + A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 + 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 + 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 + 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B + 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C + 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE + 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC + 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 + C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 + D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 + 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B + F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 + 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 + 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E + 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 + 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF + A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE + 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E + 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 + D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 + 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 + DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 + F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 + 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F + 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 + 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 + 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 + 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 + EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 + E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 + A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF + F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC + EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 + 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 + 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 + C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A + D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 + EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 + 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB + 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA + B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C + 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 + 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 + 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 + D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A + FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 + D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F + E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD + BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 + FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 + 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA + 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 + D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 + 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 + C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E + 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF + DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 + 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B + B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F + 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 + B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E + 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE + EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 + 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 + FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 + CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F + 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED + FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 + 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF + B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 + 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED + 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E + 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE + 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B + 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 + D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 + F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 + 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 + F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 + 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 + 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 + A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 + 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C + D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 + 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 + 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 + 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 + B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC + 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 + 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 + 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 + A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 + 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF + C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C + C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 + B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 + 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 + 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF + 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 + ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 + 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC + 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF + 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 + 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F + 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 + FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F + 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 + 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 + A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA + 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 + A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 + 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F + 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF + 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 + C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 + 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 + F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 + F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 + E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F + 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D + A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF + B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B + 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 + 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A + D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 + 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 + C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 + 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 + C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 + 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 + 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D + 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 + 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 + 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 + BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 + 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 + F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C + 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F + C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF + A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 + D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 + 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 + C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 + EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 + C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 + 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B + FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 + 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 + BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D + 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 + 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 + 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC + D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 + 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD + 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 + 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 + E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 + AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B + AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 + B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C + 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF + CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B + C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD + 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 + DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB + F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 + 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 + AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 + B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 + B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE + BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C + 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED + 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 + BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A + F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 + EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 + 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E + F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 + AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 + C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C + 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 + 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F + ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 + E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F + 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 + 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 + EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 + ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 + 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 + 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 + EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 + 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 + BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 + 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 + 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D + 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B + 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF + 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C + 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E + 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 + 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F + B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C + 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 + 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 + 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B + BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F + 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB + 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 + 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 + 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 + EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 + 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 + 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 + EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A + 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A + 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 + E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A + B5BF6F91D5F50E66B9A5D0FFD9} + end + object lblTitle: TLabel + Left = 231 + Top = 3 + Width = 402 + Height = 62 + Anchors = [akLeft, akTop, akRight] + AutoSize = False + Caption = 'TurboPower LockBox 3' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -33 + Font.Name = 'Lucida Sans' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + Transparent = False + WordWrap = True + end + object Label1: TLabel + Left = 231 + Top = 65 + Width = 400 + Height = 137 + AutoSize = False + Caption = + 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + + 'is to provide basic cryptographic functionality, implemented nat' + + 'ively as a white box.'#13#10'Block mode ciphers include AES, Blowfish,' + + ' Twofish, DES, 3DES and XXTEA. Hashes include MD5, SHA-1 and the' + + ' SHA-2 family. Chaining modes include ECB, CBC, PCBC, CFB, CFB-8' + + 'Bit, OFB and CTR. The source code is highly readable and underst' + + 'andable. Salting is provided where it is needed, transparently. ' + + 'The design is very extensible. Extending the range of ciphers an' + + 'd hashes can be done cheaply, easily and quickly.' + WordWrap = True + end + object lblRunTimeVersion: TLabel + Left = 231 + Top = 208 + Width = 78 + Height = 13 + Caption = 'run-time version' + end + object lblDesignTimeVersion: TLabel + Left = 231 + Top = 224 + Width = 93 + Height = 13 + Caption = 'design-time version' + end + object lblLogoAttribution: TLabel + Left = 0 + Top = 330 + Width = 614 + Height = 47 + AutoSize = False + Caption = + 'The above photo was sourced from http://www.flickr.com/photos/ml' + + 'iu92/3146549932 and has been copied with the kind permission of ' + + 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + + ' under the Creative Commons license (http://creativecommons.org/' + + 'licenses/by-nc-sa/2.0/deed.en).' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + WordWrap = True + end + object Memo1: TMemo + Left = 231 + Top = 243 + Width = 194 + Height = 86 + Color = clInfoBk + Lines.Strings = ( + 'TPLB3 is free and open source ' + 'software. It is made available for ' + 'use and copying by an LGPL or an' + 'MPL license at your choice. ' + 'Refer to the "Statement of copying' + 'permission" tab for details.') + ReadOnly = True + TabOrder = 0 + end + end + object tsWelcome: TTabSheet + Caption = 'Welcome' + ImageIndex = 1 + object browserIntro: TWebBrowser + Left = 104 + Top = 0 + Width = 527 + Height = 380 + Align = alRight + TabOrder = 0 + ControlData = { + 4C00000078360000462700000000000000000000000000000000000000000000 + 000000004C000000000000000000000001000000E0D057007335CF11AE690800 + 2B2E126208000000000000004C0000000114020000000000C000000000000046 + 8000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000100000000000000000000000000000000000000} + end + object memoWelcomeInstructions: TMemo + Left = 0 + Top = 0 + Width = 104 + Height = 377 + BorderStyle = bsNone + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'The video to the ' + 'right requires an ' + 'internet connection ' + 'and Adobe Flash ' + 'Player 10 to be ' + 'installed, in order to ' + 'play.' + '' + 'The video is hosted ' + 'on YouTube. If you ' + 'are on a corporate ' + 'network and having ' + 'trouble accessing ' + 'the video, check ' + 'your firewall ' + 'configuration for ' + 'access to ' + 'www.youtube.com .') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsProject: TTabSheet + Caption = 'Project' + ImageIndex = 2 + object Label4: TLabel + Left = 0 + Top = 3 + Width = 323 + Height = 30 + Caption = 'This product has been brought to you by ...' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -27 + Font.Name = 'Script' + Font.Style = [fsBold] + ParentFont = False + end + object lblWebsite: TLabel + Left = 3 + Top = 312 + Width = 221 + Height = 13 + Caption = 'https://code.google.com/p/tplockbox/' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + end + object Memo2: TMemo + Left = 3 + Top = 32 + Width = 614 + Height = 217 + Color = clInfoBk + Lines.Strings = ( + + 'The TPLB3 product is produced under the organisational umbrella ' + + 'of the TurboPower LockBox project. This project has no ' + + 'legal incorporation. It is an informal organisation with no defi' + + 'ned membership. The TPLB3 product is owned by the ' + 'individual contributors to its parts.' + '' + + 'LockBox was originally produced and released by TurboPower Softw' + + 'are Company as a commercial product. Versions 1 and' + + '2 of the product were commericial and were released in the perio' + + 'd from 1997 to 2002. The copyright holder was' + + 'TurboPower Software Company. Version 2 source code was donated t' + + 'o the the TurboPower LockBox SourceForge project' + 'under an MPL 1.1 license, which is free and open-source license.' + '' + + 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + + 'rivative work of LockBox 2 and does not share any' + + 'common code, but the mission of the library remains the same. An' + + ' exception is the unit TPLB3.DCP.twofish_Modified' + + 'which is a modified version of a file from David Barton'#39's DCPCry' + + 'pt package. The original unit of this was' + 'developed by David Barton.') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object lblWebLabel: TStaticText + Left = 3 + Top = 295 + Width = 174 + Height = 17 + Caption = 'TPLB3 on GoogleCode is located at:' + TabOrder = 1 + end + end + object tsCopyLeft: TTabSheet + Caption = 'Statement of copying permission' + ImageIndex = 3 + DesignSize = ( + 631 + 380) + object Label7: TLabel + Left = 3 + Top = 3 + Width = 370 + Height = 13 + Caption = + 'Copyright 2009..2014 Sean B. Durkin (except for portions marked ' + + 'otherwise)' + end + object Label8: TLabel + Left = 3 + Top = 18 + Width = 614 + Height = 24 + Caption = + 'The below copyright applies to all the source code and compiled ' + + 'binaries of the TPBL3 project, except the TPLB3.DCP.twofish_Modi' + + 'fied unit which comes with its own statement of copying permissi' + + 'on in its header comment.' + WordWrap = True + end + object Label9: TLabel + Left = 8 + Top = 48 + Width = 190 + Height = 13 + Caption = 'Statement of copying permission:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object Memo3: TMemo + Left = 2 + Top = 67 + Width = 625 + Height = 246 + Anchors = [akLeft, akTop, akRight] + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + + 'This component library is part of TurboPower LockBox 3. TurboPow' + + 'er LockBox ' + '3' + + 'is free software being offered under a dual licensing scheme: LG' + + 'PL3 or ' + 'MPL1.1.' + '' + + 'The contents of this library are subject to the Mozilla Public L' + + 'icense ' + '(MPL)' + + 'Version 1.1 (the "License"); you may not use this file except in' + + ' compliance' + 'with the License. You may obtain a copy of the License at' + 'http://www.mozilla.org/MPL/' + '' + + 'Alternatively, you may redistribute it and/or modify it under th' + + 'e terms of' + + 'the GNU Lesser General Public License (LGPL) as published by the' + + ' Free ' + 'Software' + + 'Foundation, either version 3 of the License, or (at your option)' + + ' any later' + 'version.' + '' + + 'You should have received a copy of the Lesser GNU General Public' + + ' License' + 'along with TurboPower LockBox 3. If not, see ' + '.' + '' + + 'TurboPower LockBox is distributed in the hope that it will be us' + + 'eful,' + 'but WITHOUT ANY WARRANTY; without even the implied warranty of' + + 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + + ' to LGPL,' + + 'see the GNU Lesser General Public License for more details. In r' + + 'elation to ' + 'MPL,' + + 'see the MPL License for the specific language governing rights a' + + 'nd ' + 'limitations' + 'under the License.' + '' + + 'The Initial Developer of the Original Code for TurboPower LockBo' + + 'x version 2' + 'and earlier was TurboPower Software.' + '') + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + end + object tsAuthors: TTabSheet + Caption = 'Authors' + ImageIndex = 4 + DesignSize = ( + 631 + 380) + object Bevel1: TBevel + Left = 328 + Top = 16 + Width = 281 + Height = 257 + end + object imgAuthorPic: TImage + Left = 336 + Top = 24 + Width = 265 + Height = 233 + Stretch = True + end + object lblAuthorEmail: TLabel + Left = 328 + Top = 293 + Width = 150 + Height = 13 + Caption = 'email: sean@seanbdurkin.id.au' + end + object lblAuthorWeb: TLabel + Left = 328 + Top = 312 + Width = 173 + Height = 13 + Caption = 'web: http:\\www.seanbdurkin.id.au' + end + object Label12: TLabel + Left = 175 + Top = 135 + Width = 135 + Height = 13 + Caption = 'Select author to see details.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + end + object imgSean: TImage + Left = 175 + Top = 312 + Width = 66 + Height = 65 + Center = True + Picture.Data = { + 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 + 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 + 696E6720494A47204A50454720763632292C207175616C697479203D2038350A + FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 + 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E + 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 + 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 + 00B5100002010303020403050504040000017D01020300041105122131410613 + 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 + 262728292A3435363738393A434445464748494A535455565758595A63646566 + 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 + A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 + DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 + 01010101010000000000000102030405060708090A0BFFC400B5110002010204 + 0403040705040400010277000102031104052131061241510761711322328108 + 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 + 363738393A434445464748494A535455565758595A636465666768696A737475 + 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA + B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 + E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 + AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF + 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 + D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 + 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 + CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 + 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E + 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 + CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 + C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA + 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 + 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 + F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF + 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 + 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 + E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 + AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 + 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 + 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F + A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 + B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F + FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B + A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 + 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE + 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 + D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB + 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 + 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 + 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C + 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE + 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B + E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 + F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 + 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 + 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 + E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 + C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A + CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 + B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 + 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 + 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C + 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C + DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC + B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 + 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA + 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 + 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A + 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 + EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 + 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 + 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 + 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 + 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 + 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C + D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 + 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 + 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC + B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 + B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 + AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 + 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F + 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 + DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C + F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C + 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 + 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 + 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 + 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 + 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 + 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 + ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A + B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 + 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD + 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 + 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 + CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB + BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E + F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F + 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 + C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 + EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 + 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 + FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 + 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB + 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 + 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD + C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 + B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 + CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF + 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE + E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA + EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 + B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 + CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 + DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 + 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 + 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F + 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C + 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D + 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 + 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 + 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE + 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E + 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 + D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 + 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A + 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 + 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 + F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 + 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 + 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 + A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 + ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F + A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 + 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 + 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 + 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 + 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 + F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 + 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 + C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E + B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C + AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 + 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E + FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 + 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 + 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B + 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F + EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C + 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 + 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD + 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D + 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 + 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 + FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 + 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 + 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B + FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D + B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 + 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 + B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 + 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F + 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F + F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF + 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 + A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 + 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 + DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 + FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD + 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 + CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 + 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 + BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 + B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D + FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 + 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 + C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A + 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 + 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 + B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 + BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 + 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 + 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB + 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 + 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C + 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 + 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 + BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C + 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 + 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 + 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 + 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 + DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 + 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 + AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD + 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 + 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF + 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C + DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 + 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A + B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 + C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 + F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E + 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 + C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC + 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 + 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB + B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 + 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E + EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 + 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 + 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA + 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C + D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E + 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A + 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 + F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE + 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 + 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 + 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF + 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD + 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE + BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C + 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C + AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 + CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 + 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB + 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 + 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 + A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A + 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 + B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D + 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E + 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 + FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B + 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C + 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 + D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA + 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 + 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 + 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D + FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 + 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 + E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A + 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 + 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A + A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 + 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 + EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 + 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B + 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 + 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 + 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F + A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A + CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B + 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 + 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E + 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 + 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F + 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D + 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA + 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E + 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 + F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 + 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 + 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 + 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A + 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 + 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B + 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 + 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 + 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 + A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 + 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 + AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F + 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C + DA66209F4EF451457D427A1E3D8FFFD9} + Visible = False + end + object imgNick: TImage + Left = 247 + Top = 312 + Width = 66 + Height = 65 + Picture.Data = { + 0A544A504547496D616765A3040100FFD8FFE000104A46494600010101004800 + 480000FFE116CB4578696600004D4D002A0000000800000000000E0002020100 + 04000000010000002C02020004000000010000169700000000FFD8FFE000104A + 46494600010100000100010000FFDB004300080606070605080707070909080A + 0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837 + 292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D + 1832211C21323232323232323232323232323232323232323232323232323232 + 3232323232323232323232323232323232323232323232FFC000110800AC00C4 + 03012200021101031101FFC4001F000001050101010101010000000000000000 + 0102030405060708090A0BFFC400B5100002010303020403050504040000017D + 01020300041105122131410613516107227114328191A1082342B1C11552D1F0 + 2433627282090A161718191A25262728292A3435363738393A43444546474849 + 4A535455565758595A636465666768696A737475767778797A83848586878889 + 8A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5 + C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8 + F9FAFFC4001F0100030101010101010101010000000000000102030405060708 + 090A0BFFC400B511000201020404030407050404000102770001020311040521 + 31061241510761711322328108144291A1B1C109233352F0156272D10A162434 + E125F11718191A262728292A35363738393A434445464748494A535455565758 + 595A636465666768696A737475767778797A82838485868788898A9293949596 + 9798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2 + D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C0301 + 0002110311003F00F9FEA582468D89538C8A8A9CBD681ADCB5F6890FF11FCE97 + CE73FC7FAD57A2A6C5DD96448DFF003D47E748656FF9E99AAF45160B93195BFB + D49E6B7AD474502B8FF35BD6956439EB51E2B46D34E9580774201F51D281AD49 + A4D30B595B5CC7730CAF3062F1267745838C371DFAD356D0C31906272FEB569A + E3EC69B633C8EA4018AA726A52BB6598E3EB45C76B15C5AB2B64E4006B47CF8C + 5B88D41DF8C64554BAD44CE8154638E4D544793230C3F3A4099D459EAD7496CB + 179FB557E5FA56A58EB37568A803875F475C061EC6B0B4FF0037682FB0E7A071 + 9071F5A9A448E5326D1B1D4EEF2F1C63DAA1D2835AA378E22A45DD33D57C15AA + C17FABC6A08494F543D7F0A6F8BBFE435273FC47F9D79C69BAB7D8FCA9D19924 + 89B2B327047F9F4ADF3E268F5D9C3BBAF9FF00C58FE2F715C95A87247DDD8EFC + 3E27DA54F7B7B1D3942D1AFF00BA29863C0AB2B810A03DC52040475AF3AE7A64 + 49F2EDCF7A97690F8E7A52018700D4D903B526333B5118D32EFF00EB8BFF00E8 + 26BC0EBDFF0054FF00906DD1FF00A60FFF00A09AF00AF4B2FDA478D9AEF0F985 + 14515E89E485393AD369CBD681A1F451D293348A168A28A0028A334A064E2802 + C59A8F3959802AA7383D0D75B14CB7364E4A33955C9DB8C03D81FE7F857220ED + C0538ADCB68AFC5AA5BC7191E660ED51C91EF5372919B78FF3152DD0F4CD67B9 + EC0569DEDB4703156915DFB953900FD6A8088BC8028247B0A103191AB13D33ED + 532C68EDC650FBF6A96581A373B87BF152DBA7230508CF393FD3AFE5405872DB + 4A24F2FCF0BDD595B0AC7EBC63F1AD9D2ED2F962699631344548001CB29F6FCB + A53DADADADEC952E24DC8C721930E07D33D3F3ACD25612765CB283D09CA9C7F5 + A603E5BB48E09044192463F3C65783EFF5ACE86E5E0B94990E194E46296E4BEE + 0CD2EFE3EF77155973D49C8F4A4D5C69D9DCF69D1F528F55D362B98CF3B4065F + EEB77AD30B8419AF37F03EB42D2ECE9F2F114E7E539FBADFFD7AF4A382BF4AF1 + 6BD3F6736BA1F4187ABED69A7D7A8D551BB25A9CEB81C3511AEDCE4D3A41C1C1 + AC0E8296A43FE2557793FF002C1FFF004135F3F57D03AA0C69575FF5C1FF00F4 + 135F3F57A797ED23C7CD7787CC28A28AF44F2429C83269B52C033250C6B7342D + 74F49D4162D45C5A5B228588B3499C62AF59ABCBFB98701C83824E00ACA695A2 + 7620FCDC8CD6316DCB73A24A318AD0BB61A425E297DCDB47502B56C7C376B716 + 124CDB8957201CF6A83C25A8470DE4B04DF764438FAD7436B3A43A64A9900991 + B815CD88A9522DA5E47561A9D2924DF99CC4FA45BA03B4107EB59263D9230FEE + D747732824D61DE00AE71DEB6A5293DCC2B422B61FA6C314D740CEDB635193EA + 4F603DEB7B06EB72C22479253CED3DBB006B9EB21E64CB18EAC4007DCD7AF784 + 34586D70427CC40C93D4D5CE7CA854A9B99C941E03D4EEA107C9603D1DB18AD1 + B2F8717B14C1E500277C7F857AF470858C71C5598E206B0F6B2674FB0823C9AE + 7C051CD112CEB1B81F2F18CD7312F862E2C6E592455609CE7D457D06601C8DB9 + AC6D6FC3D1DED948D02059954ECF4FA1A235249EA12A506B43C4EF2D7ECCCAAE + A3C97FE1CF047D7EB5CFDEA4493B0466D9FC3CE715D96BFA0DEC282FA1573129 + C4C8465A3FF15F7AA179E11964B18EF2D6412C6E3240EC6B7F6B139DD096A71C + 4FBD380E29D3DBBDBC855C10475149110C707A77AB3026B662B2AB0EA0E4115E + D9A74A66D36090F568C1CFE15E230E3781EFD6BD8FC3ACAFA1DA6D39C20AE0C7 + 2F7533D3CB9EB246A27CCFD6A47C6F18CD314150C714F272B9AF34F58A5AA8CE + 99767FE983FF00E826BE7DAFA0754C9D2EEFFEB8BFF235F3F57A797ED23C7CD7 + 787CC28A28AF44F2429C8482714DA72F2681A2CAC8C107CC79A63F228E4F4E95 + 66EA38120B6F2F7798533267A673C629228AB0CAD6F32C8A7906B55669D6D04F + E6E15C93B6B2185755069F1BF8521B99432A6F2A1C7F7B19028E54F705271D8C + 437649E58FE551CD207C60E4D5B78D6372A5318F5AAB738560400062B38DBA1A + 4AFD4B9E1E8BCCD5ADD08FF9680D7BC699088F630E80578AF83A0F3B54327511 + 906BDBB4B6591179AE7AF772B1D985D20D9D0C4498C55A88657DEABC38C75157 + 1233B722A12366D080041D726949007D6A68ADCB9CB1C0F534DBB96DAD93324C + 8ABEAC7157CAEC67CCAE674B14786528083C10475AC2BCD2ADA3B5748230A0F4 + 03A0AD4B8D774B50DB6E6373E8A7359E356B1B81812804F63D454383358C933C + 87C4DA0DC0BA9265819D4F24A5716C9B19971EDCF5AFA12F6D926898AFA715E3 + 5E2DB1FB26AAC55300F5ADA9546FDD672E22924B9D1851F079AF55F04CCB2682 + 802905188AF34B1B496FAE63B7810BC8E70AA075AF5DD1BC3B3787B4F48A63B9 + A41B8FB1EE2B2C659D335CBD3F697E86BC786539E79A7150463A54511C2FBD48 + 4E71CD7947B051D50634CBBFFAE2FF00FA09AF9F2BE82D5011A7DD8FFA60FF00 + FA09AF9F6BD3CBF691E466BBC3E61451457A279214F8C12491DA99562DC0F267 + 27B28C7E74017B40B15D575FD3F4F793CB5B9B98E22C7B6E6033FAD743F1362D + 2EDBC757B69A3E3EC76EB1C4B8391B820DDFAD72B612982EA39D4E0C6C181F70 + 69B7370D73752CEE72D239627EB4ADD4AEA44DD2BBFB78205F04E8DE701BE7BC + 2067FBB8EBE95C0B74AEC2FB577BBF0AF8774D8E08C35AC8CD919CBE4E79A101 + D5FC42F0859683E258ED6D4830496C92AE7AF39073F8A93F8D711A9E8ACE8860 + 009E411563C4DA86AFAC6AED7F74B246BB5634405B0AA06005CF41ED544C57B1 + 90C23B90179C9271587B1A8A574CE85561C9CB244FE1669AD26BB40A565000C1 + 1C8EB5DAE9F65ADDD2868E79211EA24C03593A44F06A5E30FB4EDF92EE25661F + ED6307F5AEA5A1D461D5459C60FD940CEF4E5B1EC2A252F78E8A705CB627B57D + 7F4F9B33DC09A2EF86E6BB6D335A5B8882ABFCC7822B8DB0D3FC42E76DD9436C + AE78214330EDFC3C559B1B396DB5B802F04BFCC149C7F9C5449B4CDA114D1DC5 + F5F3AC38071C76AE17558A1D46E3FD2AEA560BC05535D96A686501471918CD73 + E7472C16311B065393823E6FAFAD4B9C932A308B5A98F0FF00C239659569C090 + 100892719C9F6CD5D88E952B6C87CA07DB073566EBC1F617F76F7976B2F9CC54 + 90170A4A8C0240E2AFC1E1EB21746E7ECEBE69EB2B2FCCD5737A68C882B3D511 + 496ED1C21B39523818AF38F1DE9E7E5B8C020F06BD6AF554C2547615C4F89E11 + 3698E366E2071FCAB38CB964997287341A0F00F8456D2D5F51F2CF98F10F2D9C + 76233C7A7F5AE8359B8DD25B43B79111763F538FE86B6F4A952C745B68A40F24 + A91A86C2F4E2B9AD5678E5D465087EE205E3B7538FD6A310FDD6CD70CACEC411 + 1CE391CD498E6A1460B8E3A5488E18D79E7715355E74EBB3FF004C5FFF004135 + F3E57BF6A67FD02F7FEB8BFF00E826BC06BD3CBF691E3E69BC7E61451457A279 + 4152C47F7722FAE3F9D4552C2769CFA1140D1645BB244598115596BA79B4BBD5 + F0A26B72D93FD92699A28E7CF1902B985EB4BA21F5D053D2B52EAE5A1B2B1087 + 0CA0915987A55EBA4F316CD338CAE29C419A76C2F753879BA5E0F491B1534675 + 3B89A4B64BA07E5C105B834E7D008782DE3BB0A594B127A5577D16E63BB302DD + A13B776EDD8045501DC785F458A1D26DAE642A2F6D6765250E728D8E0D77F6D0 + 24E564C61877AF23F085F5EE9F71F6572B25ADD49B493D5587715ECBA615F292 + B86B2B4CF4F0ED4A08BEB1054E4926B2E38F76BD18F4C9FD2B6C1C1F6AC984EF + D7770181D0567637D8D4B9211B07A536DF065F50697538245C646370C8AA5079 + 96D77113282A7EF29ED43BDC71B729BC23C74A8E64C2F03148B764107B1A6CD3 + AB77AA76B1924EE67CAA79CD72D7EC1679011C2F6AEA269393ED5CAEA5FEBD98 + F4622B291AC7732F50F8B7630466D2C2C27FB629D84CC46D561C763CD2E8E659 + AC5AE6E4EE9E7732393EF5E75A9E9262F124A720879C9FD735EA56C823B2541C + 70054E2ACA114BA860DCA5393974254233F853E3181B854698F5A941E38AE13D + 0286A9C69D77EF0BFF00E826BC06BDF352C369F77CFF00CB17FF00D04D781D7A + 597ED23C8CD778FCC28A28AF44F2429C8719A6D39680359F58D41B418F4B6B99 + 4D8A486458777CA18F7C5662D4EAF9B765278C1C5575EB432BA8F3D2AECAC8F2 + DA89495400648AA24D5C98069A28C9E02F3490336638B4A6B941F6B976907249 + C62892DF4D33B05BE90018C1FBD9ACF1F6359A58F286355CAB9EA4FA5432450B + 5B2CCAC048D9CA0FE1AAB81B5631DADBCD0CE9A812D1CA1821079C1AF67D1AE4 + B40C464851BB03D2BC53FB16D0582DCACF26FD992BC75AF50F03EB31CB67693B + 302197CB93DBFC9AE6C447667661256BA3A57D5D802BB3E63C605568E7BB5BA8 + E78622707E604F515A3AA69D0CD1B141863CABAF06B9ED31FCABBF26F6FAE635 + C901C1047B76AC4EC49B8DCE8E7BEB9BDDA8D0CA147072314A2CE787962A323D + 31C5598A0B7DA1DF5D063DDD957763EBFF00D6A8AE67D1A163E599AF65DD91BC + 92318F7E2AADD4949BD237FB8A53EA0B668449709C7607273F41535A35E4CC8C + 4108DCE1BD2A3B4B41712ACD24291AAF288AB803DEB566944109618CE3005437 + 729C5C5DFA945DB2EF9ED581ABFDDF7CD6B990A444B75639358779279F761073 + F4ACDA1C5DD9C8CDA735D78BDD88FDDA0573F5C575C0E131DB15C978935E6D03 + 56611DAACAF2203966C018A9BC37E2A3AC48D6F7491C33F54099C30F4E7BD655 + 69D49479EDA236A3569425ECEFAB674801C1229E9BF340E3D6979CFCA3F1AE43 + B0A37C3FE25F7B9FF9E2FF00FA09AF05AF7CBFE74BBC38C7EE5FF91AF03AF4F0 + 1B48F2334DE3F30A28A2BD03C90A72D369E83E463E98A009A37DA8E38E411CD4 + 6B4A837B84040C9EF4636B153838E38A4F62BA887A55D91916EE32DF7768CD52 + 356A48A49AF512242EF818503AD340CB1349626EA76585D622BFBB5CE706984D + B7D8D3CBDC26C1F333D0F3C62A66926865B9F3ECBE79131865C6CF71505CEFFB + 25B86B5310507F798C6FA4C0BD21B1FECC528C45CF42371E957FC1DAF0D3AECD + A4ED88253F292780D5566BAB36D092116656703FD6ECFEB5807AD29453562E33 + 717747D23A66A5F688444CC18819539EA2924B1579CB81F78D791F857C573D84 + F05ADF31DB9063909EDE86BD8E1BD8DE157421B3C8E6B8AA45C59EA51ACA5AC5 + D8B16F14516D2C8A48FF0066B44C6B390E500FA0C0AAD01F322DEC40A937BF97 + BD1C6CF4EF4D36D1529EB76C94000F1D2AB5DCCA48048C2F351CF7A238D8935C + EDC5FDC5E4E6DED11A491BAEDE83EB51A8B993D89B50D4429D91FCCC7B0A9B4E + D35E188DCDC0FDE37201AB7A5787D6D7F7F7444939FC96AAF8BF5F83C3FA53CC + E434EFF2C31E7963FE02A249BD114A4A2AECF2FF00885E536AB1286FDE804903 + D3DEB97B69E4B69E39A262AE8C1948F5A2EAE66BDB992E6772F2C8C5998D442B + D0A70E5828B3CBA9539E6E68F5ED0F568F57D3527520483E5917FBA6B4092383 + 5E59E19D64693A9ABCB215B77F964EFF00435E9116AB617255A2BC81C3740241 + 9FCABC9C45074E7A2D0F6F0B885561EF3D43522469975EF0BFFE826BC12BDE75 + 33FF0012DBAC73FB97FF00D04D783575603691C39A6F1F98514515E81E5053D1 + B08E31D6994AB400E53CD3853075A7AD265210F5157EDE59A3D523781774A3EE + 8AA1FC63EB5692E1EDAFC4D1FDE53919A680D6B89756B9BB9736EDE632057555 + ED4DD42F2F6FED56DDECCA880F2554F14D4F11DDADEFDAB085F6ED231C5363D7 + A741719507CFFBD45D0C9A7D5E597461686D36A00079983585D5AB624D70C9A5 + 7D84C0A063EF66B1FA9E29302EDF46765B286C9F2C1E3B5767E12F13DFAA7D85 + 90DC796B9520FCD8AE3A5904810E31B542D4DA3DFB69DABC1720F0AD86F707AD + 2A8B9932A94B9648F5E83C5EAABB278A6423F859714F8FC43733FEEEDADE4909 + FE1519FD055EB351288E78F0C8E01C1AE92D4650055FCB8AE1E7F23D2E4F339D + 834BD5B5370D763ECB0F751F78FF008575163A74165088A08C228EB8EA7DC9AB + 31C6481922A4B89ED74EB492EEEA558A18D7733B9E052BB61A22B6A1776DA569 + F35EDDC8B1C110DCCC7FCF5AF9E3C4DAF4FE23D665BC972B18F9618C9FB89D85 + 6CF8E3C6D71E28BB3041BA2D3236CA467AB9FEF37F876AE38D7552A5CBABDCE2 + AD579B45B001410314D2D8A03E78ADCC06ED2CFB7F3A9FCA58D433BE3D3151EE + 0BD3AD34E4753405CBE9ADEA36F6D24315DCA22652A51B0C318F7AE66B518128 + DF4ACBA9514B6413949D936145145510152C2AAC4867DBC7A5454E4EA68635B8 + AEBB5B8391D8D2A60F538A770D1B0EE391518F4A43D894AC60821F77E14E91D1 + A42C33CD46071F8525031F914E542E320714B1C25F93C2D4A401C0E828023113 + 77C0152AC71A0DE49CFBD2A0DC79E83AD3646DC4E3EEFA53480954AB8CB0C03D + C76A6B47DC74A8A391A36C8FC47AD6DA4B6E103050411E9406E7A37C3CD596FB + 4B5B591B32C3F2F3DC76AF49B5B718C826BC0FC2F7A34ED7A2911B114870457B + F69EE1A24607218020D7154A694EE7752A8E502CC92C1656D25CDCC8B1C31AEE + 6773800578578EFC6573E29BC105A064D3A16FDDA9E371FEF1F7FE55DEFC5B6B + 81E1DB458F77D9DAE312853D783B73EDD6BC719C4631C56F469AB7318569B6EC + 5558254C8247B8ED51B29EA3A54ECF95DCDC2FA7AD57794B302BC63A56E738DC + 51823A75A9171276F9BD3D69784E7BF6A431A1446327EF52282ED40F98E4D584 + 1B1738E4F4A006BA8489C01CED3935835D1B058E072464953815CE5364B0A28A + 290829CBD4D368140128383C5376F34DA327D682AE4A095E952C50EE42E4640A + AB93EB5A968001B3F85979A40860395E2998E69E83871E8680053183FCB1003F + 8BAD418CD4EC06DA8E813186A689885033C5458A9507CA29816EDEE1A299241D + 50838AF61B2F881A5699E1F8243299E7D985817EF647AFA578EC31AB4809AB52 + 008BF28C544A9A96E690A8E3B1ADE23F17EA7E22B8DF77294814E63B743F22FF + 0089F735CFEECF27F2A69E492793EF4A06466AD24968436DBBB1AC59F93D2929 + CDD299400A0E0EEE98A19CC8FB88C7B521A7C6A3AD201C8B938EDDEA6C85F98F + 7E829B08F973EA69C066673FDC031ED4C41238489D9CF2548FFEB0AE7AB56E18 + B48C0F450401595484C28A28A047FFD9FFE20C584943435F50524F46494C4500 + 010100000C484C696E6F021000006D6E74725247422058595A2007CE00020009 + 000600310000616373704D534654000000004945432073524742000000000000 + 0000000000000000F6D6000100000000D32D4850202000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000001163707274000001500000003364657363000001840000006C7774 + 7074000001F000000014626B707400000204000000147258595A000002180000 + 00146758595A0000022C000000146258595A0000024000000014646D6E640000 + 025400000070646D6464000002C400000088767565640000034C000000867669 + 6577000003D4000000246C756D69000003F8000000146D6561730000040C0000 + 002474656368000004300000000C725452430000043C0000080C675452430000 + 043C0000080C625452430000043C0000080C7465787400000000436F70797269 + 676874202863292031393938204865776C6574742D5061636B61726420436F6D + 70616E790000646573630000000000000012735247422049454336313936362D + 322E31000000000000000000000012735247422049454336313936362D322E31 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000058595A20000000000000F3510001 + 0000000116CC58595A200000000000000000000000000000000058595A200000 + 000000006FA2000038F50000039058595A2000000000000062990000B7850000 + 18DA58595A2000000000000024A000000F840000B6CF64657363000000000000 + 001649454320687474703A2F2F7777772E6965632E6368000000000000000000 + 00001649454320687474703A2F2F7777772E6965632E63680000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000064657363000000000000002E4945432036313936362D322E3120 + 44656661756C742052474220636F6C6F7572207370616365202D207352474200 + 000000000000000000002E4945432036313936362D322E312044656661756C74 + 2052474220636F6C6F7572207370616365202D20735247420000000000000000 + 000000000000000000000000000064657363000000000000002C526566657265 + 6E63652056696577696E6720436F6E646974696F6E20696E2049454336313936 + 362D322E3100000000000000000000002C5265666572656E6365205669657769 + 6E6720436F6E646974696F6E20696E2049454336313936362D322E3100000000 + 0000000000000000000000000000000000000000000076696577000000000013 + A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A200000 + 0000004C09560050000000571FE76D6561730000000000000001000000000000 + 000000000000000000000000028F000000027369672000000000435254206375 + 7276000000000000040000000005000A000F00140019001E00230028002D0032 + 0037003B00400045004A004F00540059005E00630068006D00720077007C0081 + 0086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00D0 + 00D500DB00E000E500EB00F000F600FB01010107010D01130119011F0125012B + 01320138013E0145014C0152015901600167016E0175017C0183018B0192019A + 01A101A901B101B901C101C901D101D901E101E901F201FA0203020C0214021D + 0226022F02380241024B0254025D02670271027A0284028E029802A202AC02B6 + 02C102CB02D502E002EB02F50300030B03160321032D03380343034F035A0366 + 0372037E038A039603A203AE03BA03C703D303E003EC03F9040604130420042D + 043B0448045504630471047E048C049A04A804B604C404D304E104F004FE050D + 051C052B053A05490558056705770586059605A605B505C505D505E505F60606 + 06160627063706480659066A067B068C069D06AF06C006D106E306F507070719 + 072B073D074F076107740786079907AC07BF07D207E507F8080B081F08320846 + 085A086E0882089608AA08BE08D208E708FB09100925093A094F09640979098F + 09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0AF3 + 0B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C75 + 0C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E13 + 0E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30FCF + 0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11AA + 11C911E81207122612451264128412A312C312E31303132313431363138313A4 + 13C513E5140614271449146A148B14AD14CE14F01512153415561578159B15BD + 15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217F7 + 181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A51 + 1A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31CCC + 1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F69 + 1F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB2227 + 2255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA2509 + 25382568259725C725F726272657268726B726E827182749277A27AB27DC280D + 283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B36 + 2B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E82 + 2EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31F2 + 322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D3587 + 35C235FD3637367236AE36E937243760379C37D738143850388C38C839053942 + 397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D22 + 3D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E74129 + 416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE45124555 + 459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349A9 + 49F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E25 + 4E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52C7 + 5313535F53AA53F65442548F54DB5528557555C2560F565C56A956F757445792 + 57E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C86 + 5CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61A2 + 61F56249629C62F06343639763EB6440649464E9653D659265E7663D669266E8 + 673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C57 + 6CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571F0 + 724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677B3 + 7811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417DA1 + 7E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783BA + 841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989FE + 8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E9006906E + 90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F970A + 977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649DD2 + 9E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4C7 + A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75ABE9 + AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B338 + B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBAB5 + BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C25F + C2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA38 + CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED23F + D2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA76 + DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2DB + E363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB70 + EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F434 + F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD29 + FDBAFE4BFEDCFF6DFFFFFFDB0043000101010101010101010101010101010101 + 0101010101010101010101010101010101010101010101010101010101010101 + 010101010101010101010101010101FFDB004301010101010101010101010101 + 0101010101010101010101010101010101010101010101010101010101010101 + 0101010101010101010101010101010101010101FFC200110800E90109030111 + 00021101031101FFC4001E000000060301010000000000000000000000030405 + 0607010208090AFFC4001C010001050101010000000000000000000000010203 + 0405060708FFDA000C03010002100310000001F9FF0000132A7AC723F226E8A6 + 229422792321CDC2B755686928576EE1632689A324F1CD3F492CAE7FB29541A1 + 79F23DDF7AB63AFA1BB5760F4AFB46D12AD56D91D616E1AA48FF009ECFA83E28 + C2800000718ED1A4996A6E3B66AEA89AC8CC22069ABD4D63EC7658B79EF8D233 + 61B58C4FD18FB41EF9BCB1B556BBDB59FB57979B7B23173DD04CE859463F56BD + E228CE546A25F9E6FA83E2BC28000005F1DA3476A1B0651702654086CC7EEA97 + B2D97DAF62B122872C7892146D5562DC2F74B49560E5435273BD87A2FE41EEB6 + 0665F58D54892382334452477CEE7D41F16E14000002F8ED1A3B5001B0000010 + D992485ABD2AEB49627F3E3608ED8AE9463F453BA123E3D92F475A1215544EAD + E07F71F01EADDE9E6DEB6E912A547BA2350B64D9AEF9D4FA93E2BC28000005D1 + DA39AE2D4D837170A98172886B247B827B295CAD25802C1149607914C8A59548 + B783C87C6257157B119D166D4357D98F0AFA466142F20495F1B1B624DA35FF00 + 3AFF0052FC5585000000B59656C529CC9524F01D13DF2ADD4F244DF35750395C + 33F48BEC16D29D20CB5F7243A154AD791D9AB6E4AB4B451C5046814A6AAA63BB + 3F88F4DF46FC9BD9303D7C68955E9DB27CEAFD4BF15E1400000486A685E5CC76 + 8D56B3E29AB91D3BE7BE9D66F23D9549D67194BF5BC656FB9CFCC075CF15CE99 + C4E9BA3E8EA4C5924BAA68401AFE33EBF8980E961534C8EA12B3539AE0C7EA8B + 7760F57EBF7887D105B249042D40AF25927CE87D4FF15E14000004E3376AE1E7 + BAAA8BA7E3986ED4EECF25F689A733D452DD6F195CF45CDD47D0F28E492FA2FC + DFA0FA7BCFEFD8D2B1DDF12F588A1FCF9333CC4D0C88439B4C6973F47EA73E63 + 55D11F62656F7B21E0DF4AAF60AE309472225F9D9FA97E2CC28000007BAD7A53 + 5EDB1DCA4C52436051D39D656CB63552CD0C17471DF193FB59E7BEC7D771A4FE + CC2FD3D5552B15AC25C725735AED1AD9E84B10F939DAF97565252C092886DFB4 + 3E01F504F284E78108E6E26F9D1FA93E2DC28000005F1D874649BCCD6F81C925 + 83A2675ABB234CC47334B0CF60BDEE479C7AEDFD236C7BD0BE58AEB1D1EEF8C4 + 4AC35E787436EA6AF738CAFD1F32FAEF2F85DECF728E5F5EBC2FE97B8B1355E1 + 8278DCD6E9BE743EA5F8B70A000001D23B4AA29ACF9A0AB629924907A17A29CC + 9C4748D1662AF75733A2333A2F59F8EF49EA0B79F604CE9A58A4E12D77ED0CAA + 12B4F4DBD6134B66439DA09F36EF973D3F0FC69D0719DE58BDD7A0FE53ECED3C + FE939B0351AC6DB3F3ADF537C5985000000E314F388A6F4A8AFE54AD94F243E9 + EDB5E96E1BA3E03E63BEE78EDF80B0E4B3D1B06C5A2D6DB99FB5DD35EDDA16E8 + 50D52FF2A3A3B12CD39253BEBAA4ABAB58E2DD1CCE50DBE73DB7E6FD16AEE43A + 483F35BAF0C698234B6D7CE97D4BF16E14000004A9933DABA5EB1D535ED96E8B + D2B911E32ED71BD3DEB0EB5C90AD8EC0C6EADD2ED07F7C6939EEBFD1DD1E7799 + 313A581E857AB7B2F3B9662F49D1B81AF2721E6DAFA2CDD1F2FE88457B877CE3 + D31A71B41F1A8635B1C5B3F3C3F517C5D850000012C64B895CD50B8E8E6C3A3E + 8BD1AF2A91F16AEEC35D6F721E81E9172DD548AFB2DE794BE3ED7616CE341F3B + 5004CAFE3EF1A88A582C36F9EE85F9868E659D69FC75E73DEC9F2F44D473A361 + 8E967E7ABEA1F8BB0A0000025B5AF486E4703AED52C9F71B61E9553E19AC3910 + C1FE8BF15E93D3DCDF5173587C8A46D07527E96D1CD8366EB4A248AC3D9C3113 + 6134B46135E7E72A37B9977397E58D2C3F44BC53DF56C53B834523585B63E7A3 + EA1F8BB0A0000026F4756DED8CFE7AA322C8A639CD995FAB69CAF4F03E2AC5BF + F0FA5F5EF86F50BEEE357ACD41C75FA36CD6A771F79EEE456DDDC45F35787E76 + 942E039BE95FE03DFE5AB07D4F4E7C73DD930E7346E44604B1F3DBF507C5B850 + 00000F50D8EEA5ABC16EB6AE2995B9B2DB705C133A4719016A9B058F65FCC3DB + 7A3E77E256532B53AB7432E8EA7B425AF257B12A5470C5E81A19529DAD778FB4 + A94373EEF66F9F7A2B62C9B20B86B4ACFF003EBF4E7C5985000000E315993DB8 + E2B5645914AA9C921B504E6474898E6868B9E7A55E71EBFDA4D7525665774B56 + 5AC12B9D85C2EAE9B03EC33D8F1110AECA9EADDE674D095F1FD9D819B68A47EE + AAA46B6B66F9F1FA77E2EC28000005D1CF2595B1A8E459148B5CD7DB50C85257 + 0886C55E9EB6C9A719DF7AFF008DD1B0335F986C5EEBEBDCACD9EE85D5DA8D66 + E9DBC62570CAF1D4868AADA513CED3F2FF00D0BC9FB1F83F4CEADE0FD21422A6 + 0D9AFF009E6FA7BE30C2800000708E67FB091FAEF551CEB5F13D588A568ED229 + 1B096DC57D5542DFB2BC6FA975435D5757E92657AD5ABA7CC6F9929F49E7BA2A + D5B5A9B81CD5435F1526F0FF00D9BE7F7A65AF597C1BE909F636F9605249F3E1 + F4E7C6185000000ECC9F2F54F0AA96CABA58B123260D73B9243E23A06E3F98A8 + B6F3CEDDF5E392F47E8CC9D771BB13D5FAAF351E9A17C0E4A94246F591CFD319 + 36BCBAE8F92F387D0FCD8C16EAE77ABF547C2BE8A48F9098E5F9F6FA73E2EC28 + 000007A497572EF1BB48A55B344FF2167BC490C9046B6ECB2DE65A2F76B096F6 + 76AFB57C47A5D9CA49ACD2DAED581D6B144D2D1BB235E82A73F225BCFF000CBD + 1FCB497B4B6BB753A9383F47BA79BEBAF6E4BBDF073E8FF8EF0A000001C1B268 + AF358E3639154F03839F610E35A30B4984A948D574EAFC31888E9AC6EA3B4303 + AB9435A7A3ED5AD67ABE9589CB1D079A9FCECF7FE755EE851390D11CD8D4902B + 72E56B864A764CD00000003DB2870A992191C8B26816B9D743E4737B48692379 + CAF9EB30B91971AA886CFB4FE5BED775C05D16A1923A27F5851D8CCF9FDED789 + E69D6CC2950B13229E3494548D5298B5649400000001532629EC52C90C6C8E0F + 8896CBBC52000E32C4C3D250E53646352B3D34E23D1BD19E57A4B4EEC13296B9 + 36B37E7D3B6E2F9CF4F35331E950246EC2ECE6AB6BD3A2BBAA51C51000000095 + D3D362B14CB723CC56B423207045CA8FB21BB5AED20D92C5208E539527B4743D + E6F3CF4ABFED533E5AFE0F769C572CEB656A8AD6C540C7128B911C01B9AE7F91 + AB1E73D434C0000001C23B4BDA334B02C73CC8A62816048C710F6AB6BC4B0B33 + 47172DE4E9D918CF54B8AEF7D1CA9639BB5713C32ECF93671891AE8EA26AD1D8 + 5C22B6355CDCD76557779CC305300000005F1DA34548E88E47A947A9093A3C95 + 690E47195B1D5680C04858F79493B3F9DE9FD89C4DDF2AFA7E478477B152A2B7 + 3585A2E07390D6B63D62B1E6455E2AD0E678698000000286CDBA3F743710B0B2 + 1D335A21AA8581CE1A08F6789D4761CE08B308A79A35F5A5BA842B731BF51480 + C3421A2851D2447A7B11B5CD4C752ECA60000001B8EC8E02015534B3CB4815BA + 39366811ED6445AA16A3C395D9CF9F4AD6D52315D0C994F8D5B4356A86B881AF + 2F452AAB518AA54AE615AE1B58000FFFC4003110000104020103030303040300 + 0300000002010304050006110712131420211022311532341623334124304208 + 3543FFDA0008010100010502FA3739D16FD6BCB9EA9FC4912573C93315F938B2 + 1DCF3967A82CF5059E72CAC8B3ED665853D956CD8D123B60FB2A6ED635D8E4F3 + 645BADDAAC998716F2D5B995BB93469D3720767752B9FD52879F466DF2BD9C63 + 7F09C721FB9B1E13DC8BF1CE772E790F3C879DC59CE7CFD451496A987624927A + 22ABF2AB7B86343798912DB171A94DF35E6C3B8B13D28479CE01E81B5C8D2ADB + 78B58B6AFEB9F7447438C50C514F1B4DFF006FC2283C705ED4FC7FD088A4B51A + AC872318041C9EF12113D9EADC21C6D1A238322BE3B472D971EB517BC4CC8B16 + E156EE52223DA84807EA95C5CF8E1CE31178C555C2FDFED1FC7FD105A427AA6C + B94D8BE1C904DF7386A9801DD8DF7B42D331DF35AF162442D726487AD06E6A63 + D94E88F34E1292F4AB68104E31533B07050150DB4E7B5117DA9F8F78A72A8BE3 + 4D7E7AC3952DF9D6CFC883D986DF04ADAA3682B9105B756BEB09D85269EC6B9D + 72C2ED45C377CC246B94F396B27D1DA43BBAF3F9C680949457B5DE7B8BE17DA3 + 88DBA79E8A5F1E371305A7C91BA7B479A5AA9E984CB818C8718DB66EB9162351 + 21CAB6762B5223487161D59BAF39AE4AF42F57488AEC36651BB3A5BEFB535895 + 5D853E5773EEABAA1CE0AFCF4AB607A1D82AF00AE7DC3DCAD8F0AAEAAAB9ED8E + 2A4B0194ED976BE3C4058929CAC58B594911BFE9B96DA22DCB48A05F68D14866 + 14C62C254E9341D30B0B2C0E8F55E31D26A5657FA2C1B2D8B45AEB007B534AEC + BE66135965290D979E71CCFCA87CE7FBD2DFF4F7A8A9DA8BF7A2F009CA61AA77 + 7B608A6426A5589494269F71F253A5B86AC74F852819D7E63E3CCBFEE03EBC9C + 3713BF49D7586069E2A037E344C6DB42CF0A262B3CA6EFAA7AA81B569AFCBADD + 7F506B6AAEBFD42C2A4CC3C4AD1738EF8D0B5B51FD523F06D360BDE26BDC6BF2 + 5F3EE6DF214667C9630D54B0B9CA7B6F40D357360DC772C5C733D43A6923299B + F2C8D7A02857D512A0297C3409C76B8A58E222B695709971CD1AA62596EB4E08 + C5AD678DEECEC7139E61AA0BB48BDF58CFDC5E211520555E3EFF006B7F2A659E + 377C4A9F1FEED233E15090DD54F46F8A2A266ACCF9ECE811123D78FC82728CFC + 229634D9AA9B448AE345CBC8A2B6F085FCD9345A8943B0D39D3CB41C015CD2CD + 4F5D8EBF3C8E11FC77727ED6BE33B79C94FCC8BAE67FEE78855EA129879A0F95 + 179500FA6B1464CEA29AC8AC290C7631223B82D31E516A2F761BD0A28DE6FBAC + D4B8E7542A9E52DECBD433B0B16193980759EA8551FA9690B3A57D387B617A7D + 3B54CF31CA27383C2E71C3DED4E4475BA97360BDFF00E55556B1AEEC39FF00E9 + B43116168FD59E9955D1E8A346D65DD1498EF74F9F72314562EEC0D8D3F6C602 + 8ACB62AB76AAF45F646798C7BC96EBD8FEBD48FBF0A8B5061BEEA868598B1CCE + 4C6763A7526A4A441D33526F6097169D6822EC938645F37CAE70B838BF25ED98 + DF8C35E92E41B8DE76191B3ED389FE5EB559EBFF00A1F54BAB0761A944BEB978 + 359BB32D9682A5B89BFBB319D4325EED2ABE0C6D8626C8FD7CD995EFFD9FA6DE + 32FC933A79013364E97D8DE5D43E99B8DD56B3AE7E98970DA76EC7142455F436 + 0B2D4DB660462D92F7DB362821CA227FE44D7C9ED9E5DEB1CBC68A4A4789FE4D + 84D0DF7DBD55F0AD8744EA5B40A28F5D42DD87EBB794EC5D41AFD52964C50A5A + D06A74002B2F848AE4464C22D3C47442B4047F4A5EE797C613055D6ECC5143A7 + 158753557CFB54B0AB65BB3E00FCE1F7228F3E20E50BDA0C9CB7DD88AC309F9C + 04FEEED0FA93B46CC79073A9EA22B35DAED6CF85A8B15E5A154979461C76F870 + 5481E0E6F640883092079AFE50BC7DD84D280CA045C743B52DD789FB1757364E + 9E97F5B6CDD44B68ADA33044973F738A8898BFBFDB0A4FA672C01B8F4E9F46FF + 00CFB00F7CB4D55E8B4E5A4DE351C28EE1C89D3DD92D75E728107B58E15B43FB + 54BCB7D25B238C719E71FA53970E67AEE14E509049731D7394B9E564F54AA0A7 + C3E99572A5DF1C4604C1C3FC22773BED12FBBA8DD5C7379D293E8C7F22E3B9CB + 0907B5AC033DCC2303DB0B31A2D85BB11B59B0EF16E5832DC8B3685A3B0661CC + FD763A573960EA13323B71BB64E0EF3B7199ADCA688FB92DC53B374534D6FA71 + 05C2714914508D151E54557109B8BF72FB47F321A4F4C3F4613FBF60A6DCCFEA + 2BD931DDDBAE3D18EE9682DB7BB588C5D0ACFD5D459D5C82196FFA47195A1923 + 1AA2190470A4AB1498D492B39D66D052D0CA262430DC1848BFF1AE9C416F6786 + B2359D7E084180BF8044CF18A628878E38F67B93F2269E04CFF513E65C85F2D9 + 4E9D1D164CF82F5B49F48735E894271BA5772CAE6B56ADD8575FD7B52E3D3FA2 + A599013A733723DAE8D52CD96E72266554071D7811106D5E5932243EA036D2BC + 8F6CC0E46D6656F5B6C92E9DEE0E5AB7F3C261239E36FE47DCC3CA2D0FD227F2 + DCFF00ECAE99A5074A15415ECB6596DF974D56DD3D15C9EBF75ADDF81804D6E6 + B2FD58FA881045B4AF7188A3E95953E3B55C77C2D3A62016B6C0D650543F60EE + EAD81D7B8CA332214C7E14AD5AFD9D8EA554917955CEEE17DBC705DDF68FD21F + F32612FAB9116214A728A30EC321B26A5CDD39D8D507F9D2B7793AD48D4F6162 + 628809880C7256DA06CBD6B79E50CB2B0445B8BFE328757976666D36C33D61DD + 4183FA697B2B9AEDB09B6E303F83E3BFDAFF00DA4C1023AEAB64F6415FF990E1 + B7637375A7A56140D3E5CCB3B2AD72B2CA753EC8C539E57C409B234DDBA46AB6 + 9597AD58C4AA36B99366087225415199681184A6585D4AA0D1A3C0240411EAB6 + FACE9958F3CF497953E9DDC66BFD559F5F1A0755E8DE721DAD65A27B5D715CC1 + 5C4FA42FE531E739F631763326C768A4CB0FD6DF7E46CDB148845F9D7C00EC1F + 605C93A26C37912537B959C1273A8292858BBBEB3281A5EC768E555444AA8C2D + 66D5B0D66A34BB4EC73F6CBCE31309130C57198C878E1466F3BBEEF6FF00A4C4 + FCAFE207F261C95876169B92D925BEEA36506C36C62755C9DB2A1EA42FDD46EB + 6C4C2E132B673B5D6358E85AD65483078D1270DA190B71972E6DEB35AAAEA4F5 + 22C7A81679CE29E777760A2229385CF3C622AFBBFD60E1640FE428FDFECED22C + 618EC0700B851E17A337BEA20C66D5321A976B484596D6F5BADD57527A9D6FBD + 5836E36E2292A2A973F44F8CE4DD52E1B440EEC6E37B865FF69C0EDC1FC8CD51 + CF39A1790F9525C1E497C2D6234C8E3644286FFF00718F271E85E73351B57F5D + BEA09F1E7468E88433A6C3A7AFEA5F51A7F506CD2B2326132CA090FDA6D282F1 + 9D8A6ABDAD0A724AC33F0284E97B53F1FE4679FA2FEDC69A27891A6D94C643BC + A498AE16447FD3BFEADA14944D4ACE8FDC7AD810D73AE4C4877A75CFDAE48C5F + B31D795C569C56D147E3946C7E495B0E5557BD50C630FB53F025DAAA38298A7F + 6B51D5C40410073113157C2D7D17187CD005D54CE90DA2B16D2B63AAA3AFEA1F + 5B6CF6A6DD9044BDE2DE111BCBC267E323BC8CA2929927DA808A00840C8B48BE + 4F6A1677E77A679073BB9588C83B19BE509CFCA22E3AAA63C7CAE2A6369F0A25 + C56BD323BF79756F7B20DC52C4F8C51E54BE3EA4AAAAD8F38D8F71FC0A35E435 + 932B95FF00A58FF343FE51FF0030FF002987F8FF00D2FD07F687ED6BF6CAFDF8 + 1F92C3C5CFF58391FF0012BF8A7FB1BFDFF5FFC4004A11000102040303080804 + 0206090500000001021100030421123141055171101322326181B1F006142042 + 5291A1C12362D1E172F10733538292B215243543637383A2D21625303474FFDA + 0008010301013F01E4975B509972D21764A1291C02401AEE8F5DAA57BF1EB355 + F1F8C7AC561B24A95FC2BC3F378C75A33337FC621532A9BA4A98DF994088E727 + 7C7E118E67C6231CDFED04635C7E27C63CF7473CA96063214FD557C180955FFC + 70804BE1BB1C2A57C4A0007F934613918E66EFFA4225A8105258EFEE8289A410 + 5618820DF422F9DBE768A6F4BB6952D348A694A79525387A32A9A6E5FC42F141 + E96D626B973D53A9553A6652E6279B95F390D141E98D3A96997B4E5A68D4B602 + 6CAC53A92613A85075A316612BC81631E96CE95328A7CC92A0A94AA5250410C4 + 62402CDDAE3C6F1E8B7FB1E97FE49FF32E24E5E77C0B08CCB403A427AD07A2B8 + 97D61C478FB49EAA780F08D3CEF873BCFCCC0277C39DF072873BFD84A1E04804 + 32998E692035F370CD761F48712C604212D9B848173C387D6095EF278BB0E178 + 330E594059DE7B43C2660B3FDA094AB5B1D34852ECC521F807F9C52D6D5D1DE5 + 4D9890A174A662D208DCA0921C761891E904D34D328A78FC1521424A07525E35 + 95AF0A3AA9C530A96A60312C959E9178F4653FFB54912E6208E6E590C4745DDD + 3D9BC8D5E24E3E67A5985AC38CD9C59FB3484971033E42A6CADE318947373DA7 + F9421DC71F693D54F01E1EC3987E5610CF944B013C7CF7466062BFD3C1A145BA + B6B71BF7FF0028E71435FA0FD20A9F3F3E7E51A5F2F3DF9C5B778FEBC814165F + EB167FDFC882082543DE0C75B77E5C45E3D18F49E76C89A24CDFC5A198A65CB2 + 7A72D6C1A6215FD61B3744A8A031385C98D9B3D15343267CA51526715A89B31B + 8602D98BE2DD096194025E348680FE40896E543F88788F693D54F01E1ED8E494 + FAC602E0EE8BB31FA42CA536BF7C294F9400F09DCD686E408DEA0385A010E41D + 2DC5B5EF8040516FAF0861D6163A287592FBB4EE68FE8FB6F282D5B166ACAB1A + 41A30AD169C7CE25DC0E9BA741D584E7929CA7176258B149EDDDD902F0E5B4F3 + DF0F098943A4388F11ED27AA9E03C22DBF948E4B6FE44DE1A12E6DA414ABAA2F + DBE5E1528FBD9FDA0CB684A483DDFA404B96CA02144E8C2EEF053DB0424E8DDF + FB430DD0D7CE1CBF9EF8D9958686B24554BFEB64A84C49766096C45D8E9F38D9 + BB4A4ED5A2955B4CAC68A84059DE958B2C1EFBE912EC4BFCBCFE9072CA067161 + AC4AEB0E23EDED24D858E43C2132E6AFAB2D47BA3D4EAF3E696C332D611CDCC7 + 6636D77C2654E520AF99998467D17CB5B6912B656D19F205449A49CB92729813 + D12DDA7583B3AB92312A9D60768854A988EBA0A78C2059E074A108B6E852D491 + D1B9EC8227ACE22C2CCD9181266A88E89F184504E29709F1FD21745353D7494A + 7537F39B0812B05C12C54CDDB0A0791E1E05E12482C3521FF86EEDE7F7F40F6B + 4D913CECC73CCD4133102CC89A0A435CB84602AC9CE26B6B033EDB8863BE3583 + 12BAC9E23DA920932C01984F808D9D292123A01D8E7C4F9EE8DA1B54CB54CA79 + 587094842FF29722109F569B244D230A969BF58F4C8DCFFB6B1B4F667A9FA3D5 + 3572A438325231A4A0363CC87CDBB23D19A4963D12A1482A5032D730A94C6E46 + 5DDDF15C865A9994028D9B3BC6D8403709BEAD059288963EB012B5A912929249 + 616F368A4F47FA095D41C0A372970752D93E6967FE70363520BAA599AD67709B + 6E63F3EFDF03675320F42560DEE417DDF7F394A91213EE8CB77085D049A84290 + 5030AC69D67171617EB01A5BBA2BF65AA41504CB5759D2C1F15EC52D9826C1B3 + 574738969C534A77598EFDDDBC22649988EB215F2821B4E4467DD17C4FBE3D15 + 9BCD6DAA1512C39C00FF007B2FAC039712FF0028711A8856B127AC9E23DAA261 + 81446494F808A4F59AD28A4A418A7CE0B1270DCA7082560EBF9B8189F2D52EA0 + CA98B0A509AB1357A624FEF685AD6B5395174ABA1DD60DE314FB6A4D6FF47957 + 4AB5A3D629502517231118BADBFF002C6C3AC452FA25412CA938952ED7D1A2BA + A012AC9CAA2BB0AD06FEE9F08999E1897D6074702362ECC44B4A67CC4622B4A5 + 771D5C4317DE14DC3F6B4066B6F85F9FA409801CF48E70B62C64019E1EB36B87 + B59C0ED8504562A58C6B96B4A93CD15580E90E89ECF787E78DABB0C28FAC5320 + CB983FAD0325FE795BD4758A5D954B5D4E79D9CB973BE0575BE59C57EC93498E + CAC2951014475802589E22FF00AC285E07DA3E18D80A09DAB444903F1A5DDFB6 + 00B77BF71198E537CA257593C47B52A69484F601E112EBA7CA5266D2CD54A9E8 + 7C2416627ACDFDD855F128972B254A27E226F0A7E8B7C4045157AE968EAE9497 + 44DCC6FD721147E9154229A5D29056940E821F210BDA536697E658E84A842AA6 + 7281709639DE26F5FE714A9C6A4A37CD478C534B12E4CB1FF0D1FE511312C4C2 + 4744F1FB085A8BF65FED0A521AC3A5097BEE84965248D140FC883056A9A19E29 + 9489466239A4E322C62BA499F4AB51969703E79C5649C3315662F9777CE0C6BD + F14C52274B2B514212B415293D60310CA284BD1D1AA5AB9C92AA7410B25D47A3 + AC18784E908EB0E23C7DA469C390C33A44332A124F381B3684499AB4BBB76C7A + BCC17C795F4831B293CE55C91F9842BA28969F85291F2105506265DBBFED1CD8 + CCC2D48482F9421528DE13390984A90BE944B54B62951C6FEEEEECFB456EC7A3 + AD4BA65044C62EAE197808DA541EA13D72F163BE27EF21BFED86700C4B1D2EE8 + F473FD8F45FF00E697F683A437221371C47B48C877724C72B4274F3FA4160B61 + DF0BEB1E07C0C6065B9B5D2071E62DF5FAC291365C9A613141415225361EFCFC + EE8C2B2081130E15618F4625F3D578C8B0F3DD13E62425B1A6C1A11504A8A429 + 2477429640B973A42EA5495241162FF689B5400241E93583C3D5CF5151043757 + 7342672E50216A1DBC23D7710C29BC489DEEC20E1BC499BD34F68DFDD1E96493 + CFC958198BB0ED57EB1282D419B22B6E3668F46B63256135B5D2C9283D04B58B + 1198D6366CF13E98E0484225E14848B7641CD3C390C20AAD6DDE3ED24D870108 + BA83AACD7F0896B2BA85DDD21396815727835A19862D4C2B3B67BF5B868593CE + 4B9414E56136C527448904F47F13A24E2DC72D6364CB556ED19B44AEA4896C94 + FC424912D412F95FF13BF0EE895B0259521225B38C8B377F646D5D8B5B4F3EA9 + 7CDFE048595A9691D208FCADA708F4766190B9C904BE1710535F52F8716F7730 + 8D9BB44A9D151817F0151D37DF58A7A5AE968C35252B38894A93AD92C93DF7EF + 85531CE7CB0141D801A41A395327270FC4E47608F532A2508B0FD33856C40B75 + 2C05339E2D76EF856CFA5A6E9629283F0CC6B44BA1512F8A5ABF85A5FF0095E1 + 52E6237B26D99395B89E3AE7120B907CE663D25A654EA34AD03A4824E2D5A361 + 6CF44F33674E09C34EB96A6500CB279C74F6BE1BFD63654F95311532F0250AE6 + D66521980296603B18131B0BFF00AF37506A1452AFF86B4E2923FC0EAE3DB061 + CF2249717D47B43DDE0215D176DD14E8C017BD4B24F6D84359A2CE0F7FC8889A + B96AA94302E81318FF00D5C5F37B8FDA29AAE653D5AAA65A942680B0540DC898 + D8DF4B90E2D637CCC23D2ADA09CE74CB5B24E5F2F3BE28BD259D5155225CF658 + 9F33D5958908638FAA48C2C5B7FD6367D28A7DBD3A9163A2544376379ED8E769 + A85079D9A65B9607038FE1B8BEE7CE2A76E53A0CC972A44DE74CBC685E04AF24 + 82F86C43E7D2277800346CBDB1EB011CE22A4998E4FE089894DDBFDD24603D17 + E91B06EC808064BDD4159624DC36631300731603A3ABBC00AF5CC1926E72D5C7 + D19E29932E585A97A0D33DC08E04827B1E2A558E9662255489735616844F5499 + 8AC2A52484D93D0B120BB77C566C5A854F2B9FB51133FE8D40FA255F68A1D9F2 + 2952E2A2AD4AD30B87EE07ED1327A39A4A50EE1090715D44801F13DF11D7B5E2 + 9B13F644E9699B29685074996BB6F514908F9298DA114C29A9EB0A9625A64D72 + 912C92C1469D08212F99C6A9AADFF411B2A72A7CF4CF6524CC0B4CC090D2F094 + 91D13BCDB716D63652132E8E5048674A02FF008D08293FA6E82FA4618F79BCE7 + 09CC711ED22E444CD3BA127914972901EF682FCE1B0B3F1B9784B8562DF17DFD + D095A9250A4965209524FE6D0F11A4502A6CCDA145B4943F0EBC209537F50B36 + 29997B3E9E4414A2662973D226252A2C9501663DD136595B34892B4A4614A972 + C294DBAF66D32C80892272073680108C44E048C290ECE401ADB3BE97804A653A + 892A6F794A57893F48C38A763D41EE844D52540BB79EDDFF00CA2A16A6E8CC58 + 0A1FD5E2694E77A736DE32689AA50EB4B96BFE14BFDE39DF85D3C1FEF08483D2 + 2497BDFB6F080127B213D209E3F6FDE26ECF4295CDA93CE6126624CDBA02D572 + B56152138CD807072844D974FD7C2942713B06E900E1BDD39365946CC257454E + BD26E39DDBF885DB85ADE319468728D5E139A788F6A924AE72B080D677CFE968 + A9499730CB39A59FE40FDE1102159A38FDA1CF38A277B47DE32EDE4F472A25CC + D9689665F38A9751816B7FECAF2CE0C26F35D874BA1F9F285CB057B9C93DBF6D + F0538430565D9FBC20B1BDE0ADD246F1F2F3F68945E6AAD95BEB01218151C235 + B3F0D77C55E032D576E81BEBD53A4098A4964CC6ED21FE8E204C4A8B0F1FDA25 + 65968DF28C7D9125C273F789FA0B37779D7D24DA2AA05D32D5225D473AA98909 + 98A5A529C212A7E82863E07E71B2ABEB76F6D2A5A498B4CA91326213CD499679 + B424FBD84ADCB0DEA19C499625224CA4864CB97CC81FF2CB63FEFE6DA6F3C990 + 801E139A788F1F6A86A0D3B9CDC59B3C9AEEDF48A852E7554C24A42884ACBBE4 + CDBBF2F07298486B6E1E2C7EEDC6042ACC771EF8C3D22FA97838ACC6DE7B0C0E + D878F47369AA9AAA5D214FE1D654CB21BDD32B2C5933F662EF89AAC4AED24F0E + EF221C855FB32E1DD0A6B36E7F1852B3BE432E314D325F3A41500545C039E7FB + C2662103130381ACBC8B96EDC9DE368991512D3CD029205D998F60BFE99C2A95 + 245B3DD08A632D761080C966BC2AC13BFF0078A6538E1FA47A694EF474750C30 + 2272C7E6E9A2D6666B7C51FD1DD2739B6254C203264CC507D1496009EF3A6905 + B1B8EAD8FCC31FAFD21C11947CE06E84A4829E23C7DA94F98BFD3C616959AB5A + D990650482E3AC4859B3BFBA2EC05FB2067E75B9F9124774085E51AF2DA29E67 + 37532A6A4FF5381438955FC889253365CA98938B1210ADDD600EA071CA178428 + 924016FA01F7FDA25CD96B517506167B989802669505383C74FE7FA41A5C55A2 + A39C0900658C0D5272246E854E9641C6B02C1B3C278ADB08DFD250736172206D + 14CB584896541C74824A80BE654014803524B0CC9689F598558A5DE61C907A2F + C0AB083DC6246D4055D21FF6AFFF001896D3658988BBA428E9D600E4A6DF1308 + E71B8784492065A8FD63D2497CEEC59A19CCB295E967206ADBE3FA3CD9864C99 + B5B31187AF2E5A894DDC025802559EAC0401643E78595C5FCE501A1A309C4ED6 + 7EC8490E388F6A4650AEB1E3F6102042F28D6045B4F18C3A4754288EB61430D4 + B1BDB5EDB5846C7A8E729A9EE18CA94905C3157363A20EAAEC178DA844D3CD25 + 452433AB42E01CF2D7E714B4782503CEF473528A983DB5C859A11453266332E6 + 2542CEC41DECCCFF004EC856C95E27698FA93296B4F7324B5F5D038D6266CA9C + A6E693354AD344661DD2AE8F55D9F566BB44DA1912918955D48152C81325F3E9 + 510AFEC969925452A575425B11C92926C65D3C89B37D5E87FD6D6538A7282932 + 68E40FF8D52A266CB037B2445452C9912F0250E7E201FEA3F58A598A4CBC2159 + 000DF260DDCDF4D614A755AF7D2FE6D1257D248CFF0058AD91EB7413E4A41519 + A25259231104CC4E897DDA450D3CBA3A5A690818304AC0A06CA5ADC7BA6E4E9C + 6039511AA7AC3E13B95B8F18CA1CC3F61F942334F11E3ED49C8F7F842BACAF3A + 08107483941CE1373091D28F7FBE0F5879D23D15ABE7254DA25938E5FE2CB3BA + 59F7BFBA7A11540A996AB12CFD86CE3BA367D4733CD8641E974C2C3A70587D8C + 6D3D83535B8AA762818E625E72094A545407E1FAA951641BCDE75B3FC37CA174 + 9E9ED220CA97236C258D9A4AE7050BD84C4A70AD26C700CDB17BA63FF4CFA79B + 5954F36A115124A0B8F5EAA914630A412A3CD965A3A20D8E67A21B14527A0B81 + 4A9DB5B6B8654D973BD5E882E6635CB505F3666CDE89C446179770FD18A81494 + 294516CD4A29253E232A48E70A95FDB4E51E94F987E207027268A956286C12C1 + 4E6A009E24424E101F32FE314A8720F6FE9156572286A27CA239D93255390921 + 0B04CA18DCCA98C95B36F0D151E9AFA4F54512C6D5AAA696B49382984BA6080B + CC912B13B8B26FD668F41BD29995E8FF0046D74D9936AE583EAF51315316BA94 + 20625A5648C2572C0C449BB467CA8EB0E23DA444D17F9780F3F384DBE51A42B2 + 30323E77C4BD7CEB07ED127A7365A55047FAD265F3679B33CB9EE8A5A9FF0047 + D689B2C34B4ACA783168A59926B25A67A0F5D2FF002B421B114FBC16E3E42287 + 6BAE930A56A5A0698756CDF838F998ADDBB4EB49526A27CB5D9CA2CAC3770FB8 + 962DD822B6B515180FAE55CCFCAA6292D7B8ECEB0ED6308AD9B325E042428331 + 2AEB01BF88F1848575950B85870DD91225AD396B121225A712BAC49F930FDE27 + F4E96B1D785069A63FCADF785A30CD998541482B5371C59C52D44FA59F2EA699 + 7CDCF92A0B96BDCA07C0E47B1E3D1DDB9236E6CD955125425CF0305653EA99C8 + 031848FEC88E9CB3F01C198819461EC8466388F6A56BE74855CC08D20C1CED00 + 3081977420DC29D8DEFAEBAC73B50162FABBBEBBF7BF6C28953E2D492468E4B9 + FAC6C7DB6BD9B35089EA98BA55D8F4D479A73EE02593A9B35CC499F4D3B0CC94 + A4A82EF2D56C587F32B3C4EFABE508E6D600535BB05FF937D62752C959E9616C + EE036EFBC2E5C8961E526505272381219FA2741A1312821C28F3618825827211 + 36A909EDE261730AFAA1B844B486E97D610B486F0D3E5FA718E702F092F65325 + 2323DAADE076DB38F4A76F9932D7B268549E794099F39070912ED89216963AE4 + F0CCCCD81AC7DE277AB79CF383D555DBA259B7E91E8A6DD9FB13694A9DD134B5 + 089722A50A2E9C38AEA527AA4A2EA048706FDB0898898996A94714B5E29885EF + 4298CBBEA0DC8E1C890E53C465C7DA49C396E8E91F2212FAC13610F78673BA31 + 5F0EFE4106F9BC089870CB513DD1B176B4DA35CB429D72A629DBE15164E6CEC0 + 2459DB56B989754A50410B170FEEEBA65A7F38A9AB5A51A9BB7D1512E72A64B5 + 8BB966EE20FDA39E9C85328921EC2C3C2254C54C377D60CEC23A1D6F3BED099A + 4E7ADCF13C225E1CC5B7DCC6D5DB52F66C9510419F3105082C0E1771D52E927B + 4A6264D54E5A9530952F115295912557D1ADD9976465DFE72C87740316188B94 + 820E23D8431B696DDDD78D83FD20D66CF912A96BA965D65348972E4D3992AF57 + 9A9972834B0A54C713308CCF5D5AA8E714BFD246C99EAC1514B5145BE628A67C + BEF08C0A1DD8E3676D3D9FB41226D156D34F4D9F0CC9683F299392BFFB0FB4D6 + 19E5D9FA40CA042838103331F38003C16E4006AFC953FD501BCFDE25A7A09B9B + 061D9DB1B0AA6A9737D55044C2CE82B25ECF6CC023BA153AA50C99F46754AD41 + DB1E81373EE851BBC05B164499892AF887446BB81FAEEED8099EBFF772FE4AFF + 00CA24D39CD41B85BC5E112827A572772AE3C20A921CD9F36D22A2B514D29736 + 69094B13D1B5F2C399B96B718ADAB9959379C5B61FF769BD90E48C4EA3D3B972 + 1ACD6DE6D7DF00F2151B861E7BE016D13DEEA63BC05123E8606F21D5F1F4B177 + 5F0A7FB894C4B38158D365E931CE2FF103ED7BA3BBC21E13785160235848BE7C + 8DDB186087D6044E4A96948032D612E80018A59E6454C89E92A0A97312404AB0 + BA5FA6E58E568A69D2AA24CB9D6C3342577388380DB87C46F134CA7660DC3B20 + 197760C1A0AD2323F485D4066C3F5FDA27D4A10852C9C210EFDDBB7C6D3DA5EB + B30A10FEAE0860FD650480559599408D5F3B3C0BC2A05A1E1FEB0D02006F698E + 1058B5BC39110B36162203BBE12D0905E1B95C6E868058B185BBC10F61659EA9 + 3901EF3EBB9ADBE3D16AEE7E8954C544AE9CE24E57960E15017CDD693B981BEF + 252A3770DBF73663B1EDBDE2611EE90DAF6EFF00A42D405E2A2A5325254B2C3F + CDC3C88AFDA336A964394A12A525237A52583B387667D338C4E726E1979FBC08 + 569C99186CA008118BDA4D47E1251CD8B2121F7B067FBC2F376607CF8C24B178 + 455E1052652564B5F77F382B2A2FF4F3E78C056F8710E21C431851B40737F945 + B5852496C3DB1B2AAD7B3AB25AD27A2AE82F82949727E50A5B9B754CB4E03F12 + 090A7E2E38FCE26288D6274E025E22580DF1B42B955842524F368BA4DC3F7791 + 0C33399B9E3006ECA1D8C3BC0E410E21DE0DBDA4F553C078410E238C22FCAD0C + 391C43B93B9E38403037C1E92C0DFAEED5FE8236655AA7D0A1EEBA73849DE9EA + 8F1F2F0545DF717F946D62B5532F096E1C8D020C0E4105B7F226CD19E7F5F693 + D54F01E1C852610087E510AFB184E907D8130C27531E8ECDC46649F8DD81D708 + 2B3C5825F80BF64F5CB94933164096332E2E075803BD9ED15FB4B9C4AE5D3870 + F6C5E6FCA7381C86041CC7FF00085D85B48E7239CF378E738FD631BB46696805 + AD0AD613A461EC83CA9E4953D725626CB514AD0E52416CC149BEE209046A9244 + 545754D49C53265CF4548169784D8912F20B6F78646F07907B472E4EAFB69E43 + C8207DBEF03AC3BFC2179F74274EFF00BC1F3F48D7BE3F68107EE7915A777DA3 + 4EF99E02341DF1AFCFC613D61FC31FBF22A041EB726BF3856B08CBBFD8FFC400 + 4811000103020303090506040305090000000100021103210412314151610510 + 1322327181A1F02091B1C1D10623425262E1147282F13392B224435373A21516 + 303563B3C3D2D3FFDA0008010201013F01E6761E897389A6649249E24AE8680F + F74574387DD978234B0C35EB2C985FCAB261B63106D1D8D83F0595BE82C8DE0A + 1BEBFB733690A951A46CED37F3EEF24F805D9ADF946E1BBDF2534D3BCF08F345 + FBB459C1374E2DCAE8D60C6CBC5AFB2FB762ADC8386C4D635DCE6F4875FBE72C + 47D9DA1FC3163A8D5A76FC0FFF00F5958BFB355D8D3530958566B75A5521B51B + 1F803AC1D96225B63122C5721D17D3C6D01529BA93C625B998EBB8751DA9E221 + C3810B94FF00F37C6FFCDFFE362C776DBFD5F25A294744EFAA6EC4743DC50F64 + F316B4EAD07BC02B233F2B7DC116B7F2B7DC135AD9EC8F7050370F7281B87BB9 + A06E1EE46CBA4248C92D2DD1CD395C3B88BF9A9A77355CE73E75712E27BCBA49 + DABEE0F640E320796EE2831BC0DBD59399C164236FBBFBA6C8BDE77CDFDE8520 + D103F65568D0AE4B6AB01224071682446E24582ADC894D952862A8805E1F99C4 + 34667112D6E6204986F5413A36068B94DAF6729625D558417563B356C003BF4F + 75B62C7B9BD20CBC75D9A68A5123D053EAE9DCC743DC50F64FB31CC79A4A7532 + E020EC129FD4B36C77EBF141BF9BAC7D6E41A3721D5D11D54A109DD4ECFD7E29 + D2402770D8377726BDC2F3C741B2C3646CFAAE5AE4AA78EA6FAB49AD6626C5B5 + 25C43CC996B8125ADE04341F25CAF45F4714693DB95CC1D60759B4F81D9C1658 + 450D53A10D88E87B8AFDFD93ED9E69854EA03213CFE11A6C275FA264C5F7FD13 + 444A7181CD75A26E6E053E43475760532C16837B78AFCCD37CDB0E9B63C45D7D + B1E467BA9B3946882EA8C25B58BA082C311A0065A018BF78474E13653CC42692 + 9CE371C0AFDFD92A6FA29E0BC103CE53BAA25129BD5BC4CF185FAB4E1AE9C507 + 34A6B827191BBD78299B2062DE128095A180E9E31FBACF574CD986E8FDD199BE + A8EF58EC3BB1785AD433435F4DD9AD9A360701224F0912B94B095F93B16EC3D7 + 6E5CA4E53F9C1B8781DDA893AEA8EBCD28593B69E050F64C5CC85D253172F017 + F158690DE940274BEA56666931DEBA5A41C1A6A3412607155B94B0342B1C3D4C + 4536D56C4B677A18EC29B0AAD3DC754DAAC78EA994F70214231036F720D93C14 + 34680C7AE2B3B364FAF14FAECD01B833EEF1EE4CACD3E87D53483081DE80817D + 5496DC2926E754544C1FCA418DE3682BED8726D1AF44E35A2F421BD6ED1A6419 + D241707445F4DBB11ED1034474E77687B8FC10F66B400EBED2B1B51D261F698D + 7430B0DC9C2A369D5ACF70CA73B76CE9B93C3ABD2AFD14F4949931D99006C275 + D3417E0B03CACEAFCBB4306E74B8553D43234F25F69F1557FEF46261C5AD63DA + C807E4B01565ADB9ECEB75C9AE379748D9EBC536489D8A4013B1748C01CF26C2 + 75903E0B13CAF95CE149D26DB0EE1BC2772BE21C6E366F471F54E9B75F927D7A + EED1C41EF54F175A8B866792758BC697BE93171C6DB960ABB2B52654CE351336 + 83FAA74F1559C1B4E46B1A6D8DF1AC71D1748C7685079D398ADEB97A99A9C998 + A004F527DCAA08A8FF0077B910611E67CF915FBFB3883DBEF3F12B11530F870E + C4627AB4A9B9BD2077E327B31FE9EF1EFC3BD956853A8C6C31CD058DFD274F8A + 6B58C1980EF1BE41B2ADC915307F6EF0B8A635C285679A9FA4123B3BA572FE11 + F89FB518BA8D692D15360F3F9AC1E1B286F705861932DF6854FB0AA59A46D5CA + 18E2D6BA9B6DAB67BAC849BCCDF5F150A141404F699C018D371F037EE0A95476 + 18BD80E7A6F6BB3C1B17C1CA4700627B9613950E6C955E1C47F86E71FF00A6AF + E9DCB118E7E1EB40BB275D8B0D8E6D588209201D77840E6BA3CDCAAD73B01880 + 0127A3758772AD6A8EFE63E4B35B98277C8FC17EFECD4A41D3DE9D84A35699A7 + 5A9B5D4CBA08317819C13E253000CA795B95A1A200D80181DCA764F1588C2D3A + D89A58B23AD44FC8858CE42A0EAEEC486C3AB75A553C03582E3B29B4DADD8A9F + 65620C07BB734AC6D6CD51FB7AEEF89549DD51E3F14DBC2609941BC116844083 + DCB264766557A47F69D2B0158D3AAD6F87C9507C8D7673D69E89F0039D91F941 + D09CA572966662AAB3241355E6A5B43368F60E87B8AFDFD928EAA9765FDC87CC + AFC2E554CD1603C0FB954C4B3341BC6C431148D832E6C9AB1872D2ABFCA55413 + 51E6357B8F99541B74D6FC5346AAFB1369BCA7D272349E9D4DED4F1518E0F6AC + 2F2A626996E69CBFBAC357FE2180F1F903F340C8237277D7E0BED008E54C45BF + 11474E73D93DC57EFECBB6F77C970D8A4745946F27C87D16C1C16C7777CC2A95 + 1CCA6C6E406CF9B0D33FAF92A2F654AD8BCAD7362A99CDF24D2D045F6854EEDB + 7BD72B3A199778286173389CAE3249DBB5330ED68BB0A6D26ECB26D19D153C36 + 630EB017F309BD0B1994C1D13E936A1195A50C19557081BB556A7123C3E4AAB4 + C8E0B90AA660F1C7E410B5CF158FC6CE6A349D0F363DCB97F0EFA58B617B81CC + 098DA9DB79F63BBBEABF7F648B9BAACE3470F88AC0672CA151CD6C6D8863B507 + B71241B366EA931EC6D3CF98CE1D8E25D725FD60F3FE691FD3087D57E13DD6EF + 9552A4D361CD01A1CF27F4FF00891FD43A8371702B1D887E0E8D0C51D31E2ABD + D3A50A8C21CC1DC58EE84EFA8D2FDAAAF2EBC13F78DDBF0D755C95CAF87AF4A8 + 035A935CF606712FDFDE572A303C31D3B7E698EA14DAD9CB6006CEE4EE50E4E6 + 487819BBBDDE50AAE2F08E334F4DFC6FE5099896C9CAF3C44C7AE2BF89EAFCE7 + D7A09D8D6B0E6378FECBFEDAC469469372FE271D8DDA4F70BA663B16F19B2547 + 0FFD390AAF283FF131DE6BF88CE6F69B8FA2C49CBA1DD7F05C85896D2AE5AED1 + FA03A4FA01728E2EAD26B59444B9D9A780EAA736A33134AA54EB0AA7A327582E + 07BF423DEBED290EC5537ED14E9B63739CC2F71F08828F39D0F715FBFB42932B + 7DDD412CA87A37004B65860C7560EA267C36AC4C0AD5036C348DC00D07AD649B + 93CC34F11F34DCC194E466B5205BBC7450F1EF589E480F2D6D6C4F4B8505C686 + 13A21349CF398E7ABDB734490333B86E4EFB2F80A8731A54FDEEFAAABF676861 + E974B4DAD68A4ECCC026C7DF7F158AAC4E018F1FE203D63B23BB44D3FC6598E8 + 3B4CAA7C88F34CD5AAF6B98D7B5B16FC5C7558AE4A6522431CD190005B9DA24C + 669EB5F4205AD629D22A65CB94B4D88734E6FF002EE8DBBEDB54FF00B3DEE75F + 23F5559F503D8583313363A1B1B7ADAB06407B1F5A9110F667A02B53EB343813 + 209CC4113617D82EB0D8DA794369614B1BC23E2562F18E78B61F0B3FCCA1F51E + 5CF00758986E82FA08D40F455664858771A759AE060836F71553107F8BC3CCB8 + 3B0ECCD0DB0353579DD111F258CA5D11E8F28B3DB55AFCC5D9B71826DAECB2E5 + 9717E36A875F2416F026C74E1A7922147310329EE5FBFB2E80A90900EE39BC76 + 2AB7A8E3BEE798687C3E2AA5368E8082E12D93A7D138D23F89DA5ECDEB77CB67 + DD09A29668330377AF7AAACA591C2E43B61885880D0CAF861DA6B4933B05F458 + 72FA125B37B8F56F564CC5BC8CA6B54826489B4ECD8AA39955D9EA75DD96333B + 5B4D935A3F89765102469E288193BD54A4DA8234CBA458EBBD50A2C2497D263D + C3FDE16CD48E0ED8775A414D14C7FC56F73DC9D45D33F2108DB60F5E29FD6047 + C11EABA771F84FD53314F75DA60F46CA640639D2D68396E349933E10853AB529 + 97439EFD8EA8746CCE502D03DE572B107946BE5BC06877F370475E6CA9D607BB + DAC4D56D26C93A988D3EAB0C73D063C0B19FF511F24E17279B5B6F855FB3486E + 62A6D999F7A7318D121F33C3F742931ECBD4F2FDD72CD1E8F1B54B6AE5765BF5 + 2735B4ED5BCD35DA48F09D3C935AD378F0F246222238A601D269B45F7EBC13AC + C95D37588037DE7C772C33DC1E3AB3D61F1EE44753388EE8F9FAF927B5C04A70 + 9927D1596E4CF8782ADDAF5BEEB923054F15D237A4A94F280E3908BEB675BE07 + 7EF5CA14E9F26E06B621A5CF7369FE3744CDB583DFA70555E6A577B89BB9C5EE + 3AE69F846FDA9DCEEB83DC87B38BA1D365122C64CEE541D87A583A34DA731C95 + 0CB72916A867F166D5DF9761E12ED5DDE799BA855EFD17742148B29198B8B44C + F9808E1EA905D6883693F45D155CB6F9AE58C19A945D5CC74AD17378F0B2698B + 9DB7408D89C2C9996788D7F6FDF827B1E69E60D2469E53DD0853A85F2045CF6B + B8EBAAA199925C4784F7C5E1371074BAA957A89EEDBE3FB20FCD9B2F9A7D9F7D + ABECED48C5D7A676B078F697DB1AFD1F26F46DB17C0E1B4EF9D9B94CBA7788F1 + 0883C39CE87B8AFDFD97EA7F5372F7480151C28A34A97DE1740AE743AD4AA1C0 + 6724BCDA449DD73BDFABB8C91726DE37E66EAAB19E8C0D47ADA9FD2E411F16DB + CD1FE232F54CDAF7FAA6BABE55543AAE1AA0733B4C765F01E5E4557965578D21 + EE1E7A2A7B1550ED80FA94C68206690E1B329F8C70F52BA73D0F46046D060DED + 1BB8A6D170971F746FF5B553C2B5E1C74B14DC2FAB2AD867319D583FD4CFFECA + A0CD9A35048777837E06378B1D8A98CAD9DF37F2595C5E330D5DC34B715C92EE + 8F955B2603A9BDBBEF2D8D257DB3C6E77370C0DDB78BEE3B74DBBD4767CF9A14 + 2A8065B6E5FBFB2EED0F5B911F70C3C0FF00A8A3CCDED37BD55D5A51A8E80034 + 99D802E9DC1AE218E8D260E507BE210C53F2FE1F5C153C5B880D7068191C0E6B + 7C7D68B94E9457792226A3CC47EA26DEF5866ED3EAFF00546B1CD95ADD3645CF + 18D638EFF14E7D611F765BDED227C90AAFD0E56F7C04DAB17796651A891BADE7 + 08D4A9D62CA6F8BE8C711B76C29A9F8A69DE3AFD4BEC07345F86BC174AD79825 + D1E4AA06B418133E6A3A9BB5F8A23AED813173C3E8995452C60766021AF32480 + 26DB4AE52AF57178AA955D99DD62D1627E12B64ECDFB3D8A9D9F0FAA1EC95D63 + 4DA07AEB14E046BB44F3304B8275DC070F82A8E2D2DCBAFAF92354123FE1E8E1 + C4FEE9C187B28B69EEF25CB787FBF0E8B1263DF3F354A5B6DD3F34E243F38D96 + FAFC532A0A85BD23A234F1FEC9AFC10307ACE8DBE08E2B06CEC8B8D32893EEEE + BF75D57C4E7EC536F7B8E570E200D48D637A7567D6B4EA0D5FF2D935A9CECCEC + BBADEEB2ABD591BBFBA69B39CA816E231EDA5504B09CA5BBE48DBEB72A3F6579 + 02865A8EE4EC33DF973BCD72FAA2F1D9602329248BEE96AFB5BF67A9E11E71F8 + 16B6961DE5A2B5065A9D12E30C807F31461B63AECE66B93F4F02BF7F65DB561C + F511339BC79A9F6C2776DBE7DCB1218DCBD17F57CFD5D39B4FA50D1FE196DFBE + 3EBDCAA65633AA8D360C3B5CD588A031545F4DDA9EB37D7AE2ABB1ECAAD6BFF0 + 98F3FA2AA5B94FADC866B74659C43F6EE8F3F2541F5A60E1A9981ACF11F554EA + D616E869B4FE62781FDC2AD673CBEA9133D56F65DFA7B8E89CF8ECA6B913049E + 253C0A864E9FD962B1047DD51B98BFBC8F92C0F5319463B4E7F5FDE227CD5271 + 34A903F902AF4A9D7A3528D5134AAB4B1E37B5C2085CB7C915B9231D5683FF00 + C32ECD4EB6CA945D39698FE4D14337F31D0F7143D97265818F5AADFE3CCDED04 + E3D609D120693AECD554A4C6D66D30E969124F1F7A7340744C8DDAA761A19D57 + 9CBF967ABFE598F25A1EEB2C6F273714D2E680D78BE66801C4F7813E6557A352 + 907676F64C69AFEA3BF6A7120CC69A7054715523AA5DDD27DE9952A54B3B3771 + 27BF7F8AC43AA09686EB23C8AA74DEED6DCC5AE71D480276EAAA986E51AF9A70 + 2CCC76BED9B6B62E20EA249D8BECDF22D4C4D518CC43603740E121DAF58876BA + 0BAE03B22C1188BC8DD1ACEC85F687916872CE072800622835CEA6ECA33C8BC0 + 3AF5B6C1BA734B5F503DA19518EEB3223290632C6837C42246E4743DC50F6613 + 22E13A2F1CCDD565CCE0155A105B7F5EBD6C4DC3926336DF57D53E9F46FD651A + 7558DEDCB77437E9F34753DEB0D4CD4786ECDDFDBEAB94F00DAC2A7546667575 + 777EC3ADF6EBE17AF850D9639B975DF7F79D9F3584A0C61B3A7ABA788F5E28BB + 2556DAD79FF294594AA364360C6F3AFBD3A9468BA3CA7ADA7ADAAA38090DB0BF + 1F8CFAF14F8024892572772554E51AF71F72D83505C6702F1985C7F4906EA952 + 65263594DB929B5B95AD1368D6E4927C49510206F950AF3235DE45BDC2172C7D + 87C3632AD4C461311FC0E22BBFA4ACEAC4D6A4F7FE9A6D32C9DC328E0B13F60F + 94A9B3EE71187C43BF4E6A5FFB9982C672763F024B31185A835EB963C8EFEA45 + 90F666E858CEF4EF921AA6274E611AA7B6A9B9D9A45BE653456A77CA7C7F64FE + 91DD623E8BF88A9963A3EAF71F5E4BC97270FF006800E8584F8895547DF3CDEE + 493BB77BBEBAAE52C3D10C154B6DD7CE6D6D2367A84DA7877B7352AED6DF4312 + 8B1BA9AB4CC6C6EBBB7959E8B7F1BBDE23E1F0557123F0F9AA959EEEADA384CF + C55EDE7BD50C33F155994A9025D3B74FAAC1615985A591B21DF8CDBB50018B0E + AEE17EF51B3728442201B112375FE441F34D60F0DD6B78C66F792881FDE0FC93 + DAD7769AD77F331A4F98F686A799DF2410B1089CAE053B104C5B2C719F904EC5 + 666E5B77FA846BB0B72E51DF2BA7674796D28DC92B04F14EB7484F65A446F9E3 + B3DC9C733DC7F51588A7D3D17D23A16993AC7C3558AA270F88AAD198758D8122 + DBFE1F254F3878BBB6DCF71598ED28772C97999F054D8EA8453634B9EF758016 + 8DF3DDB217277268C13017106B6A5D9632DC90353368DC8FF7E277ACCB32D565 + 5308DFDB9B9E677C934710A620EC4F70744156DEA02025419E0A165394458ED3 + EF434B7A2AF078C6BE2BED2E0FA3AA310C80D363AC924131A7E94D7BACE6C94C + BB492D3316F04D6AA1877D4A829B7AC4EED1BDEB93F93DB83A521AD7567412F2 + 0C09B98912A23F7D78F9CC70479C294EFDD0BACBC3DA340E7738543771746E93 + 29A604137088CC13B0F26CF2D2BA38B1766459C56450506AD9298D9D74D89D03 + ABB9411665C6A7BFD041A4919EC20C2C761462F09569BC75DA73B3C1AE1AFF00 + 52A743A273D8E1763B4F25961BA6A08546839E435AD92745C9BC9CDC234B9ED1 + D2BFB5798F113E4B2C782308B516A82A0A82A093C1342807DA2B6A09C6CB8EDE + 71CD126362FD20585815082245913736906C780DFE4B9470CDA58A2E160F93DF + 6F45340320F70E2B92CB4629A1E10D512A513CE74574D0B6C0B95A779D9ED1E6 + 08F39D13762726B7D9D87DCB96E9F51B53F2C7FD4E0DF0D6CA8B0D580D049302 + D789582E4FE8DECA8EDD7E73AF3822F3B910759B6E410D11EAF5B6EE42E336EF + 5FDFDA850B2ACA88B2636C8B6EA13966E3CC34E729F866566965412D3123C411 + E60154703470A65B4C09DB1A2EAFA9E63CEEE61AA1AAD2EA27AFEBE28E9FF845 + 37E88E89BF24FF005E48687D6E5B3DC869CC3E9CC3D7BC2ABD81FCAE5B4F31E6 + 28A08E899A8EF4FF00C3E3F05F80FF00CB5F88787C4FB1FFC4004F1000020102 + 0305030806060901050900000102030411001221051322314151617110143242 + 8191B1F02023526272A1061533C1D1E124304353738292A2B2073463B3C2F125 + 35445474A3A4D2E2FFDA0008010100063F02F24681DB86345E67905031E949EF + 3FFA639C9EFC7F698FED7DFF00FF0058D4BFFAB1A93FEAC75F79C7F3F2D36CAD + 9D48D5DB4368CD1D3D1D3C594CD24CED658E3B90013CD8B3050A0B3B2A0BE2A7 + 6757D14D495B4731A7AA8265CA6198287C8CD7DD9BC6CB229562AF1B2488CD1B + AB9DE4B3A89AE32A8BB01AEBD3C2F6BE1DD4E604DEE3B3C39DB0AD27A04DAF72 + 06BEDB6BD3052195C36878643A7BBADFB3B311C0922AA449915418124E801937 + F47521B3DEEA1756D755C19A56855A60B94CEAA8834F5DA1318B74FD981F0C08 + 36941E6ADC96A51B7D4525F915940B8BF7E9E188B779195DD0E6537074E8C342 + 3F7E98A807FBE97FE7894FDFFDD8EBE4BDF4C5C31C76E0788FA43C07939E3D2C + 733EF38E67DFF46C31055453CB4F530BACB04D0B14923914E851908756EF50DD + E0A360CFB41AAAAAB266DF4B533643248DAE7CF24F2BADDAF636CB75195D4DF4 + 3929D7293A0CE845C35F54B7D58D6CAF0B96500F57CCAB28BC2D9B72533EF11A + 4D7779866DE22DC840CA05EE6E5794B68C696B30FBDD6DC29C20F2B8BE2E54DE + FDA7FF00D89C34492D646244B148D63AA53C4328DCCC73B72E1CBC4CCE020163 + 9E27825A5DA9155476464A6929DE291778B96396030CE244394E4AB8619267E0 + 10346A65C7D7320859B2E43983B359AEAB2106D2A9D489F808F45D893882795A + 4AFD88CC9E710C4BFD328E3BB5E710370B2C0BAC8699D859247758A3532E3CF6 + 8A649A0A866923955D5B32C873A1BA923552A45890C2C4137C49F8CE063973C6 + 51A6A7E38CBCC1EBD98B69DF803BC7C7E90F01FD4D8620AA9784D410D1A65CCD + 1C6F97732140D9DCC9E985456BA34590333C9E6CF1C4BBD9F51BD20660D6BE40 + ED9E3193D26E14637214EAB20E295A57B7A59EEA2FEA8372580FB5A66E6974CA + CE486F70EDBFB3DE3B70D1E6B06B02BAF2FE3CFDE71C4BEDED03BF417B0F13DE + 4E1784EBD159873F10FCBBB01B7AA248E42DBAAA4969E5E25CA6188A554B14AA + 8406125E966B3B5C5565CA9FFB2261BC59048B4F26E9999726731EF847179DC9 + 97D342AB69C4F24376A96941DA4B4E8166C8B5305CDA4B24684C2B99B332CB69 + B7EB965A6764124686DBC8B69D1BBC91B001240D631D445942A48AB709511598 + 266C82A5544C99CC73449BAA84229A663BC8D4F02487D29A05B928588CCF0DEC + C5988E79B02A15B3248EC51D7911A5BE4FC71DA2FA616F816EA71CF4ECC73F66 + 17C47D21E1FD4A1600A67035D158E86D99B840B6A737081CF4C34ACAB3D44ACD + 0D2A71E79A43BB45215644DDC0A8377146A22448C4B9D86EEE4AAD38A7829E9D + 523DEE669E5792CD2D44CDBB5FAD9E57DFB7ECA3C8F1A41F519035EE0FBCDB53 + A7A4D6FF0051C5BA30FBBAFB89FCB51E4E286EB20B02F7B684162962BC5EA1CD + 9C056E59AC7017F637CB737BF336B88C6ED980EAB1076163C0FCB0B4F513C555 + 4ACEAAB5D42D39A75B9F4DA29E922AC5E1B96866A582A2C2F90D8C6CD4B4F2C0 + E532D424B4EF14EA55B2E49A32804A2039904B61F54FF555514754AB4D8A46DA + 74AEE28F2D23ED0862CB99721969E9EB40CD179D531DFAC32092582B693EA229 + 1C53CD1C4B35146F048F185AFE22E8F3EF34A860C380CA0C6730DD966CD19DE9 + CCF26626FDB6FDDCF9F33EFC4BB02B26204EFBDA066D6D20FDA407AFD601BC8C + F6875EAB61DF800F418BE6D3170DA769C5C1C2F75BE3F48787F5006028FE44F8 + 7B31E722369AB978A17DE345E6EF981DEEF51D644BDB2B98D849BB73BB68E648 + EA2200BBBB3E7E10A4DC6B648D2103228BB121515156FEAD931CFD9D96F0D0FC + F4B1C5B11F0DACBE9746BF6F6116B76DB9E39B7F9731F781F36C08B74F3290D6 + F375DEB067D339A667166E5FB19E0BD85EF9729952ABCDA58DAD12C55F0D5415 + 50F264969EBA97202E81B7924153BF8E40A37F4554129CB29A73BC5428F0D56C + DA8859E1CF94C322CF04B2C7C57FA9929EAE65794AA87DE7062344AC9EA234DE + 4516FDCA33A1733346DBF2DC0B25E430485A359EED1E66CED872AAD0CC6F9E20 + 39F09DE8C96D436B742387D971EA9BF675D74C5257C1FB5A59925B36ABC26E56 + D7B104020E29368D1B868A45E25F5A2947A70C83A3A1E7DA2C468705B90B63F3 + E58207438161D9817ED1F1FA434C70C6E7D98BEE24EDF47A63D038BA44EC0732 + 05C604F1D1CCD11E4E0698D69DC62D2295F1C13DD858E35CCEE728EDD4FCF51E + 38D9FB3E3A5CCF5519ABAD9E528BBE1999C04257790D053884455754ADAB8A91 + 1BC42438F30D9743251C2EA629EAE0465ACADD32901E532BC74E480FBA589642 + 0B23902CAA1A38EA82FAED51AF1FAD66DDA2E5ECBEA3D624F115568A492F6D63 + E97EA0D883E16D741A1E6A06E5110B4B90F14AFA017213D6D19594B59583F61B + 2E659A03F76F70C3B2C57FE571F885B1115920DE2BA08DF770D2D56F5DD0461E + B84314D2C8E4A6E8D4D4C8A11594BC113313B8DA4F92A4A189A68E14A7926DDA + 15A6924D1A11508DF5323451D33843F5EF26F649F1FD3292685E501A9EA02C94 + F9F855B7F4EC02C5517564CFA7144EB206CD32B9E39A537B3659540570C4CA8C + E847186CFBD52411F58590AE6D6EC329BE843126DD16E75B0E97E2173C479E3A + FB75FCF1D8DF3F1EB83B1A450D4D5E7347A8FABA98E3F759D16DD38801E3EEC0 + D2FCF0CDAFB0E34BE9CEF81A751F1FA496EEFDD8170A3D831550468AC1C6E95A + C387B72F79EDF773C53A4A51F7991997D2B2BFDAEFF1C354C50A6465CDE88B1D + 35C531FB485CF75EFA618779C5C7E5E385F9D79FC9C455D3C22A771AC748FAA5 + 4CB63BB8E5BDC345BCB3488EAE9222E491191DC62A238D8CF5B59BB8AA2A0C26 + 5967443085829865731411EE6386921CB1D3D3D24490A8CA72015156ED4ABC21 + 69E50951294205EF6CB1A37AA138D97AC84A8C21964A89081A23B1DC275CDB95 + C888FA1E25011EFAC4BA0C2B84FAC560C2CAAB1DED661A01746D0E4CB919B35D + 006CB82E94908916CB1EE0A460A264CC8C1D35CF663AB70DAC2CB752CB3ECA96 + 1322155757862841B1D5665DE344C786489A4CFF005C8038904CC30ED25C4F4E + E53366C909A67668AF51ABE416646955CBD30A694ABC8409515053CBBC795D95 + E9EAC79BD453B41B9DD7D6477A2943A284A7576A9963B115015A3A392A569089 + 1596D712831659329259951CC41E22CEAB2A46BE710B5DE28DDDB0049662A4F1 + 1D5B9B31BB1D4DD98939AE6FCEEA00C69CBB3E40F9EDE78F7E2E71412194A2EF + D15EDA12A5941047CDFD6C0E2B8207B716C10074EFC6BCEFF9601EF1F1FA4A4F + 62FC06051512869E557B6A142AAADDD998D800075C4B1BFA7148C8D6D7890D8E + B8CC492D7E7D74C08AE3CEA9C1420EBE883CEFDDDB8A68C9E228491A73386F13 + 86FCB1AEBAFF002C1D2FC3921E7659242AA5CDB9D94B65D742437318A590C579 + 5F74CF265B1CECC8353CC8D4E55D72FB30BA5F5ECC036E761F9E2FD98E5D79F7 + 9B8FDF87465E57B761B00D7B1F68B72D313566CD410D7D2DAA52555073EEF387 + 474F4648A485E5464906564629D96976CEC58A655A31BEDAFB1B52F416D1EB28 + 7D2924D9C198839496A3613C7511412AD4C34737F4B99EBE9633956E8AD0E562 + 489222099212A1B895A26DE1B00D91CE0ACF111672A1B2928C3D564956F1C8AC + 2D6E21272CF1A1397C9617CF9805ECD7F3B836B74B330C294D6E8A48EC7B59BB + B53C5D9AD8682C285DADFF006B841F02C35F7DB1111FDDAFBFF8E34E98607D96 + C0EFBE3BF32FFC87D25B760F8603C32B4521565CCA6CD95B422E3B461989B937 + 249E649E64F92A612CCAB32FAA3D6B587C6C711A4B1964CBC0735B87A7E58F40 + EBF787F1C5B27E63F8E1BED5FF002EBEDC411F32D3A7FA6F8A7CABC7B95E5D0F + 03291F85ADDBA6BAD8DE3E9A72F9F9BE3517B63963ECC7AEBDFDDE18EDFE63BE + F8CA78895B58F2D47A3D74C6F0411EF16C165B5A4CAA32A8CCB6F5380FDA5003 + 75BC9B4F65C71D0BCDACD1C51AEE4B736312D83439F892458CEE6452B786EA77 + 932344F244D0BABAD95F2A316BB730E0C66EEAC8926BC82DF36274664056E57F + EF4AF80608F6D72B65935F475392CD71C4351D003A9B73F01A74BE0F5D4F7698 + 88972833A92C0D8ADBA83D0F7E28A5DEEF8353C4778350FC235F6FAD7EB83CB9 + 74D717BDF17B78635FB4BFF21F497D9E469B2B6EFF00679ADC398F4CDCAF6E9E + 4F9EDC51488A774E00B8ED112DFE381C605D411E975FCB17DE7E67F8E0976D2E + 476F2C40145F2B03FEEBF2C402DEA20FF68C770183A74C711ECC698245F5D7E7 + B390F6EBD717BF3E9F275C1C65E87E7F9FB71722C7B45AFF009DFC2C430F1C4C + CF06EE52AE5268C056BEBCF565397C2D6E56E8F0925A3CC7293D35B053E23504 + 0D4106D63E4B0D7C3E4786366F080053275BFA22DE1FBC72270C7B702D8E4799 + E4700763AFC7E95FBBF8601E87DF8A3D9D2D398A1ABA87AE495975945C22953D + 9C045C731987A37F20F11F118D83B45E6A698D5B55D2F9965324E81A9786531C + C1A0B69E9C604803A1BE6B5A039AEAD0A9FC23A03E1CB0473C588CE01E5722E7 + 5E76D6DDA0653DF895C800A32F6F2B7CFF003C46924A99870E5BEBA0FDD6B777 + 6036C0E24170A6D997372D34BF5B697D49E5842B22BABF2286E1BBBF8FE76B1C + 700BDC5F43817F44733D39F6FC474C642573EA331FDC7D55BF5D09C3A5456AEF + 06BBB8F8DBC4F2CA33680300CDC9012080E29A9AADD95CA8CCB113985AE32ACA + 5AD72002DA3310109E2CA52A61521FD045169D08F559239A6B9D18E8AD63656C + A49CBBBDD491C83D10F94175EB78D25778B4F565B31E6233865E7726DF69791E + 204291DF6F1D70B6163FD9917BBAF451D3422CA09B11617BBE32D89C878B5CBA + 5EDCF5CA7F1781E58A7DAFB46178764AB3180B0506B9A2207D521BE68849A192 + C138582E720E5F358386378B788B6032DDD91940500001A33D3AE0F5F21EFC73 + F587C7E90EF03E18D8DB0E291629B6BED5D9DB2A191FD08E5DA3590D1C6EDDCA + F2A9FE78FD0EFD1BFD1B8A0857647E89C7156C703A337055CD4744F58C9A3D79 + 8E8A5352CC04AD7479471A7917F12FC71FF4ED9D29055D5D63BB6685D2A8D334 + 53D98CBA8786CAA45E3D332EECE8DBCFFA7FB77662C77DA14B4F4FB619E39967 + AAABDA54236BD3D4DA6B340B0AC3594C6131A36EC53F02CA272DE80F62E2A9D2 + 326189F3161EAAB6A3DD7009C6D229E988E2CBD4DDB7A390D79E5BF86251B89E + 7DE5C09117772477EA0AC6DEC19CBFDC0B7BEF291DE27D1B7A6ACEB96EC9A02A + 7303BB3AAA712A91637C04DAE9215121977824661998FD61B5EE1CDCC85A2D0C + 994C91E53266531CB7B8B5C1F0BF5F9BE0FA22E09BEA6FECE9DE7D9865DFB47C + 24DEE326834E13753C5662185AC0AB5D4D81A8DA3552C8F2B92F964D65274BAA + 913492C9934CDC4FAFD5EEAEE58E5D985CAEAD3CE58735BB2FD7CB18B9576CF1 + E504EBA76304A6681641AFD5FA6B6CB7BC6C78140B12D7047A46D6C2B53BAE6D + 151A1B462D6D07D5119C5ADA1EED791C5A47CD75CD720A9BF7F165EEE42FCF0F + 5053388FD2B730BC8653639483EB81A0B8E204C6C73C3256CAB5714468E99D23 + 9AA91A2DF79C4AF22388299088D2B9DC69BE410113BAB6362410D8C1471434AD + 91422B7D5A8B841AA8775E598D835B33DB362B69547FEEEA5A28656EDA89A235 + 935BBAF3AF872E871981181827BB0ADF7C0FA547F7E9607FF544A7F7E36657C5 + 2490C945B428AAE296125648A4A6A88E78DE37162922BC60AB83743661CB1B5B + 6CD44D5133D54E486A9977B22A0F453380A32AF450155792A85B7913F1AFFC86 + 3FE9927E8FCE249E9F663CB596A18A91A093774263576440D5326F3CED59CDFF + 0066245BF9C313FA09FA23B1B684F5BB3F63ECFA7A8AA9EB688415AF5D153C94 + B047BD4AE9A296969696A1A9E08FCD29E584476796A830906F12780006C43BE4 + 6E9D0E36426D95A49F6649B42963AF472851E079550E71EB2F102C3AA838DAFB + 24848E17ABA85544F4238D99E58A351F7032A0D74E56BE1A3AADCC5701E19255 + 3A826C4A655FAD0B7D42F174D3149B565D995F36CBAC91929EA564828D2A0AF1 + 5E389D65AA58C85932B4F1C4582678CB0BE2A69E9299E9C51C6924B2A6D6D935 + D4AE1F28BC73564D43E712233956860653C0E39A39C412433B4F493CA6DF572C + 4532DED749466B388D805E7C99599594847F5B28B9EEB6B8A68958A43212646B + E5D337A17B1D5B976F2D35C4622863F360E9BEB5729AF9029B98C65A79453A1E + 15326576B191A31139063DA759B121A3A3D9F57454D179A560ABAD9A94D379BE + 76A5AAF3490EF26309769E4992A2447A849572B138A2A392A65D9D514AAEB36D + 1A095A0AAAECF2C92059E366A8A678E2BAA45BE85E40AAB665D6351BC9EA2AB2 + E825A97059CF32C72850B76BF2007776961CCF5C4F1B0D4C641240B7B74ECEEE + 98FD20863A5529FAD25877C10993CDE30606CCE4DAD4F3C37551FDFB272C9878 + D994491323A2DF898A10C02F6DEC3BB1B6E7FEF6B882475DD41142397608C639 + F33D0E17BF0DE18D4F261F1FA5463ECD0518FF00F1E3C5C73BDC7B35C331E658 + DFC91FE35FF90C6C013B668922E57D5574E11FC3A6118545499825963223B2B7 + D9BF65F15A2BEA24A7B545A1DD056B8B75F9EDC34DB36BA49AA6E3859426EECD + A3061D6FF0C7E8EEDF9E26DC6DCA71BAA8B1C8F574D39A7AC42DFDE678E4603D + 2DD5B9DB102CB04733C251D73ADF87436EDD4761188E0AB81E4A75CADE6B5153 + 34B4CAC2EA185348CD106552C14E5BA86396D7C2C54B490C314688AAB1C62288 + 64B2A68B619422AC7A7AB6ECE2855B55F3A823893D10A0CAA247F1711951D72F + 79B954F56D61EEEB878E640EA412A3C703790AB91D6E77A9AE8035FA7C9C658A + 796253EA33230F0E34BDFF00862F24AD201AF2197FDBA62C3A7C70C1BA8C3C2D + D4107BFA62B521A99165A9DA35D2C93C49F58F1D44E6A103B1CE5644DEB21950 + A93AB686C4556D7ACAC748E963CEE93CAD267B68A8A5EF26776B08D431BB91C3 + 6E495F28224AF967AA2B7BDB7F2B3A8BDB5B290A0F60C5B5F0C017D2FEDC3635 + FB7F4A345E94B4E3FD3047841605F2C8C48E9DDFCF07C7C91FE35F8E28D469BB + 817A9E7F2716AA7DDC7601A4D58AFDEB5F0D251ED1158CC1B34790A15163C5CF + C30924DB560A36E6D14A1C93DF7BEB88B6524915736C4DA152F0CE1336426A05 + 707566E24B198A5D7D2E57B36153282B957FF4C5F74BE27418005828BDEDF1E9 + 8A64E82A636F62007E36C2F873C14275C5C6B7ECECECC0E11AF3E1CB6D7B8378 + E35D3DFF00BF1E382353CF0E3A643EFD711D2ECC836654D257894E4AE86A1DE1 + 9A2CAAD223D3D553DC3F0DD5AFE8E845ED88576CD76742E8128618DA0A185646 + D4C34F98E67B5C09E669A60A720932800411A8CAB122A0D3EC8B7E585EBDB81D + 57B797917F17D22D6D4C10807B2F1A0FDF8D9D553D14F1BD751D43C129528938 + DFBC5BD466FDA461E378F32E99D585F3291E587FC44F8E29D47AD1A8F8624AC3 + 54BC69198C27A599B92916B7B7363CE04D115DD176025B1C96CDCB1E751ACC69 + 63BDE550C516DCFDD6C7EAC9E1153B33F48E44A50F9C2BD3546758C4A2E35537 + B489A5C6A1837A4BE18D2C3969F3DB825AD6E4301C7A19EC83F09C8DEF643CB0 + A40240035C70165BF55E7ADB9F873EDC5453CEFBC8F76B246CDCD4E7C96F03C2 + D626E38B5C5C81DDF36C73E7F3CB17E830E795AE07CFB0E0C9F74EBE071B2AA1 + 394525525BB73393A72B9E1E58DEB268B19605C1E4BA023B3B7DB809D87976F9 + 35B60F8617C47C7E929EC48BFDA8BF3F9E3F41BF45E4D8B47B3C7E88ECB868FC + F6294C92D5B41454FB386EA110431D153C91D24734B4E9BD569373631AD2A87F + 241FE2A7FCB14CB15DA421557F15F4C474F2C4FE6CB92DF5472F09D38B97B707 + 308DA3DC91A327A197F10E9DD8929C475090C8AD9D024994DF9E96E58A546A3F + A8A5A88AA11CC4732B472093367CBDA35EEC538162B2C2B203D6C56FEF1F1C0D + E3AA0FBC40EBA0F1B63461AE805AC4DB5EE3CBA629679D904425CAD203E8EF2F + 94BEB6011ACC5B35BAB009738DC968B230DE06D0B1D3A35F9708D30650E63899 + 8D92255799F95B331E1894762DDDB84875F44BCD9A4925E799CDAEA3390BD56C + 35B8B92DCFC3249ECD2FC8F31E3F231BBCB9FA819ECF6EA403607BB5E5869232 + 74E16537BA35F553CF5B75BFB70FD97F81E9EF1EFC3B765FF2FE3859D0912535 + 70CAD7B595A62ADFED637B6B6B8D6F6C546D17F4252C919F68CC05F5B0D3B796 + 8716D74F2B76DB0B7D3887C7E97B17FE031148AD9AD102FF0076E6DF1F2C3FE2 + 2FC7092ABD9E30AC83D6B86B8B63737A9952C2EBC4DA0EED34B8C1A7928C2A08 + F26F374411D05CF6F8E326F9ED90A7AA787DA3E6F8F34CDC194AFECD39303D6D + 8D91599B96E924E5E84D6049FC135E3B76E23A988E65DDA955274BDCE6FF00C8 + 33760B5F5371FACDA5A407D032691DC5C68EA5938869CD4E115F68C125CA9FDA + 20E2FCBB7DF88F71B599236D0410D4A14CA74CAB7CE45C35B246553519579E24 + F3CDA29BBE22AB23091D9FD5501107BF88F3C65A0D97B42A73234A1BCDB71118 + 54714A93563D3C2D1F40C8F63C9416363BC8F65C54CF2E414CB5150AF55333E6 + E1DC25C048C00F2BB542E45923E6CD971BFDB532D4D54995F2C4BB9A78B99648 + A2CC58AEB60D50647BF37B1B0D39B12DA77F2EFE5F0BE14F56B9D3BF5FE186F0 + F9F0E2B0FF0030ED18A8840CD9A5423C77D1DADEEFCF14B4F1A0511C6B7B76DB + 53ED3D7C8735C7663966C1E57B1D303C47EEFA5FE51FF0189332E6BC361C4C32 + 9CC35B02072B8D6FCFCB4E0F2DEAE3B42DF9F863678A16787240A954541177CD + C5E3FC7102A3B7EAC26113A9CC33D87D612BCF5C40D4E079A1ACE0BFF759B406 + FD3C70952B434C6B322AE930CC01D2E621606D8DA5B19D8288A69776A3FF0096 + A8626EBFE0CF9997ECB3260D2D4303534E376D7EACB6B3AF607D0E2446512155 + 6D39E65B5B4E9F9621157B369AB68D269AEFB88DE6DCCF7DFC538CA44EAA6E69 + DC2ABA979B3B98D93734F2BC7474F9610AF1ACD53459244296695229200588BD + DE4CCEE38A4C54C7494E259499944D0412D4CAE8EC5900AE96E72B008546FF00 + 762CA74B5F0B16CAD99E670F9A3D3EF2AD409C2BEED62DC470CA517200746793 + 392BC29BB60E6B6B8B4B390A164998BBD97B49F547AA328B666CC0966BF70C2C + 284E488F10B9E7CCFCF6DB0072B651CBB85F5EDD39FB3AE162049663CBC2FF00 + 90BFBED8AC912C25585A58AE2F678AEEA48EC397023FD7153027D9A52B4A2DE3 + 0AA31F6938FD4FB567326D18573D2D44A6F25542ABC68EDA679A21720B6AF15C + 9B98CDF97518B5B058E42FC5C2BA0FBA0B7877614B68C72FF3FA5FE44FF8AE2A + 16C0E686DAF4E2BF969FFC4186FF0037FC71B37F564B2346F045E7F9FD49EE37 + B94F4F5BBAD88A8D2AB2ECC62B9EA2F7CB74D788F7E97C47045219205A991639 + 41F4E3CDA35FBF10ED48A4A84A899D21DDEFC642C746E1D5F41D79620AF8CB6E + D1DA3A85075929DCD9FC596C245FBEA3BEF4FB468E51224888E721D1D38581E7 + CFA8FBDA61655F45E342B9755B7E2D390B61CAE81DAE05865BF4EEEDE9D7B70A + 92450B2A9F5AC58F67AA6DD9E9619121A7E3CE173C2732A8248CBD99336A48E2 + BDFBC160335EE4102C82D6B8B7CDC0EEC698638627D26D59AFAEBAE9F37D7C30 + CA08BF6733AF43DE35F0C356540611DEFA8E63A20EEFB44778E78A98F4DDAD3C + A3A5AD90ADEDD962C3BC5F1322C8B2A248CAAEBC98063622E07FEBECBC1574CE + 639E9E4596275E6AE86E3F98EA34E588EBA3B095488AAE01AEE2A00D47F86DE9 + 444F35D2E595EDCB07C3118E86DF91FA56ED8623FF00DB438EBCBE47960FC789 + 0DF5CFCF1434D0546659529C4F2B65B4524994372B68B7EB81B1E3DA119A72EA + 3CF742B6299EE7A69CB9E1E9B7DBC104C614901E1215AD9877606D35DA8CCA21 + 59774E8E14661D0DED9BBEDCBAF9169EA19A4D9B23EA399A72C7565ED8FAB274 + 3C49AE60EB145324B4F57109A0606E09B02F623C735BB4DF198D88B8ECD7BEDF + 3CB165B66BDCE5EDEBF3ECC13AE9D4DCFC6FD7F3D7ADF1907BBC7E7D82C3B31C + FB41EFFE38299B5BDCF4D17E75FCF1BB8CDDB4D01F8F75FBF9F78C79EED0568A + 1BE658082AEDCF59336B1ADC7A24676FB96D443100B1AA65B28B5FB0787E7CB1 + 27E8CECC706AD947EB49D187F4588FA34684729E64D673FD942447ABC8DBAF22 + 4AC58D0D4E486B6306F78C9D2603FBC809CCBD4AE78F40FA0951C3A48A1E375D + 432B282ACA7A8606E08E77BE2FE3E384ECE9EFE7F4A3EFA5A7FF00C14C219137 + 91E6E24B95CEBD56E2C47B083DE39E1CC31EEE2CC7225C9CABD9766727DAC4F7 + F922FC588E96490C4934A559C0B91E03144B156890D64C224DE26EF779880189 + BF7DF153402A917CD48CF522E52EC38796B7E986A12F9DD5C0CF6CA1AE79EB83 + 3CB5E24A258436EB39B85B7A392DD31F1C2D3B9B6F0100FD93D0E23A6A894BD0 + C75275D4EE18315629FF00752AFA6A3935A403439A29A295595E30C1838B10C0 + 1E7A0EDF8F6E2F23A7B1BB83137BEBD74B73074C4650709FB3700EA41F40A96D + 0117E4001A936C2BC0151B40EABC7C44F69516CA973A82DCF9E98E26E22A7283 + D3A6805B4171D7BBB6CD43B22233CC7F6D30B08208DB32EF269BD141A3597591 + 882B123CA0295AADA4DE7D5C2CEA003B988DFF00B3562189BFF692656D01554D + 41B05B723940CA0765FED1F1D319299925DBDB49186CFA7395FCDD3D17DA3529 + ADA184F0C31B7FDA2A2D18531C750D14B513C8F34F3C8F34D2C8D99E49647679 + 1DD8EACCECC5998EAC4DCEBF422A2DA1451D7534091C54ED1B8A69E28A345445 + 2776D1C8AAA00D515F4D5CE37757495B461CDB7B68AA234BDF89C2324B947DC8 + E463F63092505753D4A9B691CAA5C0FBF17ED636FBAEA0FD28C91E8451C7EC44 + 0A3E181DD7F2C7EDC0F36244E64E020DB8AFD310256F9C3926D05DB3711FB1CF + 5F861E711D5D389594BC8CAC73B0F4493DBD97EE3C8E176956C33E7FAB227788 + 8536F4753C3AF8E1A09C48699E3CB7319CA52D6BDC0B79103B65508E491CF45C + 4D94931EF1ECC799E23F9F6E1764D1CE278CA33414F2BE43C36CD146E6CB6CBC + 4A1CE51C4335B4C65DA3B36AE9B91BB691903A09748645B9E68EC3C74C011A15 + B1BE635108EBA83973B5813A72E5CBB48D99492D532D81F338EAAAC29BFA5214 + 40139EA5ECBDB6180FB6EA3CC21278A189A396B5C7D80C9BCA58108E526F2A58 + 72787A85A5A38529A1E7963BBC8EC7D27964625A49185AECF736B2F25C69C23F + 3F9FDD8A9DB7B565C94D4DA2C6A7EBEAEA1C1DCD1D32E99E79C83945C2AA079A + 42B0C723AD6EDBDA2DF5D54FF571024C5494B1F0D35241703EAA9E3B28360D23 + E79E4BCB2C8CDE5CBD4FC31CFBC83616F0E648EFC14541238E679018BDAC79F6 + 7F3F6FD21E1F413DBF0C2D4DB31865CF94F23638A4FE8AB03D33AB8643CEDDD7 + C454490345972EF4E6BEF0AFBEC314FB3F232984202C4DD5B28B5AD6D31FAB96 + 1996414CB18F44A671A5F517B1D4F3F234B35F76B0C834E65996CA3DB8240B6A + 74F1D7F7E292BA2243534E9269D403C6BFE65CC2D8A7ACA6B3E78D5C28EBA5F8 + 181F4B5E46DD96E5819E08738B5F791266E5CF55D7B8E001616E59797CF2E581 + 656FCAC7DFA7E78D5BDDFBFE462AF6BED6AB8E8E868E2CF3CD25EE491648A25F + 4E59A67B253D3C61A599C858D5DCE0359A8B61D13B8D97B32FAA6994D5561439 + 25AE957D222F15347FD1E9EE37B3547D0CC71C0D63CB4ECEB8EFEB8F9D3BBE90 + F0FA03F0B7C30C7EF1F8FD1D1588EDB6333596FD5B9780EDE98074D7958FCEBD + DE49364CCDF5B48DF577D6F0BF127FA7893FCA3B4E0697079597BC1C6B18BE9A + 803F86069A7CF762AF6C6D7AA5A5A0A28B7B348D7B93982C71431E8D2D44D294 + 8608938E4924545D58119A7614BB2A8A67FD5DB26239A2A546E0DF54B7FF0015 + B41E3E19AA1B823BC90D347146640C42D83DEC3ECBF87D973CF2F5BF093ADB91 + 1DC7CB72716E9DDD98B03738BE333E83E3F4963DC41A22AE6CBC5A2817F1C023 + 93790FD442D7ED4E58120015BEE8031CFC8147536C65BBFE2B8F85BF7E39173F + 7BE360319B9F455E40FEECABD717F4B273FBFDC3B16DA0F7E3341678E5041CEA + AE076AD8FA0EBCB30B1FB38D2337EE1F3F1C53CFC4833AC7283A13131B1BEBD3 + 983DD6EA710CF1B0292A02397500DBAF2F1C0B7662B36A6D09B7147414F25554 + 4BCF24512E66396E0B1E8A83D362105C90319698C949B028646FD59487982432 + 35755AA48D1C9B42642CA32BBC743031A7A69242D515358CD2BB1361D8A34F01 + C58BBAE55F5215E6D6F59BA9F0E9DD8BC82C3A393774ECCE4FA69F789CE073CF + A91F9823911DBE45517EFF000E5FC719579FE78F1EBF3D719DBD01ADFED7F2C2 + FF00B476F79EEFA43C30CBEB29B8F0EBE55F9D7C961FE63D98E01C5F69B56FE0 + 07900E43524FDD1A9F9EDC055E434F1B76FCEBCCF3180311CA6F96F6917B50E8 + 74E571CC785B0AEBAA95045BC30248F4923E7CC122FCAFD7BB0291DFEB235575 + 075ED5603F0C8AC2DE1DB803BB1B44C09BC48AB3674D571D8B67A65AA41CBB12 + A1A9E53D823BE846331E016E5CBF2EF279606973EA275BFDA6FDC0F2E7CF96F2 + 5399CFE5DCBFBF1DD8CADC7176754EF5FE1F03CC1F494F26E98BF5F9B60DF527 + 5C5BA0D5BE7BFE7AE0463D11E97F0E5FC7F867B5CE802E99BB95475EFEF39BE9 + 0F018BF94269CEF7B717BF198E89CBDBEFFCF0153D11EFEF27BCF97EFCB7FF00 + 474F6137C76F9563BF08E5DD7E9DFDC3A6B816C6E15F2BA36F952FAC90B9093A + AF6956DD4807451236B86DA7B62BA0A1A4880CF2CCF6CCD6BEEA24D649EA1B5D + DD3C2B24D25B857151B1B61AB6CBFD1E7FAB999C0FD63B5D032F0CF62E296999 + B953539695D2FE713C913BD3C7D4BF4EC4EFEC2DDFD3A12717E6E7A9C6A74F8E + 34F2112DCC4D7B8B5ECD6D08E5F3E18BF6FE58BE3EF31FCFA7CF6E2EDCF4B0F5 + 9DFD541DC7D2EEEDC67948DFF33F62990F4FC47BF5EFFEA396391C72F661E122 + D2840E9EDE63E17C146E63CAB750320CBA7517275FA0A7BB19D39FE47D9882BA + 8DE5A5A882412452268CB2210432F2B8D3505B8BD16BF26159B7368CF572A822 + 357F42056CB78E969621153D32B644CDBB419C80CF99B8B1F56328E599AD9BF2 + 002F801E37C75BF5EBE4D3CBDDD9E4ED55D4E0CAFA2AA963EFD7DBD9E18F3823 + 89895A646F441E6D2B74B20D4F7D946371135D41FAC92FC52BFDA3FB80D07F55 + 1FE2184FC1FC30DEDC1F2FB3CABE1818F763DF8F6E0F8F93DDF41B12FE1FDE70 + 7F1C7FF9F0BFFD037FE2E078FD0FFFC400271001000202010303050101010000 + 00000001112100314151617181A1F02091B1C1E1D110F1FFDA0008010100013F + 21FF0084481001028DF01D3DB246E7B47F9FC37DF06FF666817EBFDCED0F2B22 + D1F553C9BE3D73DC9953EBED8F5F143AFCF1C4C81DFE29E362EA9AC001FAD1CE + 84926437AC0070CAA1C19A2A2361AAA9C4ACDD09124BD06F501B69C770D8F642 + 52CDAB75ADE41C2D0F8808FC1DC94C3BF394118275F4BE98BD514422F5C7B5A4 + 5030749E2A574694E46FEA98415012369272204C352E18471901E3F8C8206D7A + 483F78BA078C604BFD99CD1D079786FB2464AB88C090996956ABA1C77C0842F7 + 7AFE71DFD2C7E73B64F0EB8F0E7417BFFB9DABD4C79BEE324F2FDF3CBDDFF97C + CE1006D898AC02AB679304248C590380260296CC279152576CB12B82A78C4827 + 40395B0384478A623735994259C70A488849345318A2C688CB7390EC40DDB72D + F50C724BBC65FC2062641021809E45802C29CEECE5EC5C6C6073470D4204956D + AC35C0A8F8806CDAF1268A03588B7A333C478C19C2F01C9243E34E498F61EFFE + E020B3F08C840A5056DBFDCB04E622E9CAF5ECE4040F50047B738932CFD0C77F + 4D7E2564E5FBE19CE2E099393860557416B9B0738DC414B4E6B166454019056A + 114C3451A7395D4D24DD11B50B52A9B12128441622884C2F098410A310C3904A + 30432ACAC869C9108567AE5B740B317E1172D6825080814B4A653686253D7210 + B65B299429C702C2315A4B150642265ED862DA229620DB51E19722FD89A7CFC5 + 01002C888BCA9E77733065A8A210A0D13CA26C60B2C323B0269A022ABF6FACE7 + 0504CF5F1F3B6114DDB3C9BA35FDC4812815E9DBC7A6889C243717A75CCFF7D3 + 9C257A7EC7C8C77F4FB07E33DF1FFAFF00D3F386E5DA82B3E005F859629C25DF + AA629080B04A8061357B5688538488958C914F26B66C9023700825CCE30E9708 + 41F25918491433789A71AFC4573F2335CB853B321B0A64880CC77214A876A227 + 28090861A6D802CE9F5394A2C887DBB8F91E16B38CCC6F1E3D29723956738C38 + E5CB215250F20ACC30C8669C97D6362026D646006012B56BE9308422649A88E1 + 1BBBDF8C8743B13C6FC74FDE5A26856E24E1FC4996F52D1068EB11850B45841E + 2B54F7C1033687564538EFE9F68FC6158B38673F431BB58FBE2707E1D8455537 + 5373158A92B1CC57CAB0034E38BA3E00C054DF052D531CE80D891233B38593C4 + F69C0B00A98DF5F9EB9B53D108574BD40CD0069C1C47710A2EA03ABB4DAB50A2 + 2610370DC7C2219439D9F38DDBDE766D7C6CB5C5F121ED98857B37329B964121 + 6A1F609734C6C7CCA4C325A52CCC830582848940AA17B750A9D35792F0C2E139 + C01859A78DE6C267678D81AE96C1B896E6A7A7B601250B9744F9E4C83A20109E + 3A7F982344408EEEDD76C9C87FE3C77F4CA2C68CF6496CE584604950774EB78E + F0C5358EF72943CA64CD9E06513A97B3858B172259E7D32FCBD431D37BDE2248 + 821DD99D75D6242206A706AE08E5A09618059E11DA159A4155E31907B323C898 + 076D9CD2A080CE4C8A42A34F389BBEEA8A4E4044B524140C44603C402E868C6A + E606897048264EC6A2A8A30E7DDA282421C2645302837B4AE18C11972E12D5FD + F01046E18AE2C618C9E0B8581D2239080E36A22034D6CD6E994D8607091E7F74 + 35E87AB6EA0F4169F3F87664B323A0D0469C3E56C94A18095784BF6EC7CE9814 + 585821DBBBBF5C2A4EB68D46CF9C62A6E4097C7EF0820E91F0C77F4900E37312 + 6A0B40EBF1FBE4A97D8684E9823A484E56C41C30B680929A88B0DBCC62381823 + 0AFA3937D725F21088424D24504EAA3206100507FE7EB158C40CC0DCA1ABEA64 + 074280E823EE894F0DE0C815642F70A1A0CCA434D004B2ABC54213C647B8B6F0 + E049957450296F9FA7261AA64E8B38E685E3123EDA127961A09BD0D18FD4A864 + 8E643AA92340AD94A465891AC7189D190CE70D1D2F20CEBF9A6CCC6802259198 + E4215726302A113040ED8B8D2E1903C64E847519F3EA58454C2A24251CC2036C + 0B1F61F7EF923154A87A6EBE6B0024C8D13012467BC08C24CA41998410BBD96E + 244581757BEB890330DABD00ACB94EA05ED4BB4ED9A23C3CC0C77F490BD0C7DC + C73FCCDBF791F55751982321CC98501905A6CDCBD726940BB3A2217515F6F38F + 1489A84D1496B44B3CCE42B8C0D01D4506E088E98A62ECDE40352FFAAC78948D + D0B0F0E0AC82450267909C44160244648B222EB26599E00CD12C143C8C925049 + FB95AEE7DB26249102CCD63D2D13A4AE4ECA5DB704ACC7ABF8C482C90A6D30E2 + B3B5DF6C0888DC24A1920A0F6A54E53A39140AE26463AB81D78F27E4E1CFB819 + 87A456EE057C632928C15F2229295909AC5C0CF13CCFB53FE66B16C483296453 + 4D72A19CE53AE980325B4D8841D4301A00E046883C40553E1C5E50F96044C569 + 7C4CE278A0EC99FBE684C3E66019ED063046E8386237E27DFC60584C0FF0F1DF + D249541A9E077FD62EB65744B2818E0D3CC9593D8E59320F2155DAFB5604CE3F + 5ECE449059BB0BA8824C2B94BC83767AB986FAF3961E01E1E43EC78E7248336C + BD2BF1C50F684705BEE4F5E35CE4AC68FD6199E6D8D254F391B1662111526486 + 0AB5C98189EA15A1C56AF9EBD246141A092362C90F821AE5CBF45849D16DFC1E + 308A9A5770D42E084CF9EB5B2205AD1C733084276FBD8C8649332DCB83589747 + 26F35C2BA33A416A3896C60A007A7A1026A18573AD226D0809A08512BB1710C5 + CDC8111B070C653211CA02548B1B63B64614392EE8C4C7255331CBBDAC5461B4 + B18C28F6429BD437861006E881A293B24AA520AC75CF817D3DF2677B8E66EB59 + 5402E4EFBEBD3224A5C783BFA421FF00C119641C56455AA26B9BE2526EF5C930 + 4C39B3F0C3A80D012ADD55F61D09A4CDCB5BB24A7A49C5ED188E2D7C17BFD3F9 + D520727931255FAE3C495C4D30BF83133DF559ACE22351021A863D3594A384BD + E78F39088425BBF9AC922CF09882A110DD953C79C4A1F1AF3C9FE77DD5ED6490 + E9A26BB2A382A75692B2BB078628EA3BE99A073F3C63447076FC4D91C384D4B1 + F2E18AC1629225D94BC4AC444AA2B2672E210DF1177347D4907681561088481C + AF70C0C543E19E3C648203231262C89783CBAA561820701D83A6CEF5CC314011 + CAFD371FAC100AC2D6EE6CF8E048922CF076C4C143427836D18EFE9A1E83EF81 + C976C45D375FDEBCC0C7559935C1675A20670E232243AE335E631882322B285A + CB961D1012CDF390109AA8ED31E688BB0ABEF31FF98B076D1A941022B909A0D2 + 40FADDAD7B2CEFF660E43B8816F4180B6E4D949404B2210DA299D832020240C3 + 04F0E4C8DDB615C6922C80923038185991DC5EBDE0249910770D05F349D14ADC + 0AE11286300BC8D25A7320317A4E508974C94B6A39FF001A60CA634156333212 + 42B8214A4340E09E05C2CD9D724D5AC4A4598334EE9731A6A64190D036EC64C4 + 30CB537712C88B411165F5AA64C702021BDC1BC258B8E50F5E701DB4CACF7064 + 6174F37BC01D4E41164EA788FF007783204B6EBE7CEB813B107BE26193F6F4C7 + 7F484922A77191ED97D8D0C092E59009620298BEB192D1A849399CD3ED81AE6C + AB711E0BFEFA63317126C9E6AC848733017D148B9F5C780E616150AD80961371 + 4F1E93964D74AC3442D21C204998CD8A6550014995000D5A0188818F205125F1 + 24659260E504E6BA0C7400B04D5BD80D8703039193E42E654B1A095A22C97543 + 61E8048857247655EEA21382A466D55D24D980D962E55519C158C2D6D01E0082 + 7776506F10C3D0A8C25D0E7A0DA98A5FF043980100398024101056022299B4D6 + 42DDC15C951B0825C86BC92E19C12F7502992D06E6302103747228425D291967 + 4C85A1660403DDEBAB74D6104F5363B90188EBD5C504A2C6CE375921E228F7B9 + C028374A965ADC63BFA625476398FF00B6111DD52E8401C16C1C005F4B8C219D + 2FD0019B2F09C3602CC4D13DA77A92A4D84BCCDF656841A04CC3AA792EDECF62 + D4B31B231429005844665EFE9185ADFDA728D2D8A1325864BC0CE62069443811 + 3642044228AEC1B190A706C39095558E50B8C335C0C354CF2B6C2C1901D2B66B + 07F148CE4F10EAAD1AA6EECEA0C54B1BC02AEAD5A5789A43D46234BAA7330232 + D980D24E5BC6820FCDFEDC1349DD98A6C042132F14D4D9D1FC05BA13A5000CAA + 10027BAA37211C7DFBE0BC9946110C1522EC50C1893343E408FA28BD16B33641 + D49A8453760783A7088B7BAA01910236C2F4651ABE4156F039133EEA5AD7F726 + ED22F06FEF8812443268818EFE9E8AFA940E7F5EC98E98FECA8BBACFEF0D60C3 + 013A3795940E89425343580758EC0207D8DC253C63701123113190788869E580 + 9D249A0541D09BE98E616A2CADD4E148AC6806228208322A78128CCD2358A430 + 4D381BE5E2966380DF022838762824DB31C16564084C8BD99609985C357E15DA + 08FB3B418894111321224B07135A751234140280890070AAA630D7509D6B6226 + 3A8845400D82E628BEEE69821E661BBFD4658B324C2DC569F9CE012D5D12CC69 + DF6EFAC2803EAB129728B062064CCD128B8955214B06838331B6410890483060 + 494327A8AFEE054DD1C87A47DA5F6AC7699810395663F17ED841C233D604D63B + FA43596CB8093155075C4929B7081DDAD7E19F23AC7FB86B11EF97B73AC51096 + 25F114A8D4E4E9461084880948F062DB51472C2C3B9DB8CADD1056A0240E0989 + EF85091709FBAA890477667048974C0148D9133CBC1C16BA22369B920661E1DF + B67126262260B028A3523CCE3385D6A681E8A5E4EF861CBF79FEC7DEB1357B05 + F57F1BF0D738F54BB12CCB6B8EEC911975E842459A323A22ADBBB5CC15D10FDC + F8BE4459D9AECF33F6E23A6084832BF12FAF57F13927D4B3D447D9339BD99A08 + C18245999146D8725CC224DAC00C94554F94AC1D2A47338252C64D0209E81147 + 42F185B52C783517F7C3946B83E7F98E02A2B233A4FCFB463BFA42C128496A52 + 969002DDB582CAF3310405966EE0CC73D3DC37EBED9C1970F94726443EACA3AF + BE5BC589208C99966C97613035664A0298402D7117A8A31E971925D6E3A81B37 + 975D9F0F579D4DAC03170469AE57FD72263C0957DE3CBD72A564A1A41DD5ED4D + 61D2845049332C5D0500D64958052C737BF91DB2248CC0A4017616875691C839 + 4C4EF05B57814C5D204C9C9B53F9986FB8EB152DE5BE79A81A9B8F3B7051DB45 + FA1E97FCC1E20075AB7CCC1E4EF06571EFA53F7CC6F37EC0A4A4D4BA280EE652 + 07082999C27647648129E10671E99A176EEFEE33874FF278ECE088128D7F6B78 + C7580A7F51EFED84892367A3CFC31DFD31F4E1E6796483AD3531050C8361C501 + D04ABBF34F8F78F9F7C359041E7F0322883A6944E1D79C8745720304D03024B0 + 2C26158564E9B991599D12D6E50C5770890D961CDBEFDF289959DAE0F1C06E47 + 6652CD48A08EFA03D30BCCD419454C0BD0839E0B269ABA90D883DE30FF003210 + CDD5641A960504AC00592E20111D645DA9672F94816BBD7245280CE701A3D955 + 72D82700934D3883365034910A369B8B88A5AC9A215D85C8DD42972BCD906141 + 652F812493569C4D7D9736C9E7C9D0530CC7442624756D24B25E39C478B9DF42 + AC1143700A427390900A1522305CCB16A51D81094486D39C5309032BE7CE4257 + 772F5D611CF57BD3E951C6251EE550D44FCE31DFD269C7E2C17020DEAA4F485C + EAFA6523B7C8CE324F97C3DF094DC20AC0D74F4C22A50F39C4B6420114FC6305 + 21C42044E94C1B77E96A9222D803921863DD7193F17916C0B1939DE87A61DF34 + AA83BE110ACAD0E8C961E8884D64D0B280891C3138A7B5EB1E82128AC86E1C7A + 0B8332DA68D9B1742A8460885CB982AF1080A4AC32151700244B2F4A64B8E6D3 + 3E73DC70838210B07AD6286F376F30D4D32B368016CF2CE0C2A4B4603FD50A42 + 346E5C0473C94AA66E84E8920E70C15D2A363333D4D27F29D3D454EBA5B5531D + 3079B20227626A1BC9EF82EFA7AF23DCE4C73349128F1BFD62863652EA3CEBAD + 60290E6E453C6F972C218A3CCE1DFD2F1B03E4AD888A05A006D4E5E27E73FBCF + 8FBE75813FDF02162083482BBE49AC3A6C5C0494F34567080F11E1DE2254B3CA + F6C84BC135121B75826DE706AF6B381494444B1012B562B35B41A7EDB3670DA2 + 31C04A7046EC08F03D2F2372BC8914468B0C368916F1CACC9E5CCEAC48B77AE5 + 45532DAD3122992C1E67F70E48A87EF8CBC84B30642EDD28D8A10F5959B4C628 + D324D72B83907B4ECF9CBD4CD2162010BA0B88A3A8530655C87951C812361E6F + 066AD549995DE5088CC601797E401584A4D24A2EB1B8F5069310EA85CA9B988C + 74C8914E6D034A26E5B216819839E2B59B2C10E8AB83E6F014C61A8361A79320 + EAE55DB80B07877862F1DFD2113E6FBAE132349DE1ABCEBEF835E8FAE4B962F9 + 5E1031DC586E59577F385519A9CC0A4B93C290C85CFD0A9CC429AD7D4E31B517 + 021F31037DEB2CE3642AD082CB240F4C78C728C0D4A382F3D7E0CD7B57A43B5E + 04AB70C5F18176EC8D711C6223A7A84AAF5752E51119124088955E4268122CDC + 272A4689824090D30274031414EB2482D16D5D409240100046A000FE79724189 + 662665520210BB93D715689D9DF63D56A787005928C60369941B542116CADD4C + 29CA741B2B7C96B075D14E5AC21445BB14448717D074A7894226DE43C4B08A7A + 68907DCA8D08A148BCAFA32E91F0F359136280222E6F97DA0C76172AFF003268 + 517B4FF71DFD32FF00D03FB992902158C3126E5D488AD670FF00978FA7F0E47C + 89024CEE3733AFC18825A02A94C08A5DA9C37831C5D10DD5987DF013C5AE42F6 + 10BCBBC0B5B5800B13B842C30D8B6CACFAE01FA124116D99561EE2C28C811B96 + 6A4ED0F209673AF585B94C9A882F965C624602424104298992626ECA692E8A10 + C24090CEC42CBDC8862419C350042DCF1AA235046501F506585A4CD3A129810D + 0DA7B84A4333B5E8BA26CA6106D849B72F3A1B6F242005CE8920A3746C10C8B1 + 3093511041526F68E0E4C87400592A4A1135FC7047CF9D5FBBD70C7D38B811AD + 6D5C986C9C3AE54AEC45853103915472BBFE18ACD842D170B78BFBE3BFA6DF5F + 7B33E44281AE1CDC82A7A06A3EC79B7C8C7AAAEB49B72C7A4BD9BCE44054E029 + CAE0A0465B02AFA2A8E9D721F58036821C10906BB7539E7F3A2200461DCEDEBD + 525EAB9F440512F55D5CE3D65F8FE6318B1F0452ACF11E2EF0A254245AA12C86 + 333CD06221FC80128134219B2103869802618399D80E72C890184206D584CE0F + 379C0655B16A16EC6E166C4C9C2578C10D3B90B1371A385DED75053B488CC2F0 + DAB3AEAA53704E2245CA20C682286201892B652AEF01C5A700568083248B0F64 + 6C090E84494F5FB0E74735BDE07662B7AAEDDFA77C3827589287893335CD9E15 + 21E000CA659C4149C6418C549D2268684D8563BFA6240428E543CA05EFA8CBBE + 4F3F6F7CDFD7FBFBC7587A9B5ECE40D164D0D329EDD70A51E731D0A245888691 + 39118663432723C04642481C9254C6124B897CB9315939803884490ADD9393F5 + 38FBF55E4B40ED858EF188C4E25161B22C253B406D3262EEFB410531445AF015 + 608C80A76D81074ABB31DF21190DE679A058CA8C2B0255861A522AAC60B80BE0 + 0F4C7A0B5832D303B455A10C43C826E2800282CFC5C92E5794267A4303D8C10C + EBAC14C573FE6D5067002A2617D4F83DF0092E7AEED18963692431C06F5BDE18 + 5E43482B5D86E14BF6D3842B28EAADC742DC6A865841F08FE96A3E97D87E0C77 + 9B89D38E3127C7F9F0C4601048AC33C6286D21DA37244C1A4AC3C3B6A98AF6F5 + 021D48425AC9A11204225DE3D4C818666AE210EA04DBED7169A97E5418B45080 + 6112E9544C7DB0ADE225CABDC02FB675FEB71FD949447332438A78C8DA425CC2 + 5BDC8CF2E56328E484935CD035CCC4E034460CB4471D5E4E37162D087730EF49 + 1F75A195249E8203C927C4754E49C8D4DB0C95AA16E18CC8DC293430AB2E0B87 + 5ED95CB67F75918576DFF31C58C73C1F25F7E338A92EE6CD1349D9C6C3CA4112 + F40089E7D32242F35D9D1CC73BFAA3ED1F6CE715FDB111BF958197D1E72E42DA + FDD37F47EB3748521A74D9262485666857544AD84225DC5E6D81B241FD753B4B + 8D60D64C7C38EC6C07229FA78479408D1E0124BCCE92BD7014D2B13B38547898 + 32D088698FD00C8E39B5B8798F44DD4D6186B35028A1CEA44B64243D0287C06C + 82881832140D84239219F4F9E990B93B881983D8BC21444A7AAD6BC6E706A665 + F9D326487897830E3C59CEBA3A6FBFA7D47392DED76164BC4ACEF2A6D90F8A7A + F38D075113CC91AFD5E455580A9975274FC9C2E1813123BD47B6F1694155662D + EEF9C532EF9CE5CF806A7A6A6779D58EAA4D130D412F73D759C6A69640CF03E2 + FAE30D0D358DCBA1E28C43BC665AA97A11BF443C3D4E235AA9458525E034AAA1 + 711CAED13F69A4066A1D6F1DE4D71055A02F31DF0E446B1E11322DBC952990D0 + BE01AC96D3C44C8D2186DE70447EB671501105E05D7C1B085A42D2332E6EDD5B + 850230938944EC245149B155A7283049A759C35B182BA122417804E30EBA3398 + 627D465ED0E6CE99154CED085E523D278C0B821A3D9D4EE97BEB0B8508E84DDE + F4DB4CE2052371CEC71CA6622A583A9F53FB2FC195EE8B170F9FD108F3F9BC02 + 64E41EB0F38B473EBF1DB25C7138170D18D4A22BB8DFE71BB64648B08A8F082C + 9B675FBDE24E3411A097A5164D50C5470518E1C7B2AB8E4305A0B219D6E79F97 + 9670621600273575CACCC28D4C782234D43DF72CE52F50C880A682B16BAF3385 + 3F33E4889FEEFA1A35860C451439DFFEE33A1AAA7A89B54888981C08D76A004E + 8000980425580972E15D27A834851F824530C293EC8B7E09861CAF0E3685391D + 626BB7A646293ADF2B6C758C6D1C23103492576E63F335BC9DE5588D90B08D54 + BC7972651225CC701D75FE628F13C07075975CEA4D052A633098351AB453C9DE + B24DC94F2C65725E4B25154891F4FC674C480D223E113F78D2BD6FC62188C481 + 1C1699EF8FD6246016512B2B0A441CA6EEF5843441E4948E537ED19C3EFEF922 + 65FF000299EF2954545CF35592C4AC9E5EAF488CDAB7FF000B8689D7D4054249 + 90B42A89D227ACB37D4AF4930070542554886127402C45C246D5CFD5A19154C6 + 025B8418CE76E5C4A2B74E35D0FBCE8928907092D9AAEFA9D1D327147AC9F03A + F92E81069FF7181AB44FFCCB2C15848013B6ABB3895F4A4380D9191EF34FC303 + 1C47CC243E06879380AFB06D12EA5AD98812E239C87EA21071364AD247E9500E + 81875139F3BFCCFF00DAFE644224AD0DBE3AB9B077AE6F054A7537C639A3A0F1 + 769D6FC60D7A41386E33569245C0B6E262830AA7CC78B8C3D3EDE71314E0427B + 66D0812E9F22AEDB9E9D4603265F5250A9021C97080421C71C2D26633229A12F + 0929CC401E443A8301525EA3B5FDF2C1F3881022BAEFE6F0A3C616CB9B17C3E7 + 193A528E0F6F43377A6DC4809CF3ADCD4C602288074449775AE839518526ED3B + 01A962F8602A3199AA7A8CA455D8A621993E93FE99F0FD73DE3F39F77FB67BF7 + F39AFF00CCDB3C7CE3A7CB9EC39F89F8CF9FD73F27EF86DC7B37EF367D7F19B6 + 343E75C3E3EF9FDFC39F8DCF7DC7E67AE3E4BA33DE7F27D1FFDA000C03010002 + 00030000001002028416D643B1A559EA97A9000F347CBB638DCEEFD0E81B8800 + 1D1579C5F8A4CA4DB0FD1AA000F24903853C1C8F2383823480039B058DDCFAD0 + 5E509A7F7A000074EAD3E421297D894C0068000A282BA22F7E494364086B2000 + 425C3D500488415F8C4BE68002F80EF9DA2D9251186C98AA000F27074E6EB368 + B09A8864E800063C45AF535E9CB2DE028A2000A9013228F8248CAA733E168000 + 7F99C1230E7E741E53A51200077DAD169F89E9E9267C44C8002175CBF968EC79 + 83595D9710008B36702D0E930B5FB882588002660F14E68E890DCF356FAA0003 + C6D4F868DC874B38DEC2C8003BA710E07C7E363CC212DAA000E49FB08D853767 + 3E7136128001BF4833C6D49976DBEEA961000F8B72E2DACFFE34A44D5F840012 + 69C979C8D0BD966ADAF60000A42514079E92F53020302C00019A1D76AEF2F0E1 + 68A73A98000BB47865B29B805A57086D80003BC04A92CA3B29810F792B0000E4 + B106974925FDE1435D880003EAF6FC02002D89E092114000080CE847D12A568E + 29321F000FFFC400271101010002020102060301010000000000011121310041 + 5161718191A1B1C1F01020D1E1F1FFDA0008010301013F10FE219CF6B830D740 + 346B9A13BF9FBA2B8F1FF380627288DF2F63DE1875786E3B7807834B329D1CBA + E5630DE6ADFAF9ECE69059A727A29BEA75B38C7C7BAFBAEDD3E8B35C66DEE983 + 18DFA7E09E39FF00B673DCF93CAF200E4194F472D7BF2010D0D5C301B6B275A8 + DE134D7061201DE02FA6EF0120E4C7E7E54F438A69ACE2FCD1F4C4B3DD39B503 + 930321AECA53C2B8DCE17DAF4110658B0B9C1DE0E3C62EB0C402929F9DF1BE27 + E0C2A6582D8790CD981C72E3408151CD2F7163451182A65D884CEA649A041D5F + B13A13C6B3E7AECE7D97EEE3C9661CFC7833C3B42F476A0EFDBD0EDE41236CF5 + BA7DCC7FEDE1B3B5A7EFDBEDCC6C6BCFAF7D9893BEF8AA797E1C29E17FAFE8BC + 3862CC3E4C3F173FE797D9E32D4EB2B5EF4B92F737DF1422937154BE73C6D666 + 4930DF7DB85E284523B1547E0F21E0F91C8783E472BE5F9BC27A15CB41DF7EAB + FB9DC299C30620A6B00D1100D0E1191754E074868BADBBBCD89BA12E8DA0ACB3 + C166F9B25CAD28F78C3AF86F727062B2C514751CB0CFBFAD62570252BD325475 + 4CB882EB070041EC682B65051C47CCC3AE0825BB5C6824298C33533EA5243AD8 + C301C96DB186F63887218740037004A8C508A040341252883C8DBC39105B3108 + 20D4850B0A81978F15B3DDF3EBBCE79A9D39C9875E48F3D7B3B767ADFCF2814A + E928B59EA7C73C59426742E6F6FA9F8AAEDE2A2A33A5F4F6BFDBF45E1CAC971F + AFF029A79EB7D0FF0038A70BF43F8329EE73D2FABFEF033FAFAA4E1193A0374E + B31FABADBC0A01426E20A1E0842C2CCDCD2698B24BB9722542010745C2AF1024 + 67AD92F791BFB7825490FAC006CC4EA7D8E71CCB017B9AD24C8824489E354E0E + A45C6FB637EEDFC7850833EA7C9EBD3E5398E01C224EE3A9317D7D78C26F6ED4 + DE59633700068009C40D5C8B091305181912B2BB9659A081C030020E3AB430CA + D589A0302814A44BB46208C2E575EEFE31A1F3501F268C4F87A72D6BEBE3A53F + 7BEB7C435993E3EB835F8BBECE5F73E81EE87D3F49374E0D624FAEA9E7E33FB7 + E8BC3FBEC7B9F7FE006C02E7399DFAC85C9B9D4E280C6087CA5ADD13AD7BF2C6 + 2050CABF7327E78842A95A3792081E34E775E0E1D6DBB8EBE3BEBC23CBA57068 + EF21923F8F49C6D164B546E2BBF7E478FABD6BE5C48CFCDFAC3EC706F6ADA43B + F38BD4A1346786494684CA142A2611C132EC9551A8CC2A380C81DDF3F7E16800 + A60A40DAA09D9E3B81013AD9AD8990D786B8631C46C0FC91853419720903B978 + C4BDD678F5F0E9A7104687A3E6FEA706A18CA79FF78B783AF8EF7C0A16DBD2D3 + FB7E8BC392331E917EDC674DF589F7FE205B6FEF9E13B67C2F12314F889C188F + 86F04AEA33CFF9C01A3F7E3789DA41A80EB1810D81DBD86B934315F0C37A0A97 + 42D0B79D14450C2E4E773771BC62D38CB1DDF5D4F2E32B0AF7AE38A0D523EBB6 + A33DFB9E78C49CAC53B059B1D1BD73181640AC19D4BA2CD7AF5CCF7B753D3DFF + 001CBD1FCD67870EFD03D3BE3102201BDC257173B87B539B920C4258E3BBF1CF + 0020D2673B7350B34193743897209B2849A8B591303434CC2A7438D962A4128A + CC71B81B9F2EE6D8E1F3D830C38C561ADE2E33E39A3DCE19306CFDDFAFC39EE7 + FDBF5F8E3853C7F564CC61AB70C9158BAB3E78E2D885C791AD5B07D37A539612 + C545019CBAF9FAF046190A5523087ADC4D3F1E422A355119426782E5CE38299D + 5FB288430F0F25F6C2009D34DFAFC7E059C16709F99C7BD0759F1BD63AE1D0C7 + BE3C7BF9E23A116AE9401483B8650661D7250379408B61685DBD1711F0382514 + B0153008D54F5714CF0C16EA8E0B37DE7A6436D9C8A2E164AC6D733183682E78 + D289A9981D23265649EB95E543C229AD211C1869F0D10C8BC51D7FD931E2FE38 + B3A7E5FBEFEA675C0AC8994ACF57CD9D18CACCE788148FD3FDE4B66C33718BD3 + 9B9EBADF30E800D17B080C2A16C1F3A3877A09E84210421022CA5014590E0714 + B913A4BD77AF1FA97F7FCE02036D3EFEDCA2E067AB757538C43CB75E47D749F3 + 9FD8CCA611B6E6F2D7307D3DA84D4080A084B32779C6D3B11C29011545432016 + 38C30E33F046884D86BBAE302037C7A36B9E22A44895AC914791E862B9950B92 + A4CB5EA858C8990084A859BF5818ABC3519940040F530E07B761354781E5CEB4 + E0B6B3D7D71C45933A7C673CCCAC8E8CBADAE599EA273411450DC158D817B987 + 89C830121D281C3722202C3C30445D054611C4C9F34C30E0395706AED5753084 + 5CCD92700520A0528651289480AB05192C20540C0D3998BD8D386E4C9481B645 + 7223761B4EF9AD0861A4674A532B2D973904E6664231348F62748E3ACF33DEFF + 0071F0D7102AFF00D538821A46EE73E0CCD5F458F61A954A2E92005E86061B87 + 0057A704CE463D9BF4D873D6F3E7F73C5186A9E7CFAFE26F88CAEF06FC7FCE29 + F09F78FE9E3FB3409A73DCA19F275D6C72F2A34C5C0D06C15898A5292EA45542 + 0357050F82DF072CB1117CA89F061B26738389D8ACA70463A0CAF5F486B5AE4D + 50C45C889E7E3CC9010CBA2B9339E8DDBD6321D85AECB48CF467D26E89A51AA0 + 5338898F9764C67BE9994641D9590F55EBB4CF1C70A9910C6AE3091D62B216A8 + 180068C044B263E1B716A6C433A3630F5F1EFBF88F23B323AC423F21EDF24810 + D52F547A757FF77CD43CB7A7109CDB86AB07794B8BC86D9E7627AD8E673367A0 + BDE19EC9F137C311A34002EA615DF7AE2C86450452BD21316BBE105443ABF2FC + 70A3530A8FC4FF003E9CB9CB49AEB2413D7FDC98E0F866A042BCB09DBD5DF2C5 + 22B3F5244EC5C6E13C8CE1B3DCFBF100A1AF5F1E296EBFC71F3DEBFB0A168C4F + 42066E837E426B89682F09625702C1C65C4E35AFBF4356F96A2BEABC30865261 + 708D71D63DBCF5682F99540A0C95C9A2F9730E4A039E232F6483A865EF1CDE0F + 6A45F457C6A1970790420228C09B363B7B3BEB99A99CE99EFD39EAA30ED20A11 + F1E2666B1C212021E09E87A78CB6F0C044D934D059E6E75DF044D37FA3B16FC7 + 5B9C20343C1CFC4C759C699E6DDEC650EBB3E72E2FC646AB462DF807CD44F8F4 + 728028593627D8E5AD4932D301318F18EFC775FD92285B96D48CCF977E9CAAA3 + 4B303688DC5D42C7039613E9B494687470B0AE3336221D814C61ADD7AD9C34F6 + 7DCDDFAFD33CA6408B0B58F59E86578464159002EECB0CB6CB7A511DCBDCF073 + 3C4DFAFF00870CCBD7F3C9CECA1F47F6D3D9FB1FC5E3C5FDFCF3E047EBF097DA + F18192A7DCC7C3EDC0B7A4EF667E3AF972F304C613DDB2621DE6B3A1128A0A3B + 0653FCF3E9CCDF63F29F73F5E63EEACF9B1BEC91B953056730CC195EA07DCDF7 + 6240E60EF4FC3DBEBE38C6F4499FDC6F820CB63BFD4F4C9BF1C0FBC4834DEEC8 + 6C3A338C77C5C8897BDA1BF89ED7BE1F814C9DB4C984F337133931C03FF01EB3 + EF67DBC1B07A5718F87C1CAE5F638C22078C0FAB4991E64DB8890D2192116BC5 + 3D31AE32991012027BA902B113DB090132BDBD4F4FD6F185A6B26774FD3D7D39 + 597A6FB0FA3FEF0D47BFE38311C613CFF9FC756F8BB7279224F87D7FB7D37D87 + F0C16122B9ED897E699DB8D1C34150F8309F3C367E3814C7B7DA27E386C8152A + 03B54CA6D926D9BCB19D84A552B3B74AD52366120D222A3A4EB1D0DD9E97965E + ECD4C7FD5D17BCC0B7444651EBC61ED977B99A83C92592581235B7DB7933DE9D + 6072D83BCCABE2E306329A1554600481DE68AE34F7D1C212598C7B3D7BF7A72E + 952926BD01DB89A665D3785824D444A653E730CC692A1DF4404B4220CA3B0819 + 87819A145EC7CE6D8A7BB215C9C916EDDE5B92BE957FC26F035B1DCC39F4DD6F + 9E3645463B58B4EF0026FE7DCC288E056F10DCFAB733C0672EC1B50CB7360065 + 1C785DD86AA2056810471199E63D05C40680060744D4F87EC7A7F0D123D0FD5E + 4CBA28DB946BDCC0F53A1FEC8419FE07EFD77C0A50A22937170E7D1B5758E6A0 + 386C264C643E1EDB5332AAD5EF0CDFC5FB72AB21501A3A0B4DB6BFEF1C5160E3 + 960DB51410C04AF4F2DA006812B2DCD4F025518210CEC298DCB35D55B990273E + 802B25D2E077BEB8F80DE5C94DDE96C99CC3C70384AA321170B9728DD86DE186 + 2390128918400E3639B7849B51AB409550039326646F10004864166B202C2EC8 + 1421C4C5A08006834EDA80330AE4B66C0030102868EAC4EAEF3C2A29520A4617 + 42441522E676D2A736B7A306930DDD7BCE2D4BB95B76E6D62751D12DAE45A590 + 0992A8E9258E48AB0A54410C18C0CF1AABE59CC88780620650A16B9EF5DF0B38 + 9E61497150C5EFC3823C772190808A804FB72ECE4F3683273112700BB3C58BD8 + 33D39EA71572F0C241E84D99C4FED7474E2EEC7B4F438DA7820E760E2DCD5719 + A6CEADE23AAAA11EF431C1E5E00D887957EABC4A9A32F7698FC77AF3C270144C + 800648A2532898800D4FDB12C0AA87022904504500A2B58507BCB36B3A481482 + 05BB91816545655569394A8B364A37BF358400E4A639603281508ECA82DF08D7 + 3F12444E94E40912196A5A505681A254C8478A1A3D4D8981C0D0998A121D6000 + 0533C80E5517794BA3115595828815BA0340DCF10B2B0D8AFE58812744E22B9C + D4CD1CC077D468E8E430D7E86403F01937399CC40B112749AB7DB3BCA15C5E08 + 522F7B8B72E9D78E18CB378526234AB0B3A44CA1BF312EE87398284122004086 + 4A46E156509B12A9C5800A2AD532B48CC2014317813901E3C7C5DF46BD7CC152 + A4A5CBFE7265D0EBE4F7E65D77E054FED48490027834B6952BF8C4E5FA3F0B3E + DF3F6BCB018D757783EDF0F18E190F538C805A91C861A4C5A77897DC19F56441 + 36E35CE4338A060E078D88EB1BC9DDEF34BBF4548F4468233A4951D6E9E97306 + 06186B2A9B9E6493233824EC14A564E5896DCD6D8CB7C601B0342A27C81CDE50 + 948ECF3A2844C09456BCBF888258A18183BB03402F46156F1995C7C057750891 + A41247289BA54718C5432702507182E1C22558C2B58D4209249A05814128AA28 + D048D78D67B772977726EBD03164E40A203AC7F0A7F56F33A6EF16AAE8CB7DFB + 5B9E48840E2F772A49DBED7131C97196C4D8C003ECB65131AEE69938A82AA058 + B12A6EE7192999555189CA14E142BC520061D0421E0E96B16A4E0C74E32BF990 + F7C704A4A05D6354E7CCFA6EF36BF4A777F3F1FED76C030E58B9F201A5C75B4B + 3B4D53A38AEC133DDE687B3F739A1EC7DB95618DF57B7A9FF785970BD31B6373 + E3DE28B7686258A55D6F3254FAFAEF8E474A5D6AE699D6A63CEB90F07C8E0CCB + DE41C925329266A8609454852870B6D5F5404B2986CC80620C39714996E3DD9C + 6B872C1A841D826E9EB4B980C924687A72E316DF2740D71CCC09DB0E3AC75866 + 70E5E5EE8943797A22B416F7D8070182008C9B140890EAF9DBA5660388F87741 + 2BABF02A7081AD91CB730D393B6C7DEF2D9C001B9180B21B97D7CE38E53B606F + ACD4E9BD9C90014D53C62CBC5CB5B93811038F6630A280C425016E56FB896321 + E94122C083CEE61EC727D0651CFD4E2513CF2285A4531AC6BDBB9E57CF20B666 + 6BFEF1D693AFE0F6E2D57CB7FAD2233EF0201024D3496B9EAFC43800CCDF3889 + 0C035A3678A151518C0A1664C402142BA1EC7DB999ECB33A44C757DD38DBA124 + 0BAAA5EA87AB33EDC1408294547BD193D6BB7BB7880C2BE990F6B3EDC9F0FD3F + DE13C71F106AAD63B25632708A84499975B1630AC29A3D6790269BCD523763BD + 6ADD18E1D48A7EAAB1630C81871C13534112B0C862E9DBB92E502F9890647615 + B414A5774E355B44033690AD0A010B0CF1D28404E0E8C87510382E39081B5A8A + EFB2DC19BE66C670855CF5EE12431ACBB09B2F245060348080B9AA649AC68728 + 008E96E93387874969A931B251B9575ACB772BBCCCB0EB99644815C516CF6A86 + 041D0494CCAA1C4218D14E0F705D4180462AAA6E67333986DC72E2237D17E8BE + DEFC5B80A7053CFC7CF317CD7E1A3F75CB026355F578FED24AEA4A424BB14BA4 + DE259C5D2C2AD0D983461048B5244151A9EEE5F306B6311E2109D05E6D3D4C7E + FBF193E67FBBFAFF0004EFCE7DB93CDFDF871A40A5C49040EF0B1056F5C8F82A + C56598CC89085D209C41A04AB32060E83014EBA4520CA8803431017147457BCB + C6F59D011F317D1A10630C61D60A0AC81929EEC3831C3540954CD1D06222802E + 6663045140EC0618C401E4A41B47BB6E4A9D8764E07B133563C1911AC25334C6 + 78622756851322D41296865E5C4803D1D80EAF78F4F5871C6A021B8BD243E340 + CB3A8F8BB593403506B9C59871C9383582CC0610174E46354C0B7CA60A4D313D + C87485A2252B8D38F6C427A37E1C0F9F189BF7CFE1E60F90A3801325BED8E284 + 7A34F93C9F7EBFB2CB3A5C5092373E99F62B81E7D0BF6F7FD9CD89E7AF78DFB7 + 31B7164B8BBD710B88E4D271815863743CFCFDBE3C15097CFB7236217C14FCAE + 73CDB2CD9266F896DF4E28B85416B0A039419848785AABB5305680510CE662B3 + 940DA4614930C0C8AE08969C584E83A8A1489DD753D69683CC2B7135491B4A6D + 9E02B8E88E3BC03C3A018305417A0CA6213019496678789B713BF911AEC36680 + E567B5A84EF34CACB05478F8CFAD71A5A1317143D5891918A0340862E41276A0 + AC115E958438190B83C98788736404064676EF0CC3EF12C78E08E53807919AC0 + 7260DA1BF6C359AA0147516A615AA1D5500565AA5EE847D24396BC3D5C7DF9EB + 5F402BED8E5DF92ABB7AF5BB9F3DF277F9E788F7CFDFD35C76F7FD7EA7EEE7E1 + BE63EE1AE5BBECFDCE69EDFC1CDDF0FBF357B7FBC386CC3FAFEFD670EE0D32E3 + 278C6C13CE6E5CE39DCF66BFDFDEBCF3EF3D7A5C7021CA3DB8539A48088C601D + CCD5A30E8533957020926AF2021210D90F86DF2E5D78E3118A8611240E057182 + 150448C388B0410B2A925C172810D8531D05522C117363840A582BF66485273C + E4510EE5D8AA655437C8EE21E321D4ECC62ACD50BC4EE056A81CCF2F58B78CAD + 9AAFA8DB3A977EDD01E42BD3229EBAEBCB2835D815378A0C0652B4D353B281B2 + 2833912C92F1C566061164685A63CC38266ECF2E7AF6FD391D4CF8FE3ED33CE7 + FB75F63ECF2A5E93D84C8BF293C706027C93BFD32F5C323D8FB73E8B9F7BF7E3 + 7F8BEEE5443753DCD7A1C77E9205D650F09E81FE70B24208A642BB277737CE2D + 318453C54635601409262BC220A54372EF4DC221BC39F46F691D14045A6E8E8D + 9D22A28C428B8A4C9718424C866F3457263452BA8CBB70C14028111EB3DC5190 + 405203C284B81104410A4525F556F0C86828B803CD452A4DEFD70A249D6B4FBF + B72109A5357D2EAE4AFBF7C809412999628E70851248EA3CBCE48BD4973E5768 + FA6F8B1A60D654C954D7A31BF3CC712E5EC9FA374A632F353218B482B0005776 + 0CBC86EAC41C886934F1EC105079BF1E4F979EFCFF00BFEF3F3BF8F3DFFACA54 + A597285EB7F0F0F00963261CE278707EF8C6FF000FC9C718F83F1C594B8C63AF + 6CE3D751EF38E0C08299981DF897D77737BE65067B6DAE55BE5EDF4C139B3BCF + E70EF63EA710321C0A871001A6677D7C4522A88A78D1B54231DA51D27166AB76 + A98934E4B671E294D085AB15559B45B7270F4072A909DDD3522964E4897D9456 + 0CD151617057BA90C128520C88889D949837AE6094401508A6648C8A28937485 + 442551B83C0C994301C0A59D050D785F03E6EBACEFC4FB1DE24D257C4D66B096 + D59AC91DCA8CCF58B9F5E179083085197222197A1DACE5833C160D0C35750084 + 4668E880022B5C2A3110C68F43594EA464E5368ED965CE584455590451118BDF + A3C5BC76013AAC4606128AF0CB4402E2609C040E200D72BE5F9BCC5A97C474F1 + B6E3BF9678EDF77FA88222E5A6D01723F88BF1E2A28E1D7D1E3A98C7BDDF333D + A7A6B1E31C953021F435FBE38D2FB7A637B9D7FE5E1366BCD3E59C7DBDF94159 + 30587C4B2F588E7BD4E5418F53CDD7A2BF0CEFBE36531187C4FF00B5B4FC35D4 + 93C29D4E90F9F79DF343D8FB70FA56CE63BB1C61175B0D710BC92440E2506C04 + 5B9784468281581D90630EF289EA80683006DC9A9318DB989B38A84669B8E921 + BC231CDBC11C9E402DB3014C9DB7162A8EC4834C38842CBDEAF971BE1B02AD21 + 71D40743B08DEEF0A23380006C5700AE6000B8C6D2C0A3C8EF68A9B999B7D721 + AE455EA41B8B109881088A4B45711563D9CDCB100C94C2AB9517D12FB00388A5 + CCCE8C26475F0CE1BC62C4405722094A494096A008302205079753246D8F18CE + 941049A9D8DF3A661C0B65646541B7199086C38EDF77F718F97F5450721E8C99 + 0D8EA7DDE6ACF9FBFA7377DBF27010DC1D4ECF5F6E416AE3CCDC7C7E3802CC1F + 2263E98E4451F8CA7C7F7BE30C2C75ABEF707C71C09AFAFF00E7A73B5079C1E2 + 5B67DFD3983593AF6EBC75E9CCFCEABB604C53C35C390F88389820830AC336DD + E9020703348CE9D944143010C5C9C2C6C002BB8142A59301E783D509CC195061 + 0430CA9B200D817392CF45F3175C2A23B4C5AC63439EDECEDA28D076183D00F4 + 469EC38E0C814A0602E701903603AEF9237634914C34CCAC4178AAF66231A6AD + AC03803178550176F18D4F9F116335FE7051A7154532223AFCBF77104E198C47 + 8001A3904306251628018898F9227CEBAB38078FC8016D10088E9CEA6F7FD5FA + 3C09026BD7D78E964C27DB9A15B3EDC4AE298EBD8F5388054E1DDF1EFF00EFE4 + E2DCF6971B3C6FDB9EEFA7FDE2C44626AFC7ACA6FBB9BC100B6015DB0DB73F3E + 60289E8DA8C907A7BF0E0BC01590BB986CFB6FBE23070140C0C00922B5D17991 + 82E835B0A0B93210C222F25AC26A0162449A68170E73DF144C09B5CC1AC03C4C + 55EFC73151B9C65F02DECACB7D9E62E03CE33CEB59E16F5AE3E789495C869705 + 3092E31799A86558BD1D040D26500515DF734C03075884CEB9D3E3F8E2AB2E27 + 0B426FD7FE71A4C76EF53AFC70A16C9E9FF7876FC39428EFD3B34FE3FB699032 + 4C2784BD67DB8341F3C514DADC1BEB3F4CF8E40547426E4312F93706E381A856 + 0530C993BFA4F5E18298477A7F0E791E0F9721E0F91C8783E473F5072DC92393 + DB7E3C709A084C05820F71DBBC9E2F06494424160ACBEBDAFADD71038A28996C + C0D3642D526284E81AA42B6967441310E3826C09130B6773A0D0A60D3C3C0C34 + 588846295AC697B0CA0A964CC726FCE8F3D19CBC6AA432CD3216957A2F6756F5 + 7233AAA523385531538E6213285E81418E42B8D9976B35DD5F7D7EFF00BD0F23 + 37E1ADF015870ECEAEBE5CA5D31E7D7BD7EF5C4046649F7E08466EFDB91E1FDF + 8FF63B9E5A45434EB330737CF45BCF6808CC6755D1FBEB90BB7575F1DF89D9EF + C0B0806C7710132ACB1064856B60066C0637334BEBEFDB892603BC169EA5C7EC + E7ADF47FCE7ADF47FCE7ADF47FCE7A5F53FDE004364205C8643AF63DB7CC6823 + B09D626F3EF0BE3861923E0CFE1EEF1402AC2A8419EDD5D773888438D530F033 + 8F57B2B39BB914ACA09D10119B6017116BC6495A8DFADFAD73C427C26A46F85D + B3C68D4C70ECB02A760A896F603384E597B0C0ECD4C336BAC7233A34EBFD4CFA + 7141E3FEEFDCFD9D6BF4DBE6FF00E7EEB881CF8FF38E55F3C8A5D7121CF4F4FF + 009C1445CE8B35BEFAE0763E517FB7E8BC39687134DD7767BAF4BEE5E0A5D1EB + 5921935DD3806A6621738DBAFCCDCE00049F9F77F7E9FC094C33B9F37A7880B6 + 6195333E1D5FAFAF0CEB3ED9E21B4CE37E78E4B451E92B9306C0F9F1C3133D16 + 6B3E9972FAE77C2C8ADB62AB1860CF7E3D7D787274CB7A91FDFF00DE1454000D + FDC7487529785968BB2A445CF635BC70EA0B054C487EA46E29E8F101CD735AF8 + 5F593CC8D9FC295C76BFAF1000A0F85F8F02B8CE3AF7FF00BF9E14B44F7E286F + DB82A1FBAE027974533F4E391EF0FDB992B1BF1D8CEFDBE7DE783698677593AD + F78F9CD75FD7F45E1C4638E9FF003EF8E215097D1DFC9E650399A1F5F4E23EA7 + 1215C1E746759E6BDEDFD3D3FEF353FE1D7D7C73F37E79AFC7DFFF003F4EFF00 + 999BDC9F9E489D49AF3E34F8737C699CDD5CC42CF47D3C49CA16F4010D81AE42 + 8008C05E0159AB800A93160055BE56F04EAEF02F82936DF9C1BE53C9F33AFF00 + 3F8D9FBD1CD7E3FE7F05403CFEFEEB779B9FBD73EA1FC7EFDF94CE4F3BEA197F + 7539BD7F7602300DBD070C0D9E417D7F7BFF0023CBF35F49C5F95F0FCE6F8940 + 6E7CBBFDEA79C9C317411CE5C18EFC79F0F28AED4F8FF98E6DECFC73F37E78BF + 57C73F7E08A7853E4FF3DBE1F9E2C9EF31D7AF334A61F440261CB41B784C0939 + 06D86A9B0B49C873AFC7F1FC687B1F6FEDB3DB9BE75FAF527E275ADE67F7EDF0 + FCFF001A3ECFDBF8D8F73EFCDCF77DDFC135FB3EEF36F7FD9C6BF07EFC7EDF1E + 3BF87D87363DCFBF3B7E9AFE37F7FDFC9C73FA3D787D9F779F56FC70D7C7EE7F + 8E9F1FC7363DCFBF35FB7E1FE0FBFF002E6DECFC737FBBEC7F4FFFC400281101 + 0100020201030305010101000000000111213100415161718191B1F01020A1C1 + D1E1F130FFDA0008010201013F10FD19A30E228577DAA9FD70C6C87B779F53BE + 5BEEA67D7F3C3DF3422B5D4F4C1C4A6FED67DBBFEB94D97DA5266A7F0FDB8707 + C2331EC3D730016DDEF7D4FA89E76BF9E79EA7F0FF0079F8CFF7858A030D38D7 + DFE25F4E10D1BEE7B80EE2043C77D01822D5C33027A83006F9B9E7CDAEF5FA4C + F6F9E08A2D1F3F7CBF07AF10058CDC7CFB6FCDE0D19DFA0CD90174602EC0A4E0 + 763A8D3DBB3D33DE381A157527A564CB93CB7C8ABC35C7538028244E330781F0 + 55D37B0C9DC712DD2C7E11F15EF36EDC77B1BCFE2FCB9174EFCF16931F9F3CD9 + CD7E3EC39A7BBFBE7E63C3CC81F37EEFEDD9F77EFF00A6452D55278A8B3D2F3F + 0AFEB8793BBF29EBC0083BB0BFAF6E7FE63FCE337C0F4FF3F4FF00CC7F9CCEAE + 035A93D9FA7533E8F11CB2EB5195581AC1067C154653494E481949A6CB389876 + 3633B301CB396F1BB8554034210308E103AD635BD66401E801337D0DE1CFA647 + 9B142345024CD1284C2277935C0D90F22AEEB576F6E3C18E5B224084C316421A + D18D6474B0686F53B843A09310C625E26C9591988A280A1837EED44416738645 + 6A0E82399312CA9D00587766E57817609D4CFDDE04A11C6403D194CFE67BE4BD + ADEBB7823FE6FD78960AEFCF5E2F8CFB77C0863AD3823E704B9F1CFCC7879A7C + BF77F6ECFBBF7FD883B380321FCBFA68FB3F6FD3567F83891814C0762CB30E67 + 4E34EF94A74D9DA97546DCE3A35CC0284CD818F100611D79E2EB44F0CF7B907A + DF0F6251339C33A4F4F724E25AB5BE222BAF2FC5E558B8B1C1AEF5FD70CE8F25 + 58EF79C786467019A71D674F34BFCEC33D0A4C3671650AD057D5AA8F7785901A + 25416923A01A32D42B78760D0A08589B90152B219B481007920190ADB72EF302 + C8ACDDC6FD7C79FF0039AFE63D7FAF9FAEAC5CEB9859319DA97A0AC77EBEB627 + 1DCB35FE2FA73F21E386BE7EE7F6ECFBBF7FDFA3ECFDBF44698D31A4C4F68079 + DFB7284B0C31C9D6364A7D7E397A221F2173547C90C0041CD789AEE6184C48B7 + E758F1C2C1DCDFA5F4F5FF009ABEB159FC2FF5C50CFD71AF6DE3853D22970DCB + 97C50B96FB7802A54F5FF9FF00780ECF72FDC75E9FCAF1B0BD8056EA841878B7 + 14CE797986D882653E303D4A5F55482403D514B0094CAC617B7999900005A4FD + B59968F1AAC008F258DAF79D4084B99C52467C7FEBFA022E703EDCA010F3AEF2 + CDBF9FC1241D146E99D9B9BF9E1AF9FB9FDBB3EEFDF8B11D266ED41C13D67AF1 + 44C9C75D7A6B82A3A2687BFE3946493F3C7EBA3ECFDB83C8F4D74BEBE394C49F + 3C45F94D80B9E877F4F4E31558BAEAD3C2D95A62E5ED168B8638B5F3D79FFBCC + A95D6234DFA36FCCE0C1D1B5C5C30CECDB8F0E355A448E16B80CEA66A078CDEB + 936154D99A92B86BAB5AF9CF2073AFCF3FD711B01D40C3D911F66F7394C08605 + 102816AC0D8149759A248760EB06D855DAC37AED24C3325EE527AC3FD9DF1844 + C25A30C06966452DC7147820B87E210B90418AC71000546E5267C77F19F638B0 + B3F3F1E3749B3CFD7AFF00DD3C543B87F53D786990E8DF4BF84E645F2BF77F6E + 04205C56E1C9A98CF7D3C76F5AAE7C63A6CB875E3823220A01490DD5EBAF6ECB + 2BE80F91F9E2685ACA52F88B832E2C3178EEC0519E89417E83AC64E32AF0A430 + D62CFF0021BEB8B93A3A94A779FF00CD6DE3101A2F8F53CFCFB72FC9FCFF009C + 4470A02659851B323FDCBC451D661CBA17F96FCEFCBA63B2CCBE70A10EE66E24 + E0555819A1EBD88DDF1E38C01D08A18089F26BFDE3785A51CAB69D2EB77D7985 + 211C5B7CC366F5ACBEA70CB099338933F27D2E4C710C95994A97D1632FA6B898 + 155EBAA6FC297DBD751D122D9A9307C409E9C704CE43DB7FF389A14C334CA640 + EB26CB175C8848860DA184594139082ED100B732FE03AF979B3F3BE2C86738C7 + 5CCFC7B7F77FAE60141736F3DBE0FAFDF4F97EEFED4D90A2C3395C2E5DFF00E1 + 38F6690A6C0724C632530D65BCD0A1FB14592994C6FD75C82120A1A6B80236A5 + 2691E2538BA95A264289653C968F10968501CC762825A5264A8F1109D0B4929E + 33DDF3F12F234C03937384D4EC360DF178F2986977D47393C4B8F69C584E1B63 + CA5344236192D7B753D63C17234600D1281E6C7CBBDC742C58B2A5A66FE7A706 + 54DAC9ECAF4095CE26470D8DAAAEE111B4DDC28EA119B3895588348B2A182436 + 800A8E4D808AA142900796B219565E03C469175121B48E1587BC92B733D23F44 + BF1B7538A58A0C306850A3E40778EE3A5ADFB7373DBFB78241E64F8797784028 + 5A2E5718AF5AF843A093E5147AC4D98F0CC72C331BD9E4F5E068F855D624CFAE + 0BE7AE08E4CFE7AF33B8BFE14EFAF4C47D186BE7EE7F6BC1A93C66E46CF1D192 + DCDE0CD926021AABD4534819E24B3E7610D9B569DBD573C2C41B1BAD08EE95CF + 67B1C6200D0470A9D046E58565E02A8D11209A7803A39D2ADE257424D3D30FAF + A9DE4C9C760C117365638D59DFF5CA8F8BDFF3BDF7CC9310B34F79759F2FCF10 + 32540995295B9BBD90C7539B8AD286DA93A3463589DEF86518494EDC6BCCFEEC + F3CA8266DD642487BF931FDA35C38164DEB59DFF003ED9E68212220541F42413 + BC8F4F1B5A0C87941633D80F3DB7941AD8E01B6922F9E1214F2CFD8EE69C9002 + A4D96AF382A664F3731B8F8CF27837B3B3AFF1E6E7B7F6FE8C3C48156560378B + 7FEE5CE914C11DE09AB43D9C3ECB4CC6B02E4FCCCC7D0E3A7D9E042277FD1F98 + E675D853C5FF00BFA38DF0D7CFDCFED553329F9AE3BCFAE3AC4D9EB45F310063 + 101035DF0C0009A0E021850D43DBB50E883D88A533E25F5F8E75A9981767D53B + 84EFD5E127554ECDB54DE282D7B14E28706593A30CA9FC11F276B101126334F6 + AEFC1885BC89BFF6CF1E9F12F083991D6CB9C637209837C710D6592F51F195CD + C1AEEC33330F2575B3AFCDA699C61C60C687B3F30A84942E71BF1E9EDC25DB5D + 5F279BC81DBAC2F89E01F2CFAD31CF18C8AAF662967D9EAF210761A7EB0867BF + B3D0EC519DB77FD3F09E431C72A911542CCB6F52BBA6306A0A0CD61A630E5DE7 + 1DCFE78B55F5EFD87F81391F0FD39B9C1085181BFC677E789145463358330A4A + 47D309FAA86D0F7E7E73C3C35F3F73FB767DDFBF367C7D8E67DA5FD275F6C5C7 + 2E9F731B6CF5FC7D71EA017DBFF7F3C1E04043E0F7E3E7E0E04101235B9A317B + CF9C71402201CE1703AE9479B3EDFD9CB299D14C4C3E8FB5EF1432B29E43B59E + FDBF9E45B346AFF7ED7CECD729AD74EEE09F5F9EB79E4B6AB2FBE7E7E7EDAE38 + 6D5663C47FB9F987D470F475E719EB3D7C72F7CEE39F4EABBB9D6FD39E339F53 + 5E989F59F5719C31FC53EAFA3FEE5299532F59F91F9C5E01AAB05C6909E30E23 + E7E3866BA43EE3A6D748CCEEEB9E88675D8FCF51BD8F053D87D79F5FCFC71518 + 1BBD55F18EFBF3E6F367E77C74CFD3FF0040F4FBFC65F4E1AF9FB9FDBAFBDC55 + 6B4919E77EFBFE33C013B5C4D94274B7A3E7AED807AB7D67F2F1715958666707 + FB8AD35D82005528A050DBE0D10DA0CA7E973031F3D04E81DEB3C0C55D1B1C81 + 5B7CE4F1B6E301CE8F96BCF7F70C72F8A344658B4DE7DF50FA353970C1161344 + F5F506D202852AE1BB627C4BD3326F89284D91BB866B9EF3986A7830E6C0BDEE + CF7EF81510475903C4D2B9C797815D024AA893E88DAC0F2638AC7142BACB2A07 + 572E30658DE3BA3A0C3F4FFC67F7B6F273F7D6F39C3B8DE410C0BA745CBE095C + E2138087735AF367CBF394C52A2A823743AE2AE4CB83D870A1E816DF31C1EC1F + C9E7853CAA5688473846A0E4C6339E22518594C6ADCB9DDA89E97981EEFEFF00 + 48783E9CCFAC225F061E9C35F3F73FB59C8DB8F4F1BF1CBE1A94C2C1000C10D3 + 0178EE92940BD2C53E8003056907CDBBDD3FDFF77918EE5589CA4513D609A597 + C71D9417AE05426D2ACF44DE18B5746A241A0100A51803C0A425C3A51845E8C4 + C5C716520648A51DECCE6CECC030220AB84FC7BFB4E0143008220233E087A476 + F095A00619506180B5A387C71332440012AA60291E9E1E411CA681DCC5F44F0C + 3AE6055471EA11C671997E4B4D5DAE4A0AB9F0A5AB1F4333A082C6029660AE0B + 2F20F6270184BD22E3C6339DEB4E4244476992BA7CB2BEBB23B9CC4121C1320E + 4C3BCC7CEA67809122E0DB426B5F38D79CA1D40A0CA058E2C0B13078E25F7086 + 28E5662D7CEF60DE636850D2CCAE5920E4018EC44BE8364F1DC3BA3275CC87EB + FDFEA0C61E87B3C35F3F73FB55AEB6F479F6E10A86B803D207B81C3517346042 + 2C00C960ED92A050800068B3E65FB1CA60749A184B63BCCD673F0D65CF944A40 + C0D2EA166B959E1B94001601401C59091A5DE0A554936FC3A33395F88F365B55 + 3486286344D274B944C185C2064D1DF538CAE7C12965496456EBBEAF121C3405 + 56180C2845492600E3EA905CD8025088EC2DD79759EE8528B1424CED518E1029 + 811809047114CBB8E18EC2928CFF002CAE4C589E0630F1A68A1510E1B6B88707 + 0C0CA63281A947D33EBC8BC19810670EA301C93F839A90060BA6B0E80AD42F68 + 554543CBE251B6C27A4F5E28F1D52F61888D4AD35471B5ADCC01DBE0C2300066 + 64BC4A08237316280D020287131C63E108C01F02EC068069C2A9D7120B9C1F6E + F9F9FE73E506FC70D7CFDCFED2146AE514DB9431EDE738E5AEE51348C0774C68 + 455DEB8C076E0582E217A81DBEADC1C7170632F1854F59C39D113521617D501B + 01E06125C226150A23BC9285833886834500874D113100107E7968CB56C8E408 + 1F5CC065CC97123CD8280218D2D23626924C3AB94168905922896F61E0508051 + 61059AC01347A3A102B352309024816E4DAF981D4D2800B988065D9E1EA5E551 + AC227525A402B37A45C71C215927A0CF2C1943E696931A1A229A9C32A2009109 + 9D095D05F6B71BD47A9AE31205F00233A218F4718D6B8569985C653186047AC3 + FBE25A248CC347ADEAE3824E884EB4C9C5C8AB8D1813384E439D2E4379460A20 + 0348CA8670208D43073909625B4D089901291317DE6AF699EECFE7D38E44F3C8 + F2FF001FE1F7E79BC3DEECEFE7FE2EF86BE5FBBFB4099C0AC3A732BCC0BA3C73 + 421A1A381C0C0DADA602C442DA1BC4EB33F887B7E811D685DCCF8EFEA71BB658 + AE9C1318963A5DF4990093BE8B16757D7427B79CE4066137F56F39F1759E6080 + C6F79AB134F44B6CDC5AC13EA146D25E23F4E4978C30AB478BB4C6675AE0C63B + E5A9E50732F82EB192E120B958FA10F17BFAC4BA0F28D4DBA604EFC2E264E332 + 3AC87447F26F8C5AAE1E88E9E41E74DB33C52619458486353099EB8E800A0E15 + 37468F0CA1E719E3B1E741ABEB9732B740C9BE0681558F4ABBC6BF989D871972 + 6C489A04B5EF364EBDE1401264C790B5F5F96D6B7E78C958622F5D212E0C45E1 + 586535E008B95690034650329F243A05DD8EC0C80B6FA7BFAFA7E77FA98CC55E + B31F1C109E14FA2FED94008693045541219DF9C42CB8404CA90CDB103624BC35 + 0E834832941067B87339F7C7B43FBBCDAF08B3704D7AF8E33077B9816D5DE3AF + 3E9E1C6F286A94550B7D9F4CE2AAEB13224E8C6BADFB3C1B1322355E709134AE + 662C3AE2AB930420F2CE9BC92DBA5E1205D004A554129E651623978E0033E3C5 + E9FC78C45076BD4EBCE6FA783D000BDA1AE6E08B691B061DA31AE31837B53EC2 + 2DDA11CC4F54406876605F60CD85914A52A1724C0208A44C68B95808804C7461 + 3EE17D26F4F5CB619C7D31EAF747593406842996C5C9DBE86E3C5C5E04A8006E + 1706A2BEF43BE2C39542684BE6635EAEA3C662E363243419F503137E616518B4 + 9A0E2981448B2003670B6750B84A2AEE0CF2FB77CA6DF272D87463C1F9BFD7C2 + 9EC787C2F0D7CFDCFEDCC76A4468A35C2697795C41E6DA8C22DEC83A9280119C + 5DB32834258D00BB894EF3CF4F9FADFF00BCD66EE03CE4C78FAF3B9654C1ADE6 + 0A6133E9970952C25A974E937CC0B9BCB3709220905488A4A43321171C5EE8E4 + 313EE4A78D7F271A62A0185115F11B8BB1DC3852090073818415206B18A4B8E2 + B0EDB80F4875E653133EDC400E50703928DB8F38BE2E1CAD6C392B778231DA9B + 9DA899C8FA8895ACB0E7B367683597B3224D8212DD184971C70B42828582C4D1 + 535BAFA6008D0F19FE39C1D62638B1D15C6AB7344F5A12865D29098D6A2822A0 + 2105602922B2B70230D8BA550A23709ABC50C1585F40D306AEF3E672B3C98071 + 10216B940B95B6983AC22614EB0666415659938491B0631B4FE7F9D6F8944F3C + 9F2FF1FE727CBFC7F9C0A80AF43D8BE3DFD35DF0D7CFDCFEDCE03BD85934718B + FD79E106CB9032D0C20AEBA96E3C71A8DB4132279F3D7B63E6F3B7D8FEFF00DE + 3F9871210581D2F478F399E7ABCC306D9571740D61ACE2E302338014AE070C07 + 88B7C16F315B74533A30AADCF5EF33C4B7B10028E1622E811D8318E32CA3E85A + 4425982208C1AEF86B2A0298C208C5338483E6F7CA8374108360852D03A3A41C + 6AE8BAC89AA1658CB29AED3910CE49D7998AE617D03224CA985EA806739D7A5B + BE0943285812B04633DC2769C1CB8C31B97A4CA69E4185CC056F5523D3A313BD + 629398545A20ED911CAD11A6EDF5E261886B2225784C4CE4BD71DA94602C2996 + 184197ABE1E21465150100805EB35347893CD5028568E480E9409AE02802A500 + 649B074A771C77CA6A97C5FD22E85F8E4E02399ED0F7F71F9F539A7CBF77F6EC + FBBF7E3446443D3E5E97BEBAC70DF2FE55C3F4FD3E667E7DB933FCBE7F869BE7 + 38EF81540C8780B5CF709EA612C78EC1D7A8B46B375BBBBA1E6B20CEA52E317D + 1DFF0058E4E7783289E7DFBD67703810A15C18D403B183D84DD0204F6CBC0AAF + 7905DE2B92639D5B06386D5FECC9AF32F14505BB6405818A47D6BD4BD00A4150 + 115F9498CD7E025564439D0C2A25297204543840C07065076C9A48180578E556 + 41EFBEF7E932FBEF67A629FC06CFBFF91371789EE7DB30EFDAB0640B07141797 + 0266B9B6C38FDA4A3D746AD9B71D433E1C63774826464B0C8EFA2071E5816B85 + D0985E04834E0ABE4521CD92A06D71D9928416EC69ECC2E49FECD71C0BE07899 + D757F3627D327C6EFC59FF00BC35F3F73FB76F67F47228F472C3CAFB3DE9F9E5 + 883BFC7F957D5E79F5E7F34FB9CAC65A4F716F4F5E9FEF12DCB28CE1E9BC6F3E + 5D996CDC0AB82D4BEA887AB80D838C6778EBE3460D666A7DB11F7CF64CB14758 + CF49CC131A3E72A2E999DE44305905DCED0E020EBD13A8BB5E274DBEDD7D137A + F506E68AB45B215272CC72A628EF89DA406858C4C19134F0ECE615390000E4DC + D908A0A7CE6321356039389B15D28B33C7ED97D5F9C6FF0007882673ABE7D193 + FCE46303837B5778FAFA718CE2671D03D7C6EEFCF416D022DDA3CE2518F4318E + 155A041D251E8A9A8F6E721A201F0D2C0758E9F9BC74C4FED806F74FA5EB8CA2 + AE87304694641A4D3AE3D14F5977F4BFA7E43C3CD3E5FBBFB631AEEFF1BE60B0 + C68C197A1ED9C661E31D7BFECFD08400CF58E20B5B10CF9647D3CF1A3250A0A2 + B2D25C63181DDD71131F6880165AB5C4D5F8A4C654A6063D3721FC0FBF0B2FC1 + 9656D623937163D4E2526E826102802440300486396E4CC063188DC4D99A2222 + 79152984EC47670AE585D706308DC872659700C2A6E5BA92D67482037A20640D + 1BC3989D44265210C30A509824250A6164D0030C58313D57D358BC2B057BA7B6 + BC6FCFD2709D12FC67E334E2768281102C5C46E6D1A61A6C95C8114664282855 + C97C9EB9E4D164FAD1F2001567D6BCB9FC4F0D5011E610A5C6CE49A34E680D43 + 41098D4E06AC0152800D2323EA64CBCA32BEC09C5A4421005A372D5461935718 + 086085B8BA24C066A07CFF009BF8BCFCA7879A1F3F77F6A1DF1D31421338106B + 32DA9D6FC9C218C23DAE73DABD49E9C0A87AFF001F99E1A1F0FF004FFCFF0076 + 71CBE51CFB3F9758B937C14C17C373170B9DF507D4E25C243BAE737C1ECE3381 + C17AE0BBABE263D5CBAF43A4F9447B0CD5523EBE82971FC87DF8AC731B917785 + 87319DB3353939A0980A1E2169E4512AA0E2814A2D6E40FA9874F924220402B2 + 98CB6A562790BE89C8C06620A23B18A57C27B970544B92AAA36D415643D31E13 + 787825CA630D33134FAF5C9050E3854EBB0DCFA78339600930B5902C8D338DEE + D5CF036008D7194D099C1F77CF0813AD4D518B3B6AC42C90FD00A283298D5DBA + F7CD4E190BDE72AB5738CF9E5619634D39F6CFF24E06B87829CB199111931EB7 + 3C1B88E47AAC4AA0E2B95C50F695D61B927B04F7DF10AF047C29175D8C1434DC + 687CFDDF39FAFED128E8BF7F7E0A05B1475827BFF3C12EF6DFCF141EF3EB8E6D + F2FDB818DF84EF3A6663DC4F737C2017C3BA91DE4F090F69C6262F821BF50CFE + 27B5E148A6754DBC2AEEED295799EEBCB218E9B0C74A7EDC5AA842ACF17AEB5A + D1C05E6AE261412901029976DC1C2CC518A655C0D90099BE4202935083A7319A + 5ADB485822F153232686F08062C3D19566216AFB2BAC45D0A2B3A745E0DB9360 + 54977747B297AF52B92EBB330398957ADFAE34A4CA82811918AC10D1289EB845 + 064815290CABAFE32F96725509A0412A92565CDFE364C12D652C444A02959550 + 9221D2A7CCFF00312727CBFC7F9C00B9FCF8FF0038020422903F3EB181F4E066 + F693196CD837DACF08D15CE03F33578EBD0B8BC125BB9F434A90BE338BFBBEEB + EE7E9DFDDFDF0D6F8FEEF319BABE9D78CF1C2CCACD5F4B1FCF9E559AF5FEBF2F + AFAEE410A10068C8E3330B98DC2DEB9800B7CABEA43C1D8F854BC6C155874F7D + 433D5B9B9DA8BD415F1B6EBAE069BD9FFEE3255F39C006E013EB4CA1A19F1BB4 + E08C2E4051530A3B16EC3097970E80014DEA83413E54398412D514B9A9A6827A + 6F88EF58CC2799ABBFF4B34EEED5CD745CDA61F71EBCBC23CE14A2E9DD7C67FE + E27C58A216452CB9309DB33C63AC8289CC0E10B3232710A32332B765F45C133A + DAF3D9FCFF00CE7B3F9FF9CB89266DDF4FB73DDFC7FDE3381DCB7D57BFF781AC + EDAE37F98FA716CC689F6FA6BF700CC3BD279F59FF00BFA77EBFF5CA588E3191 + B9C6433C68C257A47DB3398E18F29DFB57F3DB8D121F416BFC72190D7ABFEF03 + 01719D7D3B7FEC7805DF666EFF003BDE6715B34E8EE3ABFDEF822852D3031016 + 549E866ECCF01A2F9428AF6F49FDF180A021285F442A673A9EB78C506B1D01A0 + CD237E9406F60400594469E99B95D261C92442520C45B6963D83318E5A610DE7 + BF561F983A78088C05CA9DB94F341C6BAE1507A80480C285C081C48C0A6320A5 + 04357C1496306410B8275E3F5511FCD702B339F6FF007833D61AF6CE3DF8BA0F + 82F7CF63F8FDC1886F814C5CD966B41121C9171658E6ACF7C6DF3EFC085C3A75 + E9E3FA720C6704D80502C71B7D7FA53BBCA4BE3A54064B832B26B1ED0E02129E + F2FD927F9C10D1B3D7FE1C2C63B3B3846C0F4F5F2FDB3C40A043D33ED37C2944 + 60D131298754FA7DD5319190BB2EF3DAFCCF1CA50132388A9018C83EAEDBC623 + 0C046ACE85D422F9EB87E9EACA87ED0F4B66E3B0642E1C195CC9BB6A862371C2 + EA42808EC732D25F7EE7234350268CEECC1983EDDDEB26B0577183F606DCBC81 + 07000C741036750EBC4381016F9C27FE78C7FED7387E51FF003F9E3121E7BF6F + 5E7A5FC9FEF3D2FE4FF790CCD67AE350D22E42F6DAFDFC5B9E5B7DEDF421F7F7 + FB1C3105EBF3277FBB67DDFBF0336631E72C0FEBF1E4426BEBEB9DF08A117A29 + 9E6C16D46EE63FBFF9DFE8B32F363DEFC6F8A1B67093353B94F5BD7A7C3C5406 + 1EEC0C08E5299BF3BD598CB3373DFF00EEBE670A563F3FF7AFA1E9E20C8A08FA + 6BF3E3BEA1A05732282AF4105EAF2442C3ABA49BC0F6EB33C01818417C31E378 + 3C2F8E86E20657076EE7BC667C19E4196263C67D4FC8F1F30C1759AF4FB77391 + 32839A77B7FAF1BFE78838493D1CF1576FE9424F267E7F31CCBCA7CBC4EC6285 + 9F5FA538E327A02DF529E9FE714831D1A2BE1F53BF2187BFDDB3EEFDFF004606 + 50CF6878E3191196C47C63F4DEB3CDD9FF00B9E6DECFEB9D3E7FAE642F8FA7CF + 9EBEBBE385F467F3FAA35C3B7F3F9E2A42C4AEB69F5D6B9138A65850D9A769A7 + 1713338B2081349416509457D1E14A54B5B3115531E2687CA61DB3CF29E4FAF3 + 67C7D8FD143687BF0EE06C1ADD27D27E5E2145690DFE3E72CCCF8E6AFBFF0047 + 3158EDF3E03FAE8DDE002BDEB2FD03D7D4718C3C45B872DC19188952E21171AC + FEE4AAE73EDFE717D24F5FFCE3964AF92CF9D704584F77DFDF8B566BABBFA183 + 7FD71AF597BF063F8B351A6F0F0231DFC89D7B7E3EA4A375E9FF0079D3E7FAE7 + E53FE72DCF9CFD79ABE7EEFEA1403CFD08FE7FCCF2663EFC64B9961033549C7C + 63A914C8FBE2E18A555ABF37BD68473F54633167E9B3EEFDFF005E9F3FD7E9AB + E7ECF347BF2FC19FA67987F877AF5FC665BCDDF1F72FFCFF00E5A9EFFD3CDFE7 + EE79BBE3EE73AFB3FAE6CFB7F7CFF1DE1FB7FA7357CFDDFD377DBECFD36FA70F + C978E1FC5FE7E9B3EEFDFF004D4F7FE9E6CFBBF7E6C7B9F7E6EF8FB9CFC8F439 + F6799F87D0FDB4FFC40028100101010002020104030101000301000001112100 + 314151617181B1F02091A1C11030D1E1F1FFDA0008010100013F10FF00C1D357 + 42D360040220498722E74A9C2E7C46F857CB9525FB2786218F9EBC6A78BCD7F7 + F1B134C4EBAF969E3AE25B9373DFA6BF1F5CECC470EC2B0D234AA3557CAEF116 + 7AEBA9211DE841D48D6714B59EAB43201309F7DBF4E04896778CFDDE741DFF00 + 8F8FDFF379DA54887BED8606EFF5FF00A040B0A00B195035D6BE54246427EC61 + 984811101E54136B0B86A5457580E022DCEA22028A9512BCDD0251AEB0F374CC + 938224251052523CA06A705C2D0844331E59F6262895358BD10015879BE9BC30 + 21C6F01C04281905CB14A0B1445490C83246312264B41DE9D5E4A9A3A12C5FF4 + D6781F8795A246D8AE3DDF1EBCE6F838EAAA9167DC7A14DAFBAEF82BB523632F + 03341F80BB4E23100BB18ABDC23E1DEC66DBCDB55439581E90EE0F05A000A2B3 + 53D1A5204081F4BCEEFB7E0FE3B8D020A64219E2758E75C8E96FCACF9F7FF787 + A0B1ED004F30963A997EFC052BCC9D3E0FF59C13367AA7E1178E055F67E7AB87 + C1FD7005E8F97F9C34AA47B299DE1FE715053D7F73DFD3821B879B77FBE37A2A + B41ABB7243ECCE24DDE56781022DB8D14575E02DC789E28E1C2C18F02DD0238C + B1CB0857F6A8E20A1AF2F05790107B571406038A094A4606D682C7B1D885BC27 + EB7DCE14B0026FFF0021C9DCC0466408239721FDE5B4C3EA98D808C851CA702F + 02FF005FBF3EF7F4E8D090331264223A089789401304E884A1D8B54749A8AE57 + 8555F5DCE4002CCA2BBACF2B6ED7B2F35BA8408124495D8D054D9C0090880BC6 + 808745DB4492A080464512362F6ADA817A0E094D4142AC849D639E7ED39DDF6F + C1FC4AA70ECC711FF39492E7A9F7FAF042FA61C3CFD77AF3C40EFA7F4E644EA9 + 3F5E4AD72FAF9FA5E4C7CDBDFEFAE18D5B4F7D53D67BE434D9F476FD0CE2C878 + 0E82C0EFAD5F00B7821B323045D15CE5802726B0B161D13AE5046C3368F250F1 + A5B3390069CACF24828967576732F41FCED4EFF49C1D2F228B04BA5899443406 + 498795BC543923856104B28407AE088CBC92D9A19E56A4472F55C02045C8022F + B445622374DEBF0971FDCDC870DE5C663F93F955831A5E11E5DCCB30EA6B8091 + 1AC1CF5429D05840681D891FD8C4C50AC0441175B610EEB4F7D160E713A62B44 + 209A87FA785B47097C8F0EAD058000AAD10927C0F34F90299B05A44F56758877 + 5737A1A59D5E777DBF07F144D92A5F707E386F47E5F8E3443CDBBFE5F8E0ABA1 + D327D4F97855025EE3EB823D8DF5EFC9CFDFDF7C73BCBD5CBC01257FB49FFF00 + 67D78A892D3F2629DF10E790A8FD852A428C09781F75142C7BD51B85B958B9BB + 3A5AE11446217C8E600488111609A944B6085AD623B3C11348E01A698622F7BE + E219B039DF09060868A2261A40B72E11C04868184809FCC3247D101895912A98 + D515B78970BEB8D030E04C106D4E4D15E4B37178BB9720133414A40BAC4390CA + AA78648704F9828AEA0BA31168F609E9E19BCEAD26CCA609D08F66A2A23103A1 + 209D4F425F63E53FBB2CC08C528C16B4CD38F7C20A14A9A66174D2F7170709A9 + 80120045D86874CE777DBF07F134ECFF00E9714F7E12A4EDBD57E9DFCFC7012F + A62FDFBD9EFF00FDE219DE13F1BDFC7FBC10A9D59E7BF9CE3AAFB57822A7AFDF + F3CF1D97C49F6EB83AD08FBADFB493CDECE595469420A60B48D025A1AC160692 + DCC0CF4F22146A8AF3447F536348B123D422880628D0DEFD67D045480B6117C6 + 8A28051E0481829578B6B407AAC001B01D3A0D866916BDE4E695D4508C740240 + 43380C628BAB17A48BF00B43B22B596A90617D0689FA7B8650871770F385E189 + 95060C80572210F5F410A6E14BB6DC058FC8C92714CA2B280882E38BC0C60394 + 038908410025004223593337CF8E3CACD1D8B947121F307A794AC907006C4110 + 56291545D83DD22AC869169D30C36EF27B0EC8D5E9F2743E737B779DDF6FC1FC + 54BE130AC8485DF8F8DF8177C401F3C905CDBD446B2F1C8872CA01445522DD19 + 1E58DA28B8A785F09E6C97E6715A174761827E2FD459DB7D6B9CE4A829401BD6 + 8708201421C91BDC27FC8C1D1CA448B100AC3E11F649CA34912AB80668EC78A6 + D4E3212CC20624761587408C24DE9A63C2F3462330656C7E633354BC956EDD67 + 1EC221A70AFC47B22AA21662C53F12F730ACFA7AC74541C0E01E161E88763692 + 648EE68D1739F2D8E1DD0A5BAB4849DC040E2AFCB1E0B619F2728E2D7916D372 + 5B54021A874F26CC1588004BC55AD1B9204102AA4F98218ED5228E9CE770ADE0 + 85168200445091ABC714B8A78CA32802870B9AF030765EA1D9F00474C009DC2A + 41DAB44100C4217038E1A380151546AC0A9720B2A1F4943088422770E86DAB85 + 09521400DFA35609EA29DEF3BBEDF83F88A05888238268CEDDF13E4A21A00371 + 0A410C835D254CA2F49D808ED70894CC00BC6411A0520150D8AB15A4C0E16ADB + 2C25201462299D82064F92286C145C15E1D061214DB931BD26AF5C2D38C034C8 + 0A53D98473846A240AC148E0C305008608C5A8643B3CB038A901D7E504F4A26F + 958F6B283818B25DCA8E42D7B64646EC21F0D10F09DE5563A64675CE1B7071AA + 0C74DB0A4147917F9B79C63089A6137AD12ED527FE6CD1726C5AD6FC1463AF83 + C11D8024A8DC4FD407C3BC3835714048BEC885C57481340558C4AC68085CCF42 + 8B12B932B1C0888475C1BA20A3D95576809274F92A1B410CFE1396206036736E + 53EADA5752B5D4AF9E326380255D7BA8B04603881C91D12942F746CC5C1DAE6F + 2E8D4A9055D0D44ECF95D7867421DED46F1759D7DBDF3BBEDF83F8C02D170AB0 + C5D1ED77C499C28C64F1E3BBAD0B42F11F1547552223948C8740489E4309284A + 08804B1EEB258DC3BDA69301149BC3A17CAD4808BA08C140D8A205B10316E839 + 2C1D2457B7843582ABE944D8E8BB1D2F807804C32404DD074360EB03894C8B40 + 3543624782F0E83F280214285EDB90BD051C2144D24255C0B3A57048C0606003 + 0C4181671802890D70219E45D8E7C70B53603B8229694AB5D900E14E0BE3771B + A8A00DE1BF02C7B8D681490CF0F6700CA173CA1262CD294E3C488E8732AE510B + E3326544055C56852EAA1898BC9E0625F3077B046912695048F9260707005AA7 + 34C168A858BF00DF180C7A622C038481A89ED74A911AB8C549EC0AA8A1235521 + BAF47A72C34F5D359D6D7B1318609F23DC89533A115D452983928AAC84A5A7A8 + F43127561E8BCEEFB7E0FE2DFB05014076A1A82CF2C25E185365FD85956BD02A + 8F6A82355EB59566A2DC1B21A2BFDFA7E5323F1E0E4BA5EB1AC866A68C909441 + BC8D2D1ED08D80682528437251028D554880F92E80E1071545FC3B4E04422EF7 + BC35601B2CCB5DDC40884528E1A7C562C25AC221583244220CC31023535BC180 + 4E04465A30ECA2529D26A0064E0DB4AD22486888030276200640541DB1AA255E + 89D2B6E41EC460624A8D2925A00D2F08376862A2CA8C3C0120C4470846AE0A8C + 4A1321DA414C54DF63894968C36E344FA77287049478EA8B75C19EA3F904AF40 + AA910828C461B800C9CC3A92C8820A90613A022DA80694E830D66A74A220367E + 945315021F0042887B617CA65B1CA9BFB8C3107370A6BA3E7588D6BBC2097B41 + 45D0F5C37657B9CC723C81EB0C4E975F8E411D1810A8A4A2E47475A74873BBED + F83F88B4A14E74017C5964A0DD6701BE1147940FEB6FDBE0397301894338D505 + A13025ED4AC3C75EB7D77D7DB84822351653A76CF1E1FA3787B246374A10AB14 + 11C2383884124C504E242AAA296398621809814946A848A00EF5386B94B3BD90 + C1093545E81E081D30C379704906A79161E24610000E80880950C04CB2B8414D + 0F66B369A6BA820B0C286A5AC600766AEDD41C40A1CA8C8E8C2A435C0F9482CA + 8442F759407D8BB708705B514CC9A2A1621171AA1400D708EA740831878E7B15 + 3E50EA42E0F5A5BF7910618B85A9625730C6F3C16908676E984A846740715F51 + EE68253C92629CC3CC018C144010649B60505205D8B442A46B8D1CA9C3458066 + 422425A0F0D5BCAAA4262D5012A2082515E323264BB03C47D6603AB93882800E + 5B45042089E5DAFA3943B0883BF20734CDB6F5B74952BBA069F74123DFC47BBE + DF83F8B17F7BABA44BEA7B3CCCDE10515E8A3953AF94128231C04DE6676B7526 + 935092961F1DFEFA0F9BF1D64ED15ECD0D2F9D1C7F1C1B1D42A705647D1E2077 + 211A092D4BD30AC229C2817110309C58B625627A543FD0D5152B604DE0019CCA + 723200A80A95080207B3ADB22037621D9707AC79A6589BDCD495B984B66540AA + 5CA13451C091BADE1C0A2900015170CE17F052F05AC450A60584AF8277FC08CC + 4F41D140838E84D1D214E0B79F56C163405988591B6DB384F484AD1C7C410657 + 90D07865CC0CF0594323C037403300C9BEC011AF86A800116D7CEA881669EA3A + CB0F814F48471197402D8486ECEF7DC1AB0AC596931C3C54E927150F5691E8DA + 3D844B167305AB40E826E8DCF06CF2E053452980B55DF7B75FEF0D24A0881086 + 236B218106ECBDDF6FC1FC56914D3E73CB8C25EB3E9CA9B5301E21A124CA9054 + 1624750E1D918873D9CD49D47EDF53D71A03549515A00AB80035405423C49C43 + FA68B7972D1EFED5E9DCD203CFE171CC86F60A42BF0479F27919CCD3302C1661 + 4861A0222399D646E4F8070212856CDAC306BE012628A152F69578A378A6F62D + 1671170BFB8D8D70736174C022A002F0F2D7E41001052AE01A05030001340881 + 9E6FE3DA74D6A7AF2B6ACFCE576C7BBE78492B3452730090CD4016DA09C00778 + CAE834955EC641E1455E89E2AF953BD4046972724545521BDE42D078D0E046D3 + 8662A4ACEDD3C72A103897204D358A05C758F904451F130804D3574F0A343BB0 + 8F7C81456814E9F4E1B7A89AEF02432E84014077B0ACFF00BCA3934219A15299 + 27B8F453BBEDF83F8E58AAC28BDDEE257A56BE38EB8B2F6F968F4DA4E79518C3 + 7460A0D0411028FEE7E3E1E4010B4006B60640428055386E203B1E52B0238BFF + 000276312945892693A022847E36BCE3F0491C1CBFAEEDF11EA5990011332A04 + D4E9EF49345C1C3E286FF3004615BB7637C5A8A4DF0B9A1001914781B2CBB1CA + 51C9991BBEDA110E69C1BFC8A20654D612F00A7932BB1D316ABE59AA140BCF1B + BC3A0B419FFDCBB29F3CB278A50E691E0A18841BD9B4612707D459EB1B24151C + 1986EE7500BE42965431AAB1244623368F04D4C52BF3D6A2D36E7D22E53596C7 + 509F715261542D055282B14E58A1000F23523A6A50CA2BE70EC4D796BDEB377C + 1E54CBA5B3AED100D711D300BE53CD72E3CB094DA11021EC8C7D29829CEEFB7E + 0FE280B4E11A0CC56E8E81E13CD9081374B0E8457844353A6EF104B89DB5BFA5 + 1B5CD5E74B2EFCFA3D27AE508CDF27643BEBD64E10D2E2EA36D0250A0E94D769 + 6B8EA02F1C2051C0409A424DBA2301403603B986BA14132818D69C1B119D0F01 + 66A015C1068BD091955A70109529579C8621E20EF7AE09C3FA8822B704CE0783 + A82308FD2606A4B39E794C92EA0AFBA9490331410F819828C48411868C4F2705 + C2CDD22A6A1798928C26101E160404708200F065365A2621A8845F883B490E06 + B7AEEC718E083ADEE770A14013202F89A682A2D82DD7C04B4624D595463C1C99 + AE515805900B7309C81AAB8B613A669C3D0FA874D48EC768204700804B4AEC91 + 47EE7778DF8421520B009F02450AAE51FF00A3645A3D94DF18F2EDB469E984B0 + 317C7A4CEFBBEDF83F898FA5C34DD023412C99AC6DAF30D644740AC2821BC481 + 54522FA0BAFAFDC976F3A3E9CF107D8BCBD89FE4F7CB664824C74C125BD680A0 + 418E545C8024C23255C5E0710614D495D82865C393334685CAC263282B4C456A + F8844648E4BB38384C470BA1B8109892DE3A9E91466F80488E20F05012008006 + 4112000040C88727E50F013613A3EC2FBD0ED29889A40955D85A570BC3140090 + 4203D1E01890294426640B8A56035B635B6453A795A081652345A885BC83C21E + 513AA7D24D1747173B64AB101E9EE2D1745A2F9E21918BC05043B4C53B6A093C + B05330D5453DD20DF9B38274FA4A00006395C080A51BD43944056DBBE447D843 + 6AA84170314019C73D4114B8824C010C56AAF19BA010D536DE1475AB252B2F00 + 31D25F34EEFF00FAE06C100517BC41A1F53C8DBCEEFB7E0FE32468F08C1DA08C + 2802F1B87199DB8A636E180B034025654438CECCF081CE82672C6FBFBF0AC33C + C750047ED61B66F9E5B401A1940BD13ABB9E271BD138BD5246A015695C909A02 + 34B90D16B02451A458230105C243080E22A85720691645431741C5FF00AA0040 + 10000E8980829C15E500458258E8B7463D311974748A03E7282E836701C44202 + A8A2F24002760586242E07B2106C01102BC2E9EAED2C23144022088F06D9EDA8 + 0DB5A14DC2400821326689912B09894904C214081D57CC820ADA0828664A062A + AA3A68E89FD88385151F03009565A6276157197186DA811645D8A28B42AEAEBC + 3B266D148310A1E54085948C6BC574A9608083844180486851EB3AE2A85EC105 + 12093E80CF34E816C9068159E9A00F452D215E8D5565E0ECD01DA554CC5560A9 + 83536A8A58AB8AEF4AE1CEEFB7E0FE27490340E09145EB57000F055C8E589757 + 507FA2163203E7B278F5478D37DA18ADFDFDFD9C2D3E5F73A5D3E17AFB78E07A + A6C01B6D02888852B2F1AC1477D7B0E0C8008336E0E08DA82D8462917026B4B4 + 7AA0CA81037B38112825841051069D81780C217347351B095695B1E3FAD6F991 + 4210115A50E67A974D07D1215E92F795423A854DEC96A0B9CB3266638624D1B7 + 86205BC2F35C6408A56F07500EA5AC948712384C82F331903CA076A36EB1D650 + CCFE0021C0268007C0AF17A2C44124820A32E9EB89A0108543427A241B0A13C2 + C16E6A135280A81A7120863E2EBAF7BA812671C0E68DA96E9330D7128786F42A + 5B9071529E445F5E209544EE015ECF4840678F7C6C95C3045884F61F03E73154 + 34438C276060AD559E738F86122D798BB234BF3DA73BBEDF83F8A22A86E9A9A5 + 86C3FAFEF991A3295305EA125053548876A29E9174784CA63DE70D159F3D74F3 + B2A1A3401022F850079743BE205F1498F581887BC20D1E4128AC260211828C8A + B41E0E6390050EFA84358714FD89DA5358588FB52E13B86E62C5B3C522141D93 + 5CC9A075C4AD040E2A2C783F478A882698B0388F0BD3C1898D7E14712935FDB4 + AAB6053770E24CD02B9DC8B04CFDC18700BCCBC740183015C8D0E3CDBB93630A + 731229A219769427F01E78FB0F02D0B503449071532EA203048982A5C3D2E188 + 5D0341E14D0A02839ACB2A65150403509C318ECE263658530192424AA0C8EDF8 + 06AAC9B46B26085D71A84EC51894761943C82943C8519206F6560CB3E48938E4 + F198D41A13571F57C3C6709D736025566D313C0EEA14493AA86C292DD571275C + EEFB7E0FE2A0DE9CFA747D3CDF89F40958106B806C08CB31112BA141E83B5D40 + BA0AD53CF53842C649EF121F545A57C716B27305241E18417418CE0E00408631 + DE211A53C9C573930DA4059025C1112E0F2EDECF1205C0F48F0FC55A233548D5 + 540AE4635A035CC50A104A2B710708E710954C514985E115C95D4A207024588A + 210B1605624169A735A335C7324E4AA6C9011354F623CD565C08E40564124806 + E43E31B6355A6D3185DC209C0401A6C3CE01D702CBA5301E0D3A21B62880300B + 6CA288D49A5064DA0C621302C0B3EEBB4D58324C6854015AD31435536112EE1C + 7435258CAFC02B1E97064E08D122D46EDE4C2F14B290245351CDFB7434114168 + 10E81161905464F1CB52B7C02B9450EC2A683C0D2C26D07E22224ED7EFDDF6FC + 1FC5903DFF004C4EFA5197FA380BA1F39D644A0453C3DA3C9625449808DCD9D9 + 9C807E677FDDEB92EA33FD4D4BFB9C4DC78B15269052A062EDF7D57341E9BC1A + 8514509C08E69299240E89161D9684EA070211026770A96694E0CE4EC850D95D + 1383D591451C5A2BAB58DC1B47101106A60D3C8A0A9185E1B9702C58055C1681 + 4766718B7582A001205C416B54E2DCA964C84C03922C349FB91D08A69AF074AA + 749220192913E5C019404005D45030678072CA1667438384637D9AF7CA92F2B8 + 55299A2092060E2378BF100C6BA05B23AAE5149968C077A401982A5C814D2DB2 + 600AF581851657847E2D8948A206F83AB16F938E5F76F17AAF024A72A8502929 + C215895BA455D0F5020EDB6FC733184F69A027692037E219C075A2BEC49A6DA4 + DE89E479DDF6FC1FC5256838F5E107EECED8DBC028C58A68511C0BB8924E3C7D + 40CE943E3E21DFACCE360AE367C4E60028AA999A536F93A7E463C759A0686020 + 08042C0A0901808AE0211A00EA8B5A4158811515E3694A44A9727D4520C02248 + 5F0144F2CD48B26524C4006721514A1AABA558DBB61F438D20CAAA7E901CB83D + 91C137BC63C407105EDD12E2DD8226462D1D5096046CA5612193CC820E066D0D + B09E10AC69048588552BAF406DB3820CAA08AF492E456B521C22140BC5444481 + 53A00401018E2C12252A5491623030BB81D6F4C03CC7836263F137FF0068AA92 + 5604C194590A8B9A3BCD44BE0B80CAAB45F3D54EDF1FD883AAC11286398FB3C9 + D31EFB384366E196CD591AC578C15723589E1A811788652C0955829A556668AE + EB7AE384C4E322507A5009B7CBC73BBEDF83F8A47EC83145B06F712CF490488B + D582160096F1E008782AE53C70A829810614F2AC2E42FD3CBF5E4160875E00D0 + 5B83283DF4704B02172A44290342A10E1745935330132600FC845431B0292F42 + B7B8E363FAEED0800BED00259C330DCB0458EC3A58556FCAEA794A5969470DF4 + EF19362430533D4846940F42821D1CEA00E4B64489CF308F924CDF3078F04C43 + CB40C5627453821628E8EAEB1954C4E43C36E85B72044A2C6415B256EC008A6C + 90A0A8B64E54F4CB0BEC98BC082AC258CC870553F99C80D0C07A50606244740A + 0A38BD5C24FE54212E1DC40FC8340B47D043940C52AAFB7D676CF07AFF00793A + 89FDB06BF1D77E738C6149D2A2DA1208F838C4BC5DC1D7D3F5C726DA7151F193 + 20ACB580151C09D04CAA22FD704A292F77DBF07F1A9095716C5584192D619CDA + 5DA7C697B66C049FD89DA6CA6BDD57E935671C4FC7EFEFBE22C2A547C3761D65 + 64EDE4B13BCBBB5C2BE61DC768E50ABB419D0BAA0FB1413727963601B5810207 + A759F27F5C00021A4E803B8EB3F88630F81645A12E98F72AEF5B3FEF0F9B7434 + 86133A1F029A2CA0912E9130A0A20790E174944DC5CC61C3399FB3ECF5301251 + C48949F729F4D09A25949E4CD418246F083195DF443984A820BC34206F3FD69D + 3ECCA6E28D71E985A8AA158CDD51A805855239DAF837302E4BB139D6CA644C37 + C68DE0A0EAB278FF0087C70C7639325DC29DE712234C760FC765FB9C3032A459 + 406C140960A0BE38720EA5CC1620A6728EC2717461CA4064553AC7489A2071A3 + C14D0C62494DB58FF2AFABF53F11FBF247DA807D44BF6B7E64E489D07DFA7AB7 + F3C247E4F33F7E7E39805C5F2DC7E9FDF10FE0C63A3CD36F97AE4AB9AC37B679 + FD0042D0700B1F5E1D19603523836A7FA85AA3472D8F86AD45028379C0F20817 + 5C40A7A5858599053D00780C38351519287045662B57B7156A974302DA21246E + 014E45F77DADA08F7D4090A24CF54039428A5AF5A882D3F21AF0FB124468AE45 + 2C960008173128142F805B7D5372CF54BB2835206B91B2B833098FB5651CE16E + EDE191F4023E809DC7271A716832F073A0A30C96F8FEBDFF00FBF0E6F573BFFE + F3F7E382876A967807A018F5BF1F48B110E792FB5613AB2799E1E46A801C0424 + 1DC74CD53C15D6C89A0BAB82C8C3BAAB78A1634AFC901682C7691127126C02D9 + ECEC5A2D0B8CCFE4CAB23A90C6FB65EBA373E8A60FFBE9FB7AF33E78005713EC + 8ABF617F671C207BF3F3C2CC5E9F269C313EF9F74E35117E8A8C50589A658D38 + 2A8821B6E3FD3A70694BC2EAF4C87A9DFE7846CD759E3C6FF7CA869E8AC80346 + F6289DB0DE5F948D3409A89525B74BCD192E09128D60122A509489CB415370AD + 983F7DBE5C9CBA1C6695C696E42EE1A707C45D1B56A116936B4E9C3EAD15B580 + 8213C5D00A6F13E88302A5D008094DDEDE1F7D9C252AD178D4E5183FB5DEA75A + D0E3A2358E764D94728836082E1471040C511146522E9441CE2802C9D0F2B7CF + C3C7C78E2862005DBE3E83EF968984C926BA0275F6179308E1A5247C1745A828 + 39162592912A442C6279DD43273B92751EC951F25ECF19C68005AC961574EA50 + A506294FE307C543B924C67352C3385603B6EB70363EEA91F7C64BDC350089AB + 28DA22C4671A52690613304354DAB38C2D3CE062010231F067BAB9300988AACA + 46AA0255F8E265AA50CB0021D752E7BE120711CA763E501114F277C1BCBF1BC2 + 6452028005521CBE69A9923542D348845478D773262CA147F6BA6EA935ED4390 + 6DC8A9807445AE4A9CA81D2A024A5900B92053DC070054F3082F02CCD8F8A516 + 6A56A45068291A0D59D48051D9C3B2A566E88280753CC0C46148445314D8EE0C + 3990A47C9C390DFA9C28519FCD0D710C842B478311B3B6B854846A1643BC8702 + C863A7CCE92312913898083C6294E957D8DDB4A2283672752544CFFBF6E15C8A + 25EE2AC145BD0A00788C845D00514C95540AF5C0383D74C500B4C750145401E8 + 000470C5742F2021803EB87E8346081240D1DB0B04FE329D63E6EE17FDCE44E0 + 89136848CA505750CCA9C497403F50A21D6F5D67E589CB208A1DBBF7D78DEAF1 + 213126250A20FBD9199F1C8353C4D277D1D77F0FC9DF11054C6EB20300007660 + 4510108ADC3A755A515D700060AA585B6FC69730861C46490442D34445584198 + A317D5423060AE5C958A6E702880461D8D080EFD7435BAF2B8F28C9EECDAA4B8 + 2009CE3242A8C983E4848A1C5647040A2EC2002866B5C2AF181CD25AEAE03481 + E0D88011714177AED467D34E36636ED70F181C20738971248DD414C828813081 + 47647CD412D47803CB9B3B1638241205001224877DAE1255010A51068587A20B + A728C970910A8EE8213C1831288B2D12151228033D398113B2840AB1B1291544 + 100CE1A8AA010F4503090C433937412034E808219148664E048123B6119DA099 + 3804C72389EF8E2C44813FE426A587CDFE78D9005F63A033B40B7AEA3BC86002 + 405817E6FF005E3E9C0C5533CBFF003DF4F683792719C215023CC88F9679560A + DEA5632958283301E0C0901423C80003500308E358F82BEA87F1F9F5C683CDBF + 0789F5F9E068638885810268740C6A38A34C0B0341A0457427C4E0282BAD7B7C + 4613207BCDAEF1017B663EBC1D4F3FBD711C1C5045A916214C92E39565064A49 + 662480142748ADE018114BCED559F387866AED33A03F726D932D2DAA7E7450D5 + E6E2823C6D0107B5480140C50008C94229901203ECEDEA837881175821052564 + D3161DA2BC04020005D7CD5D527BF10CDBD3B0254196025FA8FC7738DE40FAC7 + 4B1ACA155D50F1436C1BD88428B13551ECE0AE372814453EE8331F083E260A01 + 68F7C20F4C2099B38C1E02D03A01712232C78E0A155EA2F46F6A8187F2B03202 + 11F4074E7084A8F35EFD787ACE512E00BBA9761E6EC2BBE7D060053E5BEBEDE0 + 5D8C1151EE27D032FB3CA2A5210A461AC74D9DB82F83237198EC773F2AEFAD53 + A3A5AD533EF3BF7BB88D1300DCEBFBF5C1F459C08A650BDA020B0B3832D1548F + 9F93E02C3DCC9C22C41B3E55E7EBF9E0B625F1FDB7BFF383220BB7498F8B77A9 + D670BA46AC2114B913AD2530F0CF60B9A63666AE30E06E4ED4BB40513625E2A0 + 88415491C8DDACA138C94569A0069C67A4FA8F240D2E1222B775D3444F31F7C3 + DDD843C867824CA2B92CEB229519E3352F6F6F57888164CBFDECF7FBD7090203 + 7BA7AAB988F51DDAF2A6D140A1E57789D1BEB8C2322AB206C079211A50792C04 + AD5404DA8CEB05A6D919D61ACAAE1A348811EFD955038FA082C1CFF27A1F43F1 + FF00BD8FA9F9E7E8BD3FF2B7E83DF3FAAF7E7E9F779F91FC3CFF0053F27FE2FD + C7A79FB9F5CFF77E2E747D3F1E3BFF005CE7FD4FC9CFD87AE3FC5CBA3F5D1CFD + 1F5E3B783B38BF47EBFF00C0C8B8F03FFFD9} + Stretch = True + Visible = False + end + object Memo4: TMemo + Left = 8 + Top = 8 + Width = 161 + Height = 369 + Anchors = [akLeft, akTop, akBottom] + Lines.Strings = ( + 'To the right is a list of authors ' + 'and contributors to ' + 'TurboPower LockBox 3.' + 'Not included are the authors ' + 'of LockBox 1 & 2, as there is ' + 'no common' + 'copyrightable content ' + 'between them and LockBox 3.' + '' + 'The LockBox 3 project ' + 'welcomes any contributions. If ' + 'you wish to contribute,' + 'and your contributions are ' + 'accepted, your details can, if ' + 'you request, be' + 'added to this list of authors.') + TabOrder = 0 + end + object lbxAuthors: TListBox + Left = 175 + Top = 8 + Width = 138 + Height = 121 + ItemHeight = 13 + Items.Strings = ( + 'Sean B. Durkin' + 'David Barton' + 'Nick Chevsky') + TabOrder = 1 + OnClick = lbxAuthorsClick + end + end + object tsSupport: TTabSheet + Caption = 'Support' + ImageIndex = 5 + object memoSupport: TMemo + Left = 3 + Top = 24 + Width = 286 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'Support can be obtained through the ' + 'forums at:' + 'http://lockbox.seanbdurkin.id.au/tiki-f' + 'orums.php') + ParentFont = False + ReadOnly = True + TabOrder = 0 + end + object memoHelp: TMemo + Left = 295 + Top = 24 + Width = 333 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'User help for this component suite' + 'can be found at' + 'http://lockbox.seanbdurkin.id.au/LB3Help_H' + 'ome .' + 'If the help is still partially' + 'under construction, please either be' + 'patient, or offer your own content.' + '') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsAlgorithms: TTabSheet + Caption = 'Algorithms' + ImageIndex = 6 + object Panel1: TPanel + Left = 3 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 0 + object Label13: TLabel + Left = 16 + Top = 0 + Width = 116 + Height = 13 + Caption = 'About selected Hash' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblHashDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label15: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblHashDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashWikipediaURL: TLabel + Left = 16 + Top = 136 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lblHashDigestSize: TLabel + Left = 16 + Top = 184 + Width = 97 + Height = 13 + Caption = 'Digest size = 64 bits' + end + object lbxHashFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + object pnlCipherDescription: TPanel + Left = 299 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 1 + object Label20: TLabel + Left = 16 + Top = 0 + Width = 124 + Height = 13 + Caption = 'About selected Cipher' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblCipherDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label22: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblCipherDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherWikipediaURL: TLabel + Left = 16 + Top = 141 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lbxCipherFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + object memoExtraCipherDescription: TMemo + Left = 16 + Top = 192 + Width = 233 + Height = 89 + Lines.Strings = ( + 'Extra Cipher Description') + ParentColor = True + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 1 + Visible = False + end + end + object Panel3: TPanel + Left = 3 + Top = 231 + Width = 270 + Height = 146 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 2 + object Label27: TLabel + Left = 16 + Top = 0 + Width = 170 + Height = 13 + Caption = 'About selected Chaining Mode' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblChainName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label29: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblChainWikipedia: TLabel + Left = 16 + Top = 120 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lbxChainFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + end + end + end + object btnClose: TButton + Left = 280 + Top = 416 + Width = 75 + Height = 25 + Anchors = [akLeft, akBottom] + Caption = 'Close' + ModalResult = 1 + TabOrder = 1 + end +end diff --git a/design/TPLB3.ComponentAbout.pas b/LockBox3/design/TPLB3.ComponentAbout.pas similarity index 96% rename from design/TPLB3.ComponentAbout.pas rename to LockBox3/design/TPLB3.ComponentAbout.pas index fbddd91..873f891 100644 --- a/design/TPLB3.ComponentAbout.pas +++ b/LockBox3/design/TPLB3.ComponentAbout.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,529 +12,529 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit TPLB3.ComponentAbout; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; - -const - WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; - -type - TTPLb_fmComponentAbout = class(TForm) - pnlAbout: TPanel; - btnClose: TButton; - pgAboutContent: TPageControl; - tsMain: TTabSheet; - tsWelcome: TTabSheet; - tsProject: TTabSheet; - tsCopyLeft: TTabSheet; - tsAuthors: TTabSheet; - tsSupport: TTabSheet; - tsAlgorithms: TTabSheet; - Image1: TImage; - lblTitle: TLabel; - Label1: TLabel; - lblRunTimeVersion: TLabel; - lblDesignTimeVersion: TLabel; - Memo1: TMemo; - browserIntro: TWebBrowser; - Label4: TLabel; - Memo2: TMemo; - lblWebsite: TLabel; - Label7: TLabel; - Label8: TLabel; - Memo3: TMemo; - Label9: TLabel; - Memo4: TMemo; - lbxAuthors: TListBox; - imgAuthorPic: TImage; - Bevel1: TBevel; - lblAuthorEmail: TLabel; - lblAuthorWeb: TLabel; - Label12: TLabel; - memoSupport: TMemo; - memoHelp: TMemo; - Panel1: TPanel; - Label13: TLabel; - lblHashDisplayName: TLabel; - Label15: TLabel; - lbxHashFeatures: TListBox; - lblHashDefinitionURL: TLabel; - lblHashWikipediaURL: TLabel; - lblHashBlockSize: TLabel; - lblHashDigestSize: TLabel; - pnlCipherDescription: TPanel; - Label20: TLabel; - lblCipherDisplayName: TLabel; - Label22: TLabel; - lblCipherDefinitionURL: TLabel; - lblCipherWikipediaURL: TLabel; - lblCipherBlockSize: TLabel; - lbxCipherFeatures: TListBox; - Panel3: TPanel; - Label27: TLabel; - lblChainName: TLabel; - Label29: TLabel; - lblChainWikipedia: TLabel; - lbxChainFeatures: TListBox; - lblLogoAttribution: TLabel; - lblWebLabel: TStaticText; - imgSean: TImage; - imgNick: TImage; - memoExtraCipherDescription: TMemo; - memoWelcomeInstructions: TMemo; - procedure lblTpsfaContactClick(Sender: TObject); - procedure OnURL_Click(Sender: TObject); - procedure lbxAuthorsClick(Sender: TObject); - procedure FormCreate(Sender: TObject); - private - { Private declarations } - - public - procedure UpdateAbout( SelectedComponent: TComponent); - end; - -var - TPLb_fmComponentAbout: TTPLb_fmComponentAbout; - -implementation - - - - - - - - - - - - - -uses TPLB3.InfoUtils, TPLB3.Hash, TPLB3.HashDsc, ShellAPI, TPLB3.StreamCipher, - TPLB3.Signatory, TPLB3.Codec, TypInfo, TPLB3.BlockCipher, Registry, - TPLB3.I18n, TPLB3.Decorators -{$IF CompilerVersion >= 21} - , Rtti -{$IFEND} - ; -{$R *.dfm} -{ -Content Plan -============ -Page 1: Main -0. Big Title: TurboPower LockBox 3 -2. Product definition statement. -3. Logo or nice graphic for LockBox 3 -7. run-time PE version number -8. design-time PE version -4. Brief statement about FOSS: LGPL - -Page 2: Welcome message -1. Embedded video by me introducing the component suite. - -Page 3: Brought to you by ... -Statement about project organisation and control (tpfsa) -5. tpfsa email -6. sourceforge url - -Page 4: CopyLeft -12. Copyright (mark and statement of application) -10. Statement of copying permission -9. LGPL 3 logo as clickable link -11. LGPL and GPL full wording - -Page 5: Authors -13. About authors. List - - 13.1 Name - 13.2 Photo - 13.3 Email -14 Statement welcoming contributions and adding to the list of authors. - -Page 6: Support -15 Statement about official support. -16 Statement about wiki documentation. - -Page 7: Algorithms -17 About Selected Hash - - 17.1 DisplayName - 17.2 Feature list - 17.3 Definition URL - 17.4 Wikipedia URL - 17.5 Block size - 17.6 Digest size -18 About Selected Chaining Mode - - DisplayName - Feature list - Definition URL - Wikipedia URL -19 About Selected Block Cipher - - DisplayName - Feature list - Definition URL - Wikipedia URL - Block size - -} -{ TTPLb_fmComponentAbout } - -procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); -var - Idx: integer; - Author, sAuthorEmail, sAuthorWeb: string; -begin -Idx := lbxAuthors.ItemIndex; -if Idx <> -1 then - Author := lbxAuthors.Items[ Idx] - else - Author := ''; -if SameText( Author, 'Sean B. Durkin') then - Idx := 0 - else if SameText( Author, 'David Barton') then - Idx := 1 - else if SameText( Author, 'Nick Chevsky') then - Idx := 2 - else if SameText( Author, 'Another contributor') then - Idx := -1 - else - Idx := -1; -case Idx of - -1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := ''; - sAuthorWeb := '' - end; - 0: begin - imgAuthorPic.Picture := imgSean.Picture; - sAuthorEmail := 'sean@seanbdurkin.id.au'; - sAuthorWeb := 'http:\\www.seanbdurkin.id.au' - end; - 1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := 'crypto@cityinthesky.co.uk'; - sAuthorWeb := '' - end; - 2: begin - imgAuthorPic.Picture := imgNick.Picture; - sAuthorEmail := 'nchevsky@gmail.com'; - sAuthorWeb := 'http://blog.blazis.com/' - end; - end; -if sAuthorEmail <> '' then - lblAuthorEmail.Caption := DS_Email + sAuthorEmail - else - lblAuthorEmail.Caption := ''; -if sAuthorWeb <> '' then - lblAuthorWeb.Caption := DS_Web + sAuthorWeb - else - lblAuthorWeb.Caption := ''; -end; - -procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); -var - s: string; -begin -if (Sender is TLabel) then - begin - s := TLabel( Sender).Caption; - ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) - end -end; - - - -procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); -begin -lblAuthorEmail.Caption := ''; -lblAuthorWeb.Caption := ''; -browserIntro.Navigate( WelcomeVideo_URL) -end; - -procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); -begin -// -end; - -procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); -var - LibName: string; - FileVersion: string; - HashComp: THash; - HashDsc: IHashDsc; - s: string; - CodecComp: TCodec; - Chain: IBlockChainingModel; - StreamCipher: IStreamCipher; - BlockCipher: IBlockCipher; - ErrorPos: integer; - Reg: TRegistry; - isDebug: boolean; - Features1: TAlgorithmicFeatureSet; - ExtraCipherDescription: string; - -{$IF compilerversion >= 21} - ControlObject: IControlObject; - Controller: TObject; - LContext: TRttiContext; - LType: TRttiType; - Attr: TCustomAttribute; - DesignDesc: DesignDescription; -{$IFEND} - - procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); - var - Feat: TAlgorithmicFeature; - begin -{$IF compilerversion >= 16} - // Delphi 2005 or above - for Feat in Features do - begin - -{$ELSE} - // Delphi 7 or below - for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do - begin - if not (Feat in Features) then continue; -{$IFEND} - - s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); - Lbx.Items.Add( s) - end - end; - - function WikipediaRelativeURL( const Relative: string): string; - begin - result := Relative; - if (Pos( 'http:' , lowercase( result)) <> 1) and - (Pos( 'https:', lowercase( result)) <> 1) and - (result <> '') then - result := 'http://en.wikipedia.org/wiki/' + result - end; - - procedure Debug( const Line: string); - begin - if isDebug and (Line <> '') then - lbxHashFeatures.Items.Add( Line) - end; - - procedure DebugFmt( const Fmt: string; const Args: array of const); - begin - Debug( Format( Fmt, Args)) - end; - -begin -lbxHashFeatures.Clear; -Reg := TRegistry.Create; -try - Reg.RootKey := HKEY_CURRENT_USER; - isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and - Reg.ReadBool( 'Debug') -finally -Reg.Free -end; -ErrorPos := 0; -try -Get_TP_LockBox3_Info( LibName, FileVersion); -lblRunTimeVersion.Caption := Format( DS_RunTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); -Get_dclTP_LockBox3_Info( LibName, FileVersion); -lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); - -if SelectedComponent is THash then - HashComp := THash( SelectedComponent) - else - HashComp := nil; - -Inc( ErrorPos); -if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and - (HashComp.HashId <> '') then - HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) - else - HashDsc := nil; - -Inc( ErrorPos); -CodecComp := nil; -if SelectedComponent is TCodec then - CodecComp := TCodec( SelectedComponent); - -Inc( ErrorPos); -if (SelectedComponent is TSignatory) and - assigned( TSignatory( SelectedComponent).Codec) and - TSignatory( SelectedComponent).Codec.isAsymetric then - CodecComp := TSignatory( SelectedComponent).Codec; -Inc( ErrorPos); - -if assigned( HashComp) then - begin - lblHashDisplayName.Caption := HashComp.Hash; - PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) - end - else - lblHashDisplayName.Caption := DS_HashNotSelected; - -Inc( ErrorPos); -if assigned( HashDsc) then - begin - lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; - lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); - lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); - lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); - end - else - begin - lblHashDefinitionURL.Caption := ''; - lblHashWikipediaURL.Caption := ''; - lblHashBlockSize.Caption := ''; - lblHashDigestSize.Caption := ''; - end; - - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.ChainModeId <> '') then - Chain := CodecComp.CryptoLibrary - .BlockChainingModelIntfc( CodecComp.ChainModeId) - else - Chain := nil; - - -Inc( ErrorPos); -lbxChainFeatures.Items.Clear; -if assigned( Chain) then - begin - lblChainName.Caption := Chain.DisplayName; - PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); - lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) - end - else - begin - lblChainName.Caption := DS_ChainModeNotSelected; - lblChainWikipedia.Caption := '' - end; - - -Inc( ErrorPos); -if assigned( CodecComp) then - lblCipherDisplayName.Caption := CodecComp.Cipher - else - lblCipherDisplayName.Caption := DS_CodecNotSelected; - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.StreamCipherId <> '') then - StreamCipher := CodecComp.CryptoLibrary - .StreamCipherIntfc( CodecComp.StreamCipherId) - else - StreamCipher := nil; - -Inc( ErrorPos); -if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and - (CodecComp.BlockCipherId <> '') then - begin - BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); - if assigned( BlockCipher) then - StreamCipher := nil - end - else - BlockCipher := nil; - -ExtraCipherDescription := ''; -memoExtraCipherDescription.Visible := False; -pnlCipherDescription.Height := 209; - -{$IF compilerversion >= 21} -if not Supports( BlockCipher, IControlObject, ControlObject) then - Supports( StreamCipher, IControlObject, ControlObject); -if assigned( ControlObject) then - Controller := ControlObject.ControlObject - else - Controller := nil; -DesignDesc := nil; -if assigned( Controller) then - begin - LContext := TRttiContext.Create; - try - LType := LContext.GetType( Controller.ClassType); - for Attr in LType.GetAttributes do - begin - if not (Attr is DesignDescription) then continue; - DesignDesc := DesignDescription( Attr); - break - end; - if assigned( DesignDesc) then - ExtraCipherDescription := DesignDesc.Description - finally - LContext.Free - end - end; -{$IFEND} - -if ExtraCipherDescription <> '' then - begin - memoExtraCipherDescription.Height := 100; - pnlCipherDescription.Height := pnlCipherDescription.Height + - memoExtraCipherDescription.Height; - memoExtraCipherDescription.Visible := True; - memoExtraCipherDescription.Lines.Text := ExtraCipherDescription - end; - -Inc( ErrorPos); -lbxCipherFeatures.Items.Clear; -if assigned( StreamCipher) then - begin - ErrorPos := 20; - PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); - lblCipherBlockSize.Caption := '' - end - else if assigned( BlockCipher) then - begin - ErrorPos := 30; - Features1 := BlockCipher.Features; - Include( Features1, afBlockAdapter); - PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); - lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) - end - else - begin - ErrorPos := 40; - lblCipherDefinitionURL.Caption := ''; - lblCipherWikipediaURL.Caption := ''; - lblCipherBlockSize.Caption := '' - end -except on E: Exception do - begin - DebugFmt( 'ERROR! (%d)', [ErrorPos]); - DebugFmt( 'Class = %s', [E.ClassName]); - DebugFmt( 'Error = %s', [E.Message]) - end; -end -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit TPLB3.ComponentAbout; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; + +const + WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; + +type + TTPLb_fmComponentAbout = class(TForm) + pnlAbout: TPanel; + btnClose: TButton; + pgAboutContent: TPageControl; + tsMain: TTabSheet; + tsWelcome: TTabSheet; + tsProject: TTabSheet; + tsCopyLeft: TTabSheet; + tsAuthors: TTabSheet; + tsSupport: TTabSheet; + tsAlgorithms: TTabSheet; + Image1: TImage; + lblTitle: TLabel; + Label1: TLabel; + lblRunTimeVersion: TLabel; + lblDesignTimeVersion: TLabel; + Memo1: TMemo; + browserIntro: TWebBrowser; + Label4: TLabel; + Memo2: TMemo; + lblWebsite: TLabel; + Label7: TLabel; + Label8: TLabel; + Memo3: TMemo; + Label9: TLabel; + Memo4: TMemo; + lbxAuthors: TListBox; + imgAuthorPic: TImage; + Bevel1: TBevel; + lblAuthorEmail: TLabel; + lblAuthorWeb: TLabel; + Label12: TLabel; + memoSupport: TMemo; + memoHelp: TMemo; + Panel1: TPanel; + Label13: TLabel; + lblHashDisplayName: TLabel; + Label15: TLabel; + lbxHashFeatures: TListBox; + lblHashDefinitionURL: TLabel; + lblHashWikipediaURL: TLabel; + lblHashBlockSize: TLabel; + lblHashDigestSize: TLabel; + pnlCipherDescription: TPanel; + Label20: TLabel; + lblCipherDisplayName: TLabel; + Label22: TLabel; + lblCipherDefinitionURL: TLabel; + lblCipherWikipediaURL: TLabel; + lblCipherBlockSize: TLabel; + lbxCipherFeatures: TListBox; + Panel3: TPanel; + Label27: TLabel; + lblChainName: TLabel; + Label29: TLabel; + lblChainWikipedia: TLabel; + lbxChainFeatures: TListBox; + lblLogoAttribution: TLabel; + lblWebLabel: TStaticText; + imgSean: TImage; + imgNick: TImage; + memoExtraCipherDescription: TMemo; + memoWelcomeInstructions: TMemo; + procedure lblTpsfaContactClick(Sender: TObject); + procedure OnURL_Click(Sender: TObject); + procedure lbxAuthorsClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { Private declarations } + + public + procedure UpdateAbout( SelectedComponent: TComponent); + end; + +var + TPLb_fmComponentAbout: TTPLb_fmComponentAbout; + +implementation + + + + + + + + + + + + + +uses TPLB3.InfoUtils, TPLB3.Hash, TPLB3.HashDsc, ShellAPI, TPLB3.StreamCipher, + TPLB3.Signatory, TPLB3.Codec, TypInfo, TPLB3.BlockCipher, Registry, + TPLB3.I18n, TPLB3.Decorators +{$IF CompilerVersion >= 21} + , Rtti +{$IFEND} + ; +{$R *.dfm} +{ +Content Plan +============ +Page 1: Main +0. Big Title: TurboPower LockBox 3 +2. Product definition statement. +3. Logo or nice graphic for LockBox 3 +7. run-time PE version number +8. design-time PE version +4. Brief statement about FOSS: LGPL + +Page 2: Welcome message +1. Embedded video by me introducing the component suite. + +Page 3: Brought to you by ... +Statement about project organisation and control (tpfsa) +5. tpfsa email +6. sourceforge url + +Page 4: CopyLeft +12. Copyright (mark and statement of application) +10. Statement of copying permission +9. LGPL 3 logo as clickable link +11. LGPL and GPL full wording + +Page 5: Authors +13. About authors. List - + 13.1 Name + 13.2 Photo + 13.3 Email +14 Statement welcoming contributions and adding to the list of authors. + +Page 6: Support +15 Statement about official support. +16 Statement about wiki documentation. + +Page 7: Algorithms +17 About Selected Hash - + 17.1 DisplayName + 17.2 Feature list + 17.3 Definition URL + 17.4 Wikipedia URL + 17.5 Block size + 17.6 Digest size +18 About Selected Chaining Mode - + DisplayName + Feature list + Definition URL + Wikipedia URL +19 About Selected Block Cipher - + DisplayName + Feature list + Definition URL + Wikipedia URL + Block size + +} +{ TTPLb_fmComponentAbout } + +procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); +var + Idx: integer; + Author, sAuthorEmail, sAuthorWeb: string; +begin +Idx := lbxAuthors.ItemIndex; +if Idx <> -1 then + Author := lbxAuthors.Items[ Idx] + else + Author := ''; +if SameText( Author, 'Sean B. Durkin') then + Idx := 0 + else if SameText( Author, 'David Barton') then + Idx := 1 + else if SameText( Author, 'Nick Chevsky') then + Idx := 2 + else if SameText( Author, 'Another contributor') then + Idx := -1 + else + Idx := -1; +case Idx of + -1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := ''; + sAuthorWeb := '' + end; + 0: begin + imgAuthorPic.Picture := imgSean.Picture; + sAuthorEmail := 'sean@seanbdurkin.id.au'; + sAuthorWeb := 'http:\\www.seanbdurkin.id.au' + end; + 1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := 'crypto@cityinthesky.co.uk'; + sAuthorWeb := '' + end; + 2: begin + imgAuthorPic.Picture := imgNick.Picture; + sAuthorEmail := 'nchevsky@gmail.com'; + sAuthorWeb := 'http://blog.blazis.com/' + end; + end; +if sAuthorEmail <> '' then + lblAuthorEmail.Caption := DS_Email + sAuthorEmail + else + lblAuthorEmail.Caption := ''; +if sAuthorWeb <> '' then + lblAuthorWeb.Caption := DS_Web + sAuthorWeb + else + lblAuthorWeb.Caption := ''; +end; + +procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); +var + s: string; +begin +if (Sender is TLabel) then + begin + s := TLabel( Sender).Caption; + ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) + end +end; + + + +procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); +begin +lblAuthorEmail.Caption := ''; +lblAuthorWeb.Caption := ''; +browserIntro.Navigate( WelcomeVideo_URL) +end; + +procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); +begin +// +end; + +procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); +var + LibName: string; + FileVersion: string; + HashComp: THash; + HashDsc: IHashDsc; + s: string; + CodecComp: TCodec; + Chain: IBlockChainingModel; + StreamCipher: IStreamCipher; + BlockCipher: IBlockCipher; + ErrorPos: integer; + Reg: TRegistry; + isDebug: boolean; + Features1: TAlgorithmicFeatureSet; + ExtraCipherDescription: string; + +{$IF compilerversion >= 21} + ControlObject: IControlObject; + Controller: TObject; + LContext: TRttiContext; + LType: TRttiType; + Attr: TCustomAttribute; + DesignDesc: DesignDescription; +{$IFEND} + + procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); + var + Feat: TAlgorithmicFeature; + begin +{$IF compilerversion >= 16} + // Delphi 2005 or above + for Feat in Features do + begin + +{$ELSE} + // Delphi 7 or below + for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do + begin + if not (Feat in Features) then continue; +{$IFEND} + + s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); + Lbx.Items.Add( s) + end + end; + + function WikipediaRelativeURL( const Relative: string): string; + begin + result := Relative; + if (Pos( 'http:' , lowercase( result)) <> 1) and + (Pos( 'https:', lowercase( result)) <> 1) and + (result <> '') then + result := 'http://en.wikipedia.org/wiki/' + result + end; + + procedure Debug( const Line: string); + begin + if isDebug and (Line <> '') then + lbxHashFeatures.Items.Add( Line) + end; + + procedure DebugFmt( const Fmt: string; const Args: array of const); + begin + Debug( Format( Fmt, Args)) + end; + +begin +lbxHashFeatures.Clear; +Reg := TRegistry.Create; +try + Reg.RootKey := HKEY_CURRENT_USER; + isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and + Reg.ReadBool( 'Debug') +finally +Reg.Free +end; +ErrorPos := 0; +try +Get_TP_LockBox3_Info( LibName, FileVersion); +lblRunTimeVersion.Caption := Format( DS_RunTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); +Get_dclTP_LockBox3_Info( LibName, FileVersion); +lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); + +if SelectedComponent is THash then + HashComp := THash( SelectedComponent) + else + HashComp := nil; + +Inc( ErrorPos); +if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and + (HashComp.HashId <> '') then + HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) + else + HashDsc := nil; + +Inc( ErrorPos); +CodecComp := nil; +if SelectedComponent is TCodec then + CodecComp := TCodec( SelectedComponent); + +Inc( ErrorPos); +if (SelectedComponent is TSignatory) and + assigned( TSignatory( SelectedComponent).Codec) and + TSignatory( SelectedComponent).Codec.isAsymetric then + CodecComp := TSignatory( SelectedComponent).Codec; +Inc( ErrorPos); + +if assigned( HashComp) then + begin + lblHashDisplayName.Caption := HashComp.Hash; + PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) + end + else + lblHashDisplayName.Caption := DS_HashNotSelected; + +Inc( ErrorPos); +if assigned( HashDsc) then + begin + lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; + lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); + lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); + lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); + end + else + begin + lblHashDefinitionURL.Caption := ''; + lblHashWikipediaURL.Caption := ''; + lblHashBlockSize.Caption := ''; + lblHashDigestSize.Caption := ''; + end; + + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.ChainModeId <> '') then + Chain := CodecComp.CryptoLibrary + .BlockChainingModelIntfc( CodecComp.ChainModeId) + else + Chain := nil; + + +Inc( ErrorPos); +lbxChainFeatures.Items.Clear; +if assigned( Chain) then + begin + lblChainName.Caption := Chain.DisplayName; + PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); + lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) + end + else + begin + lblChainName.Caption := DS_ChainModeNotSelected; + lblChainWikipedia.Caption := '' + end; + + +Inc( ErrorPos); +if assigned( CodecComp) then + lblCipherDisplayName.Caption := CodecComp.Cipher + else + lblCipherDisplayName.Caption := DS_CodecNotSelected; + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.StreamCipherId <> '') then + StreamCipher := CodecComp.CryptoLibrary + .StreamCipherIntfc( CodecComp.StreamCipherId) + else + StreamCipher := nil; + +Inc( ErrorPos); +if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and + (CodecComp.BlockCipherId <> '') then + begin + BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); + if assigned( BlockCipher) then + StreamCipher := nil + end + else + BlockCipher := nil; + +ExtraCipherDescription := ''; +memoExtraCipherDescription.Visible := False; +pnlCipherDescription.Height := 209; + +{$IF compilerversion >= 21} +if not Supports( BlockCipher, IControlObject, ControlObject) then + Supports( StreamCipher, IControlObject, ControlObject); +if assigned( ControlObject) then + Controller := ControlObject.ControlObject + else + Controller := nil; +DesignDesc := nil; +if assigned( Controller) then + begin + LContext := TRttiContext.Create; + try + LType := LContext.GetType( Controller.ClassType); + for Attr in LType.GetAttributes do + begin + if not (Attr is DesignDescription) then continue; + DesignDesc := DesignDescription( Attr); + break + end; + if assigned( DesignDesc) then + ExtraCipherDescription := DesignDesc.Description + finally + LContext.Free + end + end; +{$IFEND} + +if ExtraCipherDescription <> '' then + begin + memoExtraCipherDescription.Height := 100; + pnlCipherDescription.Height := pnlCipherDescription.Height + + memoExtraCipherDescription.Height; + memoExtraCipherDescription.Visible := True; + memoExtraCipherDescription.Lines.Text := ExtraCipherDescription + end; + +Inc( ErrorPos); +lbxCipherFeatures.Items.Clear; +if assigned( StreamCipher) then + begin + ErrorPos := 20; + PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); + lblCipherBlockSize.Caption := '' + end + else if assigned( BlockCipher) then + begin + ErrorPos := 30; + Features1 := BlockCipher.Features; + Include( Features1, afBlockAdapter); + PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); + lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) + end + else + begin + ErrorPos := 40; + lblCipherDefinitionURL.Caption := ''; + lblCipherWikipediaURL.Caption := ''; + lblCipherBlockSize.Caption := '' + end +except on E: Exception do + begin + DebugFmt( 'ERROR! (%d)', [ErrorPos]); + DebugFmt( 'Class = %s', [E.ClassName]); + DebugFmt( 'Error = %s', [E.Message]) + end; +end +end; + +end. diff --git a/design/TPLB3.ComponentEditors.pas b/LockBox3/design/TPLB3.ComponentEditors.pas similarity index 96% rename from design/TPLB3.ComponentEditors.pas rename to LockBox3/design/TPLB3.ComponentEditors.pas index 29ddf43..ba61443 100644 --- a/design/TPLB3.ComponentEditors.pas +++ b/LockBox3/design/TPLB3.ComponentEditors.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,482 +12,482 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit TPLB3.ComponentEditors; -interface - - -procedure Register; - -implementation - - - - - - - - - - - -uses Classes, TypInfo, DesignIntf, DesignEditors, VCLEditors, SysUtils, - TPLB3.Hash, TPLB3.CryptographicLibrary, TPLB3.ComponentAbout, - TPLB3.BaseNonVisualComponent, TPLB3.HashDsc, TPLB3.Codec, - TPLB3.BlockCipher, TPLB3.Signatory, TPLB3.I18n; - -type -TLockBoxEditor = class( TStringProperty) - public - function GetAttributes: TPropertyAttributes; override; - procedure Edit; override; - end; - - -THashEditor2 = class( TStringProperty, IProperty) - protected - function GetEditValue2( out Value: string): Boolean; virtual; - function IProperty.GetEditValue = GetEditValue2; - function SharedNonEmptyLibrary: Boolean; - - public - function GetAttributes: TPropertyAttributes; override; - procedure GetValues(Proc: TGetStrProc); override; - procedure SetValue( const Value: string); override; - end; - -TCipherEditor = class( TStringProperty, IProperty) - protected - function GetEditValue2( out Value: string): Boolean; virtual; - function IProperty.GetEditValue = GetEditValue2; - function SharedNonEmptyLibrary: Boolean; - - public - function GetAttributes: TPropertyAttributes; override; - procedure GetValues(Proc: TGetStrProc); override; - procedure SetValue( const Value: string); override; - end; - -TChainEditor = class( TCipherEditor) - public - procedure GetValues(Proc: TGetStrProc); override; - procedure SetValue( const Value: string); override; - end; - - -procedure Register; -begin -RegisterPropertyEditor( TypeInfo( string), TTPLb_BaseNonVisualComponent, 'About', TLockBoxEditor); -RegisterPropertyEditor( TypeInfo( string), THash, 'Hash', THashEditor2); -RegisterPropertyEditor( TypeInfo( string), TCodec, 'Cipher', TCipherEditor); -RegisterPropertyEditor( TypeInfo( string), TCodec, 'ChainMode', TChainEditor) -end; - - - - -{ THashEditor2 } - -function THashEditor2.GetAttributes: TPropertyAttributes; -begin -result := [ paValueList, paSortList, paMultiSelect, - paRevertable - -{$IF compilerversion >= 16} - // Delphi 2005 or above - , paReadOnly, paValueEditable -{$ELSE} - // Delphi 7 or below: Nothing more. -// paSubProperties, paMultiSelect, -// paAutoUpdate, paSortList, paFullWidthName, -// paVolatileSubProperties, paVCL, paNotNestable - -{$IFEND} - - ] -end; - - -function THashEditor2.SharedNonEmptyLibrary: Boolean; -var - HashComp: THash; - Lib, Lib2: TCryptographicLibrary; - j: integer; -begin -result := False; -Lib2 := nil; -if PropCount >= 1 then - begin - if GetComponent( 0) is THash then - HashComp := THash( GetComponent( 0)) - else - HashComp := nil; - if assigned( HashComp) then - Lib := HashComp.CryptoLibrary - else - Lib := nil; - result := assigned( Lib); - if not result then exit; - for j := 1 to PropCount - 1 do - begin - if GetComponent( j) is THash then - HashComp := THash( GetComponent( 0)) - else - HashComp := nil; - if assigned( HashComp) then - Lib2 := HashComp.CryptoLibrary - else - Lib := nil; - result := Lib = Lib2; - if not result then break - end - end -end; - - - - -function THashEditor2.GetEditValue2( out Value: string): Boolean; -begin -result := GetEditValue( Value); -if not result then exit; -result := SharedNonEmptyLibrary; -if not result then - Value := DS_MixedLibraries -end; - - - -procedure THashEditor2.GetValues( Proc: TGetStrProc); -var - HashComp: THash; - Lib: TCryptographicLibrary; - j: integer; - HashChoices: IInterfaceList; - Hash: IHashDsc; -begin -if (PropCount >= 1) and (GetComponent( 0) is THash) then - HashComp := THash( GetComponent( 0)) - else - HashComp := nil; -if assigned( HashComp) then - Lib := HashComp.CryptoLibrary - else - Lib := nil; -if not assigned( Lib) then exit; -HashChoices := Lib.GetHashChoices; -for j := 0 to HashChoices.Count - 1 do - if Supports( HashChoices[j], IHashDsc, Hash) then - Proc( Lib.ComputeHashDisplayName( Hash)) -end; - - - -procedure THashEditor2.SetValue( const Value: string); -var - HashComp: THash; - Lib: TCryptographicLibrary; - j: integer; - ProgId: string; - HashChoices: IInterfaceList; - Hash: IHashDsc; -begin -if not SharedNonEmptyLibrary then exit; -if (PropCount >= 1) and (GetComponent( 0) is THash) then - HashComp := THash( GetComponent( 0)) - else - HashComp := nil; -if assigned( HashComp) then - Lib := HashComp.CryptoLibrary - else - Lib := nil; -ProgId := ''; -HashChoices := Lib.GetHashChoices; -if assigned( Lib) then - for j := 0 to HashChoices.Count - 1 do - if Supports( HashChoices[j], IHashDsc, Hash) then - begin - if Value <> Lib.ComputeHashDisplayName( Hash) then continue; - ProgId := Hash.ProgId; - break - end; -if ProgId = '' then exit; -for j := 0 to PropCount - 1 do - begin - if GetComponent( j) is THash then - HashComp := THash( GetComponent( j)) - else - HashComp := nil; - HashComp.HashId := ProgId - end; -Modified -end; - -{ TLockBoxEditor } - -procedure TLockBoxEditor.Edit; -var - doCreate: boolean; - SelectedComponent: TComponent; -begin -doCreate := not assigned( TPLb_fmComponentAbout); -if doCreate then - TPLb_fmComponentAbout := TTPLb_fmComponentAbout.Create( nil); -try - if (PropCount >= 1) and (GetComponent( 0) is TComponent) then - SelectedComponent := TComponent( GetComponent( 0)) - else - SelectedComponent := nil; - TPLb_fmComponentAbout.UpdateAbout( SelectedComponent); - if not doCreate then - begin - TPLb_fmComponentAbout.Show; - TPLb_fmComponentAbout.BringToFront - end; - TPLb_fmComponentAbout.ShowModal -finally -if doCreate then - begin - TPLb_fmComponentAbout.Release; - TPLb_fmComponentAbout := nil - end -end end; - - - - -function TLockBoxEditor.GetAttributes: TPropertyAttributes; -begin -result := [paDialog, paReadOnly, paMultiSelect] -end; - -{ TCipherEditor } - -function TCipherEditor.GetAttributes: TPropertyAttributes; -begin -result := [ paValueList, paSortList, paMultiSelect, - paRevertable - -{$IF compilerversion >= 16} - // Delphi 2005 or above - , paReadOnly, paValueEditable -{$ELSE} - // Delphi 7 or below: Nothing more. -{$IFEND} - - ] -end; - -function TCipherEditor.GetEditValue2( out Value: string): Boolean; -begin -result := GetEditValue( Value); -if not result then exit; -result := SharedNonEmptyLibrary; -if not result then - Value := DS_MixedLibraries -end; - - -procedure TCipherEditor.GetValues( Proc: TGetStrProc); -var - CodecComp: TCodec; - Lib: TCryptographicLibrary; - j: integer; - CipherChoices: IInterfaceList; - CipherChoice: ICipherChoice; - CipherDisplayName: string; - isBlockCipher: boolean; - StreamCipherId: string; - BlockCipherId: string; -begin -if (PropCount >= 1) and (GetComponent( 0) is TCodec) then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; -if assigned( CodecComp) then - Lib := CodecComp.CryptoLibrary - else - Lib := nil; -if not assigned( Lib) then exit; -CipherChoices := Lib.GetCipherChoices; -for j := 0 to CipherChoices.Count - 1 do - if Supports( CipherChoices[j], ICipherChoice, CipherChoice) then - begin - CipherChoice.GetChoiceParams( - CipherDisplayName, isBlockCipher, StreamCipherId, BlockCipherId); - Proc( CipherDisplayName) - end -end; - - -procedure TCipherEditor.SetValue( const Value: string); -var - CodecComp: TCodec; - Lib: TCryptographicLibrary; - j: integer; - ProgId: string; - CipherChoices: IInterfaceList; - CipherChoice: ICipherChoice; - CipherDisplayName: string; - isBlockCipher: boolean; - StreamCipherId: string; - BlockCipherId: string; - Found: boolean; -begin -if not SharedNonEmptyLibrary then exit; -if (PropCount >= 1) and (GetComponent( 0) is TCodec) then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; -if assigned( CodecComp) then - Lib := CodecComp.CryptoLibrary - else - Lib := nil; -ProgId := ''; -CipherChoices := Lib.GetCipherChoices; -Found := False; -if assigned( Lib) then - for j := 0 to CipherChoices.Count - 1 do - if Supports( CipherChoices[j], ICipherChoice, CipherChoice) then - begin - CipherChoice.GetChoiceParams( - CipherDisplayName, isBlockCipher, StreamCipherId, BlockCipherId); - if Value <> CipherDisplayName then continue; - Found := True; - break - end; -if not Found then exit; -for j := 0 to PropCount - 1 do - begin - if GetComponent( j) is TCodec then - CodecComp := TCodec( GetComponent( j)) - else - CodecComp := nil; - CodecComp.StreamCipherId := StreamCipherId; - CodecComp.BlockCipherId := BlockCipherId - end; -Modified -end; - - - -function TCipherEditor.SharedNonEmptyLibrary: Boolean; -var - CodecComp: TCodec; - Lib, Lib2: TCryptographicLibrary; - j: integer; -begin -result := False; -Lib2 := nil; -if PropCount >= 1 then - begin - if GetComponent( 0) is TCodec then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; - if assigned( CodecComp) then - Lib := CodecComp.CryptoLibrary - else - Lib := nil; - result := assigned( Lib); - if not result then exit; - for j := 1 to PropCount - 1 do - begin - if GetComponent( j) is TCodec then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; - if assigned( CodecComp) then - Lib2 := CodecComp.CryptoLibrary - else - Lib := nil; - result := Lib = Lib2; - if not result then break - end - end -end; - -{ TChainEditor } - -procedure TChainEditor.GetValues( Proc: TGetStrProc); -var - CodecComp: TCodec; - Lib: TCryptographicLibrary; - j: integer; - ChainChoices: IInterfaceList; - ChainChoice: IBlockChainingModel; -begin -if (PropCount >= 1) and (GetComponent( 0) is TCodec) then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; -if assigned( CodecComp) then - Lib := CodecComp.CryptoLibrary - else - Lib := nil; -if not assigned( Lib) then exit; -ChainChoices := Lib.GetChainChoices; -for j := 0 to ChainChoices.Count - 1 do - if Supports( ChainChoices[j], IBlockChainingModel, ChainChoice) then - Proc( Lib.ComputeChainDisplayName( ChainChoice)) -end; - - - - -procedure TChainEditor.SetValue( const Value: string); -var - CodecComp: TCodec; - Lib: TCryptographicLibrary; - j: integer; - ChainChoices: IInterfaceList; - ChainChoice: IBlockChainingModel; - Found: boolean; -begin -if not SharedNonEmptyLibrary then exit; -if (PropCount >= 1) and (GetComponent( 0) is TCodec) then - CodecComp := TCodec( GetComponent( 0)) - else - CodecComp := nil; -if assigned( CodecComp) then - Lib := CodecComp.CryptoLibrary - else - Lib := nil; -ChainChoices := Lib.GetChainChoices; -Found := False; -if assigned( Lib) then - for j := 0 to ChainChoices.Count - 1 do - if Supports( ChainChoices[j], IBlockChainingModel, ChainChoice) then - begin - if Value <> Lib.ComputeChainDisplayName( ChainChoice) then continue; - Found := True; - break - end; -if not Found then exit; -for j := 0 to PropCount - 1 do - begin - if GetComponent( j) is TCodec then - CodecComp := TCodec( GetComponent( j)) - else - CodecComp := nil; - CodecComp.ChainModeId := ChainChoice.ProgId - end; -Modified -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit TPLB3.ComponentEditors; +interface + + +procedure Register; + +implementation + + + + + + + + + + + +uses Classes, TypInfo, DesignIntf, DesignEditors, VCLEditors, SysUtils, + TPLB3.Hash, TPLB3.CryptographicLibrary, TPLB3.ComponentAbout, + TPLB3.BaseNonVisualComponent, TPLB3.HashDsc, TPLB3.Codec, + TPLB3.BlockCipher, TPLB3.Signatory, TPLB3.I18n; + +type +TLockBoxEditor = class( TStringProperty) + public + function GetAttributes: TPropertyAttributes; override; + procedure Edit; override; + end; + + +THashEditor2 = class( TStringProperty, IProperty) + protected + function GetEditValue2( out Value: string): Boolean; virtual; + function IProperty.GetEditValue = GetEditValue2; + function SharedNonEmptyLibrary: Boolean; + + public + function GetAttributes: TPropertyAttributes; override; + procedure GetValues(Proc: TGetStrProc); override; + procedure SetValue( const Value: string); override; + end; + +TCipherEditor = class( TStringProperty, IProperty) + protected + function GetEditValue2( out Value: string): Boolean; virtual; + function IProperty.GetEditValue = GetEditValue2; + function SharedNonEmptyLibrary: Boolean; + + public + function GetAttributes: TPropertyAttributes; override; + procedure GetValues(Proc: TGetStrProc); override; + procedure SetValue( const Value: string); override; + end; + +TChainEditor = class( TCipherEditor) + public + procedure GetValues(Proc: TGetStrProc); override; + procedure SetValue( const Value: string); override; + end; + + +procedure Register; +begin +RegisterPropertyEditor( TypeInfo( string), TTPLb_BaseNonVisualComponent, 'About', TLockBoxEditor); +RegisterPropertyEditor( TypeInfo( string), THash, 'Hash', THashEditor2); +RegisterPropertyEditor( TypeInfo( string), TCodec, 'Cipher', TCipherEditor); +RegisterPropertyEditor( TypeInfo( string), TCodec, 'ChainMode', TChainEditor) +end; + + + + +{ THashEditor2 } + +function THashEditor2.GetAttributes: TPropertyAttributes; +begin +result := [ paValueList, paSortList, paMultiSelect, + paRevertable + +{$IF compilerversion >= 16} + // Delphi 2005 or above + , paReadOnly, paValueEditable +{$ELSE} + // Delphi 7 or below: Nothing more. +// paSubProperties, paMultiSelect, +// paAutoUpdate, paSortList, paFullWidthName, +// paVolatileSubProperties, paVCL, paNotNestable + +{$IFEND} + + ] +end; + + +function THashEditor2.SharedNonEmptyLibrary: Boolean; +var + HashComp: THash; + Lib, Lib2: TCryptographicLibrary; + j: integer; +begin +result := False; +Lib2 := nil; +if PropCount >= 1 then + begin + if GetComponent( 0) is THash then + HashComp := THash( GetComponent( 0)) + else + HashComp := nil; + if assigned( HashComp) then + Lib := HashComp.CryptoLibrary + else + Lib := nil; + result := assigned( Lib); + if not result then exit; + for j := 1 to PropCount - 1 do + begin + if GetComponent( j) is THash then + HashComp := THash( GetComponent( 0)) + else + HashComp := nil; + if assigned( HashComp) then + Lib2 := HashComp.CryptoLibrary + else + Lib := nil; + result := Lib = Lib2; + if not result then break + end + end +end; + + + + +function THashEditor2.GetEditValue2( out Value: string): Boolean; +begin +result := GetEditValue( Value); +if not result then exit; +result := SharedNonEmptyLibrary; +if not result then + Value := DS_MixedLibraries +end; + + + +procedure THashEditor2.GetValues( Proc: TGetStrProc); +var + HashComp: THash; + Lib: TCryptographicLibrary; + j: integer; + HashChoices: IInterfaceList; + Hash: IHashDsc; +begin +if (PropCount >= 1) and (GetComponent( 0) is THash) then + HashComp := THash( GetComponent( 0)) + else + HashComp := nil; +if assigned( HashComp) then + Lib := HashComp.CryptoLibrary + else + Lib := nil; +if not assigned( Lib) then exit; +HashChoices := Lib.GetHashChoices; +for j := 0 to HashChoices.Count - 1 do + if Supports( HashChoices[j], IHashDsc, Hash) then + Proc( Lib.ComputeHashDisplayName( Hash)) +end; + + + +procedure THashEditor2.SetValue( const Value: string); +var + HashComp: THash; + Lib: TCryptographicLibrary; + j: integer; + ProgId: string; + HashChoices: IInterfaceList; + Hash: IHashDsc; +begin +if not SharedNonEmptyLibrary then exit; +if (PropCount >= 1) and (GetComponent( 0) is THash) then + HashComp := THash( GetComponent( 0)) + else + HashComp := nil; +if assigned( HashComp) then + Lib := HashComp.CryptoLibrary + else + Lib := nil; +ProgId := ''; +HashChoices := Lib.GetHashChoices; +if assigned( Lib) then + for j := 0 to HashChoices.Count - 1 do + if Supports( HashChoices[j], IHashDsc, Hash) then + begin + if Value <> Lib.ComputeHashDisplayName( Hash) then continue; + ProgId := Hash.ProgId; + break + end; +if ProgId = '' then exit; +for j := 0 to PropCount - 1 do + begin + if GetComponent( j) is THash then + HashComp := THash( GetComponent( j)) + else + HashComp := nil; + HashComp.HashId := ProgId + end; +Modified +end; + +{ TLockBoxEditor } + +procedure TLockBoxEditor.Edit; +var + doCreate: boolean; + SelectedComponent: TComponent; +begin +doCreate := not assigned( TPLb_fmComponentAbout); +if doCreate then + TPLb_fmComponentAbout := TTPLb_fmComponentAbout.Create( nil); +try + if (PropCount >= 1) and (GetComponent( 0) is TComponent) then + SelectedComponent := TComponent( GetComponent( 0)) + else + SelectedComponent := nil; + TPLb_fmComponentAbout.UpdateAbout( SelectedComponent); + if not doCreate then + begin + TPLb_fmComponentAbout.Show; + TPLb_fmComponentAbout.BringToFront + end; + TPLb_fmComponentAbout.ShowModal +finally +if doCreate then + begin + TPLb_fmComponentAbout.Release; + TPLb_fmComponentAbout := nil + end +end end; + + + + +function TLockBoxEditor.GetAttributes: TPropertyAttributes; +begin +result := [paDialog, paReadOnly, paMultiSelect] +end; + +{ TCipherEditor } + +function TCipherEditor.GetAttributes: TPropertyAttributes; +begin +result := [ paValueList, paSortList, paMultiSelect, + paRevertable + +{$IF compilerversion >= 16} + // Delphi 2005 or above + , paReadOnly, paValueEditable +{$ELSE} + // Delphi 7 or below: Nothing more. +{$IFEND} + + ] +end; + +function TCipherEditor.GetEditValue2( out Value: string): Boolean; +begin +result := GetEditValue( Value); +if not result then exit; +result := SharedNonEmptyLibrary; +if not result then + Value := DS_MixedLibraries +end; + + +procedure TCipherEditor.GetValues( Proc: TGetStrProc); +var + CodecComp: TCodec; + Lib: TCryptographicLibrary; + j: integer; + CipherChoices: IInterfaceList; + CipherChoice: ICipherChoice; + CipherDisplayName: string; + isBlockCipher: boolean; + StreamCipherId: string; + BlockCipherId: string; +begin +if (PropCount >= 1) and (GetComponent( 0) is TCodec) then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; +if assigned( CodecComp) then + Lib := CodecComp.CryptoLibrary + else + Lib := nil; +if not assigned( Lib) then exit; +CipherChoices := Lib.GetCipherChoices; +for j := 0 to CipherChoices.Count - 1 do + if Supports( CipherChoices[j], ICipherChoice, CipherChoice) then + begin + CipherChoice.GetChoiceParams( + CipherDisplayName, isBlockCipher, StreamCipherId, BlockCipherId); + Proc( CipherDisplayName) + end +end; + + +procedure TCipherEditor.SetValue( const Value: string); +var + CodecComp: TCodec; + Lib: TCryptographicLibrary; + j: integer; + ProgId: string; + CipherChoices: IInterfaceList; + CipherChoice: ICipherChoice; + CipherDisplayName: string; + isBlockCipher: boolean; + StreamCipherId: string; + BlockCipherId: string; + Found: boolean; +begin +if not SharedNonEmptyLibrary then exit; +if (PropCount >= 1) and (GetComponent( 0) is TCodec) then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; +if assigned( CodecComp) then + Lib := CodecComp.CryptoLibrary + else + Lib := nil; +ProgId := ''; +CipherChoices := Lib.GetCipherChoices; +Found := False; +if assigned( Lib) then + for j := 0 to CipherChoices.Count - 1 do + if Supports( CipherChoices[j], ICipherChoice, CipherChoice) then + begin + CipherChoice.GetChoiceParams( + CipherDisplayName, isBlockCipher, StreamCipherId, BlockCipherId); + if Value <> CipherDisplayName then continue; + Found := True; + break + end; +if not Found then exit; +for j := 0 to PropCount - 1 do + begin + if GetComponent( j) is TCodec then + CodecComp := TCodec( GetComponent( j)) + else + CodecComp := nil; + CodecComp.StreamCipherId := StreamCipherId; + CodecComp.BlockCipherId := BlockCipherId + end; +Modified +end; + + + +function TCipherEditor.SharedNonEmptyLibrary: Boolean; +var + CodecComp: TCodec; + Lib, Lib2: TCryptographicLibrary; + j: integer; +begin +result := False; +Lib2 := nil; +if PropCount >= 1 then + begin + if GetComponent( 0) is TCodec then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; + if assigned( CodecComp) then + Lib := CodecComp.CryptoLibrary + else + Lib := nil; + result := assigned( Lib); + if not result then exit; + for j := 1 to PropCount - 1 do + begin + if GetComponent( j) is TCodec then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; + if assigned( CodecComp) then + Lib2 := CodecComp.CryptoLibrary + else + Lib := nil; + result := Lib = Lib2; + if not result then break + end + end +end; + +{ TChainEditor } + +procedure TChainEditor.GetValues( Proc: TGetStrProc); +var + CodecComp: TCodec; + Lib: TCryptographicLibrary; + j: integer; + ChainChoices: IInterfaceList; + ChainChoice: IBlockChainingModel; +begin +if (PropCount >= 1) and (GetComponent( 0) is TCodec) then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; +if assigned( CodecComp) then + Lib := CodecComp.CryptoLibrary + else + Lib := nil; +if not assigned( Lib) then exit; +ChainChoices := Lib.GetChainChoices; +for j := 0 to ChainChoices.Count - 1 do + if Supports( ChainChoices[j], IBlockChainingModel, ChainChoice) then + Proc( Lib.ComputeChainDisplayName( ChainChoice)) +end; + + + + +procedure TChainEditor.SetValue( const Value: string); +var + CodecComp: TCodec; + Lib: TCryptographicLibrary; + j: integer; + ChainChoices: IInterfaceList; + ChainChoice: IBlockChainingModel; + Found: boolean; +begin +if not SharedNonEmptyLibrary then exit; +if (PropCount >= 1) and (GetComponent( 0) is TCodec) then + CodecComp := TCodec( GetComponent( 0)) + else + CodecComp := nil; +if assigned( CodecComp) then + Lib := CodecComp.CryptoLibrary + else + Lib := nil; +ChainChoices := Lib.GetChainChoices; +Found := False; +if assigned( Lib) then + for j := 0 to ChainChoices.Count - 1 do + if Supports( ChainChoices[j], IBlockChainingModel, ChainChoice) then + begin + if Value <> Lib.ComputeChainDisplayName( ChainChoice) then continue; + Found := True; + break + end; +if not Found then exit; +for j := 0 to PropCount - 1 do + begin + if GetComponent( j) is TCodec then + CodecComp := TCodec( GetComponent( j)) + else + CodecComp := nil; + CodecComp.ChainModeId := ChainChoice.ProgId + end; +Modified +end; + +end. diff --git a/design/TPLB3.ComponentRegistration.pas b/LockBox3/design/TPLB3.ComponentRegistration.pas similarity index 97% rename from design/TPLB3.ComponentRegistration.pas rename to LockBox3/design/TPLB3.ComponentRegistration.pas index ab61ea1..1a1299a 100644 --- a/design/TPLB3.ComponentRegistration.pas +++ b/LockBox3/design/TPLB3.ComponentRegistration.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,43 +12,43 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit TPLB3.ComponentRegistration; -interface - -procedure Register; - -implementation - - - - -{$R '..\..\design\dclTP_LockBox3.dcr'} - - -uses Classes, TPLB3.Hash, TPLB3.CryptographicLibrary, TPLB3.Codec, - TPLB3.Signatory, TPLB3.OpenSSL; - -procedure Register; -begin -RegisterComponents( 'LockBox', [THash, TCodec, TCryptographicLibrary, - TSignatory, TOpenSSL_Signatory, TOpenSSL_Codec]) -end; - - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit TPLB3.ComponentRegistration; +interface + +procedure Register; + +implementation + + + + +{$R '..\..\design\dclTP_LockBox3.dcr'} + + +uses Classes, TPLB3.Hash, TPLB3.CryptographicLibrary, TPLB3.Codec, + TPLB3.Signatory, TPLB3.OpenSSL; + +procedure Register; +begin +RegisterComponents( 'LockBox', [THash, TCodec, TCryptographicLibrary, + TSignatory, TOpenSSL_Signatory, TOpenSSL_Codec]) +end; + + +end. diff --git a/design/TPLB3.InfoUtils.pas b/LockBox3/design/TPLB3.InfoUtils.pas similarity index 96% rename from design/TPLB3.InfoUtils.pas rename to LockBox3/design/TPLB3.InfoUtils.pas index b0c8f60..b8e1a11 100644 --- a/design/TPLB3.InfoUtils.pas +++ b/LockBox3/design/TPLB3.InfoUtils.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,116 +12,116 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit TPLB3.InfoUtils; -interface -uses windows; - -function GetLibraryInfo( - ModuleHandle: HMODULE; var LibName: string; var FileVersion: string): boolean; -// Hint: use HINSTANCE as the actual parameter to get the current package. - - -function Get_TP_LockBox3_Info( // The Run-time package. - var LibName: string; var FileVersion: string): boolean; - - - -function Get_dclTP_LockBox3_Info( // This, the Design-time package. - var LibName: string; var FileVersion: string): boolean; -// Assumes that this unit is part of the dclTP_LockBox3 unit. - - - -implementation - - - - - - - - - - - - - - - - -uses SysUtils, TPLB3.BinaryUtils; - -function GetLibraryInfo( - ModuleHandle: HMODULE; var LibName: string; var FileVersion: string): boolean; -var - iLibSize, iValueSize: DWord; - Buf: ansiString; - Ok: boolean; - fvip: pointer; - MajorV, MinorV, ReleaseV, BuildV: integer; -begin -LibName := GetModuleName( ModuleHandle); -result := LibName <> ''; -if result then - iLibSize := GetFileVersionInfoSize( PChar( LibName), iLibSize) - else - iLibSize := 0; -Ok := iLibSize > 0; -if Ok then - begin - SetLength( Buf, iLibSize); - Ok := GetFileVersionInfo( PChar( LibName), 0, iLibSize, PAnsiChar( Buf)) and - VerQueryValue( PAnsiChar( Buf), '\', fvip, iValueSize) and - (iValueSize >= SizeOf( TVSFixedFileInfo)) - end; -if Ok then - begin - MajorV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); - MinorV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); - ReleaseV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionLS); - BuildV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionLS) - end - else - begin - MajorV := 0; - MinorV := 0; - ReleaseV := 0; - BuildV := 0 - end; -FileVersion := Format( '%d.%d.%d.%d', [MajorV, MinorV, ReleaseV, BuildV]); -if result then - LibName := ExtractFileName( LibName) -end; - - - -function Get_dclTP_LockBox3_Info( - var LibName: string; var FileVersion: string): boolean; -begin -result := GetLibraryInfo( HINSTANCE, LibName, FileVersion) -end; - - -function Get_TP_LockBox3_Info( // The Run-time package. - var LibName: string; var FileVersion: string): boolean; -begin -result := GetLibraryInfo( Get_TP_LockBox3_HINSTANCE, LibName, FileVersion) -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit TPLB3.InfoUtils; +interface +uses windows; + +function GetLibraryInfo( + ModuleHandle: HMODULE; var LibName: string; var FileVersion: string): boolean; +// Hint: use HINSTANCE as the actual parameter to get the current package. + + +function Get_TP_LockBox3_Info( // The Run-time package. + var LibName: string; var FileVersion: string): boolean; + + + +function Get_dclTP_LockBox3_Info( // This, the Design-time package. + var LibName: string; var FileVersion: string): boolean; +// Assumes that this unit is part of the dclTP_LockBox3 unit. + + + +implementation + + + + + + + + + + + + + + + + +uses SysUtils, TPLB3.BinaryUtils; + +function GetLibraryInfo( + ModuleHandle: HMODULE; var LibName: string; var FileVersion: string): boolean; +var + iLibSize, iValueSize: DWord; + Buf: ansiString; + Ok: boolean; + fvip: pointer; + MajorV, MinorV, ReleaseV, BuildV: integer; +begin +LibName := GetModuleName( ModuleHandle); +result := LibName <> ''; +if result then + iLibSize := GetFileVersionInfoSize( PChar( LibName), iLibSize) + else + iLibSize := 0; +Ok := iLibSize > 0; +if Ok then + begin + SetLength( Buf, iLibSize); + Ok := GetFileVersionInfo( PChar( LibName), 0, iLibSize, PAnsiChar( Buf)) and + VerQueryValue( PAnsiChar( Buf), '\', fvip, iValueSize) and + (iValueSize >= SizeOf( TVSFixedFileInfo)) + end; +if Ok then + begin + MajorV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); + MinorV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); + ReleaseV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionLS); + BuildV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionLS) + end + else + begin + MajorV := 0; + MinorV := 0; + ReleaseV := 0; + BuildV := 0 + end; +FileVersion := Format( '%d.%d.%d.%d', [MajorV, MinorV, ReleaseV, BuildV]); +if result then + LibName := ExtractFileName( LibName) +end; + + + +function Get_dclTP_LockBox3_Info( + var LibName: string; var FileVersion: string): boolean; +begin +result := GetLibraryInfo( HINSTANCE, LibName, FileVersion) +end; + + +function Get_TP_LockBox3_Info( // The Run-time package. + var LibName: string; var FileVersion: string): boolean; +begin +result := GetLibraryInfo( Get_TP_LockBox3_HINSTANCE, LibName, FileVersion) +end; + +end. diff --git a/design/dclTP_LockBox3.dcr b/LockBox3/design/dclTP_LockBox3.dcr similarity index 100% rename from design/dclTP_LockBox3.dcr rename to LockBox3/design/dclTP_LockBox3.dcr diff --git a/design/forms/d2005/uTPLb_ComponentAbout.dfm b/LockBox3/design/forms/d2005/uTPLb_ComponentAbout.dfm similarity index 98% rename from design/forms/d2005/uTPLb_ComponentAbout.dfm rename to LockBox3/design/forms/d2005/uTPLb_ComponentAbout.dfm index 6ce39b4..f9b6f05 100644 --- a/design/forms/d2005/uTPLb_ComponentAbout.dfm +++ b/LockBox3/design/forms/d2005/uTPLb_ComponentAbout.dfm @@ -1,3185 +1,3185 @@ -object TPLb_fmComponentAbout: TTPLb_fmComponentAbout - Left = 0 - Top = 0 - Caption = 'Component About' - ClientHeight = 442 - ClientWidth = 640 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - GlassFrame.Enabled = True - GlassFrame.SheetOfGlass = True - OldCreateOrder = False - OnCreate = FormCreate - DesignSize = ( - 640 - 442) - PixelsPerInch = 96 - TextHeight = 13 - object pnlAbout: TPanel - Left = 0 - Top = 0 - Width = 641 - Height = 410 - Anchors = [akLeft, akTop, akRight, akBottom] - Caption = 'About Box to be developed!' - TabOrder = 0 - object pgAboutContent: TPageControl - Left = 1 - Top = 1 - Width = 639 - Height = 408 - ActivePage = tsMain - Align = alClient - TabOrder = 0 - object tsMain: TTabSheet - Caption = 'Main' - DesignSize = ( - 631 - 380) - object Image1: TImage - Left = 0 - Top = 0 - Width = 225 - Height = 329 - Picture.Data = { - 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 - 480000FFE1004045786966000049492A0008000000010069870400010000001A - 000000000000000100869202000B0000002C000000000000004170706C654D61 - 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 - 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 - 50504C0000000049454320735247420000000000000000000000000000F6D600 - 0100000000D32D48502020000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000116370727400 - 0001500000003364657363000001840000007377747074000001F80000001462 - 6B70740000020C000000147258595A00000220000000146758595A0000023400 - 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 - 0002BC0000007976756564000003380000008676696577000003C0000000246C - 756D69000003E4000000146D656173000003F800000024746563680000041C00 - 00000C72545243000004280000080C67545243000004280000080C6254524300 - 0004280000080C7465787400000000436F707972696768742028632920313939 - 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 - 00000000000019735247422049454336313936362D322E312039393132303300 - 0000000000000000000019735247422049454336313936362D322E3120393931 - 3230330000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000058595A20000000000000F3510001000000 - 0116CC58595A200000000000000000000000000000000058595A200000000000 - 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 - 595A2000000000000024A000000F840000B6CF64657363000000000000000549 - 4543200000000000000000000000054945432000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000064657363000000000000001F73 - 524742204945432036313936362D322E31207352474220393931323033000000 - 00000000000000001F73524742204945432036313936362D322E312073524742 - 2039393132303300000000000000000000000000000000000000000000000000 - 00000000000000000000000000000064657363000000000000002C5265666572 - 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 - 36362D322E3100000000000000000000002C5265666572656E63652056696577 - 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 - 0000000000000000000000000000000000000000000000766965770000000000 - 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 - 000000004C09560050000000571FE76D65617300000000000000010000000000 - 00000000000000000000000000028F0000000273696720000000004352542063 - 757276000000000000040000000005000A000F00140019001E00230028002D00 - 320037003B00400045004A004F00540059005E00630068006D00720077007C00 - 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 - D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 - 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 - 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 - 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 - B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 - 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 - 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 - 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 - 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 - 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 - 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 - 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A - F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C - 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E - 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F - CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 - AA11C911E81207122612451264128412A312C312E31303132313431363138313 - A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 - BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 - F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A - 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C - CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F - 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 - 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 - 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 - 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B - 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E - 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 - F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 - 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 - 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D - 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 - 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 - 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 - A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E - 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 - C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 - 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C - 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 - A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 - E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C - 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 - F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 - B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D - A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 - BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 - FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 - 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 - 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D - D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 - C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB - E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 - 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA - B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 - 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA - 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 - 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA - 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 - DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB - 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 - 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD - 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 - 0202020202040303020305040505050404040506070605050706040406090607 - 08080808080506090A09080A07080808FFDB0043010101010202020402020408 - 0504050808080808080808080808080808080808080808080808080808080808 - 080808080808080808080808080808080808080808FFC0001108014A00EA0301 - 2200021101031101FFC4001F0000010501010101010100000000000000000102 - 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 - 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 - 627282090A161718191A25262728292A3435363738393A434445464748494A53 - 5455565758595A636465666768696A737475767778797A838485868788898A92 - 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 - C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA - FFC4001F0100030101010101010101010000000000000102030405060708090A - 0BFFC400B5110002010204040304070504040001027700010203110405213106 - 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 - F11718191A262728292A35363738393A434445464748494A535455565758595A - 636465666768696A737475767778797A82838485868788898A92939495969798 - 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 - D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 - 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F - B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 - 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C - D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 - C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 - DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 - 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C - 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D - B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D - FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB - 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 - 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 - ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB - AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F - 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 - EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 - DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F - 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 - 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 - C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB - 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 - 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 - A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 - 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA - 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 - D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 - 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 - 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 - 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D - 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D - 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E - BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 - 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 - B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 - 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF - 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF - B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 - 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 - 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 - 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 - 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E - DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 - EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 - 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 - C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 - 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 - 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 - 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 - 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 - 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 - 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 - E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE - AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 - 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 - 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC - AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC - 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 - EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 - 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE - 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 - 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A - 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C - FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 - 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E - 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 - 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC - 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 - 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A - BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF - FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB - 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 - 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 - 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 - DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 - 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 - 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 - 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A - BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F - 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B - E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C - 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 - 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A - 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 - 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD - 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 - A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 - C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D - C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC - B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE - 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 - B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 - 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 - 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 - 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 - B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 - 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 - 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 - 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A - BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D - 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 - 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 - 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D - FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 - 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 - 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 - BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 - 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 - B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 - 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 - D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E - F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F - B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B - 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 - E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A - BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 - DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 - D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF - C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF - 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 - D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 - 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 - 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D - B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 - 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB - E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 - C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 - 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 - ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 - E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 - 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 - 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 - D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 - 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 - B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 - 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E - C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A - F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 - 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 - 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C - D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 - C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 - 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 - 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 - 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 - B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 - EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F - D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 - 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 - 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 - F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 - 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 - 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD - B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 - 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 - 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 - CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 - 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 - F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 - 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F - 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 - 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A - FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A - EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D - 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F - 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B - E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 - 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD - FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA - E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 - F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 - 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 - 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 - 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 - 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 - FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 - 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB - 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 - F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 - CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 - 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 - 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 - BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 - DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 - ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 - 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 - 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF - 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA - EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 - 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 - 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 - 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 - FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB - 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 - D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB - 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED - 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 - 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD - 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 - B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 - 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 - 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C - 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 - A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC - 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 - 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC - D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 - 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C - 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 - FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B - CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 - 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E - 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 - B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 - AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 - C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 - FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 - 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 - 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE - 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 - 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 - 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 - F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 - 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC - 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 - 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD - E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 - 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B - E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA - DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 - 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 - DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 - 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 - D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 - FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B - F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 - E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF - 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B - 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 - 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 - 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 - 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 - 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F - C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 - B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 - 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 - 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E - 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC - FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F - A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B - 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 - E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F - 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C - F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C - 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE - 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 - 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D - D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 - 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 - 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 - 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA - E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 - F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF - 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 - E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F - 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 - 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 - BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B - C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 - B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 - 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F - 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F - C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 - 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 - 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 - 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 - 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F - ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C - C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B - F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B - 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF - AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA - 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 - 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 - EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 - 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 - 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D - 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C - C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 - EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 - 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 - BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 - 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF - 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 - 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 - 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 - 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 - 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 - 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 - 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E - CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 - D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 - 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 - 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F - B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB - 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F - 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 - 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B - 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 - 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF - 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B - E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B - 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA - 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 - DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 - 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A - F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC - 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D - 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 - DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF - 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED - 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B - F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 - DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 - D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B - F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 - 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 - 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E - 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E - 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B - E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F - 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 - 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 - C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 - 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD - 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE - 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 - F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E - 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC - 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 - D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE - BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C - 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 - D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E - 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 - 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 - A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC - E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E - 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 - B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 - 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 - 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B - B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB - FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 - C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA - D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C - 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED - C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 - 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 - 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B - 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 - 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 - 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 - 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F - 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 - 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD - 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A - CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC - 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 - 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF - C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E - 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 - F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF - D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 - 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 - C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC - 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 - 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF - 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 - 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE - DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 - AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 - C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 - FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF - 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F - 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 - A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F - E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 - 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 - F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 - C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE - 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 - 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 - 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 - C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E - 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 - 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA - AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 - E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 - 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD - 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 - FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 - 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 - E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 - 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 - E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 - 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB - 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED - 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C - DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 - DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 - 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D - FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F - 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 - 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 - 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 - FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 - E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF - E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC - 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 - A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF - BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 - C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 - D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 - 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 - 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 - 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F - F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 - B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 - BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 - FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 - 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF - 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED - CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 - 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF - 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D - 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A - BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 - 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 - 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 - 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 - F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B - 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 - E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C - 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF - B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 - A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 - 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 - 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 - 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A - 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A - CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D - 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F - 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 - FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C - 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 - E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 - EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF - 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 - DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 - DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 - FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC - 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 - B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 - 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 - FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 - 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 - 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D - BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 - 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C - 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA - B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 - 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA - 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE - D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 - C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 - DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC - F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 - 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD - 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 - 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD - 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA - C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE - CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 - 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB - DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA - BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 - 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A - E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 - 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 - 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 - 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 - 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F - FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 - 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D - FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D - C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F - 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED - 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 - BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 - AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 - E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD - D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 - 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 - 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB - 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 - 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 - CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 - 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B - 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E - 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 - 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 - F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C - F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 - E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 - 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B - 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 - D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 - C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD - EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF - 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 - F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F - 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 - 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 - 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 - FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 - DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 - 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E - D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 - 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 - F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F - 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 - 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E - 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 - A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 - E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 - 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 - 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 - 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 - 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E - 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 - 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD - B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 - A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C - 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 - E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E - 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F - ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E - F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD - 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B - C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 - A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 - A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 - 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 - 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 - 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A - 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E - D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D - 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA - C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF - 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E - DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A - 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 - 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A - 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB - 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA - 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF - 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F - 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 - FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF - C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C - 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 - 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 - 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 - DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB - D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 - ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 - 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 - BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 - 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF - 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 - 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 - 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 - 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 - 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 - D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D - 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF - ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B - 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 - EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D - C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 - 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F - B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 - 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D - A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 - 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 - 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 - D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 - 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 - A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 - D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 - D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 - DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B - 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D - 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 - FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F - 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 - 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B - 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E - AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 - C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 - F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 - 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB - C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 - 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F - C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 - 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA - 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F - B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C - AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 - 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F - BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 - A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD - 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA - 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B - 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE - 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 - 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 - D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 - FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 - 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA - 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 - 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 - 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 - 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD - 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF - 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D - F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA - AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 - 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 - 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 - 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 - 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE - EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 - 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 - 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 - 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 - BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C - C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 - E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 - 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E - 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 - 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA - 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 - 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C - 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 - 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 - BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 - DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E - 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 - 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 - 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 - 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 - 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 - 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 - 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 - C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 - 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 - 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 - 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 - 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 - 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 - F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 - 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 - 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 - B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 - 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB - 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF - 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F - CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 - F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 - 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC - 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 - 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 - 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 - DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 - 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC - 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB - 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 - C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 - 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 - A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 - 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 - 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 - 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 - 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 - BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A - EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 - D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 - 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 - EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C - 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 - 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 - 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 - 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 - F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D - 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C - 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 - 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F - 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 - DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF - 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B - 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC - B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 - F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 - 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB - 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C - D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 - CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E - 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 - 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A - AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 - AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF - 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 - 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 - 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E - 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 - BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 - F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E - 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 - 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B - 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 - 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 - 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 - 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED - 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D - 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 - F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 - 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA - 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E - 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 - F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F - B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC - 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B - 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 - 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 - 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C - 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 - 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF - 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 - AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE - F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A - 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 - 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 - 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 - AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 - B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 - CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D - 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 - 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 - 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 - D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF - 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A - 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 - DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD - A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 - 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 - E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E - 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 - A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 - F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC - CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF - 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 - D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE - AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 - EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 - 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 - 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 - 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 - 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 - 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED - 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 - A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F - 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 - C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 - 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F - E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 - F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F - D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F - AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED - 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F - B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 - 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 - 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 - DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 - F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 - 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 - 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 - 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B - 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 - C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 - 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C - 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 - 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 - 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C - BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 - B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 - F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 - 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D - F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A - F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 - 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 - F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC - 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 - 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D - DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 - 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 - F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 - 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B - 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E - D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B - 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F - 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 - 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D - 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 - BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 - 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 - CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E - 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 - B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 - B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 - C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 - 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 - 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF - 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 - 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B - 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F - 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 - 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA - 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 - D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 - B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 - 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C - BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E - 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 - D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 - BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 - DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 - B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE - 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 - 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 - D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B - 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 - 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB - F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 - 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A - CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 - C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 - 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 - D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D - 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 - CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F - 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E - 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB - 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 - B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 - BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 - 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 - 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F - 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 - D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 - FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 - 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 - 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB - E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 - 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 - F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 - D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 - 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D - 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 - 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 - FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E - A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE - 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC - 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 - 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB - 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 - B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 - 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB - B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 - 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 - 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 - 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E - 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 - 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 - FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED - 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 - 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 - 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 - F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 - 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 - 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E - 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F - 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 - FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 - 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 - 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF - 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 - 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 - EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D - 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D - F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 - 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 - 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA - 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB - 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 - 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 - F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 - F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 - F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF - F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 - 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 - B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 - DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E - CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 - 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 - AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 - 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C - 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB - CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C - 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 - 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B - 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 - AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B - 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA - 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 - C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 - 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 - 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 - 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 - 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E - 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 - D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F - 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E - 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D - 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 - 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 - 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 - 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B - EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 - 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F - C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 - 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 - 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 - B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE - 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A - 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F - 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE - 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB - 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 - B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 - 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC - D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 - 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 - 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 - AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF - 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 - 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 - D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 - 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 - 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D - 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 - 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E - 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E - DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 - 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 - B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 - B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 - E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 - F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 - A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 - 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B - 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 - 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF - 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 - 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 - BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 - 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 - F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B - A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 - 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC - BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A - F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 - 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 - 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB - CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 - A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C - 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 - 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 - CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 - 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE - 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F - 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF - 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 - F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB - 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F - 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 - AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 - CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 - ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 - 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F - 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF - 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B - 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 - E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E - 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C - 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 - 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 - 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF - E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B - 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC - 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C - 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 - 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 - C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 - 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D - 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 - 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 - F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 - AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F - 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 - 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 - 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 - DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF - 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 - 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B - FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 - 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD - 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 - C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F - C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 - 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A - FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC - 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E - 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 - BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 - E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 - C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 - E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 - FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 - 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 - 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A - 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F - 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 - 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B - 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 - 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 - D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 - EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 - ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 - E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC - 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB - E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 - 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 - 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 - FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 - B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 - FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD - ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF - 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 - BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C - D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 - BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA - B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 - BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 - 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 - 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 - A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 - 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E - FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 - B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E - 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 - 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 - 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E - D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 - 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 - 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED - AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 - BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD - 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 - 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E - 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF - B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 - E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C - CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 - 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED - 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B - B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 - A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 - 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A - B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 - FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF - F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA - 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 - FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 - 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B - B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D - 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 - 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 - 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E - 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 - BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 - 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB - 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 - C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 - C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 - EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 - BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 - 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 - F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 - C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 - BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 - F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 - F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 - 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 - 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB - 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 - 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 - F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 - 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 - 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D - EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 - 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 - 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 - 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA - D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E - F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A - E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 - B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A - A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 - 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA - 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F - F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 - AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 - 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE - 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 - 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 - 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 - C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 - FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB - 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 - 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 - CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 - 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB - D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A - 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 - 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 - 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC - C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 - D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 - F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 - 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 - BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 - 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 - 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D - 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C - 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 - 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF - B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 - 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE - 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 - 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED - 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 - F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B - B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC - E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB - 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 - 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D - BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC - D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB - 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D - D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB - 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 - F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F - 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D - 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 - F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD - E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C - 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 - 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 - A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB - E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 - 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC - 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 - DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 - 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 - 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 - FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 - 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD - 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 - E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 - 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 - 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 - AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F - 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C - 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 - 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 - C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 - C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 - E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD - 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 - D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 - 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 - F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F - 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 - 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE - 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 - C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D - 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE - 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D - 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C - D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF - AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 - 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 - 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 - C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F - 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A - CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 - 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C - 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA - B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 - 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 - 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 - 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE - BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF - 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 - 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E - 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF - 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 - A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 - DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 - FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC - 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 - DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 - D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 - 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 - 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 - 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF - C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A - FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 - 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 - 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F - DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB - B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 - 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 - 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 - 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 - B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 - 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 - BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 - 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 - FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC - D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED - 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 - FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C - 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 - B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 - AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E - 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 - 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 - 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 - FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C - 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 - F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C - EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF - 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 - 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 - 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF - 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB - 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C - 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 - 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE - FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC - AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 - 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F - 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A - 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A - 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 - F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B - 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 - 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED - E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D - AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD - E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 - 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD - 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 - BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 - B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 - 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB - F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F - 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 - DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F - D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A - F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F - 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 - 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 - F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 - A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 - 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 - EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C - D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F - F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 - D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC - 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 - 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 - CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 - 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 - C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF - 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 - 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 - C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A - 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 - 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F - 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 - B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 - E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E - 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 - B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D - F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 - 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F - 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 - 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D - 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 - 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 - 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 - 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A - 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC - BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 - 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA - 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 - D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 - FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 - DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 - B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 - B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 - 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 - 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 - 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB - D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 - BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C - D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 - 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D - F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F - 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E - 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 - F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A - 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D - 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC - 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 - FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 - 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC - 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E - EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 - 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 - 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 - 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 - CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE - 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 - D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C - 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D - C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF - BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 - 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 - 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF - 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF - 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA - 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 - 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 - 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 - D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 - 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF - 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE - BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE - ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 - C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E - 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 - FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A - F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 - FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B - 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA - 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF - 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 - 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 - 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D - ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 - C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 - 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C - 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 - 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA - D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 - F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B - 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 - 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B - C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 - DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 - 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F - 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F - EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 - 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE - D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E - BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF - 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E - D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 - 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 - 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 - EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E - 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 - DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 - B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC - C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C - FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 - 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 - EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 - DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C - 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 - D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F - ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC - FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 - 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 - 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B - 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B - DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 - 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB - EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 - F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C - 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E - E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE - 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 - F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 - AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 - 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B - AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 - D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 - 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D - 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 - BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A - F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 - F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 - B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 - E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 - 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE - B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 - 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B - 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 - 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 - FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 - 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A - 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE - 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 - 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 - BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 - 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 - D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 - FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 - 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 - 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A - BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 - EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 - B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D - DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E - E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C - 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 - 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F - CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C - 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 - B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB - 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 - F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F - 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 - CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF - 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 - 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 - 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F - C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 - CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 - 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F - 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 - 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 - 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A - 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D - F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 - BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 - E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F - 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 - F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 - 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F - 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 - 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 - 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C - F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F - 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 - F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A - D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF - DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 - C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 - 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE - 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 - AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 - CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C - 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 - 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F - C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 - 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 - 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE - 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 - 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB - D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF - 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 - 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA - 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 - 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC - 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 - 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 - B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F - 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC - D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 - 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 - ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B - D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 - ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 - 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B - E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B - 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE - 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B - E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 - 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 - B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 - 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 - 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 - CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 - 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 - D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 - 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC - 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B - 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD - 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 - B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C - F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 - 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 - 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 - 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 - D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 - 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 - AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 - AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B - A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 - 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 - A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B - 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE - B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 - BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE - BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A - B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 - 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 - 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B - 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 - 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F - 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 - 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF - 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C - 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 - FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 - 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 - 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 - 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE - 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 - 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B - 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E - F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 - 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 - 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 - 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 - 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 - A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 - 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 - 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 - 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF - 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 - FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E - E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 - 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B - D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 - 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 - 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C - 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C - 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 - F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B - 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 - E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E - 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 - 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA - 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B - C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B - 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF - 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB - DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 - 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E - 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 - E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 - D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 - ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE - 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 - C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F - 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E - 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD - D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 - C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB - 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 - 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 - EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA - BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A - B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 - 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 - 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB - 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA - CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D - 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C - 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 - 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 - 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A - 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 - 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B - F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 - 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 - 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A - 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 - A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 - C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 - B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 - 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 - AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 - C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 - B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 - 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F - 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 - B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 - 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 - 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 - DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F - 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F - 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 - E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 - BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 - BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 - 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B - D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E - F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 - 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F - 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 - C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D - F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 - 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC - 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E - CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A - 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F - 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 - 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 - 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D - E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 - 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 - D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F - 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 - A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 - B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A - 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD - B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 - B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 - AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 - 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB - 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F - 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E - 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 - 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 - ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC - EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 - B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 - 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD - 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 - 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C - E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 - 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA - B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 - 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 - C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 - 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 - 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E - 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 - 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 - AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 - 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F - 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA - DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 - 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB - 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F - 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C - E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 - 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 - A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 - 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 - C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 - 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC - 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE - EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 - 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A - 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 - 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB - C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F - D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F - C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B - 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA - F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 - 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 - 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 - 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF - E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 - 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 - F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A - 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE - 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 - BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C - 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 - 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 - 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 - A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 - 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 - 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 - 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B - 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C - 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE - 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC - 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 - C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 - D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 - 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B - F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 - 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 - 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E - 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 - 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF - A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE - 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E - 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 - D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 - 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 - DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 - F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 - 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F - 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 - 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 - 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 - 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 - EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 - E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 - A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF - F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC - EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 - 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 - 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 - C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A - D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 - EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 - 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB - 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA - B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C - 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 - 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 - 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 - D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A - FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 - D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F - E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD - BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 - FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 - 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA - 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 - D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 - 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 - C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E - 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF - DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 - 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B - B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F - 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 - B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E - 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE - EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 - 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 - FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 - CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F - 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED - FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 - 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF - B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 - 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED - 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E - 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE - 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B - 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 - D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 - F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 - 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 - F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 - 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 - 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 - A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 - 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C - D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 - 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 - 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 - 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 - B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC - 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 - 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 - 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 - A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 - 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF - C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C - C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 - B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 - 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 - 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF - 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 - ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 - 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC - 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF - 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 - 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F - 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 - FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F - 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 - 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 - A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA - 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 - A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 - 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F - 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF - 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 - C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 - 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 - F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 - F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 - E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F - 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D - A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF - B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B - 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 - 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A - D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 - 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 - C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 - 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 - C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 - 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 - 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D - 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 - 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 - 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 - BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 - 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 - F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C - 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F - C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF - A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 - D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 - 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 - C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 - EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 - C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 - 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B - FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 - 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 - BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D - 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 - 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 - 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC - D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 - 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD - 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 - 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 - E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 - AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B - AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 - B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C - 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF - CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B - C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD - 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 - DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB - F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 - 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 - AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 - B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 - B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE - BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C - 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED - 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 - BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A - F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 - EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 - 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E - F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 - AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 - C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C - 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 - 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F - ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 - E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F - 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 - 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 - EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 - ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 - 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 - 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 - EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 - 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 - BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 - 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 - 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D - 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B - 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF - 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C - 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E - 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 - 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F - B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C - 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 - 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 - 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B - BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F - 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB - 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 - 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 - 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 - EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 - 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 - 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 - EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A - 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A - 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 - E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A - B5BF6F91D5F50E66B9A5D0FFD9} - end - object lblTitle: TLabel - Left = 231 - Top = 3 - Width = 402 - Height = 62 - Anchors = [akLeft, akTop, akRight] - AutoSize = False - Caption = 'TurboPower LockBox 3' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -33 - Font.Name = 'Lucida Sans' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - Transparent = False - WordWrap = True - end - object Label1: TLabel - Left = 231 - Top = 65 - Width = 400 - Height = 137 - AutoSize = False - Caption = - 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + - 'is to provide basic cryptographic functionality, implemented nat' + - 'ively as a white box.'#13#10'Block mode ciphers include AES and Blowfi' + - 'sh, and will soon be extended to include many others. Hashes inc' + - 'lude MD5, SHA-1 and RIPEMD-160 and will soon be extended to incl' + - 'ude many others. Chaining modes include ECB, CBC, PCBC, CFB, CFB' + - '-8Bit, OFB and CTR. The source code is highly readable and under' + - 'standable. Salting is provided where it is needed, transparently' + - '. The design is very extensible. Extending the range of ciphers ' + - 'and hashes can be done cheaply, easily and quickly.' - WordWrap = True - end - object lblRunTimeVersion: TLabel - Left = 231 - Top = 208 - Width = 78 - Height = 13 - Caption = 'run-time version' - end - object lblDesignTimeVersion: TLabel - Left = 231 - Top = 224 - Width = 93 - Height = 13 - Caption = 'design-time version' - end - object lblLogoAttribution: TLabel - Left = 0 - Top = 330 - Width = 614 - Height = 47 - AutoSize = False - Caption = - 'The above photo was sourced from http://www.flickr.com/photos/ml' + - 'iu92/3146549932 and has been copied with the kind permission of ' + - 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + - ' under the Creative Commons license (http://creativecommons.org/' + - 'licenses/by-nc-sa/2.0/deed.en).' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - WordWrap = True - end - object Memo1: TMemo - Left = 231 - Top = 243 - Width = 194 - Height = 86 - Color = clInfoBk - Lines.Strings = ( - 'TPLB3 is free and open source ' - 'software. It is made available for ' - 'use and copying by an LGPL or an' - 'MPL license at your choice. ' - 'Refer to the "Statement of copying' - 'permission" tab for details.') - ReadOnly = True - TabOrder = 0 - end - end - object tsWelcome: TTabSheet - Caption = 'Welcome' - ImageIndex = 1 - object browserIntro: TWebBrowser - Left = 104 - Top = 0 - Width = 527 - Height = 380 - Align = alRight - TabOrder = 0 - ControlData = { - 4C00000078360000462700000000000000000000000000000000000000000000 - 000000004C000000000000000000000001000000E0D057007335CF11AE690800 - 2B2E126208000000000000004C0000000114020000000000C000000000000046 - 8000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000100000000000000000000000000000000000000} - end - object memoWelcomeInstructions: TMemo - Left = 0 - Top = 0 - Width = 104 - Height = 377 - Margins.Left = 0 - Margins.Right = 0 - BorderStyle = bsNone - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'The video to the ' - 'right requires an ' - 'internet connection ' - 'and Adobe Flash ' - 'Player 10 to be ' - 'installed, in order to ' - 'play.') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsProject: TTabSheet - Caption = 'Project' - ImageIndex = 2 - object Label4: TLabel - Left = 0 - Top = 3 - Width = 323 - Height = 30 - Caption = 'This product has been brought to you by ...' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -27 - Font.Name = 'Script' - Font.Style = [fsBold] - ParentFont = False - end - object lblWebsite: TLabel - Left = 3 - Top = 312 - Width = 250 - Height = 13 - Caption = 'http://sourceforge.net/projects/tplockbox/' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - end - object Memo2: TMemo - Left = 3 - Top = 32 - Width = 614 - Height = 217 - Color = clInfoBk - Lines.Strings = ( - - 'The TPLB3 product is produced under the organisational umbrella ' + - 'of the TurboPower LockBox project. This project has no ' - - 'legal incorporation. It is an informal organisation with no defi' + - 'ned membership. The TPLB3 product is owned by the ' - - 'individual contributors to its parts. The Project on SourceForge' + - ' is administered by the TurboPower SourceForge ' - 'Administrator (tpsfadmin).' - '' - - 'LockBox was originally produced and released by TurboPower Softw' + - 'are Company as a commercial product. Versions 1 and' - - '2 of the product were commericial and were released in the perio' + - 'd from 1997 to 2002. The copyright holder was' - - 'TurboPower Software Company. Version 2 source code was donated t' + - 'o the the TurboPower LockBox SourceForge project' - 'under an MPL 1.1 license, which is free and open-source license.' - '' - - 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + - 'rivative work of LockBox 2 and does not share any' - - 'common code, but the mission of the library remains the same. An' + - ' exception is the unit DCPtwofish_LB3Modified' - - 'which is a modified version of a file from David Barton'#39's DCPCry' + - 'pt package. The original unit of this was' - 'developed by David Barton.') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object lblTpsfaIntro: TStaticText - Left = 3 - Top = 255 - Width = 356 - Height = 17 - Caption = - 'The TurboPower Source Forge Administrator (tpsfa) can be contact' + - 'ed at:' - TabOrder = 1 - end - object lblTpsfaContact: TStaticText - Left = 3 - Top = 272 - Width = 335 - Height = 17 - Cursor = crHandPoint - Caption = 'http://sourceforge.net/sendmessage.php?touser=625421' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - TabOrder = 2 - OnClick = lblTpsfaContactClick - end - object lblWebLabel: TStaticText - Left = 3 - Top = 295 - Width = 177 - Height = 17 - Caption = 'TPLB3 on SourceForge is located at:' - TabOrder = 3 - end - end - object tsCopyLeft: TTabSheet - Caption = 'Statement of copying permission' - ImageIndex = 3 - DesignSize = ( - 631 - 380) - object Label7: TLabel - Left = 3 - Top = 3 - Width = 369 - Height = 13 - Caption = - 'Copyright 2009, 2010 Sean B. Durkin (except for portions marked ' + - 'otherwise)' - end - object Label8: TLabel - Left = 3 - Top = 18 - Width = 625 - Height = 26 - Caption = - 'The below copyright applies to all the source code and compiled ' + - 'binaries of the TPBL3 project, except the DCPtwofish_LB3Modified' + - ' unit which comes with its own statement of copying permission i' + - 'n its header comment.' - WordWrap = True - end - object Label9: TLabel - Left = 8 - Top = 48 - Width = 190 - Height = 13 - Caption = 'Statement of copying permission:' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object Memo3: TMemo - Left = 2 - Top = 67 - Width = 625 - Height = 246 - Anchors = [akLeft, akTop, akRight] - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [] - Lines.Strings = ( - - 'This component library is part of TurboPower LockBox 3. TurboPow' + - 'er LockBox ' - '3' - - 'is free software being offered under a dual licensing scheme: LG' + - 'PL3 or ' - 'MPL1.1.' - '' - - 'The contents of this library are subject to the Mozilla Public L' + - 'icense ' - '(MPL)' - - 'Version 1.1 (the "License"); you may not use this file except in' + - ' compliance' - 'with the License. You may obtain a copy of the License at' - 'http://www.mozilla.org/MPL/' - '' - - 'Alternatively, you may redistribute it and/or modify it under th' + - 'e terms of' - - 'the GNU Lesser General Public License (LGPL) as published by the' + - ' Free ' - 'Software' - - 'Foundation, either version 3 of the License, or (at your option)' + - ' any later' - 'version.' - '' - - 'You should have received a copy of the Lesser GNU General Public' + - ' License' - 'along with TurboPower LockBox 3. If not, see ' - '.' - '' - - 'TurboPower LockBox is distributed in the hope that it will be us' + - 'eful,' - 'but WITHOUT ANY WARRANTY; without even the implied warranty of' - - 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + - ' to LGPL,' - - 'see the GNU Lesser General Public License for more details. In r' + - 'elation to ' - 'MPL,' - - 'see the MPL License for the specific language governing rights a' + - 'nd ' - 'limitations' - 'under the License.' - '' - - 'The Initial Developer of the Original Code for TurboPower LockBo' + - 'x version 2' - 'and earlier was TurboPower Software.' - '') - ParentFont = False - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - end - object tsAuthors: TTabSheet - Caption = 'Authors' - ImageIndex = 4 - DesignSize = ( - 631 - 380) - object Bevel1: TBevel - Left = 328 - Top = 16 - Width = 281 - Height = 257 - end - object imgAuthorPic: TImage - Left = 336 - Top = 24 - Width = 265 - Height = 233 - Stretch = True - end - object lblAuthorEmail: TLabel - Left = 328 - Top = 293 - Width = 150 - Height = 13 - Caption = 'email: sean@seanbdurkin.id.au' - end - object lblAuthorWeb: TLabel - Left = 328 - Top = 312 - Width = 173 - Height = 13 - Caption = 'web: http:\\www.seanbdurkin.id.au' - end - object Label12: TLabel - Left = 175 - Top = 135 - Width = 135 - Height = 13 - Caption = 'Select author to see details.' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - end - object imgSean: TImage - Left = 175 - Top = 272 - Width = 135 - Height = 105 - Picture.Data = { - 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 - 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 - 696E6720494A47204A50454720763632292C207175616C697479203D2038350A - FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 - 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E - 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 - 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 - 00B5100002010303020403050504040000017D01020300041105122131410613 - 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 - 262728292A3435363738393A434445464748494A535455565758595A63646566 - 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 - A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 - DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 - 01010101010000000000000102030405060708090A0BFFC400B5110002010204 - 0403040705040400010277000102031104052131061241510761711322328108 - 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 - 363738393A434445464748494A535455565758595A636465666768696A737475 - 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA - B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 - E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 - AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF - 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 - D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 - 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 - CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 - 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E - 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 - CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 - C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA - 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 - 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 - F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF - 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 - 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 - E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 - AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 - 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 - 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F - A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 - B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F - FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B - A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 - 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE - 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 - D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB - 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 - 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 - 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C - 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE - 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B - E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 - F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 - 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 - 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 - E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 - C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A - CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 - B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 - 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 - 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C - 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C - DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC - B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 - 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA - 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 - 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A - 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 - EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 - 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 - 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 - 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 - 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 - 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C - D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 - 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 - 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC - B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 - B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 - AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 - 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F - 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 - DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C - F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C - 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 - 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 - 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 - 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 - 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 - 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 - ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A - B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 - 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD - 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 - 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 - CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB - BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E - F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F - 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 - C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 - EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 - 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 - FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 - 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB - 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 - 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD - C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 - B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 - CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF - 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE - E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA - EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 - B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 - CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 - DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 - 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 - 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F - 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C - 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D - 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 - 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 - 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE - 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E - 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 - D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 - 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A - 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 - 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 - F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 - 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 - 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 - A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 - ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F - A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 - 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 - 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 - 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 - 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 - F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 - 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 - C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E - B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C - AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 - 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E - FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 - 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 - 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B - 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F - EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C - 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 - 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD - 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D - 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 - 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 - FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 - 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 - 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B - FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D - B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 - 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 - B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 - 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F - 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F - F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF - 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 - A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 - 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 - DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 - FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD - 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 - CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 - 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 - BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 - B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D - FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 - 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 - C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A - 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 - 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 - B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 - BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 - 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 - 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB - 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 - 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C - 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 - 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 - BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C - 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 - 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 - 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 - 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 - DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 - 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 - AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD - 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 - 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF - 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C - DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 - 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A - B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 - C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 - F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E - 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 - C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC - 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 - 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB - B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 - 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E - EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 - 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 - 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA - 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C - D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E - 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A - 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 - F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE - 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 - 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 - 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF - 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD - 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE - BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C - 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C - AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 - CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 - 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB - 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 - 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 - A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A - 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 - B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D - 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E - 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 - FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B - 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C - 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 - D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA - 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 - 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 - 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D - FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 - 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 - E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A - 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 - 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A - A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 - 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 - EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 - 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B - 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 - 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 - 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F - A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A - CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B - 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 - 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E - 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 - 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F - 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D - 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA - 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E - 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 - F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 - 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 - 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 - 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A - 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 - 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B - 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 - 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 - 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 - A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 - 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 - AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F - 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C - DA66209F4EF451457D427A1E3D8FFFD9} - Visible = False - end - object Memo4: TMemo - Left = 8 - Top = 8 - Width = 161 - Height = 369 - Anchors = [akLeft, akTop, akBottom] - Lines.Strings = ( - 'To the right is a list of authors ' - 'and contributors to ' - 'TurboPower LockBox 3.' - 'Not included are the authors ' - 'of LockBox 1 & 2, as there is ' - 'no common' - 'copyrightable content ' - 'between them and LockBox 3.' - '' - 'The LockBox 3 project ' - 'welcomes any contributions. If ' - 'you wish to contribute,' - 'and your contributions are ' - 'accepted, your details can, if ' - 'you request, be' - 'added to this list of authors.') - TabOrder = 0 - end - object lbxAuthors: TListBox - Left = 175 - Top = 8 - Width = 138 - Height = 121 - ItemHeight = 13 - Items.Strings = ( - 'Sean B. Durkin' - 'David Barton') - TabOrder = 1 - OnClick = lbxAuthorsClick - end - end - object tsSupport: TTabSheet - Caption = 'Support' - ImageIndex = 5 - object memoSupport: TMemo - Left = 3 - Top = 24 - Width = 286 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'Support can be obtained through the ' - 'forums at:' - 'http://lockbox.seanbdurkin.id.au/tiki-f' - 'orums.php') - ParentFont = False - ReadOnly = True - TabOrder = 0 - end - object memoHelp: TMemo - Left = 295 - Top = 24 - Width = 333 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'User help for this component suite' - 'can be found at' - 'http://lockbox.seanbdurkin.id.au/LB3Help_H' - 'ome .' - 'If the help is still partially' - 'under construction, please either be' - 'patient, or offer your own content.' - '') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsAlgorithms: TTabSheet - Caption = 'Algorithms' - ImageIndex = 6 - object Panel1: TPanel - Left = 3 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 0 - object Label13: TLabel - Left = 16 - Top = 0 - Width = 116 - Height = 13 - Caption = 'About selected Hash' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblHashDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label15: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblHashDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashWikipediaURL: TLabel - Left = 16 - Top = 136 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lblHashDigestSize: TLabel - Left = 16 - Top = 184 - Width = 97 - Height = 13 - Caption = 'Digest size = 64 bits' - end - object lbxHashFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - object pnlCipherDescription: TPanel - Left = 299 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 1 - object Label20: TLabel - Left = 16 - Top = 0 - Width = 124 - Height = 13 - Caption = 'About selected Cipher' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblCipherDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label22: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblCipherDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherWikipediaURL: TLabel - Left = 16 - Top = 141 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lbxCipherFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - object memoExtraCipherDescription: TMemo - Left = 16 - Top = 192 - Width = 233 - Height = 89 - Lines.Strings = ( - 'Extra Cipher Description') - ParentColor = True - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 1 - Visible = False - end - end - object Panel3: TPanel - Left = 3 - Top = 231 - Width = 270 - Height = 146 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 2 - object Label27: TLabel - Left = 16 - Top = 0 - Width = 170 - Height = 13 - Caption = 'About selected Chaining Mode' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblChainName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label29: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblChainWikipedia: TLabel - Left = 16 - Top = 120 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lbxChainFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - end - end - end - object btnClose: TButton - Left = 280 - Top = 416 - Width = 75 - Height = 25 - Anchors = [akLeft, akBottom] - Caption = 'Close' - ModalResult = 1 - TabOrder = 1 - end -end +object TPLb_fmComponentAbout: TTPLb_fmComponentAbout + Left = 0 + Top = 0 + Caption = 'Component About' + ClientHeight = 442 + ClientWidth = 640 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + GlassFrame.Enabled = True + GlassFrame.SheetOfGlass = True + OldCreateOrder = False + OnCreate = FormCreate + DesignSize = ( + 640 + 442) + PixelsPerInch = 96 + TextHeight = 13 + object pnlAbout: TPanel + Left = 0 + Top = 0 + Width = 641 + Height = 410 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'About Box to be developed!' + TabOrder = 0 + object pgAboutContent: TPageControl + Left = 1 + Top = 1 + Width = 639 + Height = 408 + ActivePage = tsMain + Align = alClient + TabOrder = 0 + object tsMain: TTabSheet + Caption = 'Main' + DesignSize = ( + 631 + 380) + object Image1: TImage + Left = 0 + Top = 0 + Width = 225 + Height = 329 + Picture.Data = { + 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 + 480000FFE1004045786966000049492A0008000000010069870400010000001A + 000000000000000100869202000B0000002C000000000000004170706C654D61 + 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 + 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 + 50504C0000000049454320735247420000000000000000000000000000F6D600 + 0100000000D32D48502020000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000116370727400 + 0001500000003364657363000001840000007377747074000001F80000001462 + 6B70740000020C000000147258595A00000220000000146758595A0000023400 + 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 + 0002BC0000007976756564000003380000008676696577000003C0000000246C + 756D69000003E4000000146D656173000003F800000024746563680000041C00 + 00000C72545243000004280000080C67545243000004280000080C6254524300 + 0004280000080C7465787400000000436F707972696768742028632920313939 + 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 + 00000000000019735247422049454336313936362D322E312039393132303300 + 0000000000000000000019735247422049454336313936362D322E3120393931 + 3230330000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000058595A20000000000000F3510001000000 + 0116CC58595A200000000000000000000000000000000058595A200000000000 + 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 + 595A2000000000000024A000000F840000B6CF64657363000000000000000549 + 4543200000000000000000000000054945432000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000064657363000000000000001F73 + 524742204945432036313936362D322E31207352474220393931323033000000 + 00000000000000001F73524742204945432036313936362D322E312073524742 + 2039393132303300000000000000000000000000000000000000000000000000 + 00000000000000000000000000000064657363000000000000002C5265666572 + 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 + 36362D322E3100000000000000000000002C5265666572656E63652056696577 + 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 + 0000000000000000000000000000000000000000000000766965770000000000 + 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 + 000000004C09560050000000571FE76D65617300000000000000010000000000 + 00000000000000000000000000028F0000000273696720000000004352542063 + 757276000000000000040000000005000A000F00140019001E00230028002D00 + 320037003B00400045004A004F00540059005E00630068006D00720077007C00 + 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 + D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 + 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 + 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 + 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 + B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 + 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 + 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 + 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 + 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 + 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 + 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 + 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A + F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C + 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E + 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F + CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 + AA11C911E81207122612451264128412A312C312E31303132313431363138313 + A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 + BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 + F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A + 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C + CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F + 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 + 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 + 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 + 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B + 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E + 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 + F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 + 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 + 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D + 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 + 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 + 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 + A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E + 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 + C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 + 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C + 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 + A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 + E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C + 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 + F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 + B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D + A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 + BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 + FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 + 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 + 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D + D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 + C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB + E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 + 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA + B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 + 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA + 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 + 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA + 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 + DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB + 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 + 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD + 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 + 0202020202040303020305040505050404040506070605050706040406090607 + 08080808080506090A09080A07080808FFDB0043010101010202020402020408 + 0504050808080808080808080808080808080808080808080808080808080808 + 080808080808080808080808080808080808080808FFC0001108014A00EA0301 + 2200021101031101FFC4001F0000010501010101010100000000000000000102 + 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 + 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 + 627282090A161718191A25262728292A3435363738393A434445464748494A53 + 5455565758595A636465666768696A737475767778797A838485868788898A92 + 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 + C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA + FFC4001F0100030101010101010101010000000000000102030405060708090A + 0BFFC400B5110002010204040304070504040001027700010203110405213106 + 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 + F11718191A262728292A35363738393A434445464748494A535455565758595A + 636465666768696A737475767778797A82838485868788898A92939495969798 + 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 + D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 + 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F + B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 + 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C + D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 + C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 + DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 + 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C + 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D + B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D + FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB + 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 + 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 + ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB + AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F + 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 + EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 + DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F + 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 + 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 + C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB + 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 + 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 + A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 + 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA + 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 + D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 + 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 + 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 + 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D + 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D + 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E + BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 + 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 + B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 + 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF + 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF + B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 + 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 + 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 + 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 + 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E + DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 + EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 + 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 + C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 + 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 + 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 + 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 + 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 + 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 + 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 + E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE + AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 + 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 + 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC + AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC + 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 + EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 + 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE + 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 + 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A + 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C + FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 + 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E + 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 + 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC + 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 + 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A + BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF + FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB + 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 + 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 + 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 + DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 + 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 + 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 + 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A + BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F + 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B + E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C + 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 + 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A + 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 + 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD + 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 + A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 + C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D + C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC + B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE + 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 + B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 + 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 + 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 + 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 + B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 + 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 + 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 + 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A + BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D + 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 + 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 + 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D + FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 + 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 + 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 + BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 + 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 + B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 + 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 + D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E + F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F + B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B + 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 + E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A + BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 + DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 + D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF + C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF + 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 + D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 + 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 + 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D + B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 + 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB + E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 + C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 + 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 + ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 + E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 + 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 + 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 + D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 + 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 + B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 + 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E + C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A + F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 + 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 + 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C + D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 + C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 + 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 + 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 + 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 + B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 + EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F + D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 + 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 + 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 + F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 + 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 + 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD + B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 + 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 + 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 + CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 + 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 + F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 + 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F + 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 + 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A + FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A + EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D + 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F + 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B + E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 + 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD + FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA + E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 + F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 + 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 + 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 + 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 + 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 + FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 + 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB + 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 + F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 + CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 + 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 + 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 + BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 + DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 + ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 + 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 + 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF + 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA + EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 + 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 + 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 + 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 + FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB + 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 + D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB + 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED + 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 + 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD + 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 + B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 + 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 + 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C + 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 + A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC + 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 + 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC + D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 + 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C + 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 + FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B + CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 + 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E + 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 + B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 + AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 + C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 + FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 + 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 + 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE + 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 + 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 + 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 + F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 + 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC + 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 + 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD + E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 + 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B + E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA + DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 + 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 + DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 + 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 + D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 + FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B + F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 + E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF + 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B + 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 + 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 + 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 + 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 + 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F + C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 + B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 + 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 + 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E + 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC + FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F + A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B + 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 + E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F + 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C + F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C + 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE + 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 + 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D + D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 + 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 + 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 + 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA + E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 + F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF + 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 + E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F + 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 + 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 + BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B + C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 + B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 + 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F + 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F + C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 + 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 + 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 + 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 + 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F + ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C + C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B + F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B + 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF + AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA + 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 + 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 + EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 + 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 + 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D + 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C + C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 + EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 + 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 + BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 + 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF + 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 + 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 + 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 + 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 + 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 + 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 + 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E + CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 + D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 + 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 + 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F + B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB + 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F + 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 + 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B + 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 + 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF + 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B + E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B + 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA + 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 + DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 + 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A + F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC + 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D + 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 + DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF + 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED + 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B + F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 + DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 + D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B + F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 + 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 + 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E + 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E + 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B + E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F + 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 + 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 + C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 + 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD + 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE + 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 + F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E + 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC + 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 + D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE + BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C + 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 + D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E + 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 + 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 + A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC + E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E + 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 + B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 + 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 + 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B + B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB + FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 + C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA + D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C + 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED + C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 + 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 + 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B + 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 + 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 + 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 + 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F + 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 + 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD + 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A + CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC + 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 + 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF + C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E + 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 + F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF + D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 + 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 + C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC + 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 + 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF + 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 + 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE + DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 + AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 + C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 + FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF + 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F + 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 + A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F + E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 + 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 + F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 + C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE + 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 + 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 + 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 + C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E + 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 + 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA + AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 + E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 + 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD + 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 + FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 + 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 + E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 + 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 + E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 + 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB + 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED + 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C + DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 + DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 + 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D + FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F + 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 + 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 + 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 + FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 + E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF + E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC + 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 + A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF + BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 + C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 + D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 + 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 + 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 + 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F + F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 + B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 + BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 + FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 + 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF + 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED + CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 + 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF + 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D + 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A + BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 + 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 + 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 + 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 + F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B + 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 + E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C + 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF + B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 + A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 + 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 + 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 + 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A + 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A + CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D + 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F + 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 + FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C + 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 + E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 + EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF + 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 + DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 + DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 + FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC + 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 + B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 + 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 + FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 + 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 + 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D + BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 + 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C + 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA + B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 + 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA + 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE + D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 + C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 + DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC + F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 + 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD + 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 + 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD + 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA + C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE + CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 + 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB + DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA + BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 + 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A + E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 + 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 + 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 + 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 + 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F + FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 + 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D + FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D + C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F + 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED + 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 + BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 + AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 + E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD + D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 + 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 + 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB + 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 + 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 + CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 + 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B + 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E + 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 + 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 + F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C + F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 + E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 + 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B + 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 + D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 + C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD + EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF + 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 + F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F + 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 + 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 + 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 + FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 + DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 + 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E + D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 + 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 + F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F + 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 + 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E + 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 + A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 + E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 + 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 + 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 + 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 + 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E + 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 + 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD + B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 + A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C + 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 + E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E + 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F + ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E + F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD + 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B + C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 + A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 + A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 + 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 + 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 + 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A + 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E + D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D + 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA + C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF + 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E + DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A + 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 + 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A + 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB + 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA + 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF + 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F + 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 + FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF + C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C + 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 + 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 + 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 + DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB + D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 + ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 + 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 + BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 + 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF + 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 + 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 + 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 + 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 + 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 + D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D + 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF + ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B + 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 + EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D + C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 + 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F + B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 + 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D + A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 + 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 + 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 + D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 + 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 + A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 + D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 + D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 + DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B + 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D + 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 + FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F + 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 + 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B + 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E + AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 + C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 + F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 + 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB + C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 + 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F + C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 + 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA + 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F + B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C + AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 + 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F + BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 + A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD + 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA + 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B + 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE + 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 + 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 + D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 + FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 + 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA + 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 + 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 + 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 + 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD + 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF + 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D + F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA + AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 + 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 + 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 + 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 + 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE + EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 + 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 + 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 + 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 + BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C + C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 + E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 + 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E + 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 + 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA + 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 + 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C + 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 + 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 + BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 + DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E + 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 + 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 + 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 + 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 + 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 + 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 + 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 + C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 + 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 + 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 + 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 + 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 + 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 + F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 + 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 + 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 + B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 + 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB + 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF + 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F + CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 + F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 + 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC + 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 + 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 + 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 + DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 + 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC + 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB + 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 + C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 + 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 + A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 + 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 + 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 + 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 + 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 + BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A + EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 + D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 + 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 + EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C + 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 + 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 + 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 + 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 + F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D + 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C + 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 + 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F + 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 + DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF + 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B + 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC + B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 + F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 + 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB + 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C + D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 + CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E + 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 + 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A + AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 + AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF + 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 + 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 + 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E + 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 + BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 + F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E + 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 + 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B + 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 + 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 + 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 + 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED + 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D + 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 + F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 + 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA + 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E + 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 + F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F + B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC + 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B + 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 + 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 + 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C + 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 + 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF + 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 + AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE + F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A + 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 + 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 + 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 + AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 + B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 + CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D + 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 + 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 + 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 + D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF + 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A + 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 + DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD + A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 + 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 + E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E + 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 + A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 + F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC + CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF + 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 + D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE + AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 + EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 + 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 + 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 + 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 + 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 + 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED + 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 + A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F + 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 + C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 + 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F + E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 + F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F + D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F + AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED + 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F + B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 + 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 + 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 + DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 + F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 + 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 + 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 + 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B + 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 + C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 + 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C + 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 + 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 + 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C + BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 + B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 + F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 + 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D + F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A + F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 + 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 + F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC + 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 + 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D + DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 + 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 + F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 + 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B + 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E + D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B + 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F + 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 + 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D + 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 + BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 + 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 + CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E + 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 + B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 + B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 + C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 + 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 + 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF + 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 + 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B + 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F + 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 + 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA + 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 + D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 + B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 + 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C + BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E + 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 + D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 + BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 + DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 + B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE + 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 + 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 + D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B + 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 + 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB + F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 + 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A + CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 + C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 + 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 + D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D + 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 + CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F + 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E + 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB + 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 + B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 + BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 + 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 + 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F + 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 + D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 + FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 + 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 + 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB + E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 + 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 + F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 + D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 + 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D + 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 + 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 + FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E + A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE + 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC + 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 + 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB + 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 + B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 + 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB + B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 + 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 + 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 + 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E + 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 + 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 + FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED + 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 + 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 + 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 + F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 + 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 + 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E + 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F + 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 + FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 + 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 + 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF + 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 + 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 + EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D + 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D + F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 + 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 + 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA + 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB + 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 + 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 + F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 + F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 + F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF + F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 + 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 + B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 + DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E + CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 + 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 + AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 + 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C + 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB + CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C + 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 + 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B + 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 + AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B + 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA + 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 + C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 + 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 + 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 + 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 + 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E + 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 + D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F + 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E + 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D + 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 + 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 + 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 + 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B + EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 + 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F + C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 + 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 + 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 + B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE + 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A + 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F + 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE + 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB + 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 + B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 + 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC + D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 + 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 + 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 + AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF + 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 + 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 + D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 + 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 + 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D + 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 + 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E + 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E + DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 + 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 + B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 + B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 + E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 + F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 + A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 + 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B + 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 + 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF + 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 + 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 + BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 + 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 + F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B + A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 + 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC + BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A + F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 + 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 + 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB + CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 + A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C + 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 + 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 + CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 + 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE + 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F + 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF + 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 + F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB + 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F + 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 + AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 + CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 + ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 + 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F + 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF + 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B + 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 + E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E + 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C + 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 + 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 + 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF + E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B + 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC + 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C + 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 + 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 + C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 + 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D + 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 + 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 + F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 + AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F + 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 + 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 + 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 + DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF + 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 + 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B + FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 + 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD + 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 + C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F + C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 + 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A + FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC + 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E + 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 + BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 + E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 + C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 + E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 + FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 + 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 + 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A + 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F + 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 + 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B + 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 + 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 + D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 + EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 + ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 + E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC + 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB + E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 + 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 + 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 + FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 + B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 + FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD + ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF + 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 + BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C + D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 + BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA + B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 + BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 + 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 + 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 + A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 + 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E + FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 + B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E + 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 + 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 + 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E + D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 + 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 + 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED + AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 + BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD + 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 + 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E + 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF + B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 + E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C + CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 + 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED + 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B + B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 + A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 + 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A + B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 + FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF + F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA + 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 + FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 + 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B + B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D + 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 + 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 + 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E + 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 + BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 + 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB + 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 + C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 + C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 + EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 + BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 + 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 + F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 + C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 + BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 + F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 + F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 + 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 + 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB + 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 + 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 + F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 + 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 + 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D + EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 + 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 + 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 + 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA + D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E + F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A + E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 + B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A + A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 + 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA + 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F + F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 + AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 + 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE + 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 + 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 + 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 + C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 + FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB + 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 + 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 + CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 + 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB + D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A + 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 + 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 + 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC + C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 + D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 + F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 + 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 + BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 + 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 + 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D + 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C + 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 + 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF + B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 + 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE + 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 + 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED + 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 + F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B + B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC + E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB + 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 + 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D + BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC + D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB + 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D + D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB + 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 + F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F + 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D + 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 + F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD + E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C + 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 + 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 + A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB + E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 + 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC + 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 + DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 + 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 + 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 + FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 + 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD + 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 + E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 + 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 + 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 + AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F + 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C + 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 + 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 + C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 + C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 + E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD + 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 + D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 + 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 + F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F + 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 + 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE + 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 + C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D + 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE + 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D + 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C + D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF + AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 + 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 + 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 + C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F + 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A + CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 + 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C + 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA + B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 + 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 + 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 + 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE + BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF + 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 + 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E + 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF + 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 + A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 + DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 + FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC + 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 + DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 + D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 + 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 + 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 + 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF + C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A + FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 + 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 + 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F + DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB + B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 + 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 + 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 + 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 + B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 + 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 + BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 + 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 + FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC + D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED + 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 + FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C + 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 + B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 + AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E + 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 + 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 + 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 + FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C + 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 + F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C + EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF + 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 + 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 + 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF + 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB + 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C + 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 + 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE + FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC + AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 + 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F + 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A + 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A + 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 + F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B + 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 + 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED + E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D + AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD + E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 + 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD + 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 + BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 + B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 + 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB + F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F + 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 + DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F + D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A + F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F + 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 + 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 + F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 + A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 + 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 + EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C + D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F + F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 + D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC + 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 + 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 + CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 + 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 + C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF + 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 + 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 + C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A + 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 + 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F + 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 + B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 + E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E + 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 + B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D + F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 + 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F + 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 + 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D + 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 + 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 + 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 + 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A + 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC + BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 + 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA + 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 + D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 + FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 + DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 + B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 + B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 + 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 + 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 + 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB + D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 + BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C + D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 + 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D + F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F + 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E + 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 + F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A + 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D + 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC + 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 + FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 + 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC + 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E + EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 + 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 + 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 + 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 + CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE + 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 + D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C + 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D + C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF + BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 + 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 + 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF + 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF + 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA + 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 + 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 + 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 + D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 + 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF + 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE + BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE + ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 + C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E + 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 + FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A + F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 + FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B + 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA + 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF + 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 + 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 + 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D + ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 + C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 + 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C + 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 + 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA + D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 + F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B + 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 + 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B + C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 + DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 + 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F + 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F + EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 + 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE + D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E + BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF + 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E + D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 + 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 + 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 + EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E + 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 + DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 + B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC + C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C + FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 + 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 + EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 + DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C + 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 + D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F + ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC + FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 + 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 + 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B + 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B + DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 + 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB + EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 + F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C + 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E + E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE + 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 + F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 + AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 + 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B + AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 + D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 + 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D + 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 + BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A + F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 + F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 + B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 + E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 + 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE + B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 + 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B + 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 + 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 + FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 + 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A + 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE + 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 + 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 + BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 + 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 + D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 + FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 + 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 + 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A + BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 + EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 + B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D + DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E + E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C + 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 + 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F + CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C + 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 + B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB + 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 + F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F + 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 + CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF + 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 + 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 + 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F + C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 + CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 + 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F + 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 + 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 + 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A + 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D + F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 + BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 + E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F + 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 + F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 + 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F + 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 + 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 + 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C + F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F + 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 + F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A + D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF + DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 + C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 + 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE + 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 + AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 + CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C + 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 + 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F + C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 + 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 + 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE + 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 + 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB + D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF + 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 + 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA + 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 + 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC + 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 + 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 + B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F + 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC + D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 + 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 + ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B + D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 + ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 + 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B + E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B + 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE + 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B + E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 + 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 + B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 + 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 + 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 + CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 + 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 + D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 + 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC + 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B + 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD + 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 + B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C + F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 + 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 + 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 + 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 + D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 + 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 + AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 + AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B + A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 + 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 + A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B + 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE + B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 + BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE + BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A + B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 + 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 + 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B + 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 + 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F + 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 + 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF + 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C + 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 + FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 + 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 + 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 + 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE + 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 + 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B + 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E + F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 + 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 + 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 + 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 + 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 + A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 + 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 + 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 + 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF + 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 + FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E + E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 + 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B + D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 + 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 + 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C + 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C + 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 + F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B + 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 + E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E + 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 + 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA + 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B + C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B + 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF + 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB + DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 + 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E + 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 + E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 + D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 + ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE + 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 + C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F + 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E + 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD + D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 + C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB + 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 + 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 + EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA + BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A + B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 + 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 + 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB + 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA + CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D + 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C + 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 + 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 + 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A + 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 + 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B + F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 + 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 + 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A + 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 + A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 + C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 + B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 + 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 + AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 + C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 + B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 + 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F + 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 + B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 + 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 + 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 + DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F + 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F + 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 + E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 + BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 + BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 + 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B + D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E + F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 + 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F + 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 + C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D + F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 + 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC + 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E + CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A + 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F + 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 + 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 + 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D + E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 + 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 + D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F + 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 + A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 + B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A + 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD + B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 + B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 + AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 + 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB + 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F + 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E + 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 + 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 + ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC + EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 + B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 + 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD + 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 + 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C + E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 + 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA + B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 + 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 + C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 + 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 + 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E + 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 + 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 + AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 + 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F + 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA + DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 + 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB + 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F + 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C + E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 + 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 + A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 + 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 + C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 + 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC + 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE + EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 + 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A + 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 + 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB + C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F + D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F + C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B + 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA + F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 + 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 + 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 + 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF + E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 + 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 + F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A + 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE + 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 + BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C + 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 + 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 + 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 + A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 + 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 + 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 + 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B + 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C + 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE + 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC + 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 + C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 + D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 + 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B + F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 + 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 + 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E + 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 + 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF + A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE + 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E + 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 + D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 + 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 + DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 + F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 + 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F + 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 + 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 + 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 + 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 + EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 + E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 + A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF + F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC + EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 + 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 + 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 + C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A + D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 + EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 + 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB + 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA + B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C + 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 + 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 + 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 + D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A + FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 + D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F + E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD + BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 + FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 + 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA + 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 + D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 + 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 + C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E + 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF + DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 + 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B + B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F + 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 + B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E + 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE + EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 + 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 + FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 + CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F + 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED + FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 + 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF + B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 + 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED + 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E + 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE + 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B + 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 + D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 + F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 + 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 + F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 + 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 + 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 + A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 + 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C + D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 + 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 + 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 + 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 + B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC + 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 + 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 + 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 + A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 + 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF + C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C + C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 + B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 + 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 + 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF + 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 + ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 + 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC + 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF + 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 + 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F + 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 + FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F + 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 + 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 + A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA + 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 + A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 + 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F + 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF + 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 + C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 + 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 + F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 + F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 + E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F + 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D + A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF + B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B + 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 + 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A + D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 + 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 + C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 + 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 + C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 + 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 + 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D + 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 + 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 + 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 + BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 + 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 + F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C + 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F + C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF + A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 + D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 + 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 + C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 + EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 + C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 + 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B + FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 + 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 + BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D + 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 + 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 + 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC + D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 + 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD + 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 + 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 + E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 + AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B + AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 + B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C + 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF + CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B + C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD + 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 + DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB + F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 + 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 + AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 + B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 + B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE + BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C + 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED + 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 + BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A + F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 + EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 + 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E + F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 + AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 + C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C + 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 + 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F + ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 + E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F + 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 + 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 + EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 + ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 + 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 + 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 + EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 + 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 + BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 + 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 + 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D + 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B + 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF + 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C + 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E + 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 + 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F + B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C + 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 + 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 + 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B + BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F + 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB + 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 + 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 + 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 + EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 + 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 + 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 + EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A + 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A + 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 + E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A + B5BF6F91D5F50E66B9A5D0FFD9} + end + object lblTitle: TLabel + Left = 231 + Top = 3 + Width = 402 + Height = 62 + Anchors = [akLeft, akTop, akRight] + AutoSize = False + Caption = 'TurboPower LockBox 3' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -33 + Font.Name = 'Lucida Sans' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + Transparent = False + WordWrap = True + end + object Label1: TLabel + Left = 231 + Top = 65 + Width = 400 + Height = 137 + AutoSize = False + Caption = + 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + + 'is to provide basic cryptographic functionality, implemented nat' + + 'ively as a white box.'#13#10'Block mode ciphers include AES and Blowfi' + + 'sh, and will soon be extended to include many others. Hashes inc' + + 'lude MD5, SHA-1 and RIPEMD-160 and will soon be extended to incl' + + 'ude many others. Chaining modes include ECB, CBC, PCBC, CFB, CFB' + + '-8Bit, OFB and CTR. The source code is highly readable and under' + + 'standable. Salting is provided where it is needed, transparently' + + '. The design is very extensible. Extending the range of ciphers ' + + 'and hashes can be done cheaply, easily and quickly.' + WordWrap = True + end + object lblRunTimeVersion: TLabel + Left = 231 + Top = 208 + Width = 78 + Height = 13 + Caption = 'run-time version' + end + object lblDesignTimeVersion: TLabel + Left = 231 + Top = 224 + Width = 93 + Height = 13 + Caption = 'design-time version' + end + object lblLogoAttribution: TLabel + Left = 0 + Top = 330 + Width = 614 + Height = 47 + AutoSize = False + Caption = + 'The above photo was sourced from http://www.flickr.com/photos/ml' + + 'iu92/3146549932 and has been copied with the kind permission of ' + + 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + + ' under the Creative Commons license (http://creativecommons.org/' + + 'licenses/by-nc-sa/2.0/deed.en).' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + WordWrap = True + end + object Memo1: TMemo + Left = 231 + Top = 243 + Width = 194 + Height = 86 + Color = clInfoBk + Lines.Strings = ( + 'TPLB3 is free and open source ' + 'software. It is made available for ' + 'use and copying by an LGPL or an' + 'MPL license at your choice. ' + 'Refer to the "Statement of copying' + 'permission" tab for details.') + ReadOnly = True + TabOrder = 0 + end + end + object tsWelcome: TTabSheet + Caption = 'Welcome' + ImageIndex = 1 + object browserIntro: TWebBrowser + Left = 104 + Top = 0 + Width = 527 + Height = 380 + Align = alRight + TabOrder = 0 + ControlData = { + 4C00000078360000462700000000000000000000000000000000000000000000 + 000000004C000000000000000000000001000000E0D057007335CF11AE690800 + 2B2E126208000000000000004C0000000114020000000000C000000000000046 + 8000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000100000000000000000000000000000000000000} + end + object memoWelcomeInstructions: TMemo + Left = 0 + Top = 0 + Width = 104 + Height = 377 + Margins.Left = 0 + Margins.Right = 0 + BorderStyle = bsNone + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'The video to the ' + 'right requires an ' + 'internet connection ' + 'and Adobe Flash ' + 'Player 10 to be ' + 'installed, in order to ' + 'play.') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsProject: TTabSheet + Caption = 'Project' + ImageIndex = 2 + object Label4: TLabel + Left = 0 + Top = 3 + Width = 323 + Height = 30 + Caption = 'This product has been brought to you by ...' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -27 + Font.Name = 'Script' + Font.Style = [fsBold] + ParentFont = False + end + object lblWebsite: TLabel + Left = 3 + Top = 312 + Width = 250 + Height = 13 + Caption = 'http://sourceforge.net/projects/tplockbox/' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + end + object Memo2: TMemo + Left = 3 + Top = 32 + Width = 614 + Height = 217 + Color = clInfoBk + Lines.Strings = ( + + 'The TPLB3 product is produced under the organisational umbrella ' + + 'of the TurboPower LockBox project. This project has no ' + + 'legal incorporation. It is an informal organisation with no defi' + + 'ned membership. The TPLB3 product is owned by the ' + + 'individual contributors to its parts. The Project on SourceForge' + + ' is administered by the TurboPower SourceForge ' + 'Administrator (tpsfadmin).' + '' + + 'LockBox was originally produced and released by TurboPower Softw' + + 'are Company as a commercial product. Versions 1 and' + + '2 of the product were commericial and were released in the perio' + + 'd from 1997 to 2002. The copyright holder was' + + 'TurboPower Software Company. Version 2 source code was donated t' + + 'o the the TurboPower LockBox SourceForge project' + 'under an MPL 1.1 license, which is free and open-source license.' + '' + + 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + + 'rivative work of LockBox 2 and does not share any' + + 'common code, but the mission of the library remains the same. An' + + ' exception is the unit DCPtwofish_LB3Modified' + + 'which is a modified version of a file from David Barton'#39's DCPCry' + + 'pt package. The original unit of this was' + 'developed by David Barton.') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object lblTpsfaIntro: TStaticText + Left = 3 + Top = 255 + Width = 356 + Height = 17 + Caption = + 'The TurboPower Source Forge Administrator (tpsfa) can be contact' + + 'ed at:' + TabOrder = 1 + end + object lblTpsfaContact: TStaticText + Left = 3 + Top = 272 + Width = 335 + Height = 17 + Cursor = crHandPoint + Caption = 'http://sourceforge.net/sendmessage.php?touser=625421' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + TabOrder = 2 + OnClick = lblTpsfaContactClick + end + object lblWebLabel: TStaticText + Left = 3 + Top = 295 + Width = 177 + Height = 17 + Caption = 'TPLB3 on SourceForge is located at:' + TabOrder = 3 + end + end + object tsCopyLeft: TTabSheet + Caption = 'Statement of copying permission' + ImageIndex = 3 + DesignSize = ( + 631 + 380) + object Label7: TLabel + Left = 3 + Top = 3 + Width = 369 + Height = 13 + Caption = + 'Copyright 2009, 2010 Sean B. Durkin (except for portions marked ' + + 'otherwise)' + end + object Label8: TLabel + Left = 3 + Top = 18 + Width = 625 + Height = 26 + Caption = + 'The below copyright applies to all the source code and compiled ' + + 'binaries of the TPBL3 project, except the DCPtwofish_LB3Modified' + + ' unit which comes with its own statement of copying permission i' + + 'n its header comment.' + WordWrap = True + end + object Label9: TLabel + Left = 8 + Top = 48 + Width = 190 + Height = 13 + Caption = 'Statement of copying permission:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object Memo3: TMemo + Left = 2 + Top = 67 + Width = 625 + Height = 246 + Anchors = [akLeft, akTop, akRight] + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + + 'This component library is part of TurboPower LockBox 3. TurboPow' + + 'er LockBox ' + '3' + + 'is free software being offered under a dual licensing scheme: LG' + + 'PL3 or ' + 'MPL1.1.' + '' + + 'The contents of this library are subject to the Mozilla Public L' + + 'icense ' + '(MPL)' + + 'Version 1.1 (the "License"); you may not use this file except in' + + ' compliance' + 'with the License. You may obtain a copy of the License at' + 'http://www.mozilla.org/MPL/' + '' + + 'Alternatively, you may redistribute it and/or modify it under th' + + 'e terms of' + + 'the GNU Lesser General Public License (LGPL) as published by the' + + ' Free ' + 'Software' + + 'Foundation, either version 3 of the License, or (at your option)' + + ' any later' + 'version.' + '' + + 'You should have received a copy of the Lesser GNU General Public' + + ' License' + 'along with TurboPower LockBox 3. If not, see ' + '.' + '' + + 'TurboPower LockBox is distributed in the hope that it will be us' + + 'eful,' + 'but WITHOUT ANY WARRANTY; without even the implied warranty of' + + 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + + ' to LGPL,' + + 'see the GNU Lesser General Public License for more details. In r' + + 'elation to ' + 'MPL,' + + 'see the MPL License for the specific language governing rights a' + + 'nd ' + 'limitations' + 'under the License.' + '' + + 'The Initial Developer of the Original Code for TurboPower LockBo' + + 'x version 2' + 'and earlier was TurboPower Software.' + '') + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + end + object tsAuthors: TTabSheet + Caption = 'Authors' + ImageIndex = 4 + DesignSize = ( + 631 + 380) + object Bevel1: TBevel + Left = 328 + Top = 16 + Width = 281 + Height = 257 + end + object imgAuthorPic: TImage + Left = 336 + Top = 24 + Width = 265 + Height = 233 + Stretch = True + end + object lblAuthorEmail: TLabel + Left = 328 + Top = 293 + Width = 150 + Height = 13 + Caption = 'email: sean@seanbdurkin.id.au' + end + object lblAuthorWeb: TLabel + Left = 328 + Top = 312 + Width = 173 + Height = 13 + Caption = 'web: http:\\www.seanbdurkin.id.au' + end + object Label12: TLabel + Left = 175 + Top = 135 + Width = 135 + Height = 13 + Caption = 'Select author to see details.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + end + object imgSean: TImage + Left = 175 + Top = 272 + Width = 135 + Height = 105 + Picture.Data = { + 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 + 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 + 696E6720494A47204A50454720763632292C207175616C697479203D2038350A + FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 + 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E + 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 + 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 + 00B5100002010303020403050504040000017D01020300041105122131410613 + 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 + 262728292A3435363738393A434445464748494A535455565758595A63646566 + 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 + A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 + DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 + 01010101010000000000000102030405060708090A0BFFC400B5110002010204 + 0403040705040400010277000102031104052131061241510761711322328108 + 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 + 363738393A434445464748494A535455565758595A636465666768696A737475 + 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA + B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 + E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 + AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF + 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 + D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 + 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 + CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 + 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E + 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 + CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 + C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA + 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 + 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 + F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF + 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 + 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 + E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 + AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 + 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 + 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F + A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 + B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F + FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B + A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 + 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE + 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 + D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB + 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 + 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 + 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C + 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE + 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B + E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 + F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 + 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 + 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 + E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 + C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A + CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 + B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 + 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 + 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C + 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C + DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC + B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 + 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA + 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 + 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A + 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 + EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 + 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 + 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 + 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 + 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 + 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C + D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 + 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 + 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC + B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 + B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 + AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 + 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F + 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 + DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C + F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C + 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 + 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 + 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 + 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 + 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 + 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 + ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A + B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 + 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD + 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 + 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 + CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB + BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E + F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F + 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 + C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 + EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 + 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 + FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 + 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB + 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 + 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD + C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 + B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 + CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF + 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE + E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA + EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 + B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 + CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 + DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 + 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 + 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F + 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C + 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D + 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 + 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 + 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE + 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E + 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 + D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 + 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A + 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 + 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 + F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 + 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 + 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 + A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 + ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F + A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 + 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 + 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 + 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 + 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 + F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 + 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 + C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E + B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C + AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 + 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E + FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 + 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 + 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B + 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F + EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C + 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 + 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD + 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D + 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 + 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 + FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 + 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 + 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B + FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D + B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 + 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 + B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 + 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F + 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F + F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF + 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 + A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 + 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 + DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 + FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD + 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 + CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 + 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 + BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 + B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D + FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 + 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 + C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A + 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 + 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 + B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 + BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 + 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 + 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB + 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 + 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C + 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 + 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 + BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C + 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 + 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 + 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 + 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 + DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 + 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 + AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD + 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 + 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF + 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C + DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 + 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A + B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 + C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 + F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E + 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 + C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC + 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 + 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB + B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 + 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E + EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 + 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 + 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA + 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C + D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E + 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A + 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 + F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE + 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 + 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 + 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF + 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD + 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE + BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C + 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C + AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 + CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 + 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB + 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 + 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 + A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A + 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 + B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D + 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E + 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 + FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B + 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C + 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 + D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA + 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 + 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 + 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D + FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 + 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 + E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A + 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 + 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A + A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 + 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 + EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 + 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B + 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 + 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 + 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F + A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A + CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B + 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 + 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E + 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 + 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F + 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D + 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA + 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E + 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 + F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 + 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 + 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 + 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A + 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 + 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B + 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 + 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 + 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 + A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 + 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 + AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F + 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C + DA66209F4EF451457D427A1E3D8FFFD9} + Visible = False + end + object Memo4: TMemo + Left = 8 + Top = 8 + Width = 161 + Height = 369 + Anchors = [akLeft, akTop, akBottom] + Lines.Strings = ( + 'To the right is a list of authors ' + 'and contributors to ' + 'TurboPower LockBox 3.' + 'Not included are the authors ' + 'of LockBox 1 & 2, as there is ' + 'no common' + 'copyrightable content ' + 'between them and LockBox 3.' + '' + 'The LockBox 3 project ' + 'welcomes any contributions. If ' + 'you wish to contribute,' + 'and your contributions are ' + 'accepted, your details can, if ' + 'you request, be' + 'added to this list of authors.') + TabOrder = 0 + end + object lbxAuthors: TListBox + Left = 175 + Top = 8 + Width = 138 + Height = 121 + ItemHeight = 13 + Items.Strings = ( + 'Sean B. Durkin' + 'David Barton') + TabOrder = 1 + OnClick = lbxAuthorsClick + end + end + object tsSupport: TTabSheet + Caption = 'Support' + ImageIndex = 5 + object memoSupport: TMemo + Left = 3 + Top = 24 + Width = 286 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'Support can be obtained through the ' + 'forums at:' + 'http://lockbox.seanbdurkin.id.au/tiki-f' + 'orums.php') + ParentFont = False + ReadOnly = True + TabOrder = 0 + end + object memoHelp: TMemo + Left = 295 + Top = 24 + Width = 333 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'User help for this component suite' + 'can be found at' + 'http://lockbox.seanbdurkin.id.au/LB3Help_H' + 'ome .' + 'If the help is still partially' + 'under construction, please either be' + 'patient, or offer your own content.' + '') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsAlgorithms: TTabSheet + Caption = 'Algorithms' + ImageIndex = 6 + object Panel1: TPanel + Left = 3 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 0 + object Label13: TLabel + Left = 16 + Top = 0 + Width = 116 + Height = 13 + Caption = 'About selected Hash' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblHashDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label15: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblHashDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashWikipediaURL: TLabel + Left = 16 + Top = 136 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lblHashDigestSize: TLabel + Left = 16 + Top = 184 + Width = 97 + Height = 13 + Caption = 'Digest size = 64 bits' + end + object lbxHashFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + object pnlCipherDescription: TPanel + Left = 299 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 1 + object Label20: TLabel + Left = 16 + Top = 0 + Width = 124 + Height = 13 + Caption = 'About selected Cipher' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblCipherDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label22: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblCipherDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherWikipediaURL: TLabel + Left = 16 + Top = 141 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lbxCipherFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + object memoExtraCipherDescription: TMemo + Left = 16 + Top = 192 + Width = 233 + Height = 89 + Lines.Strings = ( + 'Extra Cipher Description') + ParentColor = True + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 1 + Visible = False + end + end + object Panel3: TPanel + Left = 3 + Top = 231 + Width = 270 + Height = 146 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 2 + object Label27: TLabel + Left = 16 + Top = 0 + Width = 170 + Height = 13 + Caption = 'About selected Chaining Mode' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblChainName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label29: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblChainWikipedia: TLabel + Left = 16 + Top = 120 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lbxChainFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + end + end + end + object btnClose: TButton + Left = 280 + Top = 416 + Width = 75 + Height = 25 + Anchors = [akLeft, akBottom] + Caption = 'Close' + ModalResult = 1 + TabOrder = 1 + end +end diff --git a/design/forms/d2005/uTPLb_ComponentAbout.pas b/LockBox3/design/forms/d2005/uTPLb_ComponentAbout.pas similarity index 96% rename from design/forms/d2005/uTPLb_ComponentAbout.pas rename to LockBox3/design/forms/d2005/uTPLb_ComponentAbout.pas index 0062ce7..f23dcc5 100644 --- a/design/forms/d2005/uTPLb_ComponentAbout.pas +++ b/LockBox3/design/forms/d2005/uTPLb_ComponentAbout.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,523 +12,523 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit uTPLb_ComponentAbout; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; - -const - WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; - -type - TTPLb_fmComponentAbout = class(TForm) - pnlAbout: TPanel; - btnClose: TButton; - pgAboutContent: TPageControl; - tsMain: TTabSheet; - tsWelcome: TTabSheet; - tsProject: TTabSheet; - tsCopyLeft: TTabSheet; - tsAuthors: TTabSheet; - tsSupport: TTabSheet; - tsAlgorithms: TTabSheet; - Image1: TImage; - lblTitle: TLabel; - Label1: TLabel; - lblRunTimeVersion: TLabel; - lblDesignTimeVersion: TLabel; - Memo1: TMemo; - browserIntro: TWebBrowser; - Label4: TLabel; - Memo2: TMemo; - lblWebsite: TLabel; - Label7: TLabel; - Label8: TLabel; - Memo3: TMemo; - Label9: TLabel; - Memo4: TMemo; - lbxAuthors: TListBox; - imgAuthorPic: TImage; - Bevel1: TBevel; - lblAuthorEmail: TLabel; - lblAuthorWeb: TLabel; - Label12: TLabel; - memoSupport: TMemo; - memoHelp: TMemo; - Panel1: TPanel; - Label13: TLabel; - lblHashDisplayName: TLabel; - Label15: TLabel; - lbxHashFeatures: TListBox; - lblHashDefinitionURL: TLabel; - lblHashWikipediaURL: TLabel; - lblHashBlockSize: TLabel; - lblHashDigestSize: TLabel; - pnlCipherDescription: TPanel; - Label20: TLabel; - lblCipherDisplayName: TLabel; - Label22: TLabel; - lblCipherDefinitionURL: TLabel; - lblCipherWikipediaURL: TLabel; - lblCipherBlockSize: TLabel; - lbxCipherFeatures: TListBox; - Panel3: TPanel; - Label27: TLabel; - lblChainName: TLabel; - Label29: TLabel; - lblChainWikipedia: TLabel; - lbxChainFeatures: TListBox; - lblLogoAttribution: TLabel; - lblTpsfaIntro: TStaticText; - lblTpsfaContact: TStaticText; - lblWebLabel: TStaticText; - imgSean: TImage; - memoExtraCipherDescription: TMemo; - memoWelcomeInstructions: TMemo; - procedure lblTpsfaContactClick(Sender: TObject); - procedure OnURL_Click(Sender: TObject); - procedure lbxAuthorsClick(Sender: TObject); - procedure FormCreate(Sender: TObject); - private - { Private declarations } - - public - procedure UpdateAbout( SelectedComponent: TComponent); - end; - -var - TPLb_fmComponentAbout: TTPLb_fmComponentAbout; - -implementation - - - - - - - - - - - - - -uses uTPLb_InfoUtils, uTPLb_Hash, uTPLb_HashDsc, ShellAPI, uTPLb_StreamCipher, - uTPLb_Signatory, uTPLb_Codec, TypInfo, uTPLb_BlockCipher, Registry, - uTPLb_I18n, uTPLb_Decorators -{$IF CompilerVersion >= 21} - , Rtti -{$IFEND} - ; -{$R *.dfm} -{ -Content Plan -============ -Page 1: Main -0. Big Title: TurboPower LockBox 3 -2. Product definition statement. -3. Logo or nice graphic for LockBox 3 -7. run-time PE version number -8. design-time PE version -4. Brief statement about FOSS: LGPL - -Page 2: Welcome message -1. Embedded video by me introducing the component suite. - -Page 3: Brought to you by ... -Statement about project organisation and control (tpfsa) -5. tpfsa email -6. sourceforge url - -Page 4: CopyLeft -12. Copyright (mark and statement of application) -10. Statement of copying permission -9. LGPL 3 logo as clickable link -11. LGPL and GPL full wording - -Page 5: Authors -13. About authors. List - - 13.1 Name - 13.2 Photo - 13.3 Email -14 Statement welcoming contributions and adding to the list of authors. - -Page 6: Support -15 Statement about official support. -16 Statement about wiki documentation. - -Page 7: Algorithms -17 About Selected Hash - - 17.1 DisplayName - 17.2 Feature list - 17.3 Definition URL - 17.4 Wikipedia URL - 17.5 Block size - 17.6 Digest size -18 About Selected Chaining Mode - - DisplayName - Feature list - Definition URL - Wikipedia URL -19 About Selected Block Cipher - - DisplayName - Feature list - Definition URL - Wikipedia URL - Block size - -} -{ TTPLb_fmComponentAbout } - -procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); -var - Idx: integer; - Author, sAuthorEmail, sAuthorWeb: string; -begin -Idx := lbxAuthors.ItemIndex; -if Idx <> -1 then - Author := lbxAuthors.Items[ Idx] - else - Author := ''; -if SameText( Author, 'Sean B. Durkin') then - Idx := 0 - else if SameText( Author, 'David Barton') then - Idx := 1 - else if SameText( Author, 'Another contributor') then - Idx := -1 - else - Idx := -1; -case Idx of - -1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := ''; - sAuthorWeb := '' - end; - 0: begin - imgAuthorPic.Picture := imgSean.Picture; - sAuthorEmail := 'sean@seanbdurkin.id.au'; - sAuthorWeb := 'http:\\www.seanbdurkin.id.au' - end; - 1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := 'crypto@cityinthesky.co.uk'; - sAuthorWeb := '' - end; - end; -if sAuthorEmail <> '' then - lblAuthorEmail.Caption := DS_Email + sAuthorEmail - else - lblAuthorEmail.Caption := ''; -if sAuthorWeb <> '' then - lblAuthorWeb.Caption := DS_Web + sAuthorWeb - else - lblAuthorWeb.Caption := ''; -end; - -procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); -var - s: string; -begin -if (Sender is TLabel) then - begin - s := TLabel( Sender).Caption; - ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) - end -end; - - - -procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); -begin -lblAuthorEmail.Caption := ''; -lblAuthorWeb.Caption := ''; -browserIntro.Navigate( WelcomeVideo_URL) -end; - -procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); -begin -// -end; - -procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); -var - LibName: string; - FileVersion: string; - HashComp: THash; - HashDsc: IHashDsc; - s: string; - CodecComp: TCodec; - Chain: IBlockChainingModel; - StreamCipher: IStreamCipher; - BlockCipher: IBlockCipher; - ErrorPos: integer; - Reg: TRegistry; - isDebug: boolean; - Features1: TAlgorithmicFeatureSet; - ExtraCipherDescription: string; - -{$IF compilerversion >= 21} - ControlObject: IControlObject; - Controller: TObject; - LContext: TRttiContext; - LType: TRttiType; - Attr: TCustomAttribute; - DesignDesc: DesignDescription; -{$IFEND} - - procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); - var - Feat: TAlgorithmicFeature; - begin -{$IF compilerversion >= 16} - // Delphi 2005 or above - for Feat in Features do - begin - -{$ELSE} - // Delphi 7 or below - for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do - begin - if not (Feat in Features) then continue; -{$IFEND} - - s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); - Lbx.Items.Add( s) - end - end; - - function WikipediaRelativeURL( const Relative: string): string; - begin - result := Relative; - if (Pos( 'http:' , lowercase( result)) <> 1) and - (Pos( 'https:', lowercase( result)) <> 1) and - (result <> '') then - result := 'http://en.wikipedia.org/wiki/' + result - end; - - procedure Debug( const Line: string); - begin - if isDebug and (Line <> '') then - lbxHashFeatures.Items.Add( Line) - end; - - procedure DebugFmt( const Fmt: string; const Args: array of const); - begin - Debug( Format( Fmt, Args)) - end; - -begin -lbxHashFeatures.Clear; -Reg := TRegistry.Create; -try - Reg.RootKey := HKEY_CURRENT_USER; - isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and - Reg.ReadBool( 'Debug') -finally -Reg.Free -end; -ErrorPos := 0; -try -Get_TP_LockBox3_Info( LibName, FileVersion); -lblRunTimeVersion.Caption := Format( DS_RunTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); -Get_dclTP_LockBox3_Info( LibName, FileVersion); -lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); - -if SelectedComponent is THash then - HashComp := THash( SelectedComponent) - else - HashComp := nil; - -Inc( ErrorPos); -if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and - (HashComp.HashId <> '') then - HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) - else - HashDsc := nil; - -Inc( ErrorPos); -CodecComp := nil; -if SelectedComponent is TCodec then - CodecComp := TCodec( SelectedComponent); - -Inc( ErrorPos); -if (SelectedComponent is TSignatory) and - assigned( TSignatory( SelectedComponent).Codec) and - TSignatory( SelectedComponent).Codec.isAsymetric then - CodecComp := TSignatory( SelectedComponent).Codec; -Inc( ErrorPos); - -if assigned( HashComp) then - begin - lblHashDisplayName.Caption := HashComp.Hash; - PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) - end - else - lblHashDisplayName.Caption := DS_HashNotSelected; - -Inc( ErrorPos); -if assigned( HashDsc) then - begin - lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; - lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); - lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); - lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); - end - else - begin - lblHashDefinitionURL.Caption := ''; - lblHashWikipediaURL.Caption := ''; - lblHashBlockSize.Caption := ''; - lblHashDigestSize.Caption := ''; - end; - - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.ChainModeId <> '') then - Chain := CodecComp.CryptoLibrary - .BlockChainingModelIntfc( CodecComp.ChainModeId) - else - Chain := nil; - - -Inc( ErrorPos); -lbxChainFeatures.Items.Clear; -if assigned( Chain) then - begin - lblChainName.Caption := Chain.DisplayName; - PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); - lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) - end - else - begin - lblChainName.Caption := DS_ChainModeNotSelected; - lblChainWikipedia.Caption := '' - end; - - -Inc( ErrorPos); -if assigned( CodecComp) then - lblCipherDisplayName.Caption := CodecComp.Cipher - else - lblCipherDisplayName.Caption := DS_CodecNotSelected; - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.StreamCipherId <> '') then - StreamCipher := CodecComp.CryptoLibrary - .StreamCipherIntfc( CodecComp.StreamCipherId) - else - StreamCipher := nil; - -Inc( ErrorPos); -if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and - (CodecComp.BlockCipherId <> '') then - begin - BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); - if assigned( BlockCipher) then - StreamCipher := nil - end - else - BlockCipher := nil; - -ExtraCipherDescription := ''; -memoExtraCipherDescription.Visible := False; -pnlCipherDescription.Height := 209; - -{$IF compilerversion >= 21} -if not Supports( BlockCipher, IControlObject, ControlObject) then - Supports( StreamCipher, IControlObject, ControlObject); -if assigned( ControlObject) then - Controller := ControlObject.ControlObject - else - Controller := nil; -DesignDesc := nil; -if assigned( Controller) then - begin - LContext := TRttiContext.Create; - try - LType := LContext.GetType( Controller.ClassType); - for Attr in LType.GetAttributes do - begin - if not (Attr is DesignDescription) then continue; - DesignDesc := DesignDescription( Attr); - break - end; - if assigned( DesignDesc) then - ExtraCipherDescription := DesignDesc.Description - finally - LContext.Free - end - end; -{$IFEND} - -if ExtraCipherDescription <> '' then - begin - memoExtraCipherDescription.Height := 100; - pnlCipherDescription.Height := pnlCipherDescription.Height + - memoExtraCipherDescription.Height; - memoExtraCipherDescription.Visible := True; - memoExtraCipherDescription.Lines.Text := ExtraCipherDescription - end; - -Inc( ErrorPos); -lbxCipherFeatures.Items.Clear; -if assigned( StreamCipher) then - begin - ErrorPos := 20; - PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); - lblCipherBlockSize.Caption := '' - end - else if assigned( BlockCipher) then - begin - ErrorPos := 30; - Features1 := BlockCipher.Features; - Include( Features1, afBlockAdapter); - PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); - lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) - end - else - begin - ErrorPos := 40; - lblCipherDefinitionURL.Caption := ''; - lblCipherWikipediaURL.Caption := ''; - lblCipherBlockSize.Caption := '' - end -except on E: Exception do - begin - DebugFmt( 'ERROR! (%d)', [ErrorPos]); - DebugFmt( 'Class = %s', [E.ClassName]); - DebugFmt( 'Error = %s', [E.Message]) - end; -end -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit uTPLb_ComponentAbout; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; + +const + WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; + +type + TTPLb_fmComponentAbout = class(TForm) + pnlAbout: TPanel; + btnClose: TButton; + pgAboutContent: TPageControl; + tsMain: TTabSheet; + tsWelcome: TTabSheet; + tsProject: TTabSheet; + tsCopyLeft: TTabSheet; + tsAuthors: TTabSheet; + tsSupport: TTabSheet; + tsAlgorithms: TTabSheet; + Image1: TImage; + lblTitle: TLabel; + Label1: TLabel; + lblRunTimeVersion: TLabel; + lblDesignTimeVersion: TLabel; + Memo1: TMemo; + browserIntro: TWebBrowser; + Label4: TLabel; + Memo2: TMemo; + lblWebsite: TLabel; + Label7: TLabel; + Label8: TLabel; + Memo3: TMemo; + Label9: TLabel; + Memo4: TMemo; + lbxAuthors: TListBox; + imgAuthorPic: TImage; + Bevel1: TBevel; + lblAuthorEmail: TLabel; + lblAuthorWeb: TLabel; + Label12: TLabel; + memoSupport: TMemo; + memoHelp: TMemo; + Panel1: TPanel; + Label13: TLabel; + lblHashDisplayName: TLabel; + Label15: TLabel; + lbxHashFeatures: TListBox; + lblHashDefinitionURL: TLabel; + lblHashWikipediaURL: TLabel; + lblHashBlockSize: TLabel; + lblHashDigestSize: TLabel; + pnlCipherDescription: TPanel; + Label20: TLabel; + lblCipherDisplayName: TLabel; + Label22: TLabel; + lblCipherDefinitionURL: TLabel; + lblCipherWikipediaURL: TLabel; + lblCipherBlockSize: TLabel; + lbxCipherFeatures: TListBox; + Panel3: TPanel; + Label27: TLabel; + lblChainName: TLabel; + Label29: TLabel; + lblChainWikipedia: TLabel; + lbxChainFeatures: TListBox; + lblLogoAttribution: TLabel; + lblTpsfaIntro: TStaticText; + lblTpsfaContact: TStaticText; + lblWebLabel: TStaticText; + imgSean: TImage; + memoExtraCipherDescription: TMemo; + memoWelcomeInstructions: TMemo; + procedure lblTpsfaContactClick(Sender: TObject); + procedure OnURL_Click(Sender: TObject); + procedure lbxAuthorsClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { Private declarations } + + public + procedure UpdateAbout( SelectedComponent: TComponent); + end; + +var + TPLb_fmComponentAbout: TTPLb_fmComponentAbout; + +implementation + + + + + + + + + + + + + +uses uTPLb_InfoUtils, uTPLb_Hash, uTPLb_HashDsc, ShellAPI, uTPLb_StreamCipher, + uTPLb_Signatory, uTPLb_Codec, TypInfo, uTPLb_BlockCipher, Registry, + uTPLb_I18n, uTPLb_Decorators +{$IF CompilerVersion >= 21} + , Rtti +{$IFEND} + ; +{$R *.dfm} +{ +Content Plan +============ +Page 1: Main +0. Big Title: TurboPower LockBox 3 +2. Product definition statement. +3. Logo or nice graphic for LockBox 3 +7. run-time PE version number +8. design-time PE version +4. Brief statement about FOSS: LGPL + +Page 2: Welcome message +1. Embedded video by me introducing the component suite. + +Page 3: Brought to you by ... +Statement about project organisation and control (tpfsa) +5. tpfsa email +6. sourceforge url + +Page 4: CopyLeft +12. Copyright (mark and statement of application) +10. Statement of copying permission +9. LGPL 3 logo as clickable link +11. LGPL and GPL full wording + +Page 5: Authors +13. About authors. List - + 13.1 Name + 13.2 Photo + 13.3 Email +14 Statement welcoming contributions and adding to the list of authors. + +Page 6: Support +15 Statement about official support. +16 Statement about wiki documentation. + +Page 7: Algorithms +17 About Selected Hash - + 17.1 DisplayName + 17.2 Feature list + 17.3 Definition URL + 17.4 Wikipedia URL + 17.5 Block size + 17.6 Digest size +18 About Selected Chaining Mode - + DisplayName + Feature list + Definition URL + Wikipedia URL +19 About Selected Block Cipher - + DisplayName + Feature list + Definition URL + Wikipedia URL + Block size + +} +{ TTPLb_fmComponentAbout } + +procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); +var + Idx: integer; + Author, sAuthorEmail, sAuthorWeb: string; +begin +Idx := lbxAuthors.ItemIndex; +if Idx <> -1 then + Author := lbxAuthors.Items[ Idx] + else + Author := ''; +if SameText( Author, 'Sean B. Durkin') then + Idx := 0 + else if SameText( Author, 'David Barton') then + Idx := 1 + else if SameText( Author, 'Another contributor') then + Idx := -1 + else + Idx := -1; +case Idx of + -1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := ''; + sAuthorWeb := '' + end; + 0: begin + imgAuthorPic.Picture := imgSean.Picture; + sAuthorEmail := 'sean@seanbdurkin.id.au'; + sAuthorWeb := 'http:\\www.seanbdurkin.id.au' + end; + 1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := 'crypto@cityinthesky.co.uk'; + sAuthorWeb := '' + end; + end; +if sAuthorEmail <> '' then + lblAuthorEmail.Caption := DS_Email + sAuthorEmail + else + lblAuthorEmail.Caption := ''; +if sAuthorWeb <> '' then + lblAuthorWeb.Caption := DS_Web + sAuthorWeb + else + lblAuthorWeb.Caption := ''; +end; + +procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); +var + s: string; +begin +if (Sender is TLabel) then + begin + s := TLabel( Sender).Caption; + ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) + end +end; + + + +procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); +begin +lblAuthorEmail.Caption := ''; +lblAuthorWeb.Caption := ''; +browserIntro.Navigate( WelcomeVideo_URL) +end; + +procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); +begin +// +end; + +procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); +var + LibName: string; + FileVersion: string; + HashComp: THash; + HashDsc: IHashDsc; + s: string; + CodecComp: TCodec; + Chain: IBlockChainingModel; + StreamCipher: IStreamCipher; + BlockCipher: IBlockCipher; + ErrorPos: integer; + Reg: TRegistry; + isDebug: boolean; + Features1: TAlgorithmicFeatureSet; + ExtraCipherDescription: string; + +{$IF compilerversion >= 21} + ControlObject: IControlObject; + Controller: TObject; + LContext: TRttiContext; + LType: TRttiType; + Attr: TCustomAttribute; + DesignDesc: DesignDescription; +{$IFEND} + + procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); + var + Feat: TAlgorithmicFeature; + begin +{$IF compilerversion >= 16} + // Delphi 2005 or above + for Feat in Features do + begin + +{$ELSE} + // Delphi 7 or below + for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do + begin + if not (Feat in Features) then continue; +{$IFEND} + + s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); + Lbx.Items.Add( s) + end + end; + + function WikipediaRelativeURL( const Relative: string): string; + begin + result := Relative; + if (Pos( 'http:' , lowercase( result)) <> 1) and + (Pos( 'https:', lowercase( result)) <> 1) and + (result <> '') then + result := 'http://en.wikipedia.org/wiki/' + result + end; + + procedure Debug( const Line: string); + begin + if isDebug and (Line <> '') then + lbxHashFeatures.Items.Add( Line) + end; + + procedure DebugFmt( const Fmt: string; const Args: array of const); + begin + Debug( Format( Fmt, Args)) + end; + +begin +lbxHashFeatures.Clear; +Reg := TRegistry.Create; +try + Reg.RootKey := HKEY_CURRENT_USER; + isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and + Reg.ReadBool( 'Debug') +finally +Reg.Free +end; +ErrorPos := 0; +try +Get_TP_LockBox3_Info( LibName, FileVersion); +lblRunTimeVersion.Caption := Format( DS_RunTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); +Get_dclTP_LockBox3_Info( LibName, FileVersion); +lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); + +if SelectedComponent is THash then + HashComp := THash( SelectedComponent) + else + HashComp := nil; + +Inc( ErrorPos); +if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and + (HashComp.HashId <> '') then + HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) + else + HashDsc := nil; + +Inc( ErrorPos); +CodecComp := nil; +if SelectedComponent is TCodec then + CodecComp := TCodec( SelectedComponent); + +Inc( ErrorPos); +if (SelectedComponent is TSignatory) and + assigned( TSignatory( SelectedComponent).Codec) and + TSignatory( SelectedComponent).Codec.isAsymetric then + CodecComp := TSignatory( SelectedComponent).Codec; +Inc( ErrorPos); + +if assigned( HashComp) then + begin + lblHashDisplayName.Caption := HashComp.Hash; + PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) + end + else + lblHashDisplayName.Caption := DS_HashNotSelected; + +Inc( ErrorPos); +if assigned( HashDsc) then + begin + lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; + lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); + lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); + lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); + end + else + begin + lblHashDefinitionURL.Caption := ''; + lblHashWikipediaURL.Caption := ''; + lblHashBlockSize.Caption := ''; + lblHashDigestSize.Caption := ''; + end; + + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.ChainModeId <> '') then + Chain := CodecComp.CryptoLibrary + .BlockChainingModelIntfc( CodecComp.ChainModeId) + else + Chain := nil; + + +Inc( ErrorPos); +lbxChainFeatures.Items.Clear; +if assigned( Chain) then + begin + lblChainName.Caption := Chain.DisplayName; + PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); + lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) + end + else + begin + lblChainName.Caption := DS_ChainModeNotSelected; + lblChainWikipedia.Caption := '' + end; + + +Inc( ErrorPos); +if assigned( CodecComp) then + lblCipherDisplayName.Caption := CodecComp.Cipher + else + lblCipherDisplayName.Caption := DS_CodecNotSelected; + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.StreamCipherId <> '') then + StreamCipher := CodecComp.CryptoLibrary + .StreamCipherIntfc( CodecComp.StreamCipherId) + else + StreamCipher := nil; + +Inc( ErrorPos); +if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and + (CodecComp.BlockCipherId <> '') then + begin + BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); + if assigned( BlockCipher) then + StreamCipher := nil + end + else + BlockCipher := nil; + +ExtraCipherDescription := ''; +memoExtraCipherDescription.Visible := False; +pnlCipherDescription.Height := 209; + +{$IF compilerversion >= 21} +if not Supports( BlockCipher, IControlObject, ControlObject) then + Supports( StreamCipher, IControlObject, ControlObject); +if assigned( ControlObject) then + Controller := ControlObject.ControlObject + else + Controller := nil; +DesignDesc := nil; +if assigned( Controller) then + begin + LContext := TRttiContext.Create; + try + LType := LContext.GetType( Controller.ClassType); + for Attr in LType.GetAttributes do + begin + if not (Attr is DesignDescription) then continue; + DesignDesc := DesignDescription( Attr); + break + end; + if assigned( DesignDesc) then + ExtraCipherDescription := DesignDesc.Description + finally + LContext.Free + end + end; +{$IFEND} + +if ExtraCipherDescription <> '' then + begin + memoExtraCipherDescription.Height := 100; + pnlCipherDescription.Height := pnlCipherDescription.Height + + memoExtraCipherDescription.Height; + memoExtraCipherDescription.Visible := True; + memoExtraCipherDescription.Lines.Text := ExtraCipherDescription + end; + +Inc( ErrorPos); +lbxCipherFeatures.Items.Clear; +if assigned( StreamCipher) then + begin + ErrorPos := 20; + PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); + lblCipherBlockSize.Caption := '' + end + else if assigned( BlockCipher) then + begin + ErrorPos := 30; + Features1 := BlockCipher.Features; + Include( Features1, afBlockAdapter); + PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); + lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) + end + else + begin + ErrorPos := 40; + lblCipherDefinitionURL.Caption := ''; + lblCipherWikipediaURL.Caption := ''; + lblCipherBlockSize.Caption := '' + end +except on E: Exception do + begin + DebugFmt( 'ERROR! (%d)', [ErrorPos]); + DebugFmt( 'Class = %s', [E.ClassName]); + DebugFmt( 'Error = %s', [E.Message]) + end; +end +end; + +end. diff --git a/design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm b/LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm similarity index 97% rename from design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm rename to LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm index ac7cf0b..9280924 100644 --- a/design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm +++ b/LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.dfm @@ -1,319 +1,319 @@ -object mfmUInt64_to_Int64_Converter: TmfmUInt64_to_Int64_Converter - Left = 0 - Top = 0 - Caption = 'UInt64 to Int64 Convert Utility' - ClientHeight = 294 - ClientWidth = 562 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poScreenCenter - OnCreate = FormCreate - DesignSize = ( - 562 - 294) - PixelsPerInch = 96 - TextHeight = 13 - object memoIntro: TMemo - Left = 0 - Top = 0 - Width = 562 - Height = 89 - Align = alTop - Color = clInfoBk - Lines.Strings = ( - - 'This is a design-support utility intended to assist the extensio' + - 'n of' - 'Delphi programs to include support for Delphi 7.' - '' - - 'The Delphi 7 compiler does not recognise literals for UInt64 equ' + - 'al to' - - 'or greater than the MaxInt for SInt64. This program finds such l' + - 'iterals' - - 'and converts them into a format that the Delphi 7 compiler can u' + - 'nderstand.' - '' - - 'For example, if your source code for a Delphi 2010 looks like th' + - 'is ....' - '' - 'const X: UInt64 = $8000000000000001;' - '' - - 'The Delphi 7 compiler will bork at this. You really want to conv' + - 'ert that' - 'source into this ....' - '' - '{$IF compilerversion <= 15}' - ' // Delphi 7 case.' - ' // Equally well, we could have used the $ifdef VER150 pragma.' - 'type UInt64 = Int64;' - '' - 'const X: UInt64 = -$7FFFFFFFFFFFFFFF;' - '' - '{$ELSE}' - 'const X: UInt64 = $8000000000000001;' - '{$ENDIF}' - '' - '// if U >= $8000 0000 0000 0000' - '// S = -($1 0000 0000 0000 0000 - U)' - '// else' - '// S = U' - '') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object edtUInt64Value: TLabeledEdit - Left = 8 - Top = 112 - Width = 169 - Height = 24 - EditLabel.Width = 293 - EditLabel.Height = 13 - EditLabel.Caption = 'UInt64 value (16 hexidecimal digits 0..FFFF FFFF FFFF FFFF)' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [fsBold] - ParentFont = False - TabOrder = 1 - Text = 'FFFF FFFF FFFF FFFF' - end - object memoOutput: TMemo - Left = 304 - Top = 95 - Width = 258 - Height = 202 - Anchors = [akLeft, akTop, akRight, akBottom] - Color = clBlack - Font.Charset = DEFAULT_CHARSET - Font.Color = clLime - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [] - Lines.Strings = ( - '[Output goes here.]') - ParentFont = False - ReadOnly = True - ScrollBars = ssBoth - TabOrder = 2 - end - object btnCoerceOne: TButton - Left = 8 - Top = 142 - Width = 169 - Height = 25 - Action = actCoerceOne - TabOrder = 3 - end - object btnClearOutput: TButton - Left = 223 - Top = 111 - Width = 75 - Height = 25 - Action = actClear - TabOrder = 4 - end - object edtFileName: TButtonedEdit - Left = 8 - Top = 184 - Width = 290 - Height = 21 - Images = imglstActionGylphs16x16 - ParentShowHint = False - RightButton.DisabledImageIndex = 1 - RightButton.Hint = 'Browse to file' - RightButton.ImageIndex = 0 - RightButton.PressedImageIndex = 0 - RightButton.Visible = True - ShowHint = True - TabOrder = 5 - Text = 'YourPascalUnit.pas' - end - object btnCoerceFile: TButton - Left = 8 - Top = 211 - Width = 169 - Height = 25 - Action = actCoerceFile - TabOrder = 6 - end - object actlstMain: TActionList - Left = 360 - Top = 120 - object actCoerceOne: TAction - Caption = 'Coerce number' - OnExecute = actCoerceOneExecute - end - object actClear: TAction - Caption = 'Clear' - OnExecute = actClearExecute - OnUpdate = actClearUpdate - end - object actCoerceFile: TAction - Caption = 'Coerce file' - OnExecute = actCoerceFileExecute - OnUpdate = actCoerceFileUpdate - end - end - object imglstActionGylphs16x16: TImageList - Left = 360 - Top = 192 - Bitmap = { - 494C010102000A00040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600 - 0000000000003600000028000000400000001000000001002000000000000010 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000000000FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000007F7F7F007F7F - 7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F - 7F0000000000FFFFFF0000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000000FF - FF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FF - FF0000000000000000000000000000000000000000007F7F7F007F7F7F000000 - 0000FFFFFF000000000000000000000000000000000000000000000000000000 - 00007F7F7F0000000000FFFFFF00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFFFFF000000 - 000000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBF - BF0000FFFF00000000000000000000000000000000007F7F7F00FFFFFF007F7F - 7F0000000000FFFFFF0000000000000000000000000000000000000000000000 - 0000000000007F7F7F0000000000FFFFFF000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000FFFF00FFFF - FF000000000000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FF - FF00BFBFBF0000FFFF000000000000000000000000007F7F7F00FFFFFF000000 - 00007F7F7F0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF007F7F7F00FFFFFF000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFFFFF0000FF - FF00FFFFFF000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 - 0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F - 7F007F7F7F007F7F7F007F7F7F00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000FFFF00FFFF - FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF000000 - 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 - 0000000000000000000000000000000000000000000000000000000000007F7F - 7F00FFFFFF000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000FFFFFF0000FF - FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000 - 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 - 00000000000000000000000000000000000000000000FFFFFF00FFFFFF007F7F - 7F00000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000000000000000000000FFFF00FFFF - FF0000FFFF00FFFFFF0000FFFF00FFFFFF000000000000000000000000000000 - 000000000000000000000000000000000000000000007F7F7F0000000000FFFF - FF00000000000000000000000000000000007F7F7F007F7F7F007F7F7F000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000000FF - FF00FFFFFF0000FFFF00FFFFFF00000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000007F7F7F000000 - 0000FFFFFF00FFFFFF00FFFFFF007F7F7F000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000007F7F7F000000 - 00000000000000000000000000007F7F7F000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000007F7F - 7F007F7F7F007F7F7F007F7F7F00000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 000000000000000000000000000000000000424D3E000000000000003E000000 - 2800000040000000100000000100010000000000800000000000000000000000 - 000000000000000000000000FFFFFF00FFFFFFFF00000000FFFFFFFF00000000 - FFFFFFFF00000000FFFFE00700000000C00FC00B00000000800797F500000000 - 80038BFA0000000080019400000000008001980100000000800F9FE700000000 - 800F9F8F00000000801FAF1F00000000C0FFD0FF00000000C0FFE1FF00000000 - FFFFFFFF00000000FFFFFFFF00000000} - end - object dlgOpenUnit: TOpenTextFileDialog - DefaultExt = '.pas' - Filter = 'units|*.pas|text|*.txt|any kind of file|*.*' - Options = [ofReadOnly, ofHideReadOnly, ofFileMustExist, ofEnableSizing] - Title = 'Select your source file to convert' - Left = 440 - Top = 120 - end -end +object mfmUInt64_to_Int64_Converter: TmfmUInt64_to_Int64_Converter + Left = 0 + Top = 0 + Caption = 'UInt64 to Int64 Convert Utility' + ClientHeight = 294 + ClientWidth = 562 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + OnCreate = FormCreate + DesignSize = ( + 562 + 294) + PixelsPerInch = 96 + TextHeight = 13 + object memoIntro: TMemo + Left = 0 + Top = 0 + Width = 562 + Height = 89 + Align = alTop + Color = clInfoBk + Lines.Strings = ( + + 'This is a design-support utility intended to assist the extensio' + + 'n of' + 'Delphi programs to include support for Delphi 7.' + '' + + 'The Delphi 7 compiler does not recognise literals for UInt64 equ' + + 'al to' + + 'or greater than the MaxInt for SInt64. This program finds such l' + + 'iterals' + + 'and converts them into a format that the Delphi 7 compiler can u' + + 'nderstand.' + '' + + 'For example, if your source code for a Delphi 2010 looks like th' + + 'is ....' + '' + 'const X: UInt64 = $8000000000000001;' + '' + + 'The Delphi 7 compiler will bork at this. You really want to conv' + + 'ert that' + 'source into this ....' + '' + '{$IF compilerversion <= 15}' + ' // Delphi 7 case.' + ' // Equally well, we could have used the $ifdef VER150 pragma.' + 'type UInt64 = Int64;' + '' + 'const X: UInt64 = -$7FFFFFFFFFFFFFFF;' + '' + '{$ELSE}' + 'const X: UInt64 = $8000000000000001;' + '{$ENDIF}' + '' + '// if U >= $8000 0000 0000 0000' + '// S = -($1 0000 0000 0000 0000 - U)' + '// else' + '// S = U' + '') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object edtUInt64Value: TLabeledEdit + Left = 8 + Top = 112 + Width = 169 + Height = 24 + EditLabel.Width = 293 + EditLabel.Height = 13 + EditLabel.Caption = 'UInt64 value (16 hexidecimal digits 0..FFFF FFFF FFFF FFFF)' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 1 + Text = 'FFFF FFFF FFFF FFFF' + end + object memoOutput: TMemo + Left = 304 + Top = 95 + Width = 258 + Height = 202 + Anchors = [akLeft, akTop, akRight, akBottom] + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clLime + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + '[Output goes here.]') + ParentFont = False + ReadOnly = True + ScrollBars = ssBoth + TabOrder = 2 + end + object btnCoerceOne: TButton + Left = 8 + Top = 142 + Width = 169 + Height = 25 + Action = actCoerceOne + TabOrder = 3 + end + object btnClearOutput: TButton + Left = 223 + Top = 111 + Width = 75 + Height = 25 + Action = actClear + TabOrder = 4 + end + object edtFileName: TButtonedEdit + Left = 8 + Top = 184 + Width = 290 + Height = 21 + Images = imglstActionGylphs16x16 + ParentShowHint = False + RightButton.DisabledImageIndex = 1 + RightButton.Hint = 'Browse to file' + RightButton.ImageIndex = 0 + RightButton.PressedImageIndex = 0 + RightButton.Visible = True + ShowHint = True + TabOrder = 5 + Text = 'YourPascalUnit.pas' + end + object btnCoerceFile: TButton + Left = 8 + Top = 211 + Width = 169 + Height = 25 + Action = actCoerceFile + TabOrder = 6 + end + object actlstMain: TActionList + Left = 360 + Top = 120 + object actCoerceOne: TAction + Caption = 'Coerce number' + OnExecute = actCoerceOneExecute + end + object actClear: TAction + Caption = 'Clear' + OnExecute = actClearExecute + OnUpdate = actClearUpdate + end + object actCoerceFile: TAction + Caption = 'Coerce file' + OnExecute = actCoerceFileExecute + OnUpdate = actCoerceFileUpdate + end + end + object imglstActionGylphs16x16: TImageList + Left = 360 + Top = 192 + Bitmap = { + 494C010102000A00040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000001000000001002000000000000010 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000007F7F7F007F7F + 7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F + 7F0000000000FFFFFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000FF + FF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FF + FF0000000000000000000000000000000000000000007F7F7F007F7F7F000000 + 0000FFFFFF000000000000000000000000000000000000000000000000000000 + 00007F7F7F0000000000FFFFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFFFFF000000 + 000000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBF + BF0000FFFF00000000000000000000000000000000007F7F7F00FFFFFF007F7F + 7F0000000000FFFFFF0000000000000000000000000000000000000000000000 + 0000000000007F7F7F0000000000FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000FFFF00FFFF + FF000000000000FFFF00BFBFBF0000FFFF00BFBFBF0000FFFF00BFBFBF0000FF + FF00BFBFBF0000FFFF000000000000000000000000007F7F7F00FFFFFF000000 + 00007F7F7F0000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF007F7F7F00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFFFFF0000FF + FF00FFFFFF000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 + 0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F + 7F007F7F7F007F7F7F007F7F7F00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000FFFF00FFFF + FF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF000000 + 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 + 0000000000000000000000000000000000000000000000000000000000007F7F + 7F00FFFFFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000FFFFFF0000FF + FF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000 + 000000000000000000000000000000000000000000007F7F7F00FFFFFF000000 + 00000000000000000000000000000000000000000000FFFFFF00FFFFFF007F7F + 7F00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000FFFF00FFFF + FF0000FFFF00FFFFFF0000FFFF00FFFFFF000000000000000000000000000000 + 000000000000000000000000000000000000000000007F7F7F0000000000FFFF + FF00000000000000000000000000000000007F7F7F007F7F7F007F7F7F000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000FF + FF00FFFFFF0000FFFF00FFFFFF00000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000007F7F7F000000 + 0000FFFFFF00FFFFFF00FFFFFF007F7F7F000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000007F7F7F000000 + 00000000000000000000000000007F7F7F000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000007F7F + 7F007F7F7F007F7F7F007F7F7F00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000100000000100010000000000800000000000000000000000 + 000000000000000000000000FFFFFF00FFFFFFFF00000000FFFFFFFF00000000 + FFFFFFFF00000000FFFFE00700000000C00FC00B00000000800797F500000000 + 80038BFA0000000080019400000000008001980100000000800F9FE700000000 + 800F9F8F00000000801FAF1F00000000C0FFD0FF00000000C0FFE1FF00000000 + FFFFFFFF00000000FFFFFFFF00000000} + end + object dlgOpenUnit: TOpenTextFileDialog + DefaultExt = '.pas' + Filter = 'units|*.pas|text|*.txt|any kind of file|*.*' + Options = [ofReadOnly, ofHideReadOnly, ofFileMustExist, ofEnableSizing] + Title = 'Select your source file to convert' + Left = 440 + Top = 120 + end +end diff --git a/design/forms/d2010/umfmUInt64_to_Int64_Converter.pas b/LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.pas similarity index 95% rename from design/forms/d2010/umfmUInt64_to_Int64_Converter.pas rename to LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.pas index 46cd696..5e39314 100644 --- a/design/forms/d2010/umfmUInt64_to_Int64_Converter.pas +++ b/LockBox3/design/forms/d2010/umfmUInt64_to_Int64_Converter.pas @@ -1,281 +1,281 @@ -unit umfmUInt64_to_Int64_Converter; -// This file is not part of lockbox. It is merely a design-support tool, -// and is shown here for the curious. - SBD. -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, ExtCtrls, StdCtrls, ActnList, ImgList, ExtDlgs; - -type - TmfmUInt64_to_Int64_Converter = class(TForm) - memoIntro: TMemo; - edtUInt64Value: TLabeledEdit; - memoOutput: TMemo; - actlstMain: TActionList; - btnCoerceOne: TButton; - actCoerceOne: TAction; - btnClearOutput: TButton; - actClear: TAction; - edtFileName: TButtonedEdit; - imglstActionGylphs16x16: TImageList; - dlgOpenUnit: TOpenTextFileDialog; - actCoerceFile: TAction; - btnCoerceFile: TButton; - procedure FormCreate(Sender: TObject); - procedure actCoerceOneExecute(Sender: TObject); - procedure actClearUpdate(Sender: TObject); - procedure actClearExecute(Sender: TObject); - procedure actCoerceFileUpdate(Sender: TObject); - procedure actCoerceFileExecute(Sender: TObject); - - private - procedure edtFileName_OnRightButtonClick( Sender: TObject); - - public - procedure ClearOutput; - procedure Put( const Line: string); - procedure PutFmt( const Fmt: string; const Args: array of const); - end; - -var - mfmUInt64_to_Int64_Converter: TmfmUInt64_to_Int64_Converter; - -implementation - - - - - - - - - - - - - - - - -uses Character; -{$R *.dfm} - -function Coerce_UInt64_to_Int64( V_UInt64: UInt64; var isNeg: boolean): Int64; -// Coerces a UInt64 value into its equivalent SInt64 by modulo arithmetic. -// The returned value is the absolute value of the coerced value. -// Eg. $FFFFFFFFFFFFFFFF ==> $0000000000000001 & isNeg = True; -// Eg. $7FFFFFFFFFFFFFFF ==> $7FFFFFFFFFFFFFFF & isNeg = False; - -const - HalfRange = $8000000000000000; -var - t: UInt64; -begin -isNeg := V_UInt64 >= HalfRange; -if not isNeg then - result := V_UInt64 - else - begin - t := V_UInt64 - HalfRange; - result := Int64( t); - result := - result; - result := result + HalfRange; - Assert( UInt64( - result) = V_UInt64, 'Failed self-test!') - end -end; - - - -function Coerce_UInt64Str_to_Int64Str( - const V_UInt64Str: string; - var isNeg: boolean; - var V_Int64Str, ErrMsg: string): boolean; -var - s: string; - j: integer; - V_UInt64: UInt64; - Code: integer; - V_SInt64: Int64; - - function Check( Ok: boolean; const ErrMsg1: string): boolean; - begin - result := Ok; - if (not result) and (s <> '') then - ErrMsg := ErrMsg1 - end; - -begin -result := False; -isNeg := False; -V_Int64Str := ''; -ErrMsg := ''; - -if not Check( Trim( V_UInt64Str) <> '', 'Input empty.') then exit; - -// V_UInt64Str should begin with $ -Val( V_UInt64Str, V_UInt64, Code); -if not Check( Code = 0, 'Not a valid integer in UInt64 range.') then exit; - -V_SInt64 := Coerce_UInt64_to_Int64( V_UInt64, isNeg); -if not isNeg then - V_Int64Str := Format( '$%.16x', [V_UInt64]) - else - begin - V_Int64Str := Format( '-$%.16x', [V_SInt64]); - if not Check( UInt64( - V_SInt64) = V_UInt64, 'Failed self-test!') then exit - end; -result := True -end; - - - - - -procedure TmfmUInt64_to_Int64_Converter.actClearExecute( Sender: TObject); -begin -ClearOutput -end; - -procedure TmfmUInt64_to_Int64_Converter.actClearUpdate( Sender: TObject); -begin -(Sender as TAction).Enabled := memoOutput.Lines.Count > 0 -end; - -function isHexadecimal( ch: Char): boolean; -begin -result := CharInSet( ch, ['0'..'9','A'..'F']) -end; - - - -procedure TmfmUInt64_to_Int64_Converter.actCoerceFileExecute( Sender: TObject); -var - Lines: TStrings; - j, i, k, Len: Integer; - ch: Char; - Line: string; - isValid: boolean; - Processed: string; - Match: string; - isNeg: boolean; - V_Int64Str, ErrMsg: string; - Substitute: string; - -begin -try -Lines := TStringList.Create; -Lines.LoadFromFile( edtFileName.Text); -try -for j := 0 to Lines.Count - 1 do - begin - Line := Lines[j]; - Processed := ''; - i := 1; - Len := Length( Line); - while i <= (Len - 16) do - begin - ch := Line[i]; - isValid := False; - if (ch = '$') and ((i <= 1) or (Line[i-1] <> '-')) then - begin - isValid := True; - for k := 1 to 16 do - begin - ch := Upcase( Line[ i + k ]); - isValid := isHexadecimal( ch); - if not isValid then break - end - end; - if isValid then - begin - Processed := Processed + Copy( Line, 1, i - 1); - Match := Copy( Line, i, 17); - Delete( Line, 1, i + 16); - Len := Length( Line); - i := 0; - if Coerce_UInt64Str_to_Int64Str( Match, isNeg, V_Int64Str, ErrMsg) then - Substitute := V_Int64Str - else - Substitute := Match + '{}'; - Processed := Processed + '{}uint64( ' + Substitute + '){}' - end; - Inc( i) - end; - Lines[j] := Processed + Line; - Put( Lines[j]) - end; -finally - Lines.Free -end; -except on e:exception do - PutFmt( 'ERROR ! %s: %s', [e.ClassName, e.Message]) - end; -end; - - - -procedure TmfmUInt64_to_Int64_Converter.actCoerceFileUpdate( Sender: TObject); -begin -(Sender as TAction).Enabled := edtFileName.Text <> '' -end; - -procedure TmfmUInt64_to_Int64_Converter.actCoerceOneExecute(Sender: TObject); -var - s: string; - j: integer; - isNeg: boolean; - V_Int64Str, ErrMsg: string; - - function Check( Ok: boolean; const ErrMsg: string): boolean; - begin - result := Ok; - if (not result) and (s <> '') then - PutFmt( 'Error: %s', [ErrMsg]) - end; - -begin -s := edtUInt64Value.Text; -PutFmt( 'Coercing %s from UInt64 to Int64', [s]); -for j := Length( s) downto 1 do - if s[j] = ' ' then - Delete( s, j, 1); - -if Check( s <> '', 'Input empty.') and - Check( Coerce_UInt64Str_to_Int64Str( '$'+s, isNeg, V_Int64Str, ErrMsg), - ErrMsg) then - PutFmt( '(signed) Int64 equivalent = %s', [V_Int64Str]) -end; - - -procedure TmfmUInt64_to_Int64_Converter.ClearOutput; -begin -memoOutput.Clear -end; - -procedure TmfmUInt64_to_Int64_Converter.edtFileName_OnRightButtonClick( - Sender: TObject); -begin -dlgOpenUnit.FileName := (Sender as TButtonedEdit).Text; -if dlgOpenUnit.Execute then - TButtonedEdit( Sender).Text := dlgOpenUnit.FileName -end; - -procedure TmfmUInt64_to_Int64_Converter.FormCreate( Sender: TObject); -begin -ClearOutput; -edtFileName.OnRightButtonClick := edtFileName_OnRightButtonClick -end; - -procedure TmfmUInt64_to_Int64_Converter.Put( const Line: string); -begin -memoOutput.Lines.Add( Line) -end; - -procedure TmfmUInt64_to_Int64_Converter.PutFmt( const Fmt: string; - const Args: array of const); -begin -Put( Format( Fmt, Args)) -end; - -end. +unit umfmUInt64_to_Int64_Converter; +// This file is not part of lockbox. It is merely a design-support tool, +// and is shown here for the curious. - SBD. +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, ActnList, ImgList, ExtDlgs; + +type + TmfmUInt64_to_Int64_Converter = class(TForm) + memoIntro: TMemo; + edtUInt64Value: TLabeledEdit; + memoOutput: TMemo; + actlstMain: TActionList; + btnCoerceOne: TButton; + actCoerceOne: TAction; + btnClearOutput: TButton; + actClear: TAction; + edtFileName: TButtonedEdit; + imglstActionGylphs16x16: TImageList; + dlgOpenUnit: TOpenTextFileDialog; + actCoerceFile: TAction; + btnCoerceFile: TButton; + procedure FormCreate(Sender: TObject); + procedure actCoerceOneExecute(Sender: TObject); + procedure actClearUpdate(Sender: TObject); + procedure actClearExecute(Sender: TObject); + procedure actCoerceFileUpdate(Sender: TObject); + procedure actCoerceFileExecute(Sender: TObject); + + private + procedure edtFileName_OnRightButtonClick( Sender: TObject); + + public + procedure ClearOutput; + procedure Put( const Line: string); + procedure PutFmt( const Fmt: string; const Args: array of const); + end; + +var + mfmUInt64_to_Int64_Converter: TmfmUInt64_to_Int64_Converter; + +implementation + + + + + + + + + + + + + + + + +uses Character; +{$R *.dfm} + +function Coerce_UInt64_to_Int64( V_UInt64: UInt64; var isNeg: boolean): Int64; +// Coerces a UInt64 value into its equivalent SInt64 by modulo arithmetic. +// The returned value is the absolute value of the coerced value. +// Eg. $FFFFFFFFFFFFFFFF ==> $0000000000000001 & isNeg = True; +// Eg. $7FFFFFFFFFFFFFFF ==> $7FFFFFFFFFFFFFFF & isNeg = False; + +const + HalfRange = $8000000000000000; +var + t: UInt64; +begin +isNeg := V_UInt64 >= HalfRange; +if not isNeg then + result := V_UInt64 + else + begin + t := V_UInt64 - HalfRange; + result := Int64( t); + result := - result; + result := result + HalfRange; + Assert( UInt64( - result) = V_UInt64, 'Failed self-test!') + end +end; + + + +function Coerce_UInt64Str_to_Int64Str( + const V_UInt64Str: string; + var isNeg: boolean; + var V_Int64Str, ErrMsg: string): boolean; +var + s: string; + j: integer; + V_UInt64: UInt64; + Code: integer; + V_SInt64: Int64; + + function Check( Ok: boolean; const ErrMsg1: string): boolean; + begin + result := Ok; + if (not result) and (s <> '') then + ErrMsg := ErrMsg1 + end; + +begin +result := False; +isNeg := False; +V_Int64Str := ''; +ErrMsg := ''; + +if not Check( Trim( V_UInt64Str) <> '', 'Input empty.') then exit; + +// V_UInt64Str should begin with $ +Val( V_UInt64Str, V_UInt64, Code); +if not Check( Code = 0, 'Not a valid integer in UInt64 range.') then exit; + +V_SInt64 := Coerce_UInt64_to_Int64( V_UInt64, isNeg); +if not isNeg then + V_Int64Str := Format( '$%.16x', [V_UInt64]) + else + begin + V_Int64Str := Format( '-$%.16x', [V_SInt64]); + if not Check( UInt64( - V_SInt64) = V_UInt64, 'Failed self-test!') then exit + end; +result := True +end; + + + + + +procedure TmfmUInt64_to_Int64_Converter.actClearExecute( Sender: TObject); +begin +ClearOutput +end; + +procedure TmfmUInt64_to_Int64_Converter.actClearUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := memoOutput.Lines.Count > 0 +end; + +function isHexadecimal( ch: Char): boolean; +begin +result := CharInSet( ch, ['0'..'9','A'..'F']) +end; + + + +procedure TmfmUInt64_to_Int64_Converter.actCoerceFileExecute( Sender: TObject); +var + Lines: TStrings; + j, i, k, Len: Integer; + ch: Char; + Line: string; + isValid: boolean; + Processed: string; + Match: string; + isNeg: boolean; + V_Int64Str, ErrMsg: string; + Substitute: string; + +begin +try +Lines := TStringList.Create; +Lines.LoadFromFile( edtFileName.Text); +try +for j := 0 to Lines.Count - 1 do + begin + Line := Lines[j]; + Processed := ''; + i := 1; + Len := Length( Line); + while i <= (Len - 16) do + begin + ch := Line[i]; + isValid := False; + if (ch = '$') and ((i <= 1) or (Line[i-1] <> '-')) then + begin + isValid := True; + for k := 1 to 16 do + begin + ch := Upcase( Line[ i + k ]); + isValid := isHexadecimal( ch); + if not isValid then break + end + end; + if isValid then + begin + Processed := Processed + Copy( Line, 1, i - 1); + Match := Copy( Line, i, 17); + Delete( Line, 1, i + 16); + Len := Length( Line); + i := 0; + if Coerce_UInt64Str_to_Int64Str( Match, isNeg, V_Int64Str, ErrMsg) then + Substitute := V_Int64Str + else + Substitute := Match + '{}'; + Processed := Processed + '{}uint64( ' + Substitute + '){}' + end; + Inc( i) + end; + Lines[j] := Processed + Line; + Put( Lines[j]) + end; +finally + Lines.Free +end; +except on e:exception do + PutFmt( 'ERROR ! %s: %s', [e.ClassName, e.Message]) + end; +end; + + + +procedure TmfmUInt64_to_Int64_Converter.actCoerceFileUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := edtFileName.Text <> '' +end; + +procedure TmfmUInt64_to_Int64_Converter.actCoerceOneExecute(Sender: TObject); +var + s: string; + j: integer; + isNeg: boolean; + V_Int64Str, ErrMsg: string; + + function Check( Ok: boolean; const ErrMsg: string): boolean; + begin + result := Ok; + if (not result) and (s <> '') then + PutFmt( 'Error: %s', [ErrMsg]) + end; + +begin +s := edtUInt64Value.Text; +PutFmt( 'Coercing %s from UInt64 to Int64', [s]); +for j := Length( s) downto 1 do + if s[j] = ' ' then + Delete( s, j, 1); + +if Check( s <> '', 'Input empty.') and + Check( Coerce_UInt64Str_to_Int64Str( '$'+s, isNeg, V_Int64Str, ErrMsg), + ErrMsg) then + PutFmt( '(signed) Int64 equivalent = %s', [V_Int64Str]) +end; + + +procedure TmfmUInt64_to_Int64_Converter.ClearOutput; +begin +memoOutput.Clear +end; + +procedure TmfmUInt64_to_Int64_Converter.edtFileName_OnRightButtonClick( + Sender: TObject); +begin +dlgOpenUnit.FileName := (Sender as TButtonedEdit).Text; +if dlgOpenUnit.Execute then + TButtonedEdit( Sender).Text := dlgOpenUnit.FileName +end; + +procedure TmfmUInt64_to_Int64_Converter.FormCreate( Sender: TObject); +begin +ClearOutput; +edtFileName.OnRightButtonClick := edtFileName_OnRightButtonClick +end; + +procedure TmfmUInt64_to_Int64_Converter.Put( const Line: string); +begin +memoOutput.Lines.Add( Line) +end; + +procedure TmfmUInt64_to_Int64_Converter.PutFmt( const Fmt: string; + const Args: array of const); +begin +Put( Format( Fmt, Args)) +end; + +end. diff --git a/design/forms/d7-/uTPLb_ComponentAbout.dfm b/LockBox3/design/forms/d7-/uTPLb_ComponentAbout.dfm similarity index 98% rename from design/forms/d7-/uTPLb_ComponentAbout.dfm rename to LockBox3/design/forms/d7-/uTPLb_ComponentAbout.dfm index 906b462..79db596 100644 --- a/design/forms/d7-/uTPLb_ComponentAbout.dfm +++ b/LockBox3/design/forms/d7-/uTPLb_ComponentAbout.dfm @@ -1,3181 +1,3181 @@ -object TPLb_fmComponentAbout: TTPLb_fmComponentAbout - Left = 476 - Top = 94 - Width = 648 - Height = 476 - Caption = 'Component About' - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poDefaultPosOnly - OnCreate = FormCreate - DesignSize = ( - 640 - 442) - PixelsPerInch = 96 - TextHeight = 13 - object pnlAbout: TPanel - Left = 0 - Top = 0 - Width = 641 - Height = 410 - Anchors = [akLeft, akTop, akRight, akBottom] - Caption = 'About Box to be developed!' - TabOrder = 0 - object pgAboutContent: TPageControl - Left = 1 - Top = 1 - Width = 639 - Height = 408 - ActivePage = tsMain - Align = alClient - TabOrder = 0 - object tsMain: TTabSheet - Caption = 'Main' - DesignSize = ( - 631 - 380) - object Image1: TImage - Left = 0 - Top = 0 - Width = 225 - Height = 329 - Picture.Data = { - 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 - 480000FFE1004045786966000049492A0008000000010069870400010000001A - 000000000000000100869202000B0000002C000000000000004170706C654D61 - 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 - 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 - 50504C0000000049454320735247420000000000000000000000000000F6D600 - 0100000000D32D48502020000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000116370727400 - 0001500000003364657363000001840000007377747074000001F80000001462 - 6B70740000020C000000147258595A00000220000000146758595A0000023400 - 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 - 0002BC0000007976756564000003380000008676696577000003C0000000246C - 756D69000003E4000000146D656173000003F800000024746563680000041C00 - 00000C72545243000004280000080C67545243000004280000080C6254524300 - 0004280000080C7465787400000000436F707972696768742028632920313939 - 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 - 00000000000019735247422049454336313936362D322E312039393132303300 - 0000000000000000000019735247422049454336313936362D322E3120393931 - 3230330000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000058595A20000000000000F3510001000000 - 0116CC58595A200000000000000000000000000000000058595A200000000000 - 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 - 595A2000000000000024A000000F840000B6CF64657363000000000000000549 - 4543200000000000000000000000054945432000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000064657363000000000000001F73 - 524742204945432036313936362D322E31207352474220393931323033000000 - 00000000000000001F73524742204945432036313936362D322E312073524742 - 2039393132303300000000000000000000000000000000000000000000000000 - 00000000000000000000000000000064657363000000000000002C5265666572 - 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 - 36362D322E3100000000000000000000002C5265666572656E63652056696577 - 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 - 0000000000000000000000000000000000000000000000766965770000000000 - 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 - 000000004C09560050000000571FE76D65617300000000000000010000000000 - 00000000000000000000000000028F0000000273696720000000004352542063 - 757276000000000000040000000005000A000F00140019001E00230028002D00 - 320037003B00400045004A004F00540059005E00630068006D00720077007C00 - 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 - D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 - 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 - 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 - 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 - B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 - 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 - 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 - 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 - 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 - 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 - 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 - 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A - F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C - 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E - 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F - CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 - AA11C911E81207122612451264128412A312C312E31303132313431363138313 - A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 - BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 - F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A - 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C - CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F - 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 - 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 - 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 - 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B - 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E - 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 - F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 - 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 - 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D - 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 - 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 - 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 - A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E - 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 - C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 - 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C - 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 - A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 - E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C - 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 - F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 - B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D - A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 - BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 - FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 - 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 - 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D - D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 - C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB - E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 - 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA - B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 - 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA - 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 - 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA - 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 - DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB - 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 - 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD - 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 - 0202020202040303020305040505050404040506070605050706040406090607 - 08080808080506090A09080A07080808FFDB0043010101010202020402020408 - 0504050808080808080808080808080808080808080808080808080808080808 - 080808080808080808080808080808080808080808FFC0001108014A00EA0301 - 2200021101031101FFC4001F0000010501010101010100000000000000000102 - 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 - 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 - 627282090A161718191A25262728292A3435363738393A434445464748494A53 - 5455565758595A636465666768696A737475767778797A838485868788898A92 - 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 - C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA - FFC4001F0100030101010101010101010000000000000102030405060708090A - 0BFFC400B5110002010204040304070504040001027700010203110405213106 - 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 - F11718191A262728292A35363738393A434445464748494A535455565758595A - 636465666768696A737475767778797A82838485868788898A92939495969798 - 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 - D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 - 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F - B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 - 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C - D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 - C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 - DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 - 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C - 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D - B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D - FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB - 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 - 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 - ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB - AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F - 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 - EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 - DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F - 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 - 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 - C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB - 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 - 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 - A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 - 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA - 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 - D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 - 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 - 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 - 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D - 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D - 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E - BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 - 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 - B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 - 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF - 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF - B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 - 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 - 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 - 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 - 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E - DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 - EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 - 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 - C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 - 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 - 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 - 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 - 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 - 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 - 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 - E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE - AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 - 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 - 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC - AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC - 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 - EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 - 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE - 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 - 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A - 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C - FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 - 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E - 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 - 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC - 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 - 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A - BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF - FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB - 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 - 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 - 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 - DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 - 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 - 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 - 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A - BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F - 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B - E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C - 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 - 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A - 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 - 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD - 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 - A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 - C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D - C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC - B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE - 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 - B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 - 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 - 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 - 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 - B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 - 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 - 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 - 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A - BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D - 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 - 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 - 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D - FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 - 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 - 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 - BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 - 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 - B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 - 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 - D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E - F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F - B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B - 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 - E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A - BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 - DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 - D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF - C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF - 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 - D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 - 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 - 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D - B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 - 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB - E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 - C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 - 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 - ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 - E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 - 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 - 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 - D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 - 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 - B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 - 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E - C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A - F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 - 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 - 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C - D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 - C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 - 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 - 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 - 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 - B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 - EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F - D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 - 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 - 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 - F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 - 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 - 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD - B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 - 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 - 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 - CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 - 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 - F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 - 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F - 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 - 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A - FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A - EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D - 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F - 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B - E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 - 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD - FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA - E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 - F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 - 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 - 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 - 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 - 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 - FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 - 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB - 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 - F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 - CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 - 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 - 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 - BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 - DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 - ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 - 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 - 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF - 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA - EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 - 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 - 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 - 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 - FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB - 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 - D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB - 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED - 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 - 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD - 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 - B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 - 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 - 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C - 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 - A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC - 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 - 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC - D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 - 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C - 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 - FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B - CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 - 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E - 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 - B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 - AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 - C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 - FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 - 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 - 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE - 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 - 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 - 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 - F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 - 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC - 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 - 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD - E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 - 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B - E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA - DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 - 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 - DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 - 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 - D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 - FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B - F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 - E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF - 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B - 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 - 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 - 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 - 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 - 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F - C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 - B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 - 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 - 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E - 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC - FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F - A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B - 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 - E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F - 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C - F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C - 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE - 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 - 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D - D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 - 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 - 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 - 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA - E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 - F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF - 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 - E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F - 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 - 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 - BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B - C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 - B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 - 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F - 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F - C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 - 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 - 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 - 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 - 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F - ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C - C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B - F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B - 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF - AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA - 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 - 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 - EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 - 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 - 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D - 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C - C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 - EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 - 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 - BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 - 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF - 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 - 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 - 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 - 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 - 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 - 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 - 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E - CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 - D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 - 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 - 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F - B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB - 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F - 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 - 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B - 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 - 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF - 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B - E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B - 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA - 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 - DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 - 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A - F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC - 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D - 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 - DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF - 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED - 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B - F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 - DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 - D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B - F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 - 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 - 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E - 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E - 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B - E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F - 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 - 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 - C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 - 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD - 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE - 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 - F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E - 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC - 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 - D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE - BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C - 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 - D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E - 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 - 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 - A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC - E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E - 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 - B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 - 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 - 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B - B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB - FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 - C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA - D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C - 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED - C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 - 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 - 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B - 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 - 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 - 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 - 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F - 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 - 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD - 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A - CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC - 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 - 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF - C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E - 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 - F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF - D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 - 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 - C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC - 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 - 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF - 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 - 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE - DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 - AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 - C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 - FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF - 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F - 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 - A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F - E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 - 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 - F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 - C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE - 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 - 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 - 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 - C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E - 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 - 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA - AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 - E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 - 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD - 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 - FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 - 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 - E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 - 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 - E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 - 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB - 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED - 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C - DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 - DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 - 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D - FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F - 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 - 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 - 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 - FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 - E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF - E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC - 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 - A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF - BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 - C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 - D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 - 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 - 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 - 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F - F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 - B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 - BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 - FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 - 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF - 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED - CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 - 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF - 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D - 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A - BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 - 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 - 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 - 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 - F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B - 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 - E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C - 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF - B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 - A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 - 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 - 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 - 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A - 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A - CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D - 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F - 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 - FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C - 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 - E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 - EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF - 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 - DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 - DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 - FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC - 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 - B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 - 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 - FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 - 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 - 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D - BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 - 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C - 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA - B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 - 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA - 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE - D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 - C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 - DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC - F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 - 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD - 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 - 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD - 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA - C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE - CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 - 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB - DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA - BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 - 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A - E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 - 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 - 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 - 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 - 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F - FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 - 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D - FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D - C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F - 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED - 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 - BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 - AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 - E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD - D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 - 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 - 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB - 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 - 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 - CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 - 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B - 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E - 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 - 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 - F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C - F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 - E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 - 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B - 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 - D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 - C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD - EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF - 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 - F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F - 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 - 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 - 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 - FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 - DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 - 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E - D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 - 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 - F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F - 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 - 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E - 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 - A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 - E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 - 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 - 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 - 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 - 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E - 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 - 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD - B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 - A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C - 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 - E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E - 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F - ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E - F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD - 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B - C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 - A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 - A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 - 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 - 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 - 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A - 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E - D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D - 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA - C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF - 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E - DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A - 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 - 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A - 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB - 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA - 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF - 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F - 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 - FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF - C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C - 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 - 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 - 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 - DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB - D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 - ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 - 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 - BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 - 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF - 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 - 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 - 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 - 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 - 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 - D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D - 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF - ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B - 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 - EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D - C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 - 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F - B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 - 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D - A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 - 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 - 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 - D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 - 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 - A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 - D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 - D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 - DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B - 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D - 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 - FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F - 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 - 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B - 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E - AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 - C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 - F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 - 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB - C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 - 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F - C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 - 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA - 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F - B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C - AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 - 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F - BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 - A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD - 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA - 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B - 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE - 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 - 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 - D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 - FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 - 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA - 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 - 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 - 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 - 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD - 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF - 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D - F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA - AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 - 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 - 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 - 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 - 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE - EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 - 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 - 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 - 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 - BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C - C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 - E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 - 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E - 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 - 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA - 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 - 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C - 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 - 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 - BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 - DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E - 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 - 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 - 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 - 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 - 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 - 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 - 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 - C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 - 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 - 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 - 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 - 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 - 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 - F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 - 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 - 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 - B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 - 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB - 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF - 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F - CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 - F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 - 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC - 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 - 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 - 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 - DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 - 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC - 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB - 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 - C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 - 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 - A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 - 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 - 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 - 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 - 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 - BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A - EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 - D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 - 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 - EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C - 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 - 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 - 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 - 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 - F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D - 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C - 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 - 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F - 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 - DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF - 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B - 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC - B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 - F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 - 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB - 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C - D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 - CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E - 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 - 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A - AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 - AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF - 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 - 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 - 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E - 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 - BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 - F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E - 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 - 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B - 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 - 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 - 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 - 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED - 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D - 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 - F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 - 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA - 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E - 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 - F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F - B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC - 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B - 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 - 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 - 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C - 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 - 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF - 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 - AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE - F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A - 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 - 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 - 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 - AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 - B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 - CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D - 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 - 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 - 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 - D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF - 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A - 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 - DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD - A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 - 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 - E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E - 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 - A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 - F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC - CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF - 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 - D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE - AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 - EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 - 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 - 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 - 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 - 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 - 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED - 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 - A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F - 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 - C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 - 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F - E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 - F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F - D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F - AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED - 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F - B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 - 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 - 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 - DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 - F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 - 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 - 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 - 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B - 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 - C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 - 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C - 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 - 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 - 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C - BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 - B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 - F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 - 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D - F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A - F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 - 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 - F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC - 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 - 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D - DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 - 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 - F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 - 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B - 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E - D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B - 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F - 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 - 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D - 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 - BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 - 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 - CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E - 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 - B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 - B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 - C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 - 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 - 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF - 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 - 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B - 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F - 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 - 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA - 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 - D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 - B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 - 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C - BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E - 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 - D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 - BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 - DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 - B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE - 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 - 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 - D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B - 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 - 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB - F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 - 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A - CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 - C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 - 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 - D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D - 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 - CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F - 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E - 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB - 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 - B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 - BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 - 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 - 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F - 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 - D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 - FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 - 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 - 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB - E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 - 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 - F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 - D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 - 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D - 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 - 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 - FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E - A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE - 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC - 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 - 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB - 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 - B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 - 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB - B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 - 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 - 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 - 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E - 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 - 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 - FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED - 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 - 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 - 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 - F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 - 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 - 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E - 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F - 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 - FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 - 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 - 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF - 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 - 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 - EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D - 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D - F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 - 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 - 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA - 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB - 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 - 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 - F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 - F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 - F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF - F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 - 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 - B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 - DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E - CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 - 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 - AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 - 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C - 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB - CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C - 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 - 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B - 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 - AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B - 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA - 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 - C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 - 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 - 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 - 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 - 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E - 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 - D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F - 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E - 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D - 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 - 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 - 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 - 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B - EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 - 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F - C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 - 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 - 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 - B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE - 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A - 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F - 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE - 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB - 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 - B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 - 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC - D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 - 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 - 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 - AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF - 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 - 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 - D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 - 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 - 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D - 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 - 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E - 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E - DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 - 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 - B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 - B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 - E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 - F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 - A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 - 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B - 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 - 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF - 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 - 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 - BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 - 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 - F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B - A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 - 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC - BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A - F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 - 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 - 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB - CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 - A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C - 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 - 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 - CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 - 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE - 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F - 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF - 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 - F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB - 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F - 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 - AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 - CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 - ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 - 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F - 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF - 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B - 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 - E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E - 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C - 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 - 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 - 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF - E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B - 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC - 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C - 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 - 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 - C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 - 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D - 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 - 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 - F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 - AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F - 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 - 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 - 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 - DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF - 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 - 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B - FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 - 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD - 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 - C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F - C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 - 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A - FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC - 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E - 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 - BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 - E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 - C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 - E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 - FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 - 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 - 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A - 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F - 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 - 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B - 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 - 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 - D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 - EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 - ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 - E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC - 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB - E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 - 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 - 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 - FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 - B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 - FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD - ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF - 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 - BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C - D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 - BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA - B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 - BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 - 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 - 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 - A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 - 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E - FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 - B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E - 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 - 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 - 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E - D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 - 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 - 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED - AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 - BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD - 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 - 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E - 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF - B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 - E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C - CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 - 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED - 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B - B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 - A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 - 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A - B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 - FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF - F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA - 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 - FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 - 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B - B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D - 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 - 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 - 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E - 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 - BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 - 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB - 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 - C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 - C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 - EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 - BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 - 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 - F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 - C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 - BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 - F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 - F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 - 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 - 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB - 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 - 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 - F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 - 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 - 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D - EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 - 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 - 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 - 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA - D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E - F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A - E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 - B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A - A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 - 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA - 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F - F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 - AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 - 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE - 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 - 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 - 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 - C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 - FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB - 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 - 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 - CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 - 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB - D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A - 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 - 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 - 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC - C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 - D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 - F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 - 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 - BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 - 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 - 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D - 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C - 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 - 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF - B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 - 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE - 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 - 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED - 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 - F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B - B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC - E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB - 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 - 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D - BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC - D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB - 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D - D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB - 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 - F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F - 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D - 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 - F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD - E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C - 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 - 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 - A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB - E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 - 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC - 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 - DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 - 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 - 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 - FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 - 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD - 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 - E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 - 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 - 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 - AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F - 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C - 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 - 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 - C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 - C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 - E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD - 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 - D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 - 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 - F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F - 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 - 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE - 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 - C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D - 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE - 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D - 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C - D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF - AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 - 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 - 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 - C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F - 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A - CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 - 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C - 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA - B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 - 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 - 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 - 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE - BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF - 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 - 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E - 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF - 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 - A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 - DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 - FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC - 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 - DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 - D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 - 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 - 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 - 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF - C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A - FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 - 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 - 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F - DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB - B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 - 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 - 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 - 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 - B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 - 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 - BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 - 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 - FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC - D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED - 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 - FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C - 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 - B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 - AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E - 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 - 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 - 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 - FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C - 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 - F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C - EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF - 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 - 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 - 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF - 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB - 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C - 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 - 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE - FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC - AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 - 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F - 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A - 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A - 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 - F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B - 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 - 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED - E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D - AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD - E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 - 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD - 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 - BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 - B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 - 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB - F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F - 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 - DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F - D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A - F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F - 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 - 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 - F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 - A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 - 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 - EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C - D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F - F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 - D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC - 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 - 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 - CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 - 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 - C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF - 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 - 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 - C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A - 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 - 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F - 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 - B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 - E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E - 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 - B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D - F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 - 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F - 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 - 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D - 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 - 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 - 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 - 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A - 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC - BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 - 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA - 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 - D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 - FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 - DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 - B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 - B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 - 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 - 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 - 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB - D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 - BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C - D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 - 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D - F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F - 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E - 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 - F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A - 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D - 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC - 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 - FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 - 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC - 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E - EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 - 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 - 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 - 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 - CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE - 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 - D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C - 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D - C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF - BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 - 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 - 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF - 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF - 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA - 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 - 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 - 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 - D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 - 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF - 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE - BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE - ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 - C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E - 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 - FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A - F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 - FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B - 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA - 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF - 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 - 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 - 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D - ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 - C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 - 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C - 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 - 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA - D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 - F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B - 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 - 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B - C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 - DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 - 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F - 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F - EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 - 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE - D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E - BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF - 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E - D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 - 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 - 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 - EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E - 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 - DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 - B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC - C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C - FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 - 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 - EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 - DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C - 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 - D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F - ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC - FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 - 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 - 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B - 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B - DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 - 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB - EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 - F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C - 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E - E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE - 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 - F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 - AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 - 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B - AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 - D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 - 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D - 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 - BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A - F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 - F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 - B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 - E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 - 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE - B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 - 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B - 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 - 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 - FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 - 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A - 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE - 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 - 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 - BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 - 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 - D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 - FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 - 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 - 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A - BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 - EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 - B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D - DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E - E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C - 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 - 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F - CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C - 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 - B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB - 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 - F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F - 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 - CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF - 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 - 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 - 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F - C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 - CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 - 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F - 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 - 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 - 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A - 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D - F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 - BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 - E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F - 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 - F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 - 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F - 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 - 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 - 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C - F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F - 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 - F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A - D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF - DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 - C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 - 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE - 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 - AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 - CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C - 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 - 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F - C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 - 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 - 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE - 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 - 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB - D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF - 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 - 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA - 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 - 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC - 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 - 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 - B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F - 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC - D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 - 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 - ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B - D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 - ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 - 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B - E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B - 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE - 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B - E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 - 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 - B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 - 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 - 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 - CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 - 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 - D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 - 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC - 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B - 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD - 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 - B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C - F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 - 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 - 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 - 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 - D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 - 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 - AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 - AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B - A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 - 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 - A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B - 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE - B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 - BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE - BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A - B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 - 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 - 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B - 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 - 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F - 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 - 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF - 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C - 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 - FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 - 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 - 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 - 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE - 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 - 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B - 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E - F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 - 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 - 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 - 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 - 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 - A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 - 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 - 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 - 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF - 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 - FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E - E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 - 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B - D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 - 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 - 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C - 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C - 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 - F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B - 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 - E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E - 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 - 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA - 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B - C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B - 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF - 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB - DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 - 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E - 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 - E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 - D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 - ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE - 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 - C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F - 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E - 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD - D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 - C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB - 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 - 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 - EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA - BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A - B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 - 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 - 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB - 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA - CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D - 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C - 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 - 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 - 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A - 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 - 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B - F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 - 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 - 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A - 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 - A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 - C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 - B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 - 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 - AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 - C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 - B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 - 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F - 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 - B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 - 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 - 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 - DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F - 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F - 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 - E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 - BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 - BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 - 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B - D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E - F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 - 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F - 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 - C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D - F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 - 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC - 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E - CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A - 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F - 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 - 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 - 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D - E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 - 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 - D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F - 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 - A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 - B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A - 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD - B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 - B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 - AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 - 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB - 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F - 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E - 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 - 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 - ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC - EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 - B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 - 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD - 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 - 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C - E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 - 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA - B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 - 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 - C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 - 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 - 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E - 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 - 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 - AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 - 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F - 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA - DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 - 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB - 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F - 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C - E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 - 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 - A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 - 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 - C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 - 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC - 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE - EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 - 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A - 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 - 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB - C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F - D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F - C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B - 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA - F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 - 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 - 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 - 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF - E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 - 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 - F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A - 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE - 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 - BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C - 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 - 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 - 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 - A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 - 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 - 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 - 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B - 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C - 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE - 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC - 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 - C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 - D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 - 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B - F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 - 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 - 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E - 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 - 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF - A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE - 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E - 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 - D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 - 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 - DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 - F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 - 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F - 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 - 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 - 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 - 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 - EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 - E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 - A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF - F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC - EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 - 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 - 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 - C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A - D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 - EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 - 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB - 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA - B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C - 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 - 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 - 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 - D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A - FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 - D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F - E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD - BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 - FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 - 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA - 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 - D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 - 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 - C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E - 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF - DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 - 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B - B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F - 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 - B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E - 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE - EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 - 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 - FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 - CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F - 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED - FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 - 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF - B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 - 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED - 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E - 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE - 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B - 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 - D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 - F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 - 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 - F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 - 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 - 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 - A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 - 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C - D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 - 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 - 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 - 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 - B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC - 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 - 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 - 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 - A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 - 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF - C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C - C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 - B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 - 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 - 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF - 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 - ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 - 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC - 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF - 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 - 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F - 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 - FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F - 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 - 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 - A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA - 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 - A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 - 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F - 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF - 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 - C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 - 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 - F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 - F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 - E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F - 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D - A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF - B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B - 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 - 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A - D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 - 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 - C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 - 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 - C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 - 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 - 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D - 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 - 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 - 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 - BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 - 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 - F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C - 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F - C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF - A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 - D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 - 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 - C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 - EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 - C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 - 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B - FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 - 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 - BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D - 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 - 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 - 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC - D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 - 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD - 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 - 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 - E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 - AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B - AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 - B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C - 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF - CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B - C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD - 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 - DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB - F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 - 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 - AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 - B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 - B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE - BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C - 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED - 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 - BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A - F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 - EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 - 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E - F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 - AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 - C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C - 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 - 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F - ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 - E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F - 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 - 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 - EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 - ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 - 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 - 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 - EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 - 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 - BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 - 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 - 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D - 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B - 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF - 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C - 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E - 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 - 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F - B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C - 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 - 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 - 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B - BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F - 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB - 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 - 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 - 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 - EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 - 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 - 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 - EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A - 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A - 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 - E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A - B5BF6F91D5F50E66B9A5D0FFD9} - end - object lblTitle: TLabel - Left = 231 - Top = 3 - Width = 402 - Height = 62 - Anchors = [akLeft, akTop, akRight] - AutoSize = False - Caption = 'TurboPower LockBox 3' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNavy - Font.Height = -33 - Font.Name = 'Lucida Sans' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - Transparent = False - WordWrap = True - end - object Label1: TLabel - Left = 231 - Top = 65 - Width = 400 - Height = 137 - AutoSize = False - Caption = - 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + - 'is to provide basic cryptographic functionality, implemented nat' + - 'ively as a white box.'#13#10'Block mode ciphers include AES and Blowfi' + - 'sh, and will soon be extended to include many others. Hashes inc' + - 'lude MD5, SHA-1 and RIPEMD-160 and will soon be extended to incl' + - 'ude many others. Chaining modes include ECB, CBC, PCBC, CFB, CFB' + - '-8Bit, OFB and CTR. The source code is highly readable and under' + - 'standable. Salting is provided where it is needed, transparently' + - '. The design is very extensible. Extending the range of ciphers ' + - 'and hashes can be done cheaply, easily and quickly.' - WordWrap = True - end - object lblRunTimeVersion: TLabel - Left = 231 - Top = 208 - Width = 78 - Height = 13 - Caption = 'run-time version' - end - object lblDesignTimeVersion: TLabel - Left = 231 - Top = 224 - Width = 93 - Height = 13 - Caption = 'design-time version' - end - object lblLogoAttribution: TLabel - Left = 0 - Top = 330 - Width = 614 - Height = 47 - AutoSize = False - Caption = - 'The above photo was sourced from http://www.flickr.com/photos/ml' + - 'iu92/3146549932 and has been copied with the kind permission of ' + - 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + - ' under the Creative Commons license (http://creativecommons.org/' + - 'licenses/by-nc-sa/2.0/deed.en).' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - WordWrap = True - end - object Memo1: TMemo - Left = 231 - Top = 243 - Width = 194 - Height = 86 - Color = clInfoBk - Lines.Strings = ( - 'TPLB3 is free and open source ' - 'software. It is made available for ' - 'use and copying by an LGPL or an' - 'MPL license at your choice. ' - 'Refer to the "Statement of copying' - 'permission" tab for details.') - ReadOnly = True - TabOrder = 0 - end - end - object tsWelcome: TTabSheet - Caption = 'Welcome' - ImageIndex = 1 - object browserIntro: TWebBrowser - Left = 104 - Top = 0 - Width = 527 - Height = 380 - Align = alRight - TabOrder = 0 - ControlData = { - 4C00000078360000462700000000000000000000000000000000000000000000 - 000000004C000000000000000000000001000000E0D057007335CF11AE690800 - 2B2E126208000000000000004C0000000114020000000000C000000000000046 - 8000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000100000000000000000000000000000000000000} - end - object memoWelcomeInstructions: TMemo - Left = 0 - Top = 0 - Width = 104 - Height = 377 - BorderStyle = bsNone - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'The video to the ' - 'right requires an ' - 'internet connection ' - 'and Adobe Flash ' - 'Player 10 to be ' - 'installed, in order to ' - 'play.') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsProject: TTabSheet - Caption = 'Project' - ImageIndex = 2 - object Label4: TLabel - Left = 0 - Top = 3 - Width = 323 - Height = 30 - Caption = 'This product has been brought to you by ...' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -27 - Font.Name = 'Script' - Font.Style = [fsBold] - ParentFont = False - end - object lblWebsite: TLabel - Left = 3 - Top = 312 - Width = 250 - Height = 13 - Caption = 'http://sourceforge.net/projects/tplockbox/' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - end - object Memo2: TMemo - Left = 3 - Top = 32 - Width = 614 - Height = 217 - Color = clInfoBk - Lines.Strings = ( - - 'The TPLB3 product is produced under the organisational umbrella ' + - 'of the TurboPower LockBox project. This project has no ' - - 'legal incorporation. It is an informal organisation with no defi' + - 'ned membership. The TPLB3 product is owned by the ' - - 'individual contributors to its parts. The Project on SourceForge' + - ' is administered by the TurboPower SourceForge ' - 'Administrator (tpsfadmin).' - '' - - 'LockBox was originally produced and released by TurboPower Softw' + - 'are Company as a commercial product. Versions 1 and' - - '2 of the product were commericial and were released in the perio' + - 'd from 1997 to 2002. The copyright holder was' - - 'TurboPower Software Company. Version 2 source code was donated t' + - 'o the the TurboPower LockBox SourceForge project' - 'under an MPL 1.1 license, which is free and open-source license.' - '' - - 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + - 'rivative work of LockBox 2 and does not share any' - - 'common code, but the mission of the library remains the same. An' + - ' exception is the unit DCPtwofish_LB3Modified' - - 'which is a modified version of a file from David Barton'#39's DCPCry' + - 'pt package. The original unit of this was' - 'developed by David Barton.') - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - object lblTpsfaIntro: TStaticText - Left = 3 - Top = 255 - Width = 356 - Height = 17 - Caption = - 'The TurboPower Source Forge Administrator (tpsfa) can be contact' + - 'ed at:' - TabOrder = 1 - end - object lblTpsfaContact: TStaticText - Left = 3 - Top = 272 - Width = 335 - Height = 17 - Cursor = crHandPoint - Caption = 'http://sourceforge.net/sendmessage.php?touser=625421' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold, fsUnderline] - ParentFont = False - TabOrder = 2 - OnClick = lblTpsfaContactClick - end - object lblWebLabel: TStaticText - Left = 3 - Top = 295 - Width = 177 - Height = 17 - Caption = 'TPLB3 on SourceForge is located at:' - TabOrder = 3 - end - end - object tsCopyLeft: TTabSheet - Caption = 'Statement of copying permission' - ImageIndex = 3 - DesignSize = ( - 631 - 380) - object Label7: TLabel - Left = 3 - Top = 3 - Width = 369 - Height = 13 - Caption = - 'Copyright 2009, 2010 Sean B. Durkin (except for portions marked ' + - 'otherwise)' - end - object Label8: TLabel - Left = 3 - Top = 18 - Width = 625 - Height = 26 - Caption = - 'The below copyright applies to all the source code and compiled ' + - 'binaries of the TPBL3 project, except the DCPtwofish_LB3Modified' + - ' unit which comes with its own statement of copying permission i' + - 'n its header comment.' - WordWrap = True - end - object Label9: TLabel - Left = 8 - Top = 48 - Width = 190 - Height = 13 - Caption = 'Statement of copying permission:' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object Memo3: TMemo - Left = 2 - Top = 67 - Width = 625 - Height = 246 - Anchors = [akLeft, akTop, akRight] - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -13 - Font.Name = 'Courier New' - Font.Style = [] - Lines.Strings = ( - - 'This component library is part of TurboPower LockBox 3. TurboPow' + - 'er LockBox ' - '3' - - 'is free software being offered under a dual licensing scheme: LG' + - 'PL3 or ' - 'MPL1.1.' - '' - - 'The contents of this library are subject to the Mozilla Public L' + - 'icense ' - '(MPL)' - - 'Version 1.1 (the "License"); you may not use this file except in' + - ' compliance' - 'with the License. You may obtain a copy of the License at' - 'http://www.mozilla.org/MPL/' - '' - - 'Alternatively, you may redistribute it and/or modify it under th' + - 'e terms of' - - 'the GNU Lesser General Public License (LGPL) as published by the' + - ' Free ' - 'Software' - - 'Foundation, either version 3 of the License, or (at your option)' + - ' any later' - 'version.' - '' - - 'You should have received a copy of the Lesser GNU General Public' + - ' License' - 'along with TurboPower LockBox 3. If not, see ' - '.' - '' - - 'TurboPower LockBox is distributed in the hope that it will be us' + - 'eful,' - 'but WITHOUT ANY WARRANTY; without even the implied warranty of' - - 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + - ' to LGPL,' - - 'see the GNU Lesser General Public License for more details. In r' + - 'elation to ' - 'MPL,' - - 'see the MPL License for the specific language governing rights a' + - 'nd ' - 'limitations' - 'under the License.' - '' - - 'The Initial Developer of the Original Code for TurboPower LockBo' + - 'x version 2' - 'and earlier was TurboPower Software.' - '') - ParentFont = False - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 0 - end - end - object tsAuthors: TTabSheet - Caption = 'Authors' - ImageIndex = 4 - DesignSize = ( - 631 - 380) - object Bevel1: TBevel - Left = 328 - Top = 16 - Width = 281 - Height = 257 - end - object imgAuthorPic: TImage - Left = 336 - Top = 24 - Width = 265 - Height = 233 - Stretch = True - end - object lblAuthorEmail: TLabel - Left = 328 - Top = 293 - Width = 150 - Height = 13 - Caption = 'email: sean@seanbdurkin.id.au' - end - object lblAuthorWeb: TLabel - Left = 328 - Top = 312 - Width = 173 - Height = 13 - Caption = 'web: http:\\www.seanbdurkin.id.au' - end - object Label12: TLabel - Left = 175 - Top = 135 - Width = 135 - Height = 13 - Caption = 'Select author to see details.' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsItalic] - ParentFont = False - end - object imgSean: TImage - Left = 175 - Top = 272 - Width = 135 - Height = 105 - Picture.Data = { - 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 - 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 - 696E6720494A47204A50454720763632292C207175616C697479203D2038350A - FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 - 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E - 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E - 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 - 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 - 00B5100002010303020403050504040000017D01020300041105122131410613 - 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 - 262728292A3435363738393A434445464748494A535455565758595A63646566 - 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 - A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 - DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 - 01010101010000000000000102030405060708090A0BFFC400B5110002010204 - 0403040705040400010277000102031104052131061241510761711322328108 - 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 - 363738393A434445464748494A535455565758595A636465666768696A737475 - 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA - B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 - E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 - AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF - 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 - D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 - 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 - CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 - 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E - 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 - CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 - C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA - 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 - 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 - F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF - 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 - 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 - E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 - AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 - 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 - 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F - A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 - B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F - FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B - A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 - 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE - 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 - D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB - 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 - 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 - 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C - 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE - 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B - E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 - F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 - 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 - 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 - E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 - C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A - CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 - B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 - 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 - 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C - 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C - DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC - B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 - 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA - 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 - 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A - 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 - EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 - 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 - 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 - 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 - 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 - 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C - D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 - 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 - 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC - B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 - B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 - AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 - 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F - 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 - DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C - F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C - 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 - 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 - 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 - 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 - 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 - 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 - ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A - B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 - 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD - 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 - 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 - CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB - BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E - F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F - 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 - C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 - EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 - 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 - FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 - 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB - 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 - 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD - C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 - B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 - CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF - 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE - E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA - EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 - B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 - CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 - DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 - 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 - 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F - 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C - 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D - 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 - 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 - 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE - 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E - 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 - D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 - 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A - 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 - 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 - F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 - 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 - 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 - A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 - ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F - A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 - 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 - 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 - 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 - 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 - F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 - 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 - C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E - B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C - AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 - 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E - FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 - 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 - 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B - 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F - EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C - 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 - 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD - 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D - 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 - 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 - FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 - 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 - 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B - FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D - B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 - 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 - B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 - 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F - 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F - F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF - 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 - A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 - 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 - DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 - FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD - 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 - CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 - 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 - BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 - B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D - FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 - 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 - C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A - 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 - 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 - B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 - BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 - 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 - 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB - 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 - 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C - 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 - 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 - BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C - 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 - 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 - 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 - 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 - DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 - 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 - AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD - 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 - 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF - 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C - DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 - 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A - B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 - C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 - F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E - 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 - C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC - 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 - 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB - B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 - 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E - EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 - 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 - 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA - 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C - D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E - 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A - 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 - F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE - 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 - 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 - 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF - 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD - 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE - BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C - 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C - AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 - CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 - 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB - 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 - 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 - A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A - 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 - B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D - 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E - 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 - FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B - 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C - 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 - D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA - 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 - 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 - 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D - FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 - 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 - E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A - 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 - 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A - A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 - 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 - EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 - 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B - 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 - 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 - 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F - A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A - CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B - 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 - 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E - 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 - 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F - 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D - 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA - 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E - 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 - F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 - 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 - 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 - 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A - 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 - 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B - 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 - 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 - 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 - A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 - 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 - AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F - 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C - DA66209F4EF451457D427A1E3D8FFFD9} - Visible = False - end - object Memo4: TMemo - Left = 8 - Top = 8 - Width = 161 - Height = 369 - Anchors = [akLeft, akTop, akBottom] - Lines.Strings = ( - 'To the right is a list of authors ' - 'and contributors to ' - 'TurboPower LockBox 3.' - 'Not included are the authors ' - 'of LockBox 1 & 2, as there is ' - 'no common' - 'copyrightable content ' - 'between them and LockBox 3.' - '' - 'The LockBox 3 project ' - 'welcomes any contributions. If ' - 'you wish to contribute,' - 'and your contributions are ' - 'accepted, your details can, if ' - 'you request, be' - 'added to this list of authors.') - TabOrder = 0 - end - object lbxAuthors: TListBox - Left = 175 - Top = 8 - Width = 138 - Height = 121 - ItemHeight = 13 - Items.Strings = ( - 'Sean B. Durkin' - 'David Barton') - TabOrder = 1 - OnClick = lbxAuthorsClick - end - end - object tsSupport: TTabSheet - Caption = 'Support' - ImageIndex = 5 - object memoSupport: TMemo - Left = 3 - Top = 24 - Width = 286 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'Support can be obtained through the ' - 'forums at:' - 'http://lockbox.seanbdurkin.id.au/tiki-f' - 'orums.php') - ParentFont = False - ReadOnly = True - TabOrder = 0 - end - object memoHelp: TMemo - Left = 295 - Top = 24 - Width = 333 - Height = 161 - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Tahoma' - Font.Style = [] - Lines.Strings = ( - 'User help for this component suite' - 'can be found at' - 'http://lockbox.seanbdurkin.id.au/LB3Help_H' - 'ome .' - 'If the help is still partially' - 'under construction, please either be' - 'patient, or offer your own content.') - ParentFont = False - ReadOnly = True - TabOrder = 1 - end - end - object tsAlgorithms: TTabSheet - Caption = 'Algorithms' - ImageIndex = 6 - object Panel1: TPanel - Left = 3 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 0 - object Label13: TLabel - Left = 16 - Top = 0 - Width = 116 - Height = 13 - Caption = 'About selected Hash' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblHashDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label15: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblHashDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashWikipediaURL: TLabel - Left = 16 - Top = 136 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblHashBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lblHashDigestSize: TLabel - Left = 16 - Top = 184 - Width = 97 - Height = 13 - Caption = 'Digest size = 64 bits' - end - object lbxHashFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - object pnlCipherDescription: TPanel - Left = 299 - Top = 16 - Width = 270 - Height = 209 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 1 - object Label20: TLabel - Left = 16 - Top = 0 - Width = 124 - Height = 13 - Caption = 'About selected Cipher' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblCipherDisplayName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label22: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblCipherDefinitionURL: TLabel - Left = 16 - Top = 112 - Width = 59 - Height = 13 - Cursor = crHandPoint - Caption = 'definition url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherWikipediaURL: TLabel - Left = 16 - Top = 141 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lblCipherBlockSize: TLabel - Left = 16 - Top = 160 - Width = 97 - Height = 13 - Caption = 'Block size = 128 bits' - end - object lbxCipherFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - object memoExtraCipherDescription: TMemo - Left = 16 - Top = 192 - Width = 233 - Height = 89 - Lines.Strings = ( - 'Extra Cipher Description') - ParentColor = True - ReadOnly = True - ScrollBars = ssVertical - TabOrder = 1 - Visible = False - end - end - object Panel3: TPanel - Left = 3 - Top = 231 - Width = 270 - Height = 146 - Color = clYellow - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBackground = False - ParentFont = False - TabOrder = 2 - object Label27: TLabel - Left = 16 - Top = 0 - Width = 170 - Height = 13 - Caption = 'About selected Chaining Mode' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlue - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsBold] - ParentFont = False - end - object lblChainName: TLabel - Left = 24 - Top = 24 - Width = 61 - Height = 13 - Caption = 'DisplayName' - Font.Charset = DEFAULT_CHARSET - Font.Color = clBlack - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentFont = False - end - object Label29: TLabel - Left = 14 - Top = 43 - Width = 47 - Height = 13 - Caption = 'Features:' - end - object lblChainWikipedia: TLabel - Left = 16 - Top = 120 - Width = 58 - Height = 13 - Cursor = crHandPoint - Caption = 'wikipedia url' - Font.Charset = DEFAULT_CHARSET - Font.Color = clNone - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - OnClick = OnURL_Click - end - object lbxChainFeatures: TListBox - Left = 67 - Top = 40 - Width = 182 - Height = 65 - ItemHeight = 13 - TabOrder = 0 - end - end - end - end - end - object btnClose: TButton - Left = 280 - Top = 416 - Width = 75 - Height = 25 - Anchors = [akLeft, akBottom] - Caption = 'Close' - ModalResult = 1 - TabOrder = 1 - end -end +object TPLb_fmComponentAbout: TTPLb_fmComponentAbout + Left = 476 + Top = 94 + Width = 648 + Height = 476 + Caption = 'Component About' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poDefaultPosOnly + OnCreate = FormCreate + DesignSize = ( + 640 + 442) + PixelsPerInch = 96 + TextHeight = 13 + object pnlAbout: TPanel + Left = 0 + Top = 0 + Width = 641 + Height = 410 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'About Box to be developed!' + TabOrder = 0 + object pgAboutContent: TPageControl + Left = 1 + Top = 1 + Width = 639 + Height = 408 + ActivePage = tsMain + Align = alClient + TabOrder = 0 + object tsMain: TTabSheet + Caption = 'Main' + DesignSize = ( + 631 + 380) + object Image1: TImage + Left = 0 + Top = 0 + Width = 225 + Height = 329 + Picture.Data = { + 0A544A504547496D6167659E020100FFD8FFE000104A46494600010101004800 + 480000FFE1004045786966000049492A0008000000010069870400010000001A + 000000000000000100869202000B0000002C000000000000004170706C654D61 + 726B0A0000FFE20C444943435F50524F46494C4500010100000C346170706C02 + 1000006D6E74725247422058595A2007CF000C00030011001E00006163737041 + 50504C0000000049454320735247420000000000000000000000000000F6D600 + 0100000000D32D48502020000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000116370727400 + 0001500000003364657363000001840000007377747074000001F80000001462 + 6B70740000020C000000147258595A00000220000000146758595A0000023400 + 0000146258595A0000024800000014646D6E640000025C0000005F646D646400 + 0002BC0000007976756564000003380000008676696577000003C0000000246C + 756D69000003E4000000146D656173000003F800000024746563680000041C00 + 00000C72545243000004280000080C67545243000004280000080C6254524300 + 0004280000080C7465787400000000436F707972696768742028632920313939 + 39204865776C6574742D5061636B61726420436F6D70616E7900006465736300 + 00000000000019735247422049454336313936362D322E312039393132303300 + 0000000000000000000019735247422049454336313936362D322E3120393931 + 3230330000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000058595A20000000000000F3510001000000 + 0116CC58595A200000000000000000000000000000000058595A200000000000 + 006FA2000038F50000039058595A2000000000000062990000B785000018DA58 + 595A2000000000000024A000000F840000B6CF64657363000000000000000549 + 4543200000000000000000000000054945432000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000064657363000000000000001F73 + 524742204945432036313936362D322E31207352474220393931323033000000 + 00000000000000001F73524742204945432036313936362D322E312073524742 + 2039393132303300000000000000000000000000000000000000000000000000 + 00000000000000000000000000000064657363000000000000002C5265666572 + 656E63652056696577696E6720436F6E646974696F6E20696E20494543363139 + 36362D322E3100000000000000000000002C5265666572656E63652056696577 + 696E6720436F6E646974696F6E20696E2049454336313936362D322E31000000 + 0000000000000000000000000000000000000000000000766965770000000000 + 13A4FE00145F2E0010CF140003EDCC0004130B00035C9E0000000158595A2000 + 000000004C09560050000000571FE76D65617300000000000000010000000000 + 00000000000000000000000000028F0000000273696720000000004352542063 + 757276000000000000040000000005000A000F00140019001E00230028002D00 + 320037003B00400045004A004F00540059005E00630068006D00720077007C00 + 810086008B00900095009A009F00A400A900AE00B200B700BC00C100C600CB00 + D000D500DB00E000E500EB00F000F600FB01010107010D01130119011F012501 + 2B01320138013E0145014C0152015901600167016E0175017C0183018B019201 + 9A01A101A901B101B901C101C901D101D901E101E901F201FA0203020C021402 + 1D0226022F02380241024B0254025D02670271027A0284028E029802A202AC02 + B602C102CB02D502E002EB02F50300030B03160321032D03380343034F035A03 + 660372037E038A039603A203AE03BA03C703D303E003EC03F904060413042004 + 2D043B0448045504630471047E048C049A04A804B604C404D304E104F004FE05 + 0D051C052B053A05490558056705770586059605A605B505C505D505E505F606 + 0606160627063706480659066A067B068C069D06AF06C006D106E306F5070707 + 19072B073D074F076107740786079907AC07BF07D207E507F8080B081F083208 + 46085A086E0882089608AA08BE08D208E708FB09100925093A094F0964097909 + 8F09A409BA09CF09E509FB0A110A270A3D0A540A6A0A810A980AAE0AC50ADC0A + F30B0B0B220B390B510B690B800B980BB00BC80BE10BF90C120C2A0C430C5C0C + 750C8E0CA70CC00CD90CF30D0D0D260D400D5A0D740D8E0DA90DC30DDE0DF80E + 130E2E0E490E640E7F0E9B0EB60ED20EEE0F090F250F410F5E0F7A0F960FB30F + CF0FEC1009102610431061107E109B10B910D710F511131131114F116D118C11 + AA11C911E81207122612451264128412A312C312E31303132313431363138313 + A413C513E5140614271449146A148B14AD14CE14F01512153415561578159B15 + BD15E0160316261649166C168F16B216D616FA171D17411765178917AE17D217 + F7181B18401865188A18AF18D518FA19201945196B199119B719DD1A041A2A1A + 511A771A9E1AC51AEC1B141B3B1B631B8A1BB21BDA1C021C2A1C521C7B1CA31C + CC1CF51D1E1D471D701D991DC31DEC1E161E401E6A1E941EBE1EE91F131F3E1F + 691F941FBF1FEA20152041206C209820C420F0211C2148217521A121CE21FB22 + 272255228222AF22DD230A23382366239423C223F0241F244D247C24AB24DA25 + 0925382568259725C725F726272657268726B726E827182749277A27AB27DC28 + 0D283F287128A228D429062938296B299D29D02A022A352A682A9B2ACF2B022B + 362B692B9D2BD12C052C392C6E2CA22CD72D0C2D412D762DAB2DE12E162E4C2E + 822EB72EEE2F242F5A2F912FC72FFE3035306C30A430DB3112314A318231BA31 + F2322A3263329B32D4330D3346337F33B833F1342B3465349E34D83513354D35 + 8735C235FD3637367236AE36E937243760379C37D738143850388C38C8390539 + 42397F39BC39F93A363A743AB23AEF3B2D3B6B3BAA3BE83C273C653CA43CE33D + 223D613DA13DE03E203E603EA03EE03F213F613FA23FE24023406440A640E741 + 29416A41AC41EE4230427242B542F7433A437D43C044034447448A44CE451245 + 55459A45DE4622466746AB46F04735477B47C04805484B489148D7491D496349 + A949F04A374A7D4AC44B0C4B534B9A4BE24C2A4C724CBA4D024D4A4D934DDC4E + 254E6E4EB74F004F494F934FDD5027507150BB51065150519B51E65231527C52 + C75313535F53AA53F65442548F54DB5528557555C2560F565C56A956F7574457 + 9257E0582F587D58CB591A596959B85A075A565AA65AF55B455B955BE55C355C + 865CD65D275D785DC95E1A5E6C5EBD5F0F5F615FB36005605760AA60FC614F61 + A261F56249629C62F06343639763EB6440649464E9653D659265E7663D669266 + E8673D679367E9683F689668EC6943699A69F16A486A9F6AF76B4F6BA76BFF6C + 576CAF6D086D606DB96E126E6B6EC46F1E6F786FD1702B708670E0713A719571 + F0724B72A67301735D73B87414747074CC7528758575E1763E769B76F8775677 + B37811786E78CC792A798979E77A467AA57B047B637BC27C217C817CE17D417D + A17E017E627EC27F237F847FE5804780A8810A816B81CD8230829282F4835783 + BA841D848084E3854785AB860E867286D7873B879F8804886988CE8933899989 + FE8A648ACA8B308B968BFC8C638CCA8D318D988DFF8E668ECE8F368F9E900690 + 6E90D6913F91A89211927A92E3934D93B69420948A94F4955F95C99634969F97 + 0A977597E0984C98B89924999099FC9A689AD59B429BAF9C1C9C899CF79D649D + D29E409EAE9F1D9F8B9FFAA069A0D8A147A1B6A226A296A306A376A3E6A456A4 + C7A538A5A9A61AA68BA6FDA76EA7E0A852A8C4A937A9A9AA1CAA8FAB02AB75AB + E9AC5CACD0AD44ADB8AE2DAEA1AF16AF8BB000B075B0EAB160B1D6B24BB2C2B3 + 38B3AEB425B49CB513B58AB601B679B6F0B768B7E0B859B8D1B94AB9C2BA3BBA + B5BB2EBBA7BC21BC9BBD15BD8FBE0ABE84BEFFBF7ABFF5C070C0ECC167C1E3C2 + 5FC2DBC358C3D4C451C4CEC54BC5C8C646C6C3C741C7BFC83DC8BCC93AC9B9CA + 38CAB7CB36CBB6CC35CCB5CD35CDB5CE36CEB6CF37CFB8D039D0BAD13CD1BED2 + 3FD2C1D344D3C6D449D4CBD54ED5D1D655D6D8D75CD7E0D864D8E8D96CD9F1DA + 76DAFBDB80DC05DC8ADD10DD96DE1CDEA2DF29DFAFE036E0BDE144E1CCE253E2 + DBE363E3EBE473E4FCE584E60DE696E71FE7A9E832E8BCE946E9D0EA5BEAE5EB + 70EBFBEC86ED11ED9CEE28EEB4EF40EFCCF058F0E5F172F1FFF28CF319F3A7F4 + 34F4C2F550F5DEF66DF6FBF78AF819F8A8F938F9C7FA57FAE7FB77FC07FC98FD + 29FDBAFE4BFEDCFF6DFFFFFFDB00430001010101010101010101010101020203 + 0202020202040303020305040505050404040506070605050706040406090607 + 08080808080506090A09080A07080808FFDB0043010101010202020402020408 + 0504050808080808080808080808080808080808080808080808080808080808 + 080808080808080808080808080808080808080808FFC0001108014A00EA0301 + 2200021101031101FFC4001F0000010501010101010100000000000000000102 + 030405060708090A0BFFC400B5100002010303020403050504040000017D0102 + 0300041105122131410613516107227114328191A1082342B1C11552D1F02433 + 627282090A161718191A25262728292A3435363738393A434445464748494A53 + 5455565758595A636465666768696A737475767778797A838485868788898A92 + 939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7 + C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FA + FFC4001F0100030101010101010101010000000000000102030405060708090A + 0BFFC400B5110002010204040304070504040001027700010203110405213106 + 1241510761711322328108144291A1B1C109233352F0156272D10A162434E125 + F11718191A262728292A35363738393A434445464748494A535455565758595A + 636465666768696A737475767778797A82838485868788898A92939495969798 + 999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4 + D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002 + 110311003F00FD133660E028047B714A2D39239078C574E6CF27818CFA8C628F + B105278C1FE75FE8F7D651FE5AA81CCFD8F0A4E3807AE3AD34DAA8001C67FDD1 + 5D3B5A9239CFD283687278381D29FB71A82E872C6D338EC777A521B5C76CD74C + D69C838C9C9CFB534DA6793C66855EE572239736B9254A8183E941B53800AE08 + C822BA6369C0E0FBD27D8CF1919F4E7AD57B741ECCE605AE540239F6A61B5247 + DD07815D3B5A1248C61BB6074A67D8C83F754E79142C4205491CD1B53C80BF85 + 21B618E14E7D39E7F5AE8CDA1C1E00A6FD90E3040271F9D57B71FB147346D41C + 158C60F539A69B4E47CBB41EFF00E7EB5D19B5EBC0FAFAD0D6995070BD3F3A3D + B07B2D0E6FEC5E8B8E39E2A36B4040F90106BA736D82785F4E4534DAE090471D + FDAABDB03A6CE60D967A02DF5ED519B2191C1C63B7AD74E6DCB6708540EF4DFB + 3119F9481D334FDB87B3672A6CB18CF0DDBDE93EC679F9720F39CD750F6EAB82 + 7683D866A33047DC0C919A6AB82A6CE5CD9B9EABCFD3A531EC9B0C48C8F5AEA7 + ECCA581001F4C521B605978073C7B557D606A2CE4DAD3D0027E94D36AD8E9BAB + AB36E324E00CF5A6FD9540C00368C8E6A957172B39236BC8CFFF00AA98D6C47F + 0E7FCE6BAE36831D0FE151359A923238EB54AB859F53936B5382142FB9EDFF00 + EBA8DADB03EE90D5D69B44C9CAAE0FB535ACD7048196EB4E35C76E87206DC641 + DA48C52FD9F1FF002CF35D59B1503E51CE3AD34D92E4FCAC7F0A7ED856B1ED3F + 6200151CD2359927E51C57566CF83919F7C7F5A4FB2F5EA057C9FB73B5506724 + 6D89C7CAC0F6A4368483F2FA5759F63185383F974A43659EAA3FAD0AB87B07B9 + C89B46F4C034D36808FB81867F2AEB1AD0820EDDDE9CF4A635A86FE1393CD5FB + 712A0CE54DAB0C909FA534DA9000DB81FCABABFB267EEAE0FBF7A69B55048721 + 3F1EB4FDBBEA52A2EDB1C9B5AE790A48A69B507240271FA5758DA7C8B179EF13 + A423FE5A382147FC08F15CDEB3E22F09787E3FB46BBE27F0EE911E3703717699 + 23D9012C7F0159D4C6C20AF3925EA694B0752A3B538B6FCB52A8B42780B93DAA + 3FB280410A31D735E3BAEFED41F0674A92586CB52D6FC4F329E0D858E21CFF00 + D749D9001EE01AF33D5BF6B38E45957C3DE0BB380A9C17BFBD694824640F2D16 + 304F7C073F8D78D89E2FC0D2D25513F4D7F23DCA1C1D98545754DA5DDE9F99F5 + 5BDB81B892AABDC9A9134F9A552D15ACEEA38CAA123F3AFCF7D7FF0068DF8A97 + 99316AF16876CCA4E6C2C628F68FABEE908E831B81EE2B8ED222F8C1F166532D + 84DE22D6EC242436A17F7728B645C8E048E486C75C2063C738C57CFE2FC48C3D + 357A706FD5A4BF5FC6C7B787F0F6BCBE39A5E9AFF923F43B5AF157837C37E62E + BDE2CF0CE952A8F9E396F10C8BFF006CD496FD2BC8B54FDA4FE12593CB1699A8 + 6BDE2CBD8F930695A5BB927A01B9CA633835E2B6DF04BC1BE19BCB0D3FE20789 + B58F1AEBB7199134AD311A305828C04822066704F192100F989E833D55C78DF4 + 3F0922D878734FF0DFC3EB18B98A282C92F2F586483BB61F261639CFCD23B1CF + 2074AF8DC7F8B388B5E8C62BCFA7DEDEBF71F4597F87387A9251BCAA3F2B5BEF + B5BEE67A7D878F7E24F89A3497C33F06A5D2F4F910B2DDF8835858142F6630C2 + 85B1D3F8BD7269C757F1602BFF00091FC48F873E1E90866169A1E90D7F3A7A03 + 24CF20CF4FE0F5AF9EB5BF884FA8B4B75A86ADAAEA890B6641A8DC6E85980DC5 + 8C0BB625FBA0608618F7C1AF883E29FF00C140FF0066FF0086375A859F883E26 + 586BBADEE779B4CD258DDF92DD3020B5F91303801C8618C57C4E37C4ECCAA69E + DDC5768A4BF13F43C0F85D8687C54A2BD6F27F76C7EA2DE7C4CF07E98458CBE2 + EF8A9AEEB258A08E24B7B4463D70638E38CAE067A66B3DBE2FFDA1E0FECCF0C7 + 8C679DE41BB3AD4A30707F842BA81C375F4AFE7D3C57FF0005A3F86DE1D7BB93 + C05F06F5BF14DF65963BBD5EEEDF4D84019208863F3A5EA3396F9B191C76F987 + 57FF0082C6FC7CD4B519B51D23C3BF0A7C3D33AF9654DADC5D300723E6676507 + 82470075E3A57CED6E34C6B7AD69BFFB7A5FA347BF0F0DE8D9F2D14FE518EBE8 + 95CFEABE1F8AD7691CAD73A0EBD085400A497ED396639F943342543003254FA8 + 3C56B597C60D2EECC7E7D85DA06E0868F2C49C8C6E439072BC1318FBC3D2BF92 + 2B1FF82B17ED2D6F73FDA135AFC2CD491412C25D2E47120CE48244D9FEF0E067 + 1F535EF3E13FF82C278AE2BD8AE3C77F0A2C670652EF3E95A995C679388A7465 + E07401C753CF15D581F11331A2EF0AD2D3BB725F73B9E263BC36A32BF35056EE + AD73FA9ED1FC6DE12D73C91A7EAF099645F96320863F81008FC54575E2DD6451 + 246E92C446438219587B11915F80BE04FF00828B7ECDFF0012A08ED2E3C5B378 + 2B5599C29B7F105B1B45C92082B72AD25BE723192EA4E7AD7DE7F0E7E3C6AEAC + AFE14F14DAEB7A611FBA8AF1BED305C281C6CB8524918040E641C0E2BF49C8FC + 6B9292A78F8A92EF1D1FDDB3FC0F82CDFC28F71CF092717FCB2FF3DCFD063664 + EE214FE029BF63238C007DEBCCFE1FFC72F0778D858596A617C1FAFCEA0456F7 + 732886E89E710CFC293FECB60FB57B9BD93AB344D1B2329DACA460838CE31DBE + 95FB76579FE1F194BDAE1A6A4BF2F55D0FC9F33C971383A9ECF131717F9FA773 + 956B339F53EDD2986CC8EDC57526CD981C119EC31FCBF23F95466CB9C951CD7A + 6B1279FECD9CA9B46393DFA7147D98FF0075BF2AEA0DA138C01F5A67D8F3CE1C + FE14DE2102A699EE62C8EDCE33ED49F63F61FD2BB0FB01EC381D7DAB1B5ED4B4 + 5F0BE9173E20F136B3A478774284EC96F6FA7582156C6426F62373103841963E + 95F212C524AED9ECC70ADE88C66B3E096000EA47A537EC873B02E589E07527D8 + 0AF907E227EDC9E04F0F3CF63F0F3C37AB78E6FC292977785EC6C49ECC91E0DC + 4CBDF25625F7AF853E207ED7BF197C5A678751F1943E0ED15F2BF66D3251A6C4 + 5493C33AB79CE3B7CD2907D2BE731BC6585A0B49733F2DBEF3EAF2DE07C6621A + BA515E7FE5B9FAFF00E2BF15F833C0D1EFF1978A7C39E15623E58AFAE9639DCF + FB10026563F4435F3BF88FF6BAF843A2B4D6DA5278A7C5570BD0C5682CE16FFB + 693957C7079F2ABF19350F8B5E0BD205DDEDE78FB4DB224EC792C630D2DCB907 + 80C48DCD81F7E466E83E539C579B6A7FB447C39D2A16B886DAFB5599937C61A5 + 528E79CEE949C93F29C808AA7B022BE431BE235693E5A292FC5FE9F91F6784F0 + DF0D049D79393ECB45FD7A33F5FAF7F6C9F15EB6B2BF837C11E0FD3A207026D4 + 6F64B86CFBF30A679EBCFA735E75ADFED03F18248BED5AAFC456B3B463B4C3A0 + 5A4765167D04E23F358F2061491CFDE1D6BF38ED7E2F78E356FECF5F0AFC39F1 + 4EBE6E2DE3B8B79B4DD0AEAE91D5B24796E10A0C0C1EDD7278AE47546FDA775A + BB4BDD4BC3DFF08DDA2C21925D6758B6D37243370D112D221C705403B79F515F + 378AE2EC6D4769547F97E563E829F0A65F876AD4E2BD75FCEFF858FBAB59F89B + E249124D55759F15B79AA217BDD6EFE376DE482442AC659028DA304B678C9C1C + 0AF3ED47E24695AAC622D6BC53606CA2CBC8226F31B76324CD712105BA6705B0 + 3070062BE2E97C0FE257769BC57F1CBE1868D06E756FB2CB77A9CADC8215308A + 09196047D306B52CF4DF823A6BDB5FEA1F123E29F897568A2DBE6E9FA5C56D10 + 6DD9054CCC727B6486CF27031C78F2CC2A546DCB7F33D2AF2A54D28C23F723DD + 35BF8E3E05D16716BA3BAF88EE530545A4AA5509EDB80233F283907030335E63 + A9FED45A669577279D058D8DDACAD19377771A3170E55C00780D95278241EA78 + C67CC2E7C4DF0C34AD52F2F746F861A9F89FE62BFF0013AD7E6C4ACAAA8AE52D + C226000063BF3CD5C8FE33EABE7DECDE1BF077C35F0ACD9F3A59ADF434967DFC + B026498B166C9EA7FF00D58BC4CFA9849A50BDAEADADDFA7F5B1FA03FB27EADE + 02F88FA278BBE257C47D534ABCD234CB8B5B3B3B595FCD80CAC8EEEF2F03CD51 + B515506E52CCDBB3802BEAFF00167C54D5351B8FEC5D2CDF781F4C48D6489E58 + 00D467F970A6380FFC7AA60939914BEDE563F4FCDCFD927E2CF8BA6F8E377AC7 + 8D35B8FC65241E0EF12CDA5C1A8283069DA82E9EDE44D0C78D91BC4EC19582E5 + 5901ED83F51EB90C7A4E99A878DBC4FAADA409E44F7F757D75398A1B48E3F9E5 + B9B895F81C0919893D0375EDE16698A7195E4EEFF05D3F4D4FA2CA329A589846 + 759DA3D12D2EFCFF00AE86C4BE2C5D1F4ED4ED63B8FECDD35E40F7F3493B66E2 + 34562F25C5C31CC9B4724BFC831B8000357E39FED29FF0555F879E1D79BC29F0 + 374B1F15BC5112F927570C62D1AD1F18DD14A3E7BBDA57204788FD1CD7CE9F1A + BE287ED0DFF051FF001CEAFF000A7F666F0F7896F3E0469970B15F5EBB9B1B3D + 45B77CB71AADD38DB1427AC5667748CA37B46CC42A7DBBFB38FF00C11DBE12F8 + 561B1F13FED07E20D47E305D80A4E9764D3E97A2C72E036C56045D5D00410794 + 4619242E335E155AB2AAFF0078FE5FE7DBF03EED52C2E021CF3B453D96CDFA2D + FF000F567E1EF8A3E2EFED5BFB556B72F87AE75FF1F78E2495C94F0E7862DA51 + 6B01CE4E6DADF8FAB4CC4F727B8FA1FE1BFF00C1257F6B7F18C115E7883C29A0 + 7C2CD20056DFE22BE26408C386FB35BAC8A0631CB3A751EB5FD365A5F7C29F83 + BE16BBF0CFC32F07689E03453F65B7D3340D320B08A2DA4952446BF320DC4967 + 666627BB1CD7CB7F177E3DF843C18A2F7E257C4CF0B783CEE0D1C1A8EA2B1CE5 + B700365A8DD2B636B7017EBD6B96A62A30F817F5FD7A9ECE5D87C4D74E728AA5 + 1BDAF3DDFC935FFA51F9FBE13FF822CF86AD96D64F1D7C7D8EF27618961D12C6 + D6CD636DBC8124ED72CC030519D80F5E3BD7D0767FF0441F842D6DB9FC47F13E + F83421D26FF8492C63F31F200531FD8942803711C9E077C8AF3FD4FF00E0A47F + B3968371F61B5F1678EFC590A9509F60F0F3E3001F984970D0E4658F4EBCF22B + 9587FE0B13E10F0DBCD6F65E09F897A8698E76F9771AA58C3BD49E54282FB4E0 + E41073EB530C449ABBBFDDFF00008CCA8578FB987AA9CBCE374FD2DDBE66878A + BFE08A1E0976913C2FF15FC65E1CB860447F6BB9D2EF90BED276F2B6CEC73818 + DC3A8F9B24E3E3FF00893FF0491FDAB7C07F68BBF06DE786BE26E9C832B0C464 + D32E9F8E311DC66062323A5C1E73D7AD7E83697FF059EF80DAB69690788BE0AF + C695BF2789AD351D36E50276C832464E071818EBD4F7F55F0E7FC149FF0062CF + 1DEBD6467F1AFC43F840F2AB099F5FD02E2183CDEA0B4D64D7118E73C9E30403 + D2BA633A525752D7CD7FC047CC4B38CC294B96BD0E68F749FF009BB7CD1FCD27 + 8DFC17F127E116B6344F8A3E03F167C3BD6CB1444D46CE4B713118C98DCFEEE5 + 1DFE46615D2FC39F8D9F117E14EA2D7FE02F18EB5E1E858813240C3C89F9E92D + B36518F4EAA0F5E6BFACCB1BEF097C71F0BEBD73A0EADF08FF00696F86570922 + 3DA417969ABC68096DA2E2300CB13601003AAF27A64815F98FF1ABFE0969F0AB + E239935FFD9AB5D5F857E3174671E1DBE7927D2EF2404FC91F596D8E48036071 + C01E40E4D2961DB5EEABFA6A7661B37C1D67CB37C8FB3DBEFE9F348CBF801FF0 + 541F0F6BC74DF0A7ED01A25BF8791D4432EBBA6C6D2D93E06DDF736B8692DCE7 + ABA19539C954E83F787E19FED153784B4BF0E5F49A81F89BF07EF62492DAEEC2 + E12EEE2C207FBB259CBBB1716FF29FDCB3120708E98D87F88CF897F0A3E25FC1 + 0F13A7843E29784359F02F890C6D3C02601ADEFE15629E75ACC098EE22CAB297 + 463B48218290547B2FECE7FB59FC50FD9CF541168777FDB7E06B89BCED47C357 + D3B0B2BC6C826584E09B6B8FFA688086FE359074EFC9F3EC665D5556C34ACFF0 + 6BCFB9C19CF0A6131949D0AF14D7F5B3EE7FA07683AA687E2BD134DF12786355 + B2D7F40BC52D6D796CE5A39304065190195D4F0C8C032370C14F15AAD6430321 + 769EE3A75AFC3DFD93BF6C1D17C4BE1F9FE2AFC17D524D474913C50789BC2B7E + C22314BB4623BA44DDE44EAAA7CABB8C32B0C0FDE2068C7ED87C39F1E784FE2A + F85EDFC59E0DBE7BAB277F26E6DE650B75A75C6D0C60B945276C807208256452 + 1D1994F1FD3FC1FC7D4335A765EED55BC7F55DFF0035F89FCBBC5BC075F2C9F3 + 2F7A93DA5E7D9F67F83FC0BA6C73C8DB8E94BF616EC2BAC6B3E4E0639F4F5A8C + D90C9F9457DABC49F16A85CF15FDBD7F6C8F0EFEC45F093C3BE34BDF0EDC78B7 + C61E23D624D0BC33A6F96FE4C93C50F9D71713B27CC62851A23B148691E68937 + 202EC3F9B5F885FB6D7ED33F1CB5B7F114BE0CF135EDD61962BDD4E210C16509 + 24ECB7595A282DE3C804AC6AB9C7258FCC7CA3F6A7FDA93E37FC5FF8C9F107C5 + 7E35F17DE5CDEC5ABEA5A5D847B4245A5D8C5792A436768AC310C28B1A654637 + B02EFBD98B57C8577E23D675C8AEE4BFBAD4754648C3BF9AED2173E60E72C4E3 + EF7E9EF5FCF19FE775B133714DA876FD59FB9F0C6454A9414E5653EEF5F9256F + D7567D4BAA78BBE2F6A76724DE2FF8DBE01F08EEFBF0A5EC97F3A819E0A5BA90 + 0838EAC476E2B87BDFF8419CF9BE23F8A1F13BC61310405B2B24B44938392249 + 8938EBEE38E457834724CC81AEA3FB0D8ED7621CEC523A64E78EE4FE15CEDE78 + F7C29A48D97FE2BD0A1605979BB466C64750B93FC2381EF5F238876B5D9F7B43 + 0E9B6B99B5E4ADFF0004FA817C49F08344B7B68EDBE1E6A1E251184CC9AC6BB2 + 49B8EE3CBC30844CE58019CF1FA76DA67ED15ADF842FB4CB9F00784FC09E00BD + B7064B6B9D2B478967899860B09A4566390C791EBCE40AF80B5CF8DFF0C2C256 + 31F895754C1C62DEDA57CF4EECA074E719EBD7079AE3EFFF006B0F87F6A592D3 + 46D7EF768C0F326823E84633F3123EB8CFB573D4AF4D5F999D1432EAD295E349 + CAFF0087E27EB5EB9FB517C6FF0088A97EDE2DF8B5F10F5F92540A5EEB58B991 + 98601D9CBE02E3036F419C74CD790FF685EDD5C5E35D5DDC4F22AB13E6392460 + F62793EBCFA7BD7E65DCFEDB7796624FEC6F085A472E1943DCDD4B276C670AA8 + 3D3A9AE1AEFF006CBF8AF3C939B0B6D0AC8C8AE85934F466E4F24190B8DDC75F + 4CD671C7D18E8BF04630E16CC24F994546FDD9FAF8B3BC01A367DE331C7CB700 + 375CAFD01E9ED5D5695A6DE5DE9D0CE96D39B675CE021385C9FBE4743820FB8A + FC3C9FF6B2F8F97210C3E35D4B4E2BF207B63141B063A031C6AC30300735E71A + EFC67F8B7E24F3BFB67C6FE23D403E4913DFDC4DDB9FBF263F4AD239C412D22D + 83E05C6D495E7522BEF67EF06A3AC681A44CFF00F090789342D22EA476256E2F + 228CA641C75EFF005E9CF43CD719AB7C5AF853A55AC827F1D785AE6DB0A9B62B + E49E43C60E15093818AFC1BFED6F124EC0B6AB761CF2CD1AAA93F8A8C9351CE7 + 539462F2FF005599319F9A5936FE478AE69E6D525AC61F79E852F0F6092556BD + FD17FC39FD06FC10FDAFBE05F827E29E957FE24F1CA69DE1E9ACEFF4E6B892DA + E16380CD6AC88F2379780A4E01C6700E6BEB8BA3E26FF828FC379E10D1F52F10 + F84FF621D16EBC8D5353B10D0DF7C54D6201BC69D64F200D1E9D6EFB5A6B82B9 + 7930002DB3CBFE797F62BFD9B2DFF690FDA37E17FC34D46EB53D3BC2D77AAC23 + 59BDB3C0B882D012CD1C3231C2CD2042884E76E59F9F2EBFB54F0F49E08F0AC1 + 6DE16F0BE8DA0F82FC15A32DBE916FA669B03476BA459C644691C6A4B1C28627 + 71F989DCCCCEC59ABC7C66224DA94F77B1DF570F0C1C151C35EA4A167AAD9B76 + FBDF4EDBF63E11F8D3A0685F0F7E0F7C37D23E1F69E7C07A1E857171FD91A7E8 + 570D6B6D046D6E646C6D903B30DA9976F30B3396760C54D7D07FB4C7ED4961FB + 3C7C36D43E26EBDA1EA7E2FD134ED374A636762CBF6BB9BDBB114504685CED55 + F3248CB139F94B1009183E57FB5F69D7AFF073C2F716D6F636E971E23B874104 + CBB5E178E5114922B02E06371C83856001CAB1C757E31B91AC6A5E158DD264B6 + 8F51D0ADE6684B2C836AC28016C9208DA0E3BF2320F4F2E93928F2DCFABA3976 + 1F115E78AA914D2E65DF5D17F9BF2BEC7E38FC41F8CBFB7D7ED112F872E27B48 + BF650F86BAF6A70E8DA7436D6F3BEAB7824477019B1F6B10C70C334B24816D23 + DA8C72EC541E23E237FC1393C65E06F1978C344B1F02DE7C61BCD0B4E37FAFF8 + ABC47E2A4D1F4E9665622586D34F81CEA178CA48F98DC7CC4F0A8A09AFD58F89 + 9A35C69FF0CEEAE22D322BEB996F2091C4FBFF0073BA3B8C4A19158ABAB60890 + 8619CF5CF1B5F1B7E3FF00C38F82DFB43691E04F1F7C55B3F87DA1CDE1696FAF + 3FB4EF6386CB549677BB48CCEA41766568F0AF9642400C32A73B546A2BDCD3FA + EFB93571F53EB12834B656EFABEBE495B4FF00863E078BF605D6756F017C26F1 + 37C05D1BE05787A783C3726A1E24935BF061D6F53D52F05DBAE6CAD750FB4C21 + 8C1B08B72EB921CB16C023EE1F88FF00B10EAFF1B3F6633E05F007C3DFD9EFC0 + 9F1B12E2DB4D9BC59A9F8334BB49EEA0DF707CB692C6D604B19AF18D8C66ED61 + FDD42980ABE63495E5FF00B44FED27F0FF00E05FC44FD96FE2278834BF1F78DB + 40D56CB57BEB297C39A609E6BFB5911631E579AD17CC7CF89B63051B54938C57 + D9BF0CFE21695E32D63E04EA96B61AFE916DADFDABC4AF69AACD00B8B46413DB + 88AE56332464C66D5B251C805F048C1CEF46A494AD2D579DEDF99F3F9DB6E3ED + 62F927A59A5ABD536FD3A35B5BCD9F93FF0005FE05F843E307ECF1A56B3E3DF8 + 27F057C3FF0015BC35E2C5F0FF0088AFAF3C216E3FB6F4F896672B22DA9800BD + 2D0CB6B25D44CAA444B32EE6725BD13E387FC1347E035CFED0727C31F859A078 + B7C05A25E7860F896C2FF49F12CB73347235DDC29B4FB05DC73A3C71C5082651 + 346FBC8050EEC8FD33F8B3E3EF831E34F849ACF893E0C7C4AF853F15E28B53B4 + 3AE4FE1DD6A1D45ACEEAE229DA2966689CF94EC2208BBB1BB2E71924D6C5C58C + 117ED79F0EEF8C4B3C537806ED5180CB10E6F30FC9E31B8F18EFDF3C6D5F0968 + A4BAFF00C03CACB38DAAF3CAA4DBE58C57BAD756DAF55D0FE7035DFD8A7E2DFC + 3FF883F12EFBF65EF8C5A7FC63F1AF80354974FD7D3C313DD683E2BF0FDCA338 + 1985D9567C989F0D697126ED8404DDC1F69F823FF053FF001A693AAB7857F6AC + D035AF886B138B3B8F12D840B67E26D39B18FF004EB4711C17F85007EF160B92 + 3FE5A49C67F5B3E1AE81A2687FB727ED0BA059E956B69A2EB50AF8825B58D50C + 776F3496978EE7D6493CD9F716FBC483C8209FC92F899E0EF88737C57D3FF677 + FDB3347D13E2EF867C437F716DF0F3E2B693751C9AB6851F9ECB15AC7AB2A86B + CB389A44B79B4ABE491AD4B249088D0625E0A729C1F345DADFD7F5F91F518978 + 6CC23155A16975B6EBCFD3BEBF267ECB78EE5FD9EFF6E7F80925A5B268DF1F3E + 1E99E222EAC37C57DA4DF01B410180B8B3BC559790C11C8DDB8491E41FE6EFF6 + B9FD8CFC75FB2E6B2D74935EF8DBE175CCFF0067B1D6A7B7F2EEB4BB82C57EC5 + AA44A3F75701810928FDD4C47CBB181897B7BBF02FED27FB0878B752F8D9F067 + C7F16ADE0ED37554F0EEABE21D29A39ADA0BB56575D27C4BA6EF63033E4144B8 + FDDCBCB412EF5217F65FF65DFDA7FE107EDCD6FE2FF0BF8DFC23A25978A351B3 + 9CF89FC2574EF2431C45079B35A798737364FB46EDFF00BC8C90AF8216423AF2 + 9CB9A5AB97DDFD7F5B9582C2C307465496B4E09B4D3D6FA5D6F6EEF4B76B5CFE + 6EBE107C64F1CFC0DF1B58F8D7C09AB7D8356894413C4E4B5B6A96848636B751 + 0204911C6719051B6BA1040AFEAEBF609FDA734AF8AB6567F147E116AB069DE2 + 3820367E26F0C6A173B50C71C4656B6BBC72C30ACF05D28C8DDBB1912A9FE7B7 + F6F4FD88358FD943C6771A878664D47C45F04751D41ADB46D4646F36E3499D81 + 912C2F1FF89DA3C98A638F3951D4FEF23707C3BF64BFDA4FC57FB2EFC62F0DFC + 52F0FF00DA352D35185AEBBA5C32141AC69A58F991293C09864BC4D8E1D707E5 + 7707BB075EA61EB46BD16D4A3B58E2CCF0D4F1985953569292F54FB7F99FE8DD + E0CF11E85E3FF0ED9789FC3734F269F3168A48A6C09ECAE171E65BCEA09D9321 + 6191D082AEB957527A7FB0A7FB3F80AFCCFF00D8FBE37E8FE38F8C3A46A5E01B + E8F54F855E39D39A7B0B858F645A804B23736B70A3395950C5716EFBB0C04ACA + DCC6A07EAEFD8C1E7657F50F0C712FD7B091AED7BDB3F55D7E7B9FCA79F643F5 + 3C47B2E8F55E8FA3F347E5E7C56FF8212FC11F897F10FC7DE36D3FF683F8D9F0 + DF4AD7758BAD7068FA4787F45986953CF33CD24705D4C9BDA1DF34842BA13820 + 166DA09E1ACFFE0DE5FD8D343B5BED57C7BF1F7F6BBF15D845179D3B5C78AF48 + D02DA200FDE92482C46C5CF73201D06457F44BF613D30703B93C9AFC78FF0082 + FA6856D7DFF0491FDADE6BB89A5B7B3FF845EFDC0553B8278934D43C3707897B + F5FA57CCD7952A74DD4F6706D778C7F3B5CFBCCBAAE25D58518CDC53695D2D57 + E4FF0013F815FF008291FC3FF86DF073F6D8FDA6BE137C0DF174FE23F833E1CF + 14CBA6787EEA7D63FB5CFD94450B05FB712C67C3BCA9BC121B61C1239AF86A5B + 2D43EC0DA89BDBA7B665DC5D64C06C9C0DA339EB8FC8D6F49049ADC3A8DB69D6 + 9F64113DAC4AB310A76AA49CB1E84E48FD076AAF6F0C11695A75C4CDA533C301 + 566693334877B8D8AB9FBB820E715F8CD7A71949CBA3BBFC4FE85C3CDD2A7183 + 776AC9F77A7E6CCAB0B1B4D477BB3CCCC3AF9809279EBC7F3AD9B8D12D610238 + 702F648DDE28E45255C28E4139E33838FA541E19111F323DDBD09C0217B6718F + C6BAEBAFB2DBDA9BA0D2F9F6F03DBA448B9326E270D9F6DCD9FC28A3878B8393 + B1389C5CE353962DFF005FF04E2C69D1ADCDBC2CFCBE9FF6CCEDEADE5160B8E7 + 233C67BD5B9D7468748FB6DBCDA9BF9A5A38C98D400CB80770CE40C91CE6AFC5 + 3DA9D2E09E3B2D44EB6B69F607023C461028512062724EDE318E306A82DBDD3E + 8B6F6A6C73325CCD300E721959471EB9E3A9A5EEAF83AEBB3F2B0F9DBB3936AC + FBFF005E4696BFA37D8F4EBE96C52D5E2441B67576F3147196C676F3CF4E064F + A5417CAF637FAD79690C7247676CCA4A021092B938208E87AD4928B89AC6E60B + 1D16C74A33A98E41017385F419E833DFDB152FDA6FA5D4FCF79B4DB4BD923585 + E36DA490003908DCF6FC2B5A8D49FBA9FF0057EF6F239A8CA518FBFAAD77F96F + 6BF66247104B9B6D4247682E66D364691E2401BEFAFCC01EFE9C7715BBE18F0C + F88FC7FAE69DE0CF0A585F6BDE2BD46E16D34CB16644B8BA72719E7851D4976C + 2AAA9662006C65C13B0BF7BE975DB34B829B066488075C8240C923A8CE315FAE + 1FB157893F6B1B1F077882F20F1E789EC7E09C56F3DB7F653F86ECEE22BC8EE9 + 45BCCD14EF6ED259DBBED8D1A48990DC3AAA82CCA5AB3AC9B8691DFD0E4C663D + D14A72B5977BAF92D1DCF7EFD82FE1E69DF083E25FECEFE1C48E07D66E7C5FA5 + 4DA85E0183A84B3FC9BD49E444824548F3FC209EAE73FB39AA5A4BA45D7C46B5 + 5B3B792D6DAE1678CAF24066DDB41ED818E3D477AFCBAF03783FC65E0DF8B7F0 + 0751D7FC25E24D16D4F8B3419619F50D3E7B74982DDC2C0ABCAAB9CA65863AAA + E4022BF52F47D2A0BCD1FC58B72D788973732CA842E247653956390704F4E738 + F515E46650B28DF7D4C783AA3AD5ABE21ECF974FFB7B4F4B6A7897ED0E9AC4BF + 03BE1C5CBD9C735A45AD5DDBCB29B88D9244913763CAC07F9485F98671CE7AF3 + E85AD413CDE1CF0AF88962536D16B3E1869E58A1D85C1B880976C70CDB59864F + 278CD5DFDA7F48B7F0F7C0CF00AE8DAB7DAED46A90DD4D3471FCB1196D8A61F1 + 908C773050704AF38E984F88979E22B1F811A66A3E00F863AA7C46F1858CFE18 + BAB2D034FB98EDEE359646B7F351669331C7F2EF725C00151B3835C985A7EE7B + C7A588CD28BA927845A4B5FF00C9B55676B7CFAEE958E5BE2B6936DA1F82A3B6 + B779AEAF65D4112EBCD672AEA6DEE102A6080F8201DA415F95CF3804687C60F8 + 41F047E3578FE6F04F8CBC0BA5EA7F176D346137873C4577A5C573168098136F + 81C10E92E216600AED0C4B8F989AE6342F11FC40F8C7F077C7DAC7C45F86BA4F + C25F1B693E23FEC8B9D0ECF5693535B4F2AD670C97178C9E5B4A24B7954BC0A2 + 218DA19FAB7BD2785F5ED37F68BF0DF88DAC6F22B17D02522F5212B1238B7981 + 05C82BB8178C1F60AB8E063D6A78552846FE7FA1F956373EA94ABD671A9795A2 + 9F9DB9B9B5EDB6DDD1CEDB412F847C4FF09BE045D5A3EB5E1CD7B47B8D3F52D4 + 61964B79A58D5278DE22A87011B6B16CE7EF3004672397F1769FE18F87DFB45F + ECABE1BD2E4B9D334DD4ECB52D2D34D5C33CF1899489433317639BD914E0E57C + C56FE1E3ADFDAAFF00625F89DFB44784742F89BF083F688F883F037E27783A1B + F1043A16C3FDB06481EE2045533C124771F6885610E85C1598029F229AF11F0B + 7EC6D6FF00B57FC3AFD95F59F8B9F127E2D783FC53E02D56E7C5305EF8A45CCF + AF6B7A74B35BDCCBA45DCF314B8B6BB22258C498DD1B5B4A8108298DA3868ABA + 8AB1C1FDA15A7C95AA55D1F449E965A74B6AD74BF99C7CDF0BFC09F02FC05FB4 + 6FC3FF0087BA0787BC2BE00D3356D0C697A7C24A25A4325D48E88F2392F24812 + EC23348CD2315C924915F5825B5B47FB4BFC2DD58176B27F025E360306531217 + 6C11D464381B811F85723F133F6619FE34FC3AF8D1F0BECBC4C7E1EF893C6F78 + 26B4D4A7DD341A6DD2DD9B8884C8B86303C83C860A7708DB2A4E1775CF0E7C3D + 6F859AB5FC1A9EA9E25F13F873C29F0CE1F0735E7F6819EF6F6E12D0413BC33C + C48498BBDC15C92B19D884911835E84E3EF6C7CC42B3F66DB9DE527ADF7DEF77 + EB7F53C57E1F22C5F16FF64BF1A4EF2DC43E25F0E78874EBCB896DBECF2F9897 + 524B179E022FCC82755E4646C0318C57CD16377F11BE20FC2CF137C35F157C07 + BAF86F2587C6D796C1AF2492DAEEF1A0B8133DFC5A7CB02615E2BB880B947712 + 99DC6DE598FD0FE02FD9F87C048BFE09F3159F88AF7C53A068D7B0786B55B8BF + 69A3BB9B52D42717125C3C0D24F1C6AF1C7223049303CB8B862C58F4F37C52F8 + 83A85C7C0CF1578A756B3D42E2EBE27EBBE0AD41A7B68D84165E546B648872A5 + 5A1313E19724E0649C023C3A98594A2A56B3FEBF33F41C267F4E8C9D04F99749 + 6AADB5F4F96A7E74FED1DF0D35EF817FB4C7C45FDAABE116A9278EBC09A978A4 + 687F173C2773A72CD6D0C17457F717B0C8BE55CE99751AB6CDE185BDDC499389 + 10D7AEFC06FD97FE087C14FDB47E127887C19E1C9E2B1B8D774ABEB2F3EF64B8 + 6D320BC8151E3B10E498E206562A1B3279676176000AFA8FC43E184BBB0FDB9E + CAEE58EFF4FB8D42E216827462119202A89202AB952551C302577F2081C550B2 + D3427C7DF8086E6288490E93E1169F0402852CA0CAB73FDD5538CF7382722B82 + 9C1A92EE8FA6C7E73CF0F671FF00979FF057E563D83E33FC3CB5F8D1A07C50F8 + 4CFE16B5F18E93E23F0FDD69565A718C1379A925A18ED92357C6D956E96D4C4F + B81578E3605704D7E12785BFE0843FF055BD48C36DA8FECBF178726F294C92EB + 1E39F0FD9A1902F39C5F31EB918DBD3B57EB078A7F6E1D27E127EDD16BF04A3F + 85BE26D7FC136377A36AD73A9E9362ACD66F7324735ACD2CB2DC46890A1F2636 + 8957CC658DCA976385FEB27C1173E22F10F87EDB5AF14F866D7C25AC5C4B2B8B + 286E1265F20906397723B85DEA77EDDC5954A86DAC4AAFDC706E4B85C54AA3C4 + 36DA775DB53E7B3ECFB1397AA74A8534A2E2ADCD7BE965DD59DAC9FA23F9DBFF + 008249FF00C13D3F6F0FD95BC4FA6E9BFB47D87C2BD13E11E957D75AE6910E9B + E328358BEB6BC9ADE58A4B4482DD7CB48659265B86732610ACA00633607F436B + 651855040CE3DEBB43644B1C28FAF1C547FD9F2760D8FA57EC194D0A183A7ECA + 82B2BDFAFEB73F2ECDAB54C656F6F5524DF647BA1B2CB702B95F1C7C3AF047C4 + DF09EBBE00F893E0AF097C44F036A908B7D4B44D7F4D8750D3F518C3AC8127B5 + 995A39143246E3729C322B0C30C8F5836B9180A377D29A6D0A8CED4CE719C77A + F96FACC76B9F71FD9ED3BA3FCC2FFE0B33FB367C36F877FF000562FDA1BE08FC + 09F87FE09F869E11BAB9F0A2691E1FD1ACD6C34DD3AE6F742D3A59122810158D + 5A799DF08B80D2F039AF906CBF622BBFF8422F3E20DEFC5CF8430E876F77A859 + DE476767AA6A1776BF6248DEEA5291DA81E5C5E6C6AE43EF46C7CB80587EA0FF + 00C17A6E2D3C3BFF00059AF8E7E24BDBEB67B4826F05DC4D0C4EDE7431C3E1ED + 3373B05185DDF36DE777CB9C74CFE797887F691BAD13F692F88BAA6BDF1DBC6B + F167C033693A83F863C43E1A85AD6EAC2E6EA48A68AE258668A31F6C4F2D63B9 + DC1D642AE8246570C3E2F31708C93B6ADBE97ECFCB7FE99F5987C4E367EED095 + D463ADEF7BAD2CB47ADEDFE4CF50F86FFF0004EDF02F89BC5DFB3BDDC9FB405B + F8ABE0878E96F6C65F13F873458D65D275F8521DBA398EE6664333B5DC3F3315 + 65DB37EEF2A09DCD0BF600F0468FACFC42F0178E7C55E2EF88FF0012B46F16B6 + 95651782350B4974FD474C55C8B97658AE6582E373430BC0487867768A48C14E + 788FDA2BF6DFB2F1BDE68FE2CF85BE2CF8A57DE26F37C3B3EA965AC5A9486F2E + 638657D4AE95405B74B896E52C0F9B1A231685595801B4747E07FF008283F83B + E1E7C71F17FC60D03E1AFC45B1B2D7FC5BAA6BBAC69B657905BCB7167A9E9F6F + 1EA3024C928316FBA8AE658F1CC7E72383BE200F971C459FA5FD2FA5BE5FA115 + 69E69283927676D2F6BE9DF6D5DEDA2B69D19BBE16FD8EBE064FF13348F065D7 + C37F8EBE368F58D55F4E4D26C7C6167A6EB1A08010463CABBB587ED5E6379F89 + 3E6652A55E100067F917F6B8FD9BF5DFD977E39F89FE1A5EE81E2ED27C306DAD + 755F0ECDAE3DBCB737B612C40922E2D95609CC7309E0668D54068F954638ABFE + 1CFDA7B47F08EAFA3F8EF45F869F1267F1DE9776D75FDA7ABF8E6EAF535B7126 + F4B9D4E297786B91889CBC2B12975E001823AAFDAA3F6CCF8C1FB52C3E0AD03E + 21F87B44F09C1A1C73CAF6915A817325DCE54C8CD232AC8B0158A02B0740EAEC + 4B1DA5485597346C9FF5EA91D1428E329D46A7AC2D6776AF7DEE9272B68BCAF7 + D753D3FE1FAFC17F02F877E1B7ED13E2EFD89AD3E2CFC15D4B52BAD1353863BE + BB68348BC5F2D6DC5FDC3C8C89E61B889924257CC11CA98F94D7B9C0D77F007C + 57FB597C27D53E18FC0DD77E1BD87C37D1FC51A3E97AB78662BBB046BD8EDA78 + D99E4267696333CE8928904819064BED15F9E7AEFED1DAFDF7EC9AFF00B2443E + 1CD1A1B2FF0084BECBC56BAD25FC82ED4C105CC62D9ADB66C29BAE4389370605 + 00C364ED97E24FED81F137E25787F48D0B5A87C2324F069DA568BAB6A1E61371 + A958D8DC2CD6F6B238C18A20508D84B90095560A020DEBB9394AF7B69FD7DECC + E9E5F55B8E975777BC9BD39A2D3D5BB6978E9AFE27EB3FC35D535BB0F8CFFB4E + 7827E0CDFF00803C47F10749F04EB773A7F86FC53E05B5B7D42D354874B7B844 + B95BAB69ECAF5D6741240DE58499510395F3F69D2FD8F7F68FF8BBFB457EC737 + 5F0D34BBE5B48ED6FA7BBF11DE4EF2B096D925B4C59411070B8967786509C478 + 91A20630B93F987E27FF008282FC62F1678B35BF1E785BC39F0B3C31F102F74B + B6D2350D6AC2DD66D427B1B7B616B0472BA845631C388C48537B000331C0AEFB + FE09C1F183F698F849E22D47C23F036DBC06FE1CB89E3BBD72F35ED124BE4B38 + C797F2465268D8C8FE446562072C54B12AA18D70D573726D2BA4BF1BBEFE4FFA + D8E7A99425837EDA294935BD9BB5BDE578AEAF6EAFD4FD29F8791F8B2CBE3A7C + 30F066B1E2EF1478D469DE3AD3E19E6D4E6B92F25D8BA8410893BB7941154AED + C02A4ECCB2A21AFD18D4F57D66C343BA3676D3F9E97A6342A9B8E1002720E7B9 + 63EC4F3EFF001DF82342D72E7E33FC2CF1B5E785BC496AB378E2C2EAFAFE7B59 + 96DDE696F37A91295D803B676E0F70BD6BF47BC4115E5CC462D17468EF52E24B + 9985946525740C770223C97DA704860B8F7C75F1F1787718C575FF00863E8B84 + 738A739544D249B8DAED2D93D3D59C77ED2A62BDFD9974248AC923D4CA2C53B4 + 44C864904F83F282157E558F91FC2AB9CF4AE9FE11F88B4F1E0FF87BAFC92EA7 + 0698347B1B9BBFB36C133325BED3B0E54649CF2C474E08AF87BF6D6FDA2BC31F + 0BFE0AF837469ECBC5BE33F8937D7F750E9BA0697A534D762D625469AED90067 + 4822964894CDFC4EFB541C311F9DDA37FC163F50F00E856BE0FD6FF67DD374DD + 361B74B38D6EF57BEB69B629391FBEB32A1B0704001783C726A693F7558F3B2A + CBAB43118A8D4837194E5CAFC9BD77DFADBA763FAB81E25F871A98BBD1EC6EFC + 6DE1FD5F70B7B9592CADE669E607A493472A6F1C8383938C9352358781A5DD68 + 9E38BFB5685834914FA44CB1C8C09E4F96D28E0F19C1231C1AFE66F40FF82DDF + C19177A74D75F083C4DA55BDB4BE6462DFC516D3B95C1F959A5B68B71CEDF98E + 0F18E324D7B75E7FC16E7F652F13C73457FE15F8B5A0CD31DD218FFB2A71B893 + F38D978847247A1E48039AF52963E3CBEF33E4730E0D9FB75EC60D45EEDA4EDF + D2E9FD3FDE797C2DE15B88CFF6778EFC2F76EC490D34F716A555B3B862480AB6 + 4E31865FC7AD456DE06D32E65BBB697C55E1B374F262D826A30499553FC4CD20 + C36D24F4C641009EFF008D3A37FC15EFF634B847B58BC43F1474FB80008659BC + 3390A71D4F9173215C9CF407FAD7AAE9BFF0540FD8E6F54DE37C579EC94A2A79 + 379E19D4F6A8C8246440C30483F81AEFA35A935CDCD63E6F19936222F91D2BAF + 46BF2B1FAC107C2D58609D2C351D375CB87432173346AD1B2EEE0A97C8200182 + 7E51EA49029FAD7C3ED67EC8A6F3C2DA9EAB02DB98A466B69256886D054321CE + DF9BD47B0FEF57E5FE97FB7DFECCBAC5CCD28F8F5F0836395753343736048CE4 + AE66854071F29C9F4C0ED5ECDE19FDB47F67592C4DE695F1FBE1141383BA3F23 + C556B0CA4E70301A54F988EB82001FAF5A9D36ECA6BF03C2C56595A369383F95 + FF005BDCF72D6742D33EDF1D9EB9E1F5D474FB1BEB4BAB2B76B76B68EDA58CAF + 95B132A76AEE6E0F03E6E9D478DF88FF00670D3757D3B48F0C6977BA9E8D6F0F + 8AD7C691DE5D2899A3BB0B36F462B8016469829C29C63AF35F43784BF683D0B5 + A7B33A0FC6EF0E6B770F112A9178AAD66C2903381E7B6327030307935EA43C7F + E33BD56115CC7ADC6C485FF4282EB7720FDE08C472071FE35C71C05F58CD1D34 + 336A7423ECE549DFBB7AEBAF5F3FC2CB63F302EBF65DF8E3A178F3F6B0F15EB3 + F12A0F197837C7DE358B53F0BF87ED7329F0ED8319259C5E34B10785F2B14691 + C52180A8790E18A85ABE258EE21FDA97C2D6E93BCBA6DA9D02CB4E91712196CE + 3B68970BC0DABBD652118020893A86047EA549E20F1179AED7BE0CB2BC9E3032 + 67D114FCA30319118C8C90768F53CF5CF86DDFC39F01CBE2FB7F1D6A7A0259F8 + 996F6DEFD4DB5CEDDA63445D862230AA5628BB90DDCF249E5FECA716E4B53D37 + C4EAA4E2EA2E56AC97CBFCFA9F9A9F1ABC0DE30F895FB5C7ECFDF0EBC0FE178E + 2F0CEBB74B687C4374935D45A36A492C52C0B730A6331CCCC144DBF19F300427 + 62B7F60BA4E84DA568FA469375710DF5C5ADA416D2CC9198D2678E3546754EAA + AC5090BD81AFE7CFC05A6476FF00B53FC0E2B0C31C2FE2CD0D444A0058D7EDF6 + E800EED9DF9CFB8AFE930D92E4E3E5CF61C8FCEBEA782FF76AABEB7FEBF33ED3 + 887D9E269D09C355CBBBDF7B7E871A34F5000C6463A8A6FF0067C638CB0AEBCD + 975002E6945970385AFB958B67CBFF00672EC7AE1B661CE306BE7BFDABFE3BE9 + FF00B2BFECE7F16FF681D53C377DE333E1CD32392C745B594C326B5A95C5CC36 + 765662501BCA12DCDD5B2349B4EC46660090057D3E634C13B457837ED3FF00B3 + E699FB537ECFDF14FE00EA7AE6A7E143E25D3E282C757B2B61713E8BA8DBDCC5 + 7965791C24A894C375696D37965977AAB2E46E0C3E22AD67CBA33F42AB829723 + E4DEDA7AF43FCC7FF6A6FDA57C09FF000518FDADFC51FB4178AFE1EFC46D17E3 + 078BEC239B56F0CF87EE12DF4F8E6D36C63B38EDEC1EE1279DA4FB369D1BB2BB + 1DD2CCC108DBB6B0BC1BF0D7F652D534D9FE36F877E117C77F8BDF04B49B3BED + 5B5AB17F1DD958EB16D6366A91BDC3C012D9CC325C4B8530991D228E4DE0B27C + DDB7EDDBA0FC46FF008276FF00C14AE6F87DF12BC25F0535AD7FC03E2687C592 + DD784B4F7D0E3F17C1AA5AD95F6E569A3DE91E09558CA38867FB4287954927E4 + 0F877FB4A6B1E1CD0D3C3EFF0003BE1C7C40D0A29B5FFB349A9599BBB858755D + FE747E7881FE55FDCE02E32636C6D12480FCECB1359AB2DACFEFFEB6EC7A0B2F + 7C9194534F4BABF6BE9BAF2BBBFE563EF4F81DFB2DFECE1F107E2C78CBE077C4 + 6F869E20F058BEF06E9DE31F0CF8AB46F145E99AD60BDB5F36191E09D9A090C4 + 77C5246EA43BC3F2BA026BE70BBFD97BC69F01F45FDA17C51E3CF865A17C4FD5 + FC01E28D3F40961BDB677D3EEF4F9EE96287568216CF9D1DC192008486550594 + E5B7633ECBF683FDB4F50D37C35F11346F855776D69E1BF0EE9FA21F102783AF + E58A7D2A37FB3DAC535CBA80E866B8936E18B334CC01206293E1F7ED29FB70FC + 33F1B78DB5C117C60F1278F3C4D66346D563D5341D4565B88846112158A38576 + A0478D4448148CA152A70C75A329DDFCFF003D34EF6D0F1ABE171914F9755EEF + BAE4EFD2EB9BA296AF7EBA58FA57F670F893FB387C41B1FDA5E7F02FEC69F073 + C3DF122DE5FED6F09C0E925C8F095A08A6967BA5BABB924D81218647D8EC6381 + D0B47B42AA9835FF008CB73F0CDFE00FC50F8A5FB36FC13FDA6BE176BBA5EBB3 + 05B8D074E8A19C433279F1ADC25A6D8E22B75148B2ED694075704B160FF25786 + 7E2EFED6BAF7C41FDA3FE275C7C35D5BE2678B758F095F7853C5F2AF852F4368 + 564BA449A73CB32C0A192682D650CCF3EE6C22B4B9C96373E137ED5BFB637C2F + F831A77C2FF87963E29FF845AC51F5FB5BB1E1FBDBB821B516B2235CB4263304 + B08B67901958185E319756DA5AB3739FC5AAB2FEBEF496A3AD954B9DBB29B6E3 + BCA57578EB67BE926DDBAAF447E83FC6AF087C01F1C7FC12BF4FF88375E1EF81 + FF00B355EEBBAE43AAF869AD743B868E0BE569A73A4DB5E4505C5F3C6D6D15E4 + 486777059633238C965EA7E2378717E2CFC3DF0B695F0ABE1C699AB7ED01F0FF + 00E135CF8874E8A7D121BB138B975916CED2D946649961B19CAEE52416D91EED + CD5F8FDE12FDB03E3BF857E105C7C17D0F56F0E5DF809BC39AA78616DE54B993 + 65A5EDA3DA4F220170B1ACE5256C3ECC642E430E0EC5A7ED9FF1E747F881E1BF + 895E13B9F0D781F5CD3BC3767E1A65D356E122BB86DA4B8786E5DBCE12A4E05D + 48BBD195768C60866A5565294AFAAFD346BBEBBAFE90E8E4F5A9C270D25EF49A + BC9EA9B8E8F4BEA934F7F3DD9FB97E11F85DF117F6D0FD897C5BE06FDA43E1D7 + 877E17F8C7C35226ABE1CD72C745DBAADA2DADA99DE698C8543A4882EAD24424 + 204219CCB2C05ABF3FBE1C78B3E0C3F84353D1FC33E39F11FC15F85F61E34D33 + 428BC616D1DADDD981285FB4CF7A97511120914878E62D1926D1F1F24AAABF27 + F8ABE337EDCFF157C1965F08B5AF17FC45F107C37F12C475987C23A75A31825B + 55BB32091A1505D617B83E6FEF58F9870E4FCC09F6BFD9C74CFDB23E0A5978E7 + E19587ECB5E19D73C2DE2F2916A96BF167C1939D1E55492171206B99208DB63C + 08CAE9BD94E769CB55525522E53B5BB1CFF5051A7FBC946C9DECBE14BAFC49DF + B6AACADDDE9FAD5F0B7E34F8DF46D5BE0C7C16F0BFED67FB377ED4BF0A6DFC53 + A36916D73E19D366B6D5B4CB68AF239E333C71DF4B69142D2203F2A6E7324841 + 53B80F77F109B593F6CED1EEE5B6D374FB38F4082CDEE16301A7823D3B5320B8 + 04938F3238D8E4642F4E0E7C43E1BFC02D43C11E32F84FF12F43F839A1FC3AF0 + 65E78C346D4E2B7F0EC70C7A359B4D7714788D63918ED7258A03D7729180463A + 3F88DF0DBE3E2FED7FE20F1C687E2582C3E0F2F826F34F49D4D935C68DAF181A + CD5A38A44679A1DA567E72A72C80FCAA0F955A5EC6D396ADF31380A50CC39E9D + 2B4141C5DDD96D7BB76D2FAAF2F22D8FDA0F42FF00851171F117F674F899FB4F + 683AEEB11EBA961A8F8875B61ABC0F636A6E2E2DFCD582068ADCC68768903B36 + FE319C9FABB4CFDA1FE358F805F09B594F89DF0D75AF123F86358D6F56F0F78C + 3FB4EF758F13DA584B234D75A64B6F72B89218546E0F0CDF3BC6CC51701BF227 + E177C32FDA7B44F871E13F823AAE95E0FD4FE2CEA3A178D7C616BA4DD358DCD8 + EB93411C71A476D75118FECB15E5A19E22A5C1F38A487664A8FA27F647FDA2FF + 00E0A6372355F83B7DFB2CDA7837C1FA6681A9DD6957BAA785B53B9B79355237 + DAD86A1770DF22C71CCF2C8864019D00276300DB669E23DDD7F0FB99D78EC8E6 + DD4F6366A36D5B5B36DA6DBF95B6DACBA1F64FC01FDA0F44FDACFE0CFC438BC1 + FA5FECDFAD7C7ED26FE386DF45F89BA02343158BC28F148D6D1C3F6CF2EE03CC + 89748AEAAF180770CA9F33F867E11F01EABFB447ED39E0CFDA5BE07FECC90F81 + B44D034ED76CA1F12F83FC39716BA0F9970D0F9ABA9C969133DA4C4AC8AD3396 + 08C88C77AB67E27F847F177F6E7F1CFC4BF0CFC09FDA1BFE0981E0BFDA0B5982 + FA17B4BBF15FC3E9927F07D9DC4804B2C7A8491CF01B40824917E7C120856624 + 57B86A7FB447ED3DE08F8D3FB44EA5E32FF82767C50F1968125EDA781AE351B2 + 81DECED2CAD6ED858CD0DA4966EF7566CB2433B6164552E01742542DFD65DD5D + BF99C6F29A94E1C918AD52D5495D69D1DD5EFDECB53DE7E3E7ECCBFB2B784FE1 + 978B7C4167FB347EC90DA9699A3C33DBEA0BE03D3A1B6BA9DA280F9C05B88B7C + 7202E546E180F95C139AF9E7C0BFB2BFECA7F153E1AFC01F146A3FF04FDF82BA + B9F16C57706AFE21D12EAFB4CB5F0F5E9D42E6D2CFCDD2E3D452E6486430A079 + 2098EC24F18E57EACFDA8F49F8AB69F097E28F84F45F87D3F8DEF34DF0D269BA + 758DB24E23D7E4B416E5A3842032A49247672F969C333955DC770CFCF7FB15FE + D0DFB65EA3F06B5EF869E1FF00D88BC55E0DD27C1DE17D57C41A75FEB29A8447 + C4FAA2FDA2E6DF4DB486EAD52679A6FB44F831CCC06D05B970A5E230D57F95B6 + DDF4B68BEFEFD0AC066D4DD29D4759452493729CB57757B5B5BB5A2E97DDDAEC + F3783F630FD8162F86763F1075FF00D897C6DA6431DC6ABA76B971E0AF18EBD7 + 1A7F87EE2D6E26B757B8FB66A827F2649221CC71C9B4EE071F296E42F7F627FD + 801FE0DF87BE277883E0F7ED5BE12BFBBD29A49E4F0E78F2F6EF44D3B522F2C5 + 0DBCD7735B4D2DB2CB24710491E375FDE727819D8F85FF00187C53AD7C0FF8DD + 75E3DFD87BE37DBC9E10F09EA5AD35F78A2DEF6CEE35CB7BAD5A192E21D3D4DA + C711BC8E468AF48752FB2D640854332360F823F6C6F873ABFECA1F10B54F12FE + CFBF12AD34AF0369DA3689AE6B37F720369CFA8DF4AD6F776D6EB244B2C09796 + 89BE5741247E7C6B8292383D1CB4DB6EC97CBFE01C30C4639D9734A56693F7FB + DBCDF7EDFA9BBE0CFF0082497EC6FF00107C2BE11F16A788FF006DFF0008E9FA + BE9116ADB9B53D2B59B0D3A530472BDA3DEFF65468261E680825F2CCA01D9B88 + 655A37FF00F0487FD9F7476F065BE8DFB59FED0DE0CD7FC4203E8FA6CFE1CD1A + E2591848898244B6DC06923CB0000CF62057E9A7C37F84FE26F09A6876DAFF00 + 89AC61D2A0D2B47D0D7438228EE22B5B9B77BA6BB9DAE1796F3D66B38B6FDD09 + 6C5815329AF8EBFE0A33F12FE047C25F1BFECC765F1CB4DF8F7A6CB0D8DDDD69 + 3E2DF086A914325A5C2DF46F2E16493CB9EE6DDE3B4996DE58E4531CBC82A4E3 + 7AB86A31A4A76D4F2A8E6F8EAD5E38784EFCCBF962FA5FAAD6DD7D34B9E1FA3F + FC136BC5AFE21D63C1DF0EFF00E0A9BF14EEBC43A76AB1E8F3E93FF08ADEC135 + 9DCC9179912C813578D4AB29C891034646E21B82074BE1EFD91BF6D0D3B57D0D + FC21FF00054DD57C65A328B9BEBAB2B0BBF10D9DC5DE9F637A96DA9416D7533D + C5A457711DC9E5C8D95778C9010EE1E97E3BFDBF7E0FF8160FD8E7E235D7C45F + 1CFC5FF05F88FC5B71AA7FC25B7DE1483428747F0F4104FA7EA063B7896332ED + 9EEADE7F2C460116CEE808D9BBE83F881FB58FC00D0BF6D4F007C0B93C6BA742 + BE28F02EA525C6BD6AC4D8C7A96B72D84FA5DB2B95C39BAB6B20C920F9374D68 + AC54C8C16250C3D9FF009FFC12255F33E6BBA6B66F5847ECE8FECA6B5EF67D16 + E8F7EFD9635CD03C4BFB447C12F09699AEF8E353F1068FA9787BC4D7326BF2BD + D4D7BA55E5E5BC96972BA8316175E604539621B07690A576D7F534F6D8672012 + 7711CFAD7F155FB367ED03F05EEBFE0A08DE12F04789DBC65E20F0E689E1FF00 + 0D697A669F05C4973AD5FE93756EA6D49488A5BB1BD3141E639D8BBB248EA7FB + 63FB4C4F7925A4E6CEDF5848967B9B25BA8DE6B50C031DCA0EEDA09C07C05618 + 23822BD4C8AB462A718F7FD0FAAA384AAE2BDB2B3B276B68AEDB693EBAEB6E88 + CDFB29E708A68FB22FA28AD47181F32003D07AFD297E5EE8335EFF00D68D3FB3 + 5BD8D01E3DF0D04C0D52029F5E735F33FEDB7E27D0F54FD8A3F6C6B3B6D5224B + 897E13F8BFCB293B4326E1A35D38DB2290C9F77EF0231CF3DEBF1225FDBEFE2E + 050CBA47878A839C89CF3FA5666A9FB787C47F11693AC787B5FF0005785B5BD1 + 751B3B8D3EF6D2EBF7B6F796B2C6D1CB0CA8461A3923764653905588C735FA03 + F0871F6D12FBD1F1757C55C04E9CA17B5D35F0B3F981F84FFB5C687F0F7E245C + F85B56D06F341BFF00037886DB57BBD67C55A65BFF00696997E2F5235D32D268 + E20D1C8C9BD12ECAAE523F9BFD66E5678E6EBF68BF87BA7FEDC1E36F097C49D2 + 7C0DE3FF00853E26B7F1368F2787B488E1D32EB45BE30B44F05A6D2B6ECE353B + 5BC4600EC732A9C8DBB70FF6FEF0043F197F6A6F8A3A7E8FE3CF849FB3EF8327 + D33C2D687C3FA8DE5DDB69B67E5D8A189966225F28191AE27540467749807915 + C049FB19FED1DE33F0FF008893C2FF00B5658FC42F126ABE048F5DD67C3779AD + EAFA7CBACE850285B6B4B89AE3F70E316EAD0C570638C47086DC8CA16BF19CEF + 2EAF87AD530F5B49A6D369BD75EBBFF2BFC6E7D7E432C0CA11AD424B91A4D292 + F47A5D24BE27B68AF1B6CCFAAF53BDD77C6B6DE10B3F13DFFC57D43C1D63E14F + 065DDD4DE1CD76D6CF58D1E1BAB9D43EDB7B6FF6D6105C1636CA268E6DE02307 + 1B30587A2FECCDF1ABF68ED73C5FE11F853F1AFC4FE3BB8F14EBFE3C4B8D6A16 + 9A389AF6EF45D4DEC25B5963B651116852EAC09F2C05DF15BBFCC1483F983E28 + FD9A7C51A30F0647F16BF6B9F0D6853BA68BA4DADCDDDCEB32D86956B736A6F2 + DED66BD93C948648E3BBF3843B4A0496465932192B63E207EC67F12FC29E08D0 + 3E3DF85FF693F0EFC54D06F3C6C9A45AEB5617DAB4134D73797AB00D56DA662E + D24724D1A348EA5246DA87321C639954E4764B7BF5EEEEBA771E2729C356A6D5 + 49AD5AE57CBD546DA3BD9E9D9FE3A9F6AEA4DF193E3AF867E077ED85FB33FC69 + F0DFC2BF8BF36ADAA5D6A7A44DADC368B6D7974D6F2594B02CE8D13B2FFA542F + 7120217CAF989F9C0ED7F660B3F881E3CBFF00869E36B4D73E2EE8BE22B9F086 + 93ABBC42E34AB8F0B78DB4EB99E58F57B29ED241E6DB5D35A0BA12436E13CA8E + 1F31515258D8FE68E97FB1B7C40D6FE19FC5E8BE1E7C78F859E34B6F0F5F5BC7 + A8F8274ED6EF22BDD42596E96DF73DB488B1C5B18869166C1CA0501A42A2BD13 + E097ECAFF1E02A78ABE1EFEDB5F057E181D1D9ECAE3C8F1EEA906A1A732AB472 + 5B456496AAD3B050D1794BF2FCCB1B6DDDB6AACD68976DBAF97A1862301869D1 + 925515A2DD9B8EB14F5B3EFBE8EDFF0003C57F69FF00D9335BFD9E7E35FC57F0 + 2F85B40F1AEA9F0DF4CD6561D0B52B9B6F325B8D3E4B78A7B793F760EE50B2F9 + 665036968C8243E56BAAF819FB3C8FB6D8F8B7E24E8EF0DBABA4B63A3DD4592E + 739135CC44723206C80E37119718015BF58BE18FC3CF18FC72F0F9F178F8F1E0 + 3F89DE288522D2A7BED5BC5B17F69DC4B1249F2167448CC80C5E5AA2B00B8DAD + B79AF937E2768569E22F0BEAFE12D37E2FF84FE1978C2F8C91DADAEA96176C75 + A48954CD143756FBBC9F958348E239582B0E143313DF8282F67CB2DD58F3B15C + 4156A54FABA767B396BD377FE6FF002391D5FE27DA78DB47F1A86F87BF123C71 + E17D3E54D3F54D67C39693DC24170B234A8639ECE55B98CC60203380D0E4B21E + 1C06EAE58359D57EDBE1DB3B7F8CDF183C3167E1BF0ADD69FA27F6EB4BAEF84F + ED57B736929D3AE4981F6192CA194F9C0848AEBF7A1847E69F98B54FD937F68E + F84FF16D7E0F78D3C7DE11F80B7376F6634CD7E6D7A73A36B2B711B1867B29AD + 2179268F6C526E75894C611958718AB971FB07FEDFBE1CF17FC5BB1BED33538B + C4BE1E9221E23B87F1F59A35C5A089CDBDE46D2CE1AE2D1A2594C72282701976 + A91B6957AB79A94755DFF07F8B3B696070D4E9BA6EA456CECDAB6E9DD3BE9B35 + A3EA7F45FF000C3C27AA7863E0E7C3DD2D7C57E36F15F86ED7C6DA4A785F51F1 + 0CB6135F49A11BDB636F1DD3D981148D1B89D03A6F2447F7B6915E91A96953F8 + 8BC413E857ACF616092B5F6AB2614186D9611248E64C90A52324E4E3F7B30524 + 1C67F3EBF64CF82DFB6A7C32D07E036A9F1B7E325C78FF00E144BE23F0FCF63A + 2AF8B2DB54D3F4FB796657B664C6656DCD223E14F9681B8072C47A3F81BE057E + D213FC5BF8F6BF16BE32DD7C44F805AFD8CFA6695E0CD42F4D89BBD36E26334D + 06A42048DE3545C42AEB21332112B6D2112BE7B129425CF66DEAD2DCE6C0D1FA + C3A947DB4230E6576DDAFADF952F37BDBA6DB9E91E10F1D7C37FDA33E30FC3BF + 8FBF073E22786BE24F847478F5EF08DDC7A6C12C49A42CF6292D9DBCA92AA33E + DF2A58C4A142BA3447AAB13DEFED29E2FF008E5A178F3E0D5B7C34F853E2BF8A + 9F0E12DD758D5B4ED11ADD6E2F23378E6E228E079A39E7BA7B64052340CD2005 + 01CE2BF3BBF67EF85F07EC0DFB40789BC3FE34F893A07837E057896E358B8D3A + 79E7B8682DE0B781E3D3ECF514680EDB8864BAD8ACA583F98A5DC87403E9BFDB + 0BF672FDA63E395F7C1FF8F5FB2A7ED3165A1492D869FA25868F1EBDA8E8B6DA + 8DEC4F28B69AD25584449739F311D6708184716583643674F152B2B2BA6BFCCF + 5330C9297D6145CD25071B3927AA7B2E8AF77A5DA47D23FB4CE8FA7FC54F865F + 186FBC27E3AF8E169A2E99A35BEA3ACF823C61E0EBFD2F446B6B6D924D269725 + FE9F6F2D8DFAA9575786791098F0536C8EE2C6A1F1B7E17F82B42F07F82FE2DF + C62F115FDFC1F0BAD27BBF0541A4C77BFDBB60F6FF0065FB6F98966D750C925C + 15457179122BA290A3E676F82FE26F877FE0A05E0FFD93FC4307C7EFDB1FE154 + 5E3E6F12E9D05858788B52B58F45B8D305BDC096CEEEF56CE3F3A7795A3B91B8 + 2C6A2C36EF6694AD7DD3FB457C03D6FC7DF01F5497F664F1F7C28BAF8CE740F0 + DEA9E1FD6F525591359D06DEE1F6DB36A0C8CA6CCB5CDCCF0B903F7A885812FB + D1D2936EF15F91CB8AC34694553AB52327B697B6B67EF34BA2BB77E97DEC4DF0 + ABE2F68B6E9F023E19EBFE3CF8847E2127C21D1FC4377E1B92CECE5D0EEED584 + 703DF35F4B6A6E16F565918158EE1323CB7298CE767E3C68DA7FC4EF87DE34F0 + BD8FC49B1F86FE27F1E32F86FC3F7F77E293A1EA0DA92A194DCE9CA260F3BC73 + 2D8C5F648CFCF6EF3E4067515F1DFC68F83DF1F7E1178CFF0068CF8BFE14F1FF + 00C38BDBFF0008781F4AD3BE1E41AE69D2CE90E8B6E19F57D335130C41CBC464 + 49E2BD76655316D7E0964DEF197EC8F69FB5A6AFFF0004F9F8DB79FB427833E3 + 7FC39D02E16CF57D43C397971A2C08934EA4DEE8A4DB02B7316AD6E612989253 + 1C3187388DD86D2C4351E58C77F4F530A183A5EDFDB4EA2B534D6977EF3B6D74 + 975B59DB5BA343F612F8C1F173C75F08B445F8DBA778C2CBE31F8443F84EF667 + D511E7BE821113FDADC8663F6C5B62F6EECD872E92499CC9C7E9BF8AF5C9757D + 44691AC5FCFE25D35E1584C77E7ED50C8A54FC8639B72B038C10DC71DF15F1EF + ECD1F0CB5BF0EF86BC53E2BF157C65F831F1EFC63AE78ABC42355D43C2C26B1B + 18D965582206D1AD605826023713050C15B18670031FA4B5A93C3DA3DC41A3D8 + EAFA45C5FDAABDA2C50CCD2465957122C5270B2F965883B58E013CFCD93B536D + C9C56DD2FF00D799E6E73469354EA452736DB7CA9DACEDD1ABAB35D6DBB69BD0 + 9B468EDF50BFBA8F53B633486F6E64F906E8D7182371FBC1F81C01D87B56D78F + B44F09F8C3C1D7DA2F8D342D3BC4362A56E9ED6F2C61BBB6695508899E39D5E3 + 6E588C80586E6C73C571FA7F8DB44F00E83E26F881E33796C3C31626D2E0DD2D + A3DDC61A47688910460BB12FE48C039C64FF000D6178A3E327C21D77C210EAF6 + 9E32F0FEBFE1EBCD286BD1C7650CB16A1359DB875B89ADF4F72B72645313AB70 + 5542B82432E2B4C5B7ECDC23ABFEBFE01E5E5EAF8C8D49FBB18B5AE9E4FF0027 + D0E1FE31FC1BF843E37F879E0FD3FE3FFC2DF05F89B42B6BB8B51D2B4FB982D9 + 2D7449E3CC62243BE20898088C858A39DE8C8CA145794FC4CD13F671D7EFA2F8 + A7E2CF0A7C27F187C68F0E69174FE1BBF96FAC1B50B5963679E0891D67788CA1 + D8F92644631973B369359FFB697C45D6BC69FB3D6BDF0FBE14FC4BF86367F152 + D74FD2FC55A5D9DFEA1033C5A6CD2DAEF9AE6CA58DDD6CE58672FB8A0F2C94C9 + DA0D7F37FF001A3E317ED7BF02BE306ABF0B7E2C3FC1AF1378934FF2BED90E9B + 0D9DD5BCFBA15979BBB628E0852411952AC08C0201AF3DD1A14A768DDAFEAE7D + 8E5197E371749C938C5EBA5DED7E9E5B6AB768FDE6F0778C7F6B1F077C4FB0F8 + FF00F0E3FE098FE13D37C7FA8EB369E28975A8BC097AF79AC4A97A9723ED579F + 68123A34B022CA8AE81F0D9EC6BEDFFD973E2C7ED0DF0D353D5BE32FC5FD13E3 + 0F837E244DAFDE78AF54B3D77416921BBBA92EE595E133885A5F20F9CC9E509B + 3E48540DC035FCE6FC1CFF0082D3FED49E07F893F0F746F8AF27C3BBAF819A5E + AD65278834BD13C2DA6C3AA5D686265927B6B2BD93A5C342CC892B36776D62D9 + C93FB2BF04BE2DFEDAFE26F1E6A5AD7C7DF16EABA37C287BE4D53C37A369BE13 + F0ADBCCFA3C9FBD86DF55B98D24BC8AFC432A5BC91C51AEC612E27DDB5C7D1E4 + 79657C6B70C2539CDAB5F955FBDAFDBE619A519E052FADCE9C20F6BC9DF65AAB + C7A792D343FA23F08FED91FB4CF8D2F2F63D1FF677D06DF4D8D17CA9AEF51960 + 12B0EACC197E5561CE32C5738249AE9E7FDA7BF68859E655F07FC0A89439015F + C41296519E84E3935F9A571FB50DE6B17020F115C6B71787B6847B2B088C21A3 + 030A81C1CE3A64FB53A0FDA23C0F0C10C31F8775B48D102A80AA7000E993C9FA + 9E6BEAEAF0967E9E986B2F257FC5B3EAF0FC45C30A294B149F9B9DBF2470373F + B2FF008EE15FDEF8BF45624F4FB200187B562DD7ECD5E3E12BB1D7F4B9A3887C + AF1C18F4E9EB5FA5C742D02F2EA4BA4F096A1294C6118B305FD7151DEE8FE1F5 + 8C492F8225283211813927B8C66BF7E8F136393B26BEE5FE67F2CACA7036D53F + BD9FC4FF00FC1440E81F0CBF696FDAC7E1B7C4B316ADA8F883E15E85069456C5 + A74FED3FB24735B1E06222AD0A8F309014E7B66BC6B53FDAFF00E12E99A758DD + 699AD789B54D66E7E1DE83E17D42D2CF4B7656923B5D6A3BDB6B8326C5037CFA + 5386048232549D856BDBBFE0B95A5DADA7FC140F53934ED366D3AD2EBC05E14B + 8113E772E219A2663E8372019E9D077AE3BE005F785749F077C0AD53C5DF0CBE + 1FFC52F04697E15F11EABAB68BACFC3FB3D4659EDAC2E2696E6E2DEE82179D15 + 36BCE8D89636D8C1F638DBFCD7C51467531988AF2766E4DBF9737F9FE47EE796 + D5C3D2C0D08B8B92E5495BFC31F2FEE2EDEBB187E1AFDAFBE0E278C61D52EBC7 + FF00193C036D75168BA66A5A858E8693C7269CDE1CB6D2B524B8B49E19D64646 + 1349148A37615D46DF355D6BE8FF00B527C1BB8FD8DBC03FB3C4BF10758F0CEA + 9E19BA3ACB3A4375E578A648351B76B3D32EA0FB332AC5E5896E9A459372C912 + 01820D6F786ADFE15E8FE29F03E8561F0A3F652D4F51F15EAFE16F0FCB6D6DA2 + 472F88FC3324F6B1EA4F7369A5CE8F14A265CDBC1722401F3189158C991E8FF0 + 7740F851E20D2FC1FAC5D7C0EFD95BE213DB6A3E3CF3755D3BC2725B477C34FD + 1E3B9B7D36EEC2E8A49186266958B219519191275DB86F9FB34A4EEB4FD2CFBF + 46CEBAEF0FFBBBC6697BAFECF4524AFA3DD26F7BF63CDBC7FF001E7E1578FB4D + F0DCFA47ED7767E1EB2D23C6FA9FD89357F0089754D4747D456EE61FDA9750CA + AF7896B247046CF23C40B5E99546F8941B337ED05E1CBAF0BCBE09F117C7DF80 + 361F126FFC51657F27896C6CE7BCB6D574C8ACEF6368B51BDD915FB234ADA648 + 914B33345242CE81B3835F45D07E0769F65AC6BFE35F82BF05BE22784ACFE184 + 7AD6ABA7D9786AE74FD4745BC6D164646925B328562FB4476C62BE4605C3B997 + 2C2463E59168BFB2DA7C23F08FC75D63F65EF15CFF000E359BBBBF0D472E8FAE + EA8B1E9DAE792C2D23D4247D41FCB495C34BBD436F58275550632A5D693A4DA7 + 6EFD7BDBEFBAFC4CF0B85A155414633693B2D29F55CC96CAEADD1A6B456B1F56 + 7847F6BAF853F03FE1CFED09AE7C47D2FF00668F1CFED15A8E972CDE1EBBB4B3 + 4D69F5ABD1B93377751C30DCB4530951FF00D21D650F193BB9603E7BF835F105 + BC73E13F8337DF133C6DE1B8B42D5FE286A1A76BD1DDA5A8974712E9FBA1D46C + C4840B5D91412DBE0611D042A4E579FB67E15FEC77FB28FC5FF1378EFE1EF823 + E037C3FB059BE1ECD059EA4DA96ADE7DA78AFCA8E237481EE592DA28EE5A1640 + 84875694C8A000A3F002F3C37A9E90D77A3F89AC614D52D2EAE34ABC2630C86E + 6090C72C4AE32AD8753D0E31B4E30466E309C2AB77D5A5E9A3FD7AFA9397D2C1 + 6268CA14EE9C5EADA575CCA49595DD92E8AEF65F2FD60F1F245F174FC7DF87BA + 97C41D33C59F137C0BF1D6CE5D3B5359A365D47C2D696F75A7446D5E16789234 + 856CA555562AD89886241CFB769FF166FF00C6FF0005BF6EEB6F82DF1020D37C + 77AC7C54B162D6770219352D10DEDC45A98866C705E29E39B0086783CE284ED6 + 07F0B934AB585644B688DBC6D1189D63F9519491F2B01805723EE9C8C8CFD3D3 + BE107C32F18F8CF5EB9F0E781751BFD1CDCC6ABA95DA5D4B6F6D0C19E0DC18C8 + DEB9C858FE62C4E00FBC46F0C2D44941AF5FC12FC8DF1597D0507273B28B4D5E + 3A2B34DA7AECDEDB5B63FAF6D1BE27783FFE152FECDDE184D4F4F8B578B5FF00 + 0523DBACEABB123BA87CC4923EBB020E78272474C578DFC3EFDA67C25E30FDB3 + 7E347ECE1E3ED45F47B88F5429736D21666BFB28AF629A48A2746DD2916ED6F7 + 062465778E22403B30BF0B7ECC1F0E7C31F0C3C59F0C7C29A64B3EA50B788B47 + 7BCBFBE0EF777F2FF684019DC6E601407C2C4BF2A024A9C972FF004CFED75FF0 + 4F2F0D7ED05F15EC7E29E9DF11BC4FF09FE25C4B6B05DDD6976A2F7FB45616D9 + 6D22169A278AEE3501164562A512305495DD5E3665395271F68B46799C2B91D1 + C654AAA351A95DB8BDB7F2F24EDF33CFFF006D0F875F0BFC0FE18D17C1FA2F85 + 740F86DE3258358B1F0E786BC3BA9C375A0DE594F23CB75279DD62937F932409 + 9CED6685A352A02FDE9F007C77E35F067C1AFD867C270781B46F11786FC433A6 + 9373AB5CDEC90DD68B3C97372D1CD6B6E2D6459C32A4DB9FCD876F1B4BEE38F9 + 2FE36FECA317883E2BFC0EFD97B59F13F8DEE4CDF0EFC556D6DE239F5092F355 + 5BD8044F6BA9493B15692E05C2EF652CA183BA02A0A95F58FD9B3F649F80FE16 + F18B789FC2DF1DBF691F8C96BE0FF0FDDE8FAEE817DADB6A567AB6A771E6C6B7 + 56B6ACD9B3B90D1CA62B542FF746655DC777152949AB45597FC17FA9EEE3A387 + 842319CF9DB5A5B6972ADEF7B25D75EBB5968BCFBF6BBB9D57E247C11FDA2F40 + B709A847A745078974B2EC3CCB69ECAE9659234738037C4678F0C48064E075C7 + 71FB147C56BEB6FD9B7F657F049FEC8BBD62D7C43AFF0081AE0DCDD446E534FB + 08750BDB388C45C968F7CB670703206074AF573F14FE186B3F15BC1FFB376AFF + 000BF5CB9F08F8D34ABEB2D72DB5BD3AF3C39AAE8266B5BAFF0044D434EB885F + CC8E7B6B691D2E21700027032BCFCA5E31FD857F657F0278474C6F0D7C14F8B3 + F0FEC7C416BA27C2ED52EF5BD41B4CF103C925F47347E20B29227B887EDECF66 + 893168E147463BA101DABADD47CAA305B1E3A8D37192ABA293D3676E97DFA2FC + 5F6B9F47FED19FB557C38FD9574AF065FF00C505F88DE24BFF00883E203247A6 + 787A38CDD1D02C9E192737504CD8FB14D2CBE4CA83F792AA6102F9995F997F65 + 8F10C5FB36681FB677ECD7A86AD6EF63F0C3C432F8D7C153C727EE753D2AF6D1 + DE09559982A21B84B59D97394799F8418C7B7F873E1178035FD32D7E0D786FE1 + 9457F0FC0BF897633783EF74BF11A683ABB9B442ED77797B74CD15D4AFE7B3DC + 2011F9E33B3CA2833C6F8B75AF86DF007E1F7FC1489BC3FF000A3C31E2CF0BEB + 8BA1EBBE25D32CADA59AEF5F975D99ACEEEC02F9C044105FC9246B079382FE61 + C1C80AB4EAC9F3CBFAD97FC00A4B0F0A0B0B453727DECBDE4EE9EEEDD5FE7DD7 + 33F0CBC0DA17C47FD9D6EBC29A97C41F851E1AD760B8D75B4FD735661757FA16 + A4CD0A417969B1D44444909121925889DD104F33915DF7C04D66C7C6BA3785D7 + 48F8CFFB34FED39A468B7135CE8DA931946BFA55BAC9334317F679B6B855BA80 + 5CCD10B98E6816489959882CC6BE79B4F007EC63F06FE166A7E2AF861FB2A6B9 + 69A7FC4BF0DDD7846EF48F1B6B975A834F651DF5BDCCA9A8C11DE6D5955EDA36 + 8A6B573246EB19528464FD69F093F66FFD9D7F653F881AFF0088FE09FC37B7D0 + BC4DA8F8526B79B50D4F5ABED46EAC236BD43B607B976411BA797BB6AEE6687A + EDC83B5384F99396C7978FC4D0A30942126E5A28E8ACF4EEAEFA5D7C8F4BFDA0 + D34887F662F8C1A96BB7DA7E89A7C13D8857B89E38916592FA088167918023E4 + 08325492C3AE029F02F86DE3FF0085363FB284BF6BFDA43C33690DC68FAAF866 + EBC27A7A585D36A771A8B5DC76046A51C8D730DCCB20314768BB55FECF23956C + 363D23F68DD63C61AD7C018FC3BABE9B1EADE0EF1280BAF41736966F6B796B70 + 1A48ED44722E77C6B6F0CC40313FEF5447264FC9EBDF00FF00636FD9BB47F824 + 93787FE05FC3FD0340F10DFE9BE25D52DA2373209750B109259CC5A499D94C12 + 79AF1A8608BE748A5712C8A5CE325272A6B46703C4D15454716DA927A256D9B4 + F4BF5DFEE3E02F8FBFB55787742F801E26F00F887E2A695A0781A3D0FC1BE15D + 0AEA5B294A5E6BD657500F12E962748B22E2DEDAE6C1A68E4F9A20A51705981C + 6F1B78D3F603F8BDFB72FC2AF1B6A9E38B0F88DE2FD5F413A3E9D63E23F021B9 + 84D9DD5B4B3E8F35AD8CD6EB15F339BF4489EE72DE44312B18B9AFA4FF006B7F + 0D681A1F8AFE13785340D1FC2ACFAD789A6F13EB76D73A6D84B16BD7D79776D1 + DCDDCB6F728DE65C4A8A51E451BD9300FB779A8E8FF05CFED4DF0A60F0A7C2CF + 8611E956736BD6CECFE0285EE34D161A46EB3B4B55FB24573F67B59A04B9823B + 5386F35D219183A9AE3AB46575CD64F43E9B2ACDA9C294952E6945464EF7E8AC + B4D15EF6DBBB7D0FCD7F85FF00B377FC135BC4FF00F0503F8ABF08EE5BC5FE28 + F8BB75E2BBABED2B44FEC1BBD2ACB4AD5A290DFCBA659DAC4B1410A5BFD9AE22 + 293868E48C158BB0AFDC7D53E0BFC45BDD4F54BBB4F859A83C73DC4B74AEF7CB + 1B3EE72D9DA7A1CB1AF3FF0013F8974CD03E275FF89BC5BAEFC3FF000369DE1C + D3878AFC69E2436EDA2D84B35B22C4935D3BBBCE892DCCF6D0A096496511B140 + CCCE73FA0DA7EA31CB2D85DB4FAACF0DCC51C824FB434884380DC1E46D39E08E + 0822BF5CF093309E16A623D82BC9DB7EC9BE9E57FC4F91E309C71D0A3F599495 + 975D75B24EDA5B5D3A5F667C4EBF03FE25306127C30BC8D79CAFDAD4EDF6C77A + AABF04FC7918119F863E2052A318170D81FA57E844CB70ADBE27D4EC231CA2A4 + AC41FAD02E7536018493904672666E6BF6F871562FF917E27C1CB87B09B3A8FF + 0003D0AD7C612B9923B76BCB1D3B70E05B0C2E7FDA079A6DCEB3E1C8E069AF35 + 2B8BCFE25855031603B63B74FAD79227867C4221B95B7F127881E3660A9E65B0 + 0A99FE2C918AEAA0F85DA67FA2DC4BE28D623B98D4B4C55902961CF200F6E95E + 3CA8508EBCD6F4FF008626157112FB3F7FFC39FC91FF00C169757BDF8ADFB666 + BBE1CF03E897BE0AD334CD1EC747D72FB5A51650CA9616AB706F3CF1BD8E9EC2 + F95D1FAB3464EC016BE1ED17E19FED71E10B2F0FE89E06F1C7ECFF00AF68DA3E + 8DAC2594D69E23D3AE636B0D7AD912F62952E5118B491431BA8745640C1D4956 + 527EEFFF0082B778BFC59F0EFF00E0A1FA9E95A878974AF01DBDBF85F4BBCF0B + 78866126A56FA8E9ED6FE5C06FE281965B6DD3457E8FE5E5A311404210CC5BE5 + 0F86FF00103F653F1E7ED47E1586FD7C17E1BF09EB5F0BAFBC3FE3B991FF00B0 + 346D47598DE4F2A4B595C44B0CA618EDD167555DD2428FCB972DFCF7C4F5B971 + 3512D62DCBCB6BFCFA5BE68FDA385E1386160A70D6CE5B396EFBAB2D62ECB7ED + 6465DAF86FFE0A53A4DBEADF0ADFE1ED978A358F09C3A1DE59695E658DE6A76D + 0E96D05E5A9D2A18AEFCCB92123851C448EEC8CF1AA83B80B17D79FF000511B4 + F1DE99F162F3E037873555BEB5D4FC673D9E9F6B6896DAD4DAC0369757ACB6F7 + 81DEECBF9AAF1478789FCDDD1805ABA3F847E3AF03EB3F053E06FC7C6F1169DA + 778C3C3DE08F889E10F1F7DB2698DC4DE65A09F4E2F2481DE5DC67B98143333E + 5507DD606BD8FC4FA28F14FC0EF839E21B1D5B541E23F0EF8C7C0167E20B7B86 + F32CA7F0B5E582476AF2C6ABBC4715E4D6EB32924482652036DE7C2BCE516A4F + B7E2ED7FC13FF827A152BD2A7594634A3F1493D1AB74FBDE967E6BB9E03F0CFC + 43FF00050BF03EBD65ACF84BF647D6B58974BF01BFC19D547FC23F773DAEA56B + 2C77EB99DA39C29B8316A9227C8CD0B2246769CB03F25EAFF103E28FC30FD932 + 5FD94FC79F06BC59E14B7D5FC4BA5F8A345D775CB3BDD2DA41626E9A4852D6E2 + 055B8CFDBD732238D800CAB6EC8FD4FF000E7C3279BC67FB387C3DF11DAF8B3C + 0DF0A7C49E3EF11F873C6715C7C418B57F0F8D425D3CB585FD84819A5B68A2B5 + 5B992269642505B2B32C4C416EA7E145B697F11BF61CF12FECB7FB565D687ABF + 8FE1BFD4D3C3573AC4ED733687ABAC135BC1A8DBC91364624F25C042CB2AC8E0 + AC9BEB9ABB4A2EA4BCBF34FF003D763D3C1E2E9CA6A318C7752D347EEDD736EE + F6B3B6BB35D59F247ECDBFB79F86BE1EFED37E21F8ABA07C00F1C6AB77E27F0A + 68FA15C693A56AF6AD3DD6B16D68B6F35E9F36354F2E63123B0FBCBB5E463962 + 2BD33E3D7863C25FB46F89F5BD6353F0A7FC2B9865D564D6934FD2A5B626CA59 + 547DA13CC862589CCAE1DDA4541B9CEE0C4F2DE5BF0ABE0CE97F0BF4B9841241 + AE788E6686DF50D5446CBF2328631DB86E561C8C63EF39505C8E157D4344B7B5 + B1D5E33F6B79DA76DB9653D092C41C8C6396CFB01C706BDA8E19C1C677BA7F85 + CF90CC31946A55954C3AB4E2959EB77656EFD17CFB9F2DF8D7F667D3FC43E27D + 2EFBC19791F857C36EB0595D5B3D93C8D6D3460237958F91C9DB9F9D81246F62 + 771AFA77C23F0EF4CF02E9D61A2786ACD6D7488AE0B4AED26E9A57C006591C00 + 5DF81CE3031850060551F1AF8D7C5BF0EFE1DEA5F14BC2BE1FD23C6BA4E8DE26 + D1F4CD5B4E91567456BAF3D63CC251D5C8F2D6321F19F3901EB5ED7F177F6CFF + 000978EFC25F05BE35FC38FD9D7C0BE17F0BDA789EDFC1BAC58ADADB94B9BE9A + 3B999509B522396DB6D83AA153E629964C4ADB06EE97895ED3923AED7F9DADF7 + DCC6A53C6D6A5093F835B5DEFF00AFCCF4AF0369B71178FBC03770C37A8D1EAD + A65C02C48793FE2616BC67031F7B3C7A038CE057EE1450C73DB5D46D1A0BFB79 + 06C468C654EE38C1EAA460824631C63822BC5BE34FC18F86F65E1AF83BF103E1 + E58E8D0ACBE25F0CA79D6F12C0B7163797D67228608155D90CB18DE54370464E + 4E7CE7C5DF11FE25F85FE3DF83FC1369AD413783B5CB15BC360F670B00A23999 + A5F39A3F3049B8A390ADB711F6C15AF271D3F6A9795CF1B0B39D39C696D2BDB7 + F4FC3728FC6ABABD1FB727ECBF791C104F7773E17F144121DE1635431AA2C8AC + CF8E2478E4273FC2DD785AFCCFF807FB4DFEC07E08F8ADF157C572FC62FDA9BF + 659F15DFDEDC5BEBBE768E9AAE9DA9B1BA9259A0BDB5BAB5D46181EDE6575478 + D6309BE41965C2D7D03FB75F8F3C71F0DFE3AFECF7E35F09788358F0C6BF1DAE + AD6715E5A2A6618A58ED22954AB8652AE19918119031CF435EF3E18F871A7FC4 + EF859F00BF685F18FEC6FF00B2EFC7EF17DFC4755F1BF8B356D021B4D78CCFA9 + 7916D3446280C1777062DECFE62B3130A1DA14BBAF930A72943992EBFA9F7117 + 4F0F4E1F586DC1423F0BB6EBB5ACEDD2EFE4CE7EEBE34781BE2D7ED99FB257C3 + 0F07DAFC41F1EEAFE1BD0EE3C7E359D534A8AC750D5FC3D7D66D2C6638E38AD6 + 16891250C418A2915DA5508AC25DFC0F8FAFBC43E0BF8F3FB2E7ECF7F14B52F8 + 99F117E23EBD1CFE25D26F85A5BC363AA5DC37979792C11C65C4626B4B582DED + 447B43BAF9183FBEC5769FB5A59D97877C23E2EF1C6A36FA7CBE2FD0FC610695 + A6F8B525163AA41A64EF36EB6FED3004B6F03C922B3AF98230559DC6066BE81F + 04F8EF5DBBD2FE02699E2FF127C43BAF1749E17B78D74F9FC13F6BB2BAD50D95 + C16F37C486271697322DBC8851640488B258F9A0129C65CAF95EB739310E1CC9 + 3568593DF572F5B6D7B5D5B5BF4D2DF9FE9AB2FC75D67E1241E1C87C63E0FD2F + E2C7C68975ED0B5FD7ED1EC6D74D5D1A39E6963D4E1044D69E7F96FE44589524 + F999990C654FA8E8C7E28F8BBE077EDBBF13EC7E01FC45D37C493EBF268A9E0F + D5B6DAEADAD5AD9B2195ADB11B452878AE1963F2DE5131819518965AFAE7C22F + AFFC69F857F0C3C77A8EB37B71E10D634CB74F12E8F398EEAC75D86E227697ED + 2D20766F2D7CA48F690AAC89B79C83CEFC01F016BDAC7C09F819E31B1F89FE2F + B0F0DE83ABCF67A9693713C7268FE2AD15F53BA3776FA85A4EB234A9E4AC9144 + 40050851B86FE76A74E696ACF2F138DA552D186895969EF6FA35A5B469DAFA34 + 7C65FB567EC9FF001BBC49FB16FC1B5F863E18F1737C5ED1AE6C75A93C2D61B6 + DB54B7B2BCB475B8B38A266DD35CDACB35A8645193E44DF210028F59F833F107 + F6A7F891A1FECE9A3FC52FD9C34AF03F87FC493DF41E2ED6F50D4DA19FC3B636 + 8CBE5DEDDE9A211730ADE334CB6F08947EF0EE6C204ACDFD8693E21784BC1BF1 + 17E1678AAD74ED4BC2BA06A97A3E1FDD9D424B9BCD3741BD174D05B48CF8DCF1 + 47108A3DCCE5167DA40F2A3CCFF1C7C66B61F1EFC24DA27ED4FF0006FE1B789B + 4CD374F95BC1BE21964846AD285926547992556B682E207541388662AFE5E164 + C1517256F79E9E40DA69518F2CEEF4959DECD593B27D1EDBED677B9E65F11BF6 + 7CFDA474AF8A9FB47FC40F06F89FE056B5E37F1AF8BC681E1AD1FC5DE3386C2C + 3C4BE1DFB30BB867B34173E55ADFE96F6EB6C206F2BCD85A475494AB39FD0AF8 + 15F10E2F861E0AF02784BF682F19F86BC3FF001A6F6D6FF4FD4F4DD1EF1AEBC3 + 96D756B1B5F49159DC2AB22B8B15B5B96691F69DD26D663915F9ABF1B3C5DF0C + BE0B7C4CFD9D7C73E329BE1F783FC6BAC78ACAEA4FE18D65AEEDAE74E5B392D5 + B51BE22DADA290C333DB44D72B19624B6F918ABEDF69F8AFF15BE19E8DE39F05 + F8934AF1E6897EDA03EB3E28D66E277115A688FA8688B67A4C174F9DA3ED1241 + 8883ECF3F0163660E8EC51928272EA679A60E58CF674A4BDD927AABA7EEE895D + F4BF4B76B696BF5BFB54DA9F8E7F13BE166A7F097F690F00FC21F0B69FA06A9A + F2EA7ADF8506BFA6EAD25BDCDB9B6B8B5BB56681364D2C69389248D961292C49 + 390C173AC7E08FED2FE1EF89DF017E3A3FED13E0CBBF0D43A8684BE23D1B46F0 + F224BADEA97ED63A6EA925A6A2F146F1595C48A2487680F121915045B8356AFC + 24F177C40F893FB43F86EF3C5B71ABE95E2EF0CF842C741F14FD8EC842FE1AF1 + 5DC3C336A3652A863F67B80D688EB112C8B1449B1C8CD7D63F126F63D2F43F0D + DADBDCCD2CE7C5FE1616A858B3394F1169F92CC79248E7F1A894233E69DF6FF8 + 052C5D5C2D3A785824D497557BA7CCDEB6BE8B5FC366D1F2168DF0FD3E287C69 + F8D3FB397C54F157C6BF8E16F178D6CBE23DBDE2EA565BBC45A5E992DACB69E1 + 8B8B2758629E022578DAE7ED10C8DB15F081156BF5BF4BBCB2F0CDA693E11F0B + 6897FE1EF0E5ADAC76F6765144D7096902A0096EB233B96D8008F1B982840A0E + D0B5F979E26F82FF001ABC5BF187E3CD869BE01F1BE8FA4788AD64F00689E21B + 3B37B88ED85FE98D35BEB022B66F33EC08DA5496B34A8CB245732C0853E72D5F + 62DE7C5CD476878AEB48B1B360AC8F6D70D3CCACBF7D0E547CC183020E1B39C8 + 06BF5BF083035AA55AB24AF1B6B7B5EEDFDFDF65667CEF1AE2E29C20E5A2D92D + 969BF6BBEDD0F7EBDF14DE59169A6BDD4E1527207D8DB117A8383C7E359726B3 + BDDDDED6FE462492C11FE63EB5F3EDD7C451E209EF6DAFB59D3EF0B27988A2E0 + 45207CE00C1EA0FA9AE4C7C58F10403C91E16D5DC27CB91A9A8071C71C57EFD0 + CAE6D6DA9F9DBC6416ECBCFF00B6FDBF9DA7C707867C65728AA7CAB6BB591C7E + 0B81FAD606ADFB6D78948D434AB6F877268CB776D25BACA22945C4123A141347 + B7A3AEF565CF702BDD9B57F0F4F0DD4D1FC37F105CDD42FB5DD34F5D87D80EA2 + B8D7F185A9D4ED34ED3FE18EA96F70F3AA461ACDD9E472DC7CC0617FC9AEF851 + C2CAEBD97E3FF04F31D4AF7BA9FE1FF00FC0FD73C67F0B3E35F8AFC45E38FDA5 + 7E1D699F133C5DE1FD2AD6D26BFD5ADE5BFD42E6D22B686DA2B58CC922AF98F7 + 46EC80E49F3268D94A05DB5E51F167E087ECCBA778A3F662B4D0BF6729B4DBCF + 1843A9784EF8D9EB5730F87A3D62D6EE4C492B4571E70BA685ADE512F98607B7 + 9A1758C98DC8ECBF6DAB3F889AB7C7D8BE26FEC77F0BBED5F0E753D0F41D6B5B + 0D343241AD6AEDA85E5CC134515CCE93C71B98E2212158C33DB3928BB327E26F + 0D6B5FB5FF00C14F037C3FF869E21FD9C7C6B7FA0699E2D3E3AD126BED035179 + 9A4860B8B79E28A6B63247F66C5F90E71B811100C36F3FC619C538D2C5CA3CCA + 4A32B732774D75D7ADD36EFE5A1FD1DC3D83AB530A9C2AEAE3A479ACD36B4D13 + D2D25B6D67ADACD1D4E97FB3E7C00F8843C5D65E1CF835FB52D9788F4BD5A2D0 + B5FD186AF6F3EABA0EA10452CB7CF169725BCB35CDBC48B873BE496329955DB2 + 56A7C39FD91BF66FF899A9FC2FD3F46F13FED2FE15F87FE36BE9E0D2BC52E34C + BAB7F205F18A24BFB248E3105C2A9B597CA328DEA4C91919289E67A57ED83A6E + 9DF13BE2778F7E2A7C19D1F53BFF0012F8E65F1ECB671EA97DA64BA4CD342F14 + D0DBB79B6F3BC6F14F2821E40AF94241D8A46EFC2DFDA33F672F095DFC29B3D6 + BC17F120F852C348F19E89AA5B4422BBB892DEE5CB6872C722DC44B3DCDA09A5 + DD3058D81031BD48038229B8A9545AB5F8FF005B7CCFA0C4C715172F60E574D5 + B66ACA2F6BB6EF7DEF6BF6FB47736FFF0004F0F1B6BBF0BFC23F103E1B7ED3FE + 17F147856F7C6ABE1FB787524D4F4731EF63143A9410B4D2C933182682478923 + 134715C1CE5158D7D69E02FF008259DBF837E22F802CEFFE2D787FE217C42D72 + D751BC5D52F34DBFB5B6D221B3081A38A376925B99A446631B31500238C4614B + 1F8F3E0B7ED7FE09F04E99F017C11E21BDF1758F85F43BCD1352D5A46D384D06 + 9F776F67F65BB922F2CB4CE196CB4C20A29DC1E5180579FA57C5DFF052CD02DB + F694F85FF123C3FE25B3F1AF822DFC777575A6C6CAD68DE13D12DA48EDE04B88 + 0C684FDBA23732CC252702553F2F92A042A71E6517B7A7A5BE5FD7438B33AB9A + CDB85257B7556D56BA6DBE9B69D346DA4FEDCF197ECA775E19D47E28E892F8F3 + C1169A7F86A3D2D3537D4EE24B1B9B99EFC466CC436CD1BB4818B38023672769 + 276804D7C21FB75E85E30FD93E2F07E86D7FE1BBAF14F8816FA482EF4E99AE22 + D323B478A2930B24633397B8528DCAA8DCDC9DB556DBE2C7C1CF869E31B6F00D + 87C62F05F8B74193E23F892C96E9B5D8AF0A58DBEAF6DA8E937AF70CFC24B6D3 + CD0ACA58A8789A3CF2C2BDE3FE0AC7E0ED1BE2E5A7C1BF187C37F889F0DFC64F + 6371AF417AB0F892D26115A4AD6D20BB965491846A0C1B5B7919DD9E718AEB9E + 3DA8D35BDDFDDA2FD59E065592A8625CABBB46CDABAB736F6FCAEFFC99F977FB + 32FED2BF1BFE140F889E05F859E1CD7FE21C5E2ED2EF34DD4F4CB1B67BB9EF21 + B98BC99D644F227DEB2823E6203ABFCC8E19981A7E16FDA8B54B287E2C7C34F8 + BBF0D547F69F8C2D3C5C9A7E91A6C96571A16BF68AD1C68B66F828A44D73BD48 + 24999C9427614ECBE05EA163E1EF859E3FB09FC2BF10756F09CBACA453F8CFC3 + 965791ADA5C8484A959A00668C46C30B24F0B43224EC190336DAFADFC17F107F + 6976FDAA34BF84FA17C79F106B5178ABC23A7788BC25AD5D6A525AEA56424852 + D6CF4ED426B3689196196192D5A4540766255DA1BCB1BE2AA5AA464BF2BF4BD9 + FE87D0CA8C5BAB6A6BA3BB934DD9AD568D2B5FC9F7BDF4FD1EF863FB46FC46F8 + 95A4FC06F0F5CFC33F187C32F87A7C59E148ADADBC470186F6E2DE3D42D63498 + 443FD5A168381260B05CA80006357F6C2F8F1AF7C1AFDA9FE1D78974FF00D9EB + E3BFC6BF075AE850DE5BDEF852CBED68025BDC5A5C44C16261034770D1310ED8 + 6431B8E5805B3E15FDA73F6C3F095DFECFBF017F693F85FF000E7489F5AD4FC3 + F6E35EB6F19B6B97BA9C51EB56A8F24CB126C173BA45DD2C92B336C0555B2587 + D71E1EF8C12789FE31F8BFE1B4171756FA6E87777A134A8E5F2ED67BE8428592 + 7D843B96326E2C4907EEFCB915E4CB99ABC1DB73E5A8D1A747136A9053BBF76D + 2D3D6E8FCEEFDA7F57F883FB4FF87BF673F10E91F096EBE1D7C569FC33E23F17 + 69BA078AE78EC6FA68ECD018F489C958479974B69E6C2CC431678A30A0C95F46 + FEC3DE3FFDBEADBC39E10F83DF127F64ED0FE06FC17D36D26967F136BBAACF2E + A77C0F9CD0AD959890E599E50BE610238A3DEC4972AADC27ED8FF0FF00C697DE + 07F08EADF17EEB47D53C61A178CAE34E835D8F498AD23BED26EEC7ED5025C5BC + 19851A3BA8618F78552C18338DC58B7D8BF05F59F87DE14F84DFF04FEF02F8F7 + 48F891FF0009878E344D622F0ECFA0EBB77A758696F69737055F5316F730ACAB + 222430C41E2B852772ED8D739E75271873F5FBB7FEBF33E8F1105384A8538AE5 + B596F2B35D9DD2B6CD69F2678C7ED63F0EFC4BE23FD9BBC697FF0000AFFC01F1 + 63C6127882DEF24B0D4B54B4F22FF6CC527B323ED11209D526F382CA46E10CBB + B048A6FECCF07EDA5E30F807E2CF84DFB425CFC2AFD9A742B8F07C9E1CF001F0 + 9DEAEA3A9B5F4D0342355B811DCDD462D5005C44A43BC8495D8114D62FC25F89 + 23C75E25F8D7ACDEE8D7FE1FF0AF8D3E2CE91E1291DC63FB2EF2EB4BBC8ACA59 + 39085E4BBB5862393FEB2E8819049AF4AD7753F8B5AF7C4EF84FE3AF82573F0E + 7FE1178747D5F4EB9F09EADAE8D2B51BDB44B97B3824D3AE1D1E1596D9608834 + 72EC0E0B856423822D4DDE3A5FFC91E5E25D68D08D19349E9EF5AEF7F9AD9DB6 + FF0033E7CFD957F647FDABBE127ECF3F123F67AF8F3F14F43F879E16D434BBED + 2BC190F85A69350BBF0FC93B3892F16EDB606B70CCD2C3687730F3E526480909 + 5D87C0BF01F83FF6009BC39E21F88FF1CBF693FDA2F5ABEB492C748B4BDBB857 + 4BF0B5A24F134925BE9525D36EB9725479BB98C71F98130F264FD2D1785ACFC0 + F349A743E0AF06782353BBBC4D6351B5F0F98648A7BD9621BDAE0C1147189815 + 52DE5AB6719DCC18357CF9FB5AEABA1DE5F7ECFF00E0C716D36BBAD5DDFAE936 + 65D8DC6A456EEDBCE5B6894179A48D0090AA8E1465801863D51A3C96937B799E + 366398D5AEFD8415E351A4D24AED75D747EAEFF99D8783344F807FB1F69DE31F + 07787BC4DF11BE22EBFAD78B5B55B4FF00848E346BFD23449248EDE4B3B19E41 + FE9D65661832B2C8030691701A4515C27C5DF81BFB26FED4BAC78C3C57F18FE1 + 2F88BC59E35F075C2F86607D23C41269975ACE9F6EE256DAD01D84A7DA6E1C45 + 2A17F95D5240190533F69736173F1AFF00661F015CDB78DB52F19F8A2D750BDF + 0D45E534EB752464BDE59DBC83F771B476D1C7388B78671E584CB1453E1163E3 + 5F8A9E2FF1BF8075BF85DF08BE30DD68BE23D7B5AF1A68DAB4B630D9699E26D1 + EDAC2E6DA6D34CA2532E9DA84D20FF00465BD8E1CCBF66760A8F91CDCD14B53D + 4C361FDACFDADF965DEED6D75D1AD3DD7E4ED2ECCF70F1CFC25FD90FF68CF85D + F093C17A0FECF365E30F86FE06BED4BC2DA359D9789DB4BFF845ECE0BA686FA2 + 92732C5F6987CD884D3C45A49DF72CA14C8CF9D9FDA1F54D27E1F78F3C2FA778 + 5BE12FC1DD5A0F13E89A1E8BE20875CF0B5BEAD6FAED869B7D143A7D932CDFEA + 85AE23F21A2DA408D436E11C6A3C5FF66ED47E2EFC44F1BF8DADFE237EC26BFB + 38A69C67D43FE137BCB2FECDBBBC990B456BE7C2A2117D7ED1491ABCC5A68B10 + 9772C1806F5DFDADBE147C79F18F8F7E05C9FB3EF8A3F66C88C36462BDD2FE22 + F8816C4C52C570B71692411A9F3A612219D248E3539F255B80015DD4232839B5 + F81C75EAD4A3898E169CED1D5EB2BAD7A5EED6AEEDF9EBD99ECFA57C75F11689 + F1C9FC39A6F857E1569DE1CD5E2BED6FC4573E1FB08EEE6F15456D0B416AF3CF + F648A66BAB65B19ADCAA3CCAB931AB9F2801816573F1CB5FF1A7C5CF016832F8 + 33C59AA787741F0D78A6C2D753B006CC5C45A85CB34B0B5BEC912E2665D36453 + B9A28DE20FE5056615C6F8A3E0AFC64F8A3E36D3347F88BFB6BFC31D13C7B2D8 + DA68B67A2E8DA5DCDE43750C76D00F13589BF31B4F6E59DA03653C12C12C114E + CCE8189993CDFE11FC3DF11787FE37788BC65FF0DF7E28F1CF87627F0EDDCFE1 + 27F05BDB491F8596774B58750BE313493CD0D9C7770315114934EB99E401C124 + AABBA5CA4D0C02709C9CEEF97B3EFDED6D36BEC7D19F01B445D0BF6FBF899AF2 + 4F14BA2CFA35FCE6E7CAF31DE26BCB7D88EC99F3369F9707760EE000CE2BC37C + 4BA87C33D37C4FACD95C6ABAE6937F16A1725A1B40CE7779AF9756DDB7E6EBEB + CF4AEFBF669F861F0575EFDA87F697F8B0BE12F8EFE1AF8A562FA958EA7A337C + 4182F3C3F6EB7D14B6F733DB583DADBAC6DFBA79551E4956396E328A36214E43 + 58F14689A7788B59D0AE7C3DE0FF000EF8774ED467B24BB79D2283516476443B + 9D382FB73B7AE4E3AD7EDFE0BE32961FEB356BCD476DFB2BEB7D8F90E2CCBE58 + AAF0A7874E72B25F3B76FD4B49E25F87F16E91EEB58959584DE79B32E6541D8B + 9CEEC1AB27E2C7C10725DEE6F2473C9636370371F5E95D7DDFC44B1B1F0DE9FA + 859E81E12D734C8A16DB1C77B0C62D877277004E6B824F8C7E159D1268BC1FE1 + C11380CB9BB8B383C8AFDA6A7166060D3A95A31BED79257FBEC7CF438471EF48 + 5193B764CFD00B4F8D9278827F3B4786386D78DB36F9019FF02302ACC7F133C4 + 526A11CEBE1BD41ED5668C896391891F30F98E48000FE95F2C687FF092F88E59 + 26D57E145DE8C15F6ABFF6AAB9E0F5DA0E057A0597867569C5CBC9A6CB69B949 + 21F5176053DD46067B7D2BA2A6128C5688F16352A4B43F9E0B11E27B0F8A167E + 03F183685188FC49A0C5670F88D255B6B9B4BFD1358D3D62BB865DB2F970B4C6 + D1FCA384081970C40AE9BC2BF16FC59A1FC33B9D5BC1DE26BCF0EE8CBF05F41F + 116896D6F7935C3E9DF6FF001447657B14AF233799308D1E332F2EC8E859838E + 3E94FF0082827ECE3E19F8EFF17BE0BE9DE21B3F169B98FC3D716735DE91736D + 25C69B149A995174F6B3EE6B8B58DD944AD16E30ACAAE53692C3F383C21FB0C4 + 7E23D4DBC13FB3D7ED13E21B7F1178C6C6F7FB2ACF5BF0FCFA669FE2DD261BD6 + 8CDBFDBED24712B2DCD8FCC8D0ED578E362137293FC8DC4996CF078EAB86BF34 + 62DBBDBA28DBD74BDFE47EF39257C16230909CBDC9592B59B5F137E6B5B3DF6B + EFB5FF006335187C37E30FF82887C18F0A4BE08D46F3565F87B7BA7DB78D66D4 + 22BDD3F548CF957126971AB42EBE7DA3CB148EFE71644B8286240EACDF0F597F + C335DC69DFB5EEA5A7FECF7A7F88341F15FC51B0F0BC5A6F897C3367A35E6812 + 5CC124D2A40D6E64961B68DB4E7688C325BC845D6FC26D21FE55D37E117EDC53 + 78313C4BA5FC66F03F88757F0FEAE74DD4FC357BE30B196EBC3F2DF9B68C4D34 + B7718B59566105A6EF2A77915111F1B58B5757E4FF00C144EDB769177F04ECBE + 2FDCDCF8B3C33ABC5A8E8EB67AB21BBD22016B636826D3AEDE316F242150798A + 2490212ADF2B01E0DA10FF0086EED4BBF9D8EFC3E0A76BC6AC764B49BFB2F57F + 759DD3EF6DCFA2FE29FEC9FF00B12F8A7C27F1123F853F0E7C47E07F14EAFAAE + 85A2F8045A78A350D41E769ADADAF67923B79E592262D12DD44C6524447202BB + 84CFCA9A7FEC69E0BF8FDFB32EA1F1A3F659F86BFB46C5E38D1666B5BAD33514 + B6BEB0F12B09504B159F99E4DC25C45134EE5605B98D9A35887CEE31E7BA87C7 + 0FDA17E02F867E0EEA5E3DF807E2AF00DBE8DE33FEDCD175DD5ECAF6CE2D47EC + D1DCC0DA703347E533C29346BB8BEEC5AA6F5218B57D1FA0FF00C1403C4FA2F8 + 6BC73F133C1DE16F88BA768D75AAB6A7A9F88F5ED6A06F3EEA6BB9278ECECE27 + 8DE49B64B2CA88EB2AAC519412312AACDC9566D5DC5F6FC97FC1FF00863DFA50 + AF469D38397326EDCCDDD7C4D6CDDDDD5ACAFA5DA567767E7EFC35F81579E2AF + 0EEA9E3CF172EBBE18F84BA45AC9A8EA5A85BD91B8BAB9B7465128B581800C17 + 761E671B1791891B295FA7FF001F3F62CF817A27C33F825A7FC03FDA17C21E10 + D1B57D19B56D5B4FF11DBBAB5D412362CEEAE5AC2196440F7105DC0166574678 + 59D1DFCB54AF99FE0A7ED7F6DE2BF187C7C5F8F77F20F0D78FFC11AE78595E16 + 021D265BD8A60B3EE6DA1984B24131772BE6184A864CA01EC1E00F88FA57C52D + 77C4BF0FFE146B5F0EBC6B73A37C20D3FC35069FE259AD62D3BC592C579A9EA1 + 35807BD1E4EEC4E8124C61278E3DAE386AF4EA25151A92D3FE026DF7ECBA1E3E + 32B63A55A508DD72BD97C2D3E55BBDDA6DF55B2DBAF803FEC95FB69FC2AB9F0E + DC7852E343B5D03C416175AB693AD691E3CD320D3B5382393C99190DECD6ECB2 + 640528F1AC8718C65582C7F043E0B7EDE5E01FDA23C39E34F077C02F8A5E3AF8 + B505AE9DAAC336A9A7BEA563258348AF6B34F791CE2D92D9CDAED4633AA94560 + B8C835E89FB31F8EB53FDA6ADFC4F2F887C29E12FEC7D1AEBC35A5DAE8E9E291 + E1D9ADF458AE66965FB0EA9717106CB85FB55CB15DEB98DE50AADB315F567C05 + F1DFC6CF85DE34F8E1A5EB3E37F88DE1DBB1A9DC782BC3335E6B505EDDE95A26 + A3A0BDEE92B6F73166095FC986CEE56441FBC74C9F99F229CDCDC66F5DED7FB9 + 76D5FEA15F175A92AB4E4A3CE92BAF5B6FAB6D2BEBA5B4D2E7D6F1697FB4D78B + 3E207ECDDE2BFDA1FC05A2E8BE21D0FC67A2A25CF87749B8B7D2EC92E755B162 + 8669A69FED04B46A04AA51492A0295009E3FF6AEF853FB47F80FF6B1B6FDACBF + 658F01F88BE25DC2ECB6F16F85ECE5DC2F2668BECA2E9A1DEAC2DAE6DFC889E7 + 89B7C3716A921E1C1AFBB8493DBFC02FD94FC98A4BCB17D77E1E442D62F31847 + BB59B22001C90BF3818EBC839F5F44F8B6B1F87BC4B0E8DACE94A756B19BCBD4 + 6CD27DB1DE44FB2658A76438272C8C476DC08C96047859B5670519474B5FE674 + F03603DAE26A439799DDA5656B5B5BF6D6D65AE8DA67827C7ED2BE30FC7CF87B + A3F807595B6F833F1675CD21F5F11FF6C26AD1689A9DB2192186EAE62B689265 + 59E5843B471019590E64E0B51F84BE07F8A9F1AFC61FB28F8EEDBE3DE9DF11EC + BE0E7872EFC3BA9785FC29B6DEC24D5654933728144125AA47299E440519730A + F9650EF6AF6BB5F11AF8DFE2768D145A79B7BAB7F01F882EE494A34CA67596D1 + 5220C1805C995082E324E7835CCFEC35A9780B46F841FF00052DBAF1DFC16F18 + 7ED2D79AD6B9E1B6F0BF847498ED61D475CB8935ABE96187ED176A61B684BBDB + CD2CD20D890C6E76BE029D55353A51BCB46BE57E692B7E3632A988AD4B12E8B8 + A84B56D2B6968C766EE92EAFB2D7A5CF8C749FF827B7C00D465F889F05BE317C + 42FDA46EFC5D61A6DD788AFAE3C55E2DBFD36D9ECE6B858E0D46DE5124965388 + 180845C32E58B48D24659936E678D7F617FD873F686F8E1A7DA5AF8A3E26CDE2 + CB9F0DDADFFF00C25DE07F1469B7DA3EB9F6186DEC3CB951AD58DBDE6D8E0696 + 685DD4921DB6C8ED5F6A5A7C73F8147F689FDA474AF13F8ABE0CFEC5361F0CBE + 1D5A786B4CD3EE7C6165A8CD0DDAEB304B7ED1C77DF628EE66C4AE62B686345F + 22289D439949AF9FFC61F1FBF644F81DFB7778A6EF5FF89DA1F8675C3A6FD9EF + 349BAB079273A95CA5B9114DF6585A3669408245D8AD1B79BD40C1393A108B49 + F62D63730AB152A776AFD12DB5ED15A6DFAA5A1F42FC2AF88DF0FBC17A86A1FB + 3FE85F0E63F0AF867C0F6BA85B69B3DD6B7717D766482489965BB13C63CD171F + 6892533AB1CBACAA57E5207B8DFEB3E1AD5E5F85FE25F10FC37D3FC490692973 + AE699ADAC503A786276B6C79904934CB289A789844CF0C4EA864895CAEE057E0 + CF88DE37F00F887E357EDAFA07C20F0FFC41D77C65E07F04DFAEB5A549A0BC77 + ADADDCC2EEB0DA405CB5C197ECED22B421A375C3A160C0364FECD9FB5A7C69F1 + 3FEC637DACF867F64CF8A1F10FE23F87574ED01E39D1349B0F12BEDFB2F9D64F + 71BA599218BCB7B84F25BCA76043B0C888AB888D928BD16F6D8F1B0BC3F567CF + 52B452A92D139F54DDAEB5577FCBE57D4FB3FC7DADF89D3E189D7ACE4BC7F13B + 432A6957B6FA75B3B68F3265E79F12AEF50F98ACBE5C93BD81042AD793F837E3 + E78BBC5DE0FD02DFC5FE2CB27F1CB8B8D74CA238A27BFD36DEEBECF343346A9E + 5CA365D431A3A8592395606C8DEE0F80FC4EF863F11FE3E7C74F84DF157E157C + 4BF86EDA6F81FC19A8E9DA7D847E2159AC6C7C4B04D2BDB7DBED206F36E6CB50 + 925960B872BE6C6159D4A6D0AF8F2FC10F13A789AFEEB5DFDAAFE1BF817C45E1 + 9F0CFD8B4D96CBC3416E7C23E22D5E5B7B9BB8C5B4CA2DF57D2E782DA48A0DEF + E7A929280B2C019AA55F9B5B1185C9F0D4E504E49E9AE97D6EBAA4FADEEDDB4B + 26B4D7EADF879E22F88BE24D03C2FF00F0B2FC13F1DBE1478AF4E880D77419EC + 67B4B1598864713DCC9693DA5E4331D93C72DBDD28612226F62FB0FCD9FB657C + 4EB3F82DFB52FECDDFF099477BA4F86F545B2BA83510CA2DAD4DBDF341389B38 + 3B145CDBCA4FCC116466F94336E97F654D7EEFF671F0A78993E347C41F8C3FB4 + C78AEC7C59A5786045AA0B14B7F0EBCF197827B3769A66BC674C48D2CD286445 + 0B1C60EE27E9AF8E03F670FDA33C59F0FF00E15FC7AFD9E3C45E38D2B4CBEB9D + 4EC2E359BB974FFB25B1B5044F6E2108D756D7223D8C8252A7CA4DEB94C27742 + 6FD9DBA9F3F89C27263355784535A76B766FA3EF6BFAEAFC2BF685F1EF87BC13 + F10FC2F2FC3DF1C9BAF1859F87755B6B2B95D32E6FECEC759D5AD2C6C740B6D4 + AEA0492288DE4D6452379DE30D11775CA206A4F82BF1227F13FC4CD43E2FFC2F + 3E21F05685E22D5FC13F0FB50802C9692D85C26A1F67D6B4CF31195835BBDC34 + 4F26DDB2160E86456E3EA6D2FE26F8C23F19F893C11E18F841F0D4B58782E0D7 + 346B736F1D8BA25ADECF6696C2E2284A9862B6B7125BAB43F265506D0491CF68 + DF100C9E32F1FF00C35F11DC0F8711D8DFE8BE2BD123D47C345ACF519EE618AF + 1AE6CD71143717B05E1B88A599645996548CB677B13855A726F9AFD7F43D8C36 + 3234E93A518FD8BDEFE7E8EFADBAE9AFA9E1BFB3AFC3FF008A1777FE34F17F8B + FC19E32F03A5CF8B5FC4D7BAB6B50B2DBDBCFE1FD4E759AC6F6546062FB77DB1 + 5AD670258A58E294953B156BE8BF0278E75BF84E9A5784344D3BE057C4AF0BDD + 5FA5DDE69FA9786A2D547EEC966916691C796C08C67E6E7B0AF67F8E5ACDADA7 + C02FDA2B5AB191534F8F44749A39D079B13620DC48270A8DB87CA0F073D3EE8F + C68FD996FF00FE1727C47B7F18EB47C4F0FC12D3AFCDAAB5938FF89E31CEF789 + 87CC1636F948C73CD79D9967CB014254E34A33949349CB9AE93BAD1276E97D7A + FA1FA4787794AC6CE788729412946F156B3B453D6EAFD5EDD0FDAFD66D3E0FDC + 7856CE27F86FE1882E2FE498CA2CB4E1244892EE90A80338C3310B81C57CBA3E + 03FC1840120F873A524206115A4BB042F6046CE0D7D27F0BDECFC3F25CAE8F15 + BC5E12E63B1690B99D941E3CD560416F706BE854D52D5D11BFD07900FF000FF5 + E6BF24A946A567CD55A67F40C55382E58A3F0FEDBF68AD775B8E0BCD256E2F74 + C48394B991ADDC37F78263A7A1AD493E2378E350B5D3EF23BB9347D3F072CD76 + E558E3B8CF27EA07D2B94B696E3538634D6ACE2D3EDF710DBEECA161D7692179 + FA55981FE1E595E5CDCE97E1ED535EBA5091986099D6284E797DDD2BFD589578 + 356B7E163FCC88D16B67FA9F9CDFB64FC6A1E14F1BF856CB54D27FE16078A346 + 4B5F155C4D612CA2EFC2D25B5CC5736978D204D90C532CF2C4F924346F82518A + 1AF96F47FDAC7C05ADF843C4B61E21BFF1CE83E36D47C0DE2D8C1D3E499EDE2F + 13DD5E5CCF613DB88E4CAAB4178D6F2CDB540091EE0719AFBF3E38FC58F85BA3 + 7C71D52CB5FF0009DDB43AA7C3ED67C277BA7A4E42F8B62366D7FF00D9D7172B + 8681F12C06376DDB49CA85216BCC35AF875AC7C3DF037C25F074DFB2E7C2DF88 + 1FB2D78FC7826F3C39E2DFEC6596E341B9967845D2C92C40CB7137DA03DB62E1 + D2398CBE5B2CA58AD7F23F1E5575735C4723566F9747D5AB34F7D524BB6DA687 + EE9C2EF0F4F054A1560EF6E6D5A5B3E97B27BBB25BD9DDDD3382F8B7F16BE026 + ABF097E2FF00C45D2BC4BA7697A9F8E3E17F8734B5D0EDA4F26F6DBC51A40D88 + E1633B94A18AC9F7617889C746E7D3ACE0F1A781BE3CFEC51E21F865E327D6FC + 49E2AF04DC78863D11B5282F6CBFE120B4596DADA6F2CEF5492482542C24DCBB + E594900330AD393F629F057ED0BF033C65A2FC1BF017ECD7A17C4E4BC8BC53A4 + 78CBC3BAE5C35BDEE9715D4B6F73A65DC0D11934FB9080CA6D9848B908A082B9 + 3F04FECCBF01B4DF1569E9F157C41F137C69F093414D405ADAEB1E13F0DB6AB7 + FA54A5846B7D76B15C5BC91DA8958AB4B19665C73B3CC40FF2717ED272717CB6 + B3F2D2FDEDD5FCAC8F7692C3AC3B8C9B77BAB349BF7A2A297BB7D92E9ABB3BD8 + FB65FE3478BFC47F0FFE17EADA2789BC7DA1F86F50F04EB9E2B9FEC76ADA9DDD + ADF36B50C4D7977128335E2A43701658C372AEEC3691B85DD3FF00685F8B12AF + 8E7C333FC6678EEF41F19C1E0DD0A49BC3D7B1E9BE24D3E38097F3ADAE5DA7B7 + BC9A3F32E216B859436258980508478A0FD90BE34E8FF1AD7E04FC37FDAF3C2C + D79A5C13DB7C3D6D66D353D260F105849F66BC90456D34329B05792480949432 + BB2021B6B213E29F1027FDB73C17E08B4F147C48F09697AD693ABF88343B44BA + B28ED6FEE2DEFB476FB2D9C0EB61262247DCD165D7F7DC6D60D8AE6535192937 + BFEB2BFE57D3F3D0F6D65D4AABE585AF656EFA592DE377A2B6EF5D3467E8DF88 + 340FD8BBC6DAB7ED0B717FFB2F7C354F889670E85E1DD1E2B1B1BCD1AD6D35C8 + 6D6DA5D5A6BAB68678E25914DDCA8638E24598C49CA32977F23F883FB1E7EC27 + A57ED5DE13F0A5DFFC2E73F047C5BAA5DF8634D8F4DD4A310E8BAC592C71EA09 + 0DEDDC53CD72B1C922B0126158891431511B37CFBF1AFE347C76B7BFF1FF008E + FF00698FD95BC75F0FFC57E2FF00891A1FC4DB3D5DB49BDD3AC6DDACA1682EE2 + B67BB493CC1731E09944F80F92548C6DF49D33F6D0FD9F7C7DA40B6F17596B5E + 1C87C3FF0018F59F88BE1890A19AEA5D2EFF00CF47B4905B89636942CB0336D6 + 1B1EDC1CC88F95F4284A33B26969BFA69FA37BF647CC4F078DA11E784A7256B6 + 8EFF0066CADABFB496A9269735DD8E6B48FF00827FE85E0FFDA3EFBF67BF1E7E + D47A7F87F56BED7751D03C19E25F0BE96D796DA9CF6CF1207BD2B347E53ABDC2 + 433DB44EF2C12799CB2A565F86BF617FDB6357F1FDE7807C3BF18BE16F89FC52 + 9E21B7456B7F8AAAD0DDDE580F2ED2F227994ACE2350C90EDDD222C6E9B176ED + AF49F867F1EBE1CFC62F057ECFBE31F88DE3AB4F037C4EF017C4FF001178A354 + BCD46EA08E7BBB0D51A3949DD94DD2249696F2E554AC85A651B0AED6DDF036AD + 73ACF823F61EF8E1F0D75EF0EE99E3EF0FEAFE279FC4B6B14C96D3DAD8DC5D41 + 7FA7B3C7F7248C5D8BB511EE262382C154ABD690A7CCA377D3F3B6AFEF7DB62E + 798E269CA4AA35BF2BBC74BFBED356E5F89463D5EB25B6C7E8CF86BE1D7ED8BF + B3BA7C1DF09FED19F163C43E3FF3B5FF000FCBA75BE9D3C0BA2D9C56BA85A848 + E1315BDBCD3CB1A90E5E60A4318F6A104C8DF60F8CFC636173E38F88FE2DD56C + CDDE9B6734B72E11465618A474DD27037FEEE3542464E3900EDC5725FB507ED6 + 7E15F8F9A2FC37B9D0B54D1EF5ECBE205ACD0AE9C5DA1B00B728B3C0B233B3ED + 569D71B9890138E981B20C7178FF005FB0BCD32EA192E2EAFED5D229764A923B + B08F12672A55D632197919E0E7047CEE7B38A54DADAFFE47AFC04EAD5A78B849 + A551A76695BB5F4DD2D1799E35E03FDB0FF644F14F8F7C2BE38D33E2F6A5A378 + 934559ECADA3D275AD1EEE0BEB39840F2413D9CB709E644C02282A415646E32A + B8FD08FD967F67FF0085D7763F15BE317ECFDAAF88BC41A2EADE2BB7B9BCD2B5 + FD66E20D3F43D476C970B6BA642276105A38BC925D8AF2C237E17614C27F28BF + F0501FD91F4BF0EFC4397E27FC28D2F5AF1B378AAE5EEEF3C391696649ED2FDA + 09669AE9042A7F7329B69A565D8A2390C8012BB547F425FF0006E2DF41A87EC4 + FF0013EEF5D8ACF50D3F47F143F9764CC562F2922BD905B9CA92A09523382407 + 3C718315314952535D34DDE9AEBF89F4D9270FE17136972B69AEB7D576D7FE1B + B17AF3F64CF841F147C57E27F8E5E2CFD9E3E0678A7C53AC6A1A80D4EF75A86D + 2FB528AEECAEDED66DF6AF1B24677DB6C8CE4078BCA2A48615D4E9DF09BC05E2 + 6D6AC7C61E2DF877E0AD56F9045B354B8F0FD94D7EB14454C510B89636955429 + 554C15DA7A633CFD55FB31CFE17D4FE107ED31AD6A8C6FA083C6FE30BFD3A48E + 62119CDD5CCCB2C69F28DC93B05553C9450C08008AF23D17C536BACC178ADA82 + BCC21042B02923960332FCF92082C093CF25474CE71861E32B4DDBDEFEB53838 + 9F39AF87E6A3878B8AA764DF45A2B5BB5AED16B57B2B3D160B0D4F49D3ED22BB + 86F973710B6E960662CBBD9C7CD2FCA02ED7C8F980E06457AAF8A27D67C4F369 + C9A8EAB7E6F5E5B76696494CC66880388C96C9009C0EB90578E739F25F10F887 + C2FE18D120D6BC61AB5B7877C1D0470C5777CF04D707CC2E234DF1C4AD9DC582 + EF38507AE3005769AC78FF00C0779F0FBC3BE35D13C4967E24B04D1A5BE86EA2 + BEB659B50B54264F35036C42CA5186D2000DEE715EA2953845ADBFAFEBA1F975 + 58E2F1334E379B4EEDEB2695EFAEF6D7BBD6F7EA7E5C7C15D2ED5BE307C5B1A9 + F87F45F11E8F2C7726EA1D5AC4DC5BDEC11DDDD4C77A91F332AAB0507F8D55F1 + C135CFFC0EF1FF008C3C2D25FB7C06F16DAF88B5EF14F8B2C747D2FF00B3B505 + BCB9D6B4987CF975286D0F98AED2430C481A419F2CC64E394DDF4A7C34D2FC11 + F0834AF1F7C54F831E1AF1FEBADE27D767F1BC377ACDACB1DB68EF7AA93AE916 + F7E903A5AA07899D2DD9A528F2B92A1581AE1B50F891E13F869F003E1DFC41F8 + 41F04749F0DE97A65BEA1E22F0E1BDB4B7BEB4F0F5FEA4E64BC82390335C42D7 + 064903BC0D1AB2B228C228884D29CA5A9BD5C33A4B962AEE29EF64B54EFBB6DB + 575A5BF43E6FBFF1968C7E1ADDF8D741D0BE317C65D1BC5DF176D6EB46BBF027 + 852EF549AF20D15E6B7BD78A22144691E62551318DA4C931EF0AE57E8DF89B63 + F163C6DA41F157C3EFD90755D1B5DB0F87CBE7586B1E2C3A45FF008913598DD6 + 48C4976B384D474E9AEAEDE78A796108A638EDC945816BEE4F851E31F10F8963 + 96443E1AB2F0E410C4F359E8ED31B8B6B8963599C5CA79691459F30BAA29766D + EAEDB4B8CE2FED4FE24D33C37F05F5E9B50F1F781BE116AF77A8693616FADEB7 + 2882D7CE170F726DCB178C6E921B7955541C9603838AEC749A8C657DFCBB1E25 + 4CDE5ED9D154EF2BF76F7D35B72B7A6FEB74EFB7CDBE1BD17F685F851F16DFC6 + 7F143C71FB35F873E00E83A15BF846F3C6726A37977AD78BED959CADDADA43BA + D34C96E0C8826170EE90012ECF377462B81F879F0FFF006C3F847F1074FF001E + F8F3F6F997E257823C5DE2EB38A5D26DFC23359E9B7125FC8B0C38BA8C4E964A + E8914314318589D8A0F341E4B2DAD2FEEFF671F111F881E3EF87B7D611F86758 + B3B2F1BF833C74627D5C5CDBCE904434FDAB2335D1B94B79EC6469F7C87E424A + A95D2D5BC7F6DE14F18FEC59F026FE1F0D787BC4DAE7FC20FAC4971269456FB5 + 4B0D36EEDAE2E616BB58FE55826B25664DD95555FBBBB9E6AF1F7756F6BFE9FA + 9EDE0EBBA73B4629EAD35656692BB7B36BCECFCBA1F4B7C19F10F803F699F87F + F1EBE0F78A3E1CF8F2F74F9631A078963B5F1043BAEADAE16506E2DEE2310B40 + AA6CD64DA72DB8A282C19ABE20FD92BE08C9F02FE16C1F07B4FBCB0D575CD1B5 + 5D4ACAEB50C4889A9BC575227DAA38CE4C6B22A870849DB9C678AEEFE1AF83BE + 372787BE2B7C50F871F0E7C6CC747F1A3FC41834F7BF87481AF5A786EF750F37 + 479EE24953C917F05E49796ECD1CB0C90DA12C37BC21BF27DBF6D7F115E59F86 + 75DF0269FACE84F730078AE6F751DF6F72CF1E51416EBC1E7241CF500D7C6F16 + C252A34E9D04B56F5BA4BF1B1FB0F85CE50C4626AE21D97BBEEEED3B7CFA5974 + FC0FDF4D3EE7C6BA1DBC9616BA8C76913E646C2E07B9E3919F6AA326A3AC33BB + 35D4FB8924E1C819AFC31F097EDC9FB46C57C97575E1F975A08D25B6E5898217 + 0373329CE1B03DEBAC3FB5E7ED2D704DC1D065264F9F88D40E79E9DBE95F9FD6 + CBF130769CA2BE69FE4CFDA69E61879AF753FB99EE3E37F14DBE92123F11F8A2 + 1BF9D944BE6CB71F2479F454FC6B82D2FC61E1486DAE52D3E256BD2DD82AD1DB + D8212AC49C1CB75DBD6BF4AFE23FC37F81D6165A3DCFC46F80D3CB7AC7FE269A + 80D3BC88C63D36FDE3D0F3EF5E1E9A0FC28BDB98F46F84BE1ABDB3DD214330D3 + 408EDD4F00963E95FEA0E16B54ABABB25E577FE47F9D55E853A2ED1F7BD6CBF0 + 3F217FE0A0BF0EEEB46F873F01FE215B6A17977A46A7AFEAF6D6D712DCB492AC + C9696EED9C8DCBC7F5FA57C29E1BF8C3F1B74BD23C2DE05F0A7C44F1847E1EB0 + D4ACAEF4CD222995ADDAE62B98E6B646438F32359E28245899BCB0E88F8CA823 + F6BBF6D4F85DA345A07C37F0BF88F555F1FEB91EB72EB10698CE0CD6713DBBC2 + 24FB244C18C123C2C9BDD423344E0162840FC71F154BE10D03C7924BA14BAC36 + BB0EB16F757770674105948265731A2F960871C12D90B1E08C3630BF80719D25 + 2CD6AC5BB5DAFF00D2627EA1C399A53787A78750BF2A6F5575BBD55FD7FC8FD7 + 1D13E2FF00FC1537E1BFC23F1BF89B53F83BF093C6BA595B9BAB9BF92E2DF51D + 5AD6392D98CF38B4B2D48930C48B24ECCC870ECEC55B2D8FCD8F847FB44F823C + 23A548DAB7893E28E85F12D35A3ADC5ADE8B7B6F756D7E7119F225D3640A6DE4 + 0B1B62E2D9E19177F25C2A22FE8E5D78A752F871278A6F7C3571A3F87FC217DF + B4058783FC42349D4EE1AC94C8B717AB25AC6DBD21B5B858D3CC815D52379582 + 02AC71E85FB4D7C47F07DBEBDFB5BD97C76F857F0CA1D12FBE2B597C201AE5FE + 9104D73A7E976F6375731EA8B733E2469E716E11648E78224F32360536E4FC15 + 2AFCB294B4D6DDD7F2FF00F24BA6A7551B4D2A72A564FF0096C9E8DAB5BDE4ED + 6BDAFD7D0F8DBC0BFB45FC17F17AFC31F8C7E27D6E2F87BE35F057C44F187886 + F2C2FA58CB6A5A5EAA16E91410773CE66858155560C6661B86D6AF44B7F12F8B + B50FF827DFC0AD0FE12DFF00862FA28A5D2B50F897A7CD062EB49D162BED39EC + E5B476DA8F99FCB3208F7BAA0070A16423C73E29FC23F813A25AFC25D0BC6BFB + 38E91E19BEF165E5CD85978EBE1FF89EF6DEC6E6EA3291A5AC96138962B191E3 + 952E5D6488865F2CA975DF21E2BE197EC83F05FE30FC60F0AFC09F855FB52F8D + BE1D7C56D46E752B6D4744D7FC3F24834BB8B4B84586DE79A06B4CCAF24723FC + D190B88DB8CEE1E6351BA8DBAFE2B7BADFAFE27DB294793DB464D41252BB5CCB + 975D34BFF9E8B4B23F467C79A37C5683F6E5D37E13FC37F8A9A8F82A6F127C0D + D0359D2926BE96D34DD3F5382C9EDA259CC0E1BEC92359B1914600FB448D8DCB + 93E21E0FF1B7C1FF008E3FB0AFC77FDA0FE2C7ECF1F09AEFC69E24D5347F0369 + F73A2786EC2DEF746D52E0DC5BDA5E0BEF284C8E04092CB3066791979077135F + 307C5C5FDA37F672F149FDA46EFF006D7F047C50F1A68B2BF827C2D7A86EB53D + 435AD122B8920B77892E2CA4B18ED1E337170A8F339DAAD8666209F05F81DFB4 + F789FE0E7C2AF197C16B7F0D699E2CF875AD5F59EA8FA6DECE57ECD796B289AD + E68D8C7261E39159D5C05652F28CBAC8C95E8D26A726BAEBBEB6D6EBA5F6EC7C + 8FF6449D0854A2D49A70B38FBB7E5BF32BFBBFDD6AFD9EB73EEFF8EDFB3B7EC5 + 1E15D63E27EB765F057E2AF837E1BE8BE2DD07C01A8DDE97E389A69744D52E74 + A8AEC5DC31DC4532ADBDC319A32B309F63A291B564C47CE4FF00B05FEC9BF0CB + E2B6A707C46FDA2FC7BE3CF8436516997F7F169DE11874EBCB07BF8A39ECACB5 + 2BFB9B85B64678A68B335B8652CC1018E4385F1AD1FF006D0F0FEB7E05FDA5FC + 09F16BE19DE6A5A67C48F1669FE2A99F47BCE74692C4C3F658A03238660BE408 + DCB03BD18F284E47B37C13FDAC3E1DEBBE32F1AF8A7C53E3BBBF83DA84BAB787 + 534E8752D321D561D4F4AB0D3E1B696DAFA06BAB6864595E0DE019B08C141570 + 72344B5565FD799B4238C8516A5396965BDDBF86ED3B4A5D65B764FB9FAADE24 + FD9E3E1FF807E19F80FE257C36D72CEC7E1B49A8E890E9FA53F87469850CF731 + 3A8FDD49E5065DA031C36E0AD96F9558FD19AB634CF8937D15F4B1D996D4A2BD + 0BD310CB216123EE232A1195F71C0C1C81D09F27F88DAB7C19B6FD935347F859 + E29F869AAD85D789F49F1547A3F879F4F823D32D6E2EC4D2449656F23F931C41 + 8A631B7727DEF9B23CEFF6A0F15C3E1BF86FFB4578BA20B6DABDB784B589ADA5 + 8DC8CC82D658902E33860E50039CE463A600F07886F2A50F26767860E4B15554 + AFAF36FBECBEFDDEA5FF00F8266FED27F0DBE217C74FDACBF6C3F1978617C47F + 0B7E18F863C47A87842D5E18916EDB49B68EE6CA49830225B8BCD4351D3E550C + 0AA9B7B4046C85B381FF000478FDBCBF667FD9A7F63FF8CBF0CBE3EFC70F0BF8 + 13C4FAAEB852D92E0BCBAA4E8F78DE618A248DA57764BFBB90485464A052E992 + C3E32FF827B780BC44BFF04EDF8E71F86EFB488B59BBBBD52FB50B6B99BCB992 + C63BDD06CD03A637C713BC401765C7CE782702BE4AFDBA7F625F16FC05D2FC47 + E3D87C59F0F7C49A5EADAF496165A4F87AEA7BEBCB7F36CA79E67970802C31CD + 0C9106249657858E0B15AF633DC150861B0B421A5E0DC92EADC9DDFDD6FB91F6 + D9263654ABD64E3A295A3BE8928DBCF7BB3FA17F047ED61E12F061F8A7F06BC2 + 3E02F1CE8FE23B3F19F8B2D2E23D6604B3B7D38C7732AC30398E490C97216290 + F96A361C13E66D393F43FC2CD33C3BE09F81F69E24F1A6B1A25B7887C67E219F + 45F075BEA7ACA5BDCDF7D82169AF26B0B59326E4CB71731DBB6CFB8968E79F97 + 6FE78F88BC3FE3B8BC0FE16F8A9E06D23C01E27D6755F8B1E24B44FED5F13DBE + 93A6DE6CB59A76BA6BE6C8923856FDDCECDE5CAA4406596BA2F8EFA4F817E287 + C6CFD92FF684F89FE2CD0BE1E7C3FF00863A49F07E9365A7E957577A65E32F9D + 776F7B6F74B339B4B83753CF7734C59D6E4BA4654A4781E4623054F0738D38BE + 6728C5FA36AF6F55B1E267339E3DBC4629A8C2116BCF7B5EDAB69E9F7EF7D57D + 13FB4158DDDF7C167BBB079E492EAE2D234821793370AB70CAD0BC519065570C + D956DDCA676E791F34F88CF877C35FB057C36D53C5DA9786B4AD10DC689611CF + AA5AAA4905C5CC935D4616F305D31E53A042CA8CC4FDE72057BDFED4F75E04F1 + 7FC1CF1CFC32D4343D2FE2C78616D6DAFB58D26CBC411E9D7D636703A5C2EA11 + 246CD74863648F32ECCED90B02EACC0F79ABFC4BD17C5BF04ADAFE2F06FC33F0 + C7832FB4CD3751845CDB5BDFDAB5CC30A5DC4D2E9B73B92748258A2CC9E5C38F + 295D3E6C9A9AB4EF34E3D1DCF83C0566F0B5215A2E2E5CABA6C9F4DFDEB5D68A + CB477D4F84EEF54F8A56DA27C54B1D2B45F883E38F0A7807C19A0699A97843C3 + 96325E6A961E24BC8D088E2B35432CCF25B3C458A864891159F05B757A9F873C + 0DF1CBE217EC9FAE7843C29FB26EB5E06F1F05D37C3F643E2E47FF0008D5CCEA + B14E1EF54348EFF64B6F325468D5629673391B996202BD7F54F8B5F193C61F03 + 34DF8AB61AC788BFB567D3B4CD57577B186E00B1BB9B76D90DEF9DBA30D34520 + 5420617703F28DB5BDE0BF8AF75E238B4BD0B5BF17F881FE21E83E17B2BED4E1 + 9A6741AA5B5FDB01134A14E242B2D95C32B6DCA159941032A7A6952BFC6FFAFE + BC8C730C6CB5F6514DA4B7BBB2ED6F77AADF6D7ABD4F43F867F1335AF027C2CF + 07DC7C72F1278416E2C679748834AF05C97F7FA469C8E649618B7DC451DC4B29 + 8E392491D8052C0EC18C30E67E3A7C65FD9D7E27E85E16F815F14BC0B79F167E + 1AF8DAD2C750BD5B3BCFB04586BB0A8E0B6CB8578A758A50D11574253AABB0AF + 98BE307C76F85B61E31F107ECE1ABEB77FE1FD7F46D013C4FAB6AB7D0DB5BE87 + A5EA12AFDAD2CE7D4A470D1DF1B6817645F2C651665F9DC10999A1B7C2BF8996 + DFB35B781359D5FC79E23782E6FB4B6D0E1FB769FAC69BA537DAB535B4B845F2 + FED7070822F315E69248E28D5D9F23BA4D3B417A1E07F66D4A753EB3513BB7CC + 9EAADA5ECADDAD75E4BD4F62F831F00FF64BF0B783754F007C0EFD9D2C34AD32 + DBE295835D3EBB7D71A95EA6B763248B65AC9BB3289658EDA598AAC43CADAB34 + D946DCC1FD4ADBC5117C5FF0E7ECCFF163C59E15F0949E37BAD7742BF4BE3749 + 7373A1C9A81B9F3E2B72F08923B59E3B4CB12CA640880AB08C13E3BE16D27F69 + 6F0EF89A2F13F823E0F3D9DE6757F13C1A5F887C4F69A4DBF89ADF5A96D045A7 + 5C6164B8D3B51B08E27BB9D2486451B26B75667991EBD4BE08C3E385F837F0CF + C25E36B9F82B61ACF86F54D2E0BC93C3FA84EBA64B6505BCD1C252F2FE28A59A + FDA6718450102FCA99F999B89F2A8B8ADECFBFF5D7EF3AF1129BAD1A8E49C799 + 3BDD49F9BBBD6DFA5974697D59A9DC585B7C1EF8A7A5E97A64C2EEF3C21AAA18 + 34FB5926796E6E74B9ED5122890339769658155467000FBA0123F8A4D43F662F + DA47E0EF84BC3FAE5F787F5B5F0569FA84533B5CA14686455119516B371200DB + B2146715FDD4F83BC35E29D76DA6D0BE19F884F85FC65773C5F65D5AD6DFCD30 + 6EC3485533CFEE91D339C64E4018AF9D3F681FF825FF00C4AF1FEBFE067F07F8 + 875AF15AF9132EB13F88656963D36ECC99F36188E5791D76D4D6CA6A6270D184 + 9A4974B775DFA6FDB5EE7EA9C0D8CA349D6AF0BB7295AF7ECBEF7BF5E963F948 + B0F177C5D36DA2E97E25F0DDB785FE1D79EB34DA9D9DABE5493832C91A9F9460 + 0E3D09E2BD6A7F8D5F09639E68FF00E16159CDB5C8DF1C6423F3D5464707B702 + BF7D3C63FF0004F5F823FB30784AE353FDA4349B4F1468D2C6CF26A635ABB468 + 9C722316906402C781B8F35F29278ABFE096C1101F81BE25C803FE60572DFAF7 + FAD78B82F062BE2A1CF4EE97F76FFF00C8BFCEC7E8957C43A74256AB64FF00BC + D2FD51FB8DA4D9EB3E32D2AEB47D7FE144916897E4C3BE3B85236118DC0119ED + 5E55E20FD8A23D26DCDE786AEFC3F6B6C57CC9639EEDEDC0E738DCBDBDFB7E35 + FA85E0FF00869E2FBED4B5583C4B041E1ED3A290A5AC4660ECF18E3792BC0C9C + 903B66B0FE297C0DF126BD3A36997914DA14481650F7470D8E7846F5C1E6BFA5 + B0BC51ECEAF251A9C89EFD7F33F9C71BC352AD4554AB4DCDADBA7F48FE247F69 + AF117C64F85DFB567C74F085A7C50F02F8D3C5FA5A5F6B6960FB752D2EFECF4E + 335D9D1E2BB31AFF0067DD436C66B592D97CE8D6711160865321F30F889ACFC2 + 5F8DBE21F85B65F16FF65FD2353F19F883C2ADF10F4DF1378535083C3373AE69 + 2D6EAB25ACB2C1B56EAF05C2B4423B854DA6DD444F8B9AFB3FFE0B57E04D23C5 + FF0018A1F823E0BF879E1FF82FF1063862D4EE7C5BAEDAC9A73FC46824B3712C + 635286410BE9B02065F3258A493ED36D323BC68156BF253C4D71FB4F7C28F8A9 + F03FC23F13FE0A784BE2FA691F0D6E745D0F4CF0F59CDA9D96B9E19BA926533C + EF661DFCD57320C9485E3223255182B57E419D545F5C9A9CAEDBDDDD7F337ABF + 92DFA3D2C7B993E5E9D053A4B96714D68ECEF6565A72DF6EBB27ABEDD96B7FB2 + 4FC06336B7A7F87BE21FED51F04F50D035CB2D0B5A5F13F85D6EEDBC3BE239A2 + 33DB417C91FD8AE2CC85478D2E3CB3B9D1B613C093D1FE32FECFBFF0519F85BF + 157C39E03F0FF8DB4AF8EF6D068F16BD6B7DA01D3EDEC2F95E09ECE5B6B8B6BB + 30BCF298659E3F28961343302A0AB62BC474CFDAC7E0D6AFE32F18F89F54D07C + 4FF0FF0056D53C41E149F57D36DEF26B88AFE18E39AD35CF3981DF1A4B1FD8E4 + 581D58892DF2B86F947BBD8FC45D1FC6BE25F8A7AD687E37F0BFED05F0E478FE + FAF2D74DBAD46EB47F1369DA30B82DA75DDBBDC08A461142E60FF479229235DC + AD05C4646DE58464D249BBBF9A7B75D7E5E5F79D98A789A3255271528C52F8A2 + 9B574B9ACD25E9BEBF81F1CFC60F1C7ED01F0BB5DF87BF067E32FC394F851A6F + 84F53B4F16C7E198AC56D5A412C72B47346C2492311949E7545888446F314E0A + 6D5A7F1DFF00694F0DFC4EFDAD3C07FB4678134DF17F81A3B5D2B44B2D55EF1A + 23752CF6B07D9E6962F21981468562C64EFF00DD93C715FB03FB577837F62ED6 + F5DB1FDA1BC03AC59F8A7C77A4AB69DADB5F6B926A1A75AC76D0931DD4AF2B4B + 9BE124FB65632B9672A7CB5972EFF9D3FB3BEB3F0C7C1DE10F89DE3687C0DF03 + 3C7BA62F8EACEDEC62F883E1B865FB6DBC96AF3A5B5ADD4F6F325B5C294768ED + E4312DCAACD86578C29E5C3E1F9E51A8D5A4B5EDE5DBC8F46971047D84E31A6D + AD23DB7DEDADBADF567D69FB5FFC1DFD9CBE3DFC32F86977FB37FC44F036B3AD + E85A9345ACCBA735D5E5A490BE9F12B013C71F96F2C72AA95457603CD704A6E2 + 2BE13F1C7EC77AEDA5EF87E1F8713DAEA164BA747F6FB8D56F45BC97176657DD + 22008C8A814C43664118FE23F31FDF6F883F137F672D67C1FF001864D73E0FE9 + BF09B4FF00875AD7FC23AB109E1D1A4D47532A50D8325B43828F3232DBC68B23 + B21F3000AC54713E37F857F052D7C57E0AF01D87C61B6D07C61AEDD59FD9AD75 + 15FB4AC1BED848B023C613330061C472AA337DE2CA0296F43030A7093BEEF5FB + F53E11E7B8E84630826E9C159736BA2B6ED257B5D7A1FCEBFC5FF81FAEFC229F + 4482FF00FB4355B79F4E8AE6E35286C644B28AE5A49018124239DAAA872DB492 + DF740C575DF06FF664F14FC49B8B2D435C6BBF08784E4DA4CD243BAEEF90923F + D1E06C0DA40C79927CBDC2BF41FD0FF897F64CF176A17ABA37C33D42C7E2059A + F9915C4B1DDC56D359DC82ABF64BA843B209C6E0400DCAEECED208AF9B17E18F + 8FBC3BA55EF883C43E0FF11D868F1DE0B4FB75CD8C91C3E72C8531E638C11BE3 + 003676B328C13C67B633A52D5308F14D7E4E4947967DFF00AEA78CF877C09E09 + F85BE09BDD3BC17E1FB3F0E69F142D2CC63C7DA2FA55C9F326988DF2C9843DF0 + A33B401F28F2DFF829F7C73F17F845BE1C7C3BF0ADE5C68B078A25D4A3F13334 + 2866BDB68AF228A3B64739DB092652C542B330DB90AB83ECFAFEA897B6BAED97 + EEA330DA5F4CC11F27F776D2B920F427000C0FEB5F0E7FC15775B17BF1F7F67C + D1121920FB278552E195F86633EAD7721638EB9D8719EAA01AF0B3BE59382F3F + F23ED3802757DBCDB6EEEF7D5EA9A7BFE07CDDFB37CE34DF8F7F0975BB67B8B0 + D5E0D76C6682FA09DE19EDDFCD4C3ACD1ED752BC36E0410403C57F5B5FB2CFEC + 3FFB1D786BF625FD9CBF6A1F8BFE1DFD98F50F0CF8AFF6A7F3FE2D7C46F1B6A7 + 6897DE05F0D687AA5D7D93C3D6CB71B588D41AC616B98D5F74B05EB334730F27 + CAFE43BE0879917C55F87D731E370D42D98003EF7CC3000EE6BB9F8A5269CBF1 + 1FE20FF6C35ECB6BFDAB7372B142F12F9970CD22990AC9C020614B805B0BB380 + C31DD5669475EFFE5FD5FB9FA3E1BA7A1FDB94DFB317FC1BF9A97C68F8B3E2AF + 8C3F11FF00643F0569365F1F2F3E25EB96DE28BFD2ADD3C65E1DB8F0725FD9E9 + 5A2C514DE7DBE8F14DE26B0BC96D7CA8C5C5DDBCA855FC98D53F08AF3C69F033 + C53F060FECCDF097E22D978BB57F853A35CAC32ADB3A5AEA161677D7504D769A + 863CBB9135BDCDA5D38899A28F6C3B1C86735F831B3C1F6D6AC9656D7E9A9188 + 8539B18A11279848F91236665C76054EF63C81C9FE81FE02FC26F829A3FEC69F + 0F7E2CEB1F08FE1AF8C3C4FE22F0DF8662D661F14DA49A8E99A95D58B4C96B24 + B66B222AB90BB0B29CC85C970C37579157F7B28A82B35DDDF6F95D79EFE565A1 + E0719E2E950C1FEFAF66EDA5BAF7DB45DBBD8FACFC69F11BE144DF07F56F889E + 06D1A3F8B7E2ED1B481E1AD52E7C23651EB171697D7DF67B7293CB6E0F9DB237 + B52E9B9BCA5910B05CA2B65F8AFF0065BF8FDE1C7F1EF86754D0FC23E15D634D + F00E8BE0CF0FD8F8BB59B6B1D27C59A9C81DE445D523B968FF00D0BECB1A18D6 + 2DF2BC9204930A1C7A5681F1CFC65A0FC0CD3FC53F0AB48F05FC2BD36DFC388F + 05AF842E62D26DF48967DA91358E9D0C1142F009248E5656DA660082247009F1 + 9F8BDF153F683F8A9FB22F8BFC552699A8EB128D06CE1F1186F0C06D3996558D + 679FED3BF6B4B167CE68635731AA87601594D1460F4E676FEBB9F96E26BBF7A3 + 495AFABBEB757F96E95B7765B6BABF73D23E0B7C70D3FE0BE99F033E30FC58F0 + 678225BDBEB7834697C056F7D770699690329D42395F5129E6CF76AD14493A47 + 13C2AA190B606752FF00F670F80F1FC49F11F8E2EFC53F1CE4D674ED586AB63A + 75B789667B6D2748B65510786D8A8F3AFF0048499E37F227669649C202CC5DCC + BBBF082D5B56F841F0611AEF4DBFF116991DB5C0B47B919F2058C44958B93B30 + 22249E3087071C57C2B17C4FF889F09BFE0A1FAFFC11F1AE83E3AD5FC15E2DBA + 92F7C1779A2E9B72D74D1DEB2CF1BACD0E42F9323DD4124E31F67781257C2035 + D0D420A37BFCFBFE472CE75AB559538BB2E5BD93B3B75F3E8AFF00F059F63F82 + FE267C29F1F7C4CF8D7E174F811FB3D78BA76D37416BAD42F6D678BFB56DED65 + DD636BAC457A1A25B9B37762AC91AED708B8047C9E897DE3F87C35ABEA7E21D6 + B54F057C3AF03785BC3A973A8C779AB47A2E8D1B44DE5A0B89D42C4A26B89D14 + B88FE70C4ED24E0F89F8BBE1E78A7E2B5F7C50D3FE22CD3FC39F87733E89F0C2 + 4F13F882F6C20BF9B4D5B88AF2E7C4514B121B7BA8E591648608B747BDD9B223 + 40E95EBDE22FD9A74EF8B7F0335AD0FE3F78B344B8D52F35FD2FC4FAA1F0CA79 + 9A714B0B96B8B7B578EEB78BBB5289209FCD052469E5D91A848CD275A495ADAB + D7F37BEDF8F99E756A7854D4EA3B46365A59BD6CB6D7FCADA1C37C247F8CD0F8 + BFE29E9BE2E97C01E2CD19AE91F4BD66DF5D486F0A3C92B44B736EFE4BABCD0C + D693A181E452C1813C2E78DFD903E32FC21B0F88FF001FFE10F873F6B8F0CFC7 + 291FC6D7F349A77882C9F50D612488849DADEFEDDD2DEEED9D623B6678F21D1D + F7C8B210347E16FC29FD9B60F1F6A1FB4B7817E16F88F54F1069D6B6F669AA3F + 88357D76FB4BB15096B1D9E9FA74B73E4C56D6B6B298E3558CB5BDAAB046620E + 7B0F0369579E35B3F8A9AD69FA34BA4F83B43985EC2BA3D8C16D64937D9EE448 + F73E4A465A396D9E689490EC64B8897850CD5E74AB4D7BCBAF4F976D8FA1A94A + 84E9FB0716AC926DD935EF7CDEFB6A9EBB743F573E0278B3C2DE1FD47C3BE27D + 220D37C61A4DC5CA5B9B2D3EF219A568DA174CA9462A3974E382DB48E339AFBC + 6E7E37E9FE158A69747F867E38B68995E50F15879AACC0E00DA4038C0FCEBF99 + FF00F82772E85E08D0FC6E9ADF8DED7C05E1FBEF196816D6DAB33246D6F218A1 + 469A257D8AF2EE2800EACD80031E2BEE9FDAB7E3A587ECAD67AC78E35EFDADBC + 4BF1420D2A45BAB0D0E07586EF5C70C77C642E508078383E87D2BEB7298C713E + EB5AAD3CBFE01F49C2387AD87A13E56DC79AE9BB5F54AFF89CCFFC145BC75F17 + 3F68CF805E29F08F85FF00649BFD3BC7F16B115F45E2FF0012F88A2D0E29ECD0 + 92D041624FCFB802A1A42173F357F3AF75F0F7C4F6D75736D7D1784EDEF63919 + 268FFE12AB63E5B83865C83838391915F3FF00EDF3FF000516F89BFB60CB71E1 + CD5B4AF885A5E953DF24BA6C1A8DF4C6458B765516040109248033B8F4F5AFCE + 8B9F849F146D6E27B5B9F873AFC3711BB47224B60E1D181C10C08C8208E73CD7 + D0E57E20D5C9F9A95092A9196B66F48BFEEE97D7CDB3DACDF83A8E64E352A45C + 64B4BAD1BF5DCFF47597F6D0B1D375368755F8AF61796AC7CD10D9D9076CF65D + C6B1FC6BF173C39F14174A03C59F116EB4691867EC7208228A4CF4915704D7CF + BA77ECD1F05752F16BD87C37F0EF8CBC7139904B00B7BCDDB17A0525BEE8FAF3 + 5F76E8FF00B23F8ABC2569669A678734F8B541147722CA5D415D616C1E1F8E58 + 01F9D7DC55AD97D171947DD974D8FCAE84333C4A9426B9A2BB733FD753F9A5FF + 0082FC7C28D374EF863A6FC4B8B4BBCB8D1078634EF0CDB5EDE9599EDFC42BAF + 1BEB711A93E6C5E6591D5435C61A3F90464A99143FCC973E24F1C7C5D87E2EEA + 7F0B7E3A782BC1BF14BE1949E13D73C2B657D7D02D8F88F449B448247B20A195 + 2695EF6E4CA5D98E3CB70C084DABFB8DFF0005C1F853A7EBFF00B1C786AFBE20 + 69424B98FE2D7802C6E2313B2472DBCD777304CBBE2C3A8292E37A90C0671CE0 + D7F3227F629F83FE35F176A5E13F087883E2D7EC9FF106E7C27AA78D235BFBF8 + 351F085CE851EE11DC457D24D14C2C67960B95F34CD28896166902B0287F26CF + 69C3EB32AF16FDE77D3BD97A745E7A1F534A9C69D1587ACF96D76BDDBA49B8EE + BF0DBADFD7D59FC5BAAF8D3E1F7C13D17E30E9FF0004BC55AFCFA5F8FBC51ABE + ADE2BF0ED8DE59CDE228754B7B3B8134F144DE45AC8D24AAD2C4B84791260084 + C0D7F007EC6BFF0004F1F8D7E35F86A90C9E3FF05EBEBA54DA878CFC39E14D6E + 2BBD0E09122B89FEC62E0ADC5C4174D1595E4CD6F6D96681118046750DE21F08 + FE0B7EDD7F0BEDBC011F85B47FD983E32F84741F01EA9AB691E1BBFD42CF508A + F74ED6D164BCD2DAC57C9BABB9E55B78CAC4E7C96475F2E42275CFCD3E08FDA2 + FC75FB2A6B5F0F2EFF00E159F8AFE03F8BADBC7575E34D7ED6F7453A5E9DA85B + 5D2412D9C56B61346AF10802C8D180E17C965404867CF8DCB052B2D3F07D56DA + 5D5F5DDAD0EF546A54E68E16A2E6BEC9E9AB6F5EDA592D347AA692B9FA39E3AF + 845FB27FED71E0EB7F097ECC7F1965F857025E7DAFC1DA46A9A2B3786D2D22B1 + 2D22DE5C465A7B640564B9F3181680B112C4CDD3E1BF0EF80BF6A1F803E156F8 + 31E26FD98ADBE30782FE32B5BEA5A28D0B528B573ADAE997188AE34FB8B1323D + ABC336D63E6792E1642AE0C7232D617C4EF899FB2AF8ABE17FEDF9A57C39B693 + C39A36AFAF59F8CFE12D9DE69D259DE69F3DCDDDBFF6858DA081995238ADAE75 + 4B721DBCB96DE38DB0088C2FE81F8C27F883F107E14CDF0B347F19F8874AD76C + 3F67783E24FC3BD36D1FCB6BDD56D3C417E6F5634C037134B069CF1AC7F312A4 + 2A805BE6D6955A8BCAD6F3E8DBDED7DBBEE2C660E187A7185AE9BBDA4DA69FBA + D3BC755693BCAF7F85DAC7C77A3FED6FE1AF1068FF00B4BFC04FDA9743D5FE13 + F8C756F1A68FE22B237704D04BA16A1A5CB108ECAE63921326444B2C2E19119B + 7AB820A79727AF6A1F12FE1BFED1DFF0B46FFE1BEBAF178B3C2DF1A349F1D681 + 79776B2DADCEA5E1FF00ECA7B3BB68D1C6F56F3E3B7915640B94520ED3843F5B + C1F1574BF187C48F15F883E227C22F821F15BC4BFF000AE347F0E3C9E28F0AD8 + DE25FEACDA0CB776FF006BBA3199E50CD6F281BA4076B88C1D91A63E36FF0082 + 847EC49F027E0F7C20F849F1EFE0EE97AD780A5D565D2B47D5BC3EAD3C9A5C8F + 3E9F777725E446EA49258DC9821528B21847240520835AC2D392BEAB55BEFA5F + EE5F23CEA15E854AAF0C93A7269595D38A6E29B7D1EAB4DDADF5D0F72F805F13 + 358D6BE257EDA1FB3B780FC62DA2F82E0F1E5FEB097FA748B24634D55D4AEAEE + D93602F243917C83610CCA91206C0C360FC1CFDAAF59F8A5A15BF8EBE15F8E0E + BFAF69CF6E27F0E78DEF12E196CA12446926E678AD362792F0CBB16261E623CF + 0BA823F233E1C7C47F8C1FB3E6B8FAFF00C39F106BDF0D75DBDD3B633AD8C27E + D567345246A7CAB989D4A34734C15B6F47CA9E86BD03E147C6DF11D8685E06F8 + 4D7FF0AFC39F17F4DD1A632784E18E07B5D5B429CCBE6B359DE403CD08CF9691 + 5BF76E3FD6EE00635545AE56F64BF5D3A3D92B1D188CAE2D4E4B5BF2DBE49F35 + EF6F89EBBAF5BE8FFA5FFDADF44D6BFE19AED3C63E29F869E12D0BC6A6DAE52E + 7EC17F15D4F62B71A54E8611342A23785992DD53E694811C6778CF3FCFD7FC14 + DE75D43F6B1F0DD85EDB5B3DDE95E0BF0F4324687FD5B335CDC6D079EA275CE3 + B9F6AFD08D47E3CFC79F18FC1DB7F007C42B8F0DE8FA4DB786CDB47636133DDC + C90DAE9D2AC4B2DF39C4937C9164C6A10797B559C104FE75FF00C150342D5F4C + FDADBC4BE29D5AC5B49D0355D07444D1EE64CA45A9C50E9F143234521C296599 + 678DD064A9519C6E04F9D8DA8D72736C9BFC8CB82B0AA188A90834DF4B6DBAD3 + EEFF008767CEBF04E2B27F8A5E1D36ED2C9A62DF6E4F3982B18379D9B8F1F305 + DB96F51EF5A7F18ADA4FF8583E2F924373206BB778DA43B5994B1209DD823A1C + 671D070739AE22D3E00FED0D7779F0F753F0D7C23F8C0906B777791E893C5A45 + D5B7F69B416AD3C82DDDF66FD91A990E3180335DEEB3FB247ED4DE1ED22F7C4F + ADFECFFF0015E1D3E3DF24B38D345D4C1C8CEF9238DE49B92DCB95FE2393DEBC + FAB9946A46D176F567EBEDC693BC99C6C5E0BF11594DA483E17F114AD7BA9369 + 16ED0E9D3CF1DD6A0320DB42F0ABACD328C82885981078E2BFA37F879F0FFE28 + 78A3FE09CBF0A7C37F0F7E1CEAFE3AF1B5878774AB993C371C6B05EDEDA99E7B + 798C6B700209552E8C9B240A088580646606B4A6D77C61FB1F7ECB9F05ED7E1B + DBE97E0ED7B4EB4D2ECAFEC64B45296F76DA5BCD75C263CA9DEE967DF2A7CDB9 + 9B249639BDFB425D7C6EF1C7C17D7FC5DF0DEE343BBF1B3E911EA915DEA3E2FB + EB6BCD1DDA1134B32456D166575884F184670640E42AFF000D6586C4CECA57B3 + F25E763E0389F19F5CA8F0DC8B922D3BB6D6AE37D525B24F5D77DB5B1D17853C + 1FF1B3C3BFB3B788BE1D78EFC1BF067F676F1659F866DBC3FA2DCF8A75DB5D7E + E247C84964D5A3D2519ECA08A3FDE463CC9764843158D77B1E9D7E148F017ECE + 3E3EF0EFC68F8B9E27F8BDA4B6990BDA9F86DB3C26DA65827CD7B269F35E4D77 + F6B9278D511E531C5218D76C6636393E33E0BF8B3E32F883FB32DDF8E35ED434 + AF0E78B350D664F0CA41A1C7FE872C71C30078962B97722599259D895CB06500 + 205F9ABAFF001FF84FC051FECA52EA5E23F16D8683E33D206809A758A7859E4B + AD3A64785A159750DC25537323C50DADAA87590BCA5D64F942F7534D6B2EFF00 + D6C7C56226DD574E166F47A2B76B24DDDEAD77D6FF0023EBDF876DE13F83FF00 + 07553E0B687AFE99A2B696DAFDBEA9E2EBEBCD652EC9B68D847757571786E88D + 90C2B8802C31F95F20FBDBBBDD1FE23F8BFC6FE0CD07C47A6D8DAE852CDA1DC4 + BABE9E9334874EBD96DA1683CA70E0B6E769D361460CA23276B21CFC6DA8FC2A + F8F3A641E3EF0B5DDAD8E97616FE12F0A781B47F0D78B75E1E1FB09F5F5682E2 + F6FAC6E67FDCCB1C3166399831795A11145E610457D112FECFDE37D1FC73E319 + B41F8DFE1CD03C397F61E1FF0008DB5C697A15DDD7F6AE91606F2576996FBCB8 + E0D5E67BAB848A780CC90DAACA192691D0C2BDAC9A516AFD8E1783A13A8E74E6 + 9396AE5BF6BDDEAF67AF7E9E5E63E3FD67E1F7883C2FACFC0B7F1968B27C7EBE + B46F1B59F871A49A3D46FB4BB488991D5A21E5AC4D6C75090ABB6486470AC911 + 35F4A7C288F48BFF00D9F3E1F5A4FAA58DCDCEA1A2A2EA9F66960930B229C93B + 1BE490A4A386C75439504E780D37E01FC27F19789FE2BF8A3E2A7822DB5FF127 + 8A3C336FE10D4E59E3716E90DBDCBCB1B43145865651B10DCAB2B347FB83BA32 + FBBBD7F0F783BE107836D3C01E05F0AF863C21E1BB78E28DAC3C3D63058D8A33 + 0532B086108AA5F79566C64ECE493963C153309FB2BA5BFE1FD7A9EA66591E1A + 388FAB425792E5D16AA5A5DC93BAB5B5DFAEA7C07FB1A59FED6DF0B34DFDA5BE + 1F7C44FD9AB56F16D9E9376D2F86F551E27B1D36CFC4F2C6CC8B609772F9B982 + 78648256BC0802287465F32402BACF8C5E0CF1E780BC75FB327C4337D7DE0AD6 + BC2979AB5E9F0FC48C6C751D62FED672F70DE68093430C36AF671C5346CB2453 + 13852ECB5F427EDBDFB4C685FB1F7ECF771F133C17E31F17E9BE32D6BC5DA569 + D751F872CED4422DDADA6F3A5BA865643B2416411110E55B61520920FE767C17 + FF0082B3FC0ED6FC45A38F10EADF0CEDB5296E51A5D43C429A8E8F78B823E779 + 64964B4623AE5B20941C81D358E1A4DF2C9EABD3F0DCF4F2394711CD8D4BDDD9 + 5A2E5D354FDEB59B6F4B18DE2BFD9820F873FB22789357F819FB3E6B97B6371A + BE9FA8DDE9DA158DDCB3DCBDA499FB54E84BCD70908B9250461B68326D036B15 + EDBF68BF87DAD9FD98FC05F10BC0BF14CFC528BC39657571ABF836F74E489FC3 + B60C8CD71A9A48A118EC6FBF14CD239570EA5B6B29FB77E25FFC1523F657F03D + DADCDF7C71F06FC53F114B68F7D1DB7867555D6EFF002A85DCAF95225B47B02E + E3E75C4442EEC236003F2E7C6EFDB33C2BF1F7F669F8A42FFE2DE93A136B7A5C + 9A66836B2FDAAF64D45EE207586392E05B8B7476001289C0412B09490C4F4BA7 + 4E1CCAEF556B7E3B7AF7D0FAFCA71F8EAF560E3171826DDDAB5F6EEAFA2DAD6F + CADFCF26B3657F63AA58EA7A8789668FC43138BAB0B9FB68516A9110CA42750C + 08181F8FBD58D43E35FED1FACDFDF6AF3F8935ED426BA99EE5EE0EA527EFD9D8 + B17FB9DF39FC6BBAF895F0ABC4DE19D453C29A968361E2F9524335D5CDA63CAB + 7461F218643CB6E1C902AF41F07BC786084DBE911ADBEC1B01BA230B8E3F4AF3 + F0D99615D28CEDCCDEEECDAFCB43EFAAE1712AA38A7CBFD75B1FD9068767E21F + 0DF8DAE13E1FDE78FF0055B79D4CAB36972888F07852E30303D0FA57DB9E1696 + CBC4361733F89FC57E3A93C4AB6C0326B1A9F9450019D83CA23D6BCCF50F85FF + 0011357F10CAFA5F8816C6CA3319BEB782168D6303AE197B7E35EE37FF00B337 + 86350D3FC357110D725BDBAB8659965946E9877DC09DC17D0D7F40E33154B957 + 33D7D3FE1CFE6BCBA9623DE8C2378AE97B2F91F98BFF0005A0D0FC5FE0CFD80F + C4FE3BD13C4BA05FD9E87E2EF05EBF650896591BED11EB96EB186DC7E600CB93 + CF40DED5FCA2787FF6C5F87B7BE22D3C78F7E12F833E1E695A97813C65F0F3C4 + 7A9787238ED56F6D3578CFD9E68ED22882AC96B3CB75283B5CB7DA0A9C85CD7F + 611FF055AF82BE0C4FD85FF68AD59B49FEC4F007876E3C377DA925F6A52949C2 + 6BDA70900563B4E03139CF60002702BF989FD86BE1CF8C1343F893F143F65C83 + 40F883F11FC23E3DD34DD47AC411DB4FA9F859D260658C4AB24B115985B7CB1A + 3C8E66FB848551F0F9B538559B9B69DBE5BE9ADBD7F53D878C8E1E2E128B4F7D + F4D74D1B56D1AEA9D8E73C3BF153C37F13FC33F1D7E227C35D2A0F14E9FE03D0 + BC1DA99B893528B48D71A0D274782C6E754D3849347E6A06852392D5F7F9F132 + E23DF1A6DFAABF675FDAFBC43F12748F81FE22F163F88B4DD375EF1EF8D3C75F + 6795CEA12DF436E9379BA5A3CEA511ADADE6B4088BE58712AFCA55005F36F865 + F02BF641F8D3F1C74DB8F127ECDBAAF83F45F8D7378A6C34D49F55B969BC19E2 + 0B39628AF858D9E116D2513DD79D0C72091A30A632170631E53F07BF65CFDA6F + 49F0FF00C04D63F66FFDA37E05FC6ED12D97C4FE30F0DF86F5EB3BBD3A532085 + 60B974B278DA5905D5AAD9B2F98F0812388CA861B9BE765527F6D5B4BF7D5BD7 + 6F4F322AC305522E126E2EEBE2F28CA36BEA95A4AEDD96CEDAEDA5E27D03F65C + F8850FC72D13E29FECF3A27C2ABBF157852DFE37786BC59E1095DB58B749E77F + 36D4B5CBFD9BECEDE5DD0920F2D230C1DD1108454C5D1BF625D02F3C5DF11352 + F833FB5278ABE0F78E3C01E1ABA9B54D1BE2CE990CDB123B75610DBEA119481A + D676B8B4312B5BEC02E2278CCCCA71F346ADE3BFDA52D7F661F863E2CF1A7ECF + DF146DFC19A6F8724F877A178E2EB449D213A5DC4ED72B09955332B8125D7945 + C85064721980D83D2BC5DFB44FC06F899E11F8E27C2BF10FC4961A9BF887C212 + 783748BE69A23716124DA7CBAB59A443CD8E3812EA2BD99559D308AA064384AE + 5A6ED7B3D5767FA7FC0B9F57530B555A14DBE5BD9ED24B58C7ADFA6EB4B6AF75 + AF13E3CF097EDB5FB38F8CBC25E08F15DB2F8EBC4DF1163D17E20D81D1E25F11 + CDABB59E6DE0844F0461E331A136F2C318086290283B1811FADDE2AF887F1C3C + 59F073C39F0F3F6A2F80FF000EBC06614D2AE749B5586EB54BBB67B285E186E3 + 7CEED0464099C3451072BBDB2EA4E061F8875CF8F5F185BC73E1EF82BE331A5F + C4EF86961E14D4B40F0E5CDE47630DF68B3693A5DCDFCA5E4DA5A4916E3ED5E6 + 02588899506D455AFD20F19DCEBDF167F655D03C73F16BC27A17807C4F06AB67 + 25F69D6904E874DC3F92F2EE9B6EC33A146D84203B86768D8A3D3C25FE1DD5FE + 7EBF23F3CE25C7CDAA778C54F4BDB7E8D5976B5975D5349D8FE7A3E30FECC9E1 + 3F883E2BBAF1A691E26D6B42D6F5297ED1A82797F6D8EF66206E74DEEAD1B9DB + D3254E000A057AA7C3FF0085FE06F85FA5369BE17D2E78679900BCBEB83BAEEF + 48FF009EAFC617BF96AAA8BD813CD7ABDFE95A95BC71CFA826FB9CED98EE01B7 + 360F20F73BBA7418CF6E64BDB2916EE70DE52C986627713B4039E3D720F6E2BA + 1D16B7D8E559955A9495394B4FEAC71DAAC44699E20B50B13BFF0064EAC89FC2 + 01FB05C15049C8E0F4F52C057E9AEA5A3C5AFE85E0C43A45ADED81FF0089A5BC + 72C0933477124492ABC68C180701B2245F9813818C62BF3AAC6DEDEF3C4963A2 + 30B80D709750295C16C496F22700F18249EA7AFB62BF483C1773A847F0BFE146 + B93D932DBDE78774DBCB2232BBBF711869109C7F10DA3B0208238C57CA71446F + 4125B2DCFD1BC33AAA9E379A4BDED2DEAF4FCAEFD16DB1CA7C5AF0C8B6F127EC + D57D722E567D23C57ABCB74F2401F79BAF0FDD825C900A2A4A1402C4E4EDCE37 + 0C7A9F8665B78B4F4D5ECFE7684B462556CCB0FA10173CE5B233EAD8E841C8F1 + ADDE9977A4695AB6B90335D5CEBEF6D6DB66F298CB2432170CA7FD60F296E32B + D00058E0AAE3E72F157C52F12FC2DF1AFC24F066909A7BE8BE22B6692EDD2DD3 + ED71E65916368A76041E8A02B03C87FE2C0AF1A8508FB185BAA7F8376FC2C7B9 + 9DD7A8F11513BF3A9A5E4EEAED5D79DFA3B75474BFB61F823C73E27F83FE1E9B + E1C7852D3E22EA91788EDA5BCD39355B7B126DCDB5CC7E789E7221023774DD1B + 1076B02B9DB5D7F86F4BD5759F843AB5A78F74BF067C333A869EDA15A7FC21BE + 268B57D424FF0043F2FCD9EEE3863896EA27D8E91299157CBC331FB95E75F19B + E3247E19F0DF856D3C43A8DADFC72EAF63A65F5CD96B3F6C30B4C5E3D9390885 + 368DACBB8EEF99C2F45ACFFDAA069DF087E16DF7C59D4357D66CB49934840349 + B521EDEDE6371B638ECA1E0C6ECAD243B4B1DDF21605F2C7A70F68FBABA1F259 + 861F152F76A68E5F0FDABE9B745A5AD7E5D9ADCE4FC57A1FC3FF000AFECD83E1 + 87C4EF0BDDFED15A5A42BADF8A25BDD4A1D2B52BCB64B9F3E1D4E2B5B4930912 + CA224554287CA196760ED9FACE39FC3DF03BC3BE21B3F809E12F087ECF9E1B10 + 469A73F842C22B3BB6D40DB31896F6E5D1DAF98049C9371BF280A2E3AD61FC41 + D6B43F8A9FB2FF0087B45F02C379E3AD635BD1A6B0D1574DB46943CDABBC70C7 + 31917E482D960FF499A591D16211B8936B4615BC635BF829F1DC68DF12F579FC + 45F0EBC25E1B51178A3404D675AB9BCB5B1BA9841657B6F7B159445844235B9B + 98E5824946F99213B479CC9E9528B6AE95DD8F0B1752109B857972A52BDBA3BD + 95EDA6FA74D2DA687AFF00C44F1C78FBC5DFB1B7867C7B79A4F87FC451F88342 + B33E2C1FF08FBCAC90CA24325E090388A1549608C1211B69941F977283E97E0C + F8BDA6DEEB49E04BAF08EA9A6DEE8FE09F0A6A316B4F1E535537B65E7C9045F2 + 864F2B1680E5D8B8977E17866F08B75D3B44FD9CF44F877E2BF8CB0FC4CF0BE9 + 771A6D9431681A4AE89672AC12F9B2594CACF712DCDB4CF1B34E8F229751E5A8 + 894B299FE2778FBE28FC3EF84FA8F8A3E0F45E09F0378B2EED6E3C63B27D2524 + D27564F2628E6B5BA91A5692094DBFD95D1E258D235B64895B6A322CCE525AA7 + 6D2F7DCC30DECA737071E64DDACFDDF3D2EB7B797A2D8FB4FC0BE2136FA9DCC1 + AA35DD8D888DA4699C93E601CCA3CD2546EDAF85E460F7EB59BE22F1DF86FC53 + AE6B43484D3EC26B792292348033C6081B4B160B8591C8DE53B12C4673B8FC9B + A3F8EEDB5DF86FA2FC5DD73534D32CAF7C2965E347D2F5093745A435A4623D46 + 1B8693FE597DB2E208D896C155C71939D0F815E18F1B27C2AF84BA878E25F016 + A1E30D3ECE568F50D33567922D56395A46FB7C08F0A2C45E231A324AFE62153B + 5B001AE5C5559CE9BA7257F3D8EAA59261A73788A3354AEAC9272766B4DF57AE + B7767BEEAFA7C7FF00F0508F19E9BE083E11F067C6CF859AA78D7F660F163C56 + BA9EAFA46A125B6A9A35E5ACC92B081CC6C8674882CD146CCA1C457117426BCE + BE1B7FC1337F65CF087C57F837A413E25F8E765AFF008B3FB4ECEEF54D49134A + B8F0E2C5E6C10BDBDBAC42779165123CACE14AAC6362798CB5FA3DFB45F803C7 + 7E3DF037853C17E1ED6FC29A46B29E23D3352BDB7BDBD2D21D243BC771E57969 + 2A2CE51D9A3DCE54BA648EA0416761F07B46F15689E37F0ADCFC4BF13EB5E19B + 1B1F87F73A6EA3125B0F0FDD9918C372F64F0C4E9773C6D25BB481E589A12857 + 00A6D8861A305CAEF65F22B28CDABC308A9D06936DEA9DEF67BB49E97D9F7B1F + 951FB41FEC7DF07FE217C2FF000678BBE1358F86BE1878A7C2DE1369DADF4ED3 + 9A4D3FC48F797976F69A4B488C3C8D4D63B79AF55E505A4B3977B12A9193F2CF + 873C2F63E26F07F8245EEB3E2837161F6996D74893589D61D2E65CAB3476EE4C + 4BB941E5472AC47426BFA9EF177844FC5DD13C45E09F18695A65AF857581AC69 + FACDB597EEDA09ECDB658CD6975B449034A6DED76EE19312B443E50E0FF245E3 + 7D63E20E89A66997DE35D3345892D6EAD1EE2EAD2755FB33C8AA59593A853923 + 1DAA71B829B5CAA5CB0DFB36EFB25F35A5FF0023F50E01CE96268C9D44E528D9 + 77493EB7B277D1DEFDD1F70699FB3F7C48D63448EE7C7BE28D23E1C4B79A53DE + 68882092E9AFAE06163B7F97023620E771E057E5C6AF0FC6BD2B55D4F4B6BEF1 + 8BB5B5C496E4A48ECA76B15C839E471D6BF52BE36FED0DF147E2AF802C354F0B + 7806E346F865A5593DBFF695BB89679D2355DB20E788B20E71C935F14E9FFB5E + F81A0B0B286FAD354BBBD48516697ECE3F7AE14066E5B3C9C9AF95CBF30C4626 + 972E217338B7BBBFE17563F56C660E8D29DE94AC9A5E5FF0E7FA4ADE7C168AE2 + 2975BD3FC557BA1E86ABB8416B19DF367A2976E0E7A66B5357F0C6A1AF45F0F2 + 1F0C47E2BD2EF256FB3EA91DEC085E285324CAB303DF18E0F7AD6F10FC41F115 + 8C1A7786B428F5DF1A6B8D12C8D6F6F6DE4C318E08F34E30457D17E0587C5B69 + A72F897C65E1BD1ED6FA4B668EDB46B390C924871C07C74CFA7415FBC56C7558 + 25293D8FC270D96E1EA49D382B2D2FBE9F3D52ED63F2B3FE0B69F0BF47B9FF00 + 82507ED61A6E817EFA4C93695A024CD7771E645284F12696ED2941CB10013C72 + 7E9CD7F0BFF0BFF64EF8FD64FE23D7FF00674FDA0BE1D9D76559349BAD0752BF + 4D0357D4268A55135ABC178F243198B78915E675DC54F964965CFF00A39FEDD3 + FB3578AFF698FF00827E7C7CF86B61E06FECCF89FAAF866F23D13481A8002F6E + E265BBB7B369D5945B8966B6863136E5F2CB8258004D7F9EAD9EAFE22F869F10 + 34BF81FF00B46F85BC5DF0ABC476C9E24B6D3CFC50D366D0D6DE1B88EDB3A69B + D85017CDC59C4C977681BCB7412A825DB3F3D0AF294ED195A5F9F975BFA25FF0 + 79389635E9CE3ECE09D3E5BD9ABA7D754D69B778DB4F979FF83BE3B7ED17FB23 + 2F8624FDA03E01FC49975CD0BC6BAC78ABC35ABF8B56E2C124D6AEE257BCDD7C + 5196E95CAC570C61932C46770FBD5EADFB37FED51E0FD07C01E2EB2D0BE3327C + 25F885A6FC1BBEB1D175ED618D998BC546CA34916CE74F3199A67B0B30AE02B6 + F9CB0036161F70F893E2BF82749F8EFF00B3E7C3FF0017F867C3DE23F85BE13B + 8D3BC43A0EB3E26D722D6268135B86E2C6DEDE3F32DA08AE1ED22B592EC4D345 + E7E510AA829B9FE46FF8296FEC0FA77C0EF88FA17C56F8531597873E1078FB5E + 16D796CF73BA1F0C7882794B4A90A6448F652ACA658D23DC63F2E54E8D193A53 + 9CA2D41AD1DD26B4D76DBA6BD6FBA47C64730C2E22718D787254A967BDD3B3BA + 5ADED78BBF9DE49DF4BFA3695E28F8ADE10D07E2AF8D7E15F8A759F847E3FD2B + C1771E2AB1D67C2FE22179E13F1C5858A1B8BEB46B8C1649E6B486E201304B5B + 80C2249E17337DA2B07E20695F0BBE32FECC367FB437ED23FB35DDF883E1E5EF + 86FEDF6DE36F879A768FA76AFE1AD5EE6686DE3B69945D580BB93CC9E27113DB + DC2CCAC0A846DFB7C07F68BFF826E7C41F830FF007E1EFC37F1CF887E2DEB3F1 + 0A2D665FECA9E38345B184D943653865125C98823A5FE0ACCDBF2AB8197D829E + 8FE3FF00DAD7E1CF812DBF668F881FB365CFC4CF863F05FC510F8E3C5AFE1C59 + E57B69A2B047821BCD562335A3C5047722E3CB8E22E1D448C596039E4C4D38B4 + D3959BEFA75FC34EDD8F77015A8D5842B61A51959DEFAA7CAAF1693BDFE2D136 + ED77D9EBD8F83FFE09DFF16344F829F0F3F681F847FB50F80BC1D2C36D3F84BE + 255978CB5B86092C3C456F73B63D334D85A3737F0B5BDC5AAA46D878992E18B2 + C2CA47EB368BFB32FC74D1AC744D03C5FF001BBC43F16BE27E9696305EC7AF5F + 5C25BDB38817ECF05AA0C5AC11246A9B488901C12EE597757E167807F684D07E + 23780B44F0DFC5BF14DBDB6B3A7FC57D17C57E1EBCBA479923D2261258DFDBBD + D15C058ED26B66F3242BBD74F8813C003F49FE1EFED1DE22F09780359F11F847 + C47A5BBF8A3C77A5782F5AF11C1FE94B0DCC3A76B1672DDDA5C2B6DF3671A1DB + 32CBF365189400CA197A684270B3575FD2FD5F73CBE26C3E22BC5C653BABBD92 + 5D6E937BED7E9D2DBEA6AC9E13F1778B9359D5AC749BFBCB64924F3EF9A02602 + EA5B3F3838003705BEEE41E41AA2FE199A6BDB0F3AE164BA312C32A49807CCDA + BB909EDF3023903239278A87E28FEDC1FB527EC39AB5E7C1AF8CDF0AB4FD4B4A + B6F17CB05A7C42BFB669ADAF3C2D34D750DA4B1B4523AEE9D63B79CC534A5E38 + 5270A9975F27EC1F1B7C40F80BE3DD5BE19780BC39F0B3C6AFA6A69F69E23D57 + 57D06DA0862B45B8D37CF1688C38921474DB2C8ED118CA7CA5C9727B1E609DDB + 49FA69E7D4F93FEC8C4D05195EF177B3BAD6CD27F9EC7C356164B078E3C272AA + CAB7D06AD66A8FFF003D479B82A4753B867EB9AFBCBE1F78A2D2F3F66DFD956D + 2E229EF27D1FC3C9A7BB79A0A4E893798ACA060E0A8DA413C30CFF0019AF8C7C + 57ABF8425F895A1DFF0082ACF5CD27C34353B09AC935498CF391E64786943A86 + 55700B88C8DCA08525B193F53F81BC67E09F85BF057E08EA1F15B46D6EEFC2B2 + 592D9451E9C8B72CF70A641F68901605A20B1606D1BB9076B00D8F0F3CC37B5A + 5682D5DAC7D6F0B678F0788855ABF0ADECF5D9E89FAB5F7BBE869FED131453F8 + 83F65ABDBA61183F14A7B8325B801D627F0DEB04ED3F77711C704819FA0AF99B + F6807F1143FB46FECEF7767F0B7E3278FBC18961F6C66F0CE8571A9882386FA7 + 79A39843B9A0702688EF906DC4A873F2B57B4FC6C9E1D634ED1B56F05EA9A869 + 571E19D426F16E9D2884DD2214D2AF60C3BCC3CA8E3D97DBF73EE385C143BB8A + 3F043E24FC50F8BBFB3A7C55D73569358BDD5EDEC27B5B89F49509F67F26EE18 + A3B85840C42FB6618CFCAECA76ED5C81E153A11BA6DA4FF5773DE9E655210738 + C6F18EB6BF45A6DAEAAFDFA3EF73CA3E2C7ECFB3FED41F0D356F0A9F15F823E0 + B7C4399F4B9859A5ADB99EC64B6DCC96DA9C766DF248E252EBB2467462396F99 + 47A2DCE9FE09D53E17695F0B7E34788349FDA4F52BEB66D33547B8B1FECEB7D4 + AE926DACEB042F982449A35C3A32CBE64464255B22BC7EDAEF54B3F8AFE32F14 + C365697DE21B6D0AE2E6381596D96F185942C617908C471975501DF0AB82C7D6 + B93F8CDE32F1468775FB297ED29E1AF86BF103C45FB396A7A8DE5EF8975BB1D0 + 6EEF16C64BE582689E68E146D92E679DCC6DC3342EAA738CF3B8C20925D75F2F + 23D1C33C4E26325CEA314F9525A496AAF67BFC3CDB6B73F443C1D63E11F82DF0 + B9FC3DE04F03F86BE1B693636F15AC3A6E8EB722DA32FF007A45371FBC9DA466 + 2CD73BE50F2672E4A803E74B1F1CDBE85E0CF14F8193C4FA545E20D7AC65BC83 + 482FE65EBDBC254ADE4311E0408C82363BB04CC0B290B91ECDE2AD2F59F883E0 + DD0BC67E1AF11F85FC0FE1EBFD5EC1B5DB8F19DE5F59456F6137C925CDB42D0F + 9D1CB9484A5B4E89B8370D113B8F6DAAF843F652F83DE2DF0CFC76B6F87FE09F + 881F10A1F075F7855B51D5744DD6DAD4285AE431B7BF6954DE2C6ED1ADC451C1 + E5DAA6C459941947B11C649B8F26896CF53E07FB2231F6D3AE9CA52BA6A2D377 + BAEADFA3BDD796BA1F146A1F067E26FC67FD9ABC53A37C30D2EFC7C427F10DE6 + BBA4C10DAB06BB9E34286CB6B1411F9FE6491AC8EC8A9234658E335EE9E0FF00 + 0A78D7E2CFECCDA5687F1BB45F17FECEBE34BFF09DEF86A6B3D5F4E8ADF54B1B + D16CB08BB8ECA6625AD59E38A4092EC77459620ABFEBAB5FC47693FC20FD9F6E + F47F833F09FC37F062D574986FADAEBC0BA579524500F3240B773492CB737691 + 46A5A4FB4064C900021D99788FDA0ECFC5D2FC12F82BADF853C4DE0BF869E21F + 146A7A12DFDEEA9A6B3D95E5F4908B88A0FB4BCCB22096489977299362798369 + C00155A729A737B2FEBA7F91182CC29D39C30F1B272764DA4DED67BDD6CB6D6D + F33E82F027C11F82765E061F0E35AF0F5878FF00C2926871E989A7EBA04AC6C2 + 69C5DDCC2A76C6CD0DCDE795718707608E058CAAA12DE6708F853F0AFC7BA0FC + 0AF83BE17F87DF082D6F561BEBDD3340D3E2B291A53BC079991773B7949F2C8E + CF9DD9078DA3D3F4AF114F770EB5AF3D978474FB2BC8FC9BBBBD36E63BDB7D8A + 5BE4FB7F97124DF36E54901C637657B57E76FED296FF000F35DFDA17E01FC51F + 87FF00197C65A17C5DF0F3FD9AE74DF0F680BA92EA56C93F9B1C2F7370F15A47 + 282D3C67CC132949B3B731AE62AE2631A57A8924B777FD5EAC79765B5EB62DC2 + 873B94AF64949A4ECED751568DF4DD3B6EDEA7DA3E14F8ADE17B7FDBE749F85D + E2CB70D61736173A95A9826B8B6FF8496CE288109089376C9E1586EA395A1738 + 281B11B5771AD5BEADA4EB5E25D79ECFC3DE1BF0FEA1730E9979AFF88B51B5B1 + D2627B1D22F1EDAE23B8B9943CB1437E6DACF74625950A8708E91E4FE2DFC70F + 8EDF1BBC53F17745F8A9A3FECF9E09F096B5E1149F48D175693569758D4EDA29 + A46679ADE2976D8C6E3CC7C4AB6A6419387C80C381B3B0F15FC45F1369BE30F8 + B7E2CD67C6F6331526FEFAEDA7B98A31C158CC84F9447202A6D51D80E952F34A + 13A6E14D39DF54A2AFD3CECBF13EBF01E19E365569E2311354AD1B4B9B577BBD + B95DBB5BCFC8FD09FDA97FE0A13F0DFE1FEB3A16ABF02BE31378C6FEED9975F5 + B0D307F674062BBBEB8B596CEE6E144B75791FF6ADD5B9748C5BB471C4E3E7C2 + AF8CF857C3DF0CFC6BA0782FE20F8EBC03E1ED034396547106A3279B73A84C83 + 11F98A7E520281F2F5AF17F8BBE04F056B9F0FF53D13E157C1D8FC53F16756BB + 87CBD4AEED95FEC165110E443216C2C8C1307D49AF1DD56EFF0068DBD97C292F + 8FBE0AEA967A745E65A6976458A9B5C8C79A46EDBBCF5040FA57C7626B3CC15E + 71F6738B7F13D95BA27D765B5FA9FB664591E1F27A5EC68BE68B4AEECAEDF4E6 + 692D95EDD9687D1DFB4BEB9E3EF0F7C40D0FC25E0BD2DFC25F07EEED56F2CAD1 + ECFC86958B0CC68A463CBC90DE98E2BC6AE3C2DA7CF713CD71F0C3C3F3CEEECC + EE2CD7E762724F071C9F4AFAC3C29E07F8C1E3FD0B47F0EF8D755B89BC3DA446 + B0E9ABA9912CD6ABDD439CB600E339AED8F843C196E4C0F7DA7CCE9F21756387 + 238C8FAD78F570F0A508C2752F6EC9FF00C0BBF33EA235E559B942175E763FBD + 897E09699E1FBBB3BDF855F0D75DD6E39976CED35FB8861F2C672CD231604FA7 + 5354FE10788BE2BD9F88B5FD4FC536DE1DB5F0A58CB342B03E9734865607EE2C + E3E52C318EFE95F5F47E3CD0E4BC90E83A8DF4104F21925B7911E331B6718390 + 073E86BB7D3F52D6352D1AEA24B4D3B49D2C2796B2B60A807BEDF5AFD7AAE3EA + B8FBEAF7EEF53F35A180A6A6A54656B7456B1F991F173E387C72D675CD33C3D2 + 78797C0F1DCA89145B5D47BE4809206E7E8A76F078C8E95F39EB5FB2FE91F1C3 + C3C3C0FF00176D3C1DE39F0935CC9E7787BC4362B3D8CAEDC02F13ABC64E3F88 + 283CE7DEBF5A3C61FB39FC39F123DA6A5A86A324D7F09493CE58B74AF8E40560 + 72A09AE2B5CF0E7877E19C77FAF594573AAFF6A40F6F336A53E648980C298C1E + 4638ED9AE9A199C3D9FB3A71FC3FCCE0AD93CE5373AF2BAF5FD0FE693F6BBFF8 + 37CBF639BDD1B4E83C1D7BF107F65B5D5753B4BF7D33C05A836A3A52EA10EE48 + AFDF46BD32C44462470162783018E08CD7E5FF00FC1453FE08B1FF00054CF1C7 + 8A7E07F893C0BAE7C23FDB6BC19F0F2C22B6D21FC1B6A7C3DE25783CC85E796F + 749D46E1A3B9BA616E848B5B99338C0400E07F565AF5CFC428B577F10DDE92DA + DE89A65B977BC96ECDB40D0AAE72C2419E3AE457C77F0AFF00E0B19FB2E5D7C4 + 0BEF86FADFFC27FE15492E1A38B5F974D926D2CC99DB96940E63272037423DAB + 758094E2A54B75F77DDE5E5638A583C34AA2735AEB66F7D559EBE6B4F43F974F + 8D7E27B9F13FEDA1FB21F8B3C47AF7C45F0178A344BBB1F02DFF00C25F18D95C + E97A858DCFD9E69E7D52DECA7D926D9E4B4861998C4AD9FB3059641B55353E11 + 7C6CF8C9E02F8CBF0A3E2D6BFAEEA1E35F0E78AFE1F78ADFC556FA9BE2CD3C57 + A3CF72851DA31FB8F97EC0AC81414895C28DA1857F4EDFB7069BFF000BFF00C0 + 72C5A3FC29F0AFC65F044E0CD1EA1AB680357D1F4D61F32CCB68E0CB0B920112 + C4508EA18100D7F169AC7C1DF8DB65F107C7FF0004F40F165DFC1DF08EA171A8 + 87D3746B09EEE0B182E63962B892237CED711A4C26955916507E7623049274AC + 9D34B99EADBD3CDD96B7D95F5577A69D8F8797042D695369A51E55CC97C29CDE + EBB7327FDE71D5EBA7D2DE1EFD977F623FDA3B49F86F6F2FC1DD4FE01F8DFC47 + 2EABAA6B3ADF823C44DA7691A1C69671EA4A834FBE6B9B744923B993E6F9238A + 2B47DA5768AF8BAF3FE09A5F19F53D7BE25697FB3F7C5BF845F1462D1F5B99F4 + 6D2DFC46DA5EB5AD58C4EFF64BEF25A35B48E66446655136461CAB6DEBDAF8EB + C4BF157E0BE8DE2BF067C58F01F87F5FF0BEA3F0EAEBC1B6973E12BEDB70F71F + D957DA7C37D776B74C1A22F1DDDA09123C8C5A214CB3393F4B7ECBBF18FE1B7F + C2C7F847E23F1A78EBE137C4CF0B58DB8B39BC45A939D135CF0C4A7679EB796B + 3C88042D233CE0A4B25ABFEF0B41048FB8D54C13835049C5FCEDBF6B3ED7E9DA + F7D0F2EBD4C76154EAA973416C9FBDE7BDEFBBB3575A6A937B7E70FED4FF0017 + 3F6BCF0CAF8CFF00651F8EFE36B4616F65A669BE20D3A0B9B7D4619A18C5BEA1 + 68AB741A48C6CDD11DD1796CBFBC8F80CEA7F53FF63CF8F1A4F877F64D9FC177 + 9F0AFC7171E32B9D327D362D4B525B3B2B282DE5B1B3805EA991A4B9BA60F6AF + E5ED8D022B3B163E60032FF698D1BF653F8ADF1A26F8FBF0EF47D1BC41AF5E47 + 68D35F477C6E6C1E7B744B759D2D15BC9F30A470307E47CA1B1B8E479EBEB8B6 + F3897CE69DDD995D94EE058F6249E7A6727FFD4B0C9CA2E7F69E87CFE739CC6A + 528617D9D9AF79F4B495B6B3BFDEF64933D3352FB12F897423032411CB7B6CFE + 6C92395880983B364E58004F18CE38C6302BD1FE325D22FEC71F00A2D53508A1 + BD85BC9855EE63196961BC942AE4E4B146C85527804FCC057CFB2EA69752D85C + 6F0248E4F98103690369272471D0E0F5EBE95FA11A37C2CF865F173E02FC3FF0 + 27C51F0568FE33F0B1B7D36E934CB80E239E780B323CA6274236995800082433 + 272AC41F3739ACE95A7BDDFA0F25A0B1115093B3567A2BBBEDA2BEBBFCB77648 + A1F0F7C163E315D2F84746D5B56D5ED20B56875ED3EEB50B75D2B4BD3E780C12 + 0B94B8036C8C18C884BEF6740AA30CD8F11FD8E3E067ED2FFB2C43E32F87DF14 + 3C79E06D2FE10CED3A8F13E83E288B52D4F5AB5DEAE96EB68D118CC8B2C31C82 + 69245F237498F3BEED7DC9A0F847C2BE16D1F4DF0BF847C33A0F86EC21840B2B + 3D36C22B4B68F0B8388E250A08000C904E00273CD7C9C3E2945AEFC7FF00137C + 31BF919756D21BCCB7B22EAF23C42D165B79550E7745991A6CE0AE53383822BE + 370D2F89EBB5CFD7332C4559548C28F2DA4D45A6B6D92DDB5BF656EBBEAFD7FC + 5377FB30FC3CF1DB598F849FDAFF00F0B3618B40822F13CD1F88F4DB199512D8 + C31FDAE26FECF5BA8E588CC638489586E26318AF41BED6B50D3A2D4F49D02DE5 + D3745D0F4C82DFC37E51F2EDE0B548910476B12B130450E0462050A308B8C005 + 47CFFF00B60FC39F05784BE3BFECFBA7F8335CF1325BDF78A2CAE5745D575C5B + F9A5BBB7485CCB67097698016FE7BCC630222CCEDB40209F23F88FFB4EFC32F0 + 34FAFC5E30F18CDA6F876F75A8ECA3B6D4C0B7D52D2D6DADF3792AE9CB19BEF2 + 1EE55228088312677891510B1F46719425ECB9569BF5D8F89549E261EDE8CA6E + 524EC9AB6B6B6BABB6CF66EFE47AC6B771E2BB7F81DAA59788343BAD7B49BC80 + 6AD3DD5EDCFCB6916E7589A2CB093F76BE5DC3361A33BF6B77C7CFD6DABDEEAF + A5DEFC1EF0F68F7BE2474F87777ADE9F3DB7FA445A74E4DE58DBA5D60EDB7DFE + 66227760B262E13FE598AF8FD3E28FC46FDA2FE3C78E7E20FEC4BFB33FC60F8E + 7E2CD73C331F81EFB56D6336BA0E9B6A5238665516F2A450ACA914482DE7BC58 + D3E66F2CBBEE5D2F8AF6BFB4EF80E2F0CE99FB546A7F0EFC5171E39D2AE6EED3 + 40D2A7F3ED3C396F672470B978A28A381670F2F94AD9B8202B7EF31D65557651 + DDEF6D3F177B2B79B3E870BC2D3A959BE651E6493BF7D355157BB766B5E5E9B9 + F4F7C74FDABBC01ABFC2FF0005F83F5E8FC71F08BE3F788B48D32D751D0F41B5 + 8BC41A8CB6F04999EDF7C7729A7A2C85A748E6924F3A38652AF193951C178B7F + 68A1E3309E0EF8ABF08EEBC6BF0D7C2162353D55754B0B4D5AF3454580C76F70 + 209605D36148831503ECF21C16F9989663F22585F58C5AA4FAD68A25D3FC6F67 + 140FA2CD71FE9170EC8429814B6768DBCE00C01C5767F1DBE26EA1A478624F11 + 7C58D0B4CD335BF1669DFF0008C5CDC69BE685BF887FCBD5CC0BB7CC6507EEF4 + EBDB35E76619B5A4A9466B99EE92777DBF4E88FBCC93C3BC0D1B559C39B92EE2 + E4F48DF7EBB6FA372B773E71D17C47F10F5FF8D3A7FC52D4FE2F78EFE2778734 + A659BC2CBAB4A7CAB67E91C70DAA85B7811000008A345EC02D7E877852DF50BF + F007C45D424B0B0F167C4AF135AC96D6B7128653A6C8F82660E31E5E33C05AFC + EAF06DAEA7E1D7D2ADEFAFA0D474D6B84B5B7BD4B468A15B7E8A7046158E0671 + 5FA136DF12AFBC13A2F84F4BF0C59D8EA1AD6A7A8C16B7AAAA4A699A6AE4CB39 + 04F0F8C804F52C2BCDE23C4CA8F25385E495B4BABC9AEB3B6D6D94775BBD4FB9 + C870706A574A2B5D97BA9768AFCDF5F44749E17F81FA9EB9E0BBCD1F57B8669A + D6111DC6A96AECD2DA02003BCF3F31EBCF3DEBB187E05FC0DD2EDB4FD3B52F18 + EADF6558D537DB6E0D21038519FE23ED5F777C00D57E15EA925F685E0AD3EDB4 + 5BDBA66B9BE52854EA27805A4CE771233CD7E4AFEDADF083E2278ABE3B584DFB + 3CF8B74F82D7C1F34FAADD34971E5C304C0EF112AA82256C829B6BE1E8E7B8CA + B55C6151D252BB95AFE6FF00A67D655CAB0F4A9A9CE1ED1AD1753DF3E1B7833C + 39F083E2BF8D6F343F185FF8C7C17A868D6B36931DCAAACDA55C19184D1BB903 + 763018679FAF4AFA422F1BFECF7AA6ADA56817DE2B6F1578E0B2F93A6419BCB9 + 278E760C841C8E4FAD7A41F895E17F8E9F05FC2BA4C5F09A3D23C7D7BA445737 + D1DC2A465A4D803E148050939DA0F7AF857F628F0BC3A7FC42F8A9E2B6B1F15A + FC439F569AD24B1D64C493E99E4FCA230C8301082AE0E0EE0C2B1CD28D46DD48 + D5E6B2DFA860AAC62941D3B5DEC7D73FB52F88AE7E1C697E12F1DEA3A5D9782F + E1758442D2F2DD462F26697A34AC7E52BB411B4722BF3FEFBE28FF00C13A67BD + BC9E3FDA0AFED23795DD6210BE220493B473DBA57B8FEDCDF1BBE15F877C32F1 + FC54D6B4EF17F8D3ECCC2CF4513F9C4CC3A33C20ED5DBEAD5FCDB5D6B7777573 + 71731DC59DAC7248D22C4B02B08C139DA0F7C6719AFA9E14C8EA6230D7AE9DBA + 3DAFF95FF13C6E20CDA950AD68DB5E9FF03A1FEC8FF0B3E34E8FADDACD0F88E7 + D3F5C4DC8AC9E605209E776475AE83E2359EAFE2DD0751F13FC2D9E2B28EC0E6 + 7B4172CAD74ABD42F6CF706BE3FF00859F0E7E027D9F45821F8B3E6DFE1519D5 + C472CF26070C9FC15F6169BE39F875E03D2F5BD32C7C576BAFA242EB2410BF9E + 6DCA827E7099C0FAD7EB55E2954BD34EE7E69858559D2E5AFA2EF7FD4F8AF4CF + DAC2FADB5FBDB33E3286D6EAC914DD5A5E4E11942F3DFA1AF7CD23F6A1F82BE3 + 2B3D27506F15E957FA8AC0F2DE2CA5648ED8776C838C67B9AFCF7F15FED33F0B + B59BFBFD4B56F877E11BAB58249237BBD5ACE359301B0D180D823039CB76ED5F + 949F143C5BE0DF8ADFB40785EC3C2BFB42FC12F0AFC2B7D4063C2B6F68ABFDA5 + B4F31DC18F04A75CAE31D2BD7865F29C79AA41A5DD7F5FE7E87252C4723E552E + 63FA18FDA060F859E2BF86BAD4FF0011BC6F69A57C24B6D3A4D7A746D4A38ADE + EADD016057691BD075D84E18803078AFC63FD9EF51FF008261FC78F88F6363A3 + 7C749E0D6ECE196FA6D16FED5620F691B11BD0B26028E3BE71F957A4FED21F17 + FE0769DE0C1E00F8DBF11FE1669FF0B61B344B1D118C70AE23195F2A343961C7 + CAA4E320715FCECFED37FB5569DA8780F59F849FB1BFC3EF027C32F86376F37F + 69788AFE3D9AE6BE78CA23E3289D5467920FCBB6851A3463C9527693E97D7EED + FE7B7E45D553A92E754EF05D7CFEE3FA49D4FF00E0A21FF04E7B6BCF18FC3DF8 + 3DF1F97C0DAEE8FB74FF00B3DE2DCC316A5701F6930C846C95791D32335F9EBF + B697ECF5FB64FED63E38F01FC01F0A9F86BF093C0BACB36BADF10F55D0A7B7B8 + 8214527CBFB48DBBD5B20EC0413DF0326BF2CBFE09EFF0A7F6519AE2CFE277ED + 2FFB55F85BE11D869A05ADD787ACAD9EE75DBE2C7026858E4295201F951B804E + 715FB05F197FE0A5BE21FD98B438B5BFD9C74EFDA4BF697F0E5CDB369DA3EBDE + 3F58EFEC442187EF618111245509C01B149000C763C184CD255694A52872456B + 7BA764B66FAA6DEDA33AB1395C2328A6ED7B2DACBE573F3FCFFC11CBE16783B5 + D8BC23F15BF6FBF84FAEF8EA59763DE6A16F28B3B6239CBC8F31C9C740481ED5 + F1DFC6BFD90FE0C7C27D5FC45F10BC09FB43F85BE24DBF84AFBCB5BDD2F4C302 + 6A9228198EC6F4EE52792A586E1D476AFA9EDBF697F0878C7C09FB40FC67F8C3 + F0E26F8C9F1B4EB093787E1B6B78A28A25920002B598C068948E723823D857C8 + 9F0D3C0FE2CF8ED67AE6B7E28F08EA5ABCB6BE6EA0345F3069FA3D82AFDFDAA4 + 846603A28E78CE2BC3CD334C1DA15A5CF52ACD6914DDF476D75D169B2E6BF6B6 + A5432A9A72A4D45416EDD9AD7CADAF9DF43E558FE2778A6FEF9B5CF155958DE6 + 82D2A86D52E1DA292C622E00690C485662A3A90A19B071C9AF51D63C6DF0EB4C + D7EE7C15A978DFC36BAAA3C72C5762768AD6F1645664786E24555236F66D8C38 + 0546013E3DF1DBC67ACE8FF11F4AD3BC34FE15B6F07C090DDE9D3D89DF61BF19 + 21837DE656EA0F19C74C647E65FC4EF889E35F13F88EFAE757B9D1B538AEA792 + 48CD840ABE6FCA0EE2467A210401F2E1B8E0D6B9362B15283AD8A6927F656EB6 + B5DFE1E67C8E77C0D96D45ECF0F1709775A2DB5F776ECF4B1FBB296444FA7DCC + 2C8B03EC8D5C6D78E519E002073ED8E318F5AFD46F83B1B47E02F86C77C6D8D3 + 3CB811FE5673B9C0036FDDE4BF2076C6457F193E0DF8CBE3CF00BEDF0778BFC4 + 1E1BB7DE24FB224A4DB3B8208CDBBE63CF1FDDCFBD7D93E13FDB0FF6C9F89961 + A57C1CF87FF11BE21EA37570AD1C3A3F852CBCBD42F01EA035B219F693C9DA51 + 073920576E3EA43130506CF97C27086232FA8EAD39AB777A5BF3FCCFEA13E2BF + C6CF827F05F4B8AFFE2DFC44F0A7C39B810B2C2351D4156E648CAF22DECD775C + C921C63288463249E6BF08FF006B7FDAF3F672F8A9F10BE1BF8BFE0DFC3DFDA1 + B57F8D1A1CAF69A7F88F47BA1A0C5AA40CEF22DBF92D05CDDDC0469250852385 + 824B221DCAE36F8B783FF614F18E8FFB4F7ECB3E09FDACAF5FE1F597C4BBED42 + 49DADF5EB6975A8A1B78DC6C9EE1C491C77334DE5468A5A57F98F01B68AFE8FF + 00E11FEC95E0FF00823E18F8ADA4FC07F84FF0A7E1178BAE747D5B47D03C4DE1 + ED4B52BEF125E34D6B28866D4757BD8D5EDE4DEF6ECD1C1FBA8DD5C87C22D785 + 52853836E0BE7F71D153174B0BECEA549CAAB6EE9A768EADAD6CEEEDAF75A5EC + 7E43FC3FF82DFF00050FFDB5BC2DA5FC57F8A9F133E1CFEC65F006299F4FD3EF + 27B27B3D4AE7CF8D62992D961275298CAAB123B5DDDC31CB80A491903EEEFD90 + 3FE09C1FB24FC3B9FE26E9FF00163E1EDA7C57F8B3E0AD734BB8D4F5DF1C6A0F + 7FE1FD53429879AFAC5A693188608D5624B81241762EDA19234DCF22CAA6BE84 + FF008271FC55F05FC5FF00D94746FD9D7E2169DE2FF0AFED2BA4E89A868DE31F + 0D6B1E1CBDB69511A49164D47F7902DB32C88C0EE328C4A64C819527DEFC6BF0 + 72C744F14FC7BF1C78FF00E35F85BC39F0F35EF0D587872DACF4CD286A17FA75 + A4D32ADCC770CCC9090560F26195BFD59BC91E5E5218E94631D1B7CC9F45B5FA + 6DFA9963335C573D5A104A9A4D59AD2EAFDED76DF7BD9F6BD8F45FEDAD1749F8 + A363E1C9355D3745F09E95E0FD5B5022CA18ACAC74E4F3A392030C0A23821586 + 165CC8150808E377CB91FCC27ED41FB4EF81BE2CFC73F02D97C36BF83C55E17F + 0D682FA45AEB861912DB5469676B8926821923474853202B303BC96753B48CFF + 004F33FC2CF0C5D6AFE3CF10681E035F06EABE23D2C6937BA95ECBE76A97D671 + C296D6A934A14A986358CA32260B160CFBC8C9FE713E247EC767E05FED371786 + 6C3414F17EA336810EB1223CBB2DA3432BC28E46D070CF6F200BB792A7AF5AF2 + F32AF4E9417B55CB1B3F4E9F2FBFEE6CFB2F0FA9C6A579B84F9AA2B697BBEB77 + F2F2E873BF0C3C53E08F0C6B7F69F1269FA45FDBBA331908F2A58F7270E84F20 + E48E3BD7C99F147E3AF8E3E31787759F0BF8E2FF00C38B6367A81974CBB9A10F + 73022362354D98118618CF3935D2F8B3C3FE03D43C7F7D378F248B47D516E07D + A63B8BA92148594FFAB541D1307F1AED7E347FC28BB59E4D37E0E58CDA2F85EF + B4D861D4658E2257CD539628CFC0DC793839AE3C9F04A38852A7CD5A72D5593B + 47ADAF657DBA688FD4F30C45E8352B5382D1DDABCBE5AFF99E63E32F1578EFC2 + 9FB3F58C7269771E20D7A4B95B6B6BAB6B7CA5AC67E612383C8718C0AEB3F64A + D6FC51E133AAEA7E26DBAC6A5AA26EBC5BC97CC967523A303C2607423A77AF80 + 3C6BF1225B7BBBDD3ACF59D6353D3D1898964B9658D581C06099E7A753587A57 + C5DF13C7A65E5B69C6F1AF65264BAB8F309DAA3850BE8315F414F85F0CA33A58 + 995A537CDEEEB6F2EB7FBFBDD9E6D4CEEB3942A52575056D7AF9FF005A9FD2C7 + C11D77C2FA142DE353E228B4A06668228E7BF42225EE83F964D797F89BE31FC0 + 8F835FB4ADB6BBE24F10C77BE12F1214BA9A5B2B81731E917110C324A8BCAAC9 + 9CE7DBDEBF9D093C77AF4F692B49A95D8B662464C8D863DF8AE763F10DE4B70D + 6D6897135C37F101C8FC71FD6BCCAFC2D41E8AABB3D348D9FE6FF23B29E7B514 + 53F66AEB5D5E9F923FA23F8DDFF051BF812FE3AF1178ABC13E24F11DC5C5BCF1 + 59D959D8DA1449E1419DCD21F526BE27F885FF000508F1CDEF8FEEFE277C26B3 + BBF867AB5E58C7677F25D2ACED7CC8789957A23E0E37771F4AFCE8D22DA772B2 + 6A36EB15E0C8408FB89F5DC3B56ACD69116F36EA601C0C2A33E547E55EDE0382 + F014A10E68F372AEADFE3B1E56338AF17394945F2DDF4D7EE6EE686BFE23D43C + 5DABEA3E21F10EA973ABEB3793BCF3CB2CDBA499D8E49249F5271D8555FB141F + C31C9B7B62A182DEDEE194AD9AC888D95311C2E7DCD696FBB1C6CB45F6DE38AF + A94D7D88E9F33E75A6DDDBD7CCFF0048FB3FDAD9BE022378CBE2CF82BE13FC31 + D2B519B1A85C5FEAA4CF79963929095059D4F3807F3AD8FD9DBFE0AA5F037F69 + 9FDA324FD9DBC15F0F750F08DDEB8B35B685E2EB9B658ECB5BB9442595E21878 + C10A7633901CF1C1C06FA07F6BAF077847C6FF00057C4F63E33F0B7873C5D650 + EA76ED0C3AA58C57491379CBCAAC8AC01FA57E6DFEC13E14F0BE95E39F1E9D33 + C37A069C6DF5CBA8EDFC8B38E3F21015C2A6D03681E82BC2CCB399FF006A4703 + 4E292B26DEEDF974B7E7F91D3808C55172A9EF74EDD17979FA1F3D7FC168BC6B + FB54FC23F036BDF0F3C43F03FC3165F0C6E2F009BC4FA159CB7F737D046325A6 + 78536DA42490A5A4391D38CE6BF0EBF665FD8D7F6E9FDB4FC55A36BDF04BC0B7 + BE11F0EAFEF21F105C46BA569D6EBC6592761994E3B206CFE35FE921E1DB2B2D + 47E0DFC40B6D42D2D6FADE5F0E5E2491CD1875917CA938607823D8D7E4E7EC61 + 71716FF0A7C1FA75BCF341A7AC8AAB023158C0326080A38C575E1F2FAB8A9D49 + 4EA594545E895F56D593D96DFCBAF5EE66AB2A2D422B7FEBE67E5D7833E117EC + D3FB2AF833453F1CFC2FA87C68FDABBCF7B5D5B59BEF0F3EBDA65CED3B7F74D2 + 83E42A6074DBF8F5AFCB8F187ECD3F0CBC4FE31F897F11B56F893AC69DE2CBAD + 625BCB1D16CF438EDF4CB28188C4680648E3DEBFA68FDBE618AC3C25F11EEAC6 + 28ECAE63D34BA490A846462064823907DEBF907D475FD78FC56F16C475BD5CC5 + E72FCBF697C7DDF4CD77E6993E168E1B9DC2F293D5DDA6EFDED6BEBA8B2EC7D6 + AB5DAE6B28FF00C3F5FEBC8F60F86BA6FC2DF839E2ED3A7D17E197FC2E8F896B + AAADC595A9B733B799FDDD98385209C93D0126AEF8C7FE0A09F16FC73AAF8D34 + B8D3C23F00340D3351B8B57D37448C4B77732263F77248EBB2303D1467A0278C + 558FF825BDD5D5DFEDC3A7CD77733DD4DB7563BE472C72B66C54E4FA76F4AFCF + CF10410CBAA7882E6486292E65D6F5896491941691CDE36598F52C72793CF26B + C4C8B153A18A9AB26AD2D2D6F85C7AFC5D7F9B5EAD9EA6718753C341A6D6CEFD + 75FC17C9117C3DFDA67E337C24F893E2AF1378775A8FC2B6DE214305ECB269F1 + DCCF3C0C49263F317099EA5801EC3815DDDDFED49E3CD6ED6DBC1DE38D53C4AB + F0CE6B996E6C5D90416D7D2F7F9D707382C76E7F3AF02FDA2A474378EAEEAE90 + 46A841C141B4703D057D4BA6695A65FF00C3AF04C17DA6D85E431EAF13C692C2 + AEA8C6D392011C1AF9BCE33BAD49CB0F1D2F2716D68F5EDD9792FC4F672FCBA9 + B846BCB5E549A5D3FE0FCCF18FDA66FBC2DAFF00C0BF184FE18866B8F1343FD9 + B168423609E4C6F771ACCA4704298DA41D4719AFC7DB481B5ED5E09AC24B29AE + BEC915B791E708F7CDE488C61DB6AAA9C039C8C03ED5FA85F1AA3483E127880C + 089095D4ACD54A8C600BB4C018ED5F2EFC5EF0C786B48FD87FF66CF18693E1ED + 0F4BF16DFEBBAC5BDF6A96F691C7797B124F71B5259D407755DAB80C48181E95 + BE4784585A3F57BB95A4F5F4B5BF33CACF719ED6B466A293924BEF4FFCBC8F6A + F077FC13DB5DD6BE19DC78EBC61E34D2B51F16EA9776DA27833C35A35C8BB3A8 + EA532991DB50BF0B886D6D6DE39EE65312BB3A44555D4B2B8FE983F63AD1BE04 + 7ECD1FB187C4AF0F785134AD57C3FE15D1AF3C41AEEB7A225B4D7DE2C8ADED5E + F67BA92788932CA1D24B6F2246C423CB4C614337F26DFB10F8DFC69A2FC40F13 + AE8FE2EF13E92B6BE01F125F5B0B6D425885BDCAD84922CC9B586D903C513871 + C868D0E72A31FB1BFF000426B2B3BDD23F692D0EF6D2D6EF449F4BB559ECE58C + 3C1309B49D49660F19F958481103647CC14039C0AF6BEAEA3277777BFA1F95F1 + 6D1ACF0B3F6D3E65069DAD64D376B75FD5EFE56FD93F81173F11BC5DF047E12F + ED243E1EF807C59F13354B2B7D62C34E8E48ADFF00B022BAB7378B6967A8BDB4 + E60263582333CA628649F019E30410DD2FE25EB7A97EDF971E13D5FF00B6B45F + 005E7C03D37C53378761403C9D497C4D790BDCCD1212864684A29D8EEAEB1A82 + 4FCB599FF04D2B8B8BDFF8272FECDAF793CD76E7C216D1132B162505EDD42179 + EC238D2303B22AAF400579B7846F2EE4FF00829BFED38D25D5CBB597ECF3E1D8 + ACC9724DA27DB4BED8BFB83712D818E493D6AF12A3CA9A5AF73E330AE70C4622 + 175CB152B2B3D2D24B4D74F92BF43BDFDAFEEBC51AB7C37F839F143E1DF8FF00 + 5EBBD22C3E3AE8D3CF2D84D2C0349B52DF63934C11E55D218E42C8EB281BFED8 + EA54A6D15EC3FB70D95EE8DF097C7B7B74E743D23FB46085965D48C704D0CB23 + 5BC490C4CE22370D74F6FB63552F90C01E421FCEBFF82A87893C45E1CFD9E346 + BEF0F6BDAD6837ADFB56AEE9ACAE9E076FF47B83CB2104F28A7EAA3D057DB3F0 + 06187C4BA2AEB1E238A3D7F57B9D5DEF2E2EAF544F34F3C7A7E6395DDF2CCEA4 + 92AC4E464E0D7262A7EC62E6B5B7FC03AE9E19D6F67CEF7BFE16FCEDFF000E7D + 2BE1FF0016F8FF0058F177C42D5BC47A5DAA782A2874E8BC311BED533BFD801B + 8C01F349009A7DAB21C0CC3305036E5BF1AFFE0A1FF17E5F87DE0DF0E7C4ABAF + 11E9FA078F2C75A7D3AD7C3B2C43CCF11D9E206B88049D14C0EF1C9E84B9E32C + 6BF606CE49249B4A2EEEE4B4D924E73884E3F2AFE697FE0B1B2CB27863F66E9E + 49249277BFF12BB3B312CCDE5699C93DCF279F735962B0B1C4A54EB6A9FF00C3 + 9F43C075A5431DCF4F46AF6FBADFF0FEA7E4FF00ED09F1AFC4FF001E7C791F8F + B50D3F49B09A085222A0857B84539CB81C6481D6BD407C12FDAEFE30F8722F1C + 7817E17F8D75FF000BB5AA35A3044895D00C6618CB0320E3838FA57C3123BB69 + 766ECECCEF1B1724F2DC8EBEBD4D7F721F02E28A1F82DFB3F451471C510D0AD4 + 055000C7943B5619866D532BC3AA582F753DF5FF00863F67C1E0563EBFB4C43B + BF43F8C487F677F8D57771AEC3AFFC38F1C6917F61937315DE973A6D61D3242F + 3D3B579DE8B617F6B63AF40B6575697CB2A426DCA1564209CE7233D8F5AFEFEB + 55B3B46F195DA35ADB327951F05063A57E08FF00C16AFC2FE1AD0B59F843AA68 + 7E1DD0B46D4EE4CCB717369691C32CEBB73877500B0CF3C9AF3325E28957C4C2 + 8CE1EF34EEEFDD7A7EA6F9A650E9537252D2EB4B7FC13F9E5B2F0C6AFA85C493 + EA39B1B0DFBC46E7E66E3B28AF4C4B3B4B6855A5DA5C2805F68048C7A0A48492 + 8C4924E3AD52C933DA127273FD6BEFA85354AF6D6E7C954AD2AB6E6D0B907C91 + 98AD2D9DF8C9278E7F9D57DB24EB2429F622C0E58673B3D89A935066FB1BFCC7 + EF1EF55A2FDD595B88BF740819DBC67206734DCF5B790429E97342CB4399C08A + 5BA2537960A1B6ED1FEEF5C56A369DA1C6CD19B5B772A76EE2EDCE3BFDDAFD9A + 9BC15E0DB7FD95BC15A9DBF84BC3306A4DA249235C25844B2B398C92C5C2E739 + E735F99B63A4E9525959C92699A7BBB448598C2A49381C938AF17FB6E295F93A + B5BF6F91D5F50E66B9A5D0FFD9} + end + object lblTitle: TLabel + Left = 231 + Top = 3 + Width = 402 + Height = 62 + Anchors = [akLeft, akTop, akRight] + AutoSize = False + Caption = 'TurboPower LockBox 3' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNavy + Font.Height = -33 + Font.Name = 'Lucida Sans' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + Transparent = False + WordWrap = True + end + object Label1: TLabel + Left = 231 + Top = 65 + Width = 400 + Height = 137 + AutoSize = False + Caption = + 'TurboPower LockBox 3 (TPLB3) is a Delphi Library, whose purpose ' + + 'is to provide basic cryptographic functionality, implemented nat' + + 'ively as a white box.'#13#10'Block mode ciphers include AES and Blowfi' + + 'sh, and will soon be extended to include many others. Hashes inc' + + 'lude MD5, SHA-1 and RIPEMD-160 and will soon be extended to incl' + + 'ude many others. Chaining modes include ECB, CBC, PCBC, CFB, CFB' + + '-8Bit, OFB and CTR. The source code is highly readable and under' + + 'standable. Salting is provided where it is needed, transparently' + + '. The design is very extensible. Extending the range of ciphers ' + + 'and hashes can be done cheaply, easily and quickly.' + WordWrap = True + end + object lblRunTimeVersion: TLabel + Left = 231 + Top = 208 + Width = 78 + Height = 13 + Caption = 'run-time version' + end + object lblDesignTimeVersion: TLabel + Left = 231 + Top = 224 + Width = 93 + Height = 13 + Caption = 'design-time version' + end + object lblLogoAttribution: TLabel + Left = 0 + Top = 330 + Width = 614 + Height = 47 + AutoSize = False + Caption = + 'The above photo was sourced from http://www.flickr.com/photos/ml' + + 'iu92/3146549932 and has been copied with the kind permission of ' + + 'the copyright holder, Mike Liu (mliu92).'#13#10'The photo is copyable' + + ' under the Creative Commons license (http://creativecommons.org/' + + 'licenses/by-nc-sa/2.0/deed.en).' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + WordWrap = True + end + object Memo1: TMemo + Left = 231 + Top = 243 + Width = 194 + Height = 86 + Color = clInfoBk + Lines.Strings = ( + 'TPLB3 is free and open source ' + 'software. It is made available for ' + 'use and copying by an LGPL or an' + 'MPL license at your choice. ' + 'Refer to the "Statement of copying' + 'permission" tab for details.') + ReadOnly = True + TabOrder = 0 + end + end + object tsWelcome: TTabSheet + Caption = 'Welcome' + ImageIndex = 1 + object browserIntro: TWebBrowser + Left = 104 + Top = 0 + Width = 527 + Height = 380 + Align = alRight + TabOrder = 0 + ControlData = { + 4C00000078360000462700000000000000000000000000000000000000000000 + 000000004C000000000000000000000001000000E0D057007335CF11AE690800 + 2B2E126208000000000000004C0000000114020000000000C000000000000046 + 8000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000100000000000000000000000000000000000000} + end + object memoWelcomeInstructions: TMemo + Left = 0 + Top = 0 + Width = 104 + Height = 377 + BorderStyle = bsNone + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'The video to the ' + 'right requires an ' + 'internet connection ' + 'and Adobe Flash ' + 'Player 10 to be ' + 'installed, in order to ' + 'play.') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsProject: TTabSheet + Caption = 'Project' + ImageIndex = 2 + object Label4: TLabel + Left = 0 + Top = 3 + Width = 323 + Height = 30 + Caption = 'This product has been brought to you by ...' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -27 + Font.Name = 'Script' + Font.Style = [fsBold] + ParentFont = False + end + object lblWebsite: TLabel + Left = 3 + Top = 312 + Width = 250 + Height = 13 + Caption = 'http://sourceforge.net/projects/tplockbox/' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + end + object Memo2: TMemo + Left = 3 + Top = 32 + Width = 614 + Height = 217 + Color = clInfoBk + Lines.Strings = ( + + 'The TPLB3 product is produced under the organisational umbrella ' + + 'of the TurboPower LockBox project. This project has no ' + + 'legal incorporation. It is an informal organisation with no defi' + + 'ned membership. The TPLB3 product is owned by the ' + + 'individual contributors to its parts. The Project on SourceForge' + + ' is administered by the TurboPower SourceForge ' + 'Administrator (tpsfadmin).' + '' + + 'LockBox was originally produced and released by TurboPower Softw' + + 'are Company as a commercial product. Versions 1 and' + + '2 of the product were commericial and were released in the perio' + + 'd from 1997 to 2002. The copyright holder was' + + 'TurboPower Software Company. Version 2 source code was donated t' + + 'o the the TurboPower LockBox SourceForge project' + 'under an MPL 1.1 license, which is free and open-source license.' + '' + + 'LockBox3 was developed from scratch in 2009/2010. It is not a de' + + 'rivative work of LockBox 2 and does not share any' + + 'common code, but the mission of the library remains the same. An' + + ' exception is the unit DCPtwofish_LB3Modified' + + 'which is a modified version of a file from David Barton'#39's DCPCry' + + 'pt package. The original unit of this was' + 'developed by David Barton.') + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + object lblTpsfaIntro: TStaticText + Left = 3 + Top = 255 + Width = 356 + Height = 17 + Caption = + 'The TurboPower Source Forge Administrator (tpsfa) can be contact' + + 'ed at:' + TabOrder = 1 + end + object lblTpsfaContact: TStaticText + Left = 3 + Top = 272 + Width = 335 + Height = 17 + Cursor = crHandPoint + Caption = 'http://sourceforge.net/sendmessage.php?touser=625421' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold, fsUnderline] + ParentFont = False + TabOrder = 2 + OnClick = lblTpsfaContactClick + end + object lblWebLabel: TStaticText + Left = 3 + Top = 295 + Width = 177 + Height = 17 + Caption = 'TPLB3 on SourceForge is located at:' + TabOrder = 3 + end + end + object tsCopyLeft: TTabSheet + Caption = 'Statement of copying permission' + ImageIndex = 3 + DesignSize = ( + 631 + 380) + object Label7: TLabel + Left = 3 + Top = 3 + Width = 369 + Height = 13 + Caption = + 'Copyright 2009, 2010 Sean B. Durkin (except for portions marked ' + + 'otherwise)' + end + object Label8: TLabel + Left = 3 + Top = 18 + Width = 625 + Height = 26 + Caption = + 'The below copyright applies to all the source code and compiled ' + + 'binaries of the TPBL3 project, except the DCPtwofish_LB3Modified' + + ' unit which comes with its own statement of copying permission i' + + 'n its header comment.' + WordWrap = True + end + object Label9: TLabel + Left = 8 + Top = 48 + Width = 190 + Height = 13 + Caption = 'Statement of copying permission:' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object Memo3: TMemo + Left = 2 + Top = 67 + Width = 625 + Height = 246 + Anchors = [akLeft, akTop, akRight] + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + Lines.Strings = ( + + 'This component library is part of TurboPower LockBox 3. TurboPow' + + 'er LockBox ' + '3' + + 'is free software being offered under a dual licensing scheme: LG' + + 'PL3 or ' + 'MPL1.1.' + '' + + 'The contents of this library are subject to the Mozilla Public L' + + 'icense ' + '(MPL)' + + 'Version 1.1 (the "License"); you may not use this file except in' + + ' compliance' + 'with the License. You may obtain a copy of the License at' + 'http://www.mozilla.org/MPL/' + '' + + 'Alternatively, you may redistribute it and/or modify it under th' + + 'e terms of' + + 'the GNU Lesser General Public License (LGPL) as published by the' + + ' Free ' + 'Software' + + 'Foundation, either version 3 of the License, or (at your option)' + + ' any later' + 'version.' + '' + + 'You should have received a copy of the Lesser GNU General Public' + + ' License' + 'along with TurboPower LockBox 3. If not, see ' + '.' + '' + + 'TurboPower LockBox is distributed in the hope that it will be us' + + 'eful,' + 'but WITHOUT ANY WARRANTY; without even the implied warranty of' + + 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation' + + ' to LGPL,' + + 'see the GNU Lesser General Public License for more details. In r' + + 'elation to ' + 'MPL,' + + 'see the MPL License for the specific language governing rights a' + + 'nd ' + 'limitations' + 'under the License.' + '' + + 'The Initial Developer of the Original Code for TurboPower LockBo' + + 'x version 2' + 'and earlier was TurboPower Software.' + '') + ParentFont = False + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 0 + end + end + object tsAuthors: TTabSheet + Caption = 'Authors' + ImageIndex = 4 + DesignSize = ( + 631 + 380) + object Bevel1: TBevel + Left = 328 + Top = 16 + Width = 281 + Height = 257 + end + object imgAuthorPic: TImage + Left = 336 + Top = 24 + Width = 265 + Height = 233 + Stretch = True + end + object lblAuthorEmail: TLabel + Left = 328 + Top = 293 + Width = 150 + Height = 13 + Caption = 'email: sean@seanbdurkin.id.au' + end + object lblAuthorWeb: TLabel + Left = 328 + Top = 312 + Width = 173 + Height = 13 + Caption = 'web: http:\\www.seanbdurkin.id.au' + end + object Label12: TLabel + Left = 175 + Top = 135 + Width = 135 + Height = 13 + Caption = 'Select author to see details.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsItalic] + ParentFont = False + end + object imgSean: TImage + Left = 175 + Top = 272 + Width = 135 + Height = 105 + Picture.Data = { + 0A544A504547496D616765A1220000FFD8FFE000104A46494600010100000100 + 010000FFFE003B43524541544F523A2067642D6A7065672076312E3020287573 + 696E6720494A47204A50454720763632292C207175616C697479203D2038350A + FFDB0043000503040404030504040405050506070C08070707070F0B0B090C11 + 0F1212110F111113161C1713141A1511111821181A1D1D1F1F1F13172224221E + 241C1E1F1EFFDB0043010505050706070E08080E1E1411141E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E + 1E1E1E1E1E1E1E1E1E1EFFC0001108009600C803012200021101031101FFC400 + 1F0000010501010101010100000000000000000102030405060708090A0BFFC4 + 00B5100002010303020403050504040000017D01020300041105122131410613 + 516107227114328191A1082342B1C11552D1F02433627282090A161718191A25 + 262728292A3435363738393A434445464748494A535455565758595A63646566 + 6768696A737475767778797A838485868788898A92939495969798999AA2A3A4 + A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9 + DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F01000301010101 + 01010101010000000000000102030405060708090A0BFFC400B5110002010204 + 0403040705040400010277000102031104052131061241510761711322328108 + 144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35 + 363738393A434445464748494A535455565758595A636465666768696A737475 + 767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AA + B2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6 + E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00BFFD9761D5 + AD23C9F48EB5347D2ECA55BEB74B58F0F6CCC4141C85C3E3F4A6C16AFB0679FF + 008155DD3E596CEE7CE891188565219C720820FE86BAD62277D5A3C154CC53A6 + D86C286D1318C6368AC5F14682354B609E4C823B64DD085DA4B3E785F61D7F13 + 5DA0B06683ED20DB955201CB648CF4E3AD2A40C8C30F0020E7023269C7112525 + CD2452A4731A3787B50D32582E6FB4EFB30B98010B90DBC027938CE3918AD587 + 4FB6370AD25A6F55C360000D6A45AA5DEAB732D85D0862FECE3E5445108DE87E + 6CF3EE48A9042CB70BFBDE1D48C81D306B49626F37690FD92B18F69A6A321636 + CCEDBC92DB01E41EF489A2592C8CCF670925B2094008AD74B460645131387CF4 + C75029DF66508499DB77A0C5672C4A4FE2295245686CEDBFE11FBBD31E3411CA + 155540FE1C9CE38EB922B061F0A6990808F24857797C67B9FC2BA609174DF233 + 7A0C7353269F348372595C30F65FFEB50B129FDA6CA50473BAFE81A2EA178F32 + F9A8CDC92149E71CD67A784B4FDA079B3301C7FABE6BB7FECCB803F77A75D6EF + 528697FB2F50DD81617457D7691FCEAFDADF64CAB7738A4F09E9C06079BC7765 + 02A61A1DB2C0B6EEF3BC4BD00403FA5760744D4DC8DBA7CBF8B81FD69DFF0008 + E6AE4F16417EB28FF1A7CEDFD962B23839FC3F66650E25BF461D36550B9F0AE9 + AE863617AC0F43E58C8E73D715E9ABE1BD6727FD1EDD7FDE9295BC37A9F19FB2 + 2FAE5F354A72FE564D958F39D3F49D26C63655F3A5263319DF1EEC83F863B554 + 5D1742482587EC1248247DE5CA0C83E838E057A69F0F5E98CFEFAD01CF19627F + A5413F872F1B1B6F6D233DCED63FD2B684E4B683FBC4F5EA7975C68DA0B218E4 + B49C02724EEC1FE551C3A2F87E199654B5B82CA00E65AF4A97C3339CEFBDB76F + FB646A183C38D0DCACA67B5751D51A0C835BC5B7BD37F791E57388920D1CED0B + A7AF049EA71F4C7E3552FEDF4968E412DA91197F318190E335EB5259E8EA38B1 + 801F68C5675D5A58B4CACB671796321D360C37A56F75FCA5F2F99F3F5C2A5ADE + 5C4314322A383220917B67B7EB5CFC6CC751793242A8EA0E39AFA2358F0F6877 + D2666D34E3615CA395C66BC87E23E8963A2EA515A69EAEA8F1EE218E4E493DEB + 92B45A5CC7760145D45139792FAE26D57ED93383BFE5E8071D33FA51515C43B8 + 6DE807028AC15568F52A60F99DD1F49430B91879D463DAACAC46307F781B3504 + 2D16702353F874AB01CA81F28C1AF0F9CF9C4D0E45C0DE64C67DA9EF24A1015C + 818EB8EB509600672A09FD69E27D8497642A3F8693931A64BE6C823C19B1BBAE + 1464F5FF001A8A55DCC5BCF909C6305B1FCA88EE049B444A9CF1D3352CC5608B + E74C13D772F34F9A5B8D14FECA5DC6F9A558B3F36189CFEB5A96CFA0C0CBBAD2 + F6E081CA99428FE64FEB548DE5A11F300481D0362A39AEE1908C14181CE5B914 + 955921EFD4E92D7C4DA6DA7FC7BF87CAE3BAB293FAD595F1D6080745947FDB50 + 3FA572B148A176E771CE48032453DB6B723818CF35BC717552D3F21DA47473F8 + E6E379F2745CAF6CDCE0FE82A03E36D488FF00901420FA9B9247F2AC18C37999 + C863EA31FE344C5901210B76E303F5AD6189C44DD930B3EA6BCFE36D5B195D3A + CD73EB231E7F0AA67C67E203F7E2D387B0573FFB356740F713CFB1ADE2500801 + B764F6F6FAD6C1F0F5C981648D958E33B3B1FC6B593C52DD8724994EEBC69E20 + 3811C1A78CF7F298FF00ECD5567F16788DF0A05AC7C60ED83AFE66967B730395 + 75C30E0AEDC1150491A2953E530079C9AE778BABB5C9E413FE127F14845C4B6C + 31C716E39FD6AB5E788BC4CE706F047EF1C03FC2A49B87E58A83DB355A653C7C + DCE78E69FD6EAF70E4B08BAF788D23C35F2C83D4C4B9FE5548EA5AF33973A8DC + B363A0DA00FC31564A2AEE2D26187AF355E4906E01543EDEFC62AD62AA3EAC39 + 511BEA1AF32026FEE32BCF6AD8D33C44362C7A9028DD3CD03AFD4563498C0DAA + 13270727A550BA0E412B8243606071571C4D45ADC1687A3431C57718920B8491 + 4F4C357897C5DB8B77F1A4968926F9608950AE0E738C9FD0D6EBCF776E018D8A + 9519F94E0D54D5B539E7D1B5396E2DE27921B5771332032121481F375C735D74 + EB7B66A2CEAA189F632E74B53CB65BDB767DAB3863E983456C781AC9EF6E9EE6 + 21124B34BB17781C0C1C007B738E68AEC860B9E37B9D52CD6A2765147D0969A3 + 6AF3925747BD44038674D80FE2D571348BE8817B8B8D32D531F766BD40C0FAF0 + 4D79BCB737F70333DFDC4C7BEF90B7F3A62A0382646AF3161208F0D56B1EADA5 + 7832EB5B4325BF89F4AE49F9617DE47B74156AF3E186AB0EC911FED841195597 + 6822BCA6DDBCA394770C3B86C5747A578C3C41A6B0FB3EAD745474477DE3F26C + D37878762E35E3D51DA4BA1DD68503C963A3E66C0C2C80E33F53D6B12EA7D425 + 320BED1D189EE8BDFEB9AD5D2FE2DEA91A84BEB2B7B951C12BF21FEA2B7AD3E2 + 07847524DBA9698D6EC7A9F2C30FCC73533A4EDA1D11AB4A5D4F33BC0D3CA5FC + B58C0FE1552A38FC6AFE8905ACD76B05E5D0B3B7DA59E531973C761CF26BD322 + B6F03EAA3FD0B518A3723014C807E8DCD4571F0EE39017B4B98D95B9195C7EB9 + AE6F6128CB99EA57B1E6F859E6B742DFCD296CF3797D371F94B7E55242B1A8C0 + 270075620D677C43BFBFF08789C69256331AC3E73EF0183A9F43FE7BD68F876F + 34AD7ED11AD6430C8065E02016FC3B91533C3CE5EF2FB871A525A5C963727E54 + DA7071FDDA9A6C1503A05E83FAD43AAC50E99FBD9A57C16C246172CC7D05451C + F7F38FF47D31D87ABBE00FCB3FE71F8766069B8C5C98DC5AD197EC222D28938C + 839AEFBC3AA93C0237623D31C8AE174DB996200CFA75C28F55C1381D4900E7E8 + 064D75FA05E5A2CC14C5716CE7B3A11EF8F4248E700935D4F53582B157E20693 + 15B5AC5A908C86CF9726DEFC120FE95C5492A142A15F775E7201AF5AF1ADB457 + 3E11BAF9D5963C49B81CE3079FEB5E3F70D66EE63595CA76C3F15E6626294EE8 + 271B32332EC28B21E4F4EA71F8D2B61B3823183824E055694B40DB77EF41C105 + 371A8967678A42AD9EA4809815CC88B21E614909FDEEDC9EC739A8A4B0433644 + ED00070C40E3EB559A4530AE09574FF9E631519C18CC8667738C7CCB8EFF005A + B5A13644B756CF131412AB8CF563542585836641BB3C8DAD906A46F30264AAB3 + 8EBD4E7D2AA4826DC91966DEDCA81C63E95684D219710A0E45BA83FEF573F3DD + 4D7771AA6956B1A102CDC367AB3120003E99AB7E26BE9F48B4DEC11DB3B14337 + 39FA573F672A69D68F737F762DEE6EC028EC7AAE4123A1EA715E960A3152E664 + CA3A1178751B48F114AEF13959DCF916E80B2AFCEBF31E7B74A2A1D0F59B27BB + BEB8BEF2EEADACA259148046E618E40E3E5C81C7D28AF55548C7664DA4F73E8E + F0D699E12F1B7815FC4361A3269D7928923F29242C91C8338C027BF1F9D7946F + 607B0AE73C1FABDF43A4BD8C377709124A5F62C842E4F7C7E15A8B3B9393D7A9 + C9AF1A8C2716F99DD7430C45484EDCAACFA9A2AE4F2302A6561C1C9FC2B39266 + EE7F5A9526E99FE75B9CD63411FD0D4D14BC1E09AA11CA4938E2A4F30F1C7E23 + 8A4D8F94D38EE0F518AD8D2FC51ADE9B8165AA5C42A3F84392BF91E2B95598E4 + FB558B52F348114649EC0734B42A29AD84F8A7A9DFF885E1D5AF5D259E08BC87 + 655DBB90927271E84D723A76A9347B678A668E5886DCA8C1C8F43DC5761AE3DB + 5843B2EBCBF98619739AE03508A28EE2496C65F3620BF2AFF4F5A5A23D3C3F33 + 5691E97E0EF8ACED24969AEDA3CBE5FC8B7511F981ED953C362BD1ED3C51A3DD + C092C177685FA11E5F90DF81E467DB8AF08F0C7D965D334D7B98DDDD2FC839E9 + B0F247E6C3F2AEB75CD6B41B2536D0C44A73B846B9C7E14FDA58EA744F608AF6 + CE68A3E6DE653D48963C8FAF2BFD6A6175A5DB484066872792264DBFA363F3AF + 9D59EC6EFF00796970EA0FF0E4A9155A6D3219DBCB9AED883D8C949D5452C3BE + E7D0BAAF8AB40B3B09E27D4EDA069A33137993205652318C06C7A738FE66BCDA + EBC45E11B201A4D724BA7CF31DADBE7FF1E3815E49E35D1AE2CD2278E3CC2FC2 + B67BE2B36C03AA6D90E4AF15949467AB4274EDB9EB63E21784526F2934AD51B3 + CB48D2A211EF800D6FC56C2EA34BBD3AE18C13279885D7F84FAF3D783C5785D9 + DB5CEA3A9C56B650BCB2CAC238D1392C4FA63AD7D0FA7F86757D1343B4B49038 + 30C20365481BBA9C1FC4D44E8AB6888E589873E9F731B65F63FF00BAFB78AA37 + 1697990EB1C58C7DD639FD4D6D4F1DF281E75BB3A06078E45464C51CA51AD98F + 1D43E7159BA5A09D34CE78B4C939DF11453FDD395155354331CCD19E4F01564C + 022BAA996D766DB947453F2827B1FAD67EA76F630D9CF3A08418A2665F9BAF1D + 3EB42A6C8F647946A66EB5CD71E348894B50030DC09CE79FAF35278B34E8B579 + 2DE38D1E092150AC7A8E7DAB7FE1B5B40344BABE96249269A739666E8063B7D4 + 9ABB2C7135D92B1850ED918AEE8C6DE88231BB3CF353F074B6565892F16472BE + 67968A46E5CFFF005A8AF46BD459E5DAE21DAA9B5776413ED9A2A79E5729B69E + 8713E186FF00489906705437F9FCEBA20873900D416B043090D146AB918240E4 + D68E06D04364F7A5A9E3BD752103201191F5F5A9109E3279A02FCDD6A545F607 + 3DC8E954090E52E471FCEA6456C0F9B27D2A38D0E739EB52AAB0FE94AE5F292A + 67A60935BBA1A2A40D394C391C63A81FFD7AC6B404CCAAD9C138AD8B3BA8ECA4 + 9D653B82283B3BE00C01FE7B9A994EC7461E9734AECE6BC57A75CDC169E4F914 + F6EB81FE26B84921B9B6BBC0C804D7A9EA7A8F9F7204AA8222B9E3D7DBD85735 + 7D66D737AAB142AC33D477150E47A94E262DBEA779A55DDB488E4C12CAA5C380 + 70738C8CD43ADC0B339322A891BEF6E1C8AE8FC51E1D962F0D3DD344E9F38232 + A719AC24BFB89ECED99E24951465CEDCB003AD10926CE8E5B9B1F0FBC317DA85 + ADF3C0A66091EE41F37240248183E82B9F9F48D6A3B9F32790AC6CD9DD95618F + A1AF53F03F8C23F0CB444586F55E7318182318EF5C56A37B6DA878A64956DDA0 + 124A59608DB708F9C8145D5EE5722B17F5AB2D4E6F878F2DEC4585990CB28182 + 037CA377A020FAF1F8F1C1595B5D5D4812142ABBB963C0C7D6BDA3C6535E5B78 + 4ACD2DE078B4DBBF96E59C02AEE082AAC7B1E38AE1CA3038D898F4E98A74A375 + 738B175FD9BE548E93E13EABA2782AE9AEAEF4E5BEB971813ABE1A21E8A0F1F8 + F5AF65D3BE2AF846E11733CD0CAC71B264C01F8F4AF9D4C71F523F5A0ECCF218 + 7E35D7176D0F3BDB49BBB3E9B6D4F41D61166486C27EFBD1867F4AC6BDF0DE94 + C0CD6D2CB13375E372FE58AF03B5BB7B4915E09E68987428E4735D5693F10F5E + B3D9E74F1DD45FDC997391F518AB5C8F7435599D86B3A15D24656DCC33467B1C + AFE86B81F11E91791DABACB6AEA1815F9549033DF35EA7F0FBC61A4F8A24B9B4 + 9EDEDEC2F6040E37B7CB203DC13FD6BA2D6AD8DB69EF7305A473BF965D78183E + FD7A552A307B1AFB595AE7CE9F0BF42F104F35CD8269EAF6F10693CC97853D38 + 5F56EF8F6AB5A8595EC2D3016D3895094DBB7057D6BE83D0E0FB4686B2A59C31 + 1DDBE711E386F51597AD6871EA57F25CB49345238002900AF0302B49D25CB65B + 8E9D5777747CF4D67A9EF60095C8FE31C8A2BD7B51F0BDEC19D924336063AE0F + EB4564A93EC6DCE8F1B8CEDC0E0D384E338E49AF57D13E10DA184C97FA85C48C + 1B185411AFE679ABCBA2783BC3727EFB4FB6BA994700932E0F3D49E3D3A578D5 + 332C3C34E6D4CE9E575A7AD8F2FD274AD5B530A74FD2EF2E5738DF1C44AE7EBD + 2BA483E1FF008BDA5549F4AFB386C61A695547F3AEC742F8D3E1AD1DAE6CB56D + 3E4B548199614822055C751C7638A6DC7ED07A65EEA569A6E97A1C862B999226 + 96770BE5866DB90A33D01CD72CB30AD2D634F4FEBA9BAC0528B4A52D4834EF84 + FA910A6FAE9533C958632E40FA9C0AEB744F861E18B7883EA0D7371203F76490 + 28FC97FC6BA48EEA49402F231F6CD39A7545CB3051EA4D7835B3FAD2D22AC7B9 + 4B27A30DC934FD1BC31A601F62D22D558746F2813F99E6BC53E3A4D6969E217B + FB2C46F2C6BE66D3D597207F4FCABB7F1878DB4FB146B582F23331E18A1DC57D + B8EF5E31F10356B7D56D234058481CAA96FE227B57565B53175AAA9CD3B7A0B1 + 30C3528F245AB9D2F8223B2BED0E092E624959941C919E6BA3D3ED34E8AF95A2 + B684B8E85945727E0BD969E0F8A63148DE5A959028E548E39AB1A06A936A5A88 + 4B3B69400E1773640CFE35F40D36B43892499D77C47D3AE354F0B456F671177F + 9A470178C01DFF000FE95F3B680DE4EBF369EF90CB230507F5AFA7B46D1FC53F + F0971B3D4FCA4D382F18E4B7EBDEBE59F8911C9A27C4CD6A3B57DA6DB5097CBF + 65DC481F91155878BBB4CA9BB59A3D1F49B012BC7662DAF82BF04444631F9715 + A33F8505BF8BAD21D36DC470CA32DB9B710C7EF331FD6B81D17E2A4D63224B26 + 9D99178F95F835575EF891AD6A9E7F927EC4B3FCAE50FCFB7FBA0F61F4AD9C24 + DD909D48D8F40F8CDE3FB582CFFE10EF0DCC925AC6A12F2E3821D81C951F88E4 + FE15C1695AB2DD42A3E5F371F2E78DE3D6B8991DA793CB53F2FF001B7F4A23BD + 297D198988553B57E95D54A9A82B1C35D7B67A9DE9BA98920C2722869A4206D8 + CFE754ECAED6ED152462B263A8EF5335B5CF244A715A3858F3270E57A8F124C4 + 7DD53F534D6927191B52A2782E94FF00AD19A6341764FF00AEC134D585645CB1 + BFBCB1BE8EEA0645910FD430EE0FA8AF60F0AFC45D2858137777E46D87CA36D3 + B651493D41F4EBC5787BD94A7EFDC1FC2A27D3378C35D4BCD3D774690925A33D + FBC4DE26BCB0F06DD6A1A65C9837DC2ADA9539DC99C8CFFE3DFA571FA6FC57F1 + 042BB6F62B6BB53D7828DFA570B25EDFC9A74565717B2CF0C472A1CF4AAADB71 + C753D6B48CA5D424D5F43D667F88B04CC9FBC58A5750DB71B80F6268AF23672A + 78F5A2B68CDA4099F4AF897576B68FC9898F9A579627A0AF3BD52ECB31677FC4 + 9AE7F5AF18EABAA4A65668E0046311AF6FA9AC296E1A662D2C8ECC7D4E6BE0B0 + B9055DE6D2FC4FA0AF9CD25F026FF0313C712A1D66631B060C55B8FF007706A7 + BFF1635E685A2696BA75A5B9D29999278A301E4276E4B1EA7EE83CF7ACDF1529 + 370AE07541FA1AC74CD7D1D2C37B3A7ECF73C7A95BDA4B9F63DF6EBE25EB9709 + 8B6305B29FEE2E4FE66B06FF005ED5F5027ED7A8CF303D99CE3F2E95CED8AEEB + 385F39DD1A9FD2AE4319623E524E6B2A597E1E8BF72089A98DAF53E293256936 + 82CCD803935CAF8875390C90C91E06C62507F5FAD5BF136A6D6EC96898C1197C + 7F2AB9F0F343B4D66F9F56D6264834BB020BEF04F9D21E88A072DD3381ED5E94 + 29A8C6EF70A517F133B2F847AADCAE9F2C37B6D208DE313A65490C992B93F523 + BF5C1AE9BFB7ADE1D4336B0A42A83230870CD9E3A03567C3BA8C335F46C9672C + 488BE4F9536DDCD18E870381F4ADABDF0E5BBCA64B4448D5CFCCA47CBF976AC3 + 114395F34754CEDC26239AF0A8AD25D09AEF51D5B54D434BD62D0CB02B010DC9 + 242AB639C819CF4CF2476AF22F13E9FA06ADADCB3EB3A35F896E2E26679A2952 + 321C1E7B12CB907823A743EBEA97FB34BF267BA794D9DAA37EEE08F9919BAED1 + DCE38CFD6B84BDBAD4751D4B6D8E9D059EE7253F75E7DC863C925BA02727E959 + 7B0F671527BBFCBF32D621D6A9251F81697BDB5FEBA1C27C52F8612785EC2D35 + AB19646D36EFE40B3303247201F30E3195F46C0F43EFE6E6272DB7A0F5AFB3AD + 2D6DD74792F3C43E66AB35E21B7586E31BEE40E044074541D59BD727AD786FC7 + 4F86727856D21F12E9D1C71585E5C323DBC6C4A40C725550B7CCCB80464F71EF + 5A539A7A03565BFF005E5DCF24B871140238F827AFD2A9AB95704019CD49312C + DB8E6AB927CC503A9200AE9488B1D55A4C639D4671902BA5B0BB336222C38191 + 9EF5C733E0EFCF03083FAD6A69F7412412FDE09BB8270395EBF81E6B4DD58E6A + B0E6474AC4E7E61DE91CA8E7033ED4CB5952E6149A339461914AEDB4F1C56691 + C16B0D727A0C5577508D923DE89A465CE1370F5CD35D811D73FA55A1A423B824 + F1D2A22C09E7AF7A490E3B64544EF9CF1548A48467C6475A2A3192C013B47A9E + 9455AB976351588C64558B485EE2748A304BB9C00055089B1D4F38E95D278782 + C5652DEC9C393E5C5CF6EE7FA514287B5928A39A72E55734E2D374DB389435BC + 37138E1A4750DF80CF41524F25B2C584B5B5F420C4BCFE9591717ADE708F7723 + 19E7D6A49E554EA4F4AF7E308538D923952727A914CD6C461112123A05185FCB + B559B5D2359BCB46974D52ACBC2C9BF6E3E87D6B5FC05E0FB9F11DF2DD5CA347 + 64ADC03D64FF00EB57B7D8781ED9ACD52394C785C280A36E3E82BC0C754A4A7E + EAD7F03D5C361A4D5D9F206B7A0EAD60EF25DD8CA067264FBC0FBE6BD7BC13A0 + 47A6F866C23D46708FB7CC8E18230F34923E090B8EBC6D0589C2EDAECFC79E19 + 7D09E36908961990E4E38CFA7F2AE2AD2DE7D26D2DEF93534B0452D2C51CB3AA + 2618F641F31C802B8A5539D58F4943975BD859359D48CEA9A7E9963A784F936C + D199A7246796208C1C1E83D057556FAB6B17B67141F6590B940ACC91B286C77E + 7FC6B91D7B58BFD7241A8694534DB372774365F28041CE5A4700E4E3DAACE91A + 75E6A8079BABDC4F1487059B52250B7718079EF4A355D356BA5F8FE7FE663570 + F4E5AB497FE05FA69F81D078935582DA4FECF9ECEE350BA4841710CCAB1A31FE + 1673DFD42E6B91BCBAD5EF27863574B1B5F3189B7B17F2C7033F34A7963815D6 + 5D68D7363AD3B4BA5D9CD62634862BA595A4469446BF285E3A7EB5CD78E2C6E2 + 5749B54BA63A6473652268824484AB00000325BB67DEB1E6BCB5EBD5EBF76AFF + 0047E66D4D422F963D3FADACADF89ADE11BDF13EB97915E79564ECEA89040ECD + 2048872AA154741DFE6193926B9BF8F5E3DD463B6BDD025B292EAE6466B5B9BE + BA8D4247B48DD1C118E179039EBD0FA1AF5BF8272241A1695F28566B6407D41C + 735E03FB55D89B1F8C1A9B0C88EEE38AE547604C6149FC4A1AB86B3B5ADE874C + AC95D2FEBF43C9247DC38E0F715024804C1B1CAF34E9FE5391D6A183E690BB74 + CE2BB1230B1B8E76E9D1E4F232EC6A5D3A4F3A1039C17C0F7C0C9ACBBCB83E48 + 8BA93DAB46C1BC836EBD76A9661F5AA462E3A1BDE10BB0FA384627744E54E3EB + 5AC5F2393C561FC3DD3351D4F57D4ED34CB669CC48D2945EB80C0703BF5AD894 + 4B14CD1CB1B46EA70C8CB820FA1159F346F6BEA7256A4D4AF6D1892ED0383CE2 + A26EE72682C0E40C546DB867241CF3D6ACC6C23AB1C8CD44E4827A9A7070382A + 703BD465CE76838E791E9548AB114AEDBBBD14C9587396068AB2AC5F57C9C1E6 + B6A39D96CA28178D899FC4F35CEDABB34A898CE4815AB0399A66F4EDCD7A197D + 3D5C8E3ACBA132485B5A82227899037D08CFFF005ABABF0AE8975E26D58B790E + 2D607DA40CFEF0FF009EB5A5F0FBE1CDD7882E20BFBB2F05BC41B6E061A40C39 + FA0AF6C68B42F03E81F6B9A3448E11B638D71973D87D6B3C6636DFBB86E74E1B + 0D7F7E44DE1BD1EDF48B28E4BA78A050BFC4DB547B55EB9F1769B677F2D9C72C + 212DEDCDC5C4EC7E448C67278FA1FC6BCF9FC4373ADDF0BBBC551DA38C0CAC43 + D07BFBD3B5CB0B792D2ED587909771086774F41CA93EA01FCEB91E5929C6EDEA + 6EB3084656B68757E26BDD37C57A088A6BD82D6D6EB9B399971237192C173D31 + 5C569DF0EAEAC9A5617115DC6CB9C24011CAFD49249C7BD56B2D2AE24F1469F7 + 77D016B7D36C0436EEB27CBE61E738EE324F06BAD97C4D36830CF797F0BDC44D + FF002D214276FA02BDBF957055C257A4B45A1E852C6516ED17A9E19AED93DB78 + 9645496F63B08E4476F257746AD8E18AF3CF38CE2BB4D1B4196E2EE0BAD35AC2 + E218E36DA8A8119D9863767382707DB35CB5B6B57F73ADEA3ADDB42EF05D4C5A + 4B603E78C678C0EFC7A5757A15CDA4CC973A45CF9126E1E6C247CAC7FDDEAAD5 + 4A2D5BC8AA894A3AECCDCF0E6B86DEFA6D1F5651E4CCC1648DC15789C281903A + A9C0E08FC3AD70DF11BC37FF0008AEA91CF733497B6D2CAAD6B2BDCB192553D4 + 7CD9008079F6E7BD7B0DA4567AB5828D534FB6BBB884F1E6282E07B679AE67E2 + EDA4373E0B5B7B5043C12EF83CC1BF66074E7B52A93E69DD697DC9C3D274A1C9 + 7BDBF222F851A80934EB4DA891EC62A551B2170DD327DB15E5DFB60A4A7E245B + 5C3AFEEA4D36311B7AE19F3FCEBB1F85F7974FA716B92FE679C70EC81370E3A0 + 1C7B7E1585FB60461FFE119BA1F7CC53AE7D71B38FD6B28E9511BF2FBACF9DE7 + 3C1CD410B703EB524E7838FC455553851F9D7A114649172DFF007D7433C81C9F + A56C42E0C8CC7D2B1AD76C7186624166EBE95A5E608A3DDB890470693467247A + CFECBEB1B78F35766751FE8A42E4E0F2EBD3F2AF70F17F82B45F11C44DD4221B + 9030B731001B3EFEA3EB5F2C7C1FD424B7F16CC52428D2C6D820F7041FE95F48 + 7877C5F226D87503B97FBFDEBE5732A93A58BE68BB688F4E8528CE8D9AB9E59E + 31F026AFE1C6695A3FB5D97559E21903FDE1DAB8D949248C0F402BEB486E2D75 + 0818A0578D8639E73F8579EF8DBE18586A3BEEF47DB6774724A63F76E7E9FC3F + 8715D785CD6FEED5FBCE0AF9735AD3FB8F0594E0600A8DDF68E1BFFAF5AFE23D + 0F53D16ECDBEA36B240FD149E55FE87B8AC575C2E4FF00FAABDD849495D1E6BA + 6D3B320773CE68A64806320E28AD07645BD127F3EEBA005509E8076C7F5AEC7E + 1B58C5A97896286700C4B99197FBD8EDF9E28A2BD4A2F970CDA38A493A963E96 + F094E2DA211AA0C1E062BCCBE3C5F5EFFC26BA5584B20366D179C8AA4E490483 + 9FC40FCA8A2BCAA293AE8F466DFB3658F0EA19619501E550904D5AD1F577BDF3 + 2D6752CD10DA49E847F8D1457BD4FA9E0C8D0D32E58235ABB31087683EC7A569 + 584F23808C41218A9E3834514DABA649C8F8FBC2691DA3EBBA14A9633407CC9A + 139F2DD73CE31D0E79C74FA561D86A8D3DC08AF208FED0AB8F363EE3F4A28AF2 + 31308C5E88F6F05525387BCF63A5D335494DDC7102ECC063731EA2B5359BB37B + 6A90CAB91CF5A28AF325B9E8A6CC3F0DC11DA5DCF0C4311EF0C07A67AD627ED5 + 76135E68FA0CE8E8AB6E25CE49CFCDB318FCA8A2A3FE5EA358FC2CF9B2788E48 + 2467A6455508378CF38A28AEE44A2D25BAC8990C47B1A6798C10C192429C8CF6 + A28AA666B5353C0170D078B6D1867E69369FC4115EEF6F21DB4515F299DA5ED9 + 7A1EB60DFBACD8D3355BAD3E4578A46C0ED9E2BBBD0F5B1A820DD1156C738A28 + AF2A06D31FAF695A7EAD66D6B7D6D1CF1B0E8EB9C7B8F435E13F127C069A0C2F + 7F63741AD7760C726772FD0F71F5A28AF5B2DAB38D4514F4670E321171BDB53C + DA66209F4EF451457D427A1E3D8FFFD9} + Visible = False + end + object Memo4: TMemo + Left = 8 + Top = 8 + Width = 161 + Height = 369 + Anchors = [akLeft, akTop, akBottom] + Lines.Strings = ( + 'To the right is a list of authors ' + 'and contributors to ' + 'TurboPower LockBox 3.' + 'Not included are the authors ' + 'of LockBox 1 & 2, as there is ' + 'no common' + 'copyrightable content ' + 'between them and LockBox 3.' + '' + 'The LockBox 3 project ' + 'welcomes any contributions. If ' + 'you wish to contribute,' + 'and your contributions are ' + 'accepted, your details can, if ' + 'you request, be' + 'added to this list of authors.') + TabOrder = 0 + end + object lbxAuthors: TListBox + Left = 175 + Top = 8 + Width = 138 + Height = 121 + ItemHeight = 13 + Items.Strings = ( + 'Sean B. Durkin' + 'David Barton') + TabOrder = 1 + OnClick = lbxAuthorsClick + end + end + object tsSupport: TTabSheet + Caption = 'Support' + ImageIndex = 5 + object memoSupport: TMemo + Left = 3 + Top = 24 + Width = 286 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'Support can be obtained through the ' + 'forums at:' + 'http://lockbox.seanbdurkin.id.au/tiki-f' + 'orums.php') + ParentFont = False + ReadOnly = True + TabOrder = 0 + end + object memoHelp: TMemo + Left = 295 + Top = 24 + Width = 333 + Height = 161 + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + 'User help for this component suite' + 'can be found at' + 'http://lockbox.seanbdurkin.id.au/LB3Help_H' + 'ome .' + 'If the help is still partially' + 'under construction, please either be' + 'patient, or offer your own content.') + ParentFont = False + ReadOnly = True + TabOrder = 1 + end + end + object tsAlgorithms: TTabSheet + Caption = 'Algorithms' + ImageIndex = 6 + object Panel1: TPanel + Left = 3 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 0 + object Label13: TLabel + Left = 16 + Top = 0 + Width = 116 + Height = 13 + Caption = 'About selected Hash' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblHashDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label15: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblHashDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashWikipediaURL: TLabel + Left = 16 + Top = 136 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblHashBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lblHashDigestSize: TLabel + Left = 16 + Top = 184 + Width = 97 + Height = 13 + Caption = 'Digest size = 64 bits' + end + object lbxHashFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + object pnlCipherDescription: TPanel + Left = 299 + Top = 16 + Width = 270 + Height = 209 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 1 + object Label20: TLabel + Left = 16 + Top = 0 + Width = 124 + Height = 13 + Caption = 'About selected Cipher' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblCipherDisplayName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label22: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblCipherDefinitionURL: TLabel + Left = 16 + Top = 112 + Width = 59 + Height = 13 + Cursor = crHandPoint + Caption = 'definition url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherWikipediaURL: TLabel + Left = 16 + Top = 141 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lblCipherBlockSize: TLabel + Left = 16 + Top = 160 + Width = 97 + Height = 13 + Caption = 'Block size = 128 bits' + end + object lbxCipherFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + object memoExtraCipherDescription: TMemo + Left = 16 + Top = 192 + Width = 233 + Height = 89 + Lines.Strings = ( + 'Extra Cipher Description') + ParentColor = True + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 1 + Visible = False + end + end + object Panel3: TPanel + Left = 3 + Top = 231 + Width = 270 + Height = 146 + Color = clYellow + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentBackground = False + ParentFont = False + TabOrder = 2 + object Label27: TLabel + Left = 16 + Top = 0 + Width = 170 + Height = 13 + Caption = 'About selected Chaining Mode' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlue + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsBold] + ParentFont = False + end + object lblChainName: TLabel + Left = 24 + Top = 24 + Width = 61 + Height = 13 + Caption = 'DisplayName' + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object Label29: TLabel + Left = 14 + Top = 43 + Width = 47 + Height = 13 + Caption = 'Features:' + end + object lblChainWikipedia: TLabel + Left = 16 + Top = 120 + Width = 58 + Height = 13 + Cursor = crHandPoint + Caption = 'wikipedia url' + Font.Charset = DEFAULT_CHARSET + Font.Color = clNone + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [fsUnderline] + ParentFont = False + OnClick = OnURL_Click + end + object lbxChainFeatures: TListBox + Left = 67 + Top = 40 + Width = 182 + Height = 65 + ItemHeight = 13 + TabOrder = 0 + end + end + end + end + end + object btnClose: TButton + Left = 280 + Top = 416 + Width = 75 + Height = 25 + Anchors = [akLeft, akBottom] + Caption = 'Close' + ModalResult = 1 + TabOrder = 1 + end +end diff --git a/design/forms/d7-/uTPLb_ComponentAbout.pas b/LockBox3/design/forms/d7-/uTPLb_ComponentAbout.pas similarity index 96% rename from design/forms/d7-/uTPLb_ComponentAbout.pas rename to LockBox3/design/forms/d7-/uTPLb_ComponentAbout.pas index 0062ce7..f23dcc5 100644 --- a/design/forms/d7-/uTPLb_ComponentAbout.pas +++ b/LockBox3/design/forms/d7-/uTPLb_ComponentAbout.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,523 +12,523 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -unit uTPLb_ComponentAbout; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; - -const - WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; - -type - TTPLb_fmComponentAbout = class(TForm) - pnlAbout: TPanel; - btnClose: TButton; - pgAboutContent: TPageControl; - tsMain: TTabSheet; - tsWelcome: TTabSheet; - tsProject: TTabSheet; - tsCopyLeft: TTabSheet; - tsAuthors: TTabSheet; - tsSupport: TTabSheet; - tsAlgorithms: TTabSheet; - Image1: TImage; - lblTitle: TLabel; - Label1: TLabel; - lblRunTimeVersion: TLabel; - lblDesignTimeVersion: TLabel; - Memo1: TMemo; - browserIntro: TWebBrowser; - Label4: TLabel; - Memo2: TMemo; - lblWebsite: TLabel; - Label7: TLabel; - Label8: TLabel; - Memo3: TMemo; - Label9: TLabel; - Memo4: TMemo; - lbxAuthors: TListBox; - imgAuthorPic: TImage; - Bevel1: TBevel; - lblAuthorEmail: TLabel; - lblAuthorWeb: TLabel; - Label12: TLabel; - memoSupport: TMemo; - memoHelp: TMemo; - Panel1: TPanel; - Label13: TLabel; - lblHashDisplayName: TLabel; - Label15: TLabel; - lbxHashFeatures: TListBox; - lblHashDefinitionURL: TLabel; - lblHashWikipediaURL: TLabel; - lblHashBlockSize: TLabel; - lblHashDigestSize: TLabel; - pnlCipherDescription: TPanel; - Label20: TLabel; - lblCipherDisplayName: TLabel; - Label22: TLabel; - lblCipherDefinitionURL: TLabel; - lblCipherWikipediaURL: TLabel; - lblCipherBlockSize: TLabel; - lbxCipherFeatures: TListBox; - Panel3: TPanel; - Label27: TLabel; - lblChainName: TLabel; - Label29: TLabel; - lblChainWikipedia: TLabel; - lbxChainFeatures: TListBox; - lblLogoAttribution: TLabel; - lblTpsfaIntro: TStaticText; - lblTpsfaContact: TStaticText; - lblWebLabel: TStaticText; - imgSean: TImage; - memoExtraCipherDescription: TMemo; - memoWelcomeInstructions: TMemo; - procedure lblTpsfaContactClick(Sender: TObject); - procedure OnURL_Click(Sender: TObject); - procedure lbxAuthorsClick(Sender: TObject); - procedure FormCreate(Sender: TObject); - private - { Private declarations } - - public - procedure UpdateAbout( SelectedComponent: TComponent); - end; - -var - TPLb_fmComponentAbout: TTPLb_fmComponentAbout; - -implementation - - - - - - - - - - - - - -uses uTPLb_InfoUtils, uTPLb_Hash, uTPLb_HashDsc, ShellAPI, uTPLb_StreamCipher, - uTPLb_Signatory, uTPLb_Codec, TypInfo, uTPLb_BlockCipher, Registry, - uTPLb_I18n, uTPLb_Decorators -{$IF CompilerVersion >= 21} - , Rtti -{$IFEND} - ; -{$R *.dfm} -{ -Content Plan -============ -Page 1: Main -0. Big Title: TurboPower LockBox 3 -2. Product definition statement. -3. Logo or nice graphic for LockBox 3 -7. run-time PE version number -8. design-time PE version -4. Brief statement about FOSS: LGPL - -Page 2: Welcome message -1. Embedded video by me introducing the component suite. - -Page 3: Brought to you by ... -Statement about project organisation and control (tpfsa) -5. tpfsa email -6. sourceforge url - -Page 4: CopyLeft -12. Copyright (mark and statement of application) -10. Statement of copying permission -9. LGPL 3 logo as clickable link -11. LGPL and GPL full wording - -Page 5: Authors -13. About authors. List - - 13.1 Name - 13.2 Photo - 13.3 Email -14 Statement welcoming contributions and adding to the list of authors. - -Page 6: Support -15 Statement about official support. -16 Statement about wiki documentation. - -Page 7: Algorithms -17 About Selected Hash - - 17.1 DisplayName - 17.2 Feature list - 17.3 Definition URL - 17.4 Wikipedia URL - 17.5 Block size - 17.6 Digest size -18 About Selected Chaining Mode - - DisplayName - Feature list - Definition URL - Wikipedia URL -19 About Selected Block Cipher - - DisplayName - Feature list - Definition URL - Wikipedia URL - Block size - -} -{ TTPLb_fmComponentAbout } - -procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); -var - Idx: integer; - Author, sAuthorEmail, sAuthorWeb: string; -begin -Idx := lbxAuthors.ItemIndex; -if Idx <> -1 then - Author := lbxAuthors.Items[ Idx] - else - Author := ''; -if SameText( Author, 'Sean B. Durkin') then - Idx := 0 - else if SameText( Author, 'David Barton') then - Idx := 1 - else if SameText( Author, 'Another contributor') then - Idx := -1 - else - Idx := -1; -case Idx of - -1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := ''; - sAuthorWeb := '' - end; - 0: begin - imgAuthorPic.Picture := imgSean.Picture; - sAuthorEmail := 'sean@seanbdurkin.id.au'; - sAuthorWeb := 'http:\\www.seanbdurkin.id.au' - end; - 1: begin - imgAuthorPic.Picture := nil; - sAuthorEmail := 'crypto@cityinthesky.co.uk'; - sAuthorWeb := '' - end; - end; -if sAuthorEmail <> '' then - lblAuthorEmail.Caption := DS_Email + sAuthorEmail - else - lblAuthorEmail.Caption := ''; -if sAuthorWeb <> '' then - lblAuthorWeb.Caption := DS_Web + sAuthorWeb - else - lblAuthorWeb.Caption := ''; -end; - -procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); -var - s: string; -begin -if (Sender is TLabel) then - begin - s := TLabel( Sender).Caption; - ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) - end -end; - - - -procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); -begin -lblAuthorEmail.Caption := ''; -lblAuthorWeb.Caption := ''; -browserIntro.Navigate( WelcomeVideo_URL) -end; - -procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); -begin -// -end; - -procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); -var - LibName: string; - FileVersion: string; - HashComp: THash; - HashDsc: IHashDsc; - s: string; - CodecComp: TCodec; - Chain: IBlockChainingModel; - StreamCipher: IStreamCipher; - BlockCipher: IBlockCipher; - ErrorPos: integer; - Reg: TRegistry; - isDebug: boolean; - Features1: TAlgorithmicFeatureSet; - ExtraCipherDescription: string; - -{$IF compilerversion >= 21} - ControlObject: IControlObject; - Controller: TObject; - LContext: TRttiContext; - LType: TRttiType; - Attr: TCustomAttribute; - DesignDesc: DesignDescription; -{$IFEND} - - procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); - var - Feat: TAlgorithmicFeature; - begin -{$IF compilerversion >= 16} - // Delphi 2005 or above - for Feat in Features do - begin - -{$ELSE} - // Delphi 7 or below - for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do - begin - if not (Feat in Features) then continue; -{$IFEND} - - s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); - Lbx.Items.Add( s) - end - end; - - function WikipediaRelativeURL( const Relative: string): string; - begin - result := Relative; - if (Pos( 'http:' , lowercase( result)) <> 1) and - (Pos( 'https:', lowercase( result)) <> 1) and - (result <> '') then - result := 'http://en.wikipedia.org/wiki/' + result - end; - - procedure Debug( const Line: string); - begin - if isDebug and (Line <> '') then - lbxHashFeatures.Items.Add( Line) - end; - - procedure DebugFmt( const Fmt: string; const Args: array of const); - begin - Debug( Format( Fmt, Args)) - end; - -begin -lbxHashFeatures.Clear; -Reg := TRegistry.Create; -try - Reg.RootKey := HKEY_CURRENT_USER; - isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and - Reg.ReadBool( 'Debug') -finally -Reg.Free -end; -ErrorPos := 0; -try -Get_TP_LockBox3_Info( LibName, FileVersion); -lblRunTimeVersion.Caption := Format( DS_RunTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); -Get_dclTP_LockBox3_Info( LibName, FileVersion); -lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, - [LibName, FileVersion]); -Inc( ErrorPos); - -if SelectedComponent is THash then - HashComp := THash( SelectedComponent) - else - HashComp := nil; - -Inc( ErrorPos); -if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and - (HashComp.HashId <> '') then - HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) - else - HashDsc := nil; - -Inc( ErrorPos); -CodecComp := nil; -if SelectedComponent is TCodec then - CodecComp := TCodec( SelectedComponent); - -Inc( ErrorPos); -if (SelectedComponent is TSignatory) and - assigned( TSignatory( SelectedComponent).Codec) and - TSignatory( SelectedComponent).Codec.isAsymetric then - CodecComp := TSignatory( SelectedComponent).Codec; -Inc( ErrorPos); - -if assigned( HashComp) then - begin - lblHashDisplayName.Caption := HashComp.Hash; - PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) - end - else - lblHashDisplayName.Caption := DS_HashNotSelected; - -Inc( ErrorPos); -if assigned( HashDsc) then - begin - lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; - lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); - lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); - lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); - end - else - begin - lblHashDefinitionURL.Caption := ''; - lblHashWikipediaURL.Caption := ''; - lblHashBlockSize.Caption := ''; - lblHashDigestSize.Caption := ''; - end; - - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.ChainModeId <> '') then - Chain := CodecComp.CryptoLibrary - .BlockChainingModelIntfc( CodecComp.ChainModeId) - else - Chain := nil; - - -Inc( ErrorPos); -lbxChainFeatures.Items.Clear; -if assigned( Chain) then - begin - lblChainName.Caption := Chain.DisplayName; - PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); - lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) - end - else - begin - lblChainName.Caption := DS_ChainModeNotSelected; - lblChainWikipedia.Caption := '' - end; - - -Inc( ErrorPos); -if assigned( CodecComp) then - lblCipherDisplayName.Caption := CodecComp.Cipher - else - lblCipherDisplayName.Caption := DS_CodecNotSelected; - -Inc( ErrorPos); -if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and - (CodecComp.StreamCipherId <> '') then - StreamCipher := CodecComp.CryptoLibrary - .StreamCipherIntfc( CodecComp.StreamCipherId) - else - StreamCipher := nil; - -Inc( ErrorPos); -if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and - (CodecComp.BlockCipherId <> '') then - begin - BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); - if assigned( BlockCipher) then - StreamCipher := nil - end - else - BlockCipher := nil; - -ExtraCipherDescription := ''; -memoExtraCipherDescription.Visible := False; -pnlCipherDescription.Height := 209; - -{$IF compilerversion >= 21} -if not Supports( BlockCipher, IControlObject, ControlObject) then - Supports( StreamCipher, IControlObject, ControlObject); -if assigned( ControlObject) then - Controller := ControlObject.ControlObject - else - Controller := nil; -DesignDesc := nil; -if assigned( Controller) then - begin - LContext := TRttiContext.Create; - try - LType := LContext.GetType( Controller.ClassType); - for Attr in LType.GetAttributes do - begin - if not (Attr is DesignDescription) then continue; - DesignDesc := DesignDescription( Attr); - break - end; - if assigned( DesignDesc) then - ExtraCipherDescription := DesignDesc.Description - finally - LContext.Free - end - end; -{$IFEND} - -if ExtraCipherDescription <> '' then - begin - memoExtraCipherDescription.Height := 100; - pnlCipherDescription.Height := pnlCipherDescription.Height + - memoExtraCipherDescription.Height; - memoExtraCipherDescription.Visible := True; - memoExtraCipherDescription.Lines.Text := ExtraCipherDescription - end; - -Inc( ErrorPos); -lbxCipherFeatures.Items.Clear; -if assigned( StreamCipher) then - begin - ErrorPos := 20; - PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); - lblCipherBlockSize.Caption := '' - end - else if assigned( BlockCipher) then - begin - ErrorPos := 30; - Features1 := BlockCipher.Features; - Include( Features1, afBlockAdapter); - PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); - lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; - lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); - lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) - end - else - begin - ErrorPos := 40; - lblCipherDefinitionURL.Caption := ''; - lblCipherWikipediaURL.Caption := ''; - lblCipherBlockSize.Caption := '' - end -except on E: Exception do - begin - DebugFmt( 'ERROR! (%d)', [ErrorPos]); - DebugFmt( 'Class = %s', [E.ClassName]); - DebugFmt( 'Error = %s', [E.Message]) - end; -end -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +unit uTPLb_ComponentAbout; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, OleCtrls, SHDocVw, ComCtrls, jpeg; + +const + WelcomeVideo_URL = 'http://lockbox.seanbdurkin.id.au/online_resources/Intro3_Embedded.html'; + +type + TTPLb_fmComponentAbout = class(TForm) + pnlAbout: TPanel; + btnClose: TButton; + pgAboutContent: TPageControl; + tsMain: TTabSheet; + tsWelcome: TTabSheet; + tsProject: TTabSheet; + tsCopyLeft: TTabSheet; + tsAuthors: TTabSheet; + tsSupport: TTabSheet; + tsAlgorithms: TTabSheet; + Image1: TImage; + lblTitle: TLabel; + Label1: TLabel; + lblRunTimeVersion: TLabel; + lblDesignTimeVersion: TLabel; + Memo1: TMemo; + browserIntro: TWebBrowser; + Label4: TLabel; + Memo2: TMemo; + lblWebsite: TLabel; + Label7: TLabel; + Label8: TLabel; + Memo3: TMemo; + Label9: TLabel; + Memo4: TMemo; + lbxAuthors: TListBox; + imgAuthorPic: TImage; + Bevel1: TBevel; + lblAuthorEmail: TLabel; + lblAuthorWeb: TLabel; + Label12: TLabel; + memoSupport: TMemo; + memoHelp: TMemo; + Panel1: TPanel; + Label13: TLabel; + lblHashDisplayName: TLabel; + Label15: TLabel; + lbxHashFeatures: TListBox; + lblHashDefinitionURL: TLabel; + lblHashWikipediaURL: TLabel; + lblHashBlockSize: TLabel; + lblHashDigestSize: TLabel; + pnlCipherDescription: TPanel; + Label20: TLabel; + lblCipherDisplayName: TLabel; + Label22: TLabel; + lblCipherDefinitionURL: TLabel; + lblCipherWikipediaURL: TLabel; + lblCipherBlockSize: TLabel; + lbxCipherFeatures: TListBox; + Panel3: TPanel; + Label27: TLabel; + lblChainName: TLabel; + Label29: TLabel; + lblChainWikipedia: TLabel; + lbxChainFeatures: TListBox; + lblLogoAttribution: TLabel; + lblTpsfaIntro: TStaticText; + lblTpsfaContact: TStaticText; + lblWebLabel: TStaticText; + imgSean: TImage; + memoExtraCipherDescription: TMemo; + memoWelcomeInstructions: TMemo; + procedure lblTpsfaContactClick(Sender: TObject); + procedure OnURL_Click(Sender: TObject); + procedure lbxAuthorsClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + private + { Private declarations } + + public + procedure UpdateAbout( SelectedComponent: TComponent); + end; + +var + TPLb_fmComponentAbout: TTPLb_fmComponentAbout; + +implementation + + + + + + + + + + + + + +uses uTPLb_InfoUtils, uTPLb_Hash, uTPLb_HashDsc, ShellAPI, uTPLb_StreamCipher, + uTPLb_Signatory, uTPLb_Codec, TypInfo, uTPLb_BlockCipher, Registry, + uTPLb_I18n, uTPLb_Decorators +{$IF CompilerVersion >= 21} + , Rtti +{$IFEND} + ; +{$R *.dfm} +{ +Content Plan +============ +Page 1: Main +0. Big Title: TurboPower LockBox 3 +2. Product definition statement. +3. Logo or nice graphic for LockBox 3 +7. run-time PE version number +8. design-time PE version +4. Brief statement about FOSS: LGPL + +Page 2: Welcome message +1. Embedded video by me introducing the component suite. + +Page 3: Brought to you by ... +Statement about project organisation and control (tpfsa) +5. tpfsa email +6. sourceforge url + +Page 4: CopyLeft +12. Copyright (mark and statement of application) +10. Statement of copying permission +9. LGPL 3 logo as clickable link +11. LGPL and GPL full wording + +Page 5: Authors +13. About authors. List - + 13.1 Name + 13.2 Photo + 13.3 Email +14 Statement welcoming contributions and adding to the list of authors. + +Page 6: Support +15 Statement about official support. +16 Statement about wiki documentation. + +Page 7: Algorithms +17 About Selected Hash - + 17.1 DisplayName + 17.2 Feature list + 17.3 Definition URL + 17.4 Wikipedia URL + 17.5 Block size + 17.6 Digest size +18 About Selected Chaining Mode - + DisplayName + Feature list + Definition URL + Wikipedia URL +19 About Selected Block Cipher - + DisplayName + Feature list + Definition URL + Wikipedia URL + Block size + +} +{ TTPLb_fmComponentAbout } + +procedure TTPLb_fmComponentAbout.lbxAuthorsClick(Sender: TObject); +var + Idx: integer; + Author, sAuthorEmail, sAuthorWeb: string; +begin +Idx := lbxAuthors.ItemIndex; +if Idx <> -1 then + Author := lbxAuthors.Items[ Idx] + else + Author := ''; +if SameText( Author, 'Sean B. Durkin') then + Idx := 0 + else if SameText( Author, 'David Barton') then + Idx := 1 + else if SameText( Author, 'Another contributor') then + Idx := -1 + else + Idx := -1; +case Idx of + -1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := ''; + sAuthorWeb := '' + end; + 0: begin + imgAuthorPic.Picture := imgSean.Picture; + sAuthorEmail := 'sean@seanbdurkin.id.au'; + sAuthorWeb := 'http:\\www.seanbdurkin.id.au' + end; + 1: begin + imgAuthorPic.Picture := nil; + sAuthorEmail := 'crypto@cityinthesky.co.uk'; + sAuthorWeb := '' + end; + end; +if sAuthorEmail <> '' then + lblAuthorEmail.Caption := DS_Email + sAuthorEmail + else + lblAuthorEmail.Caption := ''; +if sAuthorWeb <> '' then + lblAuthorWeb.Caption := DS_Web + sAuthorWeb + else + lblAuthorWeb.Caption := ''; +end; + +procedure TTPLb_fmComponentAbout.OnURL_Click( Sender: TObject); +var + s: string; +begin +if (Sender is TLabel) then + begin + s := TLabel( Sender).Caption; + ShellExecute( Handle, 'open', PChar( s), nil, nil, SW_SHOWNORMAL) + end +end; + + + +procedure TTPLb_fmComponentAbout.FormCreate(Sender: TObject); +begin +lblAuthorEmail.Caption := ''; +lblAuthorWeb.Caption := ''; +browserIntro.Navigate( WelcomeVideo_URL) +end; + +procedure TTPLb_fmComponentAbout.lblTpsfaContactClick(Sender: TObject); +begin +// +end; + +procedure TTPLb_fmComponentAbout.UpdateAbout( SelectedComponent: TComponent); +var + LibName: string; + FileVersion: string; + HashComp: THash; + HashDsc: IHashDsc; + s: string; + CodecComp: TCodec; + Chain: IBlockChainingModel; + StreamCipher: IStreamCipher; + BlockCipher: IBlockCipher; + ErrorPos: integer; + Reg: TRegistry; + isDebug: boolean; + Features1: TAlgorithmicFeatureSet; + ExtraCipherDescription: string; + +{$IF compilerversion >= 21} + ControlObject: IControlObject; + Controller: TObject; + LContext: TRttiContext; + LType: TRttiType; + Attr: TCustomAttribute; + DesignDesc: DesignDescription; +{$IFEND} + + procedure PopulateListBoxWithFeatures( const Features: TAlgorithmicFeatureSet; Lbx: TListBox); + var + Feat: TAlgorithmicFeature; + begin +{$IF compilerversion >= 16} + // Delphi 2005 or above + for Feat in Features do + begin + +{$ELSE} + // Delphi 7 or below + for Feat := Low( TAlgorithmicFeature) to High( TAlgorithmicFeature) do + begin + if not (Feat in Features) then continue; +{$IFEND} + + s := GetEnumName( TypeInfo( TAlgorithmicFeature), Ord( Feat)); + Lbx.Items.Add( s) + end + end; + + function WikipediaRelativeURL( const Relative: string): string; + begin + result := Relative; + if (Pos( 'http:' , lowercase( result)) <> 1) and + (Pos( 'https:', lowercase( result)) <> 1) and + (result <> '') then + result := 'http://en.wikipedia.org/wiki/' + result + end; + + procedure Debug( const Line: string); + begin + if isDebug and (Line <> '') then + lbxHashFeatures.Items.Add( Line) + end; + + procedure DebugFmt( const Fmt: string; const Args: array of const); + begin + Debug( Format( Fmt, Args)) + end; + +begin +lbxHashFeatures.Clear; +Reg := TRegistry.Create; +try + Reg.RootKey := HKEY_CURRENT_USER; + isDebug := Reg.OpenKeyReadOnly( '\SOFTWARE\TurboPower\LockBox\3') and + Reg.ReadBool( 'Debug') +finally +Reg.Free +end; +ErrorPos := 0; +try +Get_TP_LockBox3_Info( LibName, FileVersion); +lblRunTimeVersion.Caption := Format( DS_RunTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); +Get_dclTP_LockBox3_Info( LibName, FileVersion); +lblDesignTimeVersion.Caption := Format( DS_DesignTimeIs, + [LibName, FileVersion]); +Inc( ErrorPos); + +if SelectedComponent is THash then + HashComp := THash( SelectedComponent) + else + HashComp := nil; + +Inc( ErrorPos); +if assigned( HashComp) and assigned( HashComp.CryptoLibrary) and + (HashComp.HashId <> '') then + HashDsc := HashComp.CryptoLibrary.HashIntfc( HashComp.HashId) + else + HashDsc := nil; + +Inc( ErrorPos); +CodecComp := nil; +if SelectedComponent is TCodec then + CodecComp := TCodec( SelectedComponent); + +Inc( ErrorPos); +if (SelectedComponent is TSignatory) and + assigned( TSignatory( SelectedComponent).Codec) and + TSignatory( SelectedComponent).Codec.isAsymetric then + CodecComp := TSignatory( SelectedComponent).Codec; +Inc( ErrorPos); + +if assigned( HashComp) then + begin + lblHashDisplayName.Caption := HashComp.Hash; + PopulateListBoxWithFeatures( HashComp.Features, lbxHashFeatures) + end + else + lblHashDisplayName.Caption := DS_HashNotSelected; + +Inc( ErrorPos); +if assigned( HashDsc) then + begin + lblHashDefinitionURL.Caption := HashDsc.DefinitionURL; + lblHashWikipediaURL.Caption := WikipediaRelativeURL( HashDsc.WikipediaReference); + lblHashBlockSize.Caption := Format( DS_BlockSizeEqs, [HashDsc.UpdateSize]); + lblHashDigestSize.Caption := Format( DS_DigestSizeEqs, [HashDsc.DigestSize]); + end + else + begin + lblHashDefinitionURL.Caption := ''; + lblHashWikipediaURL.Caption := ''; + lblHashBlockSize.Caption := ''; + lblHashDigestSize.Caption := ''; + end; + + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.ChainModeId <> '') then + Chain := CodecComp.CryptoLibrary + .BlockChainingModelIntfc( CodecComp.ChainModeId) + else + Chain := nil; + + +Inc( ErrorPos); +lbxChainFeatures.Items.Clear; +if assigned( Chain) then + begin + lblChainName.Caption := Chain.DisplayName; + PopulateListBoxWithFeatures( Chain.Features, lbxChainFeatures); + lblChainWikipedia.Caption := WikipediaRelativeURL( Chain.WikipediaReference) + end + else + begin + lblChainName.Caption := DS_ChainModeNotSelected; + lblChainWikipedia.Caption := '' + end; + + +Inc( ErrorPos); +if assigned( CodecComp) then + lblCipherDisplayName.Caption := CodecComp.Cipher + else + lblCipherDisplayName.Caption := DS_CodecNotSelected; + +Inc( ErrorPos); +if assigned( CodecComp) and assigned( CodecComp.CryptoLibrary) and + (CodecComp.StreamCipherId <> '') then + StreamCipher := CodecComp.CryptoLibrary + .StreamCipherIntfc( CodecComp.StreamCipherId) + else + StreamCipher := nil; + +Inc( ErrorPos); +if assigned( StreamCipher) and (afBlockAdapter in StreamCipher.Features) and + (CodecComp.BlockCipherId <> '') then + begin + BlockCipher := CodecComp.CryptoLibrary.BlockCipherIntfc( CodecComp.BlockCipherId); + if assigned( BlockCipher) then + StreamCipher := nil + end + else + BlockCipher := nil; + +ExtraCipherDescription := ''; +memoExtraCipherDescription.Visible := False; +pnlCipherDescription.Height := 209; + +{$IF compilerversion >= 21} +if not Supports( BlockCipher, IControlObject, ControlObject) then + Supports( StreamCipher, IControlObject, ControlObject); +if assigned( ControlObject) then + Controller := ControlObject.ControlObject + else + Controller := nil; +DesignDesc := nil; +if assigned( Controller) then + begin + LContext := TRttiContext.Create; + try + LType := LContext.GetType( Controller.ClassType); + for Attr in LType.GetAttributes do + begin + if not (Attr is DesignDescription) then continue; + DesignDesc := DesignDescription( Attr); + break + end; + if assigned( DesignDesc) then + ExtraCipherDescription := DesignDesc.Description + finally + LContext.Free + end + end; +{$IFEND} + +if ExtraCipherDescription <> '' then + begin + memoExtraCipherDescription.Height := 100; + pnlCipherDescription.Height := pnlCipherDescription.Height + + memoExtraCipherDescription.Height; + memoExtraCipherDescription.Visible := True; + memoExtraCipherDescription.Lines.Text := ExtraCipherDescription + end; + +Inc( ErrorPos); +lbxCipherFeatures.Items.Clear; +if assigned( StreamCipher) then + begin + ErrorPos := 20; + PopulateListBoxWithFeatures( StreamCipher.Features, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := StreamCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( StreamCipher.WikipediaReference); + lblCipherBlockSize.Caption := '' + end + else if assigned( BlockCipher) then + begin + ErrorPos := 30; + Features1 := BlockCipher.Features; + Include( Features1, afBlockAdapter); + PopulateListBoxWithFeatures( Features1, lbxCipherFeatures); + lblCipherDefinitionURL.Caption := BlockCipher.DefinitionURL; + lblCipherWikipediaURL.Caption := WikipediaRelativeURL( BlockCipher.WikipediaReference); + lblCipherBlockSize.Caption := Format( DS_BlockSizeEqs, [BlockCipher.BlockSize]) + end + else + begin + ErrorPos := 40; + lblCipherDefinitionURL.Caption := ''; + lblCipherWikipediaURL.Caption := ''; + lblCipherBlockSize.Caption := '' + end +except on E: Exception do + begin + DebugFmt( 'ERROR! (%d)', [ErrorPos]); + DebugFmt( 'Class = %s', [E.ClassName]); + DebugFmt( 'Error = %s', [E.Message]) + end; +end +end; + +end. diff --git a/design/pipe.bmp b/LockBox3/design/pipe.bmp similarity index 100% rename from design/pipe.bmp rename to LockBox3/design/pipe.bmp diff --git a/design/signature.bmp b/LockBox3/design/signature.bmp similarity index 100% rename from design/signature.bmp rename to LockBox3/design/signature.bmp diff --git a/design/umfmPrecompute.dfm b/LockBox3/design/umfmPrecompute.dfm similarity index 96% rename from design/umfmPrecompute.dfm rename to LockBox3/design/umfmPrecompute.dfm index d70c9a4..0c21ac4 100644 --- a/design/umfmPrecompute.dfm +++ b/LockBox3/design/umfmPrecompute.dfm @@ -1,71 +1,71 @@ -object mfmPrecompute: TmfmPrecompute - Left = 0 - Top = 0 - Caption = 'Precompute' - ClientHeight = 412 - ClientWidth = 692 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poDesktopCenter - PixelsPerInch = 96 - TextHeight = 13 - object memoUI: TMemo - Left = 0 - Top = 0 - Width = 692 - Height = 412 - Align = alClient - Color = clInfoBk - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Times New Roman' - Font.Style = [] - Lines.Strings = ( - 'Welcome to PreCompute!' - '======================' - '' - - 'Precompute is a design-time utility to generate (read "precomput' + - 'e")' - 'the byte-to-byte maps for mulitiplication of various factors in' - 'GF(2^8). These maps are used in the implemenation of AES.' - '' - - 'To be confident that the AES implementation used in TurboPower L' + - 'ockBox' - 'is compliant with the AE Standard, and that the maps used are' - - '"nothing-up-my-sleeve" numbers, the developer can inspect the so' + - 'urce' - - 'code for this program, verifying that they do indeed generate G2' + - '(2^8)' - - 'multiplication tables, run the program and verify that the outpu' + - 't of this' - - 'program is the same set of constants used in the AES implementat' + - 'ion' - '(unit uTPLb_AES).' - '' - - 'To run the generation function of this program, double-click her' + - 'e on' - - 'this memo box. Compare the output here, with the actual constant' + - 's' - 'used in unit uTPLb_AES.') - ParentFont = False - ReadOnly = True - ScrollBars = ssBoth - TabOrder = 0 - OnDblClick = memoUIDblClick - ExplicitWidth = 516 - end -end +object mfmPrecompute: TmfmPrecompute + Left = 0 + Top = 0 + Caption = 'Precompute' + ClientHeight = 412 + ClientWidth = 692 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poDesktopCenter + PixelsPerInch = 96 + TextHeight = 13 + object memoUI: TMemo + Left = 0 + Top = 0 + Width = 692 + Height = 412 + Align = alClient + Color = clInfoBk + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Times New Roman' + Font.Style = [] + Lines.Strings = ( + 'Welcome to PreCompute!' + '======================' + '' + + 'Precompute is a design-time utility to generate (read "precomput' + + 'e")' + 'the byte-to-byte maps for mulitiplication of various factors in' + 'GF(2^8). These maps are used in the implemenation of AES.' + '' + + 'To be confident that the AES implementation used in TurboPower L' + + 'ockBox' + 'is compliant with the AE Standard, and that the maps used are' + + '"nothing-up-my-sleeve" numbers, the developer can inspect the so' + + 'urce' + + 'code for this program, verifying that they do indeed generate G2' + + '(2^8)' + + 'multiplication tables, run the program and verify that the outpu' + + 't of this' + + 'program is the same set of constants used in the AES implementat' + + 'ion' + '(unit uTPLb_AES).' + '' + + 'To run the generation function of this program, double-click her' + + 'e on' + + 'this memo box. Compare the output here, with the actual constant' + + 's' + 'used in unit uTPLb_AES.') + ParentFont = False + ReadOnly = True + ScrollBars = ssBoth + TabOrder = 0 + OnDblClick = memoUIDblClick + ExplicitWidth = 516 + end +end diff --git a/design/umfmPrecompute.pas b/LockBox3/design/umfmPrecompute.pas similarity index 97% rename from design/umfmPrecompute.pas rename to LockBox3/design/umfmPrecompute.pas index 564af58..cb680a0 100644 --- a/design/umfmPrecompute.pas +++ b/LockBox3/design/umfmPrecompute.pas @@ -1,331 +1,331 @@ -unit umfmPrecompute; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls; - -type - TmfmPrecompute = class(TForm) - memoUI: TMemo; - procedure memoUIDblClick(Sender: TObject); - - private - procedure Put( const Line: string); - procedure PutTable( Factor: integer; isLast: boolean); - - public - { Public declarations } - end; - -var - mfmPrecompute: TmfmPrecompute; - -implementation - - - - - - - - - - - - - - -uses Math; -{$R *.dfm} - -function Poly_Mul( x, y: byte): word; -// Multiply two polynomials. Also known as Finite Field multiplication. -// Refer to section 4.2 in the standard. -// This is the multiplication BEFORE any modulo -var - j: integer; - Factor: word; -begin -result := 0; -Factor := y; -for j := 0 to 7 do - begin - if Odd( x) then - result := result xor Factor; - x := x shr 1; - Factor := Factor shl 1 - end -end; - - -function BitCount( Value: word): integer; -begin -result := 0; -while Value <> 0 do - begin - Value := Value shr 1; - Inc( result) - end -end; - - - -function Poly_Mod( Quotient, Modulus: word): word; -// Assume Modulus <> 0 -var - QuotientBits, ModBits: integer; - OriginalModBits: integer; - ModShift, RightRoll: integer; - -begin -QuotientBits := BitCount( Quotient); -OriginalModBits := BitCount( Modulus); -ModShift := QuotientBits - OriginalModBits; -if ModShift > 0 then - Modulus := Modulus shl ModShift - else if ModShift < 0 then - ModShift := 0; -ModBits := OriginalModBits + ModShift; -result := Quotient; -if Modulus = 0 then exit; -while QuotientBits = ModBits do - begin - result := result xor Modulus; - QuotientBits := BitCount( result); - RightRoll := Min( ModBits - QuotientBits, ModShift); - if RightRoll > 0 then - begin - Modulus := Modulus shr RightRoll; - Dec( ModShift, RightRoll); - Dec( ModBits, RightRoll) - end - end -end; - - - - - -const GF2_8_Modulus = $011B; // == m(x) = x^8 + x^4 + x^3 + x + 1 - -function GF2_8_Mul( x, y: byte): byte; -begin -result := wordrec( Poly_Mod( Poly_Mul( x, y), GF2_8_Modulus)).Lo -end; - -// Tables Needed: x1, x2, x3, 9 b d e -procedure TmfmPrecompute.memoUIDblClick( Sender: TObject); -var - SaveCursor: TCursor; -begin -SaveCursor := Screen.Cursor; -try -Screen.Cursor := crHourGlass; -memoUI.Clear; -memoUI.Font.Name := 'Courier'; -Put( 'type'); -Put( 'TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e);'); -Put( ''); -Put( 'const'); -Put( 'GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ('); -PutTable( $01, False); -PutTable( $02, False); -PutTable( $03, False); -PutTable( $09, False); -PutTable( $0b, False); -PutTable( $0d, False); -PutTable( $0e, True ); -Put(' );') -finally -Screen.Cursor := SaveCursor -end end; - - - -// Output should look like .... -// ================================ - -{ -type -TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e); - -const -GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ( -( // fx01 --- Times 01 Table. - $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, - $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, - $20, $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, $47, $48, $49, $4A, $4B, $4C, $4D, $4E, $4F, - $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, - $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $6D, $6E, $6F, - $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $7A, $7B, $7C, $7D, $7E, $7F, - $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $8A, $8B, $8C, $8D, $8E, $8F, - $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $9E, $9F, - $A0, $A1, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD, $AE, $AF, - $B0, $B1, $B2, $B3, $B4, $B5, $B6, $B7, $B8, $B9, $BA, $BB, $BC, $BD, $BE, $BF, - $C0, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $C9, $CA, $CB, $CC, $CD, $CE, $CF, - $D0, $D1, $D2, $D3, $D4, $D5, $D6, $D7, $D8, $D9, $DA, $DB, $DC, $DD, $DE, $DF, - $E0, $E1, $E2, $E3, $E4, $E5, $E6, $E7, $E8, $E9, $EA, $EB, $EC, $ED, $EE, $EF, - $F0, $F1, $F2, $F3, $F4, $F5, $F6, $F7, $F8, $F9, $FA, $FB, $FC, $FD, $FE, $FF - ), - -( // fx02 --- Times 02 Table. - $00, $02, $04, $06, $08, $0A, $0C, $0E, $10, $12, $14, $16, $18, $1A, $1C, $1E, - $20, $22, $24, $26, $28, $2A, $2C, $2E, $30, $32, $34, $36, $38, $3A, $3C, $3E, - $40, $42, $44, $46, $48, $4A, $4C, $4E, $50, $52, $54, $56, $58, $5A, $5C, $5E, - $60, $62, $64, $66, $68, $6A, $6C, $6E, $70, $72, $74, $76, $78, $7A, $7C, $7E, - $80, $82, $84, $86, $88, $8A, $8C, $8E, $90, $92, $94, $96, $98, $9A, $9C, $9E, - $A0, $A2, $A4, $A6, $A8, $AA, $AC, $AE, $B0, $B2, $B4, $B6, $B8, $BA, $BC, $BE, - $C0, $C2, $C4, $C6, $C8, $CA, $CC, $CE, $D0, $D2, $D4, $D6, $D8, $DA, $DC, $DE, - $E0, $E2, $E4, $E6, $E8, $EA, $EC, $EE, $F0, $F2, $F4, $F6, $F8, $FA, $FC, $FE, - $1B, $19, $1F, $1D, $13, $11, $17, $15, $0B, $09, $0F, $0D, $03, $01, $07, $05, - $3B, $39, $3F, $3D, $33, $31, $37, $35, $2B, $29, $2F, $2D, $23, $21, $27, $25, - $5B, $59, $5F, $5D, $53, $51, $57, $55, $4B, $49, $4F, $4D, $43, $41, $47, $45, - $7B, $79, $7F, $7D, $73, $71, $77, $75, $6B, $69, $6F, $6D, $63, $61, $67, $65, - $9B, $99, $9F, $9D, $93, $91, $97, $95, $8B, $89, $8F, $8D, $83, $81, $87, $85, - $BB, $B9, $BF, $BD, $B3, $B1, $B7, $B5, $AB, $A9, $AF, $AD, $A3, $A1, $A7, $A5, - $DB, $D9, $DF, $DD, $D3, $D1, $D7, $D5, $CB, $C9, $CF, $CD, $C3, $C1, $C7, $C5, - $FB, $F9, $FF, $FD, $F3, $F1, $F7, $F5, $EB, $E9, $EF, $ED, $E3, $E1, $E7, $E5 - ), - -( // fx03 --- Times 03 Table. - $00, $03, $06, $05, $0C, $0F, $0A, $09, $18, $1B, $1E, $1D, $14, $17, $12, $11, - $30, $33, $36, $35, $3C, $3F, $3A, $39, $28, $2B, $2E, $2D, $24, $27, $22, $21, - $60, $63, $66, $65, $6C, $6F, $6A, $69, $78, $7B, $7E, $7D, $74, $77, $72, $71, - $50, $53, $56, $55, $5C, $5F, $5A, $59, $48, $4B, $4E, $4D, $44, $47, $42, $41, - $C0, $C3, $C6, $C5, $CC, $CF, $CA, $C9, $D8, $DB, $DE, $DD, $D4, $D7, $D2, $D1, - $F0, $F3, $F6, $F5, $FC, $FF, $FA, $F9, $E8, $EB, $EE, $ED, $E4, $E7, $E2, $E1, - $A0, $A3, $A6, $A5, $AC, $AF, $AA, $A9, $B8, $BB, $BE, $BD, $B4, $B7, $B2, $B1, - $90, $93, $96, $95, $9C, $9F, $9A, $99, $88, $8B, $8E, $8D, $84, $87, $82, $81, - $9B, $98, $9D, $9E, $97, $94, $91, $92, $83, $80, $85, $86, $8F, $8C, $89, $8A, - $AB, $A8, $AD, $AE, $A7, $A4, $A1, $A2, $B3, $B0, $B5, $B6, $BF, $BC, $B9, $BA, - $FB, $F8, $FD, $FE, $F7, $F4, $F1, $F2, $E3, $E0, $E5, $E6, $EF, $EC, $E9, $EA, - $CB, $C8, $CD, $CE, $C7, $C4, $C1, $C2, $D3, $D0, $D5, $D6, $DF, $DC, $D9, $DA, - $5B, $58, $5D, $5E, $57, $54, $51, $52, $43, $40, $45, $46, $4F, $4C, $49, $4A, - $6B, $68, $6D, $6E, $67, $64, $61, $62, $73, $70, $75, $76, $7F, $7C, $79, $7A, - $3B, $38, $3D, $3E, $37, $34, $31, $32, $23, $20, $25, $26, $2F, $2C, $29, $2A, - $0B, $08, $0D, $0E, $07, $04, $01, $02, $13, $10, $15, $16, $1F, $1C, $19, $1A - ), - -( // fx09 --- Times 09 Table. - $00, $09, $12, $1B, $24, $2D, $36, $3F, $48, $41, $5A, $53, $6C, $65, $7E, $77, - $90, $99, $82, $8B, $B4, $BD, $A6, $AF, $D8, $D1, $CA, $C3, $FC, $F5, $EE, $E7, - $3B, $32, $29, $20, $1F, $16, $0D, $04, $73, $7A, $61, $68, $57, $5E, $45, $4C, - $AB, $A2, $B9, $B0, $8F, $86, $9D, $94, $E3, $EA, $F1, $F8, $C7, $CE, $D5, $DC, - $76, $7F, $64, $6D, $52, $5B, $40, $49, $3E, $37, $2C, $25, $1A, $13, $08, $01, - $E6, $EF, $F4, $FD, $C2, $CB, $D0, $D9, $AE, $A7, $BC, $B5, $8A, $83, $98, $91, - $4D, $44, $5F, $56, $69, $60, $7B, $72, $05, $0C, $17, $1E, $21, $28, $33, $3A, - $DD, $D4, $CF, $C6, $F9, $F0, $EB, $E2, $95, $9C, $87, $8E, $B1, $B8, $A3, $AA, - $EC, $E5, $FE, $F7, $C8, $C1, $DA, $D3, $A4, $AD, $B6, $BF, $80, $89, $92, $9B, - $7C, $75, $6E, $67, $58, $51, $4A, $43, $34, $3D, $26, $2F, $10, $19, $02, $0B, - $D7, $DE, $C5, $CC, $F3, $FA, $E1, $E8, $9F, $96, $8D, $84, $BB, $B2, $A9, $A0, - $47, $4E, $55, $5C, $63, $6A, $71, $78, $0F, $06, $1D, $14, $2B, $22, $39, $30, - $9A, $93, $88, $81, $BE, $B7, $AC, $A5, $D2, $DB, $C0, $C9, $F6, $FF, $E4, $ED, - $0A, $03, $18, $11, $2E, $27, $3C, $35, $42, $4B, $50, $59, $66, $6F, $74, $7D, - $A1, $A8, $B3, $BA, $85, $8C, $97, $9E, $E9, $E0, $FB, $F2, $CD, $C4, $DF, $D6, - $31, $38, $23, $2A, $15, $1C, $07, $0E, $79, $70, $6B, $62, $5D, $54, $4F, $46 - ), - -( // fx0B --- Times 0B Table. - $00, $0B, $16, $1D, $2C, $27, $3A, $31, $58, $53, $4E, $45, $74, $7F, $62, $69, - $B0, $BB, $A6, $AD, $9C, $97, $8A, $81, $E8, $E3, $FE, $F5, $C4, $CF, $D2, $D9, - $7B, $70, $6D, $66, $57, $5C, $41, $4A, $23, $28, $35, $3E, $0F, $04, $19, $12, - $CB, $C0, $DD, $D6, $E7, $EC, $F1, $FA, $93, $98, $85, $8E, $BF, $B4, $A9, $A2, - $F6, $FD, $E0, $EB, $DA, $D1, $CC, $C7, $AE, $A5, $B8, $B3, $82, $89, $94, $9F, - $46, $4D, $50, $5B, $6A, $61, $7C, $77, $1E, $15, $08, $03, $32, $39, $24, $2F, - $8D, $86, $9B, $90, $A1, $AA, $B7, $BC, $D5, $DE, $C3, $C8, $F9, $F2, $EF, $E4, - $3D, $36, $2B, $20, $11, $1A, $07, $0C, $65, $6E, $73, $78, $49, $42, $5F, $54, - $F7, $FC, $E1, $EA, $DB, $D0, $CD, $C6, $AF, $A4, $B9, $B2, $83, $88, $95, $9E, - $47, $4C, $51, $5A, $6B, $60, $7D, $76, $1F, $14, $09, $02, $33, $38, $25, $2E, - $8C, $87, $9A, $91, $A0, $AB, $B6, $BD, $D4, $DF, $C2, $C9, $F8, $F3, $EE, $E5, - $3C, $37, $2A, $21, $10, $1B, $06, $0D, $64, $6F, $72, $79, $48, $43, $5E, $55, - $01, $0A, $17, $1C, $2D, $26, $3B, $30, $59, $52, $4F, $44, $75, $7E, $63, $68, - $B1, $BA, $A7, $AC, $9D, $96, $8B, $80, $E9, $E2, $FF, $F4, $C5, $CE, $D3, $D8, - $7A, $71, $6C, $67, $56, $5D, $40, $4B, $22, $29, $34, $3F, $0E, $05, $18, $13, - $CA, $C1, $DC, $D7, $E6, $ED, $F0, $FB, $92, $99, $84, $8F, $BE, $B5, $A8, $A3 - ), - -( // fx0D --- Times 0D Table. - $00, $0D, $1A, $17, $34, $39, $2E, $23, $68, $65, $72, $7F, $5C, $51, $46, $4B, - $D0, $DD, $CA, $C7, $E4, $E9, $FE, $F3, $B8, $B5, $A2, $AF, $8C, $81, $96, $9B, - $BB, $B6, $A1, $AC, $8F, $82, $95, $98, $D3, $DE, $C9, $C4, $E7, $EA, $FD, $F0, - $6B, $66, $71, $7C, $5F, $52, $45, $48, $03, $0E, $19, $14, $37, $3A, $2D, $20, - $6D, $60, $77, $7A, $59, $54, $43, $4E, $05, $08, $1F, $12, $31, $3C, $2B, $26, - $BD, $B0, $A7, $AA, $89, $84, $93, $9E, $D5, $D8, $CF, $C2, $E1, $EC, $FB, $F6, - $D6, $DB, $CC, $C1, $E2, $EF, $F8, $F5, $BE, $B3, $A4, $A9, $8A, $87, $90, $9D, - $06, $0B, $1C, $11, $32, $3F, $28, $25, $6E, $63, $74, $79, $5A, $57, $40, $4D, - $DA, $D7, $C0, $CD, $EE, $E3, $F4, $F9, $B2, $BF, $A8, $A5, $86, $8B, $9C, $91, - $0A, $07, $10, $1D, $3E, $33, $24, $29, $62, $6F, $78, $75, $56, $5B, $4C, $41, - $61, $6C, $7B, $76, $55, $58, $4F, $42, $09, $04, $13, $1E, $3D, $30, $27, $2A, - $B1, $BC, $AB, $A6, $85, $88, $9F, $92, $D9, $D4, $C3, $CE, $ED, $E0, $F7, $FA, - $B7, $BA, $AD, $A0, $83, $8E, $99, $94, $DF, $D2, $C5, $C8, $EB, $E6, $F1, $FC, - $67, $6A, $7D, $70, $53, $5E, $49, $44, $0F, $02, $15, $18, $3B, $36, $21, $2C, - $0C, $01, $16, $1B, $38, $35, $22, $2F, $64, $69, $7E, $73, $50, $5D, $4A, $47, - $DC, $D1, $C6, $CB, $E8, $E5, $F2, $FF, $B4, $B9, $AE, $A3, $80, $8D, $9A, $97 - ), - -( // fx0E --- Times 0E Table. - $00, $0E, $1C, $12, $38, $36, $24, $2A, $70, $7E, $6C, $62, $48, $46, $54, $5A, - $E0, $EE, $FC, $F2, $D8, $D6, $C4, $CA, $90, $9E, $8C, $82, $A8, $A6, $B4, $BA, - $DB, $D5, $C7, $C9, $E3, $ED, $FF, $F1, $AB, $A5, $B7, $B9, $93, $9D, $8F, $81, - $3B, $35, $27, $29, $03, $0D, $1F, $11, $4B, $45, $57, $59, $73, $7D, $6F, $61, - $AD, $A3, $B1, $BF, $95, $9B, $89, $87, $DD, $D3, $C1, $CF, $E5, $EB, $F9, $F7, - $4D, $43, $51, $5F, $75, $7B, $69, $67, $3D, $33, $21, $2F, $05, $0B, $19, $17, - $76, $78, $6A, $64, $4E, $40, $52, $5C, $06, $08, $1A, $14, $3E, $30, $22, $2C, - $96, $98, $8A, $84, $AE, $A0, $B2, $BC, $E6, $E8, $FA, $F4, $DE, $D0, $C2, $CC, - $41, $4F, $5D, $53, $79, $77, $65, $6B, $31, $3F, $2D, $23, $09, $07, $15, $1B, - $A1, $AF, $BD, $B3, $99, $97, $85, $8B, $D1, $DF, $CD, $C3, $E9, $E7, $F5, $FB, - $9A, $94, $86, $88, $A2, $AC, $BE, $B0, $EA, $E4, $F6, $F8, $D2, $DC, $CE, $C0, - $7A, $74, $66, $68, $42, $4C, $5E, $50, $0A, $04, $16, $18, $32, $3C, $2E, $20, - $EC, $E2, $F0, $FE, $D4, $DA, $C8, $C6, $9C, $92, $80, $8E, $A4, $AA, $B8, $B6, - $0C, $02, $10, $1E, $34, $3A, $28, $26, $7C, $72, $60, $6E, $44, $4A, $58, $56, - $37, $39, $2B, $25, $0F, $01, $13, $1D, $47, $49, $5B, $55, $7F, $71, $63, $6D, - $D7, $D9, $CB, $C5, $EF, $E1, $F3, $FD, $A7, $A9, $BB, $B5, $9F, $91, $83, $8D - ) - ); -} - - - - -procedure TmfmPrecompute.Put( const Line: string); -begin - memoUI.Lines.Add( Line) -end; - - - -procedure TmfmPrecompute.PutTable( Factor: integer; isLast: boolean); -var - Row, Col, Idx: integer; - s: string; -begin -Put( Format('( // fx%0:.2x --- Times %0:.2x Table.', [ Factor])); -Idx := 0; -for Row := 0 to 15 do - begin - s := ' '; - for Col := 0 to 15 do - begin - s := s + Format( '$%.2x', [GF2_8_Mul( Idx, Factor)]); - if Col < 15 then - s := s + ', ' - else if Row < 15 then - s := s + ','; - Inc( Idx) - end; - Put( s) - end; -if isLast then - Put(' )') - else - begin - Put(' ),'); - Put('') - end -end; - -end. +unit umfmPrecompute; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls; + +type + TmfmPrecompute = class(TForm) + memoUI: TMemo; + procedure memoUIDblClick(Sender: TObject); + + private + procedure Put( const Line: string); + procedure PutTable( Factor: integer; isLast: boolean); + + public + { Public declarations } + end; + +var + mfmPrecompute: TmfmPrecompute; + +implementation + + + + + + + + + + + + + + +uses Math; +{$R *.dfm} + +function Poly_Mul( x, y: byte): word; +// Multiply two polynomials. Also known as Finite Field multiplication. +// Refer to section 4.2 in the standard. +// This is the multiplication BEFORE any modulo +var + j: integer; + Factor: word; +begin +result := 0; +Factor := y; +for j := 0 to 7 do + begin + if Odd( x) then + result := result xor Factor; + x := x shr 1; + Factor := Factor shl 1 + end +end; + + +function BitCount( Value: word): integer; +begin +result := 0; +while Value <> 0 do + begin + Value := Value shr 1; + Inc( result) + end +end; + + + +function Poly_Mod( Quotient, Modulus: word): word; +// Assume Modulus <> 0 +var + QuotientBits, ModBits: integer; + OriginalModBits: integer; + ModShift, RightRoll: integer; + +begin +QuotientBits := BitCount( Quotient); +OriginalModBits := BitCount( Modulus); +ModShift := QuotientBits - OriginalModBits; +if ModShift > 0 then + Modulus := Modulus shl ModShift + else if ModShift < 0 then + ModShift := 0; +ModBits := OriginalModBits + ModShift; +result := Quotient; +if Modulus = 0 then exit; +while QuotientBits = ModBits do + begin + result := result xor Modulus; + QuotientBits := BitCount( result); + RightRoll := Min( ModBits - QuotientBits, ModShift); + if RightRoll > 0 then + begin + Modulus := Modulus shr RightRoll; + Dec( ModShift, RightRoll); + Dec( ModBits, RightRoll) + end + end +end; + + + + + +const GF2_8_Modulus = $011B; // == m(x) = x^8 + x^4 + x^3 + x + 1 + +function GF2_8_Mul( x, y: byte): byte; +begin +result := wordrec( Poly_Mod( Poly_Mul( x, y), GF2_8_Modulus)).Lo +end; + +// Tables Needed: x1, x2, x3, 9 b d e +procedure TmfmPrecompute.memoUIDblClick( Sender: TObject); +var + SaveCursor: TCursor; +begin +SaveCursor := Screen.Cursor; +try +Screen.Cursor := crHourGlass; +memoUI.Clear; +memoUI.Font.Name := 'Courier'; +Put( 'type'); +Put( 'TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e);'); +Put( ''); +Put( 'const'); +Put( 'GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ('); +PutTable( $01, False); +PutTable( $02, False); +PutTable( $03, False); +PutTable( $09, False); +PutTable( $0b, False); +PutTable( $0d, False); +PutTable( $0e, True ); +Put(' );') +finally +Screen.Cursor := SaveCursor +end end; + + + +// Output should look like .... +// ================================ + +{ +type +TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e); + +const +GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ( +( // fx01 --- Times 01 Table. + $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, + $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, + $20, $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, $47, $48, $49, $4A, $4B, $4C, $4D, $4E, $4F, + $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, + $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $6D, $6E, $6F, + $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $7A, $7B, $7C, $7D, $7E, $7F, + $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $8A, $8B, $8C, $8D, $8E, $8F, + $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $9E, $9F, + $A0, $A1, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD, $AE, $AF, + $B0, $B1, $B2, $B3, $B4, $B5, $B6, $B7, $B8, $B9, $BA, $BB, $BC, $BD, $BE, $BF, + $C0, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $C9, $CA, $CB, $CC, $CD, $CE, $CF, + $D0, $D1, $D2, $D3, $D4, $D5, $D6, $D7, $D8, $D9, $DA, $DB, $DC, $DD, $DE, $DF, + $E0, $E1, $E2, $E3, $E4, $E5, $E6, $E7, $E8, $E9, $EA, $EB, $EC, $ED, $EE, $EF, + $F0, $F1, $F2, $F3, $F4, $F5, $F6, $F7, $F8, $F9, $FA, $FB, $FC, $FD, $FE, $FF + ), + +( // fx02 --- Times 02 Table. + $00, $02, $04, $06, $08, $0A, $0C, $0E, $10, $12, $14, $16, $18, $1A, $1C, $1E, + $20, $22, $24, $26, $28, $2A, $2C, $2E, $30, $32, $34, $36, $38, $3A, $3C, $3E, + $40, $42, $44, $46, $48, $4A, $4C, $4E, $50, $52, $54, $56, $58, $5A, $5C, $5E, + $60, $62, $64, $66, $68, $6A, $6C, $6E, $70, $72, $74, $76, $78, $7A, $7C, $7E, + $80, $82, $84, $86, $88, $8A, $8C, $8E, $90, $92, $94, $96, $98, $9A, $9C, $9E, + $A0, $A2, $A4, $A6, $A8, $AA, $AC, $AE, $B0, $B2, $B4, $B6, $B8, $BA, $BC, $BE, + $C0, $C2, $C4, $C6, $C8, $CA, $CC, $CE, $D0, $D2, $D4, $D6, $D8, $DA, $DC, $DE, + $E0, $E2, $E4, $E6, $E8, $EA, $EC, $EE, $F0, $F2, $F4, $F6, $F8, $FA, $FC, $FE, + $1B, $19, $1F, $1D, $13, $11, $17, $15, $0B, $09, $0F, $0D, $03, $01, $07, $05, + $3B, $39, $3F, $3D, $33, $31, $37, $35, $2B, $29, $2F, $2D, $23, $21, $27, $25, + $5B, $59, $5F, $5D, $53, $51, $57, $55, $4B, $49, $4F, $4D, $43, $41, $47, $45, + $7B, $79, $7F, $7D, $73, $71, $77, $75, $6B, $69, $6F, $6D, $63, $61, $67, $65, + $9B, $99, $9F, $9D, $93, $91, $97, $95, $8B, $89, $8F, $8D, $83, $81, $87, $85, + $BB, $B9, $BF, $BD, $B3, $B1, $B7, $B5, $AB, $A9, $AF, $AD, $A3, $A1, $A7, $A5, + $DB, $D9, $DF, $DD, $D3, $D1, $D7, $D5, $CB, $C9, $CF, $CD, $C3, $C1, $C7, $C5, + $FB, $F9, $FF, $FD, $F3, $F1, $F7, $F5, $EB, $E9, $EF, $ED, $E3, $E1, $E7, $E5 + ), + +( // fx03 --- Times 03 Table. + $00, $03, $06, $05, $0C, $0F, $0A, $09, $18, $1B, $1E, $1D, $14, $17, $12, $11, + $30, $33, $36, $35, $3C, $3F, $3A, $39, $28, $2B, $2E, $2D, $24, $27, $22, $21, + $60, $63, $66, $65, $6C, $6F, $6A, $69, $78, $7B, $7E, $7D, $74, $77, $72, $71, + $50, $53, $56, $55, $5C, $5F, $5A, $59, $48, $4B, $4E, $4D, $44, $47, $42, $41, + $C0, $C3, $C6, $C5, $CC, $CF, $CA, $C9, $D8, $DB, $DE, $DD, $D4, $D7, $D2, $D1, + $F0, $F3, $F6, $F5, $FC, $FF, $FA, $F9, $E8, $EB, $EE, $ED, $E4, $E7, $E2, $E1, + $A0, $A3, $A6, $A5, $AC, $AF, $AA, $A9, $B8, $BB, $BE, $BD, $B4, $B7, $B2, $B1, + $90, $93, $96, $95, $9C, $9F, $9A, $99, $88, $8B, $8E, $8D, $84, $87, $82, $81, + $9B, $98, $9D, $9E, $97, $94, $91, $92, $83, $80, $85, $86, $8F, $8C, $89, $8A, + $AB, $A8, $AD, $AE, $A7, $A4, $A1, $A2, $B3, $B0, $B5, $B6, $BF, $BC, $B9, $BA, + $FB, $F8, $FD, $FE, $F7, $F4, $F1, $F2, $E3, $E0, $E5, $E6, $EF, $EC, $E9, $EA, + $CB, $C8, $CD, $CE, $C7, $C4, $C1, $C2, $D3, $D0, $D5, $D6, $DF, $DC, $D9, $DA, + $5B, $58, $5D, $5E, $57, $54, $51, $52, $43, $40, $45, $46, $4F, $4C, $49, $4A, + $6B, $68, $6D, $6E, $67, $64, $61, $62, $73, $70, $75, $76, $7F, $7C, $79, $7A, + $3B, $38, $3D, $3E, $37, $34, $31, $32, $23, $20, $25, $26, $2F, $2C, $29, $2A, + $0B, $08, $0D, $0E, $07, $04, $01, $02, $13, $10, $15, $16, $1F, $1C, $19, $1A + ), + +( // fx09 --- Times 09 Table. + $00, $09, $12, $1B, $24, $2D, $36, $3F, $48, $41, $5A, $53, $6C, $65, $7E, $77, + $90, $99, $82, $8B, $B4, $BD, $A6, $AF, $D8, $D1, $CA, $C3, $FC, $F5, $EE, $E7, + $3B, $32, $29, $20, $1F, $16, $0D, $04, $73, $7A, $61, $68, $57, $5E, $45, $4C, + $AB, $A2, $B9, $B0, $8F, $86, $9D, $94, $E3, $EA, $F1, $F8, $C7, $CE, $D5, $DC, + $76, $7F, $64, $6D, $52, $5B, $40, $49, $3E, $37, $2C, $25, $1A, $13, $08, $01, + $E6, $EF, $F4, $FD, $C2, $CB, $D0, $D9, $AE, $A7, $BC, $B5, $8A, $83, $98, $91, + $4D, $44, $5F, $56, $69, $60, $7B, $72, $05, $0C, $17, $1E, $21, $28, $33, $3A, + $DD, $D4, $CF, $C6, $F9, $F0, $EB, $E2, $95, $9C, $87, $8E, $B1, $B8, $A3, $AA, + $EC, $E5, $FE, $F7, $C8, $C1, $DA, $D3, $A4, $AD, $B6, $BF, $80, $89, $92, $9B, + $7C, $75, $6E, $67, $58, $51, $4A, $43, $34, $3D, $26, $2F, $10, $19, $02, $0B, + $D7, $DE, $C5, $CC, $F3, $FA, $E1, $E8, $9F, $96, $8D, $84, $BB, $B2, $A9, $A0, + $47, $4E, $55, $5C, $63, $6A, $71, $78, $0F, $06, $1D, $14, $2B, $22, $39, $30, + $9A, $93, $88, $81, $BE, $B7, $AC, $A5, $D2, $DB, $C0, $C9, $F6, $FF, $E4, $ED, + $0A, $03, $18, $11, $2E, $27, $3C, $35, $42, $4B, $50, $59, $66, $6F, $74, $7D, + $A1, $A8, $B3, $BA, $85, $8C, $97, $9E, $E9, $E0, $FB, $F2, $CD, $C4, $DF, $D6, + $31, $38, $23, $2A, $15, $1C, $07, $0E, $79, $70, $6B, $62, $5D, $54, $4F, $46 + ), + +( // fx0B --- Times 0B Table. + $00, $0B, $16, $1D, $2C, $27, $3A, $31, $58, $53, $4E, $45, $74, $7F, $62, $69, + $B0, $BB, $A6, $AD, $9C, $97, $8A, $81, $E8, $E3, $FE, $F5, $C4, $CF, $D2, $D9, + $7B, $70, $6D, $66, $57, $5C, $41, $4A, $23, $28, $35, $3E, $0F, $04, $19, $12, + $CB, $C0, $DD, $D6, $E7, $EC, $F1, $FA, $93, $98, $85, $8E, $BF, $B4, $A9, $A2, + $F6, $FD, $E0, $EB, $DA, $D1, $CC, $C7, $AE, $A5, $B8, $B3, $82, $89, $94, $9F, + $46, $4D, $50, $5B, $6A, $61, $7C, $77, $1E, $15, $08, $03, $32, $39, $24, $2F, + $8D, $86, $9B, $90, $A1, $AA, $B7, $BC, $D5, $DE, $C3, $C8, $F9, $F2, $EF, $E4, + $3D, $36, $2B, $20, $11, $1A, $07, $0C, $65, $6E, $73, $78, $49, $42, $5F, $54, + $F7, $FC, $E1, $EA, $DB, $D0, $CD, $C6, $AF, $A4, $B9, $B2, $83, $88, $95, $9E, + $47, $4C, $51, $5A, $6B, $60, $7D, $76, $1F, $14, $09, $02, $33, $38, $25, $2E, + $8C, $87, $9A, $91, $A0, $AB, $B6, $BD, $D4, $DF, $C2, $C9, $F8, $F3, $EE, $E5, + $3C, $37, $2A, $21, $10, $1B, $06, $0D, $64, $6F, $72, $79, $48, $43, $5E, $55, + $01, $0A, $17, $1C, $2D, $26, $3B, $30, $59, $52, $4F, $44, $75, $7E, $63, $68, + $B1, $BA, $A7, $AC, $9D, $96, $8B, $80, $E9, $E2, $FF, $F4, $C5, $CE, $D3, $D8, + $7A, $71, $6C, $67, $56, $5D, $40, $4B, $22, $29, $34, $3F, $0E, $05, $18, $13, + $CA, $C1, $DC, $D7, $E6, $ED, $F0, $FB, $92, $99, $84, $8F, $BE, $B5, $A8, $A3 + ), + +( // fx0D --- Times 0D Table. + $00, $0D, $1A, $17, $34, $39, $2E, $23, $68, $65, $72, $7F, $5C, $51, $46, $4B, + $D0, $DD, $CA, $C7, $E4, $E9, $FE, $F3, $B8, $B5, $A2, $AF, $8C, $81, $96, $9B, + $BB, $B6, $A1, $AC, $8F, $82, $95, $98, $D3, $DE, $C9, $C4, $E7, $EA, $FD, $F0, + $6B, $66, $71, $7C, $5F, $52, $45, $48, $03, $0E, $19, $14, $37, $3A, $2D, $20, + $6D, $60, $77, $7A, $59, $54, $43, $4E, $05, $08, $1F, $12, $31, $3C, $2B, $26, + $BD, $B0, $A7, $AA, $89, $84, $93, $9E, $D5, $D8, $CF, $C2, $E1, $EC, $FB, $F6, + $D6, $DB, $CC, $C1, $E2, $EF, $F8, $F5, $BE, $B3, $A4, $A9, $8A, $87, $90, $9D, + $06, $0B, $1C, $11, $32, $3F, $28, $25, $6E, $63, $74, $79, $5A, $57, $40, $4D, + $DA, $D7, $C0, $CD, $EE, $E3, $F4, $F9, $B2, $BF, $A8, $A5, $86, $8B, $9C, $91, + $0A, $07, $10, $1D, $3E, $33, $24, $29, $62, $6F, $78, $75, $56, $5B, $4C, $41, + $61, $6C, $7B, $76, $55, $58, $4F, $42, $09, $04, $13, $1E, $3D, $30, $27, $2A, + $B1, $BC, $AB, $A6, $85, $88, $9F, $92, $D9, $D4, $C3, $CE, $ED, $E0, $F7, $FA, + $B7, $BA, $AD, $A0, $83, $8E, $99, $94, $DF, $D2, $C5, $C8, $EB, $E6, $F1, $FC, + $67, $6A, $7D, $70, $53, $5E, $49, $44, $0F, $02, $15, $18, $3B, $36, $21, $2C, + $0C, $01, $16, $1B, $38, $35, $22, $2F, $64, $69, $7E, $73, $50, $5D, $4A, $47, + $DC, $D1, $C6, $CB, $E8, $E5, $F2, $FF, $B4, $B9, $AE, $A3, $80, $8D, $9A, $97 + ), + +( // fx0E --- Times 0E Table. + $00, $0E, $1C, $12, $38, $36, $24, $2A, $70, $7E, $6C, $62, $48, $46, $54, $5A, + $E0, $EE, $FC, $F2, $D8, $D6, $C4, $CA, $90, $9E, $8C, $82, $A8, $A6, $B4, $BA, + $DB, $D5, $C7, $C9, $E3, $ED, $FF, $F1, $AB, $A5, $B7, $B9, $93, $9D, $8F, $81, + $3B, $35, $27, $29, $03, $0D, $1F, $11, $4B, $45, $57, $59, $73, $7D, $6F, $61, + $AD, $A3, $B1, $BF, $95, $9B, $89, $87, $DD, $D3, $C1, $CF, $E5, $EB, $F9, $F7, + $4D, $43, $51, $5F, $75, $7B, $69, $67, $3D, $33, $21, $2F, $05, $0B, $19, $17, + $76, $78, $6A, $64, $4E, $40, $52, $5C, $06, $08, $1A, $14, $3E, $30, $22, $2C, + $96, $98, $8A, $84, $AE, $A0, $B2, $BC, $E6, $E8, $FA, $F4, $DE, $D0, $C2, $CC, + $41, $4F, $5D, $53, $79, $77, $65, $6B, $31, $3F, $2D, $23, $09, $07, $15, $1B, + $A1, $AF, $BD, $B3, $99, $97, $85, $8B, $D1, $DF, $CD, $C3, $E9, $E7, $F5, $FB, + $9A, $94, $86, $88, $A2, $AC, $BE, $B0, $EA, $E4, $F6, $F8, $D2, $DC, $CE, $C0, + $7A, $74, $66, $68, $42, $4C, $5E, $50, $0A, $04, $16, $18, $32, $3C, $2E, $20, + $EC, $E2, $F0, $FE, $D4, $DA, $C8, $C6, $9C, $92, $80, $8E, $A4, $AA, $B8, $B6, + $0C, $02, $10, $1E, $34, $3A, $28, $26, $7C, $72, $60, $6E, $44, $4A, $58, $56, + $37, $39, $2B, $25, $0F, $01, $13, $1D, $47, $49, $5B, $55, $7F, $71, $63, $6D, + $D7, $D9, $CB, $C5, $EF, $E1, $F3, $FD, $A7, $A9, $BB, $B5, $9F, $91, $83, $8D + ) + ); +} + + + + +procedure TmfmPrecompute.Put( const Line: string); +begin + memoUI.Lines.Add( Line) +end; + + + +procedure TmfmPrecompute.PutTable( Factor: integer; isLast: boolean); +var + Row, Col, Idx: integer; + s: string; +begin +Put( Format('( // fx%0:.2x --- Times %0:.2x Table.', [ Factor])); +Idx := 0; +for Row := 0 to 15 do + begin + s := ' '; + for Col := 0 to 15 do + begin + s := s + Format( '$%.2x', [GF2_8_Mul( Idx, Factor)]); + if Col < 15 then + s := s + ', ' + else if Row < 15 then + s := s + ','; + Inc( Idx) + end; + Put( s) + end; +if isLast then + Put(' )') + else + begin + Put(' ),'); + Put('') + end +end; + +end. diff --git a/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dpr b/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dpr new file mode 100644 index 0000000..3d32221 --- /dev/null +++ b/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dpr @@ -0,0 +1,63 @@ +program LockBox_DUnitM_Tests; +// This module was dynamically generated by the DUnitM GUI Runner Wizard. + +uses + Forms, + SBD.Generics in '..\..\unit-tests\dunit-m\run\SBD.Generics.pas', + SBD.Messages in '..\..\unit-tests\dunit-m\run\SBD.Messages.pas', + SBD.Messages.Solution in '..\..\unit-tests\dunit-m\run\SBD.Messages.Solution.pas', + DUnitM.UnitTestFramework in '..\..\unit-tests\dunit-m\run\DUnitM.UnitTestFramework.pas', + DUnitM.UnitTestFramework.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.UnitTestFramework.Solution.pas', + DUnitM.ViewModel_Tree in '..\..\unit-tests\dunit-m\run\DUnitM.ViewModel_Tree.pas', + DUnitM.ViewModel_VCLForms in '..\..\unit-tests\dunit-m\run\DUnitM.ViewModel_VCLForms.pas', + DUnitM.VirtualTrees in '..\..\unit-tests\dunit-m\external-libraries\VirtualTreeView\Source\DUnitM.VirtualTrees.pas', + DUnitM.VTAccessibility in '..\..\unit-tests\dunit-m\external-libraries\VirtualTreeView\Source\DUnitM.VTAccessibility.pas', + DUnitM.VTAccessibilityFactory in '..\..\unit-tests\dunit-m\external-libraries\VirtualTreeView\Source\DUnitM.VTAccessibilityFactory.pas', + SBD.ServiceProvider.Internal in '..\..\unit-tests\dunit-m\external-libraries\sbd-dependency-injection\SBD.ServiceProvider.Internal.pas', + SBD.ServiceProvider in '..\..\unit-tests\dunit-m\external-libraries\sbd-dependency-injection\SBD.ServiceProvider.pas', + DUnitM.dmVirtualTreeNonVisualSupport in '..\..\unit-tests\dunit-m\run\DUnitM.dmVirtualTreeNonVisualSupport.pas' {dmVirtualTreeNonVisualSupport: TDataModule}, + DunitM.GUIRunnerForm in '..\..\unit-tests\dunit-m\run\DunitM.GUIRunnerForm.pas' {mfmGUIRunner}, + DUnitM.TestSuiteDxVirtualTree in '..\..\unit-tests\dunit-m\run\DUnitM.TestSuiteDxVirtualTree.pas' {TestSuiteVirtualTree: TFrame}, + DUnitM.MemoryMonitor in '..\..\unit-tests\dunit-m\run\DUnitM.MemoryMonitor.pas', + DUnitM.MemoryMonitor.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.MemoryMonitor.Solution.pas', + DUnitM.BaseExecutive in '..\..\unit-tests\dunit-m\run\DUnitM.BaseExecutive.pas', + DUnitM.Executive in '..\..\unit-tests\dunit-m\run\DUnitM.Executive.pas', + SBD.Environment in '..\..\unit-tests\dunit-m\run\SBD.Environment.pas', + SBD.Utils.XML2 in '..\..\unit-tests\dunit-m\run\SBD.Utils.XML2.pas', + DUnitM.NUnit.Logger.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.NUnit.Logger.Solution.pas', + DUnitM.NUnit.LoggerUI.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.NUnit.LoggerUI.Solution.pas', + DUnitM.NUnit in '..\..\unit-tests\dunit-m\run\DUnitM.NUnit.pas', + DUnitM.NUnit25.ResultsLog.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.NUnit25.ResultsLog.Solution.pas', + DUnitM.RttiUtils in '..\..\unit-tests\dunit-m\run\DUnitM.RttiUtils.pas', + DUnitM.StringUtils in '..\..\unit-tests\dunit-m\run\DUnitM.StringUtils.pas', + DUnitM.XMLWriter in '..\..\unit-tests\dunit-m\run\DUnitM.XMLWriter.pas', + DUnitM.XMLWriter.Solution in '..\..\unit-tests\dunit-m\run\DUnitM.XMLWriter.Solution.pas', + DUnitM.TestCase in '..\..\unit-tests\dunit-m\run\DUnitM.TestCase.pas', + DUnitM.TestCaseParameters in '..\..\unit-tests\dunit-m\run\DUnitM.TestCaseParameters.pas', + DUnitM.TestCaseRound in '..\..\unit-tests\dunit-m\run\DUnitM.TestCaseRound.pas', + DUnitM.TestNode in '..\..\unit-tests\dunit-m\run\DUnitM.TestNode.pas', + DUnitM.TestProcedure in '..\..\unit-tests\dunit-m\run\DUnitM.TestProcedure.pas', + DUnitM.Assertion in '..\..\unit-tests\dunit-m\run\DUnitM.Assertion.pas', + DUnitM.DDExtensions in '..\..\unit-tests\dunit-m\run\DUnitM.DDExtensions.pas', + DUnitM.Fixture in '..\..\unit-tests\dunit-m\run\DUnitM.Fixture.pas', + DUnitM.RunInstance in '..\..\unit-tests\dunit-m\run\DUnitM.RunInstance.pas', + DUnitX.ConsoleWriter.Base in '..\..\unit-tests\dunit-m\run\DUnitX.ConsoleWriter.Base.pas', + DUnitX.Windows.Console in '..\..\unit-tests\dunit-m\run\DUnitX.Windows.Console.pas', + uLockBox_TestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_TestCases.pas', + uLockBox_CipherTestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_CipherTestCases.pas', + uLockBox_Hashes in '..\..\unit-tests\dunit-m\test-suite\uLockBox_Hashes.pas', + uLockBox_HugeCardinalTestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_HugeCardinalTestCases.pas', + uLockBox_OpenSSLTestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_OpenSSLTestCases.pas', + uLockBox_RSA_TestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_RSA_TestCases.pas', + uLockBox_Signatory_TestCases in '..\..\unit-tests\dunit-m\test-suite\uLockBox_Signatory_TestCases.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'TP Lockbox 3 Unit Test Suite'; + Application.CreateForm(TmfmGUIRunner, mfmGUIRunner); + Application.ShowHint := True; + Application.Run; +end. diff --git a/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dproj b/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dproj new file mode 100644 index 0000000..8d82d9b --- /dev/null +++ b/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.dproj @@ -0,0 +1,662 @@ + + + {8A46BF32-1F8F-45B1-A3DE-A091FF2ED9D2} + LockBox_DUnitM_Tests.dpr + True + Debug + 1025 + Application + VCL + 18.2 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + false + LockBox_DUnitM_Tests + false + false + 3081 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + 00400000 + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + false + ..\..\work-products\ephemeral\dcu\D10_1Brln\$(Platform) + ..\..\work-products\exe\D10_1Brln\$(Platform) + + + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName= + + + 3 + 7 + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + true + 1033 + $(BDS)\bin\default_app.manifest + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + true + true + + + DEBUG;$(DCC_Define) + true + false + + + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + Debug + + + 3 + 7 + Debug + 1033 + true + true + true + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + + + + MainSource + + + + + + + + + + + + + + +
dmVirtualTreeNonVisualSupport
+ dfm + TDataModule +
+ +
mfmGUIRunner
+ dfm +
+ +
TestSuiteVirtualTree
+ dfm + TFrame +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + LockBox_DUnitM_Tests.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + True + False + + + + + LockBox_DUnitM_Tests.exe + true + + + + + .\ + true + + + + + 1 + + + 1 + + + + + Contents\Resources + 1 + + + + + classes + 1 + + + + + Contents\MacOS + 0 + + + 1 + + + Contents\MacOS + 1 + + + + + 1 + + + 1 + + + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + library\lib\mips + 1 + + + + + 1 + + + 1 + + + 0 + + + 1 + + + Contents\MacOS + 1 + + + library\lib\armeabi-v7a + 1 + + + 1 + + + + + 0 + + + Contents\MacOS + 1 + .framework + + + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + library\lib\armeabi + 1 + + + + + 0 + + + 1 + + + Contents\MacOS + 1 + + + + + 1 + + + 1 + + + 1 + + + + + res\drawable-normal + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-large + 1 + + + + + 1 + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + res\drawable-hdpi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + Contents + 1 + + + + + ..\ + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + 1 + + + 1 + + + 1 + + + + + res\values + 1 + + + + + res\drawable-small + 1 + + + + + res\drawable + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + res\drawable + 1 + + + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + 0 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 0 + .bpl + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-xlarge + 1 + + + + + res\drawable-ldpi + 1 + + + + + 0 + .dll;.bpl + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + + + + + + + + + + + 12 + + + + +
diff --git a/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.res b/LockBox3/packages/D10_1Brln/LockBox_DUnitM_Tests.res new file mode 100644 index 0000000000000000000000000000000000000000..b65c3567e8d868f6d3fa598e2b337cacbf370fb3 GIT binary patch literal 2432 zcmbtW%Wm676ul0NqB0Pmn*v=AWicd&G7-MYp=1k1 zH~olyLjR(F(|!M-?ios?EF(scga&EyKF+!4&ZRg+L=5NM-Ri{c*75R5pF7SPjLk2U7D-dD8(S#y2}mR7uj zZfTWG$2TiP^i93GQ+Ne5Dy*Q`s=KrM&+ea}5i#K0-F@}WIU60_rU_ffQpI^THteot zFqs8;7-zGw@n-sh4-BR%k%c13GdVVvQW-~wPxnSbDVh4ok^vx7V`E-s2P(LhsZczP zgECinRPi8B4}?m)3)^6+$l^$<>S~LvPS-ID=e;0~0cOU)jpzeW6iFP23Y8zi+S+g8 zEX;4zrK~EbP)&i?RaG3A=DNmiTVoeBnwMu2vu9bJ`SW(Nu|fuRSj5LSqLhczaxTsD zvys_aR^;ZYst4>kf3$YpFSynb%0gx#`n_BWXbjcyy1OlX)9wkvtGHU$oLY3XEU+wK zb$Ui?%tQ*~S+fk?wW{v3JWcbAKg+YK%oDXqXeXfGwe;V{Q_OvI`6s!Y=5HlNr0)$q zzwg?v8w8OZMw`e)WV5-Lf%v*+LG=!e83^L~*dv(>6!G>m6~A@}11 zBHk~4D_p;KhwSNIXLNt|w4pQln)B(kWRnx-%Ot;H7<~OUNyQM$)VwJ2vSLwQvi0<^ zs~EoojB`|l{B?v3Uth9GI5vKhJv8IV zw4!}s_qZSV4jL{89PRhGJBUKh61FFXb;CQIj-EdA!T62LtufVOj^D`D2L%sA*dEcS n{%-AI_i#$b_;%|(&jr5YQ#@VJ57?1Rv5Q$9_xDaa*!27lQkitr literal 0 HcmV?d00001 diff --git a/packages/XE7/Lockbox3_Demo.dpr b/LockBox3/packages/D10_1Brln/Lockbox3_Demo.dpr similarity index 96% rename from packages/XE7/Lockbox3_Demo.dpr rename to LockBox3/packages/D10_1Brln/Lockbox3_Demo.dpr index b8d0031..f22cc07 100644 --- a/packages/XE7/Lockbox3_Demo.dpr +++ b/LockBox3/packages/D10_1Brln/Lockbox3_Demo.dpr @@ -1,16 +1,16 @@ -program Lockbox3_Demo; - -uses - Forms, - umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}, - uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas'; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'LB3 Demo'; - Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); - Application.Run; -end. +program Lockbox3_Demo; + +uses + Forms, + umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}, + uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'LB3 Demo'; + Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); + Application.Run; +end. diff --git a/LockBox3/packages/D10_1Brln/Lockbox3_Demo.dproj b/LockBox3/packages/D10_1Brln/Lockbox3_Demo.dproj new file mode 100644 index 0000000..c94bb19 --- /dev/null +++ b/LockBox3/packages/D10_1Brln/Lockbox3_Demo.dproj @@ -0,0 +1,182 @@ + + + {35D43C26-849F-44E8-8049-370515C03874} + Lockbox3_Demo.dpr + True + Debug + 1025 + Application + VCL + 18.2 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + 3081 + Lockbox3_Demo + false + false + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + false + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + false + 00400000 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + true + 1033 + true + 3 + 7 + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\default_app.manifest + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + Debug + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + ..\..\work-products\ephemeral\dcu\D10_1Brln\$(Platform) + ..\..\work-products\exe\D10_1Brln\$(Platform) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + + + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + + + false + 0 + 0 + RELEASE;$(DCC_Define) + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + true + 7 + 3 + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + true + 1033 + + + true + DEBUG;$(DCC_Define) + false + + + 7 + 3 + Debug + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + true + true + 1033 + CompanyName=;FileDescription=3.7.0.0;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + true + + + + MainSource + + +
mfmLockbox3_Demo
+
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + Lockbox3_Demo.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + True + False + + + 12 + + + +
diff --git a/LockBox3/packages/D10_1Brln/Lockbox3_Demo.res b/LockBox3/packages/D10_1Brln/Lockbox3_Demo.res new file mode 100644 index 0000000000000000000000000000000000000000..33efe2a7fe15f7f9e0b80d617a2926119998b842 GIT binary patch literal 2372 zcmbtW-EQMV6h2)lAk{A7lB?BVafLLo9ovahC9R_Ufryr^wxMu`#`ZY1)<41Hq>T`- z!Q1dQ-17#MZ=A$Qsx6gvCmMTv=A84L^Uaye5D_u-ySr7#aIZamvYG!9ItTTfMXke) z($gm{hF5e+zvB6d-eNSSH}oUE$9TTRShv3p|M{0l+pm0lMxWI3)A~uI9j<290=!ZP z4&bk%k`l^k3U3LeB;h%ym3m{X)+hn<-E=(ilE<3*j|GeA<72nGzC#sB{hmlX36MAl=5U!&ZT*AJ}?`} z3fx>pbq`(J57tw=0oQp%awhW#d@t7tYy{P4&29s~p?eJVDyfz=rcSzA⁡%bvi~P z%tZ#_`DPi~>#W)@iYzN~{-VgMvPjj|ps9dv+tR=7%xoTjiJ7Ld`T7%u%(}LFEYtARvl8s-oK&HhFL*eV)Bo%`$Q}fxZC@U5hC0kbyyGrm+ zz&J-#uwQG)=*=Y?M?>Rx*|BWf^?Ka)+%9*W(Bs03CATa;l2SU66I*|Pkq?FMJq+!5 zw&MqV!M&&t=s1YDFFO$z9oMxw9WU-XLPLLG;{LN3ZF1025 Package None - 18.1 + 18.2 Win32 @@ -18,6 +18,11 @@ Base true + + true + Base + true + true Base @@ -28,11 +33,29 @@ Base true + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + true Base true + + true + Cfg_2 + true + true + true Cfg_2 @@ -51,7 +74,7 @@ true true false - _XE7 + _D10_1Brln true 1033 TurboPower LockBox 3 run-time package @@ -63,11 +86,17 @@ package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= Debug + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + - 1033 + 7 + 3 System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) 0 @@ -75,13 +104,32 @@ 0 RELEASE;$(DCC_Define) + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + true + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + 7 + true DEBUG;$(DCC_Define) false + + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + Debug + - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 3 + 7 + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) true diff --git a/LockBox3/packages/D10_1Brln/TP_LockBox3.res b/LockBox3/packages/D10_1Brln/TP_LockBox3.res new file mode 100644 index 0000000000000000000000000000000000000000..f35b41605e7b000b625b6b2cb7ed5e5789354021 GIT binary patch literal 652 zcmZ{i-Acni5QR@_Kr6ZM0le_SYY7-oLC{M5Db!YK=xvEHmSWpTqTtKr)I?@T|TN4iy!M%SFE3Ck}l<~=x&prlVR$AL(x+ICj6Ckp4BpUI8IbDcqdYbOH%U97kRusEb*Hw!uP5%eF$7`|P(w&fw LmSgoFIedUWFzHu{ literal 0 HcmV?d00001 diff --git a/LockBox3/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj b/LockBox3/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj new file mode 100644 index 0000000..c2199ab --- /dev/null +++ b/LockBox3/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj @@ -0,0 +1,72 @@ + + + {DC1BD900-94B2-440B-A5BB-CD3AE245F681} + + + + + + + + + + + + + + + + + Default.Personality.12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/XE6/dclTP_LockBox3.dpk b/LockBox3/packages/D10_1Brln/dclTP_LockBox3.dpk similarity index 91% rename from packages/XE6/dclTP_LockBox3.dpk rename to LockBox3/packages/D10_1Brln/dclTP_LockBox3.dpk index 3a531e9..db681d9 100644 --- a/packages/XE6/dclTP_LockBox3.dpk +++ b/LockBox3/packages/D10_1Brln/dclTP_LockBox3.dpk @@ -1,46 +1,46 @@ -package dclTP_LockBox3; - -{$R *.res} -{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} -{$ALIGN 8} -{$ASSERTIONS ON} -{$BOOLEVAL OFF} -{$DEBUGINFO OFF} -{$EXTENDEDSYNTAX ON} -{$IMPORTEDDATA ON} -{$IOCHECKS ON} -{$LOCALSYMBOLS ON} -{$LONGSTRINGS ON} -{$OPENSTRINGS ON} -{$OPTIMIZATION OFF} -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -{$REFERENCEINFO ON} -{$SAFEDIVIDE OFF} -{$STACKFRAMES ON} -{$TYPEDADDRESS OFF} -{$VARSTRINGCHECKS ON} -{$WRITEABLECONST OFF} -{$MINENUMSIZE 1} -{$IMAGEBASE $400000} -{$DEFINE DEBUG} -{$ENDIF IMPLICITBUILDING} -{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} -{$LIBSUFFIX '_XE6'} -{$DESIGNONLY} -{$IMPLICITBUILD OFF} - -requires - rtl, - designide, - vclie, - vclimg, - TP_LockBox3; - -contains - TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', - TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', - TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, - TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; - -end. +package dclTP_LockBox3; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES ON} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE DEBUG} +{$ENDIF IMPLICITBUILDING} +{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} +{$LIBSUFFIX '_D10_1Brln'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +rrequires + rtl, + designide, + vclie, + vclimg, + TP_LockBox3; + +ocontains + TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', + TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', + TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, + TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; + +d. diff --git a/packages/D10_1Brln/dclTP_LockBox3.dproj b/LockBox3/packages/D10_1Brln/dclTP_LockBox3.dproj similarity index 72% rename from packages/D10_1Brln/dclTP_LockBox3.dproj rename to LockBox3/packages/D10_1Brln/dclTP_LockBox3.dproj index a8f7178..c60f89d 100644 --- a/packages/D10_1Brln/dclTP_LockBox3.dproj +++ b/LockBox3/packages/D10_1Brln/dclTP_LockBox3.dproj @@ -7,7 +7,7 @@ 1025 Package None - 18.1 + 18.2 Win32 @@ -53,11 +53,29 @@ Base true + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + true Base true + + true + Cfg_2 + true + true + true Cfg_2 @@ -77,7 +95,7 @@ true true true - _XE7 + _D10_1Brln true 1033 false @@ -93,6 +111,9 @@ rtl;$(DCC_UsePackage) + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 rtl;TP_LockBox3;$(DCC_UsePackage) @@ -102,11 +123,12 @@ rtl;$(DCC_UsePackage) + 7 + 3 rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) - 1033 Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) rtl;vclimg;vclie;$(DCC_UsePackage) @@ -117,30 +139,38 @@ 0 RELEASE;$(DCC_Define) + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + true + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + 7 + true DEBUG;$(DCC_Define) false + + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + Debug + - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 3 + 7 + CompanyName=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=3.7.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) true MainSource - - - - - - - - -
TPLb_fmComponentAbout
-
- Cfg_2 Base diff --git a/packages/D10_1Brln/dclTP_LockBox3.res b/LockBox3/packages/D10_1Brln/dclTP_LockBox3.res similarity index 100% rename from packages/D10_1Brln/dclTP_LockBox3.res rename to LockBox3/packages/D10_1Brln/dclTP_LockBox3.res diff --git a/packages/XE6/CSharpDemo.dpr b/LockBox3/packages/XE6/CSharpDemo.dpr similarity index 95% rename from packages/XE6/CSharpDemo.dpr rename to LockBox3/packages/XE6/CSharpDemo.dpr index 8156e95..7328abc 100644 --- a/packages/XE6/CSharpDemo.dpr +++ b/LockBox3/packages/XE6/CSharpDemo.dpr @@ -1,15 +1,15 @@ -program CSharpDemo; - -uses - Forms, - uCSharpDemo in '..\..\demo\uCSharpDemo.pas' {mfmCSharpDemo}, - uCSharpZeroPadding in '..\..\demo\uCSharpZeroPadding.pas'; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmCSharpDemo, mfmCSharpDemo); - Application.Run; -end. +program CSharpDemo; + +uses + Forms, + uCSharpDemo in '..\..\demo\uCSharpDemo.pas' {mfmCSharpDemo}, + uCSharpZeroPadding in '..\..\demo\uCSharpZeroPadding.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmCSharpDemo, mfmCSharpDemo); + Application.Run; +end. diff --git a/packages/XE6/LockBox_DUnit_Tests.dpr b/LockBox3/packages/XE6/LockBox_DUnit_Tests.dpr similarity index 97% rename from packages/XE6/LockBox_DUnit_Tests.dpr rename to LockBox3/packages/XE6/LockBox_DUnit_Tests.dpr index bdd8001..177a295 100644 --- a/packages/XE6/LockBox_DUnit_Tests.dpr +++ b/LockBox3/packages/XE6/LockBox_DUnit_Tests.dpr @@ -1,23 +1,23 @@ -program LockBox_DUnit_Tests; - -uses - Forms, - TestFramework, - GUITestRunner, - uLockBox_CipherTestCases in '..\..\unit-tests\dunit\uLockBox_CipherTestCases.pas', - uLockBox_HugeCardinalTestCases in '..\..\unit-tests\dunit\uLockBox_HugeCardinalTestCases.pas', - uLockBox_RSA_TestCases in '..\..\unit-tests\dunit\uLockBox_RSA_TestCases.pas', - uLockBox_Signatory_TestCases in '..\..\unit-tests\dunit\uLockBox_Signatory_TestCases.pas', - uLockBox_Hashes in '..\..\unit-tests\dunit\uLockBox_Hashes.pas', - TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', - uLockBox_OpenSSLTestCases in '..\..\unit-tests\dunit\uLockBox_OpenSSLTestCases.pas', - TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', - uLockBox_TestCases in '..\..\unit-tests\dunit\uLockBox_TestCases.pas', - TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; - -{$R *.res} - -begin -Application.Initialize; -GUITestRunner.RunRegisteredTests -end. +program LockBox_DUnit_Tests; + +uses + Forms, + TestFramework, + GUITestRunner, + uLockBox_CipherTestCases in '..\..\unit-tests\dunit\uLockBox_CipherTestCases.pas', + uLockBox_HugeCardinalTestCases in '..\..\unit-tests\dunit\uLockBox_HugeCardinalTestCases.pas', + uLockBox_RSA_TestCases in '..\..\unit-tests\dunit\uLockBox_RSA_TestCases.pas', + uLockBox_Signatory_TestCases in '..\..\unit-tests\dunit\uLockBox_Signatory_TestCases.pas', + uLockBox_Hashes in '..\..\unit-tests\dunit\uLockBox_Hashes.pas', + TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', + uLockBox_OpenSSLTestCases in '..\..\unit-tests\dunit\uLockBox_OpenSSLTestCases.pas', + TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', + uLockBox_TestCases in '..\..\unit-tests\dunit\uLockBox_TestCases.pas', + TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; + +{$R *.res} + +begin +Application.Initialize; +GUITestRunner.RunRegisteredTests +end. diff --git a/packages/XE6/LockBox_DUnit_Tests.dproj b/LockBox3/packages/XE6/LockBox_DUnit_Tests.dproj similarity index 98% rename from packages/XE6/LockBox_DUnit_Tests.dproj rename to LockBox3/packages/XE6/LockBox_DUnit_Tests.dproj index f0d7ddd..6902c63 100644 --- a/packages/XE6/LockBox_DUnit_Tests.dproj +++ b/LockBox3/packages/XE6/LockBox_DUnit_Tests.dproj @@ -1,149 +1,149 @@ - - - {075D9077-1EE9-4025-AC22-0CE19603E231} - LockBox_DUnit_Tests.dpr - True - Debug - 3 - Application - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - true - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - LockBox_DUnit_Tests - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - ..\..\work-products\exe\XE6\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - true - 1033 - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - false - 1033 - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - ..\..\work-products\exe\XE6\$(Platform) - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - - - 1033 - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - - - - - - - - - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - - - - - LockBox_DUnit_Tests.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - True - - - 12 - - - - + + + {075D9077-1EE9-4025-AC22-0CE19603E231} + LockBox_DUnit_Tests.dpr + True + Debug + 3 + Application + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + LockBox_DUnit_Tests + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + ..\..\work-products\exe\XE6\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + true + 1033 + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + false + 1033 + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + ..\..\work-products\exe\XE6\$(Platform) + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + + + 1033 + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + + + + + + + + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + LockBox_DUnit_Tests.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + True + + + 12 + + + + diff --git a/packages/XE6/LockBox_DUnit_Tests.res b/LockBox3/packages/XE6/LockBox_DUnit_Tests.res similarity index 100% rename from packages/XE6/LockBox_DUnit_Tests.res rename to LockBox3/packages/XE6/LockBox_DUnit_Tests.res diff --git a/packages/XE6/Lockbox3_Demo.dpr b/LockBox3/packages/XE6/Lockbox3_Demo.dpr similarity index 96% rename from packages/XE6/Lockbox3_Demo.dpr rename to LockBox3/packages/XE6/Lockbox3_Demo.dpr index 67484ca..a5cff37 100644 --- a/packages/XE6/Lockbox3_Demo.dpr +++ b/LockBox3/packages/XE6/Lockbox3_Demo.dpr @@ -1,16 +1,16 @@ -program Lockbox3_Demo; - -uses - Forms, - uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas', - umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'LB3 Demo'; - Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); - Application.Run; -end. +program Lockbox3_Demo; + +uses + Forms, + uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas', + umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'LB3 Demo'; + Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); + Application.Run; +end. diff --git a/packages/XE6/Lockbox3_Demo.dproj b/LockBox3/packages/XE6/Lockbox3_Demo.dproj similarity index 98% rename from packages/XE6/Lockbox3_Demo.dproj rename to LockBox3/packages/XE6/Lockbox3_Demo.dproj index 7a064ef..a7c8d2c 100644 --- a/packages/XE6/Lockbox3_Demo.dproj +++ b/LockBox3/packages/XE6/Lockbox3_Demo.dproj @@ -1,117 +1,117 @@ - - - {0AC5B25B-3985-4BFA-BFA3-C75494E90AEA} - Lockbox3_Demo.dpr - True - Debug - 1 - Application - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - Lockbox3_Demo - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - ..\..\work-products\exe\XE6\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - - -
mfmLockbox3_Demo
-
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - Lockbox3_Demo.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {0AC5B25B-3985-4BFA-BFA3-C75494E90AEA} + Lockbox3_Demo.dpr + True + Debug + 1 + Application + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + Lockbox3_Demo + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + ..\..\work-products\exe\XE6\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + + +
mfmLockbox3_Demo
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + Lockbox3_Demo.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE6/Lockbox3_Demo.res b/LockBox3/packages/XE6/Lockbox3_Demo.res similarity index 100% rename from packages/XE6/Lockbox3_Demo.res rename to LockBox3/packages/XE6/Lockbox3_Demo.res diff --git a/packages/XE7/MakeSampleKey.dpr b/LockBox3/packages/XE6/MakeSampleKey.dpr similarity index 96% rename from packages/XE7/MakeSampleKey.dpr rename to LockBox3/packages/XE6/MakeSampleKey.dpr index e0f6984..5d50705 100644 --- a/packages/XE7/MakeSampleKey.dpr +++ b/LockBox3/packages/XE6/MakeSampleKey.dpr @@ -1,16 +1,16 @@ -program MakeSampleKey; - -uses - Forms, - umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Make Sample Key'; - Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); - Application.Run; -end. +program MakeSampleKey; + +uses + Forms, + umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Make Sample Key'; + Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); + Application.Run; +end. diff --git a/packages/XE6/MakeSampleKey.dproj b/LockBox3/packages/XE6/MakeSampleKey.dproj similarity index 98% rename from packages/XE6/MakeSampleKey.dproj rename to LockBox3/packages/XE6/MakeSampleKey.dproj index fe04b6f..66b57f7 100644 --- a/packages/XE6/MakeSampleKey.dproj +++ b/LockBox3/packages/XE6/MakeSampleKey.dproj @@ -1,117 +1,117 @@ - - - {18050D8D-ABCD-4279-8230-875D83702645} - MakeSampleKey.dpr - True - Debug - 1 - Application - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - $(BDS)\bin\default_app.manifest - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - ..\..\work-products\exe\XE6\$(Platform) - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) - MakeSampleKey - 00400000 - false - false - 3081 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - false - false - false - - - $(BDS)\bin\default_app.manifest - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmMakeSampleKey
- dfm -
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - MakeSampleKey.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {18050D8D-ABCD-4279-8230-875D83702645} + MakeSampleKey.dpr + True + Debug + 1 + Application + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + $(BDS)\bin\default_app.manifest + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + ..\..\work-products\exe\XE6\$(Platform) + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + MakeSampleKey + 00400000 + false + false + 3081 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + false + false + false + + + $(BDS)\bin\default_app.manifest + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmMakeSampleKey
+ dfm +
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + MakeSampleKey.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE6/MakeSampleKey.res b/LockBox3/packages/XE6/MakeSampleKey.res similarity index 100% rename from packages/XE6/MakeSampleKey.res rename to LockBox3/packages/XE6/MakeSampleKey.res diff --git a/packages/d2010/Precompute.dpr b/LockBox3/packages/XE6/Precompute.dpr similarity index 95% rename from packages/d2010/Precompute.dpr rename to LockBox3/packages/XE6/Precompute.dpr index d27906c..9649135 100644 --- a/packages/d2010/Precompute.dpr +++ b/LockBox3/packages/XE6/Precompute.dpr @@ -1,15 +1,15 @@ -program Precompute; - -uses - Forms, - umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Precompute'; - Application.CreateForm(TmfmPrecompute, mfmPrecompute); - Application.Run; -end. +program Precompute; + +uses + Forms, + umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Precompute'; + Application.CreateForm(TmfmPrecompute, mfmPrecompute); + Application.Run; +end. diff --git a/packages/XE6/Precompute.dproj b/LockBox3/packages/XE6/Precompute.dproj similarity index 98% rename from packages/XE6/Precompute.dproj rename to LockBox3/packages/XE6/Precompute.dproj index 6062de6..cf7c720 100644 --- a/packages/XE6/Precompute.dproj +++ b/LockBox3/packages/XE6/Precompute.dproj @@ -1,116 +1,116 @@ - - - {2D5A4DB0-5540-4EE9-B68C-64FA43C8E9D5} - Precompute.dpr - True - Debug - 1 - Application - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - Precompute - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - ..\..\work-products\exe\XE6\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmPrecompute
-
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - Precompute.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {2D5A4DB0-5540-4EE9-B68C-64FA43C8E9D5} + Precompute.dpr + True + Debug + 1 + Application + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + Precompute + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + ..\..\work-products\exe\XE6\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmPrecompute
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + Precompute.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE6/Precompute.res b/LockBox3/packages/XE6/Precompute.res similarity index 100% rename from packages/XE6/Precompute.res rename to LockBox3/packages/XE6/Precompute.res diff --git a/packages/d2010/RSA_Encryption_Demo.dpr b/LockBox3/packages/XE6/RSA_Encryption_Demo.dpr similarity index 96% rename from packages/d2010/RSA_Encryption_Demo.dpr rename to LockBox3/packages/XE6/RSA_Encryption_Demo.dpr index 8fbddba..869dfed 100644 --- a/packages/d2010/RSA_Encryption_Demo.dpr +++ b/LockBox3/packages/XE6/RSA_Encryption_Demo.dpr @@ -1,15 +1,15 @@ -program RSA_Encryption_Demo; - -uses - Forms, - umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); - Application.Run; -end. +program RSA_Encryption_Demo; + +uses + Forms, + umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); + Application.Run; +end. diff --git a/packages/XE6/RSA_Encryption_Demo.dproj b/LockBox3/packages/XE6/RSA_Encryption_Demo.dproj similarity index 98% rename from packages/XE6/RSA_Encryption_Demo.dproj rename to LockBox3/packages/XE6/RSA_Encryption_Demo.dproj index e5905db..fa204d4 100644 --- a/packages/XE6/RSA_Encryption_Demo.dproj +++ b/LockBox3/packages/XE6/RSA_Encryption_Demo.dproj @@ -1,115 +1,115 @@ - - - {F05EB12F-6D3A-407D-819C-C9912C72756D} - RSA_Encryption_Demo.dpr - True - Debug - 1 - Application - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - RSA_Encryption_Demo - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - ..\..\work-products\exe\XE6\$(Platform) - false - false - 3081 - - - true - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmRSA_Encryption_Demo
-
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - RSA_Encryption_Demo.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {F05EB12F-6D3A-407D-819C-C9912C72756D} + RSA_Encryption_Demo.dpr + True + Debug + 1 + Application + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + RSA_Encryption_Demo + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + ..\..\work-products\exe\XE6\$(Platform) + false + false + 3081 + + + true + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmRSA_Encryption_Demo
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + RSA_Encryption_Demo.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE6/RSA_Encryption_Demo.res b/LockBox3/packages/XE6/RSA_Encryption_Demo.res similarity index 100% rename from packages/XE6/RSA_Encryption_Demo.res rename to LockBox3/packages/XE6/RSA_Encryption_Demo.res diff --git a/packages/XE6/TP_LockBox3.dpk b/LockBox3/packages/XE6/TP_LockBox3.dpk similarity index 97% rename from packages/XE6/TP_LockBox3.dpk rename to LockBox3/packages/XE6/TP_LockBox3.dpk index f146772..d7e16d7 100644 --- a/packages/XE6/TP_LockBox3.dpk +++ b/LockBox3/packages/XE6/TP_LockBox3.dpk @@ -1,88 +1,88 @@ -package TP_LockBox3; - -{$R *.res} -{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} -{$ALIGN 8} -{$ASSERTIONS ON} -{$BOOLEVAL OFF} -{$DEBUGINFO OFF} -{$EXTENDEDSYNTAX ON} -{$IMPORTEDDATA ON} -{$IOCHECKS ON} -{$LOCALSYMBOLS ON} -{$LONGSTRINGS ON} -{$OPENSTRINGS ON} -{$OPTIMIZATION OFF} -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -{$REFERENCEINFO ON} -{$SAFEDIVIDE OFF} -{$STACKFRAMES ON} -{$TYPEDADDRESS OFF} -{$VARSTRINGCHECKS ON} -{$WRITEABLECONST OFF} -{$MINENUMSIZE 1} -{$IMAGEBASE $400000} -{$DEFINE DEBUG} -{$ENDIF IMPLICITBUILDING} -{$DESCRIPTION 'TurboPower LockBox 3 run-time package'} -{$LIBSUFFIX '_XE6'} -{$RUNONLY} -{$IMPLICITBUILD OFF} - -requires - rtl, - vcl, - vclimg, - dbrtl; - -contains - TPLB3.BlockCipher in '..\..\run\TPLB3.BlockCipher.pas', - TPLB3.StreamUtils in '..\..\run\TPLB3.StreamUtils.pas', - TPLB3.StreamCipher in '..\..\run\TPLB3.StreamCipher.pas', - TPLB3.CryptographicLibrary in '..\..\run\TPLB3.CryptographicLibrary.pas', - TPLB3.BaseNonVisualComponent in '..\..\run\TPLB3.BaseNonVisualComponent.pas', - TPLB3.Codec in '..\..\run\TPLB3.Codec.pas', - TPLB3.ECB in '..\..\run\TPLB3.ECB.pas', - TPLB3.CBC in '..\..\run\TPLB3.CBC.pas', - TPLB3.PCBC in '..\..\run\TPLB3.PCBC.pas', - TPLB3.CFB_Block in '..\..\run\TPLB3.CFB_Block.pas', - TPLB3.CFB_8Bit in '..\..\run\TPLB3.CFB_8Bit.pas', - TPLB3.OFB in '..\..\run\TPLB3.OFB.pas', - TPLB3.CTR in '..\..\run\TPLB3.CTR.pas', - TPLB3.HashDsc in '..\..\run\TPLB3.HashDsc.pas', - TPLB3.SHA1 in '..\..\run\TPLB3.SHA1.pas', - TPLB3.BinaryUtils in '..\..\run\TPLB3.BinaryUtils.pas', - TPLB3.Hash in '..\..\run\TPLB3.Hash.pas', - TPLB3.MD5 in '..\..\run\TPLB3.MD5.pas', - TPLB3.Random in '..\..\run\TPLB3.Random.pas', - TPLB3.StreamToBlock in '..\..\run\TPLB3.StreamToBlock.pas', - TPLB3.Base64 in '..\..\run\TPLB3.Base64.pas', - TPLB3.CipherUtils in '..\..\run\TPLB3.CipherUtils.pas', - TPLB3.AES in '..\..\run\TPLB3.AES.pas', - TPLB3.PointerArithmetic in '..\..\run\TPLB3.PointerArithmetic.pas', - TPLB3.HugeCardinal in '..\..\run\TPLB3.HugeCardinal.pas', - TPLB3.IntegerUtils in '..\..\run\TPLB3.IntegerUtils.pas', - TPLB3.HugeCardinalUtils in '..\..\run\TPLB3.HugeCardinalUtils.pas', - TPLB3.MemoryStreamPool in '..\..\run\TPLB3.MemoryStreamPool.pas', - TPLB3.RSA_Primitives in '..\..\run\TPLB3.RSA_Primitives.pas', - TPLB3.RSA_Engine in '..\..\run\TPLB3.RSA_Engine.pas', - TPLB3.Asymetric in '..\..\run\TPLB3.Asymetric.pas', - TPLB3.Signatory in '..\..\run\TPLB3.Signatory.pas', - TPLB3.CodecIntf in '..\..\run\TPLB3.CodecIntf.pas', - TPLB3.Constants in '..\..\run\TPLB3.Constants.pas', - TPLB3.I18n in '..\..\run\TPLB3.I18n.pas', - TPLB3.SimpleBlockCipher in '..\..\run\TPLB3.SimpleBlockCipher.pas', - TPLB3.DES in '..\..\run\TPLB3.DES.pas', - TPLB3.TDES in '..\..\run\TPLB3.TDES.pas', - TPLB3.BlowFish in '..\..\run\TPLB3.BlowFish.pas', - TPLB3.Decorators in '..\..\run\TPLB3.Decorators.pas', - TPLB3.DCP.twofish_Modified in '..\..\run\TPLB3.DCP.twofish_Modified.pas', - TPLB3.TwoFish in '..\..\run\TPLB3.TwoFish.pas', - TPLB3.XXTEA in '..\..\run\TPLB3.XXTEA.pas', - TPLB3.SHA2 in '..\..\run\TPLB3.SHA2.pas', - TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', - TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', - TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; - -end. +package TP_LockBox3; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES ON} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE DEBUG} +{$ENDIF IMPLICITBUILDING} +{$DESCRIPTION 'TurboPower LockBox 3 run-time package'} +{$LIBSUFFIX '_XE6'} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + vcl, + vclimg, + dbrtl; + +contains + TPLB3.BlockCipher in '..\..\run\TPLB3.BlockCipher.pas', + TPLB3.StreamUtils in '..\..\run\TPLB3.StreamUtils.pas', + TPLB3.StreamCipher in '..\..\run\TPLB3.StreamCipher.pas', + TPLB3.CryptographicLibrary in '..\..\run\TPLB3.CryptographicLibrary.pas', + TPLB3.BaseNonVisualComponent in '..\..\run\TPLB3.BaseNonVisualComponent.pas', + TPLB3.Codec in '..\..\run\TPLB3.Codec.pas', + TPLB3.ECB in '..\..\run\TPLB3.ECB.pas', + TPLB3.CBC in '..\..\run\TPLB3.CBC.pas', + TPLB3.PCBC in '..\..\run\TPLB3.PCBC.pas', + TPLB3.CFB_Block in '..\..\run\TPLB3.CFB_Block.pas', + TPLB3.CFB_8Bit in '..\..\run\TPLB3.CFB_8Bit.pas', + TPLB3.OFB in '..\..\run\TPLB3.OFB.pas', + TPLB3.CTR in '..\..\run\TPLB3.CTR.pas', + TPLB3.HashDsc in '..\..\run\TPLB3.HashDsc.pas', + TPLB3.SHA1 in '..\..\run\TPLB3.SHA1.pas', + TPLB3.BinaryUtils in '..\..\run\TPLB3.BinaryUtils.pas', + TPLB3.Hash in '..\..\run\TPLB3.Hash.pas', + TPLB3.MD5 in '..\..\run\TPLB3.MD5.pas', + TPLB3.Random in '..\..\run\TPLB3.Random.pas', + TPLB3.StreamToBlock in '..\..\run\TPLB3.StreamToBlock.pas', + TPLB3.Base64 in '..\..\run\TPLB3.Base64.pas', + TPLB3.CipherUtils in '..\..\run\TPLB3.CipherUtils.pas', + TPLB3.AES in '..\..\run\TPLB3.AES.pas', + TPLB3.PointerArithmetic in '..\..\run\TPLB3.PointerArithmetic.pas', + TPLB3.HugeCardinal in '..\..\run\TPLB3.HugeCardinal.pas', + TPLB3.IntegerUtils in '..\..\run\TPLB3.IntegerUtils.pas', + TPLB3.HugeCardinalUtils in '..\..\run\TPLB3.HugeCardinalUtils.pas', + TPLB3.MemoryStreamPool in '..\..\run\TPLB3.MemoryStreamPool.pas', + TPLB3.RSA_Primitives in '..\..\run\TPLB3.RSA_Primitives.pas', + TPLB3.RSA_Engine in '..\..\run\TPLB3.RSA_Engine.pas', + TPLB3.Asymetric in '..\..\run\TPLB3.Asymetric.pas', + TPLB3.Signatory in '..\..\run\TPLB3.Signatory.pas', + TPLB3.CodecIntf in '..\..\run\TPLB3.CodecIntf.pas', + TPLB3.Constants in '..\..\run\TPLB3.Constants.pas', + TPLB3.I18n in '..\..\run\TPLB3.I18n.pas', + TPLB3.SimpleBlockCipher in '..\..\run\TPLB3.SimpleBlockCipher.pas', + TPLB3.DES in '..\..\run\TPLB3.DES.pas', + TPLB3.TDES in '..\..\run\TPLB3.TDES.pas', + TPLB3.BlowFish in '..\..\run\TPLB3.BlowFish.pas', + TPLB3.Decorators in '..\..\run\TPLB3.Decorators.pas', + TPLB3.DCP.twofish_Modified in '..\..\run\TPLB3.DCP.twofish_Modified.pas', + TPLB3.TwoFish in '..\..\run\TPLB3.TwoFish.pas', + TPLB3.XXTEA in '..\..\run\TPLB3.XXTEA.pas', + TPLB3.SHA2 in '..\..\run\TPLB3.SHA2.pas', + TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', + TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', + TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; + +end. diff --git a/packages/XE6/TP_LockBox3.dproj b/LockBox3/packages/XE6/TP_LockBox3.dproj similarity index 98% rename from packages/XE6/TP_LockBox3.dproj rename to LockBox3/packages/XE6/TP_LockBox3.dproj index ad62609..e4ac833 100644 --- a/packages/XE6/TP_LockBox3.dproj +++ b/LockBox3/packages/XE6/TP_LockBox3.dproj @@ -1,208 +1,208 @@ - - - {BFB30971-26C9-49E7-8275-3614C28BF9EB} - TP_LockBox3.dpk - True - Debug - 3 - Package - VCL - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - true - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - 00400000 - false - 5 - 3 - _XE6 - TP_LockBox3 - 3081 - true - false - true - CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - true - true - false - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - false - false - true - TurboPower LockBox 3 run-time package - - - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - Debug - - - 1033 - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - 0 - 1 - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - - - false - 0 - RELEASE;$(DCC_Define) - 0 - - - true - false - DEBUG;$(DCC_Define) - - - false - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.0.0;Comments= - - - 0 - 1 - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - false - - - - MainSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - Package - - - - TP_LockBox3.dpk - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - False - False - False - True - True - - - 12 - - - - + + + {BFB30971-26C9-49E7-8275-3614C28BF9EB} + TP_LockBox3.dpk + True + Debug + 3 + Package + VCL + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + 00400000 + false + 5 + 3 + _XE6 + TP_LockBox3 + 3081 + true + false + true + CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + true + true + false + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + false + false + true + TurboPower LockBox 3 run-time package + + + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + Debug + + + 1033 + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + 1 + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + + + false + 0 + RELEASE;$(DCC_Define) + 0 + + + true + false + DEBUG;$(DCC_Define) + + + false + 6 + 1033 + CompanyName=;FileDescription=;FileVersion=3.6.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.0.0;Comments= + + + 0 + 1 + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + false + + + + MainSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + Package + + + + TP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + False + False + False + True + True + + + 12 + + + + diff --git a/packages/XE6/TP_LockBox3.res b/LockBox3/packages/XE6/TP_LockBox3.res similarity index 100% rename from packages/XE6/TP_LockBox3.res rename to LockBox3/packages/XE6/TP_LockBox3.res diff --git a/packages/XE6/TP_LockBox3_XE6.groupproj b/LockBox3/packages/XE6/TP_LockBox3_XE6.groupproj similarity index 97% rename from packages/XE6/TP_LockBox3_XE6.groupproj rename to LockBox3/packages/XE6/TP_LockBox3_XE6.groupproj index a784bcc..2166023 100644 --- a/packages/XE6/TP_LockBox3_XE6.groupproj +++ b/LockBox3/packages/XE6/TP_LockBox3_XE6.groupproj @@ -1,108 +1,108 @@ - - - {CD35A969-3EE9-444D-8433-F317BE3BC706} - - - - - - - - - - - - - - - - - - - - - - - - - - Default.Personality.12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {CD35A969-3EE9-444D-8433-F317BE3BC706} + + + + + + + + + + + + + + + + + + + + + + + + + + Default.Personality.12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/D10_1Brln/dclTP_LockBox3.dpk b/LockBox3/packages/XE6/dclTP_LockBox3.dpk similarity index 98% rename from packages/D10_1Brln/dclTP_LockBox3.dpk rename to LockBox3/packages/XE6/dclTP_LockBox3.dpk index 3c6cef8..4096461 100644 --- a/packages/D10_1Brln/dclTP_LockBox3.dpk +++ b/LockBox3/packages/XE6/dclTP_LockBox3.dpk @@ -26,7 +26,7 @@ package dclTP_LockBox3; {$DEFINE DEBUG} {$ENDIF IMPLICITBUILDING} {$DESCRIPTION 'TurboPower LockBox 3 design-time package'} -{$LIBSUFFIX '_XE7'} +{$LIBSUFFIX '_XE6'} {$DESIGNONLY} {$IMPLICITBUILD OFF} diff --git a/packages/XE6/dclTP_LockBox3.dproj b/LockBox3/packages/XE6/dclTP_LockBox3.dproj similarity index 98% rename from packages/XE6/dclTP_LockBox3.dproj rename to LockBox3/packages/XE6/dclTP_LockBox3.dproj index cbd7031..a8251f5 100644 --- a/packages/XE6/dclTP_LockBox3.dproj +++ b/LockBox3/packages/XE6/dclTP_LockBox3.dproj @@ -1,181 +1,181 @@ - - - {FB4472D9-9E7C-4B3E-8D95-E12BB9426246} - dclTP_LockBox3.dpk - True - Debug - 1 - Package - None - 15.4 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - true - System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;System.Win;$(DCC_Namespace) - 00400000 - false - 5 - 3 - _XE6 - dclTP_LockBox3 - 3081 - true - false - true - CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - true - false - true - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - false - false - true - TurboPower LockBox 3 design-time package - - - rtl;$(DCC_UsePackage) - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - Debug - - - rtl;$(DCC_UsePackage) - - - rtl;$(DCC_UsePackage) - - - rtl;$(DCC_UsePackage) - - - rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) - Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - 1033 - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) - - - false - 0 - RELEASE;$(DCC_Define) - 0 - - - true - false - DEBUG;$(DCC_Define) - - - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.0.0;Comments= - - - - MainSource - - - - - - - - - -
TPLb_fmComponentAbout
-
- - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - Package - - - - dclTP_LockBox3.dpk - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - False - False - False - False - True - False - - - 12 - - - -
+ + + {FB4472D9-9E7C-4B3E-8D95-E12BB9426246} + dclTP_LockBox3.dpk + True + Debug + 1 + Package + None + 15.4 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;System.Win;$(DCC_Namespace) + 00400000 + false + 5 + 3 + _XE6 + dclTP_LockBox3 + 3081 + true + false + true + CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + true + false + true + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + false + false + true + TurboPower LockBox 3 design-time package + + + rtl;$(DCC_UsePackage) + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + Debug + + + rtl;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) + + + false + 0 + RELEASE;$(DCC_Define) + 0 + + + true + false + DEBUG;$(DCC_Define) + + + 6 + 1033 + CompanyName=;FileDescription=;FileVersion=3.6.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.0.0;Comments= + + + + MainSource + + + + + + + + + +
TPLb_fmComponentAbout
+
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Package + + + + dclTP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + False + False + False + False + True + False + + + 12 + + + +
diff --git a/packages/XE6/dclTP_LockBox3.res b/LockBox3/packages/XE6/dclTP_LockBox3.res similarity index 100% rename from packages/XE6/dclTP_LockBox3.res rename to LockBox3/packages/XE6/dclTP_LockBox3.res diff --git a/packages/XE7/CSharpDemo.dpr b/LockBox3/packages/XE7/CSharpDemo.dpr similarity index 95% rename from packages/XE7/CSharpDemo.dpr rename to LockBox3/packages/XE7/CSharpDemo.dpr index 8156e95..7328abc 100644 --- a/packages/XE7/CSharpDemo.dpr +++ b/LockBox3/packages/XE7/CSharpDemo.dpr @@ -1,15 +1,15 @@ -program CSharpDemo; - -uses - Forms, - uCSharpDemo in '..\..\demo\uCSharpDemo.pas' {mfmCSharpDemo}, - uCSharpZeroPadding in '..\..\demo\uCSharpZeroPadding.pas'; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmCSharpDemo, mfmCSharpDemo); - Application.Run; -end. +program CSharpDemo; + +uses + Forms, + uCSharpDemo in '..\..\demo\uCSharpDemo.pas' {mfmCSharpDemo}, + uCSharpZeroPadding in '..\..\demo\uCSharpZeroPadding.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmCSharpDemo, mfmCSharpDemo); + Application.Run; +end. diff --git a/packages/XE7/LockBox_DUnit_Tests.dpr b/LockBox3/packages/XE7/LockBox_DUnit_Tests.dpr similarity index 97% rename from packages/XE7/LockBox_DUnit_Tests.dpr rename to LockBox3/packages/XE7/LockBox_DUnit_Tests.dpr index bdd8001..177a295 100644 --- a/packages/XE7/LockBox_DUnit_Tests.dpr +++ b/LockBox3/packages/XE7/LockBox_DUnit_Tests.dpr @@ -1,23 +1,23 @@ -program LockBox_DUnit_Tests; - -uses - Forms, - TestFramework, - GUITestRunner, - uLockBox_CipherTestCases in '..\..\unit-tests\dunit\uLockBox_CipherTestCases.pas', - uLockBox_HugeCardinalTestCases in '..\..\unit-tests\dunit\uLockBox_HugeCardinalTestCases.pas', - uLockBox_RSA_TestCases in '..\..\unit-tests\dunit\uLockBox_RSA_TestCases.pas', - uLockBox_Signatory_TestCases in '..\..\unit-tests\dunit\uLockBox_Signatory_TestCases.pas', - uLockBox_Hashes in '..\..\unit-tests\dunit\uLockBox_Hashes.pas', - TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', - uLockBox_OpenSSLTestCases in '..\..\unit-tests\dunit\uLockBox_OpenSSLTestCases.pas', - TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', - uLockBox_TestCases in '..\..\unit-tests\dunit\uLockBox_TestCases.pas', - TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; - -{$R *.res} - -begin -Application.Initialize; -GUITestRunner.RunRegisteredTests -end. +program LockBox_DUnit_Tests; + +uses + Forms, + TestFramework, + GUITestRunner, + uLockBox_CipherTestCases in '..\..\unit-tests\dunit\uLockBox_CipherTestCases.pas', + uLockBox_HugeCardinalTestCases in '..\..\unit-tests\dunit\uLockBox_HugeCardinalTestCases.pas', + uLockBox_RSA_TestCases in '..\..\unit-tests\dunit\uLockBox_RSA_TestCases.pas', + uLockBox_Signatory_TestCases in '..\..\unit-tests\dunit\uLockBox_Signatory_TestCases.pas', + uLockBox_Hashes in '..\..\unit-tests\dunit\uLockBox_Hashes.pas', + TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', + uLockBox_OpenSSLTestCases in '..\..\unit-tests\dunit\uLockBox_OpenSSLTestCases.pas', + TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', + uLockBox_TestCases in '..\..\unit-tests\dunit\uLockBox_TestCases.pas', + TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; + +{$R *.res} + +begin +Application.Initialize; +GUITestRunner.RunRegisteredTests +end. diff --git a/packages/XE7/LockBox_DUnit_Tests.dproj b/LockBox3/packages/XE7/LockBox_DUnit_Tests.dproj similarity index 98% rename from packages/XE7/LockBox_DUnit_Tests.dproj rename to LockBox3/packages/XE7/LockBox_DUnit_Tests.dproj index 109f9a6..183fc0a 100644 --- a/packages/XE7/LockBox_DUnit_Tests.dproj +++ b/LockBox3/packages/XE7/LockBox_DUnit_Tests.dproj @@ -1,150 +1,150 @@ - - - {075D9077-1EE9-4025-AC22-0CE19603E231} - LockBox_DUnit_Tests.dpr - True - Debug - 3 - Application - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) - true - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - LockBox_DUnit_Tests - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - ..\..\work-products\exe\XE7\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - true - 1033 - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - false - 1033 - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - ..\..\work-products\exe\XE7\$(Platform) - ..\..\work-products\ephemeral\dcu\XE6\$(Platform) - - - 1033 - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - - - - - - - - - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - - - - - LockBox_DUnit_Tests.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - True - - - 12 - - - - + + + {075D9077-1EE9-4025-AC22-0CE19603E231} + LockBox_DUnit_Tests.dpr + True + Debug + 3 + Application + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) + true + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + LockBox_DUnit_Tests + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + ..\..\work-products\exe\XE7\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + true + 1033 + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + false + 1033 + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + ..\..\work-products\exe\XE7\$(Platform) + ..\..\work-products\ephemeral\dcu\XE6\$(Platform) + + + 1033 + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + + + + + + + + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + + + + + LockBox_DUnit_Tests.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + True + + + 12 + + + + diff --git a/packages/XE7/LockBox_DUnit_Tests.res b/LockBox3/packages/XE7/LockBox_DUnit_Tests.res similarity index 100% rename from packages/XE7/LockBox_DUnit_Tests.res rename to LockBox3/packages/XE7/LockBox_DUnit_Tests.res diff --git a/LockBox3/packages/XE7/Lockbox3_Demo.dpr b/LockBox3/packages/XE7/Lockbox3_Demo.dpr new file mode 100644 index 0000000..f22cc07 --- /dev/null +++ b/LockBox3/packages/XE7/Lockbox3_Demo.dpr @@ -0,0 +1,16 @@ +program Lockbox3_Demo; + +uses + Forms, + umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}, + uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'LB3 Demo'; + Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); + Application.Run; +end. diff --git a/packages/XE7/Lockbox3_Demo.dproj b/LockBox3/packages/XE7/Lockbox3_Demo.dproj similarity index 97% rename from packages/XE7/Lockbox3_Demo.dproj rename to LockBox3/packages/XE7/Lockbox3_Demo.dproj index e2443ab..5e907ca 100644 --- a/packages/XE7/Lockbox3_Demo.dproj +++ b/LockBox3/packages/XE7/Lockbox3_Demo.dproj @@ -1,460 +1,460 @@ - - - {0AC5B25B-3985-4BFA-BFA3-C75494E90AEA} - Lockbox3_Demo.dpr - True - Debug - 1 - Application - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - Lockbox3_Demo - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - ..\..\work-products\exe\XE7\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - 6 - 3 - 3 - true - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmLockbox3_Demo
-
- - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - Lockbox3_Demo.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - - - Lockbox3_Demo.exe - true - - - - - 1 - .dylib - - - 0 - .bpl - - - Contents\MacOS - 1 - .dylib - - - 1 - .dylib - - - - - 1 - .dylib - - - 0 - .dll;.bpl - - - Contents\MacOS - 1 - .dylib - - - 1 - .dylib - - - - - 1 - - - 1 - - - - - Contents - 1 - - - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - res\drawable-normal - 1 - - - - - library\lib\x86 - 1 - - - - - 1 - - - 1 - - - - - ../ - 1 - - - - - library\lib\armeabi-v7a - 1 - - - - - 1 - - - 1 - - - - - res\drawable-xlarge - 1 - - - - - res\drawable-xhdpi - 1 - - - - - 1 - - - 1 - - - - - res\drawable-xxhdpi - 1 - - - - - library\lib\mips - 1 - - - - - res\drawable - 1 - - - - - Contents\MacOS - 1 - - - 1 - - - 0 - - - - - Contents\MacOS - 1 - .framework - - - 0 - - - - - res\drawable-small - 1 - - - - - ../ - 1 - - - - - Contents\MacOS - 1 - - - 1 - - - Contents\MacOS - 0 - - - - - classes - 1 - - - - - 1 - - - 1 - - - - - 1 - - - 1 - - - - - res\drawable - 1 - - - - - Contents\Resources - 1 - - - - - 1 - - - - - 1 - - - 1 - - - - - 1 - - - library\lib\armeabi-v7a - 1 - - - 0 - - - Contents\MacOS - 1 - - - 1 - - - - - library\lib\armeabi - 1 - - - - - res\drawable-large - 1 - - - - - 0 - - - 0 - - - 0 - - - Contents\MacOS - 0 - - - 0 - - - - - 1 - - - 1 - - - - - res\drawable-ldpi - 1 - - - - - res\values - 1 - - - - - 1 - - - 1 - - - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - - - 1 - - - - - - - - - - - 12 - - - - -
+ + + {0AC5B25B-3985-4BFA-BFA3-C75494E90AEA} + Lockbox3_Demo.dpr + True + Debug + 1 + Application + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + Lockbox3_Demo + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + ..\..\work-products\exe\XE7\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + 6 + 3 + 3 + true + 1033 + CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmLockbox3_Demo
+
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + Lockbox3_Demo.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + + + Lockbox3_Demo.exe + true + + + + + 1 + .dylib + + + 0 + .bpl + + + Contents\MacOS + 1 + .dylib + + + 1 + .dylib + + + + + 1 + .dylib + + + 0 + .dll;.bpl + + + Contents\MacOS + 1 + .dylib + + + 1 + .dylib + + + + + 1 + + + 1 + + + + + Contents + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + res\drawable-normal + 1 + + + + + library\lib\x86 + 1 + + + + + 1 + + + 1 + + + + + ../ + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + res\drawable-xlarge + 1 + + + + + res\drawable-xhdpi + 1 + + + + + 1 + + + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + library\lib\mips + 1 + + + + + res\drawable + 1 + + + + + Contents\MacOS + 1 + + + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + res\drawable-small + 1 + + + + + ../ + 1 + + + + + Contents\MacOS + 1 + + + 1 + + + Contents\MacOS + 0 + + + + + classes + 1 + + + + + 1 + + + 1 + + + + + 1 + + + 1 + + + + + res\drawable + 1 + + + + + Contents\Resources + 1 + + + + + 1 + + + + + 1 + + + 1 + + + + + 1 + + + library\lib\armeabi-v7a + 1 + + + 0 + + + Contents\MacOS + 1 + + + 1 + + + + + library\lib\armeabi + 1 + + + + + res\drawable-large + 1 + + + + + 0 + + + 0 + + + 0 + + + Contents\MacOS + 0 + + + 0 + + + + + 1 + + + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\values + 1 + + + + + 1 + + + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + 1 + + + + + + + + + + + 12 + + + + +
diff --git a/packages/XE7/Lockbox3_Demo.res b/LockBox3/packages/XE7/Lockbox3_Demo.res similarity index 100% rename from packages/XE7/Lockbox3_Demo.res rename to LockBox3/packages/XE7/Lockbox3_Demo.res diff --git a/packages/d2010/MakeSampleKey.dpr b/LockBox3/packages/XE7/MakeSampleKey.dpr similarity index 96% rename from packages/d2010/MakeSampleKey.dpr rename to LockBox3/packages/XE7/MakeSampleKey.dpr index e0f6984..5d50705 100644 --- a/packages/d2010/MakeSampleKey.dpr +++ b/LockBox3/packages/XE7/MakeSampleKey.dpr @@ -1,16 +1,16 @@ -program MakeSampleKey; - -uses - Forms, - umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Make Sample Key'; - Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); - Application.Run; -end. +program MakeSampleKey; + +uses + Forms, + umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Make Sample Key'; + Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); + Application.Run; +end. diff --git a/packages/XE7/MakeSampleKey.dproj b/LockBox3/packages/XE7/MakeSampleKey.dproj similarity index 98% rename from packages/XE7/MakeSampleKey.dproj rename to LockBox3/packages/XE7/MakeSampleKey.dproj index 97d429f..fd8052a 100644 --- a/packages/XE7/MakeSampleKey.dproj +++ b/LockBox3/packages/XE7/MakeSampleKey.dproj @@ -1,119 +1,119 @@ - - - {18050D8D-ABCD-4279-8230-875D83702645} - MakeSampleKey.dpr - True - Debug - 1 - Application - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) - $(BDS)\bin\default_app.manifest - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - ..\..\work-products\exe\XE7\$(Platform) - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) - MakeSampleKey - 00400000 - false - false - 3081 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - false - false - false - - - $(BDS)\bin\default_app.manifest - Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - true - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmMakeSampleKey
- dfm -
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - MakeSampleKey.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {18050D8D-ABCD-4279-8230-875D83702645} + MakeSampleKey.dpr + True + Debug + 1 + Application + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) + $(BDS)\bin\default_app.manifest + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + ..\..\work-products\exe\XE7\$(Platform) + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + MakeSampleKey + 00400000 + false + false + 3081 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + false + false + false + + + $(BDS)\bin\default_app.manifest + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + true + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmMakeSampleKey
+ dfm +
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + MakeSampleKey.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE7/MakeSampleKey.res b/LockBox3/packages/XE7/MakeSampleKey.res similarity index 100% rename from packages/XE7/MakeSampleKey.res rename to LockBox3/packages/XE7/MakeSampleKey.res diff --git a/packages/XE7/Precompute.dpr b/LockBox3/packages/XE7/Precompute.dpr similarity index 95% rename from packages/XE7/Precompute.dpr rename to LockBox3/packages/XE7/Precompute.dpr index d27906c..9649135 100644 --- a/packages/XE7/Precompute.dpr +++ b/LockBox3/packages/XE7/Precompute.dpr @@ -1,15 +1,15 @@ -program Precompute; - -uses - Forms, - umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Precompute'; - Application.CreateForm(TmfmPrecompute, mfmPrecompute); - Application.Run; -end. +program Precompute; + +uses + Forms, + umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Precompute'; + Application.CreateForm(TmfmPrecompute, mfmPrecompute); + Application.Run; +end. diff --git a/packages/XE7/Precompute.dproj b/LockBox3/packages/XE7/Precompute.dproj similarity index 98% rename from packages/XE7/Precompute.dproj rename to LockBox3/packages/XE7/Precompute.dproj index f9e3121..cba95b9 100644 --- a/packages/XE7/Precompute.dproj +++ b/LockBox3/packages/XE7/Precompute.dproj @@ -1,118 +1,118 @@ - - - {2D5A4DB0-5540-4EE9-B68C-64FA43C8E9D5} - Precompute.dpr - True - Debug - 1 - Application - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - Precompute - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - ..\..\work-products\exe\XE7\$(Platform) - false - false - 3081 - - - $(BDS)\bin\default_app.manifest - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - true - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - ..\..\work-products\exe\XE7\$(Platform) - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmPrecompute
-
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - Precompute.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {2D5A4DB0-5540-4EE9-B68C-64FA43C8E9D5} + Precompute.dpr + True + Debug + 1 + Application + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + Precompute + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + ..\..\work-products\exe\XE7\$(Platform) + false + false + 3081 + + + $(BDS)\bin\default_app.manifest + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + ..\..\work-products\exe\XE7\$(Platform) + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmPrecompute
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + Precompute.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE7/Precompute.res b/LockBox3/packages/XE7/Precompute.res similarity index 100% rename from packages/XE7/Precompute.res rename to LockBox3/packages/XE7/Precompute.res diff --git a/packages/XE6/RSA_Encryption_Demo.dpr b/LockBox3/packages/XE7/RSA_Encryption_Demo.dpr similarity index 96% rename from packages/XE6/RSA_Encryption_Demo.dpr rename to LockBox3/packages/XE7/RSA_Encryption_Demo.dpr index 8fbddba..869dfed 100644 --- a/packages/XE6/RSA_Encryption_Demo.dpr +++ b/LockBox3/packages/XE7/RSA_Encryption_Demo.dpr @@ -1,15 +1,15 @@ -program RSA_Encryption_Demo; - -uses - Forms, - umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); - Application.Run; -end. +program RSA_Encryption_Demo; + +uses + Forms, + umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); + Application.Run; +end. diff --git a/packages/XE7/RSA_Encryption_Demo.dproj b/LockBox3/packages/XE7/RSA_Encryption_Demo.dproj similarity index 98% rename from packages/XE7/RSA_Encryption_Demo.dproj rename to LockBox3/packages/XE7/RSA_Encryption_Demo.dproj index b5f4384..505d5da 100644 --- a/packages/XE7/RSA_Encryption_Demo.dproj +++ b/LockBox3/packages/XE7/RSA_Encryption_Demo.dproj @@ -1,116 +1,116 @@ - - - {F05EB12F-6D3A-407D-819C-C9912C72756D} - RSA_Encryption_Demo.dpr - True - Debug - 1 - Application - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - $(BDS)\bin\default_app.manifest - RSA_Encryption_Demo - false - false - 00400000 - false - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - ..\..\work-products\exe\XE7\$(Platform) - false - false - 3081 - - - true - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - 1033 - - - 0 - false - RELEASE;$(DCC_Define) - 0 - - - true - DEBUG;$(DCC_Define) - false - - - ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) - true - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - - MainSource - - -
mfmRSA_Encryption_Demo
-
- - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - - - - - RSA_Encryption_Demo.dpr - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - - - 12 - - - -
+ + + {F05EB12F-6D3A-407D-819C-C9912C72756D} + RSA_Encryption_Demo.dpr + True + Debug + 1 + Application + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + $(BDS)\bin\default_app.manifest + RSA_Encryption_Demo + false + false + 00400000 + false + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + ..\..\work-products\exe\XE7\$(Platform) + false + false + 3081 + + + true + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 1033 + + + 0 + false + RELEASE;$(DCC_Define) + 0 + + + true + DEBUG;$(DCC_Define) + false + + + ..\..\work-products\ephemeral\dcu\XE7\$(Platform);$(DCC_UnitSearchPath) + true + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + + + + MainSource + + +
mfmRSA_Encryption_Demo
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + + + + + RSA_Encryption_Demo.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + + + 12 + + + +
diff --git a/packages/XE7/RSA_Encryption_Demo.res b/LockBox3/packages/XE7/RSA_Encryption_Demo.res similarity index 100% rename from packages/XE7/RSA_Encryption_Demo.res rename to LockBox3/packages/XE7/RSA_Encryption_Demo.res diff --git a/packages/D10_1Brln/TP_LockBox3.dpk b/LockBox3/packages/XE7/TP_LockBox3.dpk similarity index 100% rename from packages/D10_1Brln/TP_LockBox3.dpk rename to LockBox3/packages/XE7/TP_LockBox3.dpk diff --git a/packages/XE7/TP_LockBox3.dproj b/LockBox3/packages/XE7/TP_LockBox3.dproj similarity index 93% rename from packages/XE7/TP_LockBox3.dproj rename to LockBox3/packages/XE7/TP_LockBox3.dproj index 0ce6090..69bc207 100644 --- a/packages/XE7/TP_LockBox3.dproj +++ b/LockBox3/packages/XE7/TP_LockBox3.dproj @@ -1,588 +1,582 @@ - - - {BFB30971-26C9-49E7-8275-3614C28BF9EB} - TP_LockBox3.dpk - True - Debug - 19 - Package - VCL - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Cfg_1 - true - true - - - true - Cfg_1 - true - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - - - Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) - 00400000 - false - 5 - 3 - _XE7 - TP_LockBox3 - 3081 - true - false - true - CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= - true - true - false - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - false - false - true - TurboPower LockBox 3 run-time package - - - 3 - false - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.6.1.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - Debug - - - $(MSBuildProjectName) - iPhoneAndiPad - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist - Debug - - - iPhoneAndiPad - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist - - - 1 - 6 - 1033 - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments= - - - 1 - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments= - System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - - - false - 0 - RELEASE;$(DCC_Define) - 0 - - - 3 - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.6.1.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - - - 1 - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments= - - - 1 - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments= - - - true - false - DEBUG;$(DCC_Define) - - - 3 - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.6.1.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - - - true - - - true - - - 3 - false - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= - - - 1 - 6 - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments= - false - - - - MainSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - - - - Delphi.Personality.12 - Package - - - - TP_LockBox3.dpk - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - True - False - False - True - True - - - - - TP_LockBox3.bpl - true - - - - - 1 - .dylib - - - 0 - .bpl - - - 1 - .dylib - - - 1 - .dylib - - - - - 1 - .dylib - - - 0 - .dll;.bpl - - - - - 1 - - - 1 - - - - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - res\drawable-normal - 1 - - - - - library\lib\x86 - 1 - - - - - 1 - - - 1 - - - - - - library\lib\armeabi-v7a - 1 - - - - - 1 - - - 1 - - - - - res\drawable-xlarge - 1 - - - - - res\drawable-xhdpi - 1 - - - - - 1 - - - 1 - - - - - res\drawable-xxhdpi - 1 - - - - - library\lib\mips - 1 - - - - - res\drawable - 1 - - - - - 1 - - - 1 - - - 0 - - - - - 1 - .framework - - - 0 - - - - - res\drawable-small - 1 - - - - - - 1 - - - Contents\MacOS - 0 - - - - - classes - 1 - - - - - - 1 - - - 1 - - - - - res\drawable - 1 - - - - - Contents\Resources - 1 - - - - - - 1 - - - 1 - - - - - 1 - - - library\lib\armeabi-v7a - 1 - - - 0 - - - 1 - - - 1 - - - - - library\lib\armeabi - 1 - - - - - res\drawable-large - 1 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 1 - - - 1 - - - - - res\drawable-ldpi - 1 - - - - - res\values - 1 - - - - - 1 - - - 1 - - - - - res\drawable-mdpi - 1 - - - - - res\drawable-hdpi - 1 - - - - - 1 - - - - - - - - - - - 12 - - - - - + + + {BFB30971-26C9-49E7-8275-3614C28BF9EB} + TP_LockBox3.dpk + True + Debug + 19 + Package + VCL + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + 00400000 + false + 5 + 3 + _XE7 + TP_LockBox3 + 3081 + true + false + true + CompanyName=;FileDescription=;FileVersion=3.5.0.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + true + true + false + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + false + false + true + TurboPower LockBox 3 run-time package + + + 3 + false + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.7.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + Debug + + + $(MSBuildProjectName) + iPhoneAndiPad + CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist + Debug + + + iPhoneAndiPad + CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist + + + 7 + 1033 + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + + + false + 0 + RELEASE;$(DCC_Define) + 0 + + + 3 + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.7.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + + + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + true + false + DEBUG;$(DCC_Define) + + + 3 + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=3;versionName=3.7.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + + + true + + + true + + + false + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + false + + + + MainSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + Package + + + + TP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + True + False + False + True + True + + + + + TP_LockBox3.bpl + true + + + + + 1 + .dylib + + + 0 + .bpl + + + 1 + .dylib + + + 1 + .dylib + + + + + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + + + 1 + + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + res\drawable-normal + 1 + + + + + library\lib\x86 + 1 + + + + + 1 + + + 1 + + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + res\drawable-xlarge + 1 + + + + + res\drawable-xhdpi + 1 + + + + + 1 + + + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + library\lib\mips + 1 + + + + + res\drawable + 1 + + + + + 1 + + + 1 + + + 0 + + + + + 1 + .framework + + + 0 + + + + + res\drawable-small + 1 + + + + + + 1 + + + Contents\MacOS + 0 + + + + + classes + 1 + + + + + + 1 + + + 1 + + + + + res\drawable + 1 + + + + + Contents\Resources + 1 + + + + + + 1 + + + 1 + + + + + 1 + + + library\lib\armeabi-v7a + 1 + + + 0 + + + 1 + + + 1 + + + + + library\lib\armeabi + 1 + + + + + res\drawable-large + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\values + 1 + + + + + 1 + + + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + 1 + + + + + + + + + + + 12 + + + + + diff --git a/packages/XE7/TP_LockBox3.res b/LockBox3/packages/XE7/TP_LockBox3.res similarity index 100% rename from packages/XE7/TP_LockBox3.res rename to LockBox3/packages/XE7/TP_LockBox3.res diff --git a/packages/XE7/TP_LockBox3_XE7.groupproj b/LockBox3/packages/XE7/TP_LockBox3_XE7.groupproj similarity index 97% rename from packages/XE7/TP_LockBox3_XE7.groupproj rename to LockBox3/packages/XE7/TP_LockBox3_XE7.groupproj index a784bcc..2166023 100644 --- a/packages/XE7/TP_LockBox3_XE7.groupproj +++ b/LockBox3/packages/XE7/TP_LockBox3_XE7.groupproj @@ -1,108 +1,108 @@ - - - {CD35A969-3EE9-444D-8433-F317BE3BC706} - - - - - - - - - - - - - - - - - - - - - - - - - - Default.Personality.12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {CD35A969-3EE9-444D-8433-F317BE3BC706} + + + + + + + + + + + + + + + + + + + + + + + + + + Default.Personality.12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/XE7/dclTP_LockBox3.dpk b/LockBox3/packages/XE7/dclTP_LockBox3.dpk similarity index 95% rename from packages/XE7/dclTP_LockBox3.dpk rename to LockBox3/packages/XE7/dclTP_LockBox3.dpk index 530612e..30a19ac 100644 --- a/packages/XE7/dclTP_LockBox3.dpk +++ b/LockBox3/packages/XE7/dclTP_LockBox3.dpk @@ -1,46 +1,46 @@ -package dclTP_LockBox3; - -{$R *.res} -{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} -{$ALIGN 8} -{$ASSERTIONS ON} -{$BOOLEVAL OFF} -{$DEBUGINFO OFF} -{$EXTENDEDSYNTAX ON} -{$IMPORTEDDATA ON} -{$IOCHECKS ON} -{$LOCALSYMBOLS OFF} -{$LONGSTRINGS ON} -{$OPENSTRINGS ON} -{$OPTIMIZATION ON} -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -{$REFERENCEINFO OFF} -{$SAFEDIVIDE OFF} -{$STACKFRAMES OFF} -{$TYPEDADDRESS OFF} -{$VARSTRINGCHECKS ON} -{$WRITEABLECONST OFF} -{$MINENUMSIZE 1} -{$IMAGEBASE $400000} -{$DEFINE RELEASE} -{$ENDIF IMPLICITBUILDING} -{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} -{$LIBSUFFIX '_XE7'} -{$DESIGNONLY} -{$IMPLICITBUILD OFF} - -requires - rtl, - designide, - vclie, - vclimg, - TP_LockBox3; - -contains - TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', - TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', - TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, - TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; - -end. +package dclTP_LockBox3; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE RELEASE} +{$ENDIF IMPLICITBUILDING} +{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} +{$LIBSUFFIX '_XE7'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + designide, + vclie, + vclimg, + TP_LockBox3; + +contains + TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', + TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', + TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, + TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; + +end. diff --git a/packages/XE7/dclTP_LockBox3.dproj b/LockBox3/packages/XE7/dclTP_LockBox3.dproj similarity index 93% rename from packages/XE7/dclTP_LockBox3.dproj rename to LockBox3/packages/XE7/dclTP_LockBox3.dproj index 58c8ceb..81f2772 100644 --- a/packages/XE7/dclTP_LockBox3.dproj +++ b/LockBox3/packages/XE7/dclTP_LockBox3.dproj @@ -1,190 +1,195 @@ - - - {FB4472D9-9E7C-4B3E-8D95-E12BB9426246} - dclTP_LockBox3.dpk - True - Release - 1 - Package - None - 16.1 - Win32 - - - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Cfg_1 - true - true - - - true - Base - true - - - true - Cfg_2 - true - true - - - 1 - System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;System.Win;$(DCC_Namespace) - 00400000 - false - 6 - 3 - _XE7 - dclTP_LockBox3 - 3081 - true - false - true - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments=;CFBundleName= - true - false - true - ..\..\work-products\ephemeral\dcu\XE7\$(Platform) - false - false - true - TurboPower LockBox 3 design-time package - - - rtl;$(DCC_UsePackage) - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true - Debug - - - rtl;$(DCC_UsePackage) - - - rtl;$(DCC_UsePackage) - - - rtl;$(DCC_UsePackage) - - - rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) - Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - - - Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) - 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= - rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) - - - false - 0 - RELEASE;$(DCC_Define) - 0 - - - 3 - CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= - 1033 - - - true - false - DEBUG;$(DCC_Define) - - - 1033 - CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.0.0;Comments= - - - - MainSource - - - - - - - - - -
TPLb_fmComponentAbout
-
- - - Cfg_2 - Base - - - Base - - - Cfg_1 - Base - -
- - Delphi.Personality.12 - Package - - - - dclTP_LockBox3.dpk - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - False - False - False - False - True - False - - - 12 - - - -
+ + + {FB4472D9-9E7C-4B3E-8D95-E12BB9426246} + dclTP_LockBox3.dpk + True + Release + 1 + Package + None + 16.1 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + 1 + System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;System.Win;$(DCC_Namespace) + 00400000 + false + 6 + 3 + _XE7 + dclTP_LockBox3 + 3081 + true + false + true + CompanyName=;FileDescription=;FileVersion=3.6.1.0;InternalName=;LegalCopyright=Sean B. Durkin;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.1.0;Comments=;CFBundleName= + true + false + true + ..\..\work-products\ephemeral\dcu\XE7\$(Platform) + false + false + true + TurboPower LockBox 3 design-time package + + + rtl;$(DCC_UsePackage) + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true + Debug + + + rtl;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + 0 + 7 + rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + 1033 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) + + + false + 0 + RELEASE;$(DCC_Define) + 0 + + + 7 + 0 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + 1033 + + + true + false + DEBUG;$(DCC_Define) + + + 0 + 7 + 1033 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + + + + MainSource + + + + + + + + + +
TPLb_fmComponentAbout
+
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Package + + + + dclTP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + False + False + False + False + True + False + + + 12 + + + +
diff --git a/packages/XE7/dclTP_LockBox3.res b/LockBox3/packages/XE7/dclTP_LockBox3.res similarity index 100% rename from packages/XE7/dclTP_LockBox3.res rename to LockBox3/packages/XE7/dclTP_LockBox3.res diff --git a/LockBox3/packages/XE8/TP_LockBox3.dpk b/LockBox3/packages/XE8/TP_LockBox3.dpk new file mode 100644 index 0000000..19d2137 --- /dev/null +++ b/LockBox3/packages/XE8/TP_LockBox3.dpk @@ -0,0 +1,86 @@ +package TP_LockBox3; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES ON} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE DEBUG} +{$ENDIF IMPLICITBUILDING} +{$DESCRIPTION 'TurboPower LockBox 3 run-time package'} +{$LIBSUFFIX '_XE8'} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +rrequires + rtl, + dbrtl; + +ocontains + TPLB3.BlockCipher in '..\..\run\TPLB3.BlockCipher.pas', + TPLB3.StreamUtils in '..\..\run\TPLB3.StreamUtils.pas', + TPLB3.StreamCipher in '..\..\run\TPLB3.StreamCipher.pas', + TPLB3.CryptographicLibrary in '..\..\run\TPLB3.CryptographicLibrary.pas', + TPLB3.BaseNonVisualComponent in '..\..\run\TPLB3.BaseNonVisualComponent.pas', + TPLB3.Codec in '..\..\run\TPLB3.Codec.pas', + TPLB3.ECB in '..\..\run\TPLB3.ECB.pas', + TPLB3.CBC in '..\..\run\TPLB3.CBC.pas', + TPLB3.PCBC in '..\..\run\TPLB3.PCBC.pas', + TPLB3.CFB_Block in '..\..\run\TPLB3.CFB_Block.pas', + TPLB3.CFB_8Bit in '..\..\run\TPLB3.CFB_8Bit.pas', + TPLB3.OFB in '..\..\run\TPLB3.OFB.pas', + TPLB3.CTR in '..\..\run\TPLB3.CTR.pas', + TPLB3.HashDsc in '..\..\run\TPLB3.HashDsc.pas', + TPLB3.SHA1 in '..\..\run\TPLB3.SHA1.pas', + TPLB3.BinaryUtils in '..\..\run\TPLB3.BinaryUtils.pas', + TPLB3.Hash in '..\..\run\TPLB3.Hash.pas', + TPLB3.MD5 in '..\..\run\TPLB3.MD5.pas', + TPLB3.Random in '..\..\run\TPLB3.Random.pas', + TPLB3.StreamToBlock in '..\..\run\TPLB3.StreamToBlock.pas', + TPLB3.Base64 in '..\..\run\TPLB3.Base64.pas', + TPLB3.CipherUtils in '..\..\run\TPLB3.CipherUtils.pas', + TPLB3.AES in '..\..\run\TPLB3.AES.pas', + TPLB3.PointerArithmetic in '..\..\run\TPLB3.PointerArithmetic.pas', + TPLB3.HugeCardinal in '..\..\run\TPLB3.HugeCardinal.pas', + TPLB3.IntegerUtils in '..\..\run\TPLB3.IntegerUtils.pas', + TPLB3.HugeCardinalUtils in '..\..\run\TPLB3.HugeCardinalUtils.pas', + TPLB3.MemoryStreamPool in '..\..\run\TPLB3.MemoryStreamPool.pas', + TPLB3.RSA_Primitives in '..\..\run\TPLB3.RSA_Primitives.pas', + TPLB3.RSA_Engine in '..\..\run\TPLB3.RSA_Engine.pas', + TPLB3.Asymetric in '..\..\run\TPLB3.Asymetric.pas', + TPLB3.Signatory in '..\..\run\TPLB3.Signatory.pas', + TPLB3.CodecIntf in '..\..\run\TPLB3.CodecIntf.pas', + TPLB3.Constants in '..\..\run\TPLB3.Constants.pas', + TPLB3.I18n in '..\..\run\TPLB3.I18n.pas', + TPLB3.SimpleBlockCipher in '..\..\run\TPLB3.SimpleBlockCipher.pas', + TPLB3.DES in '..\..\run\TPLB3.DES.pas', + TPLB3.TDES in '..\..\run\TPLB3.TDES.pas', + TPLB3.BlowFish in '..\..\run\TPLB3.BlowFish.pas', + TPLB3.Decorators in '..\..\run\TPLB3.Decorators.pas', + TPLB3.DCP.twofish_Modified in '..\..\run\TPLB3.DCP.twofish_Modified.pas', + TPLB3.TwoFish in '..\..\run\TPLB3.TwoFish.pas', + TPLB3.XXTEA in '..\..\run\TPLB3.XXTEA.pas', + TPLB3.SHA2 in '..\..\run\TPLB3.SHA2.pas', + TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', + TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', + TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; + +d. diff --git a/LockBox3/packages/XE8/TP_LockBox3.dproj b/LockBox3/packages/XE8/TP_LockBox3.dproj new file mode 100644 index 0000000..49b2777 --- /dev/null +++ b/LockBox3/packages/XE8/TP_LockBox3.dproj @@ -0,0 +1,180 @@ + + + {122C72D9-4EC8-4731-9C30-DF71742125F1} + TP_LockBox3.dpk + True + Debug + 1025 + Package + None + 17.2 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + true + ..\..\work-products\ephemeral\dcu\XE8\$(Platform) + true + false + System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace) + true + true + 00400000 + false + TurboPower LockBox 3 run-time package + false + false + 3081 + false + _XE8 + TP_LockBox3 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + + + android-support-v4.dex.jar;apk-expansion.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= + Debug + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + 1033 + true + + + false + 0 + 0 + RELEASE;$(DCC_Define) + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + true + 1033 + + + DEBUG;$(DCC_Define) + false + true + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + true + 1033 + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + Package + + + + TP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + False + False + True + False + False + True + False + + + 12 + + + + diff --git a/packages/D10_1Brln/TP_LockBox3.res b/LockBox3/packages/XE8/TP_LockBox3.res similarity index 100% rename from packages/D10_1Brln/TP_LockBox3.res rename to LockBox3/packages/XE8/TP_LockBox3.res diff --git a/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj b/LockBox3/packages/XE8/TP_LockBox3_XE8.groupproj similarity index 96% rename from packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj rename to LockBox3/packages/XE8/TP_LockBox3_XE8.groupproj index ba5f97c..4205144 100644 --- a/packages/D10_1Brln/TP_LockBox3_D10_1Brln.groupproj +++ b/LockBox3/packages/XE8/TP_LockBox3_XE8.groupproj @@ -1,6 +1,6 @@  - {DC1BD900-94B2-440B-A5BB-CD3AE245F681} + {175AE0DD-F04D-421D-BFB2-11381E0082F7} diff --git a/LockBox3/packages/XE8/dclTP_LockBox3.dpk b/LockBox3/packages/XE8/dclTP_LockBox3.dpk new file mode 100644 index 0000000..712c854 --- /dev/null +++ b/LockBox3/packages/XE8/dclTP_LockBox3.dpk @@ -0,0 +1,46 @@ +package dclTP_LockBox3; + +{$R *.res} +{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES ON} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DEFINE DEBUG} +{$ENDIF IMPLICITBUILDING} +{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} +{$LIBSUFFIX '_XE8'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +rrequires + rtl, + designide, + vclie, + vclimg, + TP_LockBox3; + +ocontains + TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', + TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', + TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, + TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; + +d. diff --git a/LockBox3/packages/XE8/dclTP_LockBox3.dproj b/LockBox3/packages/XE8/dclTP_LockBox3.dproj new file mode 100644 index 0000000..35a489a --- /dev/null +++ b/LockBox3/packages/XE8/dclTP_LockBox3.dproj @@ -0,0 +1,215 @@ + + + {43120C8D-0CE2-4DB3-90E8-249C9909A0AE} + dclTP_LockBox3.dpk + True + Debug + 1025 + Package + None + 17.2 + Win32 + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + false + ..\..\work-products\ephemeral\dcu\XE8\$(Platform) + false + true + System;Xml;Data;Datasnap;Web;Soap;Winapi;Vcl;Vcl.Imaging;System.Win;$(DCC_Namespace) + true + true + 00400000 + _XE8 + TurboPower LockBox 3 design-time package + false + false + 3081 + true + false + dclTP_LockBox3 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName= + + + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=preferExternal;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= + android-support-v4.dex.jar;apk-expansion.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar + rtl;$(DCC_UsePackage) + Debug + + + rtl;$(DCC_UsePackage) + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + rtl;TP_LockBox3;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + rtl;$(DCC_UsePackage) + + + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + 1033 + rtl;vclimg;vclie;TP_LockBox3;$(DCC_UsePackage) + + + rtl;vclimg;vclie;$(DCC_UsePackage) + + + false + 0 + 0 + RELEASE;$(DCC_Define) + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + true + 1033 + + + DEBUG;$(DCC_Define) + false + true + + + 3 + 7 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments=;CFBundleName=;CFBundleVersion=3.7.0 + + + 7 + 3 + CompanyName=;FileDescription=;FileVersion=3.7.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.7.0.0;Comments= + 1033 + true + + + + MainSource + + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + + + + Delphi.Personality.12 + Package + + + + dclTP_LockBox3.dpk + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + False + False + True + False + False + True + False + + + 12 + + + + diff --git a/LockBox3/packages/XE8/dclTP_LockBox3.res b/LockBox3/packages/XE8/dclTP_LockBox3.res new file mode 100644 index 0000000000000000000000000000000000000000..3bb78759d0d01ec14176e4b53dd7e7aa7cd35082 GIT binary patch literal 448 zcmZ9IO-chn5QV>ySr}Iy!G&uXVK#zb0{#&2k7USJhD0SG8Ax>JVZ4a9aqkTrzwWV# zNkPq2cfI%ObpafhZQG^gM)b4P-xuS-DCp%0)Xz%G31c4oUNEv6a>uRbq2EjE5TE(? z4+MUvk^X0~3qde-{;v3lcVk{zGH1cFYI9zARC&P@js5qCDJXSyVwQRcjtX|wOZbVL zB`evD%n-*MiAjl^fWH^jFyoD>Q@2^$oO5+DQMIfzY3&RS - - {CE1F695D-BD3C-4E23-83FD-EDD0BEF91500} - LockBox_DUnit_Tests.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;System.Actions=ActnList;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\LockBox_DUnit_Tests.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - - - - - - - - - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - - - - - Delphi.Personality.12 - VCLApplication - - - - LockBox_DUnit_Tests.dpr - - - False - True - False - - - True - False - 3 - 5 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 3.5.0.0 - - - - - - 1.0.0.0 - - - - - 12 - - + + + {CE1F695D-BD3C-4E23-83FD-EDD0BEF91500} + LockBox_DUnit_Tests.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;System.Actions=ActnList;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\LockBox_DUnit_Tests.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + + + + + + + + + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + + + + + Delphi.Personality.12 + VCLApplication + + + + LockBox_DUnit_Tests.dpr + + + False + True + False + + + True + False + 3 + 5 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 3.5.0.0 + + + + + + 1.0.0.0 + + + + + 12 + + diff --git a/packages/d2010/LockBox_DUnit_Tests.res b/LockBox3/packages/d2010/LockBox_DUnit_Tests.res similarity index 100% rename from packages/d2010/LockBox_DUnit_Tests.res rename to LockBox3/packages/d2010/LockBox_DUnit_Tests.res diff --git a/packages/d2010/Lockbox3_Demo.dpr b/LockBox3/packages/d2010/Lockbox3_Demo.dpr similarity index 96% rename from packages/d2010/Lockbox3_Demo.dpr rename to LockBox3/packages/d2010/Lockbox3_Demo.dpr index 67484ca..a5cff37 100644 --- a/packages/d2010/Lockbox3_Demo.dpr +++ b/LockBox3/packages/d2010/Lockbox3_Demo.dpr @@ -1,16 +1,16 @@ -program Lockbox3_Demo; - -uses - Forms, - uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas', - umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'LB3 Demo'; - Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); - Application.Run; -end. +program Lockbox3_Demo; + +uses + Forms, + uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas', + umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'LB3 Demo'; + Application.CreateForm(TmfmLockbox3_Demo, mfmLockbox3_Demo); + Application.Run; +end. diff --git a/packages/d2010/Lockbox3_Demo.dproj b/LockBox3/packages/d2010/Lockbox3_Demo.dproj similarity index 97% rename from packages/d2010/Lockbox3_Demo.dproj rename to LockBox3/packages/d2010/Lockbox3_Demo.dproj index f5de012..92c807e 100644 --- a/packages/d2010/Lockbox3_Demo.dproj +++ b/LockBox3/packages/d2010/Lockbox3_Demo.dproj @@ -1,104 +1,104 @@ - - - {6B873D54-8745-4BD6-BC49-2F808A237B1A} - Lockbox3_Demo.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;System.Actions=ActnList;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\Lockbox3_Demo.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - - -
mfmLockbox3_Demo
-
- - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - VCLApplication - - - - Lockbox3_Demo.dpr - - - False - True - False - - - True - False - 3 - 5 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 3.5.0.0 - - - - - - 1.0.0.0 - - - - - 12 - -
+ + + {6B873D54-8745-4BD6-BC49-2F808A237B1A} + Lockbox3_Demo.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;System.Actions=ActnList;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\Lockbox3_Demo.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + + +
mfmLockbox3_Demo
+
+ + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + VCLApplication + + + + Lockbox3_Demo.dpr + + + False + True + False + + + True + False + 3 + 5 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 3.5.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/packages/d2010/Lockbox3_Demo.res b/LockBox3/packages/d2010/Lockbox3_Demo.res similarity index 100% rename from packages/d2010/Lockbox3_Demo.res rename to LockBox3/packages/d2010/Lockbox3_Demo.res diff --git a/packages/XE6/MakeSampleKey.dpr b/LockBox3/packages/d2010/MakeSampleKey.dpr similarity index 96% rename from packages/XE6/MakeSampleKey.dpr rename to LockBox3/packages/d2010/MakeSampleKey.dpr index e0f6984..5d50705 100644 --- a/packages/XE6/MakeSampleKey.dpr +++ b/LockBox3/packages/d2010/MakeSampleKey.dpr @@ -1,16 +1,16 @@ -program MakeSampleKey; - -uses - Forms, - umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Make Sample Key'; - Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); - Application.Run; -end. +program MakeSampleKey; + +uses + Forms, + umfmMakeSampleKey in '..\..\ancillary-applications\umfmMakeSampleKey.pas' {mfmMakeSampleKey}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Make Sample Key'; + Application.CreateForm(TmfmMakeSampleKey, mfmMakeSampleKey); + Application.Run; +end. diff --git a/packages/d2010/MakeSampleKey.dproj b/LockBox3/packages/d2010/MakeSampleKey.dproj similarity index 97% rename from packages/d2010/MakeSampleKey.dproj rename to LockBox3/packages/d2010/MakeSampleKey.dproj index 28e8e66..b33e4f9 100644 --- a/packages/d2010/MakeSampleKey.dproj +++ b/LockBox3/packages/d2010/MakeSampleKey.dproj @@ -1,103 +1,103 @@ - - - {68987B0F-E94C-4AA8-B33A-9B2C8CA73E2B} - MakeSampleKey.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\MakeSampleKey.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - -
mfmMakeSampleKey
-
- - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - VCLApplication - - - - MakeSampleKey.dpr - - - False - True - False - - - False - False - 1 - 0 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 1.0.0.0 - - - - - - 1.0.0.0 - - - - - 12 - -
+ + + {68987B0F-E94C-4AA8-B33A-9B2C8CA73E2B} + MakeSampleKey.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\MakeSampleKey.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + +
mfmMakeSampleKey
+
+ + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + VCLApplication + + + + MakeSampleKey.dpr + + + False + True + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/packages/d2010/MakeSampleKey.res b/LockBox3/packages/d2010/MakeSampleKey.res similarity index 100% rename from packages/d2010/MakeSampleKey.res rename to LockBox3/packages/d2010/MakeSampleKey.res diff --git a/packages/XE6/Precompute.dpr b/LockBox3/packages/d2010/Precompute.dpr similarity index 95% rename from packages/XE6/Precompute.dpr rename to LockBox3/packages/d2010/Precompute.dpr index d27906c..9649135 100644 --- a/packages/XE6/Precompute.dpr +++ b/LockBox3/packages/d2010/Precompute.dpr @@ -1,15 +1,15 @@ -program Precompute; - -uses - Forms, - umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.Title := 'Precompute'; - Application.CreateForm(TmfmPrecompute, mfmPrecompute); - Application.Run; -end. +program Precompute; + +uses + Forms, + umfmPrecompute in '..\..\design\umfmPrecompute.pas' {mfmPrecompute}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.Title := 'Precompute'; + Application.CreateForm(TmfmPrecompute, mfmPrecompute); + Application.Run; +end. diff --git a/packages/d2010/Precompute.dproj b/LockBox3/packages/d2010/Precompute.dproj similarity index 97% rename from packages/d2010/Precompute.dproj rename to LockBox3/packages/d2010/Precompute.dproj index 28a69c0..038cf38 100644 --- a/packages/d2010/Precompute.dproj +++ b/LockBox3/packages/d2010/Precompute.dproj @@ -1,103 +1,103 @@ - - - {5A8E635A-4CA7-4DCE-BB78-3C806A56E590} - Precompute.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\Precompute.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - -
mfmPrecompute
-
- - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - VCLApplication - - - - Precompute.dpr - - - False - True - False - - - True - False - 1 - 0 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 1.0.0.0 - - - - - - 1.0.0.0 - - - - - 12 - -
+ + + {5A8E635A-4CA7-4DCE-BB78-3C806A56E590} + Precompute.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\Precompute.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + +
mfmPrecompute
+
+ + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + VCLApplication + + + + Precompute.dpr + + + False + True + False + + + True + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/packages/d2010/Precompute.res b/LockBox3/packages/d2010/Precompute.res similarity index 100% rename from packages/d2010/Precompute.res rename to LockBox3/packages/d2010/Precompute.res diff --git a/packages/XE7/RSA_Encryption_Demo.dpr b/LockBox3/packages/d2010/RSA_Encryption_Demo.dpr similarity index 96% rename from packages/XE7/RSA_Encryption_Demo.dpr rename to LockBox3/packages/d2010/RSA_Encryption_Demo.dpr index 8fbddba..869dfed 100644 --- a/packages/XE7/RSA_Encryption_Demo.dpr +++ b/LockBox3/packages/d2010/RSA_Encryption_Demo.dpr @@ -1,15 +1,15 @@ -program RSA_Encryption_Demo; - -uses - Forms, - umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; - -{$R *.res} - -begin - ReportMemoryLeaksOnShutdown := True; - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); - Application.Run; -end. +program RSA_Encryption_Demo; + +uses + Forms, + umfmRSA_Encryption_Demo in '..\..\demo\D2010+\umfmRSA_Encryption_Demo.pas' {mfmRSA_Encryption_Demo}; + +{$R *.res} + +begin + ReportMemoryLeaksOnShutdown := True; + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmRSA_Encryption_Demo, mfmRSA_Encryption_Demo); + Application.Run; +end. diff --git a/packages/d2010/RSA_Encryption_Demo.dproj b/LockBox3/packages/d2010/RSA_Encryption_Demo.dproj similarity index 97% rename from packages/d2010/RSA_Encryption_Demo.dproj rename to LockBox3/packages/d2010/RSA_Encryption_Demo.dproj index 71d1057..c3398a5 100644 --- a/packages/d2010/RSA_Encryption_Demo.dproj +++ b/LockBox3/packages/d2010/RSA_Encryption_Demo.dproj @@ -1,103 +1,103 @@ - - - {CE70A864-970C-4706-836A-E8D9CCB80629} - RSA_Encryption_Demo.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\RSA_Encryption_Demo.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - -
mfmRSA_Encryption_Demo
-
- - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - VCLApplication - - - - RSA_Encryption_Demo.dpr - - - False - True - False - - - False - False - 1 - 0 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 1.0.0.0 - - - - - - 1.0.0.0 - - - - - 12 - -
+ + + {CE70A864-970C-4706-836A-E8D9CCB80629} + RSA_Encryption_Demo.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\RSA_Encryption_Demo.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + +
mfmRSA_Encryption_Demo
+
+ + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + VCLApplication + + + + RSA_Encryption_Demo.dpr + + + False + True + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/packages/d2010/RSA_Encryption_Demo.res b/LockBox3/packages/d2010/RSA_Encryption_Demo.res similarity index 100% rename from packages/d2010/RSA_Encryption_Demo.res rename to LockBox3/packages/d2010/RSA_Encryption_Demo.res diff --git a/packages/d2010/TP_LockBox3.dpk b/LockBox3/packages/d2010/TP_LockBox3.dpk similarity index 97% rename from packages/d2010/TP_LockBox3.dpk rename to LockBox3/packages/d2010/TP_LockBox3.dpk index 73f053f..0f9f19d 100644 --- a/packages/d2010/TP_LockBox3.dpk +++ b/LockBox3/packages/d2010/TP_LockBox3.dpk @@ -1,84 +1,84 @@ -package TP_LockBox3; -{$R *.res} -{$ALIGN 8} -{$ASSERTIONS ON} -{$BOOLEVAL OFF} -{$DEBUGINFO ON} -{$EXTENDEDSYNTAX ON} -{$IMPORTEDDATA ON} -{$IOCHECKS ON} -{$LOCALSYMBOLS ON} -{$LONGSTRINGS ON} -{$OPENSTRINGS ON} -{$OPTIMIZATION OFF} -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -{$REFERENCEINFO ON} -{$SAFEDIVIDE OFF} -{$STACKFRAMES OFF} -{$TYPEDADDRESS OFF} -{$VARSTRINGCHECKS ON} -{$WRITEABLECONST OFF} -{$MINENUMSIZE 1} -{$IMAGEBASE $400000} -{$DESCRIPTION 'TurboPower LockBox 3 run-time package'} -{$LIBSUFFIX '_D2010'} -{$RUNONLY} -{$IMPLICITBUILD OFF} - -requires - rtl, - vcl, - vclimg, - dbrtl; - -contains - TPLB3.BlockCipher in '..\..\run\TPLB3.BlockCipher.pas', - TPLB3.StreamUtils in '..\..\run\TPLB3.StreamUtils.pas', - TPLB3.StreamCipher in '..\..\run\TPLB3.StreamCipher.pas', - TPLB3.CryptographicLibrary in '..\..\run\TPLB3.CryptographicLibrary.pas', - TPLB3.BaseNonVisualComponent in '..\..\run\TPLB3.BaseNonVisualComponent.pas', - TPLB3.Codec in '..\..\run\TPLB3.Codec.pas', - TPLB3.ECB in '..\..\run\TPLB3.ECB.pas', - TPLB3.CBC in '..\..\run\TPLB3.CBC.pas', - TPLB3.PCBC in '..\..\run\TPLB3.PCBC.pas', - TPLB3.CFB_Block in '..\..\run\TPLB3.CFB_Block.pas', - TPLB3.CFB_8Bit in '..\..\run\TPLB3.CFB_8Bit.pas', - TPLB3.OFB in '..\..\run\TPLB3.OFB.pas', - TPLB3.CTR in '..\..\run\TPLB3.CTR.pas', - TPLB3.HashDsc in '..\..\run\TPLB3.HashDsc.pas', - TPLB3.SHA1 in '..\..\run\TPLB3.SHA1.pas', - TPLB3.BinaryUtils in '..\..\run\TPLB3.BinaryUtils.pas', - TPLB3.Hash in '..\..\run\TPLB3.Hash.pas', - TPLB3.MD5 in '..\..\run\TPLB3.MD5.pas', - TPLB3.Random in '..\..\run\TPLB3.Random.pas', - TPLB3.StreamToBlock in '..\..\run\TPLB3.StreamToBlock.pas', - TPLB3.Base64 in '..\..\run\TPLB3.Base64.pas', - TPLB3.CipherUtils in '..\..\run\TPLB3.CipherUtils.pas', - TPLB3.AES in '..\..\run\TPLB3.AES.pas', - TPLB3.PointerArithmetic in '..\..\run\TPLB3.PointerArithmetic.pas', - TPLB3.HugeCardinal in '..\..\run\TPLB3.HugeCardinal.pas', - TPLB3.IntegerUtils in '..\..\run\TPLB3.IntegerUtils.pas', - TPLB3.HugeCardinalUtils in '..\..\run\TPLB3.HugeCardinalUtils.pas', - TPLB3.MemoryStreamPool in '..\..\run\TPLB3.MemoryStreamPool.pas', - TPLB3.RSA_Primitives in '..\..\run\TPLB3.RSA_Primitives.pas', - TPLB3.RSA_Engine in '..\..\run\TPLB3.RSA_Engine.pas', - TPLB3.Asymetric in '..\..\run\TPLB3.Asymetric.pas', - TPLB3.Signatory in '..\..\run\TPLB3.Signatory.pas', - TPLB3.CodecIntf in '..\..\run\TPLB3.CodecIntf.pas', - TPLB3.Constants in '..\..\run\TPLB3.Constants.pas', - TPLB3.I18n in '..\..\run\TPLB3.I18n.pas', - TPLB3.SimpleBlockCipher in '..\..\run\TPLB3.SimpleBlockCipher.pas', - TPLB3.DES in '..\..\run\TPLB3.DES.pas', - TPLB3.TDES in '..\..\run\TPLB3.TDES.pas', - TPLB3.BlowFish in '..\..\run\TPLB3.BlowFish.pas', - TPLB3.Decorators in '..\..\run\TPLB3.Decorators.pas', - TPLB3.DCP.twofish_Modified in '..\..\run\TPLB3.DCP.twofish_Modified.pas', - TPLB3.TwoFish in '..\..\run\TPLB3.TwoFish.pas', - TPLB3.XXTEA in '..\..\run\TPLB3.XXTEA.pas', - TPLB3.SHA2 in '..\..\run\TPLB3.SHA2.pas', - TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', - TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', - TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; - -end. +package TP_LockBox3; +{$R *.res} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION OFF} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'TurboPower LockBox 3 run-time package'} +{$LIBSUFFIX '_D2010'} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + vcl, + vclimg, + dbrtl; + +contains + TPLB3.BlockCipher in '..\..\run\TPLB3.BlockCipher.pas', + TPLB3.StreamUtils in '..\..\run\TPLB3.StreamUtils.pas', + TPLB3.StreamCipher in '..\..\run\TPLB3.StreamCipher.pas', + TPLB3.CryptographicLibrary in '..\..\run\TPLB3.CryptographicLibrary.pas', + TPLB3.BaseNonVisualComponent in '..\..\run\TPLB3.BaseNonVisualComponent.pas', + TPLB3.Codec in '..\..\run\TPLB3.Codec.pas', + TPLB3.ECB in '..\..\run\TPLB3.ECB.pas', + TPLB3.CBC in '..\..\run\TPLB3.CBC.pas', + TPLB3.PCBC in '..\..\run\TPLB3.PCBC.pas', + TPLB3.CFB_Block in '..\..\run\TPLB3.CFB_Block.pas', + TPLB3.CFB_8Bit in '..\..\run\TPLB3.CFB_8Bit.pas', + TPLB3.OFB in '..\..\run\TPLB3.OFB.pas', + TPLB3.CTR in '..\..\run\TPLB3.CTR.pas', + TPLB3.HashDsc in '..\..\run\TPLB3.HashDsc.pas', + TPLB3.SHA1 in '..\..\run\TPLB3.SHA1.pas', + TPLB3.BinaryUtils in '..\..\run\TPLB3.BinaryUtils.pas', + TPLB3.Hash in '..\..\run\TPLB3.Hash.pas', + TPLB3.MD5 in '..\..\run\TPLB3.MD5.pas', + TPLB3.Random in '..\..\run\TPLB3.Random.pas', + TPLB3.StreamToBlock in '..\..\run\TPLB3.StreamToBlock.pas', + TPLB3.Base64 in '..\..\run\TPLB3.Base64.pas', + TPLB3.CipherUtils in '..\..\run\TPLB3.CipherUtils.pas', + TPLB3.AES in '..\..\run\TPLB3.AES.pas', + TPLB3.PointerArithmetic in '..\..\run\TPLB3.PointerArithmetic.pas', + TPLB3.HugeCardinal in '..\..\run\TPLB3.HugeCardinal.pas', + TPLB3.IntegerUtils in '..\..\run\TPLB3.IntegerUtils.pas', + TPLB3.HugeCardinalUtils in '..\..\run\TPLB3.HugeCardinalUtils.pas', + TPLB3.MemoryStreamPool in '..\..\run\TPLB3.MemoryStreamPool.pas', + TPLB3.RSA_Primitives in '..\..\run\TPLB3.RSA_Primitives.pas', + TPLB3.RSA_Engine in '..\..\run\TPLB3.RSA_Engine.pas', + TPLB3.Asymetric in '..\..\run\TPLB3.Asymetric.pas', + TPLB3.Signatory in '..\..\run\TPLB3.Signatory.pas', + TPLB3.CodecIntf in '..\..\run\TPLB3.CodecIntf.pas', + TPLB3.Constants in '..\..\run\TPLB3.Constants.pas', + TPLB3.I18n in '..\..\run\TPLB3.I18n.pas', + TPLB3.SimpleBlockCipher in '..\..\run\TPLB3.SimpleBlockCipher.pas', + TPLB3.DES in '..\..\run\TPLB3.DES.pas', + TPLB3.TDES in '..\..\run\TPLB3.TDES.pas', + TPLB3.BlowFish in '..\..\run\TPLB3.BlowFish.pas', + TPLB3.Decorators in '..\..\run\TPLB3.Decorators.pas', + TPLB3.DCP.twofish_Modified in '..\..\run\TPLB3.DCP.twofish_Modified.pas', + TPLB3.TwoFish in '..\..\run\TPLB3.TwoFish.pas', + TPLB3.XXTEA in '..\..\run\TPLB3.XXTEA.pas', + TPLB3.SHA2 in '..\..\run\TPLB3.SHA2.pas', + TPLB3.SVN_Keywords in '..\..\run\TPLB3.SVN_Keywords.pas', + TPLB3.OpenSSL in '..\..\run\TPLB3.OpenSSL.pas', + TPLB3.Compatibility in '..\..\run\TPLB3.Compatibility.pas'; + +end. diff --git a/packages/d2010/TP_LockBox3.dproj b/LockBox3/packages/d2010/TP_LockBox3.dproj similarity index 97% rename from packages/d2010/TP_LockBox3.dproj rename to LockBox3/packages/d2010/TP_LockBox3.dproj index 0df8e26..7c3e74c 100644 --- a/packages/d2010/TP_LockBox3.dproj +++ b/LockBox3/packages/d2010/TP_LockBox3.dproj @@ -1,163 +1,163 @@ - - - {5AED2ED1-3EFC-4CE2-BAC2-D04B331DE465} - TP_LockBox3.dpk - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - true - C:\Documents and Settings\All Users\Documents\RAD Studio\7.0\Bpl\TP_LockBox3_D2010.bpl - false - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - false - TurboPower LockBox 3 run-time package - true - true - true - _D2010 - 1 - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - - - - - Delphi.Personality.12 - Package - - - - TP_LockBox3.dpk - - - False - True - False - - - True - False - 3 - 6 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 3.6.0.0 - - - - - - 3.6.0.0 - - - - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components - - - - 12 - - + + + {5AED2ED1-3EFC-4CE2-BAC2-D04B331DE465} + TP_LockBox3.dpk + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + true + C:\Documents and Settings\All Users\Documents\RAD Studio\7.0\Bpl\TP_LockBox3_D2010.bpl + false + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + false + TurboPower LockBox 3 run-time package + true + true + true + _D2010 + 1 + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + + + + + Delphi.Personality.12 + Package + + + + TP_LockBox3.dpk + + + False + True + False + + + True + False + 3 + 6 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 3.6.0.0 + + + + + + 3.6.0.0 + + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + 12 + + diff --git a/packages/d2010/TP_LockBox3.res b/LockBox3/packages/d2010/TP_LockBox3.res similarity index 100% rename from packages/d2010/TP_LockBox3.res rename to LockBox3/packages/d2010/TP_LockBox3.res diff --git a/packages/d2010/TP_LockBox3_d2010.groupproj b/LockBox3/packages/d2010/TP_LockBox3_d2010.groupproj similarity index 97% rename from packages/d2010/TP_LockBox3_d2010.groupproj rename to LockBox3/packages/d2010/TP_LockBox3_d2010.groupproj index 541de0b..fbf2614 100644 --- a/packages/d2010/TP_LockBox3_d2010.groupproj +++ b/LockBox3/packages/d2010/TP_LockBox3_d2010.groupproj @@ -1,110 +1,110 @@ - - - {e270b92a-42e1-4b48-8dbe-c5c1222db7aa} - - - - - - - - - - - - - - - - - - - - - - - - - - Default.Personality.12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {e270b92a-42e1-4b48-8dbe-c5c1222db7aa} + + + + + + + + + + + + + + + + + + + + + + + + + + Default.Personality.12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/d2010/UInt64_to_Int64_Convert_Utility.dpr b/LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dpr similarity index 96% rename from packages/d2010/UInt64_to_Int64_Convert_Utility.dpr rename to LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dpr index 611541a..f48545a 100644 --- a/packages/d2010/UInt64_to_Int64_Convert_Utility.dpr +++ b/LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dpr @@ -1,14 +1,14 @@ -program UInt64_to_Int64_Convert_Utility; - -uses - Forms, - umfmUInt64_to_Int64_Converter in '..\..\design\forms\d2010\umfmUInt64_to_Int64_Converter.pas' {mfmUInt64_to_Int64_Converter}; - -{$R *.res} - -begin - Application.Initialize; - Application.MainFormOnTaskbar := True; - Application.CreateForm(TmfmUInt64_to_Int64_Converter, mfmUInt64_to_Int64_Converter); - Application.Run; -end. +program UInt64_to_Int64_Convert_Utility; + +uses + Forms, + umfmUInt64_to_Int64_Converter in '..\..\design\forms\d2010\umfmUInt64_to_Int64_Converter.pas' {mfmUInt64_to_Int64_Converter}; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TmfmUInt64_to_Int64_Converter, mfmUInt64_to_Int64_Converter); + Application.Run; +end. diff --git a/packages/d2010/UInt64_to_Int64_Convert_Utility.dproj b/LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dproj similarity index 97% rename from packages/d2010/UInt64_to_Int64_Convert_Utility.dproj rename to LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dproj index 55bfbc1..25a6ace 100644 --- a/packages/d2010/UInt64_to_Int64_Convert_Utility.dproj +++ b/LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.dproj @@ -1,103 +1,103 @@ - - - {FBDB349A-7710-4D79-9F6A-39DFDD853BFD} - UInt64_to_Int64_Convert_Utility.dpr - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - ..\..\work-products\exe\D2010\Win32 - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - ..\..\work-products\exe\D2010\Win32\UInt64_to_Int64_Convert_Utility.exe - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - -
mfmUInt64_to_Int64_Converter
-
- - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - VCLApplication - - - - UInt64_to_Int64_Convert_Utility.dpr - - - False - True - False - - - False - False - 1 - 0 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 1.0.0.0 - - - - - - 1.0.0.0 - - - - - 12 - -
+ + + {FBDB349A-7710-4D79-9F6A-39DFDD853BFD} + UInt64_to_Int64_Convert_Utility.dpr + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + ..\..\work-products\exe\D2010\Win32 + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + ..\..\work-products\exe\D2010\Win32\UInt64_to_Int64_Convert_Utility.exe + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + +
mfmUInt64_to_Int64_Converter
+
+ + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + VCLApplication + + + + UInt64_to_Int64_Convert_Utility.dpr + + + False + True + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + 12 + +
diff --git a/packages/d2010/UInt64_to_Int64_Convert_Utility.res b/LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.res similarity index 100% rename from packages/d2010/UInt64_to_Int64_Convert_Utility.res rename to LockBox3/packages/d2010/UInt64_to_Int64_Convert_Utility.res diff --git a/packages/d2010/dclTP_LockBox3.dpk b/LockBox3/packages/d2010/dclTP_LockBox3.dpk similarity index 95% rename from packages/d2010/dclTP_LockBox3.dpk rename to LockBox3/packages/d2010/dclTP_LockBox3.dpk index 1457e1f..b7f4598 100644 --- a/packages/d2010/dclTP_LockBox3.dpk +++ b/LockBox3/packages/d2010/dclTP_LockBox3.dpk @@ -1,43 +1,43 @@ -package dclTP_LockBox3; - -{$R *.res} -{$ALIGN 8} -{$ASSERTIONS ON} -{$BOOLEVAL OFF} -{$DEBUGINFO ON} -{$EXTENDEDSYNTAX ON} -{$IMPORTEDDATA ON} -{$IOCHECKS ON} -{$LOCALSYMBOLS ON} -{$LONGSTRINGS ON} -{$OPENSTRINGS ON} -{$OPTIMIZATION ON} -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} -{$REFERENCEINFO ON} -{$SAFEDIVIDE OFF} -{$STACKFRAMES OFF} -{$TYPEDADDRESS OFF} -{$VARSTRINGCHECKS ON} -{$WRITEABLECONST OFF} -{$MINENUMSIZE 1} -{$IMAGEBASE $400000} -{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} -{$LIBSUFFIX '_D2010'} -{$DESIGNONLY} -{$IMPLICITBUILD OFF} - -requires - rtl, - designide, - vclie, - vclimg, - TP_LockBox3; - -contains - TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', - TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', - TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, - TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; - -end. +package dclTP_LockBox3; + +{$R *.res} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'TurboPower LockBox 3 design-time package'} +{$LIBSUFFIX '_D2010'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + designide, + vclie, + vclimg, + TP_LockBox3; + +contains + TPLB3.ComponentRegistration in '..\..\design\TPLB3.ComponentRegistration.pas', + TPLB3.ComponentEditors in '..\..\design\TPLB3.ComponentEditors.pas', + TPLB3.ComponentAbout in '..\..\design\TPLB3.ComponentAbout.pas' {TPLb_fmComponentAbout}, + TPLB3.InfoUtils in '..\..\design\TPLB3.InfoUtils.pas'; + +end. diff --git a/packages/d2010/dclTP_LockBox3.dproj b/LockBox3/packages/d2010/dclTP_LockBox3.dproj similarity index 97% rename from packages/d2010/dclTP_LockBox3.dproj rename to LockBox3/packages/d2010/dclTP_LockBox3.dproj index a673a7d..00ed8df 100644 --- a/packages/d2010/dclTP_LockBox3.dproj +++ b/LockBox3/packages/d2010/dclTP_LockBox3.dproj @@ -1,117 +1,117 @@ - - - {8BC7CAE3-EF68-4DCE-BCD7-9280FACA6B96} - dclTP_LockBox3.dpk - Debug - DCC32 - 12.0 - - - true - - - true - Base - true - - - true - Base - true - - - true - _D2010 - C:\Documents and Settings\All Users\Documents\RAD Studio\7.0\Bpl\dclTP_LockBox3_D2010.bpl - WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) - TurboPower LockBox 3 design-time package - true - true - 1 - true - ..\..\work-products\ephemeral\dcu\D2010\Win32 - x86 - 00400000 - - - false - RELEASE;$(DCC_Define) - 0 - false - - - DEBUG;$(DCC_Define) - - - - MainSource - - - - - - - - - -
TPLb_fmComponentAbout
-
- - - Base - - - Cfg_2 - Base - - - Cfg_1 - Base - -
- - - Delphi.Personality.12 - Package - - - - dclTP_LockBox3.dpk - - - False - True - False - - - True - False - 3 - 6 - 0 - 0 - False - False - False - False - False - 3081 - 1252 - - - - - 3.6.0.0 - - - - - - 3.6.00 - - - - - 12 - -
+ + + {8BC7CAE3-EF68-4DCE-BCD7-9280FACA6B96} + dclTP_LockBox3.dpk + Debug + DCC32 + 12.0 + + + true + + + true + Base + true + + + true + Base + true + + + true + _D2010 + C:\Documents and Settings\All Users\Documents\RAD Studio\7.0\Bpl\dclTP_LockBox3_D2010.bpl + WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias) + TurboPower LockBox 3 design-time package + true + true + 1 + true + ..\..\work-products\ephemeral\dcu\D2010\Win32 + x86 + 00400000 + + + false + RELEASE;$(DCC_Define) + 0 + false + + + DEBUG;$(DCC_Define) + + + + MainSource + + + + + + + + + +
TPLb_fmComponentAbout
+
+ + + Base + + + Cfg_2 + Base + + + Cfg_1 + Base + +
+ + + Delphi.Personality.12 + Package + + + + dclTP_LockBox3.dpk + + + False + True + False + + + True + False + 3 + 6 + 0 + 0 + False + False + False + False + False + 3081 + 1252 + + + + + 3.6.0.0 + + + + + + 3.6.00 + + + + + 12 + +
diff --git a/packages/d2010/dclTP_LockBox3.res b/LockBox3/packages/d2010/dclTP_LockBox3.res similarity index 100% rename from packages/d2010/dclTP_LockBox3.res rename to LockBox3/packages/d2010/dclTP_LockBox3.res diff --git a/resources/acorn16x16.bmp b/LockBox3/resources/acorn16x16.bmp similarity index 100% rename from resources/acorn16x16.bmp rename to LockBox3/resources/acorn16x16.bmp diff --git a/run/TPLB3.AES.pas b/LockBox3/run/TPLB3.AES.pas similarity index 96% rename from run/TPLB3.AES.pas rename to LockBox3/run/TPLB3.AES.pas index 1c6b0cb..1a4d470 100644 --- a/run/TPLB3.AES.pas +++ b/LockBox3/run/TPLB3.AES.pas @@ -1,809 +1,809 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.AES; -interface -uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; - -type - -{$IF compilerversion >= 21} [DesignDescription( -'From Wikipedia: QUOTE:'#13#10 + -'In cryptography, the Advanced Encryption Standard (AES) is a symmetric-key ' + -'encryption standard adopted by the U.S. government. The standard comprises ' + -'three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger ' + -'collection originally published as Rijndael. Each of these ciphers has a ' + -'128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. ' + -'The AES ciphers have been analyzed extensively and are now used worldwide, ' + -'as was the case with its predecessor,[3] the Data Encryption Standard (DES).'#13#10 + -#13#10 + -'AES was announced by National Institute of Standards and Technology (NIST) ' + -'as U.S. FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standa' + -'rdization process in which fifteen competing designs were presented and ' + -'evaluated before Rijndael was selected as the most suitable. It became ' + -'effective as a Federal government standard on May 26, 2002 after approval ' + -'by the Secretary of Commerce. AES is the first publicly accessible and open ' + -'cipher approved by the NSA for top secret information.'#13#10 + -'END QUOTE' -)] {$IFEND} -TAES = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm, IControlObject) - // The IControlObject interface is necessary to support the Design - // Description. - private - FKeySize: integer; // Either 128, 192, or 256 bits. - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; // in units of bits. Must be a multiple of 8. - function KeySize: integer; - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - function ControlObject: TObject; - - public - constructor Create( KeySize1: integer); - end; - - - - -implementation - - - -uses SysUtils, TPLB3.IntegerUtils, TPLB3.I18n, TPLB3.Constants; - - -/// THE FOLLOWING FRAGMENT WAS GENERATED BY THE PRECOMPUTE PROGRAM. -/// BEGIN FRAGMENT +++ -type -TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e); - -const -GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ( -( // fx01 --- Times 01 Table. - $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, - $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, - $20, $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, $47, $48, $49, $4A, $4B, $4C, $4D, $4E, $4F, - $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, - $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $6D, $6E, $6F, - $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $7A, $7B, $7C, $7D, $7E, $7F, - $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $8A, $8B, $8C, $8D, $8E, $8F, - $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $9E, $9F, - $A0, $A1, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD, $AE, $AF, - $B0, $B1, $B2, $B3, $B4, $B5, $B6, $B7, $B8, $B9, $BA, $BB, $BC, $BD, $BE, $BF, - $C0, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $C9, $CA, $CB, $CC, $CD, $CE, $CF, - $D0, $D1, $D2, $D3, $D4, $D5, $D6, $D7, $D8, $D9, $DA, $DB, $DC, $DD, $DE, $DF, - $E0, $E1, $E2, $E3, $E4, $E5, $E6, $E7, $E8, $E9, $EA, $EB, $EC, $ED, $EE, $EF, - $F0, $F1, $F2, $F3, $F4, $F5, $F6, $F7, $F8, $F9, $FA, $FB, $FC, $FD, $FE, $FF - ), - -( // fx02 --- Times 02 Table. - $00, $02, $04, $06, $08, $0A, $0C, $0E, $10, $12, $14, $16, $18, $1A, $1C, $1E, - $20, $22, $24, $26, $28, $2A, $2C, $2E, $30, $32, $34, $36, $38, $3A, $3C, $3E, - $40, $42, $44, $46, $48, $4A, $4C, $4E, $50, $52, $54, $56, $58, $5A, $5C, $5E, - $60, $62, $64, $66, $68, $6A, $6C, $6E, $70, $72, $74, $76, $78, $7A, $7C, $7E, - $80, $82, $84, $86, $88, $8A, $8C, $8E, $90, $92, $94, $96, $98, $9A, $9C, $9E, - $A0, $A2, $A4, $A6, $A8, $AA, $AC, $AE, $B0, $B2, $B4, $B6, $B8, $BA, $BC, $BE, - $C0, $C2, $C4, $C6, $C8, $CA, $CC, $CE, $D0, $D2, $D4, $D6, $D8, $DA, $DC, $DE, - $E0, $E2, $E4, $E6, $E8, $EA, $EC, $EE, $F0, $F2, $F4, $F6, $F8, $FA, $FC, $FE, - $1B, $19, $1F, $1D, $13, $11, $17, $15, $0B, $09, $0F, $0D, $03, $01, $07, $05, - $3B, $39, $3F, $3D, $33, $31, $37, $35, $2B, $29, $2F, $2D, $23, $21, $27, $25, - $5B, $59, $5F, $5D, $53, $51, $57, $55, $4B, $49, $4F, $4D, $43, $41, $47, $45, - $7B, $79, $7F, $7D, $73, $71, $77, $75, $6B, $69, $6F, $6D, $63, $61, $67, $65, - $9B, $99, $9F, $9D, $93, $91, $97, $95, $8B, $89, $8F, $8D, $83, $81, $87, $85, - $BB, $B9, $BF, $BD, $B3, $B1, $B7, $B5, $AB, $A9, $AF, $AD, $A3, $A1, $A7, $A5, - $DB, $D9, $DF, $DD, $D3, $D1, $D7, $D5, $CB, $C9, $CF, $CD, $C3, $C1, $C7, $C5, - $FB, $F9, $FF, $FD, $F3, $F1, $F7, $F5, $EB, $E9, $EF, $ED, $E3, $E1, $E7, $E5 - ), - -( // fx03 --- Times 03 Table. - $00, $03, $06, $05, $0C, $0F, $0A, $09, $18, $1B, $1E, $1D, $14, $17, $12, $11, - $30, $33, $36, $35, $3C, $3F, $3A, $39, $28, $2B, $2E, $2D, $24, $27, $22, $21, - $60, $63, $66, $65, $6C, $6F, $6A, $69, $78, $7B, $7E, $7D, $74, $77, $72, $71, - $50, $53, $56, $55, $5C, $5F, $5A, $59, $48, $4B, $4E, $4D, $44, $47, $42, $41, - $C0, $C3, $C6, $C5, $CC, $CF, $CA, $C9, $D8, $DB, $DE, $DD, $D4, $D7, $D2, $D1, - $F0, $F3, $F6, $F5, $FC, $FF, $FA, $F9, $E8, $EB, $EE, $ED, $E4, $E7, $E2, $E1, - $A0, $A3, $A6, $A5, $AC, $AF, $AA, $A9, $B8, $BB, $BE, $BD, $B4, $B7, $B2, $B1, - $90, $93, $96, $95, $9C, $9F, $9A, $99, $88, $8B, $8E, $8D, $84, $87, $82, $81, - $9B, $98, $9D, $9E, $97, $94, $91, $92, $83, $80, $85, $86, $8F, $8C, $89, $8A, - $AB, $A8, $AD, $AE, $A7, $A4, $A1, $A2, $B3, $B0, $B5, $B6, $BF, $BC, $B9, $BA, - $FB, $F8, $FD, $FE, $F7, $F4, $F1, $F2, $E3, $E0, $E5, $E6, $EF, $EC, $E9, $EA, - $CB, $C8, $CD, $CE, $C7, $C4, $C1, $C2, $D3, $D0, $D5, $D6, $DF, $DC, $D9, $DA, - $5B, $58, $5D, $5E, $57, $54, $51, $52, $43, $40, $45, $46, $4F, $4C, $49, $4A, - $6B, $68, $6D, $6E, $67, $64, $61, $62, $73, $70, $75, $76, $7F, $7C, $79, $7A, - $3B, $38, $3D, $3E, $37, $34, $31, $32, $23, $20, $25, $26, $2F, $2C, $29, $2A, - $0B, $08, $0D, $0E, $07, $04, $01, $02, $13, $10, $15, $16, $1F, $1C, $19, $1A - ), - -( // fx09 --- Times 09 Table. - $00, $09, $12, $1B, $24, $2D, $36, $3F, $48, $41, $5A, $53, $6C, $65, $7E, $77, - $90, $99, $82, $8B, $B4, $BD, $A6, $AF, $D8, $D1, $CA, $C3, $FC, $F5, $EE, $E7, - $3B, $32, $29, $20, $1F, $16, $0D, $04, $73, $7A, $61, $68, $57, $5E, $45, $4C, - $AB, $A2, $B9, $B0, $8F, $86, $9D, $94, $E3, $EA, $F1, $F8, $C7, $CE, $D5, $DC, - $76, $7F, $64, $6D, $52, $5B, $40, $49, $3E, $37, $2C, $25, $1A, $13, $08, $01, - $E6, $EF, $F4, $FD, $C2, $CB, $D0, $D9, $AE, $A7, $BC, $B5, $8A, $83, $98, $91, - $4D, $44, $5F, $56, $69, $60, $7B, $72, $05, $0C, $17, $1E, $21, $28, $33, $3A, - $DD, $D4, $CF, $C6, $F9, $F0, $EB, $E2, $95, $9C, $87, $8E, $B1, $B8, $A3, $AA, - $EC, $E5, $FE, $F7, $C8, $C1, $DA, $D3, $A4, $AD, $B6, $BF, $80, $89, $92, $9B, - $7C, $75, $6E, $67, $58, $51, $4A, $43, $34, $3D, $26, $2F, $10, $19, $02, $0B, - $D7, $DE, $C5, $CC, $F3, $FA, $E1, $E8, $9F, $96, $8D, $84, $BB, $B2, $A9, $A0, - $47, $4E, $55, $5C, $63, $6A, $71, $78, $0F, $06, $1D, $14, $2B, $22, $39, $30, - $9A, $93, $88, $81, $BE, $B7, $AC, $A5, $D2, $DB, $C0, $C9, $F6, $FF, $E4, $ED, - $0A, $03, $18, $11, $2E, $27, $3C, $35, $42, $4B, $50, $59, $66, $6F, $74, $7D, - $A1, $A8, $B3, $BA, $85, $8C, $97, $9E, $E9, $E0, $FB, $F2, $CD, $C4, $DF, $D6, - $31, $38, $23, $2A, $15, $1C, $07, $0E, $79, $70, $6B, $62, $5D, $54, $4F, $46 - ), - -( // fx0B --- Times 0B Table. - $00, $0B, $16, $1D, $2C, $27, $3A, $31, $58, $53, $4E, $45, $74, $7F, $62, $69, - $B0, $BB, $A6, $AD, $9C, $97, $8A, $81, $E8, $E3, $FE, $F5, $C4, $CF, $D2, $D9, - $7B, $70, $6D, $66, $57, $5C, $41, $4A, $23, $28, $35, $3E, $0F, $04, $19, $12, - $CB, $C0, $DD, $D6, $E7, $EC, $F1, $FA, $93, $98, $85, $8E, $BF, $B4, $A9, $A2, - $F6, $FD, $E0, $EB, $DA, $D1, $CC, $C7, $AE, $A5, $B8, $B3, $82, $89, $94, $9F, - $46, $4D, $50, $5B, $6A, $61, $7C, $77, $1E, $15, $08, $03, $32, $39, $24, $2F, - $8D, $86, $9B, $90, $A1, $AA, $B7, $BC, $D5, $DE, $C3, $C8, $F9, $F2, $EF, $E4, - $3D, $36, $2B, $20, $11, $1A, $07, $0C, $65, $6E, $73, $78, $49, $42, $5F, $54, - $F7, $FC, $E1, $EA, $DB, $D0, $CD, $C6, $AF, $A4, $B9, $B2, $83, $88, $95, $9E, - $47, $4C, $51, $5A, $6B, $60, $7D, $76, $1F, $14, $09, $02, $33, $38, $25, $2E, - $8C, $87, $9A, $91, $A0, $AB, $B6, $BD, $D4, $DF, $C2, $C9, $F8, $F3, $EE, $E5, - $3C, $37, $2A, $21, $10, $1B, $06, $0D, $64, $6F, $72, $79, $48, $43, $5E, $55, - $01, $0A, $17, $1C, $2D, $26, $3B, $30, $59, $52, $4F, $44, $75, $7E, $63, $68, - $B1, $BA, $A7, $AC, $9D, $96, $8B, $80, $E9, $E2, $FF, $F4, $C5, $CE, $D3, $D8, - $7A, $71, $6C, $67, $56, $5D, $40, $4B, $22, $29, $34, $3F, $0E, $05, $18, $13, - $CA, $C1, $DC, $D7, $E6, $ED, $F0, $FB, $92, $99, $84, $8F, $BE, $B5, $A8, $A3 - ), - -( // fx0D --- Times 0D Table. - $00, $0D, $1A, $17, $34, $39, $2E, $23, $68, $65, $72, $7F, $5C, $51, $46, $4B, - $D0, $DD, $CA, $C7, $E4, $E9, $FE, $F3, $B8, $B5, $A2, $AF, $8C, $81, $96, $9B, - $BB, $B6, $A1, $AC, $8F, $82, $95, $98, $D3, $DE, $C9, $C4, $E7, $EA, $FD, $F0, - $6B, $66, $71, $7C, $5F, $52, $45, $48, $03, $0E, $19, $14, $37, $3A, $2D, $20, - $6D, $60, $77, $7A, $59, $54, $43, $4E, $05, $08, $1F, $12, $31, $3C, $2B, $26, - $BD, $B0, $A7, $AA, $89, $84, $93, $9E, $D5, $D8, $CF, $C2, $E1, $EC, $FB, $F6, - $D6, $DB, $CC, $C1, $E2, $EF, $F8, $F5, $BE, $B3, $A4, $A9, $8A, $87, $90, $9D, - $06, $0B, $1C, $11, $32, $3F, $28, $25, $6E, $63, $74, $79, $5A, $57, $40, $4D, - $DA, $D7, $C0, $CD, $EE, $E3, $F4, $F9, $B2, $BF, $A8, $A5, $86, $8B, $9C, $91, - $0A, $07, $10, $1D, $3E, $33, $24, $29, $62, $6F, $78, $75, $56, $5B, $4C, $41, - $61, $6C, $7B, $76, $55, $58, $4F, $42, $09, $04, $13, $1E, $3D, $30, $27, $2A, - $B1, $BC, $AB, $A6, $85, $88, $9F, $92, $D9, $D4, $C3, $CE, $ED, $E0, $F7, $FA, - $B7, $BA, $AD, $A0, $83, $8E, $99, $94, $DF, $D2, $C5, $C8, $EB, $E6, $F1, $FC, - $67, $6A, $7D, $70, $53, $5E, $49, $44, $0F, $02, $15, $18, $3B, $36, $21, $2C, - $0C, $01, $16, $1B, $38, $35, $22, $2F, $64, $69, $7E, $73, $50, $5D, $4A, $47, - $DC, $D1, $C6, $CB, $E8, $E5, $F2, $FF, $B4, $B9, $AE, $A3, $80, $8D, $9A, $97 - ), - -( // fx0E --- Times 0E Table. - $00, $0E, $1C, $12, $38, $36, $24, $2A, $70, $7E, $6C, $62, $48, $46, $54, $5A, - $E0, $EE, $FC, $F2, $D8, $D6, $C4, $CA, $90, $9E, $8C, $82, $A8, $A6, $B4, $BA, - $DB, $D5, $C7, $C9, $E3, $ED, $FF, $F1, $AB, $A5, $B7, $B9, $93, $9D, $8F, $81, - $3B, $35, $27, $29, $03, $0D, $1F, $11, $4B, $45, $57, $59, $73, $7D, $6F, $61, - $AD, $A3, $B1, $BF, $95, $9B, $89, $87, $DD, $D3, $C1, $CF, $E5, $EB, $F9, $F7, - $4D, $43, $51, $5F, $75, $7B, $69, $67, $3D, $33, $21, $2F, $05, $0B, $19, $17, - $76, $78, $6A, $64, $4E, $40, $52, $5C, $06, $08, $1A, $14, $3E, $30, $22, $2C, - $96, $98, $8A, $84, $AE, $A0, $B2, $BC, $E6, $E8, $FA, $F4, $DE, $D0, $C2, $CC, - $41, $4F, $5D, $53, $79, $77, $65, $6B, $31, $3F, $2D, $23, $09, $07, $15, $1B, - $A1, $AF, $BD, $B3, $99, $97, $85, $8B, $D1, $DF, $CD, $C3, $E9, $E7, $F5, $FB, - $9A, $94, $86, $88, $A2, $AC, $BE, $B0, $EA, $E4, $F6, $F8, $D2, $DC, $CE, $C0, - $7A, $74, $66, $68, $42, $4C, $5E, $50, $0A, $04, $16, $18, $32, $3C, $2E, $20, - $EC, $E2, $F0, $FE, $D4, $DA, $C8, $C6, $9C, $92, $80, $8E, $A4, $AA, $B8, $B6, - $0C, $02, $10, $1E, $34, $3A, $28, $26, $7C, $72, $60, $6E, $44, $4A, $58, $56, - $37, $39, $2B, $25, $0F, $01, $13, $1D, $47, $49, $5B, $55, $7F, $71, $63, $6D, - $D7, $D9, $CB, $C5, $EF, $E1, $F3, $FD, $A7, $A9, $BB, $B5, $9F, $91, $83, $8D - ) - ); -/// END FRAGMENT --- - -type -TMatrix = array[ {product byte index:}0..3, - {factor byte index:}0..3 ] of TMixColsFactor; - -const - MixColumsMatrix: TMatrix = ( // Refer page 18 of the standard. - (fx02, fx03, fx01, fx01), - (fx01, fx02, fx03, fx01), - (fx01, fx01, fx02, fx03), - (fx03, fx01, fx01, fx02)); - - InvMixColumsMatrix: TMatrix = ( // Refer page 23 of the standard. - (fx0e, fx0b, fx0d, fx09), - (fx09, fx0e, fx0b, fx0d), - (fx0d, fx09, fx0e, fx0b), - (fx0b, fx0d, fx09, fx0e)); - - -const S_Box: array[ 0..255 ] of byte = ( - $63, $7c, $77, $7b, $f2, $6b, $6f, $c5, $30, $01, $67, $2b, $fe, $d7, $ab, $76, - $ca, $82, $c9, $7d, $fa, $59, $47, $f0, $ad, $d4, $a2, $af, $9c, $a4, $72, $c0, - $b7, $fd, $93, $26, $36, $3f, $f7, $cc, $34, $a5, $e5, $f1, $71, $d8, $31, $15, - $04, $c7, $23, $c3, $18, $96, $05, $9a, $07, $12, $80, $e2, $eb, $27, $b2, $75, - $09, $83, $2c, $1a, $1b, $6e, $5a, $a0, $52, $3b, $d6, $b3, $29, $e3, $2f, $84, - $53, $d1, $00, $ed, $20, $fc, $b1, $5b, $6a, $cb, $be, $39, $4a, $4c, $58, $cf, - $d0, $ef, $aa, $fb, $43, $4d, $33, $85, $45, $f9, $02, $7f, $50, $3c, $9f, $a8, - $51, $a3, $40, $8f, $92, $9d, $38, $f5, $bc, $b6, $da, $21, $10, $ff, $f3, $d2, - $cd, $0c, $13, $ec, $5f, $97, $44, $17, $c4, $a7, $7e, $3d, $64, $5d, $19, $73, - $60, $81, $4f, $dc, $22, $2a, $90, $88, $46, $ee, $b8, $14, $de, $5e, $0b, $db, - $e0, $32, $3a, $0a, $49, $06, $24, $5c, $c2, $d3, $ac, $62, $91, $95, $e4, $79, - $e7, $c8, $37, $6d, $8d, $d5, $4e, $a9, $6c, $56, $f4, $ea, $65, $7a, $ae, $08, - $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a, - $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e, - $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df, - $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16); - -var InvS_Box: array[ 0..255 ] of byte; - - -procedure InitUnit_AES; -var - Idx: byte; -begin -for Idx := 0 to 255 do - InvS_Box[ S_Box[ Idx]] := Idx -end; - - -procedure DoneUnit_AES; -begin -end; - - -function MulVector( const Matrix: TMatrix; Vector: uint32): uint32; -var - Row, Col: integer; - Temp: byte; -begin -for Row := 0 to 3 do - begin - Temp := 0; - for Col := 0 to 3 do - Temp := Temp xor GF2_8_TimesTables[ - Matrix[ Row, Col], - longrec( Vector).Bytes[ Col] - ]; - longrec( result).Bytes[ Row] := Temp - end -end; - - - -type -TAESKey = class( TSymetricKey) - private - FKeySize: integer; // 128, 192 or 256 - Nk: integer; // 4, 6 or 8 - Nr: integer; // 10, 12 or 14 - FCols: integer; // = Nb * (Nr+1) = 44, 52, 60 - w: array [ 0 .. 59 ] of uint32; // Logical length is 0 .. Nb*(Nr+1)-1 - - procedure ExpandKey; - - public - constructor Create( GenSeed: TStream; AES1: TAES); - constructor LoadFromStream( Store: TStream; AES1: TAES); - destructor Destroy; override; - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -TAESBlockCodec = class( TInterfacedObject, IBlockCodec) - private - FCipher: TAES; - FKey: TAESKey; - State: array[ 0..3 ] of uint32; - Nr: integer; - - procedure MulMatrix( const Matrix: TMatrix); - procedure Shift3rdRow; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - - procedure AddRoundKey( Column: integer); - procedure SubBytes; - procedure ShiftRows; - procedure MixColumns; - - procedure InvSubBytes; - procedure InvShiftRows; - procedure InvMixColumns; - - constructor Create( Cipher1: TAES; Key1: TAESKey); - destructor Destroy; override; - end; - - - -{ TAES } - -function TAES.BlockSize: integer; -begin -result := 128 -end; - - - -function TAES.ControlObject: TObject; -begin -result := self -end; - - -constructor TAES.Create( KeySize1: integer); -begin -FKeySize := KeySize1; -if (FKeySize <> 128) and (FKeySize <> 192) and (FKeySize <> 256) then - raise Exception.Create( 'Invalid key size for AES.') -end; - - - - -function TAES.DefinitionURL: string; -begin -result := 'http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf' -end; - - - - -function TAES.DisplayName: string; -begin -result := 'AES-%d' -end; - - - -function TAES.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afDisplayNameOnKeySize]; -if FKeySize = 256 then - Include( result, afStar) -end; - - - -function TAES.KeySize: integer; -begin -result := FKeySize -end; - - -function TAES.ProgId: string; -begin -result := Format( AES_ProgId, [FKeySize]) -end; - - -function TAES.SeedByteSize: integer; -begin -result := FKeySize div 8 -end; - - -function TAES.SelfTest_Key: string; // Refer appendix C. -begin -case FKeySize of - 128: result := '000102030405060708090a0b0c0d0e0f'; - 192: result := '000102030405060708090a0b0c0d0e0f1011121314151617'; - 256: result := '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'; - end -end; - - -function TAES.SelfTest_Plaintext: string; // Refer appendix C. -begin -result := '00112233445566778899aabbccddeeff' -end; - - -function TAES.SelfTest_Ciphertext: string; // Refer appendix C. -begin -case FKeySize of - 128: result := '69c4e0d86a7b0430d8cdb78070b4c55a'; - 192: result := 'dda97ca4864cdfe06eaf70a0ec0d7191'; - 256: result := '8ea2b7ca516745bfeafc49904b496089'; - end; -end; - -function TAES.WikipediaReference: string; -begin -result := 'Advanced_Encryption_Standard' -end; - - -function TAES.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := TAESKey.Create( Seed, self) -end; - - -function TAES.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TAESKey.LoadFromStream( Store, self) -end; - - -function TAES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := TAESBlockCodec.Create( self, Key as TAESKey) -end; - - - -{ TAESKey } - -procedure TAESKey.Burn; -begin -FillChar( w, SizeOf( W), 0) -end; - - -//const usingTestVectors = False; - -constructor TAESKey.Create( GenSeed: TStream; AES1: TAES); -begin -FKeySize := AES1.FKeySize; // 128, 192 or 256 -case FKeySize of - 128: begin Nk := 4; Nr := 10 end; - 192: begin Nk := 6; Nr := 12 end; - 256: begin Nk := 8; Nr := 14 end; - end; -FCols := 4 * (Nr+1); // 44, 52, 60 -GenSeed.ReadBuffer( w, FKeySize div 8); -{if usingTestVectors then - begin - case FKeySize of - 128: begin - w[0] := $16157e2b; // In appendix A, this is written as bigendien, - // but our integers are little-endien so this source - // appears to reverse the byte order. - w[1] := $a6d2ae28; - w[2] := $8815f7ab; - w[3] := $3c4fcf09; - end; - 192: begin - w[0] := $f7b0738e; - w[1] := $52640eda; - w[2] := $2bf310c8; - w[3] := $e5799080; - w[4] := $d2eaf862; - w[5] := $7b6b2c52; - end; - 256: begin - w[0] := $10eb3d60; - w[1] := $be71ca15; - w[2] := $f0ae732b; - w[3] := $81777d85; - w[4] := $072c351f; - w[5] := $d708613b; - w[6] := $a310982d; - w[7] := $f4df1409; - end; - end; - end; } -ExpandKey -end; - - - -destructor TAESKey.Destroy; -begin -Burn; -inherited -end; - - - -function SubWord( Value: uint32): uint32; -var - j: integer; -begin -for j := 0 to 3 do - longrec( result).Bytes[j] := S_Box[ longrec( Value).Bytes[j]] -end; - -function InvSubWord( Value: uint32): uint32; -var - j: integer; -begin -for j := 0 to 3 do - longrec( result).Bytes[j] := InvS_Box[ longrec( Value).Bytes[j]] -end; - -const Rcon: array[ 1..10 ] of uint32 = ( - $00000001, // In big-endien this is 0x01000000 - $00000002, - $00000004, - $00000008, - $00000010, - $00000020, - $00000040, - $00000080, - $0000001b, - $00000036); - -procedure TAESKey.ExpandKey; -var - i: integer; - Temp: uint32; - SubWord_Frequency: integer; - isNewExpandRound: boolean; -begin -if FKeySize <> 256 then - SubWord_Frequency := Nk - else - SubWord_Frequency := 4; -for i := Nk to FCols - 1 do - begin - Temp := w[ i - 1 ]; - isNewExpandRound := (i mod Nk) = 0; - if isNewExpandRound then - Temp := (Temp shr 8) or (Temp shl 24); - if (i mod SubWord_Frequency) = 0 then - Temp := SubWord( Temp) ; - if isNewExpandRound then - Temp := Temp XOR Rcon[ i div Nk ]; - w[i] := Temp XOR w[ i - Nk ] - end -end; - - - -constructor TAESKey.LoadFromStream( Store: TStream; AES1: TAES); -begin -FKeySize := AES1.FKeySize; // 128, 192 or 256 -case FKeySize of - 128: begin Nk := 4; Nr := 10 end; - 192: begin Nk := 6; Nr := 12 end; - 256: begin Nk := 8; Nr := 14 end; - end; -FCols := 4 * (Nr+1); // 44, 52, 60 -Store.ReadBuffer( w, FKeySize div 8); -ExpandKey -end; - - - -procedure TAESKey.SaveToStream( Stream: TStream); -begin -Stream.WriteBuffer( w, FKeySize div 8) -end; - - -{ TAESBlockCodec } - -procedure TAESBlockCodec.Burn; -begin -FillChar( State, SizeOf( State), 0) -end; - - - - -constructor TAESBlockCodec.Create( Cipher1: TAES; Key1: TAESKey); -begin -FCipher := Cipher1; -FKey := Key1; -FillChar( State, SizeOf( State), 0); -case FKey.FKeySize of - 128: Nr := 10; - 192: Nr := 12; - 256: Nr := 14; - end -end; - - - - -procedure TAESBlockCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - i: integer; -begin -Plaintext.Position := 0; -Plaintext.Read( State, SizeOf( State)); -AddRoundKey( 0); -for i := 1 to Nr do - begin - SubBytes; - ShiftRows; - if i <> Nr then - MixColumns; - AddRoundKey( i * 4) - end; -Ciphertext.Position := 0; -Ciphertext.Write( State, SizeOf( State)) -end; - - - -procedure TAESBlockCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - i: integer; -begin -Ciphertext.Position := 0; -Ciphertext.Read( State, SizeOf( State)); -for i := Nr downto 1 do - begin - AddRoundKey( i * 4); - if i <> Nr then - InvMixColumns; - InvShiftRows; - InvSubBytes - end; -AddRoundKey( 0); -Plaintext.Position := 0; -Plaintext.Write( State, SizeOf( State)) -end; - - - - -destructor TAESBlockCodec.Destroy; -begin -Burn; -inherited -end; - -procedure TAESBlockCodec.Reset; -begin -end; - - -procedure TAESBlockCodec.AddRoundKey( Column: integer); -var - j: integer; -begin -for j := 0 to 3 do - State[j] := State[j] XOR FKey.w[ Column + j] -end; - - - -procedure TAESBlockCodec.MulMatrix( const Matrix: TMatrix); -var - j: integer; -begin -for j := 0 to 3 do - State[j] := MulVector( Matrix, State[ j]) -end; - - -procedure TAESBlockCodec.MixColumns; -begin -MulMatrix( MixColumsMatrix) -end; - - -procedure TAESBlockCodec.InvMixColumns; -begin -MulMatrix( InvMixColumsMatrix) -end; - - - -procedure TAESBlockCodec.InvSubBytes; -var - j: integer; -begin -for j := 0 to 3 do - State[j] := InvSubWord( State[j]) -end; - - -procedure TAESBlockCodec.Shift3rdRow; -var - Mask, Temp: uint32; -begin -Mask := $00FF0000; // 3rd byte. -Temp := State[0] and Mask; -State[0] := (State[0] and (not Mask)) or (State[2] and Mask); -State[2] := (State[2] and (not Mask)) or Temp; -Temp := State[1] and Mask; -State[1] := (State[1] and (not Mask)) or (State[3] and Mask); -State[3] := (State[3] and (not Mask)) or Temp; -end; - - -procedure TAESBlockCodec.ShiftRows; -var - j: integer; - Mask, Temp: uint32; -begin -// Shift 2nd row left. -Mask := $0000FF00; // 2nd LS byte. -Temp := State[0] and Mask; -for j := 0 to 2 do - State[j] := (State[j] and (not Mask)) or (State[j+1] and Mask); -State[3] := (State[3] and (not Mask)) or Temp; -Shift3rdRow; -// Shift 4th row right. -Mask := $FF000000; // MS byte. -Temp := State[3] and Mask; -for j := 3 downto 1 do - State[j] := (State[j] and (not Mask)) or (State[j-1] and Mask); -State[0] := (State[0] and (not Mask)) or Temp -end; - - -procedure TAESBlockCodec.InvShiftRows; -var - j: integer; - Mask, Temp: uint32; -begin -// Shift 2nd row right. -Mask := $0000FF00; // 2nd LS byte. -Temp := State[3] and Mask; -for j := 3 downto 1 do - State[j] := (State[j] and (not Mask)) or (State[j-1] and Mask); -State[0] := (State[0] and (not Mask)) or Temp; -Shift3rdRow; -// Shift 4th row left. -Mask := $FF000000; // MS byte. -Temp := State[0] and Mask; -for j := 0 to 2 do - State[j] := (State[j] and (not Mask)) or (State[j+1] and Mask); -State[3] := (State[3] and (not Mask)) or Temp -end; - - -procedure TAESBlockCodec.SubBytes; -var - j: integer; -begin -for j := 0 to 3 do - State[j] := SubWord( State[j]) -end; - - - -initialization -InitUnit_AES; - -finalization -DoneUnit_AES; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.AES; +interface +uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; + +type + +{$IF compilerversion >= 21} [DesignDescription( +'From Wikipedia: QUOTE:'#13#10 + +'In cryptography, the Advanced Encryption Standard (AES) is a symmetric-key ' + +'encryption standard adopted by the U.S. government. The standard comprises ' + +'three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger ' + +'collection originally published as Rijndael. Each of these ciphers has a ' + +'128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. ' + +'The AES ciphers have been analyzed extensively and are now used worldwide, ' + +'as was the case with its predecessor,[3] the Data Encryption Standard (DES).'#13#10 + +#13#10 + +'AES was announced by National Institute of Standards and Technology (NIST) ' + +'as U.S. FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standa' + +'rdization process in which fifteen competing designs were presented and ' + +'evaluated before Rijndael was selected as the most suitable. It became ' + +'effective as a Federal government standard on May 26, 2002 after approval ' + +'by the Secretary of Commerce. AES is the first publicly accessible and open ' + +'cipher approved by the NSA for top secret information.'#13#10 + +'END QUOTE' +)] {$IFEND} +TAES = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm, IControlObject) + // The IControlObject interface is necessary to support the Design + // Description. + private + FKeySize: integer; // Either 128, 192, or 256 bits. + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; // in units of bits. Must be a multiple of 8. + function KeySize: integer; + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + function ControlObject: TObject; + + public + constructor Create( KeySize1: integer); + end; + + + + +implementation + + + +uses SysUtils, TPLB3.IntegerUtils, TPLB3.I18n, TPLB3.Constants; + + +/// THE FOLLOWING FRAGMENT WAS GENERATED BY THE PRECOMPUTE PROGRAM. +/// BEGIN FRAGMENT +++ +type +TMixColsFactor = (fx01, fx02, fx03, fx09, fx0b, fx0d, fx0e); + +const +GF2_8_TimesTables: array [ TMixColsFactor, 0..255 ] of byte = ( +( // fx01 --- Times 01 Table. + $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F, + $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1E, $1F, + $20, $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, $47, $48, $49, $4A, $4B, $4C, $4D, $4E, $4F, + $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $5B, $5C, $5D, $5E, $5F, + $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $6D, $6E, $6F, + $70, $71, $72, $73, $74, $75, $76, $77, $78, $79, $7A, $7B, $7C, $7D, $7E, $7F, + $80, $81, $82, $83, $84, $85, $86, $87, $88, $89, $8A, $8B, $8C, $8D, $8E, $8F, + $90, $91, $92, $93, $94, $95, $96, $97, $98, $99, $9A, $9B, $9C, $9D, $9E, $9F, + $A0, $A1, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD, $AE, $AF, + $B0, $B1, $B2, $B3, $B4, $B5, $B6, $B7, $B8, $B9, $BA, $BB, $BC, $BD, $BE, $BF, + $C0, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $C9, $CA, $CB, $CC, $CD, $CE, $CF, + $D0, $D1, $D2, $D3, $D4, $D5, $D6, $D7, $D8, $D9, $DA, $DB, $DC, $DD, $DE, $DF, + $E0, $E1, $E2, $E3, $E4, $E5, $E6, $E7, $E8, $E9, $EA, $EB, $EC, $ED, $EE, $EF, + $F0, $F1, $F2, $F3, $F4, $F5, $F6, $F7, $F8, $F9, $FA, $FB, $FC, $FD, $FE, $FF + ), + +( // fx02 --- Times 02 Table. + $00, $02, $04, $06, $08, $0A, $0C, $0E, $10, $12, $14, $16, $18, $1A, $1C, $1E, + $20, $22, $24, $26, $28, $2A, $2C, $2E, $30, $32, $34, $36, $38, $3A, $3C, $3E, + $40, $42, $44, $46, $48, $4A, $4C, $4E, $50, $52, $54, $56, $58, $5A, $5C, $5E, + $60, $62, $64, $66, $68, $6A, $6C, $6E, $70, $72, $74, $76, $78, $7A, $7C, $7E, + $80, $82, $84, $86, $88, $8A, $8C, $8E, $90, $92, $94, $96, $98, $9A, $9C, $9E, + $A0, $A2, $A4, $A6, $A8, $AA, $AC, $AE, $B0, $B2, $B4, $B6, $B8, $BA, $BC, $BE, + $C0, $C2, $C4, $C6, $C8, $CA, $CC, $CE, $D0, $D2, $D4, $D6, $D8, $DA, $DC, $DE, + $E0, $E2, $E4, $E6, $E8, $EA, $EC, $EE, $F0, $F2, $F4, $F6, $F8, $FA, $FC, $FE, + $1B, $19, $1F, $1D, $13, $11, $17, $15, $0B, $09, $0F, $0D, $03, $01, $07, $05, + $3B, $39, $3F, $3D, $33, $31, $37, $35, $2B, $29, $2F, $2D, $23, $21, $27, $25, + $5B, $59, $5F, $5D, $53, $51, $57, $55, $4B, $49, $4F, $4D, $43, $41, $47, $45, + $7B, $79, $7F, $7D, $73, $71, $77, $75, $6B, $69, $6F, $6D, $63, $61, $67, $65, + $9B, $99, $9F, $9D, $93, $91, $97, $95, $8B, $89, $8F, $8D, $83, $81, $87, $85, + $BB, $B9, $BF, $BD, $B3, $B1, $B7, $B5, $AB, $A9, $AF, $AD, $A3, $A1, $A7, $A5, + $DB, $D9, $DF, $DD, $D3, $D1, $D7, $D5, $CB, $C9, $CF, $CD, $C3, $C1, $C7, $C5, + $FB, $F9, $FF, $FD, $F3, $F1, $F7, $F5, $EB, $E9, $EF, $ED, $E3, $E1, $E7, $E5 + ), + +( // fx03 --- Times 03 Table. + $00, $03, $06, $05, $0C, $0F, $0A, $09, $18, $1B, $1E, $1D, $14, $17, $12, $11, + $30, $33, $36, $35, $3C, $3F, $3A, $39, $28, $2B, $2E, $2D, $24, $27, $22, $21, + $60, $63, $66, $65, $6C, $6F, $6A, $69, $78, $7B, $7E, $7D, $74, $77, $72, $71, + $50, $53, $56, $55, $5C, $5F, $5A, $59, $48, $4B, $4E, $4D, $44, $47, $42, $41, + $C0, $C3, $C6, $C5, $CC, $CF, $CA, $C9, $D8, $DB, $DE, $DD, $D4, $D7, $D2, $D1, + $F0, $F3, $F6, $F5, $FC, $FF, $FA, $F9, $E8, $EB, $EE, $ED, $E4, $E7, $E2, $E1, + $A0, $A3, $A6, $A5, $AC, $AF, $AA, $A9, $B8, $BB, $BE, $BD, $B4, $B7, $B2, $B1, + $90, $93, $96, $95, $9C, $9F, $9A, $99, $88, $8B, $8E, $8D, $84, $87, $82, $81, + $9B, $98, $9D, $9E, $97, $94, $91, $92, $83, $80, $85, $86, $8F, $8C, $89, $8A, + $AB, $A8, $AD, $AE, $A7, $A4, $A1, $A2, $B3, $B0, $B5, $B6, $BF, $BC, $B9, $BA, + $FB, $F8, $FD, $FE, $F7, $F4, $F1, $F2, $E3, $E0, $E5, $E6, $EF, $EC, $E9, $EA, + $CB, $C8, $CD, $CE, $C7, $C4, $C1, $C2, $D3, $D0, $D5, $D6, $DF, $DC, $D9, $DA, + $5B, $58, $5D, $5E, $57, $54, $51, $52, $43, $40, $45, $46, $4F, $4C, $49, $4A, + $6B, $68, $6D, $6E, $67, $64, $61, $62, $73, $70, $75, $76, $7F, $7C, $79, $7A, + $3B, $38, $3D, $3E, $37, $34, $31, $32, $23, $20, $25, $26, $2F, $2C, $29, $2A, + $0B, $08, $0D, $0E, $07, $04, $01, $02, $13, $10, $15, $16, $1F, $1C, $19, $1A + ), + +( // fx09 --- Times 09 Table. + $00, $09, $12, $1B, $24, $2D, $36, $3F, $48, $41, $5A, $53, $6C, $65, $7E, $77, + $90, $99, $82, $8B, $B4, $BD, $A6, $AF, $D8, $D1, $CA, $C3, $FC, $F5, $EE, $E7, + $3B, $32, $29, $20, $1F, $16, $0D, $04, $73, $7A, $61, $68, $57, $5E, $45, $4C, + $AB, $A2, $B9, $B0, $8F, $86, $9D, $94, $E3, $EA, $F1, $F8, $C7, $CE, $D5, $DC, + $76, $7F, $64, $6D, $52, $5B, $40, $49, $3E, $37, $2C, $25, $1A, $13, $08, $01, + $E6, $EF, $F4, $FD, $C2, $CB, $D0, $D9, $AE, $A7, $BC, $B5, $8A, $83, $98, $91, + $4D, $44, $5F, $56, $69, $60, $7B, $72, $05, $0C, $17, $1E, $21, $28, $33, $3A, + $DD, $D4, $CF, $C6, $F9, $F0, $EB, $E2, $95, $9C, $87, $8E, $B1, $B8, $A3, $AA, + $EC, $E5, $FE, $F7, $C8, $C1, $DA, $D3, $A4, $AD, $B6, $BF, $80, $89, $92, $9B, + $7C, $75, $6E, $67, $58, $51, $4A, $43, $34, $3D, $26, $2F, $10, $19, $02, $0B, + $D7, $DE, $C5, $CC, $F3, $FA, $E1, $E8, $9F, $96, $8D, $84, $BB, $B2, $A9, $A0, + $47, $4E, $55, $5C, $63, $6A, $71, $78, $0F, $06, $1D, $14, $2B, $22, $39, $30, + $9A, $93, $88, $81, $BE, $B7, $AC, $A5, $D2, $DB, $C0, $C9, $F6, $FF, $E4, $ED, + $0A, $03, $18, $11, $2E, $27, $3C, $35, $42, $4B, $50, $59, $66, $6F, $74, $7D, + $A1, $A8, $B3, $BA, $85, $8C, $97, $9E, $E9, $E0, $FB, $F2, $CD, $C4, $DF, $D6, + $31, $38, $23, $2A, $15, $1C, $07, $0E, $79, $70, $6B, $62, $5D, $54, $4F, $46 + ), + +( // fx0B --- Times 0B Table. + $00, $0B, $16, $1D, $2C, $27, $3A, $31, $58, $53, $4E, $45, $74, $7F, $62, $69, + $B0, $BB, $A6, $AD, $9C, $97, $8A, $81, $E8, $E3, $FE, $F5, $C4, $CF, $D2, $D9, + $7B, $70, $6D, $66, $57, $5C, $41, $4A, $23, $28, $35, $3E, $0F, $04, $19, $12, + $CB, $C0, $DD, $D6, $E7, $EC, $F1, $FA, $93, $98, $85, $8E, $BF, $B4, $A9, $A2, + $F6, $FD, $E0, $EB, $DA, $D1, $CC, $C7, $AE, $A5, $B8, $B3, $82, $89, $94, $9F, + $46, $4D, $50, $5B, $6A, $61, $7C, $77, $1E, $15, $08, $03, $32, $39, $24, $2F, + $8D, $86, $9B, $90, $A1, $AA, $B7, $BC, $D5, $DE, $C3, $C8, $F9, $F2, $EF, $E4, + $3D, $36, $2B, $20, $11, $1A, $07, $0C, $65, $6E, $73, $78, $49, $42, $5F, $54, + $F7, $FC, $E1, $EA, $DB, $D0, $CD, $C6, $AF, $A4, $B9, $B2, $83, $88, $95, $9E, + $47, $4C, $51, $5A, $6B, $60, $7D, $76, $1F, $14, $09, $02, $33, $38, $25, $2E, + $8C, $87, $9A, $91, $A0, $AB, $B6, $BD, $D4, $DF, $C2, $C9, $F8, $F3, $EE, $E5, + $3C, $37, $2A, $21, $10, $1B, $06, $0D, $64, $6F, $72, $79, $48, $43, $5E, $55, + $01, $0A, $17, $1C, $2D, $26, $3B, $30, $59, $52, $4F, $44, $75, $7E, $63, $68, + $B1, $BA, $A7, $AC, $9D, $96, $8B, $80, $E9, $E2, $FF, $F4, $C5, $CE, $D3, $D8, + $7A, $71, $6C, $67, $56, $5D, $40, $4B, $22, $29, $34, $3F, $0E, $05, $18, $13, + $CA, $C1, $DC, $D7, $E6, $ED, $F0, $FB, $92, $99, $84, $8F, $BE, $B5, $A8, $A3 + ), + +( // fx0D --- Times 0D Table. + $00, $0D, $1A, $17, $34, $39, $2E, $23, $68, $65, $72, $7F, $5C, $51, $46, $4B, + $D0, $DD, $CA, $C7, $E4, $E9, $FE, $F3, $B8, $B5, $A2, $AF, $8C, $81, $96, $9B, + $BB, $B6, $A1, $AC, $8F, $82, $95, $98, $D3, $DE, $C9, $C4, $E7, $EA, $FD, $F0, + $6B, $66, $71, $7C, $5F, $52, $45, $48, $03, $0E, $19, $14, $37, $3A, $2D, $20, + $6D, $60, $77, $7A, $59, $54, $43, $4E, $05, $08, $1F, $12, $31, $3C, $2B, $26, + $BD, $B0, $A7, $AA, $89, $84, $93, $9E, $D5, $D8, $CF, $C2, $E1, $EC, $FB, $F6, + $D6, $DB, $CC, $C1, $E2, $EF, $F8, $F5, $BE, $B3, $A4, $A9, $8A, $87, $90, $9D, + $06, $0B, $1C, $11, $32, $3F, $28, $25, $6E, $63, $74, $79, $5A, $57, $40, $4D, + $DA, $D7, $C0, $CD, $EE, $E3, $F4, $F9, $B2, $BF, $A8, $A5, $86, $8B, $9C, $91, + $0A, $07, $10, $1D, $3E, $33, $24, $29, $62, $6F, $78, $75, $56, $5B, $4C, $41, + $61, $6C, $7B, $76, $55, $58, $4F, $42, $09, $04, $13, $1E, $3D, $30, $27, $2A, + $B1, $BC, $AB, $A6, $85, $88, $9F, $92, $D9, $D4, $C3, $CE, $ED, $E0, $F7, $FA, + $B7, $BA, $AD, $A0, $83, $8E, $99, $94, $DF, $D2, $C5, $C8, $EB, $E6, $F1, $FC, + $67, $6A, $7D, $70, $53, $5E, $49, $44, $0F, $02, $15, $18, $3B, $36, $21, $2C, + $0C, $01, $16, $1B, $38, $35, $22, $2F, $64, $69, $7E, $73, $50, $5D, $4A, $47, + $DC, $D1, $C6, $CB, $E8, $E5, $F2, $FF, $B4, $B9, $AE, $A3, $80, $8D, $9A, $97 + ), + +( // fx0E --- Times 0E Table. + $00, $0E, $1C, $12, $38, $36, $24, $2A, $70, $7E, $6C, $62, $48, $46, $54, $5A, + $E0, $EE, $FC, $F2, $D8, $D6, $C4, $CA, $90, $9E, $8C, $82, $A8, $A6, $B4, $BA, + $DB, $D5, $C7, $C9, $E3, $ED, $FF, $F1, $AB, $A5, $B7, $B9, $93, $9D, $8F, $81, + $3B, $35, $27, $29, $03, $0D, $1F, $11, $4B, $45, $57, $59, $73, $7D, $6F, $61, + $AD, $A3, $B1, $BF, $95, $9B, $89, $87, $DD, $D3, $C1, $CF, $E5, $EB, $F9, $F7, + $4D, $43, $51, $5F, $75, $7B, $69, $67, $3D, $33, $21, $2F, $05, $0B, $19, $17, + $76, $78, $6A, $64, $4E, $40, $52, $5C, $06, $08, $1A, $14, $3E, $30, $22, $2C, + $96, $98, $8A, $84, $AE, $A0, $B2, $BC, $E6, $E8, $FA, $F4, $DE, $D0, $C2, $CC, + $41, $4F, $5D, $53, $79, $77, $65, $6B, $31, $3F, $2D, $23, $09, $07, $15, $1B, + $A1, $AF, $BD, $B3, $99, $97, $85, $8B, $D1, $DF, $CD, $C3, $E9, $E7, $F5, $FB, + $9A, $94, $86, $88, $A2, $AC, $BE, $B0, $EA, $E4, $F6, $F8, $D2, $DC, $CE, $C0, + $7A, $74, $66, $68, $42, $4C, $5E, $50, $0A, $04, $16, $18, $32, $3C, $2E, $20, + $EC, $E2, $F0, $FE, $D4, $DA, $C8, $C6, $9C, $92, $80, $8E, $A4, $AA, $B8, $B6, + $0C, $02, $10, $1E, $34, $3A, $28, $26, $7C, $72, $60, $6E, $44, $4A, $58, $56, + $37, $39, $2B, $25, $0F, $01, $13, $1D, $47, $49, $5B, $55, $7F, $71, $63, $6D, + $D7, $D9, $CB, $C5, $EF, $E1, $F3, $FD, $A7, $A9, $BB, $B5, $9F, $91, $83, $8D + ) + ); +/// END FRAGMENT --- + +type +TMatrix = array[ {product byte index:}0..3, + {factor byte index:}0..3 ] of TMixColsFactor; + +const + MixColumsMatrix: TMatrix = ( // Refer page 18 of the standard. + (fx02, fx03, fx01, fx01), + (fx01, fx02, fx03, fx01), + (fx01, fx01, fx02, fx03), + (fx03, fx01, fx01, fx02)); + + InvMixColumsMatrix: TMatrix = ( // Refer page 23 of the standard. + (fx0e, fx0b, fx0d, fx09), + (fx09, fx0e, fx0b, fx0d), + (fx0d, fx09, fx0e, fx0b), + (fx0b, fx0d, fx09, fx0e)); + + +const S_Box: array[ 0..255 ] of byte = ( + $63, $7c, $77, $7b, $f2, $6b, $6f, $c5, $30, $01, $67, $2b, $fe, $d7, $ab, $76, + $ca, $82, $c9, $7d, $fa, $59, $47, $f0, $ad, $d4, $a2, $af, $9c, $a4, $72, $c0, + $b7, $fd, $93, $26, $36, $3f, $f7, $cc, $34, $a5, $e5, $f1, $71, $d8, $31, $15, + $04, $c7, $23, $c3, $18, $96, $05, $9a, $07, $12, $80, $e2, $eb, $27, $b2, $75, + $09, $83, $2c, $1a, $1b, $6e, $5a, $a0, $52, $3b, $d6, $b3, $29, $e3, $2f, $84, + $53, $d1, $00, $ed, $20, $fc, $b1, $5b, $6a, $cb, $be, $39, $4a, $4c, $58, $cf, + $d0, $ef, $aa, $fb, $43, $4d, $33, $85, $45, $f9, $02, $7f, $50, $3c, $9f, $a8, + $51, $a3, $40, $8f, $92, $9d, $38, $f5, $bc, $b6, $da, $21, $10, $ff, $f3, $d2, + $cd, $0c, $13, $ec, $5f, $97, $44, $17, $c4, $a7, $7e, $3d, $64, $5d, $19, $73, + $60, $81, $4f, $dc, $22, $2a, $90, $88, $46, $ee, $b8, $14, $de, $5e, $0b, $db, + $e0, $32, $3a, $0a, $49, $06, $24, $5c, $c2, $d3, $ac, $62, $91, $95, $e4, $79, + $e7, $c8, $37, $6d, $8d, $d5, $4e, $a9, $6c, $56, $f4, $ea, $65, $7a, $ae, $08, + $ba, $78, $25, $2e, $1c, $a6, $b4, $c6, $e8, $dd, $74, $1f, $4b, $bd, $8b, $8a, + $70, $3e, $b5, $66, $48, $03, $f6, $0e, $61, $35, $57, $b9, $86, $c1, $1d, $9e, + $e1, $f8, $98, $11, $69, $d9, $8e, $94, $9b, $1e, $87, $e9, $ce, $55, $28, $df, + $8c, $a1, $89, $0d, $bf, $e6, $42, $68, $41, $99, $2d, $0f, $b0, $54, $bb, $16); + +var InvS_Box: array[ 0..255 ] of byte; + + +procedure InitUnit_AES; +var + Idx: byte; +begin +for Idx := 0 to 255 do + InvS_Box[ S_Box[ Idx]] := Idx +end; + + +procedure DoneUnit_AES; +begin +end; + + +function MulVector( const Matrix: TMatrix; Vector: uint32): uint32; +var + Row, Col: integer; + Temp: byte; +begin +for Row := 0 to 3 do + begin + Temp := 0; + for Col := 0 to 3 do + Temp := Temp xor GF2_8_TimesTables[ + Matrix[ Row, Col], + longrec( Vector).Bytes[ Col] + ]; + longrec( result).Bytes[ Row] := Temp + end +end; + + + +type +TAESKey = class( TSymetricKey) + private + FKeySize: integer; // 128, 192 or 256 + Nk: integer; // 4, 6 or 8 + Nr: integer; // 10, 12 or 14 + FCols: integer; // = Nb * (Nr+1) = 44, 52, 60 + w: array [ 0 .. 59 ] of uint32; // Logical length is 0 .. Nb*(Nr+1)-1 + + procedure ExpandKey; + + public + constructor Create( GenSeed: TStream; AES1: TAES); + constructor LoadFromStream( Store: TStream; AES1: TAES); + destructor Destroy; override; + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +TAESBlockCodec = class( TInterfacedObject, IBlockCodec) + private + FCipher: TAES; + FKey: TAESKey; + State: array[ 0..3 ] of uint32; + Nr: integer; + + procedure MulMatrix( const Matrix: TMatrix); + procedure Shift3rdRow; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + + procedure AddRoundKey( Column: integer); + procedure SubBytes; + procedure ShiftRows; + procedure MixColumns; + + procedure InvSubBytes; + procedure InvShiftRows; + procedure InvMixColumns; + + constructor Create( Cipher1: TAES; Key1: TAESKey); + destructor Destroy; override; + end; + + + +{ TAES } + +function TAES.BlockSize: integer; +begin +result := 128 +end; + + + +function TAES.ControlObject: TObject; +begin +result := self +end; + + +constructor TAES.Create( KeySize1: integer); +begin +FKeySize := KeySize1; +if (FKeySize <> 128) and (FKeySize <> 192) and (FKeySize <> 256) then + raise Exception.Create( 'Invalid key size for AES.') +end; + + + + +function TAES.DefinitionURL: string; +begin +result := 'http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf' +end; + + + + +function TAES.DisplayName: string; +begin +result := 'AES-%d' +end; + + + +function TAES.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afDisplayNameOnKeySize]; +if FKeySize = 256 then + Include( result, afStar) +end; + + + +function TAES.KeySize: integer; +begin +result := FKeySize +end; + + +function TAES.ProgId: string; +begin +result := Format( AES_ProgId, [FKeySize]) +end; + + +function TAES.SeedByteSize: integer; +begin +result := FKeySize div 8 +end; + + +function TAES.SelfTest_Key: string; // Refer appendix C. +begin +case FKeySize of + 128: result := '000102030405060708090a0b0c0d0e0f'; + 192: result := '000102030405060708090a0b0c0d0e0f1011121314151617'; + 256: result := '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'; + end +end; + + +function TAES.SelfTest_Plaintext: string; // Refer appendix C. +begin +result := '00112233445566778899aabbccddeeff' +end; + + +function TAES.SelfTest_Ciphertext: string; // Refer appendix C. +begin +case FKeySize of + 128: result := '69c4e0d86a7b0430d8cdb78070b4c55a'; + 192: result := 'dda97ca4864cdfe06eaf70a0ec0d7191'; + 256: result := '8ea2b7ca516745bfeafc49904b496089'; + end; +end; + +function TAES.WikipediaReference: string; +begin +result := 'Advanced_Encryption_Standard' +end; + + +function TAES.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := TAESKey.Create( Seed, self) +end; + + +function TAES.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TAESKey.LoadFromStream( Store, self) +end; + + +function TAES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := TAESBlockCodec.Create( self, Key as TAESKey) +end; + + + +{ TAESKey } + +procedure TAESKey.Burn; +begin +FillChar( w, SizeOf( W), 0) +end; + + +//const usingTestVectors = False; + +constructor TAESKey.Create( GenSeed: TStream; AES1: TAES); +begin +FKeySize := AES1.FKeySize; // 128, 192 or 256 +case FKeySize of + 128: begin Nk := 4; Nr := 10 end; + 192: begin Nk := 6; Nr := 12 end; + 256: begin Nk := 8; Nr := 14 end; + end; +FCols := 4 * (Nr+1); // 44, 52, 60 +GenSeed.ReadBuffer( w, FKeySize div 8); +{if usingTestVectors then + begin + case FKeySize of + 128: begin + w[0] := $16157e2b; // In appendix A, this is written as bigendien, + // but our integers are little-endien so this source + // appears to reverse the byte order. + w[1] := $a6d2ae28; + w[2] := $8815f7ab; + w[3] := $3c4fcf09; + end; + 192: begin + w[0] := $f7b0738e; + w[1] := $52640eda; + w[2] := $2bf310c8; + w[3] := $e5799080; + w[4] := $d2eaf862; + w[5] := $7b6b2c52; + end; + 256: begin + w[0] := $10eb3d60; + w[1] := $be71ca15; + w[2] := $f0ae732b; + w[3] := $81777d85; + w[4] := $072c351f; + w[5] := $d708613b; + w[6] := $a310982d; + w[7] := $f4df1409; + end; + end; + end; } +ExpandKey +end; + + + +destructor TAESKey.Destroy; +begin +Burn; +inherited +end; + + + +function SubWord( Value: uint32): uint32; +var + j: integer; +begin +for j := 0 to 3 do + longrec( result).Bytes[j] := S_Box[ longrec( Value).Bytes[j]] +end; + +function InvSubWord( Value: uint32): uint32; +var + j: integer; +begin +for j := 0 to 3 do + longrec( result).Bytes[j] := InvS_Box[ longrec( Value).Bytes[j]] +end; + +const Rcon: array[ 1..10 ] of uint32 = ( + $00000001, // In big-endien this is 0x01000000 + $00000002, + $00000004, + $00000008, + $00000010, + $00000020, + $00000040, + $00000080, + $0000001b, + $00000036); + +procedure TAESKey.ExpandKey; +var + i: integer; + Temp: uint32; + SubWord_Frequency: integer; + isNewExpandRound: boolean; +begin +if FKeySize <> 256 then + SubWord_Frequency := Nk + else + SubWord_Frequency := 4; +for i := Nk to FCols - 1 do + begin + Temp := w[ i - 1 ]; + isNewExpandRound := (i mod Nk) = 0; + if isNewExpandRound then + Temp := (Temp shr 8) or (Temp shl 24); + if (i mod SubWord_Frequency) = 0 then + Temp := SubWord( Temp) ; + if isNewExpandRound then + Temp := Temp XOR Rcon[ i div Nk ]; + w[i] := Temp XOR w[ i - Nk ] + end +end; + + + +constructor TAESKey.LoadFromStream( Store: TStream; AES1: TAES); +begin +FKeySize := AES1.FKeySize; // 128, 192 or 256 +case FKeySize of + 128: begin Nk := 4; Nr := 10 end; + 192: begin Nk := 6; Nr := 12 end; + 256: begin Nk := 8; Nr := 14 end; + end; +FCols := 4 * (Nr+1); // 44, 52, 60 +Store.ReadBuffer( w, FKeySize div 8); +ExpandKey +end; + + + +procedure TAESKey.SaveToStream( Stream: TStream); +begin +Stream.WriteBuffer( w, FKeySize div 8) +end; + + +{ TAESBlockCodec } + +procedure TAESBlockCodec.Burn; +begin +FillChar( State, SizeOf( State), 0) +end; + + + + +constructor TAESBlockCodec.Create( Cipher1: TAES; Key1: TAESKey); +begin +FCipher := Cipher1; +FKey := Key1; +FillChar( State, SizeOf( State), 0); +case FKey.FKeySize of + 128: Nr := 10; + 192: Nr := 12; + 256: Nr := 14; + end +end; + + + + +procedure TAESBlockCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + i: integer; +begin +Plaintext.Position := 0; +Plaintext.Read( State, SizeOf( State)); +AddRoundKey( 0); +for i := 1 to Nr do + begin + SubBytes; + ShiftRows; + if i <> Nr then + MixColumns; + AddRoundKey( i * 4) + end; +Ciphertext.Position := 0; +Ciphertext.Write( State, SizeOf( State)) +end; + + + +procedure TAESBlockCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + i: integer; +begin +Ciphertext.Position := 0; +Ciphertext.Read( State, SizeOf( State)); +for i := Nr downto 1 do + begin + AddRoundKey( i * 4); + if i <> Nr then + InvMixColumns; + InvShiftRows; + InvSubBytes + end; +AddRoundKey( 0); +Plaintext.Position := 0; +Plaintext.Write( State, SizeOf( State)) +end; + + + + +destructor TAESBlockCodec.Destroy; +begin +Burn; +inherited +end; + +procedure TAESBlockCodec.Reset; +begin +end; + + +procedure TAESBlockCodec.AddRoundKey( Column: integer); +var + j: integer; +begin +for j := 0 to 3 do + State[j] := State[j] XOR FKey.w[ Column + j] +end; + + + +procedure TAESBlockCodec.MulMatrix( const Matrix: TMatrix); +var + j: integer; +begin +for j := 0 to 3 do + State[j] := MulVector( Matrix, State[ j]) +end; + + +procedure TAESBlockCodec.MixColumns; +begin +MulMatrix( MixColumsMatrix) +end; + + +procedure TAESBlockCodec.InvMixColumns; +begin +MulMatrix( InvMixColumsMatrix) +end; + + + +procedure TAESBlockCodec.InvSubBytes; +var + j: integer; +begin +for j := 0 to 3 do + State[j] := InvSubWord( State[j]) +end; + + +procedure TAESBlockCodec.Shift3rdRow; +var + Mask, Temp: uint32; +begin +Mask := $00FF0000; // 3rd byte. +Temp := State[0] and Mask; +State[0] := (State[0] and (not Mask)) or (State[2] and Mask); +State[2] := (State[2] and (not Mask)) or Temp; +Temp := State[1] and Mask; +State[1] := (State[1] and (not Mask)) or (State[3] and Mask); +State[3] := (State[3] and (not Mask)) or Temp; +end; + + +procedure TAESBlockCodec.ShiftRows; +var + j: integer; + Mask, Temp: uint32; +begin +// Shift 2nd row left. +Mask := $0000FF00; // 2nd LS byte. +Temp := State[0] and Mask; +for j := 0 to 2 do + State[j] := (State[j] and (not Mask)) or (State[j+1] and Mask); +State[3] := (State[3] and (not Mask)) or Temp; +Shift3rdRow; +// Shift 4th row right. +Mask := $FF000000; // MS byte. +Temp := State[3] and Mask; +for j := 3 downto 1 do + State[j] := (State[j] and (not Mask)) or (State[j-1] and Mask); +State[0] := (State[0] and (not Mask)) or Temp +end; + + +procedure TAESBlockCodec.InvShiftRows; +var + j: integer; + Mask, Temp: uint32; +begin +// Shift 2nd row right. +Mask := $0000FF00; // 2nd LS byte. +Temp := State[3] and Mask; +for j := 3 downto 1 do + State[j] := (State[j] and (not Mask)) or (State[j-1] and Mask); +State[0] := (State[0] and (not Mask)) or Temp; +Shift3rdRow; +// Shift 4th row left. +Mask := $FF000000; // MS byte. +Temp := State[0] and Mask; +for j := 0 to 2 do + State[j] := (State[j] and (not Mask)) or (State[j+1] and Mask); +State[3] := (State[3] and (not Mask)) or Temp +end; + + +procedure TAESBlockCodec.SubBytes; +var + j: integer; +begin +for j := 0 to 3 do + State[j] := SubWord( State[j]) +end; + + + +initialization +InitUnit_AES; + +finalization +DoneUnit_AES; + +end. diff --git a/run/TPLB3.Asymetric.pas b/LockBox3/run/TPLB3.Asymetric.pas similarity index 96% rename from run/TPLB3.Asymetric.pas rename to LockBox3/run/TPLB3.Asymetric.pas index bfc6585..280ec9f 100644 --- a/run/TPLB3.Asymetric.pas +++ b/LockBox3/run/TPLB3.Asymetric.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,591 +12,591 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Asymetric; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.CodecIntf; - -type - -TKeyStoragePart = (partPublic, partPrivate); -TKeyStoragePartSet = set of TKeyStoragePart; - -TAsymtricKeyPart = class( TObject) - protected - function NominalKeyBitLength: cardinal; virtual; abstract; - public - procedure SaveToStream ( Store: TStream); virtual; abstract; - procedure LoadFromStream( Store: TStream); virtual; abstract; - function isEmpty: boolean; virtual; abstract; - procedure Burn; virtual; abstract; - end; - -TAsymetricKeyPair = class( TSymetricKey) - public - FPublicPart : TAsymtricKeyPart; - FPrivatePart: TAsymtricKeyPart; - - constructor CreateEmpty; virtual; abstract; - destructor Destroy; override; - function HasParts: TKeyStoragePartSet; virtual; - procedure SaveToStream( Stream: TStream); override; - procedure StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); virtual; - function Can_StoreToStream( Parts: TKeyStoragePartSet): boolean; virtual; - procedure LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); virtual; abstract; - function NominalKeyBitLength: cardinal; - procedure Burn; override; - function Clone: TAsymetricKeyPair; virtual; - end; - -TAsymetricKeyPairClass = class of TAsymetricKeyPair; - -TAsymetricEncDec = class( TInterfacedObject) - protected - FBytesProcessed: uint64; - FSymetricCodec: ICodec; - FSymetricCodecObj: TObject; - constructor Create; virtual; - procedure Reset; virtual; - - public - destructor Destroy; override; - end; - - - - -TAsymetricEncryptor = class( TAsymetricEncDec, IStreamEncryptor) - protected - FPublicKey: TAsymtricKeyPart; // Non-owned. - FCipherText: TStream; // Non-owned. - - constructor Start_Encrypt( PublicKey1: TAsymtricKeyPart; CipherText1: TStream); virtual; - - procedure Encrypt( const Plaintext: TStream); virtual; - procedure End_Encrypt; virtual; - - public - function GenerateSymetricKey: TSymetricKey; virtual; abstract; - function VerifySignature( - Document: TStream; // FCipherText is the signature to be verified. - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean): boolean; virtual; abstract; - end; -TAsymetricEncryptorClass = class of TAsymetricEncryptor; - -TAsymetricDecryptor = class( TAsymetricEncDec, IStreamDecryptor) - protected - FPrivateKey: TAsymtricKeyPart; // Non-owned. - FPlainText: TStream; // Non-owned. - - constructor Start_Decrypt( PrivateKey1: TAsymtricKeyPart; PlainText1: TStream); virtual; - - procedure Decrypt( const Ciphertext: TStream); virtual; - procedure End_Decrypt; virtual; - - public - function LoadSymetricKey( Ciphertext: TStream): TSymetricKey; virtual; abstract; - procedure Sign( // FPlaintext is the document to be signed. - Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean); virtual; abstract; - end; -TAsymetricDecryptorClass = class of TAsymetricDecryptor; - -IAsymetric_Engine = interface( IStreamCipher) - ['{F6B035A8-2829-4F43-B95C-14C77A22B379}'] - procedure GenerateAsymetricKeyPair( - KeySizeInBits: cardinal; - ProgressSender: TObject; - ProgressEvent: TGenerateAsymetricKeyPairProgress; - var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); - - procedure Sign( - Document, Signature: TStream; - PrivatePart: TAsymtricKeyPart; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean); - - function VerifySignature( - Document, Signature: TStream; - PublicPart: TAsymtricKeyPart; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean): boolean; - - function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): TAsymetricKeyPair; - end; - -ICodec_WithAsymetricSupport = interface( ICodec) -['{76B67794-CB5A-41BA-B519-9250FDC592C6}'] - function Asymetric_Engine: IAsymetric_Engine; - end; - -TAsymetric_Engine = class( TInterfacedObject, - IStreamCipher, ICryptoGraphicAlgorithm, IAsymetric_Engine) - protected - // ICryptoGraphicAlgorithm - function DisplayName: string; virtual; abstract; - function ProgId: string; virtual; abstract; - function Features: TAlgorithmicFeatureSet; virtual; - function DefinitionURL: string; virtual; abstract; - function WikipediaReference: string; virtual; abstract; - - // IStreamCipher = interface( ) - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; virtual; abstract; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; virtual; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; virtual; - function AsymetricKeyPairClass: TAsymetricKeyPairClass; virtual; abstract; - function EncClass: TAsymetricEncryptorClass; virtual; abstract; - function DecClass: TAsymetricDecryptorClass; virtual; abstract; - - public - procedure GenerateAsymetricKeyPair( - KeySizeInBits: cardinal; - ProgressSender: TObject; - ProgressEvent: TGenerateAsymetricKeyPairProgress; - var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); - virtual; abstract; - - procedure Sign( - Document, Signature: TStream; - PrivatePart: TAsymtricKeyPart; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean); virtual; - - function VerifySignature( - Document, Signature: TStream; - PublicPart: TAsymtricKeyPart; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean): boolean; virtual; - - function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): - TAsymetricKeyPair; virtual; abstract; - end; - - - - -implementation - - - - - -uses SysUtils, TPLB3.StreamToBlock, TPLB3.AES, TPLB3.CBC, TPLB3.Codec, - TPLB3.PointerArithmetic, Math; -{ TAsymetricKeyPair } - -procedure TAsymetricKeyPair.Burn; -begin -FPublicPart.Burn; -FPrivatePart.Burn -end; - - -function TAsymetricKeyPair.Clone: TAsymetricKeyPair; -var - Memento: TStream; - Parts: TKeyStoragePartSet; -begin -Parts := HasParts; -result := TAsymetricKeyPairClass( ClassType).CreateEmpty; -Memento := TMemoryStream.Create; -try -StoreToStream( Memento, Parts); -Memento.Position := 0; -result.LoadFromStream( Memento, Parts) -finally -Memento.Free -end end; - - - - -destructor TAsymetricKeyPair.Destroy; -begin -FPublicPart.Free; -FPrivatePart.Free; -inherited -end; - - - -function TAsymetricKeyPair.HasParts: TKeyStoragePartSet; -begin -result := []; -if assigned( FPublicPart) and (not FPublicPart.isEmpty) then - Include( result, partPublic); -if assigned( FPrivatePart) and (not FPrivatePart.isEmpty) then - Include( result, partPrivate) -end; - - -function TAsymetricKeyPair.NominalKeyBitLength: cardinal; -var - Part : TAsymtricKeyPart; -begin -Part := FPublicPart; -if not assigned( Part) then - Part := FPrivatepart; -if assigned( Part) then - result := Part.NominalKeyBitLength - else - result := 0 -end; - - - -function TAsymetricKeyPair.Can_StoreToStream( - Parts: TKeyStoragePartSet): boolean; -begin -result := (Parts * HasParts) = Parts -end; - - - -procedure TAsymetricKeyPair.SaveToStream( Stream: TStream); -begin -StoreToStream( Stream, [partPublic, partPrivate]) -end; - - -procedure TAsymetricKeyPair.StoreToStream( - Store: TStream; Parts: TKeyStoragePartSet); -var - hasPart: boolean; -begin -if partPublic in Parts then - begin - hasPart := assigned( FPublicPart) and (not FPublicPart.isEmpty); - Store.WriteBuffer( hasPart, SizeOf( hasPart)); - if hasPart then - FPublicPart.SaveToStream( Store) - end; -if partPrivate in Parts then - begin - hasPart := assigned( FPrivatePart) and (not FPrivatePart.isEmpty); - Store.WriteBuffer( hasPart, SizeOf( hasPart)); - if hasPart then - FPrivatePart.SaveToStream( Store) - end -end; - - -// Typically the concrete descendant of TAsymetricKeyPair will -// implement LoadFromStream something like this .... -//procedure TAsymetricKeyPair_DescendantClass.LoadFromStream( -// Store: TStream; Parts: TKeyStoragePartSet); -//var -// hasPart: boolean; -//begin -//if partPublic in Parts then -// begin -// Store.ReadBuffer( hasPart, SizeOf( hasPart)); -// FreeAndNil( FPublicPart); -// if hasPart then -// begin -// if not assigned( FPublicPart) then -// FPublicPart := TSomeClass.Create; -// FPublicPart.LoadFromStream( Store) -// end -// else if assigned( FPublicPart) then -// FPublicPart.Clear -// end; -//if partPrivate in Parts then -// begin -// Store.ReadBuffer( hasPart, SizeOf( hasPart)); -// FreeAndNil( FPrivatePart); -// if hasPart then -// begin -// if not assigned( FPrivatePart) then -// FPrivatePart := TSomeClass.Create; -// FPrivatePart.LoadFromStream( Store) -// end -// else if assigned( FPrivatePart) then -// FPrivatePart.Clear -// end -//end; - - - -{ TAsymetric_Engine } - -function TAsymetric_Engine.Features: TAlgorithmicFeatureSet; -begin -result := [ - afOpenSourceSoftware, - afDoesNotNeedSalt, // Only applicable to IStreamCiphers which are true - // crytographic codecs, that is to say they do not have the - // afCompressor or afConverter feature. Normally, stream ciphers will - // be used by injecting a 64 bit salt of random data at the start - // of the plaintext stream. However, if the cipher has this feature - // (afDoesNotNeedSalt) it means it is already salting its own - // tranform, or it cannot benefit from salt. In this case, users of - // IStreamCipher, such as TCodec will not salt the plaintext. - afAsymetric - ] -end; - - -function TAsymetric_Engine.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := nil -end; - -function TAsymetric_Engine.Parameterize( - const Params: IInterface): IStreamCipher; -begin -result := nil -end; - -function TAsymetric_Engine.SeedByteSize: integer; -begin -result := -1 -end; - -procedure TAsymetric_Engine.Sign( - Document, Signature: TStream; - PrivatePart: TAsymtricKeyPart; ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; var wasAborted: boolean); -var - Dec: TAsymetricDecryptorClass; - DecObj: TAsymetricDecryptor; - isCounted: boolean; -begin -Dec := DecClass; -DecObj := Dec.Start_Decrypt( PrivatePart, Document); -isCounted := DecObj._AddRef <> -1; -try -if not assigned( ProgressSender) then - ProgressSender := self; -wasAborted := False; -Document.Position := 0; -Signature.Size := 0; -DecObj.Sign( Signature, ProgressSender, ProgressEvent, wasAborted); -finally -DecObj._Release; -if not isCounted then - DecObj.Free -end end; - - -function TAsymetric_Engine.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin -if (Key is TAsymetricKeyPair) and - Assigned( TAsymetricKeyPair( Key).FPrivatePart) then - result := DecClass.Start_Decrypt( - TAsymetricKeyPair( Key).FPrivatePart, PlainText) - else - result := nil -end; - - -function TAsymetric_Engine.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -if (Key is TAsymetricKeyPair) and - Assigned( TAsymetricKeyPair( Key).FPublicPart) then - result := EncClass.Start_Encrypt( - TAsymetricKeyPair( Key).FPublicPart, CipherText) - else - result := nil -end; - - - -function TAsymetric_Engine.VerifySignature( Document, Signature: TStream; - PublicPart: TAsymtricKeyPart; ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; var wasAborted: boolean): boolean; -var - Enc: TAsymetricEncryptorClass; - EncObj: TAsymetricEncryptor; - isCounted: boolean; -begin -Enc := EncClass; -Signature.Position := 0; -EncObj := Enc.Start_Encrypt( PublicPart, Signature); -isCounted := EncObj._AddRef <> -1; -try -if not assigned( ProgressSender) then - ProgressSender := self; -wasAborted := False; -Document.Position := 0; -result := EncObj.VerifySignature( Document, ProgressSender, - ProgressEvent, wasAborted) -finally -EncObj._Release; -if not isCounted then - EncObj.Free -end end; - -{ TAsymetricEncDec } - -constructor TAsymetricEncDec.Create; -begin -FBytesProcessed := 0; -FSymetricCodecObj := TSimpleCodec.Create; -Supports( FSymetricCodecObj, ICodec, FSymetricCodec); -FSymetricCodec.StreamCipher := TStreamToBlock_Adapter.Create; -FSymetricCodec.BlockCipher := TAES.Create( 256); -FSymetricCodec.ChainMode := TCBC.Create -end; - - - -destructor TAsymetricEncDec.Destroy; -begin -FSymetricCodec := nil; -FSymetricCodecObj.Free; -inherited -end; - - - -procedure TAsymetricEncDec.Reset; -begin -FSymetricCodec.Reset; -FBytesProcessed := 0 -end; - - - -{ TAsymetricEncryptor } - -procedure TAsymetricEncryptor.Encrypt( const Plaintext: TStream); -var - Sz: cardinal; - Xfer: cardinal; - XferBuffer: array[0..255] of byte; -begin -Sz := PlainText.Size - Plaintext.Position; -if Sz <= 0 then exit; -if FBytesProcessed = 0 then - begin - FSymetricCodec.InitFromKey( GenerateSymetricKey); // Transfers ownership. - FSymetricCodec.Begin_EncryptMemory( FCipherText) - end; -Inc( FBytesProcessed, Sz); -if PlainText is TMemoryStream then - begin - FSymetricCodec.EncryptMemory( - MemStrmOffset( TMemoryStream( Plaintext), Plaintext.Position)^, - Sz); - PlainText.Seek( Sz, soCurrent) - end - else - begin - while Sz > 0 do - begin - Xfer := Min( Sz, SizeOf( XferBuffer)); - Xfer := Plaintext.Read( XferBuffer, Xfer); - if Xfer = 0 then break; - Dec( Sz, Xfer); - FSymetricCodec.EncryptMemory( XferBuffer, Xfer) - end; - end -end; - - -procedure TAsymetricEncryptor.End_Encrypt; -begin -if FBytesProcessed > 0 then - FSymetricCodec.End_EncryptMemory -end; - - -constructor TAsymetricEncryptor.Start_Encrypt( - PublicKey1: TAsymtricKeyPart; CipherText1: TStream); -begin -inherited Create; -FPublicKey := PublicKey1; -FCipherText := CipherText1 -end; - - - -{ TAsymetricDecryptor } - -procedure TAsymetricDecryptor.Decrypt( const Ciphertext: TStream); -var - Sz: cardinal; - Xfer: cardinal; - XferBuffer: array[0..255] of byte; - P1, P2: int64; - KeyDelta: cardinal; -begin -P1 := Ciphertext.Position; -Sz := Ciphertext.Size - P1; -if Sz <= 0 then exit; -if FBytesProcessed = 0 then - begin - FSymetricCodec.InitFromKey( LoadSymetricKey( Ciphertext)); // Transfers ownership. - P2 := Ciphertext.Position; - KeyDelta := P2 - P1; - Inc( FBytesProcessed, KeyDelta); - Dec( Sz, KeyDelta); - FSymetricCodec.Begin_DecryptMemory( FPlainText) - end; -Inc( FBytesProcessed, Sz); -if Ciphertext is TMemoryStream then - begin - FSymetricCodec.DecryptMemory( - MemStrmOffset( TMemoryStream( Ciphertext), Ciphertext.Position)^, - Sz); - Ciphertext.Seek( Sz, soCurrent) - end - else - begin - while Sz > 0 do - begin - Xfer := Min( Sz, SizeOf( XferBuffer)); - Xfer := Ciphertext.Read( XferBuffer, Xfer); - if Xfer = 0 then break; - Dec( Sz, Xfer); - FSymetricCodec.DecryptMemory( XferBuffer, Xfer) - end - end -end; - -procedure TAsymetricDecryptor.End_Decrypt; -begin -if FBytesProcessed > 0 then - FSymetricCodec.End_DecryptMemory -end; - -constructor TAsymetricDecryptor.Start_Decrypt( - PrivateKey1: TAsymtricKeyPart; PlainText1: TStream); -begin -inherited Create; -FPrivateKey := PrivateKey1; -FPlainText := PlainText1 -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Asymetric; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.CodecIntf; + +type + +TKeyStoragePart = (partPublic, partPrivate); +TKeyStoragePartSet = set of TKeyStoragePart; + +TAsymtricKeyPart = class( TObject) + protected + function NominalKeyBitLength: cardinal; virtual; abstract; + public + procedure SaveToStream ( Store: TStream); virtual; abstract; + procedure LoadFromStream( Store: TStream); virtual; abstract; + function isEmpty: boolean; virtual; abstract; + procedure Burn; virtual; abstract; + end; + +TAsymetricKeyPair = class( TSymetricKey) + public + FPublicPart : TAsymtricKeyPart; + FPrivatePart: TAsymtricKeyPart; + + constructor CreateEmpty; virtual; abstract; + destructor Destroy; override; + function HasParts: TKeyStoragePartSet; virtual; + procedure SaveToStream( Stream: TStream); override; + procedure StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); virtual; + function Can_StoreToStream( Parts: TKeyStoragePartSet): boolean; virtual; + procedure LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); virtual; abstract; + function NominalKeyBitLength: cardinal; + procedure Burn; override; + function Clone: TAsymetricKeyPair; virtual; + end; + +TAsymetricKeyPairClass = class of TAsymetricKeyPair; + +TAsymetricEncDec = class( TInterfacedObject) + protected + FBytesProcessed: uint64; + FSymetricCodec: ICodec; + FSymetricCodecObj: TObject; + constructor Create; virtual; + procedure Reset; virtual; + + public + destructor Destroy; override; + end; + + + + +TAsymetricEncryptor = class( TAsymetricEncDec, IStreamEncryptor) + protected + FPublicKey: TAsymtricKeyPart; // Non-owned. + FCipherText: TStream; // Non-owned. + + constructor Start_Encrypt( PublicKey1: TAsymtricKeyPart; CipherText1: TStream); virtual; + + procedure Encrypt( const Plaintext: TStream); virtual; + procedure End_Encrypt; virtual; + + public + function GenerateSymetricKey: TSymetricKey; virtual; abstract; + function VerifySignature( + Document: TStream; // FCipherText is the signature to be verified. + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean): boolean; virtual; abstract; + end; +TAsymetricEncryptorClass = class of TAsymetricEncryptor; + +TAsymetricDecryptor = class( TAsymetricEncDec, IStreamDecryptor) + protected + FPrivateKey: TAsymtricKeyPart; // Non-owned. + FPlainText: TStream; // Non-owned. + + constructor Start_Decrypt( PrivateKey1: TAsymtricKeyPart; PlainText1: TStream); virtual; + + procedure Decrypt( const Ciphertext: TStream); virtual; + procedure End_Decrypt; virtual; + + public + function LoadSymetricKey( Ciphertext: TStream): TSymetricKey; virtual; abstract; + procedure Sign( // FPlaintext is the document to be signed. + Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean); virtual; abstract; + end; +TAsymetricDecryptorClass = class of TAsymetricDecryptor; + +IAsymetric_Engine = interface( IStreamCipher) + ['{F6B035A8-2829-4F43-B95C-14C77A22B379}'] + procedure GenerateAsymetricKeyPair( + KeySizeInBits: cardinal; + ProgressSender: TObject; + ProgressEvent: TGenerateAsymetricKeyPairProgress; + var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); + + procedure Sign( + Document, Signature: TStream; + PrivatePart: TAsymtricKeyPart; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean); + + function VerifySignature( + Document, Signature: TStream; + PublicPart: TAsymtricKeyPart; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean): boolean; + + function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): TAsymetricKeyPair; + end; + +ICodec_WithAsymetricSupport = interface( ICodec) +['{76B67794-CB5A-41BA-B519-9250FDC592C6}'] + function Asymetric_Engine: IAsymetric_Engine; + end; + +TAsymetric_Engine = class( TInterfacedObject, + IStreamCipher, ICryptoGraphicAlgorithm, IAsymetric_Engine) + protected + // ICryptoGraphicAlgorithm + function DisplayName: string; virtual; abstract; + function ProgId: string; virtual; abstract; + function Features: TAlgorithmicFeatureSet; virtual; + function DefinitionURL: string; virtual; abstract; + function WikipediaReference: string; virtual; abstract; + + // IStreamCipher = interface( ) + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; virtual; abstract; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; virtual; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; virtual; + function AsymetricKeyPairClass: TAsymetricKeyPairClass; virtual; abstract; + function EncClass: TAsymetricEncryptorClass; virtual; abstract; + function DecClass: TAsymetricDecryptorClass; virtual; abstract; + + public + procedure GenerateAsymetricKeyPair( + KeySizeInBits: cardinal; + ProgressSender: TObject; + ProgressEvent: TGenerateAsymetricKeyPairProgress; + var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); + virtual; abstract; + + procedure Sign( + Document, Signature: TStream; + PrivatePart: TAsymtricKeyPart; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean); virtual; + + function VerifySignature( + Document, Signature: TStream; + PublicPart: TAsymtricKeyPart; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean): boolean; virtual; + + function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): + TAsymetricKeyPair; virtual; abstract; + end; + + + + +implementation + + + + + +uses SysUtils, TPLB3.StreamToBlock, TPLB3.AES, TPLB3.CBC, TPLB3.Codec, + TPLB3.PointerArithmetic, Math; +{ TAsymetricKeyPair } + +procedure TAsymetricKeyPair.Burn; +begin +FPublicPart.Burn; +FPrivatePart.Burn +end; + + +function TAsymetricKeyPair.Clone: TAsymetricKeyPair; +var + Memento: TStream; + Parts: TKeyStoragePartSet; +begin +Parts := HasParts; +result := TAsymetricKeyPairClass( ClassType).CreateEmpty; +Memento := TMemoryStream.Create; +try +StoreToStream( Memento, Parts); +Memento.Position := 0; +result.LoadFromStream( Memento, Parts) +finally +Memento.Free +end end; + + + + +destructor TAsymetricKeyPair.Destroy; +begin +FPublicPart.Free; +FPrivatePart.Free; +inherited +end; + + + +function TAsymetricKeyPair.HasParts: TKeyStoragePartSet; +begin +result := []; +if assigned( FPublicPart) and (not FPublicPart.isEmpty) then + Include( result, partPublic); +if assigned( FPrivatePart) and (not FPrivatePart.isEmpty) then + Include( result, partPrivate) +end; + + +function TAsymetricKeyPair.NominalKeyBitLength: cardinal; +var + Part : TAsymtricKeyPart; +begin +Part := FPublicPart; +if not assigned( Part) then + Part := FPrivatepart; +if assigned( Part) then + result := Part.NominalKeyBitLength + else + result := 0 +end; + + + +function TAsymetricKeyPair.Can_StoreToStream( + Parts: TKeyStoragePartSet): boolean; +begin +result := (Parts * HasParts) = Parts +end; + + + +procedure TAsymetricKeyPair.SaveToStream( Stream: TStream); +begin +StoreToStream( Stream, [partPublic, partPrivate]) +end; + + +procedure TAsymetricKeyPair.StoreToStream( + Store: TStream; Parts: TKeyStoragePartSet); +var + hasPart: boolean; +begin +if partPublic in Parts then + begin + hasPart := assigned( FPublicPart) and (not FPublicPart.isEmpty); + Store.WriteBuffer( hasPart, SizeOf( hasPart)); + if hasPart then + FPublicPart.SaveToStream( Store) + end; +if partPrivate in Parts then + begin + hasPart := assigned( FPrivatePart) and (not FPrivatePart.isEmpty); + Store.WriteBuffer( hasPart, SizeOf( hasPart)); + if hasPart then + FPrivatePart.SaveToStream( Store) + end +end; + + +// Typically the concrete descendant of TAsymetricKeyPair will +// implement LoadFromStream something like this .... +//procedure TAsymetricKeyPair_DescendantClass.LoadFromStream( +// Store: TStream; Parts: TKeyStoragePartSet); +//var +// hasPart: boolean; +//begin +//if partPublic in Parts then +// begin +// Store.ReadBuffer( hasPart, SizeOf( hasPart)); +// FreeAndNil( FPublicPart); +// if hasPart then +// begin +// if not assigned( FPublicPart) then +// FPublicPart := TSomeClass.Create; +// FPublicPart.LoadFromStream( Store) +// end +// else if assigned( FPublicPart) then +// FPublicPart.Clear +// end; +//if partPrivate in Parts then +// begin +// Store.ReadBuffer( hasPart, SizeOf( hasPart)); +// FreeAndNil( FPrivatePart); +// if hasPart then +// begin +// if not assigned( FPrivatePart) then +// FPrivatePart := TSomeClass.Create; +// FPrivatePart.LoadFromStream( Store) +// end +// else if assigned( FPrivatePart) then +// FPrivatePart.Clear +// end +//end; + + + +{ TAsymetric_Engine } + +function TAsymetric_Engine.Features: TAlgorithmicFeatureSet; +begin +result := [ + afOpenSourceSoftware, + afDoesNotNeedSalt, // Only applicable to IStreamCiphers which are true + // crytographic codecs, that is to say they do not have the + // afCompressor or afConverter feature. Normally, stream ciphers will + // be used by injecting a 64 bit salt of random data at the start + // of the plaintext stream. However, if the cipher has this feature + // (afDoesNotNeedSalt) it means it is already salting its own + // tranform, or it cannot benefit from salt. In this case, users of + // IStreamCipher, such as TCodec will not salt the plaintext. + afAsymetric + ] +end; + + +function TAsymetric_Engine.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := nil +end; + +function TAsymetric_Engine.Parameterize( + const Params: IInterface): IStreamCipher; +begin +result := nil +end; + +function TAsymetric_Engine.SeedByteSize: integer; +begin +result := -1 +end; + +procedure TAsymetric_Engine.Sign( + Document, Signature: TStream; + PrivatePart: TAsymtricKeyPart; ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; var wasAborted: boolean); +var + Dec: TAsymetricDecryptorClass; + DecObj: TAsymetricDecryptor; + isCounted: boolean; +begin +Dec := DecClass; +DecObj := Dec.Start_Decrypt( PrivatePart, Document); +isCounted := DecObj._AddRef <> -1; +try +if not assigned( ProgressSender) then + ProgressSender := self; +wasAborted := False; +Document.Position := 0; +Signature.Size := 0; +DecObj.Sign( Signature, ProgressSender, ProgressEvent, wasAborted); +finally +DecObj._Release; +if not isCounted then + DecObj.Free +end end; + + +function TAsymetric_Engine.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin +if (Key is TAsymetricKeyPair) and + Assigned( TAsymetricKeyPair( Key).FPrivatePart) then + result := DecClass.Start_Decrypt( + TAsymetricKeyPair( Key).FPrivatePart, PlainText) + else + result := nil +end; + + +function TAsymetric_Engine.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +if (Key is TAsymetricKeyPair) and + Assigned( TAsymetricKeyPair( Key).FPublicPart) then + result := EncClass.Start_Encrypt( + TAsymetricKeyPair( Key).FPublicPart, CipherText) + else + result := nil +end; + + + +function TAsymetric_Engine.VerifySignature( Document, Signature: TStream; + PublicPart: TAsymtricKeyPart; ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; var wasAborted: boolean): boolean; +var + Enc: TAsymetricEncryptorClass; + EncObj: TAsymetricEncryptor; + isCounted: boolean; +begin +Enc := EncClass; +Signature.Position := 0; +EncObj := Enc.Start_Encrypt( PublicPart, Signature); +isCounted := EncObj._AddRef <> -1; +try +if not assigned( ProgressSender) then + ProgressSender := self; +wasAborted := False; +Document.Position := 0; +result := EncObj.VerifySignature( Document, ProgressSender, + ProgressEvent, wasAborted) +finally +EncObj._Release; +if not isCounted then + EncObj.Free +end end; + +{ TAsymetricEncDec } + +constructor TAsymetricEncDec.Create; +begin +FBytesProcessed := 0; +FSymetricCodecObj := TSimpleCodec.Create; +Supports( FSymetricCodecObj, ICodec, FSymetricCodec); +FSymetricCodec.StreamCipher := TStreamToBlock_Adapter.Create; +FSymetricCodec.BlockCipher := TAES.Create( 256); +FSymetricCodec.ChainMode := TCBC.Create +end; + + + +destructor TAsymetricEncDec.Destroy; +begin +FSymetricCodec := nil; +FSymetricCodecObj.Free; +inherited +end; + + + +procedure TAsymetricEncDec.Reset; +begin +FSymetricCodec.Reset; +FBytesProcessed := 0 +end; + + + +{ TAsymetricEncryptor } + +procedure TAsymetricEncryptor.Encrypt( const Plaintext: TStream); +var + Sz: cardinal; + Xfer: cardinal; + XferBuffer: array[0..255] of byte; +begin +Sz := PlainText.Size - Plaintext.Position; +if Sz <= 0 then exit; +if FBytesProcessed = 0 then + begin + FSymetricCodec.InitFromKey( GenerateSymetricKey); // Transfers ownership. + FSymetricCodec.Begin_EncryptMemory( FCipherText) + end; +Inc( FBytesProcessed, Sz); +if PlainText is TMemoryStream then + begin + FSymetricCodec.EncryptMemory( + MemStrmOffset( TMemoryStream( Plaintext), Plaintext.Position)^, + Sz); + PlainText.Seek( Sz, soCurrent) + end + else + begin + while Sz > 0 do + begin + Xfer := Min( Sz, SizeOf( XferBuffer)); + Xfer := Plaintext.Read( XferBuffer, Xfer); + if Xfer = 0 then break; + Dec( Sz, Xfer); + FSymetricCodec.EncryptMemory( XferBuffer, Xfer) + end; + end +end; + + +procedure TAsymetricEncryptor.End_Encrypt; +begin +if FBytesProcessed > 0 then + FSymetricCodec.End_EncryptMemory +end; + + +constructor TAsymetricEncryptor.Start_Encrypt( + PublicKey1: TAsymtricKeyPart; CipherText1: TStream); +begin +inherited Create; +FPublicKey := PublicKey1; +FCipherText := CipherText1 +end; + + + +{ TAsymetricDecryptor } + +procedure TAsymetricDecryptor.Decrypt( const Ciphertext: TStream); +var + Sz: cardinal; + Xfer: cardinal; + XferBuffer: array[0..255] of byte; + P1, P2: int64; + KeyDelta: cardinal; +begin +P1 := Ciphertext.Position; +Sz := Ciphertext.Size - P1; +if Sz <= 0 then exit; +if FBytesProcessed = 0 then + begin + FSymetricCodec.InitFromKey( LoadSymetricKey( Ciphertext)); // Transfers ownership. + P2 := Ciphertext.Position; + KeyDelta := P2 - P1; + Inc( FBytesProcessed, KeyDelta); + Dec( Sz, KeyDelta); + FSymetricCodec.Begin_DecryptMemory( FPlainText) + end; +Inc( FBytesProcessed, Sz); +if Ciphertext is TMemoryStream then + begin + FSymetricCodec.DecryptMemory( + MemStrmOffset( TMemoryStream( Ciphertext), Ciphertext.Position)^, + Sz); + Ciphertext.Seek( Sz, soCurrent) + end + else + begin + while Sz > 0 do + begin + Xfer := Min( Sz, SizeOf( XferBuffer)); + Xfer := Ciphertext.Read( XferBuffer, Xfer); + if Xfer = 0 then break; + Dec( Sz, Xfer); + FSymetricCodec.DecryptMemory( XferBuffer, Xfer) + end + end +end; + +procedure TAsymetricDecryptor.End_Decrypt; +begin +if FBytesProcessed > 0 then + FSymetricCodec.End_DecryptMemory +end; + +constructor TAsymetricDecryptor.Start_Decrypt( + PrivateKey1: TAsymtricKeyPart; PlainText1: TStream); +begin +inherited Create; +FPrivateKey := PrivateKey1; +FPlainText := PlainText1 +end; + +end. diff --git a/run/TPLB3.Base64.pas b/LockBox3/run/TPLB3.Base64.pas similarity index 96% rename from run/TPLB3.Base64.pas rename to LockBox3/run/TPLB3.Base64.pas index 28647f9..e546319 100644 --- a/run/TPLB3.Base64.pas +++ b/LockBox3/run/TPLB3.Base64.pas @@ -1,281 +1,281 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Base64; -interface -uses Classes, TPLB3.StreamCipher; - -type - -TBase64Converter = class( TInterfacedObject, - IStreamCipher, ICryptoGraphicAlgorithm, IisBase64Converter) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; - end; - - - -implementation - - - - - - - - - - - - -uses SysUtils, TPLB3.CipherUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, - TPLB3.Constants, TPLB3.I18n; - -{ TBase64Converter } - -function TBase64Converter.DefinitionURL: string; -begin -result := 'http://tools.ietf.org/html/rfc4648' -end; - - - -function TBase64Converter.DisplayName: string; -begin -result := Base64_DisplayName -end; - - - -function TBase64Converter.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afConverter] -end; - - - -function TBase64Converter.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := TDummyKey.Create -end; - - -function TBase64Converter.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TDummyKey.Create -end; - - -function TBase64Converter.Parameterize( const Params: IInterface): IStreamCipher; -begin -result := nil -end; - - -function TBase64Converter.ProgId: string; -begin -result := Base64_ProgId -end; - - -function TBase64Converter.SeedByteSize: integer; -begin -result := -1 -end; - - -type -TBase64Conv = class( TInterfacedObject, - IStreamEncryptor, IStreamDecryptor, IisBase64Converter) - private - FInBuffer: TMemoryStream; - FInBufferLen: integer; - FOutStream: TStream; - - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - procedure Reset; - - public - constructor Create( OutStream1: TStream); - destructor Destroy; override; - end; - - - -function TBase64Converter.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin -result := TBase64Conv.Create( Plaintext) -end; - - -function TBase64Converter.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -result := TBase64Conv.Create( Ciphertext) -end; - -function TBase64Converter.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} 'Base64' -end; - - - -{ TBase64Conv } - -constructor TBase64Conv.Create( OutStream1: TStream); -begin -FInBuffer := TMemoryStream.Create; -FInBufferLen := 0; -FOutStream := OutStream1 -end; - - - -destructor TBase64Conv.Destroy; -begin -BurnMemoryStream( FInBuffer); -FInBuffer.Free; -inherited -end; - - -const - BufferBlocks = 100; - ToBase64_BufferSize = BufferBlocks * 3; - FromBase64_BufferSize = BufferBlocks * 4; - -procedure TBase64Conv.Encrypt( const Plaintext: TStream); -var - Space: integer; - Amnt: integer; - isLast: boolean; - base64_Fragment: string; -begin -if FInBufferLen = 0 then - FInBuffer.Size := ToBase64_BufferSize; // It can be any size, as long as it is a multiple of 3. -repeat - Space := ToBase64_BufferSize - FInBufferLen; - Amnt := ReadMem( Plaintext, FInBuffer, FInBufferLen, Space); - // Amnt := Plaintext.Read( pointer( integer(FInBuffer.Memory) + FInBufferLen)^, Space); - isLast := Amnt < Space; - Inc( FInBufferLen, Amnt); - Dec( Space, Amnt); - if Space <= 0 then - begin // We have full buffer, aligned to 3-byte. - base64_Fragment := Stream_to_Base64( FInBuffer); - String_to_stream( base64_Fragment, FOutStream{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); - FInBufferLen := 0 - end -until isLast -end; - - - -procedure TBase64Conv.End_Encrypt; -var - base64_Fragment: string; -begin -if FInBufferLen > 0 then - begin - FInBuffer.Size := FInBufferLen; - base64_Fragment := Stream_to_Base64( FInBuffer); - String_to_stream( base64_Fragment, FOutStream{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); - FInBufferLen := 0 - end -end; - - -procedure TBase64Conv.Decrypt( const Ciphertext: TStream); -var - Space: integer; - Amnt: integer; - isLast: boolean; - base64_Fragment: string; -begin -if FInBufferLen = 0 then - FInBuffer.Size := FromBase64_BufferSize; // It can be any size, as long as it is a multiple of 4. -repeat - Space := FromBase64_BufferSize - FInBufferLen; - // Amnt := Ciphertext.Read( pointer( integer(FInBuffer.Memory) + FInBufferLen)^, Space); - Amnt := ReadMem( Ciphertext, FInBuffer, FInBufferLen, Space); - isLast := Amnt < Space; - Inc( FInBufferLen, Amnt); - Dec( Space, Amnt); - if Space <= 0 then - begin // We have full buffer, aligned to 4-ansichar. - FInBuffer.Position := 0; - base64_Fragment := Stream_to_string( FInBuffer{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}, FromBase64_BufferSize); - Base64_to_stream( base64_Fragment, FOutStream); - FInBufferLen := 0 - end -until isLast -end; - - - -procedure TBase64Conv.End_Decrypt; -var - base64_Fragment: string; -begin -if FInBufferLen > 0 then - begin - FInBuffer.Position := 0; - base64_Fragment := Stream_to_string( FInBuffer{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}, FInBufferLen); - Base64_to_stream( base64_Fragment, FOutStream); - FInBufferLen := 0 - end -end; - - - -procedure TBase64Conv.Reset; -begin -BurnMemoryStream( FInBuffer); -FInBufferLen := 0 -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Base64; +interface +uses Classes, TPLB3.StreamCipher; + +type + +TBase64Converter = class( TInterfacedObject, + IStreamCipher, ICryptoGraphicAlgorithm, IisBase64Converter) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; + end; + + + +implementation + + + + + + + + + + + + +uses SysUtils, TPLB3.CipherUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, + TPLB3.Constants, TPLB3.I18n; + +{ TBase64Converter } + +function TBase64Converter.DefinitionURL: string; +begin +result := 'http://tools.ietf.org/html/rfc4648' +end; + + + +function TBase64Converter.DisplayName: string; +begin +result := Base64_DisplayName +end; + + + +function TBase64Converter.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afConverter] +end; + + + +function TBase64Converter.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := TDummyKey.Create +end; + + +function TBase64Converter.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TDummyKey.Create +end; + + +function TBase64Converter.Parameterize( const Params: IInterface): IStreamCipher; +begin +result := nil +end; + + +function TBase64Converter.ProgId: string; +begin +result := Base64_ProgId +end; + + +function TBase64Converter.SeedByteSize: integer; +begin +result := -1 +end; + + +type +TBase64Conv = class( TInterfacedObject, + IStreamEncryptor, IStreamDecryptor, IisBase64Converter) + private + FInBuffer: TMemoryStream; + FInBufferLen: integer; + FOutStream: TStream; + + procedure Encrypt( const Plaintext: TStream); + procedure End_Encrypt; + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + procedure Reset; + + public + constructor Create( OutStream1: TStream); + destructor Destroy; override; + end; + + + +function TBase64Converter.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin +result := TBase64Conv.Create( Plaintext) +end; + + +function TBase64Converter.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +result := TBase64Conv.Create( Ciphertext) +end; + +function TBase64Converter.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} 'Base64' +end; + + + +{ TBase64Conv } + +constructor TBase64Conv.Create( OutStream1: TStream); +begin +FInBuffer := TMemoryStream.Create; +FInBufferLen := 0; +FOutStream := OutStream1 +end; + + + +destructor TBase64Conv.Destroy; +begin +BurnMemoryStream( FInBuffer); +FInBuffer.Free; +inherited +end; + + +const + BufferBlocks = 100; + ToBase64_BufferSize = BufferBlocks * 3; + FromBase64_BufferSize = BufferBlocks * 4; + +procedure TBase64Conv.Encrypt( const Plaintext: TStream); +var + Space: integer; + Amnt: integer; + isLast: boolean; + base64_Fragment: string; +begin +if FInBufferLen = 0 then + FInBuffer.Size := ToBase64_BufferSize; // It can be any size, as long as it is a multiple of 3. +repeat + Space := ToBase64_BufferSize - FInBufferLen; + Amnt := ReadMem( Plaintext, FInBuffer, FInBufferLen, Space); + // Amnt := Plaintext.Read( pointer( integer(FInBuffer.Memory) + FInBufferLen)^, Space); + isLast := Amnt < Space; + Inc( FInBufferLen, Amnt); + Dec( Space, Amnt); + if Space <= 0 then + begin // We have full buffer, aligned to 3-byte. + base64_Fragment := Stream_to_Base64( FInBuffer); + String_to_stream( base64_Fragment, FOutStream{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); + FInBufferLen := 0 + end +until isLast +end; + + + +procedure TBase64Conv.End_Encrypt; +var + base64_Fragment: string; +begin +if FInBufferLen > 0 then + begin + FInBuffer.Size := FInBufferLen; + base64_Fragment := Stream_to_Base64( FInBuffer); + String_to_stream( base64_Fragment, FOutStream{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); + FInBufferLen := 0 + end +end; + + +procedure TBase64Conv.Decrypt( const Ciphertext: TStream); +var + Space: integer; + Amnt: integer; + isLast: boolean; + base64_Fragment: string; +begin +if FInBufferLen = 0 then + FInBuffer.Size := FromBase64_BufferSize; // It can be any size, as long as it is a multiple of 4. +repeat + Space := FromBase64_BufferSize - FInBufferLen; + // Amnt := Ciphertext.Read( pointer( integer(FInBuffer.Memory) + FInBufferLen)^, Space); + Amnt := ReadMem( Ciphertext, FInBuffer, FInBufferLen, Space); + isLast := Amnt < Space; + Inc( FInBufferLen, Amnt); + Dec( Space, Amnt); + if Space <= 0 then + begin // We have full buffer, aligned to 4-ansichar. + FInBuffer.Position := 0; + base64_Fragment := Stream_to_string( FInBuffer{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}, FromBase64_BufferSize); + Base64_to_stream( base64_Fragment, FOutStream); + FInBufferLen := 0 + end +until isLast +end; + + + +procedure TBase64Conv.End_Decrypt; +var + base64_Fragment: string; +begin +if FInBufferLen > 0 then + begin + FInBuffer.Position := 0; + base64_Fragment := Stream_to_string( FInBuffer{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}, FInBufferLen); + Base64_to_stream( base64_Fragment, FOutStream); + FInBufferLen := 0 + end +end; + + + +procedure TBase64Conv.Reset; +begin +BurnMemoryStream( FInBuffer); +FInBufferLen := 0 +end; + +end. diff --git a/run/TPLB3.BaseNonVisualComponent.pas b/LockBox3/run/TPLB3.BaseNonVisualComponent.pas similarity index 97% rename from run/TPLB3.BaseNonVisualComponent.pas rename to LockBox3/run/TPLB3.BaseNonVisualComponent.pas index e6aa655..583d8c5 100644 --- a/run/TPLB3.BaseNonVisualComponent.pas +++ b/LockBox3/run/TPLB3.BaseNonVisualComponent.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,66 +12,66 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.BaseNonVisualComponent; -interface -uses Classes; - -type -ITPLb_Component = interface - ['{AC0A9DC4-DF61-48A6-B460-408CE9CEEB85}'] - end; -// All TurboPower LockBox components shall implement ITPLb_Component. - -TTPLb_BaseNonVisualComponent = class( TComponent, ITPLb_Component) - private - function GetAbout: string; - procedure SetAbout( const Value: string); - - published - property About: string read GetAbout write SetAbout stored False; - end; -// TTPLb_BaseNonVisualComponent is the base class for all -// TurboPower LockBox non-visual components. The About property is - - -IEventOrigin = interface - ['{76644294-1B4C-4450-AB5F-9512A69A35D7}'] - procedure SetEventSender( Sender: TObject); - end; - -implementation - - - - - -{ TTPLb_BaseNonVisualComponent } - -function TTPLb_BaseNonVisualComponent.GetAbout: string; -begin -result := 'About ...' -end; - -procedure TTPLb_BaseNonVisualComponent.SetAbout( const Value: string); -begin -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.BaseNonVisualComponent; +interface +uses Classes; + +type +ITPLb_Component = interface + ['{AC0A9DC4-DF61-48A6-B460-408CE9CEEB85}'] + end; +// All TurboPower LockBox components shall implement ITPLb_Component. + +TTPLb_BaseNonVisualComponent = class( TComponent, ITPLb_Component) + private + function GetAbout: string; + procedure SetAbout( const Value: string); + + published + property About: string read GetAbout write SetAbout stored False; + end; +// TTPLb_BaseNonVisualComponent is the base class for all +// TurboPower LockBox non-visual components. The About property is + + +IEventOrigin = interface + ['{76644294-1B4C-4450-AB5F-9512A69A35D7}'] + procedure SetEventSender( Sender: TObject); + end; + +implementation + + + + + +{ TTPLb_BaseNonVisualComponent } + +function TTPLb_BaseNonVisualComponent.GetAbout: string; +begin +result := 'About ...' +end; + +procedure TTPLb_BaseNonVisualComponent.SetAbout( const Value: string); +begin +end; + +end. diff --git a/run/TPLB3.BinaryUtils.pas b/LockBox3/run/TPLB3.BinaryUtils.pas similarity index 96% rename from run/TPLB3.BinaryUtils.pas rename to LockBox3/run/TPLB3.BinaryUtils.pas index 6aa15c7..f52645c 100644 --- a/run/TPLB3.BinaryUtils.pas +++ b/LockBox3/run/TPLB3.BinaryUtils.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,136 +12,136 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.BinaryUtils; -interface -uses Classes, TPLB3.IntegerUtils; - -function SwapEndien_u32( Value: uint32): uint32; -function SwapEndien_s64( Value: int64 ): int64; -function SwapEndien_u64( Value: uint64 ): uint64; -function RotateLeft1Bit_u32( Value: uint32): uint32; - -procedure Read_BigEndien_u32_Hex( const Value: string; BinaryOut: TStream); -// EXAMPLE: Value = '84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1' -// ==> stream with bytes: $84 $98 $3E $44 $1C etc. -// Spaces are optional, but encouraged. -// Streaming is in place. That is to say, the stream is not moved or -// resized prior to writing to. Assume that BinaryOut is not nil. - - -function Get_TP_LockBox3_HINSTANCE: HMODULE; - -implementation - - - - - - - - - - - - - - -uses SysUtils; - -function SwapEndien_u32( Value: uint32): uint32; -begin -result := ((Value and $000000FF) shl 24) or - ((Value and $0000FF00) shl 8) or - ((Value and $00FF0000) shr 8) or - ((Value and $FF000000) shr 24) -end; - - - -function SwapEndien_s64( Value: int64): int64; -begin -int64rec( result).Hi := SwapEndien_u32( int64rec( Value).Lo); -int64rec( result).Lo := SwapEndien_u32( int64rec( Value).Hi) -end; - - - -function SwapEndien_u64( Value: uint64): uint64; -begin -int64rec( result).Hi := SwapEndien_u32( int64rec( Value).Lo); -int64rec( result).Lo := SwapEndien_u32( int64rec( Value).Hi) -end; - - - - - - - -function RotateLeft1Bit_u32( Value: uint32): uint32; -begin -result := (Value shl 1) or (Value shr 31) -end; - - - - -procedure Read_BigEndien_u32_Hex( const Value: string; BinaryOut: TStream); -var - Idx, Nibble: integer; - Ch: Char; - isHighNibble: boolean; - ByteValue: byte; -begin -ByteValue := 0; -isHighNibble := True; -for Idx := 1 to Length( Value) do - begin - Ch := Upcase( Value[ Idx]); - if Ch = ' ' then continue; - {$IFDEF UNICODE} - if Ord( Ch) >= 256 then continue; - {$ENDIF} - if (Ch >= '0') and (Ch <= '9') then - Nibble := Ord( Ch) - Ord( '0') - else - Nibble := Ord( Ch) - Ord( 'A') + 10; - if (Nibble < 0) or (Nibble > 15) then - raise Exception.Create( ''); - if isHighNibble then - ByteValue := Nibble shl 4 - else - begin - ByteValue := ByteValue + Nibble; - BinaryOut.WriteBuffer( ByteValue, 1) - end; - isHighNibble := not isHighNibble - end -end; - - - -function Get_TP_LockBox3_HINSTANCE: HMODULE; -begin -result := HINSTANCE -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.BinaryUtils; +interface +uses Classes, TPLB3.IntegerUtils; + +function SwapEndien_u32( Value: uint32): uint32; +function SwapEndien_s64( Value: int64 ): int64; +function SwapEndien_u64( Value: uint64 ): uint64; +function RotateLeft1Bit_u32( Value: uint32): uint32; + +procedure Read_BigEndien_u32_Hex( const Value: string; BinaryOut: TStream); +// EXAMPLE: Value = '84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1' +// ==> stream with bytes: $84 $98 $3E $44 $1C etc. +// Spaces are optional, but encouraged. +// Streaming is in place. That is to say, the stream is not moved or +// resized prior to writing to. Assume that BinaryOut is not nil. + + +function Get_TP_LockBox3_HINSTANCE: HMODULE; + +implementation + + + + + + + + + + + + + + +uses SysUtils; + +function SwapEndien_u32( Value: uint32): uint32; +begin +result := ((Value and $000000FF) shl 24) or + ((Value and $0000FF00) shl 8) or + ((Value and $00FF0000) shr 8) or + ((Value and $FF000000) shr 24) +end; + + + +function SwapEndien_s64( Value: int64): int64; +begin +int64rec( result).Hi := SwapEndien_u32( int64rec( Value).Lo); +int64rec( result).Lo := SwapEndien_u32( int64rec( Value).Hi) +end; + + + +function SwapEndien_u64( Value: uint64): uint64; +begin +int64rec( result).Hi := SwapEndien_u32( int64rec( Value).Lo); +int64rec( result).Lo := SwapEndien_u32( int64rec( Value).Hi) +end; + + + + + + + +function RotateLeft1Bit_u32( Value: uint32): uint32; +begin +result := (Value shl 1) or (Value shr 31) +end; + + + + +procedure Read_BigEndien_u32_Hex( const Value: string; BinaryOut: TStream); +var + Idx, Nibble: integer; + Ch: Char; + isHighNibble: boolean; + ByteValue: byte; +begin +ByteValue := 0; +isHighNibble := True; +for Idx := 1 to Length( Value) do + begin + Ch := Upcase( Value[ Idx]); + if Ch = ' ' then continue; + {$IFDEF UNICODE} + if Ord( Ch) >= 256 then continue; + {$ENDIF} + if (Ch >= '0') and (Ch <= '9') then + Nibble := Ord( Ch) - Ord( '0') + else + Nibble := Ord( Ch) - Ord( 'A') + 10; + if (Nibble < 0) or (Nibble > 15) then + raise Exception.Create( ''); + if isHighNibble then + ByteValue := Nibble shl 4 + else + begin + ByteValue := ByteValue + Nibble; + BinaryOut.WriteBuffer( ByteValue, 1) + end; + isHighNibble := not isHighNibble + end +end; + + + +function Get_TP_LockBox3_HINSTANCE: HMODULE; +begin +result := HINSTANCE +end; + +end. diff --git a/run/TPLB3.BlockCipher.pas b/LockBox3/run/TPLB3.BlockCipher.pas similarity index 90% rename from run/TPLB3.BlockCipher.pas rename to LockBox3/run/TPLB3.BlockCipher.pas index bba6177..2459ac1 100644 --- a/run/TPLB3.BlockCipher.pas +++ b/LockBox3/run/TPLB3.BlockCipher.pas @@ -1,227 +1,226 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.BlockCipher; -interface -uses Classes, TPLB3.StreamCipher; - -type - -IBlockCodec = interface - ['{7E783A4E-EF17-4820-AB33-EF8EF9DA6F22}'] - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - end; - -IBlockCipher = interface( ICryptoGraphicAlgorithm) - ['{CB927B43-8A02-4332-B844-A174D1D6B705}'] - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; // in units of bits. Must be a multiple of 8. - function KeySize: integer; // in units of bits. - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - - function SelfTest_Key: string; // Hex string; may be oriented into - // u32 groups. Input to GenerateKey(); - - function SelfTest_Plaintext: string; // Hex string; - // may be oriented into u32 groups. Input to Encrypt_Block(); - - function SelfTest_Ciphertext: string; // Hex string; - // may be oriented into u32 groups. Reference for Encrypt_Block() output; - end; - - -TBlockChainLink = class - protected - FKey: TSymetricKey; - FCV: TMemoryStream; - FCipher: IBlockCodec; - - constructor BaseCreate( - Key1: TSymetricKey; // Will be referenced, not cloned. - IV1: TMemoryStream; // Will be cloned. - Cipher1: IBlockCodec); // Will be referenced, not cloned. - - public - procedure Burn; virtual; - procedure Reset( IV: TMemoryStream); virtual; - function Clone: TBlockChainLink; virtual; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); virtual; abstract; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); virtual; abstract; - - // The following 2 methods are ONLY applicable in the case of - // cf8bit in IBlockChainingModel.ChainingFeatures; - // For example, 8-bit CFB mode. - // Do not implement in other cases. - procedure Encrypt_8bit( Plaintext{in}: byte; var Ciphertext{out}: byte); virtual; - procedure Decrypt_8bit( var Plaintext{out}: byte; Ciphertext{in}: byte); virtual; - - destructor Destroy; override; - end; - - -TChainingFeature = ( - cfNoNounce, // The chaining mode does not require any nounce nor - // does it require an IV. Ex: ECB - cfKeyStream, // A key-stream is at the heart of the chaining mode - // The final partial block can be padded arbitarily, - // encrypted as usual, and then truncated to the same - // length as the corresponding plaintext input. - // Examples: CFB, 8-bit CFB, OFB and CTR. - // Counter-examples: ECB and CBC - cfAutoXOR, // Only applies to cfKeyStream. This means that the - // cipher XORs the plaintext/ciphertext with the keystream. - // In this case, this XOR operation is done by the - // IBlockChainingModel client and not the IBlockChainingModel - // itself. - cf8bit // Plaintext and cipher text are processed one byte at a time. - // Example: 8-bit CFB. - // A chaining mode with cf8Bit MUST also have - // cfKeyStream and not cfNoNounce - ); - -TChainingFeatureSet = set of TChainingFeature; - -IBlockChainingModel = interface( ICryptoGraphicAlgorithm) - ['{7ED854DF-5270-41F7-820A-65BF9B5E1D35}'] - - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function ChainingFeatures: TChainingFeatureSet; - end; - - - -IBlockCipherSelector = interface - ['{B08F766E-1EB0-4BA0-9C84-8AF02E13B24C}'] - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - // IBlockCipherSelector s such as TCodec and other config holders - // should also implement IBlockCipherSelectorEx2 - end; - -TSymetricEncryptionOption = ( - optUseGivenIV, // Use the given IV instead of generating one. - // This option is not recommended unless trying to achieve - // interoperability with OpenSSL. - optOpenSSL_CompatibilityMode // Use OpenSSL style of block padding, instead of the normal LockBox style. - // This option is not recommended unless trying to achieve - // interoperability with OpenSSL. - ); -TSymetricEncryptionOptionSet = set of TSymetricEncryptionOption; - -TSetMemStreamProc = procedure ( Value: TMemoryStream) of object; - -IBlockCipherSelectorEx2 = interface( IBlockCipherSelector) - ['{907D6E07-C840-4EB4-888A-146B94BDFB53}'] - function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; - function hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; - end; - - - -implementation - - - - - - -uses TPLB3.StreamUtils; - -{ TBlockChainLink } - -constructor TBlockChainLink.BaseCreate( - Key1: TSymetricKey; IV1: TMemoryStream; Cipher1: IBlockCodec); -begin -FKey := Key1; // Not owned -FCV := CloneMemoryStream( IV1); // Owned. -FCipher := Cipher1 // Not owned -end; - -procedure TBlockChainLink.Burn; -begin -BurnMemoryStream( FCV); -FKey := nil // key is not owned by the chain link. -end; - -type TBlockChainLinkClass = class of TBlockChainLink; - -function TBlockChainLink.Clone: TBlockChainLink; -var - Cls: TBlockChainLinkClass; -begin -Cls := TBlockChainLinkClass( ClassType); -result := Cls.BaseCreate( FKey, FCV, FCipher) -end; - - - - -procedure TBlockChainLink.Encrypt_8bit( Plaintext: byte; var Ciphertext: byte); -begin -Ciphertext := Plaintext -end; - - -procedure TBlockChainLink.Reset( IV: TMemoryStream); -begin -CopyMemoryStream( IV, FCV) -end; - - - -procedure TBlockChainLink.Decrypt_8bit( var Plaintext: byte; Ciphertext: byte); -begin -Plaintext := Ciphertext -end; - -destructor TBlockChainLink.Destroy; -begin -FCV.Free; -inherited; -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.BlockCipher; +interface +uses Classes, TPLB3.StreamCipher; + +type + +IBlockCodec = interface + ['{7E783A4E-EF17-4820-AB33-EF8EF9DA6F22}'] + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + end; + +IBlockCipher = interface( ICryptoGraphicAlgorithm) + ['{CB927B43-8A02-4332-B844-A174D1D6B705}'] + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; // in units of bits. Must be a multiple of 8. + function KeySize: integer; // in units of bits. + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + + function SelfTest_Key: string; // Hex string; may be oriented into + // u32 groups. Input to GenerateKey(); + + function SelfTest_Plaintext: string; // Hex string; + // may be oriented into u32 groups. Input to Encrypt_Block(); + + function SelfTest_Ciphertext: string; // Hex string; + // may be oriented into u32 groups. Reference for Encrypt_Block() output; + end; + + +TBlockChainLink = class + protected + FKey: TSymetricKey; + FCV: TMemoryStream; + FCipher: IBlockCodec; + + constructor BaseCreate( + Key1: TSymetricKey; // Will be referenced, not cloned. + IV1: TMemoryStream; // Will be cloned. + Cipher1: IBlockCodec); // Will be referenced, not cloned. + + public + procedure Burn; virtual; + procedure Reset( IV: TMemoryStream); virtual; + function Clone: TBlockChainLink; virtual; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); virtual; abstract; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); virtual; abstract; + + // The following 2 methods are ONLY applicable in the case of + // cf8bit in IBlockChainingModel.ChainingFeatures; + // For example, 8-bit CFB mode. + // Do not implement in other cases. + procedure Encrypt_8bit( Plaintext{in}: byte; var Ciphertext{out}: byte); virtual; + procedure Decrypt_8bit( var Plaintext{out}: byte; Ciphertext{in}: byte); virtual; + + destructor Destroy; override; + end; + + +TChainingFeature = ( + cfNoNounce, // The chaining mode does not require any nounce nor + // does it require an IV. Ex: ECB + cfKeyStream, // A key-stream is at the heart of the chaining mode + // The final partial block can be padded arbitarily, + // encrypted as usual, and then truncated to the same + // length as the corresponding plaintext input. + // Examples: CFB, 8-bit CFB, OFB and CTR. + // Counter-examples: ECB and CBC + cfAutoXOR, // Only applies to cfKeyStream. This means that the + // cipher XORs the plaintext/ciphertext with the keystream. + // In this case, this XOR operation is done by the + // IBlockChainingModel client and not the IBlockChainingModel + // itself. + cf8bit // Plaintext and cipher text are processed one byte at a time. + // Example: 8-bit CFB. + // A chaining mode with cf8Bit MUST also have + // cfKeyStream and not cfNoNounce + ); + +TChainingFeatureSet = set of TChainingFeature; + +IBlockChainingModel = interface( ICryptoGraphicAlgorithm) + ['{7ED854DF-5270-41F7-820A-65BF9B5E1D35}'] + + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function ChainingFeatures: TChainingFeatureSet; + end; + + + +IBlockCipherSelector = interface + ['{B08F766E-1EB0-4BA0-9C84-8AF02E13B24C}'] + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + // IBlockCipherSelector s such as TCodec and other config holders + // should also implement IBlockCipherSelectorEx2 + end; + +TSymetricEncryptionOption = ( + optUseGivenIV, // This option is obselete. + optOpenSSL_CompatibilityMode, // This option is obselete. + optSuppressIVSeedPrependage // Normally the low 8 bytes of the IV (the "IV seed" is prepended to ciphertext output upon encryption. + // If you set this option, the prepending will not occur, and you must use the OnSetIV event to + // set and/or capture the IV, and transmit it yourself via a side channel. + ); +TSymetricEncryptionOptionSet = set of TSymetricEncryptionOption; + +TSetMemStreamProc = procedure ( Value: TMemoryStream) of object; + +IBlockCipherSelectorEx2 = interface( IBlockCipherSelector) + ['{907D6E07-C840-4EB4-888A-146B94BDFB53}'] + function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; + function hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; + end; + + + +implementation + + + + + + +uses TPLB3.StreamUtils; + +{ TBlockChainLink } + +constructor TBlockChainLink.BaseCreate( + Key1: TSymetricKey; IV1: TMemoryStream; Cipher1: IBlockCodec); +begin +FKey := Key1; // Not owned +FCV := CloneMemoryStream( IV1); // Owned. +FCipher := Cipher1 // Not owned +end; + +procedure TBlockChainLink.Burn; +begin +BurnMemoryStream( FCV); +FKey := nil // key is not owned by the chain link. +end; + +type TBlockChainLinkClass = class of TBlockChainLink; + +function TBlockChainLink.Clone: TBlockChainLink; +var + Cls: TBlockChainLinkClass; +begin +Cls := TBlockChainLinkClass( ClassType); +result := Cls.BaseCreate( FKey, FCV, FCipher) +end; + + + + +procedure TBlockChainLink.Encrypt_8bit( Plaintext: byte; var Ciphertext: byte); +begin +Ciphertext := Plaintext +end; + + +procedure TBlockChainLink.Reset( IV: TMemoryStream); +begin +CopyMemoryStream( IV, FCV) +end; + + + +procedure TBlockChainLink.Decrypt_8bit( var Plaintext: byte; Ciphertext: byte); +begin +Plaintext := Ciphertext +end; + +destructor TBlockChainLink.Destroy; +begin +FCV.Free; +inherited; +end; + + +end. diff --git a/run/TPLB3.BlowFish.pas b/LockBox3/run/TPLB3.BlowFish.pas similarity index 96% rename from run/TPLB3.BlowFish.pas rename to LockBox3/run/TPLB3.BlowFish.pas index ae24e9d..b7d65be 100644 --- a/run/TPLB3.BlowFish.pas +++ b/LockBox3/run/TPLB3.BlowFish.pas @@ -1,845 +1,846 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.BlowFish; -interface -uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; - -const - StoreBlowFishKeysAsExpanded = True; // To do: Make this an option. - -type -{$IF compilerversion >= 21} -{$RTTI EXPLICIT METHODS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublished])} -// Exposes the attribute on the SeedByteSize method. -{$IFEND} - -TBlowFish = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm, IControlObject -{$IF compilerversion < 21} - ,IVariableSeedSize -{$IFEND} - ) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; // in units of bits. Must be a multiple of 8. - -{$IF compilerversion >= 21} - [IntegerRange( 8, 448)] -{$IFEND} - function KeySize: integer; - - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - // IControlObject = interface - function ControlObject: TObject; - -{$IF compilerversion >= 21} - [IntegerRange( 1, 56)] - function SeedByteSize: integer; // This is now a nominal value, - // not a must-be value. -{$ELSE} - function SeedByteSize: integer; - function MinSeedByteSize: integer; - function MaxSeedByteSize: integer; -{$IFEND} - - public - constructor Create; - end; - -{$IF CompilerVersion < 21} -uint32 = cardinal; -{$IFEND} - - TSBox = array[ 0..3, 0..255] of uint32; - TPBox = array[ 0..17] of uint32; - -procedure Blowfish_Make_SBoxes_64BitKey( - const Key: uint64; var SBox: TSBox; var PBox: TPBox); - -procedure Blowfish_Make_SBoxes( - const Key; KeySizeInBytes: integer; var SBox: TSBox; var PBox: TPBox); - -procedure Blowfish_Encrypt( - Plaintext: uint64; var Ciphertext: uint64; - var SBox: TSBox; var PBox: TPBox); - -procedure Blowfish_Decrypt( - Ciphertext: uint64; var Plaintext: uint64; - const SBox: TSBox; const PBox: TPBox); - -implementation - - - - -uses TPLB3.Constants, SysUtils, TPLB3.StreamUtils, TPLB3.Compatibility; - - -function ReverseEndien32( Value: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -LongRec( result).Bytes[0] := LongRec( Value).Bytes[3]; -LongRec( result).Bytes[1] := LongRec( Value).Bytes[2]; -LongRec( result).Bytes[2] := LongRec( Value).Bytes[1]; -LongRec( result).Bytes[3] := LongRec( Value).Bytes[0] -end; - - -procedure Blowfish_Encrypt( - Plaintext: uint64; var Ciphertext: uint64; - var SBox: TSBox; var PBox: TPBox); -var - L, R: uint32; - i, j: integer; -begin -L := ReverseEndien32( Int64Rec( Plaintext).Lo) xor PBox[0]; -R := ReverseEndien32( Int64Rec( Plaintext).Hi); -j := 1; -for i := 0 to 7 do - begin - R := R xor - (((SBox[ 0, LongRec( L).Bytes[ 3]] + SBox[ 1, LongRec( L).Bytes[ 2]]) xor - SBox[ 2, LongRec( L).Bytes[ 1]]) + SBox[ 3, LongRec( L).Bytes[ 0]]) xor - PBox[ j]; - Inc( j); - L := L xor - (((SBox[ 0,LongRec( R).Bytes[ 3]] + SBox[ 1, LongRec( R).Bytes[ 2]]) xor - SBox[ 2,LongRec( R).Bytes[ 1]]) + SBox[ 3, LongRec( R).Bytes[ 0]]) xor - PBox[ j]; - Inc( j) - end; -Int64Rec( Ciphertext).Lo := ReverseEndien32( R xor PBox[17]); -Int64Rec( Ciphertext).Hi := ReverseEndien32( L) -end; - - -procedure Blowfish_Decrypt( - Ciphertext: uint64; var Plaintext: uint64; - const SBox: TSBox; const PBox: TPBox); -var - L, R: uint32; - i, j: integer; -begin -L := ReverseEndien32( Int64Rec( Ciphertext).Lo) xor PBox[17]; -R := ReverseEndien32( Int64Rec( Ciphertext).Hi); -j := 16; -for i := 0 to 7 do - begin - R := R xor - (((SBox[ 0, LongRec( L).Bytes[ 3]] + SBox[ 1, LongRec( L).Bytes[ 2]]) xor - SBox[ 2, LongRec( L).Bytes[ 1]]) + SBox[ 3, LongRec( L).Bytes[ 0]]) xor - PBox[ j]; - Dec( j); - L := L xor - (((SBox[ 0,LongRec( R).Bytes[ 3]] + SBox[ 1, LongRec( R).Bytes[ 2]]) xor - SBox[ 2,LongRec( R).Bytes[ 1]]) + SBox[ 3, LongRec( R).Bytes[ 0]]) xor - PBox[ j]; - Dec( j) - end; -Int64Rec( Plaintext).Lo := ReverseEndien32( R xor PBox[0]); -Int64Rec( Plaintext).Hi := ReverseEndien32( L) -end; - - - - -const - PBoxOrg: TPBox = ( - $243F6A88, $85A308D3, $13198A2E, $03707344, - $A4093822, $299F31D0, $082EFA98, $EC4E6C89, - $452821E6, $38D01377, $BE5466CF, $34E90C6C, - $C0AC29B7, $C97C50DD, $3F84D5B5, $B5470917, - $9216D5D9, $8979FB1B); - - SBoxOrg: TSBox = (( - $D1310BA6, $98DFB5AC, $2FFD72DB, $D01ADFB7, - $B8E1AFED, $6A267E96, $BA7C9045, $F12C7F99, - $24A19947, $B3916CF7, $0801F2E2, $858EFC16, - $636920D8, $71574E69, $A458FEA3, $F4933D7E, - $0D95748F, $728EB658, $718BCD58, $82154AEE, - $7B54A41D, $C25A59B5, $9C30D539, $2AF26013, - $C5D1B023, $286085F0, $CA417918, $B8DB38EF, - $8E79DCB0, $603A180E, $6C9E0E8B, $B01E8A3E, - $D71577C1, $BD314B27, $78AF2FDA, $55605C60, - $E65525F3, $AA55AB94, $57489862, $63E81440, - $55CA396A, $2AAB10B6, $B4CC5C34, $1141E8CE, - $A15486AF, $7C72E993, $B3EE1411, $636FBC2A, - $2BA9C55D, $741831F6, $CE5C3E16, $9B87931E, - $AFD6BA33, $6C24CF5C, $7A325381, $28958677, - $3B8F4898, $6B4BB9AF, $C4BFE81B, $66282193, - $61D809CC, $FB21A991, $487CAC60, $5DEC8032, - $EF845D5D, $E98575B1, $DC262302, $EB651B88, - $23893E81, $D396ACC5, $0F6D6FF3, $83F44239, - $2E0B4482, $A4842004, $69C8F04A, $9E1F9B5E, - $21C66842, $F6E96C9A, $670C9C61, $ABD388F0, - $6A51A0D2, $D8542F68, $960FA728, $AB5133A3, - $6EEF0B6C, $137A3BE4, $BA3BF050, $7EFB2A98, - $A1F1651D, $39AF0176, $66CA593E, $82430E88, - $8CEE8619, $456F9FB4, $7D84A5C3, $3B8B5EBE, - $E06F75D8, $85C12073, $401A449F, $56C16AA6, - $4ED3AA62, $363F7706, $1BFEDF72, $429B023D, - $37D0D724, $D00A1248, $DB0FEAD3, $49F1C09B, - $075372C9, $80991B7B, $25D479D8, $F6E8DEF7, - $E3FE501A, $B6794C3B, $976CE0BD, $04C006BA, - $C1A94FB6, $409F60C4, $5E5C9EC2, $196A2463, - $68FB6FAF, $3E6C53B5, $1339B2EB, $3B52EC6F, - $6DFC511F, $9B30952C, $CC814544, $AF5EBD09, - $BEE3D004, $DE334AFD, $660F2807, $192E4BB3, - $C0CBA857, $45C8740F, $D20B5F39, $B9D3FBDB, - $5579C0BD, $1A60320A, $D6A100C6, $402C7279, - $679F25FE, $FB1FA3CC, $8EA5E9F8, $DB3222F8, - $3C7516DF, $FD616B15, $2F501EC8, $AD0552AB, - $323DB5FA, $FD238760, $53317B48, $3E00DF82, - $9E5C57BB, $CA6F8CA0, $1A87562E, $DF1769DB, - $D542A8F6, $287EFFC3, $AC6732C6, $8C4F5573, - $695B27B0, $BBCA58C8, $E1FFA35D, $B8F011A0, - $10FA3D98, $FD2183B8, $4AFCB56C, $2DD1D35B, - $9A53E479, $B6F84565, $D28E49BC, $4BFB9790, - $E1DDF2DA, $A4CB7E33, $62FB1341, $CEE4C6E8, - $EF20CADA, $36774C01, $D07E9EFE, $2BF11FB4, - $95DBDA4D, $AE909198, $EAAD8E71, $6B93D5A0, - $D08ED1D0, $AFC725E0, $8E3C5B2F, $8E7594B7, - $8FF6E2FB, $F2122B64, $8888B812, $900DF01C, - $4FAD5EA0, $688FC31C, $D1CFF191, $B3A8C1AD, - $2F2F2218, $BE0E1777, $EA752DFE, $8B021FA1, - $E5A0CC0F, $B56F74E8, $18ACF3D6, $CE89E299, - $B4A84FE0, $FD13E0B7, $7CC43B81, $D2ADA8D9, - $165FA266, $80957705, $93CC7314, $211A1477, - $E6AD2065, $77B5FA86, $C75442F5, $FB9D35CF, - $EBCDAF0C, $7B3E89A0, $D6411BD3, $AE1E7E49, - $00250E2D, $2071B35E, $226800BB, $57B8E0AF, - $2464369B, $F009B91E, $5563911D, $59DFA6AA, - $78C14389, $D95A537F, $207D5BA2, $02E5B9C5, - $83260376, $6295CFA9, $11C81968, $4E734A41, - $B3472DCA, $7B14A94A, $1B510052, $9A532915, - $D60F573F, $BC9BC6E4, $2B60A476, $81E67400, - $08BA6FB5, $571BE91F, $F296EC6B, $2A0DD915, - $B6636521, $E7B9F9B6, $FF34052E, $C5855664, - $53B02D5D, $A99F8FA1, $08BA4799, $6E85076A), - ( - $4B7A70E9, $B5B32944, $DB75092E, $C4192623, - $AD6EA6B0, $49A7DF7D, $9CEE60B8, $8FEDB266, - $ECAA8C71, $699A17FF, $5664526C, $C2B19EE1, - $193602A5, $75094C29, $A0591340, $E4183A3E, - $3F54989A, $5B429D65, $6B8FE4D6, $99F73FD6, - $A1D29C07, $EFE830F5, $4D2D38E6, $F0255DC1, - $4CDD2086, $8470EB26, $6382E9C6, $021ECC5E, - $09686B3F, $3EBAEFC9, $3C971814, $6B6A70A1, - $687F3584, $52A0E286, $B79C5305, $AA500737, - $3E07841C, $7FDEAE5C, $8E7D44EC, $5716F2B8, - $B03ADA37, $F0500C0D, $F01C1F04, $0200B3FF, - $AE0CF51A, $3CB574B2, $25837A58, $DC0921BD, - $D19113F9, $7CA92FF6, $94324773, $22F54701, - $3AE5E581, $37C2DADC, $C8B57634, $9AF3DDA7, - $A9446146, $0FD0030E, $ECC8C73E, $A4751E41, - $E238CD99, $3BEA0E2F, $3280BBA1, $183EB331, - $4E548B38, $4F6DB908, $6F420D03, $F60A04BF, - $2CB81290, $24977C79, $5679B072, $BCAF89AF, - $DE9A771F, $D9930810, $B38BAE12, $DCCF3F2E, - $5512721F, $2E6B7124, $501ADDE6, $9F84CD87, - $7A584718, $7408DA17, $BC9F9ABC, $E94B7D8C, - $EC7AEC3A, $DB851DFA, $63094366, $C464C3D2, - $EF1C1847, $3215D908, $DD433B37, $24C2BA16, - $12A14D43, $2A65C451, $50940002, $133AE4DD, - $71DFF89E, $10314E55, $81AC77D6, $5F11199B, - $043556F1, $D7A3C76B, $3C11183B, $5924A509, - $F28FE6ED, $97F1FBFA, $9EBABF2C, $1E153C6E, - $86E34570, $EAE96FB1, $860E5E0A, $5A3E2AB3, - $771FE71C, $4E3D06FA, $2965DCB9, $99E71D0F, - $803E89D6, $5266C825, $2E4CC978, $9C10B36A, - $C6150EBA, $94E2EA78, $A5FC3C53, $1E0A2DF4, - $F2F74EA7, $361D2B3D, $1939260F, $19C27960, - $5223A708, $F71312B6, $EBADFE6E, $EAC31F66, - $E3BC4595, $A67BC883, $B17F37D1, $018CFF28, - $C332DDEF, $BE6C5AA5, $65582185, $68AB9802, - $EECEA50F, $DB2F953B, $2AEF7DAD, $5B6E2F84, - $1521B628, $29076170, $ECDD4775, $619F1510, - $13CCA830, $EB61BD96, $0334FE1E, $AA0363CF, - $B5735C90, $4C70A239, $D59E9E0B, $CBAADE14, - $EECC86BC, $60622CA7, $9CAB5CAB, $B2F3846E, - $648B1EAF, $19BDF0CA, $A02369B9, $655ABB50, - $40685A32, $3C2AB4B3, $319EE9D5, $C021B8F7, - $9B540B19, $875FA099, $95F7997E, $623D7DA8, - $F837889A, $97E32D77, $11ED935F, $16681281, - $0E358829, $C7E61FD6, $96DEDFA1, $7858BA99, - $57F584A5, $1B227263, $9B83C3FF, $1AC24696, - $CDB30AEB, $532E3054, $8FD948E4, $6DBC3128, - $58EBF2EF, $34C6FFEA, $FE28ED61, $EE7C3C73, - $5D4A14D9, $E864B7E3, $42105D14, $203E13E0, - $45EEE2B6, $A3AAABEA, $DB6C4F15, $FACB4FD0, - $C742F442, $EF6ABBB5, $654F3B1D, $41CD2105, - $D81E799E, $86854DC7, $E44B476A, $3D816250, - $CF62A1F2, $5B8D2646, $FC8883A0, $C1C7B6A3, - $7F1524C3, $69CB7492, $47848A0B, $5692B285, - $095BBF00, $AD19489D, $1462B174, $23820E00, - $58428D2A, $0C55F5EA, $1DADF43E, $233F7061, - $3372F092, $8D937E41, $D65FECF1, $6C223BDB, - $7CDE3759, $CBEE7460, $4085F2A7, $CE77326E, - $A6078084, $19F8509E, $E8EFD855, $61D99735, - $A969A7AA, $C50C06C2, $5A04ABFC, $800BCADC, - $9E447A2E, $C3453484, $FDD56705, $0E1E9EC9, - $DB73DBD3, $105588CD, $675FDA79, $E3674340, - $C5C43465, $713E38D8, $3D28F89E, $F16DFF20, - $153E21E7, $8FB03D4A, $E6E39F2B, $DB83ADF7), - ( - $E93D5A68, $948140F7, $F64C261C, $94692934, - $411520F7, $7602D4F7, $BCF46B2E, $D4A20068, - $D4082471, $3320F46A, $43B7D4B7, $500061AF, - $1E39F62E, $97244546, $14214F74, $BF8B8840, - $4D95FC1D, $96B591AF, $70F4DDD3, $66A02F45, - $BFBC09EC, $03BD9785, $7FAC6DD0, $31CB8504, - $96EB27B3, $55FD3941, $DA2547E6, $ABCA0A9A, - $28507825, $530429F4, $0A2C86DA, $E9B66DFB, - $68DC1462, $D7486900, $680EC0A4, $27A18DEE, - $4F3FFEA2, $E887AD8C, $B58CE006, $7AF4D6B6, - $AACE1E7C, $D3375FEC, $CE78A399, $406B2A42, - $20FE9E35, $D9F385B9, $EE39D7AB, $3B124E8B, - $1DC9FAF7, $4B6D1856, $26A36631, $EAE397B2, - $3A6EFA74, $DD5B4332, $6841E7F7, $CA7820FB, - $FB0AF54E, $D8FEB397, $454056AC, $BA489527, - $55533A3A, $20838D87, $FE6BA9B7, $D096954B, - $55A867BC, $A1159A58, $CCA92963, $99E1DB33, - $A62A4A56, $3F3125F9, $5EF47E1C, $9029317C, - $FDF8E802, $04272F70, $80BB155C, $05282CE3, - $95C11548, $E4C66D22, $48C1133F, $C70F86DC, - $07F9C9EE, $41041F0F, $404779A4, $5D886E17, - $325F51EB, $D59BC0D1, $F2BCC18F, $41113564, - $257B7834, $602A9C60, $DFF8E8A3, $1F636C1B, - $0E12B4C2, $02E1329E, $AF664FD1, $CAD18115, - $6B2395E0, $333E92E1, $3B240B62, $EEBEB922, - $85B2A20E, $E6BA0D99, $DE720C8C, $2DA2F728, - $D0127845, $95B794FD, $647D0862, $E7CCF5F0, - $5449A36F, $877D48FA, $C39DFD27, $F33E8D1E, - $0A476341, $992EFF74, $3A6F6EAB, $F4F8FD37, - $A812DC60, $A1EBDDF8, $991BE14C, $DB6E6B0D, - $C67B5510, $6D672C37, $2765D43B, $DCD0E804, - $F1290DC7, $CC00FFA3, $B5390F92, $690FED0B, - $667B9FFB, $CEDB7D9C, $A091CF0B, $D9155EA3, - $BB132F88, $515BAD24, $7B9479BF, $763BD6EB, - $37392EB3, $CC115979, $8026E297, $F42E312D, - $6842ADA7, $C66A2B3B, $12754CCC, $782EF11C, - $6A124237, $B79251E7, $06A1BBE6, $4BFB6350, - $1A6B1018, $11CAEDFA, $3D25BDD8, $E2E1C3C9, - $44421659, $0A121386, $D90CEC6E, $D5ABEA2A, - $64AF674E, $DA86A85F, $BEBFE988, $64E4C3FE, - $9DBC8057, $F0F7C086, $60787BF8, $6003604D, - $D1FD8346, $F6381FB0, $7745AE04, $D736FCCC, - $83426B33, $F01EAB71, $B0804187, $3C005E5F, - $77A057BE, $BDE8AE24, $55464299, $BF582E61, - $4E58F48F, $F2DDFDA2, $F474EF38, $8789BDC2, - $5366F9C3, $C8B38E74, $B475F255, $46FCD9B9, - $7AEB2661, $8B1DDF84, $846A0E79, $915F95E2, - $466E598E, $20B45770, $8CD55591, $C902DE4C, - $B90BACE1, $BB8205D0, $11A86248, $7574A99E, - $B77F19B6, $E0A9DC09, $662D09A1, $C4324633, - $E85A1F02, $09F0BE8C, $4A99A025, $1D6EFE10, - $1AB93D1D, $0BA5A4DF, $A186F20F, $2868F169, - $DCB7DA83, $573906FE, $A1E2CE9B, $4FCD7F52, - $50115E01, $A70683FA, $A002B5C4, $0DE6D027, - $9AF88C27, $773F8641, $C3604C06, $61A806B5, - $F0177A28, $C0F586E0, $006058AA, $30DC7D62, - $11E69ED7, $2338EA63, $53C2DD94, $C2C21634, - $BBCBEE56, $90BCB6DE, $EBFC7DA1, $CE591D76, - $6F05E409, $4B7C0188, $39720A3D, $7C927C24, - $86E3725F, $724D9DB9, $1AC15BB4, $D39EB8FC, - $ED545578, $08FCA5B5, $D83D7CD3, $4DAD0FC4, - $1E50EF5E, $B161E6F8, $A28514D9, $6C51133C, - $6FD5C7E7, $56E14EC4, $362ABFCE, $DDC6C837, - $D79A3234, $92638212, $670EFA8E, $406000E0), - ( - $3A39CE37, $D3FAF5CF, $ABC27737, $5AC52D1B, - $5CB0679E, $4FA33742, $D3822740, $99BC9BBE, - $D5118E9D, $BF0F7315, $D62D1C7E, $C700C47B, - $B78C1B6B, $21A19045, $B26EB1BE, $6A366EB4, - $5748AB2F, $BC946E79, $C6A376D2, $6549C2C8, - $530FF8EE, $468DDE7D, $D5730A1D, $4CD04DC6, - $2939BBDB, $A9BA4650, $AC9526E8, $BE5EE304, - $A1FAD5F0, $6A2D519A, $63EF8CE2, $9A86EE22, - $C089C2B8, $43242EF6, $A51E03AA, $9CF2D0A4, - $83C061BA, $9BE96A4D, $8FE51550, $BA645BD6, - $2826A2F9, $A73A3AE1, $4BA99586, $EF5562E9, - $C72FEFD3, $F752F7DA, $3F046F69, $77FA0A59, - $80E4A915, $87B08601, $9B09E6AD, $3B3EE593, - $E990FD5A, $9E34D797, $2CF0B7D9, $022B8B51, - $96D5AC3A, $017DA67D, $D1CF3ED6, $7C7D2D28, - $1F9F25CF, $ADF2B89B, $5AD6B472, $5A88F54C, - $E029AC71, $E019A5E6, $47B0ACFD, $ED93FA9B, - $E8D3C48D, $283B57CC, $F8D56629, $79132E28, - $785F0191, $ED756055, $F7960E44, $E3D35E8C, - $15056DD4, $88F46DBA, $03A16125, $0564F0BD, - $C3EB9E15, $3C9057A2, $97271AEC, $A93A072A, - $1B3F6D9B, $1E6321F5, $F59C66FB, $26DCF319, - $7533D928, $B155FDF5, $03563482, $8ABA3CBB, - $28517711, $C20AD9F8, $ABCC5167, $CCAD925F, - $4DE81751, $3830DC8E, $379D5862, $9320F991, - $EA7A90C2, $FB3E7BCE, $5121CE64, $774FBE32, - $A8B6E37E, $C3293D46, $48DE5369, $6413E680, - $A2AE0810, $DD6DB224, $69852DFD, $09072166, - $B39A460A, $6445C0DD, $586CDECF, $1C20C8AE, - $5BBEF7DD, $1B588D40, $CCD2017F, $6BB4E3BB, - $DDA26A7E, $3A59FF45, $3E350A44, $BCB4CDD5, - $72EACEA8, $FA6484BB, $8D6612AE, $BF3C6F47, - $D29BE463, $542F5D9E, $AEC2771B, $F64E6370, - $740E0D8D, $E75B1357, $F8721671, $AF537D5D, - $4040CB08, $4EB4E2CC, $34D2466A, $0115AF84, - $E1B00428, $95983A1D, $06B89FB4, $CE6EA048, - $6F3F3B82, $3520AB82, $011A1D4B, $277227F8, - $611560B1, $E7933FDC, $BB3A792B, $344525BD, - $A08839E1, $51CE794B, $2F32C9B7, $A01FBAC9, - $E01CC87E, $BCC7D1F6, $CF0111C3, $A1E8AAC7, - $1A908749, $D44FBD9A, $D0DADECB, $D50ADA38, - $0339C32A, $C6913667, $8DF9317C, $E0B12B4F, - $F79E59B7, $43F5BB3A, $F2D519FF, $27D9459C, - $BF97222C, $15E6FC2A, $0F91FC71, $9B941525, - $FAE59361, $CEB69CEB, $C2A86459, $12BAA8D1, - $B6C1075E, $E3056A0C, $10D25065, $CB03A442, - $E0EC6E0E, $1698DB3B, $4C98A0BE, $3278E964, - $9F1F9532, $E0D392DF, $D3A0342B, $8971F21E, - $1B0A7441, $4BA3348C, $C5BE7120, $C37632D8, - $DF359F8D, $9B992F2E, $E60B6F47, $0FE3F11D, - $E54CDA54, $1EDAD891, $CE6279CF, $CD3E7E6F, - $1618B166, $FD2C1D05, $848FD2C5, $F6FB2299, - $F523F357, $A6327623, $93A83531, $56CCCD02, - $ACF08162, $5A75EBB5, $6E163697, $88D273CC, - $DE966292, $81B949D0, $4C50901B, $71C65614, - $E6C6C7BD, $327A140A, $45E1D006, $C3F27B9A, - $C9AA53FD, $62A80F00, $BB25BFE2, $35BDD2F6, - $71126905, $B2040222, $B6CBCF7C, $CD769C2B, - $53113EC0, $1640E3D3, $38ABBD60, $2547ADF0, - $BA38209C, $F746CE76, $77AFA1C5, $20756060, - $85CBFE4E, $8AE88DD8, $7AAAF9B0, $4CF9AA7E, - $1948C25C, $02FB8A8C, $01C36AE4, $D6EBE1F9, - $90D4F869, $A65CDEA0, $3F09252D, $C208E69F, - $B74E6132, $CE77E25B, $578FDFE3, $3AC372E6)); - -procedure Blowfish_Make_SBoxes_64BitKey( - const Key: uint64; var SBox: TSBox; var PBox: TPBox); -begin -Blowfish_Make_SBoxes( Key, 8, SBox, PBox) -end; - - -procedure Blowfish_Make_SBoxes( - const Key; KeySizeInBytes: integer; var SBox: TSBox; var PBox: TPBox); -// Assume KeySizeInBytes: 1..56 -var - i, j, k: longword; - T32: uint32; - Block: uint64; - KeyBytePntr: PByte; - -begin -Move( SBoxOrg, SBox, Sizeof( SBox)); -Move( PBoxOrg, PBox, Sizeof( PBox)); -k := 0; -KeyBytePntr := @Key; -for i := 0 to 17 do - begin - for j := 0 to 3 do - begin - {$IF CompilerVersion >= 21} - LongRec( T32).Bytes[ j] := KeyBytePntr[ - (k + 3 - j) mod longword( KeySizeInBytes)] - {$ELSE} - LongRec( T32).Bytes[ j] := PByte( cardinal( KeyBytePntr) + - ((k + 3 - j) mod longword( KeySizeInBytes)))^ - {$IFEND} - end; - PBox[ i ]:= PBox[ i] xor T32; - inc( k, 4); - if k >= longword( KeySizeInBytes) then - dec( k, KeySizeInBytes) - end; -FillChar( Block, Sizeof( Block), 0); -for i := 0 to 8 do - begin - Blowfish_Encrypt( Block, Block, SBox, PBox); - PBox[ i*2 ] := ReverseEndien32( Int64Rec( Block).Lo); - PBox[ i*2+1] := ReverseEndien32( Int64Rec( Block).Hi) - end; -for k:= 0 to 3 do - begin - for i:= 0 to 127 do - begin - Blowfish_Encrypt( Block, Block, SBox, PBox); - SBox[k,i*2 ] := ReverseEndien32( Int64Rec( Block).Lo); - SBox[k,i*2+1] := ReverseEndien32( Int64Rec( Block).Hi) - end - end -end; - - -type - -TBlowfishKey = class( TSymetricKey) - public - FKeySize: integer; - FSeedData: TBytes; - FSBox: TSBox; - FPBox: TPBox; - - constructor GenerateFromSeed( Seed: TStream); - constructor LoadFromStream( Store: TStream); - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -TBlowfishBlockCodec = class( TInterfacedObject, IBlockCodec) - private - FOwner: TBlowFish; - FKey: TBlowfishKey; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - - public - constructor Create( Owner1: TBlowFish; Key1: TBlowfishKey); - end; - - - -function TBlowFish.BlockSize: integer; -begin -result := 64 -end; - - -function TBlowFish.ControlObject: TObject; -begin -result := self -end; - - -constructor TBlowFish.Create; -begin -end; - - -function TBlowFish.DefinitionURL: string; -begin -result := 'http://www.schneier.com/paper-blowfish-fse.html' -end; - - -function TBlowFish.DisplayName: string; -begin -result := 'Blowfish' -end; - - - -function TBlowFish.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - - -function TBlowFish.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := TBlowfishKey.GenerateFromSeed( Seed) -end; - - -function TBlowFish.KeySize: integer; -// Key size is 8 to 448 bits in steps of 8 bits. -// or from 1 to 56 bytes. -begin -result := 64 // Return a nominal value of an 8 byte key. -end; - - -function TBlowFish.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TBlowfishKey.LoadFromStream( Store) -end; - - -function TBlowFish.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := TBlowfishBlockCodec.Create( self, Key as TBlowfishKey) -end; - - -function TBlowFish.ProgId: string; -begin -result := Blowfish_ProgId -end; - - -function TBlowFish.SeedByteSize: integer; -begin -result := (KeySize + 7) div 8 -end; - -{$IF compilerversion < 21} -// Equivalent to [IntegerRange( 1, 56)] -function TBlowFish.MinSeedByteSize: integer; -begin -result := 1 -end; - -function TBlowFish.MaxSeedByteSize: integer; -begin -result := 56 -end; -{$IFEND} - - -function TBlowFish.SelfTest_Ciphertext: string; -// From http://webnet77.com/cgi-bin/helpers/blowfish.pl -begin -result := 'EE69A226ED1C0939' -// == $39091CED26A269EE in little-endien -end; - - -function NibbleToChar( Ch: byte): Char; -begin -if Ch <= 9 then - result := Chr( Ch + Ord( '0')) - else - result := Chr( Ch - 10 + Ord( 'A')) -end; - - -function BytesToBigEndienHex( const Value: TBytes): string; -var - L, i: integer; - C: byte; - {$IFDEF STRINGBUILDER}Output: TStringBuilder;{$ENDIF} -begin -L := Length( Value); -{$IFDEF STRINGBUILDER} -Output := TStringBuilder.Create; -{$ELSE} -SetLength( result, 2 * L); -{$ENDIF} -for i := 0 to L - 1 do - begin - C := Ord( Value[i]); - {$IFDEF STRINGBUILDER} - Output.Append(NibbleToChar( C shr 4)) - .Append(NibbleToChar( C and $0F)); - {$ELSE} - result[i*2 + 1] := NibbleToChar( C shr 4); - result[i*2 + 2] := NibbleToChar( C and $0F); - {$ENDIF} - end; -{$IFDEF STRINGBUILDER} -result := Output.ToString; -Output.Free; -{$ENDIF} -end; - - - -function TBlowFish.SelfTest_Key: string; -// From http://webnet77.com/cgi-bin/helpers/blowfish.pl -var - KeyAsString: string; - BlowfishKey: TBlowfishKey; - BlowfishKeyAsBytes: TBytes; - Temp: TMemoryStream; - L: integer; -begin -// 1. Start with string 'abcdefgh' -KeyAsString := 'abcdefgh'; - -// 2. Make a Blowfish key -Temp := TMemoryStream.Create; -String_to_stream( KeyAsString, Temp{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); -BlowfishKey := TBlowfishKey.GenerateFromSeed( Temp); - -// 3. Save it to a memory stream -Temp.Size := 0; -BlowfishKey.SaveToStream( Temp); - -// 4. Convert to bigendien hexidecimal encoded string. -L := Temp.Size; -SetLength( BlowfishKeyAsBytes, L); -Temp.Position := 0; -Temp.ReadBuffer( BlowfishKeyAsBytes[0], L); -result := BytesToBigEndienHex( BlowfishKeyAsBytes); - -// 5. Clean up. -Temp.Free; -BlowfishKey.Free -end; - - -// For SelfTest_Plaintext(), the non-unison part was contributed by merijnb on Tue 28 of Apr, 2015 -// Refer http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=525&topics_offset=1 -function TBlowFish.SelfTest_Plaintext: string; -// From http://webnet77.com/cgi-bin/helpers/blowfish.pl - - {$IFNDEF UNICODE} - function GetBytes(st: ansistring): TBytes; - begin - SetLength(result, Length(st)); - Move(st[1], result, Length(st)); - end; - {$ENDIF} - -begin -result := BytesToBigEndienHex( {$IFDEF UNICODE}TEncoding.UTF8.{$ENDIF}GetBytes( '12345678')) -end; - -function TBlowFish.WikipediaReference: string; -begin -result := 'Blowfish_(cipher)' -end; - - - - - -{ TBlowfishKey } - -constructor TBlowfishKey.GenerateFromSeed( Seed: TStream); -begin -FKeySize := Seed.Size; -// Assume FKeySize in range [1..56] -SetLength( FSeedData, FKeySize); -Seed.Position := 0; -Seed.Read( FSeedData[0], FKeySize); -Blowfish_Make_SBoxes( FSeedData[0], FKeySize, FSBox, FPBox) -end; - - -constructor TBlowfishKey.LoadFromStream( Store: TStream); -var - Len: byte; - isStoredExpanded: boolean; -begin -Store.ReadBuffer( Len, 1); -FKeySize := Len; -SetLength( FSeedData, FKeySize); -if FKeySize > 0 then - Store.ReadBuffer( FSeedData[0], FKeySize); -Store.ReadBuffer( Len, 1); -isStoredExpanded := Boolean( Len); -if isStoredExpanded then - begin - Store.ReadBuffer( FSBox, SizeOf( FSBox)); - Store.ReadBuffer( FPBox, SizeOf( FPBox)) - end - else - Blowfish_Make_SBoxes( FSeedData[0], FKeySize, FSBox, FPBox) -end; - - - -procedure TBlowfishKey.SaveToStream( Stream: TStream); -var - Len: byte; - doStoreExpanded: boolean; -begin -Len := FKeySize; -Stream.Write( Len, 1); -if FKeySize > 0 then - Stream.Write( FSeedData[0], FKeySize); -doStoreExpanded := StoreBlowFishKeysAsExpanded; // To do: Make this an option. -Len := Ord( doStoreExpanded); -Stream.Write( Len, 1); -if doStoreExpanded then - begin - Stream.Write( FSBox, SizeOf( FSBox)); - Stream.Write( FPBox, SizeOf( FPBox)) - end -end; - - -procedure TBlowfishKey.Burn; -begin -FKeySize := 0; -FillChar( FSBox, SizeOf( FSBox), 0); -FillChar( FPBox, SizeOf( FPBox), 0) -end; - -{ TBlowfishBlockCodec } - -constructor TBlowfishBlockCodec.Create( Owner1: TBlowFish; Key1: TBlowfishKey); -begin -FOwner := Owner1; -FKey := Key1 -end; - - -{$IF CompilerVersion < 21} -type Puint64 = ^uint64; -{$IFEND} - -procedure TBlowfishBlockCodec.Encrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -begin -Blowfish_Encrypt( Puint64( Plaintext.Memory)^, - Puint64( Ciphertext.Memory)^, - FKey.FSBox, FKey.FPBox) -end; - - - -procedure TBlowfishBlockCodec.Decrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -begin -Blowfish_Decrypt( Puint64( Ciphertext.Memory)^, - Puint64( Plaintext.Memory)^, - FKey.FSBox, FKey.FPBox) -end; - - - -procedure TBlowfishBlockCodec.Reset; -begin -end; - - -procedure TBlowfishBlockCodec.Burn; -begin -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.BlowFish; +{$OVERFLOWCHECKS OFF} +interface +uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; + +const + StoreBlowFishKeysAsExpanded = True; // To do: Make this an option. + +type +{$IF compilerversion >= 21} +{$RTTI EXPLICIT METHODS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublished])} +// Exposes the attribute on the SeedByteSize method. +{$IFEND} + +TBlowFish = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm, IControlObject +{$IF compilerversion < 21} + ,IVariableSeedSize +{$IFEND} + ) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; // in units of bits. Must be a multiple of 8. + +{$IF compilerversion >= 21} + [IntegerRange( 8, 448)] +{$IFEND} + function KeySize: integer; + + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + // IControlObject = interface + function ControlObject: TObject; + +{$IF compilerversion >= 21} + [IntegerRange( 1, 56)] + function SeedByteSize: integer; // This is now a nominal value, + // not a must-be value. +{$ELSE} + function SeedByteSize: integer; + function MinSeedByteSize: integer; + function MaxSeedByteSize: integer; +{$IFEND} + + public + constructor Create; + end; + +{$IF CompilerVersion < 21} +uint32 = cardinal; +{$IFEND} + + TSBox = array[ 0..3, 0..255] of uint32; + TPBox = array[ 0..17] of uint32; + +procedure Blowfish_Make_SBoxes_64BitKey( + const Key: uint64; var SBox: TSBox; var PBox: TPBox); + +procedure Blowfish_Make_SBoxes( + const Key; KeySizeInBytes: integer; var SBox: TSBox; var PBox: TPBox); + +procedure Blowfish_Encrypt( + Plaintext: uint64; var Ciphertext: uint64; + var SBox: TSBox; var PBox: TPBox); + +procedure Blowfish_Decrypt( + Ciphertext: uint64; var Plaintext: uint64; + const SBox: TSBox; const PBox: TPBox); + +implementation + + + + +uses TPLB3.Constants, SysUtils, TPLB3.StreamUtils, TPLB3.Compatibility; + + +function ReverseEndien32( Value: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +LongRec( result).Bytes[0] := LongRec( Value).Bytes[3]; +LongRec( result).Bytes[1] := LongRec( Value).Bytes[2]; +LongRec( result).Bytes[2] := LongRec( Value).Bytes[1]; +LongRec( result).Bytes[3] := LongRec( Value).Bytes[0] +end; + + +procedure Blowfish_Encrypt( + Plaintext: uint64; var Ciphertext: uint64; + var SBox: TSBox; var PBox: TPBox); +var + L, R: uint32; + i, j: integer; +begin +L := ReverseEndien32( Int64Rec( Plaintext).Lo) xor PBox[0]; +R := ReverseEndien32( Int64Rec( Plaintext).Hi); +j := 1; +for i := 0 to 7 do + begin + R := R xor + (((SBox[ 0, LongRec( L).Bytes[ 3]] + SBox[ 1, LongRec( L).Bytes[ 2]]) xor + SBox[ 2, LongRec( L).Bytes[ 1]]) + SBox[ 3, LongRec( L).Bytes[ 0]]) xor + PBox[ j]; + Inc( j); + L := L xor + (((SBox[ 0,LongRec( R).Bytes[ 3]] + SBox[ 1, LongRec( R).Bytes[ 2]]) xor + SBox[ 2,LongRec( R).Bytes[ 1]]) + SBox[ 3, LongRec( R).Bytes[ 0]]) xor + PBox[ j]; + Inc( j) + end; +Int64Rec( Ciphertext).Lo := ReverseEndien32( R xor PBox[17]); +Int64Rec( Ciphertext).Hi := ReverseEndien32( L) +end; + + +procedure Blowfish_Decrypt( + Ciphertext: uint64; var Plaintext: uint64; + const SBox: TSBox; const PBox: TPBox); +var + L, R: uint32; + i, j: integer; +begin +L := ReverseEndien32( Int64Rec( Ciphertext).Lo) xor PBox[17]; +R := ReverseEndien32( Int64Rec( Ciphertext).Hi); +j := 16; +for i := 0 to 7 do + begin + R := R xor + (((SBox[ 0, LongRec( L).Bytes[ 3]] + SBox[ 1, LongRec( L).Bytes[ 2]]) xor + SBox[ 2, LongRec( L).Bytes[ 1]]) + SBox[ 3, LongRec( L).Bytes[ 0]]) xor + PBox[ j]; + Dec( j); + L := L xor + (((SBox[ 0,LongRec( R).Bytes[ 3]] + SBox[ 1, LongRec( R).Bytes[ 2]]) xor + SBox[ 2,LongRec( R).Bytes[ 1]]) + SBox[ 3, LongRec( R).Bytes[ 0]]) xor + PBox[ j]; + Dec( j) + end; +Int64Rec( Plaintext).Lo := ReverseEndien32( R xor PBox[0]); +Int64Rec( Plaintext).Hi := ReverseEndien32( L) +end; + + + + +const + PBoxOrg: TPBox = ( + $243F6A88, $85A308D3, $13198A2E, $03707344, + $A4093822, $299F31D0, $082EFA98, $EC4E6C89, + $452821E6, $38D01377, $BE5466CF, $34E90C6C, + $C0AC29B7, $C97C50DD, $3F84D5B5, $B5470917, + $9216D5D9, $8979FB1B); + + SBoxOrg: TSBox = (( + $D1310BA6, $98DFB5AC, $2FFD72DB, $D01ADFB7, + $B8E1AFED, $6A267E96, $BA7C9045, $F12C7F99, + $24A19947, $B3916CF7, $0801F2E2, $858EFC16, + $636920D8, $71574E69, $A458FEA3, $F4933D7E, + $0D95748F, $728EB658, $718BCD58, $82154AEE, + $7B54A41D, $C25A59B5, $9C30D539, $2AF26013, + $C5D1B023, $286085F0, $CA417918, $B8DB38EF, + $8E79DCB0, $603A180E, $6C9E0E8B, $B01E8A3E, + $D71577C1, $BD314B27, $78AF2FDA, $55605C60, + $E65525F3, $AA55AB94, $57489862, $63E81440, + $55CA396A, $2AAB10B6, $B4CC5C34, $1141E8CE, + $A15486AF, $7C72E993, $B3EE1411, $636FBC2A, + $2BA9C55D, $741831F6, $CE5C3E16, $9B87931E, + $AFD6BA33, $6C24CF5C, $7A325381, $28958677, + $3B8F4898, $6B4BB9AF, $C4BFE81B, $66282193, + $61D809CC, $FB21A991, $487CAC60, $5DEC8032, + $EF845D5D, $E98575B1, $DC262302, $EB651B88, + $23893E81, $D396ACC5, $0F6D6FF3, $83F44239, + $2E0B4482, $A4842004, $69C8F04A, $9E1F9B5E, + $21C66842, $F6E96C9A, $670C9C61, $ABD388F0, + $6A51A0D2, $D8542F68, $960FA728, $AB5133A3, + $6EEF0B6C, $137A3BE4, $BA3BF050, $7EFB2A98, + $A1F1651D, $39AF0176, $66CA593E, $82430E88, + $8CEE8619, $456F9FB4, $7D84A5C3, $3B8B5EBE, + $E06F75D8, $85C12073, $401A449F, $56C16AA6, + $4ED3AA62, $363F7706, $1BFEDF72, $429B023D, + $37D0D724, $D00A1248, $DB0FEAD3, $49F1C09B, + $075372C9, $80991B7B, $25D479D8, $F6E8DEF7, + $E3FE501A, $B6794C3B, $976CE0BD, $04C006BA, + $C1A94FB6, $409F60C4, $5E5C9EC2, $196A2463, + $68FB6FAF, $3E6C53B5, $1339B2EB, $3B52EC6F, + $6DFC511F, $9B30952C, $CC814544, $AF5EBD09, + $BEE3D004, $DE334AFD, $660F2807, $192E4BB3, + $C0CBA857, $45C8740F, $D20B5F39, $B9D3FBDB, + $5579C0BD, $1A60320A, $D6A100C6, $402C7279, + $679F25FE, $FB1FA3CC, $8EA5E9F8, $DB3222F8, + $3C7516DF, $FD616B15, $2F501EC8, $AD0552AB, + $323DB5FA, $FD238760, $53317B48, $3E00DF82, + $9E5C57BB, $CA6F8CA0, $1A87562E, $DF1769DB, + $D542A8F6, $287EFFC3, $AC6732C6, $8C4F5573, + $695B27B0, $BBCA58C8, $E1FFA35D, $B8F011A0, + $10FA3D98, $FD2183B8, $4AFCB56C, $2DD1D35B, + $9A53E479, $B6F84565, $D28E49BC, $4BFB9790, + $E1DDF2DA, $A4CB7E33, $62FB1341, $CEE4C6E8, + $EF20CADA, $36774C01, $D07E9EFE, $2BF11FB4, + $95DBDA4D, $AE909198, $EAAD8E71, $6B93D5A0, + $D08ED1D0, $AFC725E0, $8E3C5B2F, $8E7594B7, + $8FF6E2FB, $F2122B64, $8888B812, $900DF01C, + $4FAD5EA0, $688FC31C, $D1CFF191, $B3A8C1AD, + $2F2F2218, $BE0E1777, $EA752DFE, $8B021FA1, + $E5A0CC0F, $B56F74E8, $18ACF3D6, $CE89E299, + $B4A84FE0, $FD13E0B7, $7CC43B81, $D2ADA8D9, + $165FA266, $80957705, $93CC7314, $211A1477, + $E6AD2065, $77B5FA86, $C75442F5, $FB9D35CF, + $EBCDAF0C, $7B3E89A0, $D6411BD3, $AE1E7E49, + $00250E2D, $2071B35E, $226800BB, $57B8E0AF, + $2464369B, $F009B91E, $5563911D, $59DFA6AA, + $78C14389, $D95A537F, $207D5BA2, $02E5B9C5, + $83260376, $6295CFA9, $11C81968, $4E734A41, + $B3472DCA, $7B14A94A, $1B510052, $9A532915, + $D60F573F, $BC9BC6E4, $2B60A476, $81E67400, + $08BA6FB5, $571BE91F, $F296EC6B, $2A0DD915, + $B6636521, $E7B9F9B6, $FF34052E, $C5855664, + $53B02D5D, $A99F8FA1, $08BA4799, $6E85076A), + ( + $4B7A70E9, $B5B32944, $DB75092E, $C4192623, + $AD6EA6B0, $49A7DF7D, $9CEE60B8, $8FEDB266, + $ECAA8C71, $699A17FF, $5664526C, $C2B19EE1, + $193602A5, $75094C29, $A0591340, $E4183A3E, + $3F54989A, $5B429D65, $6B8FE4D6, $99F73FD6, + $A1D29C07, $EFE830F5, $4D2D38E6, $F0255DC1, + $4CDD2086, $8470EB26, $6382E9C6, $021ECC5E, + $09686B3F, $3EBAEFC9, $3C971814, $6B6A70A1, + $687F3584, $52A0E286, $B79C5305, $AA500737, + $3E07841C, $7FDEAE5C, $8E7D44EC, $5716F2B8, + $B03ADA37, $F0500C0D, $F01C1F04, $0200B3FF, + $AE0CF51A, $3CB574B2, $25837A58, $DC0921BD, + $D19113F9, $7CA92FF6, $94324773, $22F54701, + $3AE5E581, $37C2DADC, $C8B57634, $9AF3DDA7, + $A9446146, $0FD0030E, $ECC8C73E, $A4751E41, + $E238CD99, $3BEA0E2F, $3280BBA1, $183EB331, + $4E548B38, $4F6DB908, $6F420D03, $F60A04BF, + $2CB81290, $24977C79, $5679B072, $BCAF89AF, + $DE9A771F, $D9930810, $B38BAE12, $DCCF3F2E, + $5512721F, $2E6B7124, $501ADDE6, $9F84CD87, + $7A584718, $7408DA17, $BC9F9ABC, $E94B7D8C, + $EC7AEC3A, $DB851DFA, $63094366, $C464C3D2, + $EF1C1847, $3215D908, $DD433B37, $24C2BA16, + $12A14D43, $2A65C451, $50940002, $133AE4DD, + $71DFF89E, $10314E55, $81AC77D6, $5F11199B, + $043556F1, $D7A3C76B, $3C11183B, $5924A509, + $F28FE6ED, $97F1FBFA, $9EBABF2C, $1E153C6E, + $86E34570, $EAE96FB1, $860E5E0A, $5A3E2AB3, + $771FE71C, $4E3D06FA, $2965DCB9, $99E71D0F, + $803E89D6, $5266C825, $2E4CC978, $9C10B36A, + $C6150EBA, $94E2EA78, $A5FC3C53, $1E0A2DF4, + $F2F74EA7, $361D2B3D, $1939260F, $19C27960, + $5223A708, $F71312B6, $EBADFE6E, $EAC31F66, + $E3BC4595, $A67BC883, $B17F37D1, $018CFF28, + $C332DDEF, $BE6C5AA5, $65582185, $68AB9802, + $EECEA50F, $DB2F953B, $2AEF7DAD, $5B6E2F84, + $1521B628, $29076170, $ECDD4775, $619F1510, + $13CCA830, $EB61BD96, $0334FE1E, $AA0363CF, + $B5735C90, $4C70A239, $D59E9E0B, $CBAADE14, + $EECC86BC, $60622CA7, $9CAB5CAB, $B2F3846E, + $648B1EAF, $19BDF0CA, $A02369B9, $655ABB50, + $40685A32, $3C2AB4B3, $319EE9D5, $C021B8F7, + $9B540B19, $875FA099, $95F7997E, $623D7DA8, + $F837889A, $97E32D77, $11ED935F, $16681281, + $0E358829, $C7E61FD6, $96DEDFA1, $7858BA99, + $57F584A5, $1B227263, $9B83C3FF, $1AC24696, + $CDB30AEB, $532E3054, $8FD948E4, $6DBC3128, + $58EBF2EF, $34C6FFEA, $FE28ED61, $EE7C3C73, + $5D4A14D9, $E864B7E3, $42105D14, $203E13E0, + $45EEE2B6, $A3AAABEA, $DB6C4F15, $FACB4FD0, + $C742F442, $EF6ABBB5, $654F3B1D, $41CD2105, + $D81E799E, $86854DC7, $E44B476A, $3D816250, + $CF62A1F2, $5B8D2646, $FC8883A0, $C1C7B6A3, + $7F1524C3, $69CB7492, $47848A0B, $5692B285, + $095BBF00, $AD19489D, $1462B174, $23820E00, + $58428D2A, $0C55F5EA, $1DADF43E, $233F7061, + $3372F092, $8D937E41, $D65FECF1, $6C223BDB, + $7CDE3759, $CBEE7460, $4085F2A7, $CE77326E, + $A6078084, $19F8509E, $E8EFD855, $61D99735, + $A969A7AA, $C50C06C2, $5A04ABFC, $800BCADC, + $9E447A2E, $C3453484, $FDD56705, $0E1E9EC9, + $DB73DBD3, $105588CD, $675FDA79, $E3674340, + $C5C43465, $713E38D8, $3D28F89E, $F16DFF20, + $153E21E7, $8FB03D4A, $E6E39F2B, $DB83ADF7), + ( + $E93D5A68, $948140F7, $F64C261C, $94692934, + $411520F7, $7602D4F7, $BCF46B2E, $D4A20068, + $D4082471, $3320F46A, $43B7D4B7, $500061AF, + $1E39F62E, $97244546, $14214F74, $BF8B8840, + $4D95FC1D, $96B591AF, $70F4DDD3, $66A02F45, + $BFBC09EC, $03BD9785, $7FAC6DD0, $31CB8504, + $96EB27B3, $55FD3941, $DA2547E6, $ABCA0A9A, + $28507825, $530429F4, $0A2C86DA, $E9B66DFB, + $68DC1462, $D7486900, $680EC0A4, $27A18DEE, + $4F3FFEA2, $E887AD8C, $B58CE006, $7AF4D6B6, + $AACE1E7C, $D3375FEC, $CE78A399, $406B2A42, + $20FE9E35, $D9F385B9, $EE39D7AB, $3B124E8B, + $1DC9FAF7, $4B6D1856, $26A36631, $EAE397B2, + $3A6EFA74, $DD5B4332, $6841E7F7, $CA7820FB, + $FB0AF54E, $D8FEB397, $454056AC, $BA489527, + $55533A3A, $20838D87, $FE6BA9B7, $D096954B, + $55A867BC, $A1159A58, $CCA92963, $99E1DB33, + $A62A4A56, $3F3125F9, $5EF47E1C, $9029317C, + $FDF8E802, $04272F70, $80BB155C, $05282CE3, + $95C11548, $E4C66D22, $48C1133F, $C70F86DC, + $07F9C9EE, $41041F0F, $404779A4, $5D886E17, + $325F51EB, $D59BC0D1, $F2BCC18F, $41113564, + $257B7834, $602A9C60, $DFF8E8A3, $1F636C1B, + $0E12B4C2, $02E1329E, $AF664FD1, $CAD18115, + $6B2395E0, $333E92E1, $3B240B62, $EEBEB922, + $85B2A20E, $E6BA0D99, $DE720C8C, $2DA2F728, + $D0127845, $95B794FD, $647D0862, $E7CCF5F0, + $5449A36F, $877D48FA, $C39DFD27, $F33E8D1E, + $0A476341, $992EFF74, $3A6F6EAB, $F4F8FD37, + $A812DC60, $A1EBDDF8, $991BE14C, $DB6E6B0D, + $C67B5510, $6D672C37, $2765D43B, $DCD0E804, + $F1290DC7, $CC00FFA3, $B5390F92, $690FED0B, + $667B9FFB, $CEDB7D9C, $A091CF0B, $D9155EA3, + $BB132F88, $515BAD24, $7B9479BF, $763BD6EB, + $37392EB3, $CC115979, $8026E297, $F42E312D, + $6842ADA7, $C66A2B3B, $12754CCC, $782EF11C, + $6A124237, $B79251E7, $06A1BBE6, $4BFB6350, + $1A6B1018, $11CAEDFA, $3D25BDD8, $E2E1C3C9, + $44421659, $0A121386, $D90CEC6E, $D5ABEA2A, + $64AF674E, $DA86A85F, $BEBFE988, $64E4C3FE, + $9DBC8057, $F0F7C086, $60787BF8, $6003604D, + $D1FD8346, $F6381FB0, $7745AE04, $D736FCCC, + $83426B33, $F01EAB71, $B0804187, $3C005E5F, + $77A057BE, $BDE8AE24, $55464299, $BF582E61, + $4E58F48F, $F2DDFDA2, $F474EF38, $8789BDC2, + $5366F9C3, $C8B38E74, $B475F255, $46FCD9B9, + $7AEB2661, $8B1DDF84, $846A0E79, $915F95E2, + $466E598E, $20B45770, $8CD55591, $C902DE4C, + $B90BACE1, $BB8205D0, $11A86248, $7574A99E, + $B77F19B6, $E0A9DC09, $662D09A1, $C4324633, + $E85A1F02, $09F0BE8C, $4A99A025, $1D6EFE10, + $1AB93D1D, $0BA5A4DF, $A186F20F, $2868F169, + $DCB7DA83, $573906FE, $A1E2CE9B, $4FCD7F52, + $50115E01, $A70683FA, $A002B5C4, $0DE6D027, + $9AF88C27, $773F8641, $C3604C06, $61A806B5, + $F0177A28, $C0F586E0, $006058AA, $30DC7D62, + $11E69ED7, $2338EA63, $53C2DD94, $C2C21634, + $BBCBEE56, $90BCB6DE, $EBFC7DA1, $CE591D76, + $6F05E409, $4B7C0188, $39720A3D, $7C927C24, + $86E3725F, $724D9DB9, $1AC15BB4, $D39EB8FC, + $ED545578, $08FCA5B5, $D83D7CD3, $4DAD0FC4, + $1E50EF5E, $B161E6F8, $A28514D9, $6C51133C, + $6FD5C7E7, $56E14EC4, $362ABFCE, $DDC6C837, + $D79A3234, $92638212, $670EFA8E, $406000E0), + ( + $3A39CE37, $D3FAF5CF, $ABC27737, $5AC52D1B, + $5CB0679E, $4FA33742, $D3822740, $99BC9BBE, + $D5118E9D, $BF0F7315, $D62D1C7E, $C700C47B, + $B78C1B6B, $21A19045, $B26EB1BE, $6A366EB4, + $5748AB2F, $BC946E79, $C6A376D2, $6549C2C8, + $530FF8EE, $468DDE7D, $D5730A1D, $4CD04DC6, + $2939BBDB, $A9BA4650, $AC9526E8, $BE5EE304, + $A1FAD5F0, $6A2D519A, $63EF8CE2, $9A86EE22, + $C089C2B8, $43242EF6, $A51E03AA, $9CF2D0A4, + $83C061BA, $9BE96A4D, $8FE51550, $BA645BD6, + $2826A2F9, $A73A3AE1, $4BA99586, $EF5562E9, + $C72FEFD3, $F752F7DA, $3F046F69, $77FA0A59, + $80E4A915, $87B08601, $9B09E6AD, $3B3EE593, + $E990FD5A, $9E34D797, $2CF0B7D9, $022B8B51, + $96D5AC3A, $017DA67D, $D1CF3ED6, $7C7D2D28, + $1F9F25CF, $ADF2B89B, $5AD6B472, $5A88F54C, + $E029AC71, $E019A5E6, $47B0ACFD, $ED93FA9B, + $E8D3C48D, $283B57CC, $F8D56629, $79132E28, + $785F0191, $ED756055, $F7960E44, $E3D35E8C, + $15056DD4, $88F46DBA, $03A16125, $0564F0BD, + $C3EB9E15, $3C9057A2, $97271AEC, $A93A072A, + $1B3F6D9B, $1E6321F5, $F59C66FB, $26DCF319, + $7533D928, $B155FDF5, $03563482, $8ABA3CBB, + $28517711, $C20AD9F8, $ABCC5167, $CCAD925F, + $4DE81751, $3830DC8E, $379D5862, $9320F991, + $EA7A90C2, $FB3E7BCE, $5121CE64, $774FBE32, + $A8B6E37E, $C3293D46, $48DE5369, $6413E680, + $A2AE0810, $DD6DB224, $69852DFD, $09072166, + $B39A460A, $6445C0DD, $586CDECF, $1C20C8AE, + $5BBEF7DD, $1B588D40, $CCD2017F, $6BB4E3BB, + $DDA26A7E, $3A59FF45, $3E350A44, $BCB4CDD5, + $72EACEA8, $FA6484BB, $8D6612AE, $BF3C6F47, + $D29BE463, $542F5D9E, $AEC2771B, $F64E6370, + $740E0D8D, $E75B1357, $F8721671, $AF537D5D, + $4040CB08, $4EB4E2CC, $34D2466A, $0115AF84, + $E1B00428, $95983A1D, $06B89FB4, $CE6EA048, + $6F3F3B82, $3520AB82, $011A1D4B, $277227F8, + $611560B1, $E7933FDC, $BB3A792B, $344525BD, + $A08839E1, $51CE794B, $2F32C9B7, $A01FBAC9, + $E01CC87E, $BCC7D1F6, $CF0111C3, $A1E8AAC7, + $1A908749, $D44FBD9A, $D0DADECB, $D50ADA38, + $0339C32A, $C6913667, $8DF9317C, $E0B12B4F, + $F79E59B7, $43F5BB3A, $F2D519FF, $27D9459C, + $BF97222C, $15E6FC2A, $0F91FC71, $9B941525, + $FAE59361, $CEB69CEB, $C2A86459, $12BAA8D1, + $B6C1075E, $E3056A0C, $10D25065, $CB03A442, + $E0EC6E0E, $1698DB3B, $4C98A0BE, $3278E964, + $9F1F9532, $E0D392DF, $D3A0342B, $8971F21E, + $1B0A7441, $4BA3348C, $C5BE7120, $C37632D8, + $DF359F8D, $9B992F2E, $E60B6F47, $0FE3F11D, + $E54CDA54, $1EDAD891, $CE6279CF, $CD3E7E6F, + $1618B166, $FD2C1D05, $848FD2C5, $F6FB2299, + $F523F357, $A6327623, $93A83531, $56CCCD02, + $ACF08162, $5A75EBB5, $6E163697, $88D273CC, + $DE966292, $81B949D0, $4C50901B, $71C65614, + $E6C6C7BD, $327A140A, $45E1D006, $C3F27B9A, + $C9AA53FD, $62A80F00, $BB25BFE2, $35BDD2F6, + $71126905, $B2040222, $B6CBCF7C, $CD769C2B, + $53113EC0, $1640E3D3, $38ABBD60, $2547ADF0, + $BA38209C, $F746CE76, $77AFA1C5, $20756060, + $85CBFE4E, $8AE88DD8, $7AAAF9B0, $4CF9AA7E, + $1948C25C, $02FB8A8C, $01C36AE4, $D6EBE1F9, + $90D4F869, $A65CDEA0, $3F09252D, $C208E69F, + $B74E6132, $CE77E25B, $578FDFE3, $3AC372E6)); + +procedure Blowfish_Make_SBoxes_64BitKey( + const Key: uint64; var SBox: TSBox; var PBox: TPBox); +begin +Blowfish_Make_SBoxes( Key, 8, SBox, PBox) +end; + + +procedure Blowfish_Make_SBoxes( + const Key; KeySizeInBytes: integer; var SBox: TSBox; var PBox: TPBox); +// Assume KeySizeInBytes: 1..56 +var + i, j, k: longword; + T32: uint32; + Block: uint64; + KeyBytePntr: PByte; + +begin +Move( SBoxOrg, SBox, Sizeof( SBox)); +Move( PBoxOrg, PBox, Sizeof( PBox)); +k := 0; +KeyBytePntr := @Key; +for i := 0 to 17 do + begin + for j := 0 to 3 do + begin + {$IF CompilerVersion >= 21} + LongRec( T32).Bytes[ j] := KeyBytePntr[ + (k + 3 - j) mod longword( KeySizeInBytes)] + {$ELSE} + LongRec( T32).Bytes[ j] := PByte( cardinal( KeyBytePntr) + + ((k + 3 - j) mod longword( KeySizeInBytes)))^ + {$IFEND} + end; + PBox[ i ]:= PBox[ i] xor T32; + inc( k, 4); + if k >= longword( KeySizeInBytes) then + dec( k, KeySizeInBytes) + end; +FillChar( Block, Sizeof( Block), 0); +for i := 0 to 8 do + begin + Blowfish_Encrypt( Block, Block, SBox, PBox); + PBox[ i*2 ] := ReverseEndien32( Int64Rec( Block).Lo); + PBox[ i*2+1] := ReverseEndien32( Int64Rec( Block).Hi) + end; +for k:= 0 to 3 do + begin + for i:= 0 to 127 do + begin + Blowfish_Encrypt( Block, Block, SBox, PBox); + SBox[k,i*2 ] := ReverseEndien32( Int64Rec( Block).Lo); + SBox[k,i*2+1] := ReverseEndien32( Int64Rec( Block).Hi) + end + end +end; + + +type + +TBlowfishKey = class( TSymetricKey) + public + FKeySize: integer; + FSeedData: TBytes; + FSBox: TSBox; + FPBox: TPBox; + + constructor GenerateFromSeed( Seed: TStream); + constructor LoadFromStream( Store: TStream); + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +TBlowfishBlockCodec = class( TInterfacedObject, IBlockCodec) + private + FOwner: TBlowFish; + FKey: TBlowfishKey; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + + public + constructor Create( Owner1: TBlowFish; Key1: TBlowfishKey); + end; + + + +function TBlowFish.BlockSize: integer; +begin +result := 64 +end; + + +function TBlowFish.ControlObject: TObject; +begin +result := self +end; + + +constructor TBlowFish.Create; +begin +end; + + +function TBlowFish.DefinitionURL: string; +begin +result := 'http://www.schneier.com/paper-blowfish-fse.html' +end; + + +function TBlowFish.DisplayName: string; +begin +result := 'Blowfish' +end; + + + +function TBlowFish.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + + +function TBlowFish.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := TBlowfishKey.GenerateFromSeed( Seed) +end; + + +function TBlowFish.KeySize: integer; +// Key size is 8 to 448 bits in steps of 8 bits. +// or from 1 to 56 bytes. +begin +result := 64 // Return a nominal value of an 8 byte key. +end; + + +function TBlowFish.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TBlowfishKey.LoadFromStream( Store) +end; + + +function TBlowFish.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := TBlowfishBlockCodec.Create( self, Key as TBlowfishKey) +end; + + +function TBlowFish.ProgId: string; +begin +result := Blowfish_ProgId +end; + + +function TBlowFish.SeedByteSize: integer; +begin +result := (KeySize + 7) div 8 +end; + +{$IF compilerversion < 21} +// Equivalent to [IntegerRange( 1, 56)] +function TBlowFish.MinSeedByteSize: integer; +begin +result := 1 +end; + +function TBlowFish.MaxSeedByteSize: integer; +begin +result := 56 +end; +{$IFEND} + + +function TBlowFish.SelfTest_Ciphertext: string; +// From http://webnet77.com/cgi-bin/helpers/blowfish.pl +begin +result := 'EE69A226ED1C0939' +// == $39091CED26A269EE in little-endien +end; + + +function NibbleToChar( Ch: byte): Char; +begin +if Ch <= 9 then + result := Chr( Ch + Ord( '0')) + else + result := Chr( Ch - 10 + Ord( 'A')) +end; + + +function BytesToBigEndienHex( const Value: TBytes): string; +var + L, i: integer; + C: byte; + {$IFDEF STRINGBUILDER}Output: TStringBuilder;{$ENDIF} +begin +L := Length( Value); +{$IFDEF STRINGBUILDER} +Output := TStringBuilder.Create; +{$ELSE} +SetLength( result, 2 * L); +{$ENDIF} +for i := 0 to L - 1 do + begin + C := Ord( Value[i]); + {$IFDEF STRINGBUILDER} + Output.Append(NibbleToChar( C shr 4)) + .Append(NibbleToChar( C and $0F)); + {$ELSE} + result[i*2 + 1] := NibbleToChar( C shr 4); + result[i*2 + 2] := NibbleToChar( C and $0F); + {$ENDIF} + end; +{$IFDEF STRINGBUILDER} +result := Output.ToString; +Output.Free; +{$ENDIF} +end; + + + +function TBlowFish.SelfTest_Key: string; +// From http://webnet77.com/cgi-bin/helpers/blowfish.pl +var + KeyAsString: string; + BlowfishKey: TBlowfishKey; + BlowfishKeyAsBytes: TBytes; + Temp: TMemoryStream; + L: integer; +begin +// 1. Start with string 'abcdefgh' +KeyAsString := 'abcdefgh'; + +// 2. Make a Blowfish key +Temp := TMemoryStream.Create; +String_to_stream( KeyAsString, Temp{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); +BlowfishKey := TBlowfishKey.GenerateFromSeed( Temp); + +// 3. Save it to a memory stream +Temp.Size := 0; +BlowfishKey.SaveToStream( Temp); + +// 4. Convert to bigendien hexidecimal encoded string. +L := Temp.Size; +SetLength( BlowfishKeyAsBytes, L); +Temp.Position := 0; +Temp.ReadBuffer( BlowfishKeyAsBytes[0], L); +result := BytesToBigEndienHex( BlowfishKeyAsBytes); + +// 5. Clean up. +Temp.Free; +BlowfishKey.Free +end; + + +// For SelfTest_Plaintext(), the non-unison part was contributed by merijnb on Tue 28 of Apr, 2015 +// Refer http://lockbox.seanbdurkin.id.au/tiki-view_forum_thread.php?comments_parentId=525&topics_offset=1 +function TBlowFish.SelfTest_Plaintext: string; +// From http://webnet77.com/cgi-bin/helpers/blowfish.pl + + {$IFNDEF UNICODE} + function GetBytes(st: ansistring): TBytes; + begin + SetLength(result, Length(st)); + Move(st[1], result, Length(st)); + end; + {$ENDIF} + +begin +result := BytesToBigEndienHex( {$IFDEF UNICODE}TEncoding.UTF8.{$ENDIF}GetBytes( '12345678')) +end; + +function TBlowFish.WikipediaReference: string; +begin +result := 'Blowfish_(cipher)' +end; + + + + + +{ TBlowfishKey } + +constructor TBlowfishKey.GenerateFromSeed( Seed: TStream); +begin +FKeySize := Seed.Size; +// Assume FKeySize in range [1..56] +SetLength( FSeedData, FKeySize); +Seed.Position := 0; +Seed.Read( FSeedData[0], FKeySize); +Blowfish_Make_SBoxes( FSeedData[0], FKeySize, FSBox, FPBox) +end; + + +constructor TBlowfishKey.LoadFromStream( Store: TStream); +var + Len: byte; + isStoredExpanded: boolean; +begin +Store.ReadBuffer( Len, 1); +FKeySize := Len; +SetLength( FSeedData, FKeySize); +if FKeySize > 0 then + Store.ReadBuffer( FSeedData[0], FKeySize); +Store.ReadBuffer( Len, 1); +isStoredExpanded := Boolean( Len); +if isStoredExpanded then + begin + Store.ReadBuffer( FSBox, SizeOf( FSBox)); + Store.ReadBuffer( FPBox, SizeOf( FPBox)) + end + else + Blowfish_Make_SBoxes( FSeedData[0], FKeySize, FSBox, FPBox) +end; + + + +procedure TBlowfishKey.SaveToStream( Stream: TStream); +var + Len: byte; + doStoreExpanded: boolean; +begin +Len := FKeySize; +Stream.Write( Len, 1); +if FKeySize > 0 then + Stream.Write( FSeedData[0], FKeySize); +doStoreExpanded := StoreBlowFishKeysAsExpanded; // To do: Make this an option. +Len := Ord( doStoreExpanded); +Stream.Write( Len, 1); +if doStoreExpanded then + begin + Stream.Write( FSBox, SizeOf( FSBox)); + Stream.Write( FPBox, SizeOf( FPBox)) + end +end; + + +procedure TBlowfishKey.Burn; +begin +FKeySize := 0; +FillChar( FSBox, SizeOf( FSBox), 0); +FillChar( FPBox, SizeOf( FPBox), 0) +end; + +{ TBlowfishBlockCodec } + +constructor TBlowfishBlockCodec.Create( Owner1: TBlowFish; Key1: TBlowfishKey); +begin +FOwner := Owner1; +FKey := Key1 +end; + + +{$IF CompilerVersion < 21} +type Puint64 = ^uint64; +{$IFEND} + +procedure TBlowfishBlockCodec.Encrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +begin +Blowfish_Encrypt( Puint64( Plaintext.Memory)^, + Puint64( Ciphertext.Memory)^, + FKey.FSBox, FKey.FPBox) +end; + + + +procedure TBlowfishBlockCodec.Decrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +begin +Blowfish_Decrypt( Puint64( Ciphertext.Memory)^, + Puint64( Plaintext.Memory)^, + FKey.FSBox, FKey.FPBox) +end; + + + +procedure TBlowfishBlockCodec.Reset; +begin +end; + + +procedure TBlowfishBlockCodec.Burn; +begin +end; + + +end. diff --git a/run/TPLB3.CBC.pas b/LockBox3/run/TPLB3.CBC.pas similarity index 96% rename from run/TPLB3.CBC.pas rename to LockBox3/run/TPLB3.CBC.pas index 2428e93..d66d98a 100644 --- a/run/TPLB3.CBC.pas +++ b/LockBox3/run/TPLB3.CBC.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,179 +12,179 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CBC; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TCBC = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TCBCLink = class( TBlockChainLink) - private - FNextCV: TMemoryStream; - - public - procedure Burn; override; - function Clone: TBlockChainLink; override; - destructor Destroy; override; - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - - - - - -uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; - -function TCBC.ChainingFeatures: TChainingFeatureSet; -begin -result := [] -end; - -function TCBC.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCBCLink.BaseCreate( Key, InitializationVector, Cipher); -TCBCLink( result).FNextCV := TMemoryStream.Create -end; - - - -function TCBC.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCBCLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TCBC.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.2' -end; - - - -function TCBC.DisplayName: string; -begin -result := 'CBC' -end; - - - -function TCBC.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afStar] -end; - - - - -function TCBC.ProgId: string; -begin -result := CBC_ProgId -end; - - - - - -function TCBC.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Cipher_block_chaining#Cipher-block_chaining_.28CBC.29' -end; - - - -{ TCBCLink } - -procedure TCBCLink.Burn; -begin -inherited; -if assigned( FNextCV) then - BurnMemoryStream( FNextCV) -end; - - -destructor TCBCLink.Destroy; -begin -inherited; -FNextCV.Free -end; - - -function TCBCLink.Clone: TBlockChainLink; -begin -result := inherited Clone; -if assigned( FNextCV) then - TCBCLink( result).FNextCV := CloneMemoryStream( FNextCV) -end; - - -procedure TCBCLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -CopyMemoryStream( Ciphertext, FNextCV); -FCipher.Decrypt_Block( Plaintext, Ciphertext); -XOR_Streams2( Plaintext, FCV); // plaintext := plaintext xor FCV -CopyMemoryStream( FNextCV, FCV) -end; - - - - - -procedure TCBCLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -XOR_Streams2( FCV, Plaintext); // FCV := FCV xor plaintext -FCipher.Encrypt_Block( FCV, Ciphertext); -CopyMemoryStream( Ciphertext, FCV) -end; - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CBC; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TCBC = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TCBCLink = class( TBlockChainLink) + private + FNextCV: TMemoryStream; + + public + procedure Burn; override; + function Clone: TBlockChainLink; override; + destructor Destroy; override; + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; + +function TCBC.ChainingFeatures: TChainingFeatureSet; +begin +result := [] +end; + +function TCBC.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCBCLink.BaseCreate( Key, InitializationVector, Cipher); +TCBCLink( result).FNextCV := TMemoryStream.Create +end; + + + +function TCBC.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCBCLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TCBC.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.2' +end; + + + +function TCBC.DisplayName: string; +begin +result := 'CBC' +end; + + + +function TCBC.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afStar] +end; + + + + +function TCBC.ProgId: string; +begin +result := CBC_ProgId +end; + + + + + +function TCBC.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Cipher_block_chaining#Cipher-block_chaining_.28CBC.29' +end; + + + +{ TCBCLink } + +procedure TCBCLink.Burn; +begin +inherited; +if assigned( FNextCV) then + BurnMemoryStream( FNextCV) +end; + + +destructor TCBCLink.Destroy; +begin +inherited; +FNextCV.Free +end; + + +function TCBCLink.Clone: TBlockChainLink; +begin +result := inherited Clone; +if assigned( FNextCV) then + TCBCLink( result).FNextCV := CloneMemoryStream( FNextCV) +end; + + +procedure TCBCLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +CopyMemoryStream( Ciphertext, FNextCV); +FCipher.Decrypt_Block( Plaintext, Ciphertext); +XOR_Streams2( Plaintext, FCV); // plaintext := plaintext xor FCV +CopyMemoryStream( FNextCV, FCV) +end; + + + + + +procedure TCBCLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +XOR_Streams2( FCV, Plaintext); // FCV := FCV xor plaintext +FCipher.Encrypt_Block( FCV, Ciphertext); +CopyMemoryStream( Ciphertext, FCV) +end; + +end. + diff --git a/run/TPLB3.CFB_8Bit.pas b/LockBox3/run/TPLB3.CFB_8Bit.pas similarity index 96% rename from run/TPLB3.CFB_8Bit.pas rename to LockBox3/run/TPLB3.CFB_8Bit.pas index e8bf38d..fc0eaa1 100644 --- a/run/TPLB3.CFB_8Bit.pas +++ b/LockBox3/run/TPLB3.CFB_8Bit.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,215 +12,215 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CFB_8Bit; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TCFB_8Bit = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - - - -TCFB_8BitLink = class( TBlockChainLink) - protected - FTemp: TMemoryStream; - FBlockSize_Minus1: integer; - - constructor Create( - Key1: TSymetricKey; // Will be referenced, not cloned. - IV1: TMemoryStream; // Will be cloned. - Cipher1: IBlockCodec); // Will be referenced, not cloned. - - public - procedure Burn; override; - function Clone: TBlockChainLink; override; - destructor Destroy; override; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - procedure Encrypt_8bit( Plaintext{in}: byte; var Ciphertext{out}: byte); override; - procedure Decrypt_8bit( var Plaintext{out}: byte; Ciphertext{in}: byte); override; - end; - - -implementation - - - - - -uses TPLB3.StreamUtils, TPLB3.PointerArithmetic, TPLB3.Constants, TPLB3.I18n; -{ TCFB_8Bit } - -function TCFB_8Bit.ChainingFeatures: TChainingFeatureSet; -begin -result := [cfKeyStream, cf8bit] -end; - - -function TCFB_8Bit.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCFB_8BitLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TCFB_8Bit.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCFB_8BitLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TCFB_8Bit.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.3' -end; - -function TCFB_8Bit.DisplayName: string; -begin -result := CFB8bit_DisplayName -end; - - - -function TCFB_8Bit.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - -function TCFB_8Bit.ProgId: string; -begin -result := CFB8bit_ProgId -end; - - - - - -function TCFB_8Bit.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29' -end; - -{ TCFB_8BitLink } - -procedure TCFB_8BitLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -end; - - -procedure TCFB_8BitLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -end; - - - -destructor TCFB_8BitLink.Destroy; -begin -BurnMemoryStream( FTemp); -inherited; -FTemp.Free -end; - - - -constructor TCFB_8BitLink.Create( - Key1: TSymetricKey; IV1: TMemoryStream; Cipher1: IBlockCodec); -begin -BaseCreate( Key1, IV1, Cipher1); -FTemp := TMemoryStream.Create; -FTemp.Size := FCV.Size; -FBlockSize_Minus1 := FTemp.Size - 1 -end; - - -function TCFB_8BitLink.Clone: TBlockChainLink; -begin -result := inherited Clone; -FTemp := TMemoryStream.Create; -FTemp.Size := FCV.Size; -FBlockSize_Minus1 := FTemp.Size - 1 -end; - - -procedure TCFB_8BitLink.Burn; -begin -inherited; -ZeroFillStream( FTemp) -end; - - -procedure TCFB_8BitLink.Encrypt_8bit( Plaintext: byte; var Ciphertext: byte); -var - P: PByte; -begin -FCipher.Encrypt_Block( FCV, FTemp); -FTemp.Position := 0; -FTemp.Read( Ciphertext, 1); -Ciphertext := Ciphertext xor Plaintext; -P := FCV.Memory; -Move( Offset( P, 1)^, P^, FBlockSize_Minus1); -PByte( Offset(P, FBlockSize_Minus1))^ := Ciphertext -end; - - -procedure TCFB_8BitLink.Decrypt_8bit( var Plaintext: byte; Ciphertext: byte); -var - P: PByte; -begin -FCipher.Encrypt_Block( FCV, FTemp); -FTemp.Position := 0; -FTemp.Read( Plaintext, 1); -Plaintext := Ciphertext xor Plaintext; -P := FCV.Memory; -Move( Offset( P, 1)^, P^, FBlockSize_Minus1); -PByte( Offset(P, FBlockSize_Minus1))^ := Ciphertext -end; - - - - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CFB_8Bit; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TCFB_8Bit = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + + + +TCFB_8BitLink = class( TBlockChainLink) + protected + FTemp: TMemoryStream; + FBlockSize_Minus1: integer; + + constructor Create( + Key1: TSymetricKey; // Will be referenced, not cloned. + IV1: TMemoryStream; // Will be cloned. + Cipher1: IBlockCodec); // Will be referenced, not cloned. + + public + procedure Burn; override; + function Clone: TBlockChainLink; override; + destructor Destroy; override; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + procedure Encrypt_8bit( Plaintext{in}: byte; var Ciphertext{out}: byte); override; + procedure Decrypt_8bit( var Plaintext{out}: byte; Ciphertext{in}: byte); override; + end; + + +implementation + + + + + +uses TPLB3.StreamUtils, TPLB3.PointerArithmetic, TPLB3.Constants, TPLB3.I18n; +{ TCFB_8Bit } + +function TCFB_8Bit.ChainingFeatures: TChainingFeatureSet; +begin +result := [cfKeyStream, cf8bit] +end; + + +function TCFB_8Bit.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCFB_8BitLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TCFB_8Bit.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCFB_8BitLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TCFB_8Bit.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.3' +end; + +function TCFB_8Bit.DisplayName: string; +begin +result := CFB8bit_DisplayName +end; + + + +function TCFB_8Bit.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + +function TCFB_8Bit.ProgId: string; +begin +result := CFB8bit_ProgId +end; + + + + + +function TCFB_8Bit.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29' +end; + +{ TCFB_8BitLink } + +procedure TCFB_8BitLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +end; + + +procedure TCFB_8BitLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +end; + + + +destructor TCFB_8BitLink.Destroy; +begin +BurnMemoryStream( FTemp); +inherited; +FTemp.Free +end; + + + +constructor TCFB_8BitLink.Create( + Key1: TSymetricKey; IV1: TMemoryStream; Cipher1: IBlockCodec); +begin +BaseCreate( Key1, IV1, Cipher1); +FTemp := TMemoryStream.Create; +FTemp.Size := FCV.Size; +FBlockSize_Minus1 := FTemp.Size - 1 +end; + + +function TCFB_8BitLink.Clone: TBlockChainLink; +begin +result := inherited Clone; +FTemp := TMemoryStream.Create; +FTemp.Size := FCV.Size; +FBlockSize_Minus1 := FTemp.Size - 1 +end; + + +procedure TCFB_8BitLink.Burn; +begin +inherited; +ZeroFillStream( FTemp) +end; + + +procedure TCFB_8BitLink.Encrypt_8bit( Plaintext: byte; var Ciphertext: byte); +var + P: PByte; +begin +FCipher.Encrypt_Block( FCV, FTemp); +FTemp.Position := 0; +FTemp.Read( Ciphertext, 1); +Ciphertext := Ciphertext xor Plaintext; +P := FCV.Memory; +Move( Offset( P, 1)^, P^, FBlockSize_Minus1); +PByte( Offset(P, FBlockSize_Minus1))^ := Ciphertext +end; + + +procedure TCFB_8BitLink.Decrypt_8bit( var Plaintext: byte; Ciphertext: byte); +var + P: PByte; +begin +FCipher.Encrypt_Block( FCV, FTemp); +FTemp.Position := 0; +FTemp.Read( Plaintext, 1); +Plaintext := Ciphertext xor Plaintext; +P := FCV.Memory; +Move( Offset( P, 1)^, P^, FBlockSize_Minus1); +PByte( Offset(P, FBlockSize_Minus1))^ := Ciphertext +end; + + + + +end. + diff --git a/run/TPLB3.CFB_Block.pas b/LockBox3/run/TPLB3.CFB_Block.pas similarity index 96% rename from run/TPLB3.CFB_Block.pas rename to LockBox3/run/TPLB3.CFB_Block.pas index 1668025..c5c128d 100644 --- a/run/TPLB3.CFB_Block.pas +++ b/LockBox3/run/TPLB3.CFB_Block.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,151 +12,151 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CFB_Block; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TCFB_Block = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TCFB_BlockLink = class( TBlockChainLink) - public - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - - - - - - - -uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; - -{ TCFB_Block } - -function TCFB_Block.ChainingFeatures: TChainingFeatureSet; -begin -result := [cfKeyStream] -end; - - -function TCFB_Block.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCFB_BlockLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TCFB_Block.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCFB_BlockLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TCFB_Block.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.3' -end; - - - -function TCFB_Block.DisplayName: string; -begin -result := 'CFB' -end; - - - -function TCFB_Block.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - - -function TCFB_Block.ProgId: string; -begin -result := CFB_ProgId -end; - - - - - -function TCFB_Block.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29' -end; - - - -{ TCFB_BlockLink } - -procedure TCFB_BlockLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Ciphertext); -XOR_Streams2( Ciphertext, Plaintext); // Ciphertext := Ciphertext xor Plaintext -CopyMemoryStream( Ciphertext, FCV) -end; - - -procedure TCFB_BlockLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Plaintext); -XOR_Streams2( Plaintext, Ciphertext); // Plaintext := Plaintext xor Ciphertext -CopyMemoryStream( Ciphertext, FCV) // FCV := Ciphertext -end; - - - - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CFB_Block; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TCFB_Block = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TCFB_BlockLink = class( TBlockChainLink) + public + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + + + + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; + +{ TCFB_Block } + +function TCFB_Block.ChainingFeatures: TChainingFeatureSet; +begin +result := [cfKeyStream] +end; + + +function TCFB_Block.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCFB_BlockLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TCFB_Block.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCFB_BlockLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TCFB_Block.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.3' +end; + + + +function TCFB_Block.DisplayName: string; +begin +result := 'CFB' +end; + + + +function TCFB_Block.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + + +function TCFB_Block.ProgId: string; +begin +result := CFB_ProgId +end; + + + + + +function TCFB_Block.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29' +end; + + + +{ TCFB_BlockLink } + +procedure TCFB_BlockLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Ciphertext); +XOR_Streams2( Ciphertext, Plaintext); // Ciphertext := Ciphertext xor Plaintext +CopyMemoryStream( Ciphertext, FCV) +end; + + +procedure TCFB_BlockLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Plaintext); +XOR_Streams2( Plaintext, Ciphertext); // Plaintext := Plaintext xor Ciphertext +CopyMemoryStream( Ciphertext, FCV) // FCV := Ciphertext +end; + + + + +end. + diff --git a/run/TPLB3.CTR.pas b/LockBox3/run/TPLB3.CTR.pas similarity index 96% rename from run/TPLB3.CTR.pas rename to LockBox3/run/TPLB3.CTR.pas index 2749517..637611b 100644 --- a/run/TPLB3.CTR.pas +++ b/LockBox3/run/TPLB3.CTR.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,171 +12,171 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CTR; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TCTR = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TCTRLink = class( TBlockChainLink) - private - FCounter: PInt64; - - protected - constructor Create( - Key1: TSymetricKey; // Will be referenced, not cloned. - IV1: TMemoryStream; // Will be cloned. - Cipher1: IBlockCodec); // Will be referenced, not cloned. - - public - function Clone: TBlockChainLink; override; - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - - - -uses TPLB3.Constants, TPLB3.I18n; - -{ TCTR } - -function TCTR.ChainingFeatures: TChainingFeatureSet; -begin -result := [cfKeyStream, cfAutoXOR] -end; - - - -function TCTR.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCTRLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TCTR.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TCTRLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TCTR.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.5' -end; - -function TCTR.DisplayName: string; -begin -result := 'CTR' -end; - - - -function TCTR.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - - -function TCTR.ProgId: string; -begin -result := CTR_ProgId -end; - - - - - -function TCTR.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Counter_.28CTR.29' -end; - -{ TCTRLink } - -function TCTRLink.Clone: TBlockChainLink; -begin -result := inherited Clone; -TCTRLink(result).FCounter := TCTRLink(result).FCV.Memory -end; - - -constructor TCTRLink.Create( - Key1: TSymetricKey; IV1: TMemoryStream; - Cipher1: IBlockCodec); -begin -BaseCreate( Key1, IV1, Cipher1); -FCounter := FCV.Memory -end; - - -procedure TCTRLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Ciphertext); -// The plaintext block will automatically be xored with the product -// of the above by virture of the cfAutoXOR feature. -FCounter^ := FCounter^ + 1 -end; - -procedure TCTRLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Plaintext); -// The ciphertext block will automatically be xored with the product -// of the above by virture of the cfAutoXOR feature. -FCounter^ := FCounter^ + 1 -end; - - - - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CTR; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TCTR = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TCTRLink = class( TBlockChainLink) + private + FCounter: PInt64; + + protected + constructor Create( + Key1: TSymetricKey; // Will be referenced, not cloned. + IV1: TMemoryStream; // Will be cloned. + Cipher1: IBlockCodec); // Will be referenced, not cloned. + + public + function Clone: TBlockChainLink; override; + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + + + +uses TPLB3.Constants, TPLB3.I18n; + +{ TCTR } + +function TCTR.ChainingFeatures: TChainingFeatureSet; +begin +result := [cfKeyStream, cfAutoXOR] +end; + + + +function TCTR.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCTRLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TCTR.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TCTRLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TCTR.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.5' +end; + +function TCTR.DisplayName: string; +begin +result := 'CTR' +end; + + + +function TCTR.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + + +function TCTR.ProgId: string; +begin +result := CTR_ProgId +end; + + + + + +function TCTR.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Counter_.28CTR.29' +end; + +{ TCTRLink } + +function TCTRLink.Clone: TBlockChainLink; +begin +result := inherited Clone; +TCTRLink(result).FCounter := TCTRLink(result).FCV.Memory +end; + + +constructor TCTRLink.Create( + Key1: TSymetricKey; IV1: TMemoryStream; + Cipher1: IBlockCodec); +begin +BaseCreate( Key1, IV1, Cipher1); +FCounter := FCV.Memory +end; + + +procedure TCTRLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Ciphertext); +// The plaintext block will automatically be xored with the product +// of the above by virture of the cfAutoXOR feature. +FCounter^ := FCounter^ + 1 +end; + +procedure TCTRLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Plaintext); +// The ciphertext block will automatically be xored with the product +// of the above by virture of the cfAutoXOR feature. +FCounter^ := FCounter^ + 1 +end; + + + + +end. + diff --git a/run/TPLB3.CipherUtils.pas b/LockBox3/run/TPLB3.CipherUtils.pas similarity index 96% rename from run/TPLB3.CipherUtils.pas rename to LockBox3/run/TPLB3.CipherUtils.pas index 287d4cd..4dc9191 100644 --- a/run/TPLB3.CipherUtils.pas +++ b/LockBox3/run/TPLB3.CipherUtils.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,57 +12,57 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CipherUtils; -interface -uses Classes, TPLB3.StreamCipher; - - -type -TDummyKey = class( TSymetricKey) - public - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - -implementation - - - - - - - - - - - - -{ TDummyKey } - -procedure TDummyKey.Burn; -begin -end; - -procedure TDummyKey.SaveToStream( Stream: TStream); -begin -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CipherUtils; +interface +uses Classes, TPLB3.StreamCipher; + + +type +TDummyKey = class( TSymetricKey) + public + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + +implementation + + + + + + + + + + + + +{ TDummyKey } + +procedure TDummyKey.Burn; +begin +end; + +procedure TDummyKey.SaveToStream( Stream: TStream); +begin +end; + +end. diff --git a/run/TPLB3.Codec.pas b/LockBox3/run/TPLB3.Codec.pas similarity index 95% rename from run/TPLB3.Codec.pas rename to LockBox3/run/TPLB3.Codec.pas index 09a956d..59e6032 100644 --- a/run/TPLB3.Codec.pas +++ b/LockBox3/run/TPLB3.Codec.pas @@ -1,2173 +1,2166 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Codec; -interface -uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, TPLB3.Asymetric, - TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, TPLB3.CodecIntf, - TPLB3.HashDsc, TPLB3.Hash, TPLB3.StreamUtils; - - -type -/// -/// Please remember to invoke TRandomStream.Instance.Randomize() at program start-up! -/// -TSimpleCodec = class( TInterfacedPersistent, ICodec, IBlockCipherSelector, - IBlockCipherSelectorEx2, IEventOrigin, ICodec_WithAsymetricSupport) - private - FMode: TCodecMode; - FStreamCipher: IStreamCipher; - FParameterizedStreamCipher: IStreamCipher; - FBlockCipher : IBlockCipher; - FChainMode : IBlockChainingModel; - FOnProgress : TOnEncDecProgress; - FSender: TObject; - - FKey: TSymetricKey; - FEnc: IStreamEncryptor; - FDec: IStreamDecryptor; - FPasswordHasher: IHash; - FPasswordHasherObject: TObject; // TSimpleHash - FXtextCount: int64; - FisUserAborted: boolean; - FOutput: TStream; - FBuffer: TMemoryStream; - FDesalination: TDesalinationWriteStream; - FisSalting: boolean; - - FAsymetricKeySizeInBits: cardinal; - FAsymGenProgressEvent : TGenerateAsymetricKeyPairProgress; - FCompOwner: TComponent; - FAdvancedOptions2 : TSymetricEncryptionOptionSet; - FOnSetIV: TSetMemStreamProc; - - procedure SetStreamCipher( const Value: IStreamCipher); - procedure SetBlockCipher ( const Value: IBlockCipher); - procedure SetChainMode ( const Value: IBlockChainingModel); - function GetMode: TCodecMode; - function GetStreamCipher: IStreamCipher; - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - function GetOnProgress : TOnEncDecProgress; - procedure SetOnProgress( Value: TOnEncDecProgress); - procedure SetEventSender( Sender: TObject); - function isNotBase64Converter: boolean; - function GetAsymetricKeySizeInBits: cardinal; - procedure SetAsymetricKeySizeInBits( value: cardinal); - function GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; - procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress); - function GetKey: TSymetricKey; - function Asymetric_Engine: IAsymetric_Engine; - procedure End_EncryptDecrypt; - procedure DoProgress; - procedure InitCheck; - function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; - procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); - function hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; - function GetOnSetIV: TSetMemStreamProc; - procedure SetOnSetIV( Value: TSetMemStreamProc); - - public - constructor Create; - destructor Destroy; override; - - procedure Init( const Key: string); overload; -{$IFDEF UNICODE} - procedure Init( const Key: string; Encoding: TEncoding); overload; - procedure InitA( const Key: string); -{$ENDIF} - procedure SaveKeyToStream( Store: TStream); - procedure InitFromStream( Store: TStream); - procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. - procedure Reset; - procedure Burn( doIncludeBurnKey: boolean); - - function isAsymetric: boolean; - procedure InitFromGeneratedAsymetricKeyPair; - - procedure Sign( - Document, Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean); - - function VerifySignature( - Document, Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean): boolean; - - procedure Begin_EncryptMemory( CipherText{out}: TStream); - procedure EncryptMemory( const Plaintext; PlaintextLen: integer); - procedure End_EncryptMemory; - - procedure Begin_DecryptMemory( Plaintext{out}: TStream); - procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); - procedure End_DecryptMemory; - - procedure EncryptStream( Plaintext, CipherText: TStream); - procedure DecryptStream( Plaintext, CipherText: TStream); - - procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); - procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); - - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; - -{$IFDEF UNICODE} - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; - - procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; - - procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; -{$ENDIF} - - function GetAborted: boolean; - procedure SetAborted( Value: boolean); - function GetCipherDisplayName( Lib: TCryptographicLibrary): string; - - property Mode: TCodecMode read GetMode; - property StreamCipher: IStreamCipher read GetStreamCipher write SetStreamCipher; - property BlockCipher : IBlockCipher read GetBlockCipher write SetBlockCipher; - property ChainMode : IBlockChainingModel read GetChainMode write SetChainMode; - property AdvancedOptions2: TSymetricEncryptionOptionSet read GetAdvancedOptions2 write SetAdvancedOptions2; - property OnProgress : TOnEncDecProgress read GetonProgress write SetOnProgress; - end; - - - - - - -ICodec_TestAccess = interface - // This method is ONLY to be used by unit test programs. - ['{1DCED340-E6C0-4B97-BBAA-98305B5D4F5E}'] - function GetCodecIntf: ICodec; - end; - - -/// -/// Please remember to invoke TRandomStream.Instance.Randomize() at program start-up! -/// -[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidAndroid)] -TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher, - ICodec_TestAccess) -{$IF CompilerVersion >= 17.0} - strict private -{$ELSE} - private -{$IFEND} - FPassword: string; -{$IFDEF UNICODE} - FUTF8Password: string; -{$ENDIF} - - private - FCodecObj: TSimpleCodec; - FCodec : ICodec; - FLib: TCryptographicLibrary; - FStreamCipherId: string; - FBlockCipherId: string; - FChainId: string; - FIntfCached: boolean; - FCountBytes: int64; - FWorkLoad: int64; - FDuration: TDateTime; - FStartTime: TDateTime; - - procedure SetLib( Value: TCryptographicLibrary); - procedure Dummy( const Value: string); - procedure SetStreamCipherId( const Value: string); - procedure SetBlockCipherId( const Value: string); - procedure SetChainId( const Value: string); - procedure SetIntfCached( Value: boolean); - procedure ReadData_Stream( Reader: TReader); - procedure WriteData_Stream( Writer: TWriter); - procedure ReadData_Block( Reader: TReader); - procedure WriteData_Block( Writer: TWriter); - procedure ReadData_Chain( Reader: TReader); - procedure WriteData_Chain( Writer: TWriter); - function GetMode: TCodecMode; - function GetOnProgress: TOnHashProgress; - procedure SetOnProgress(const Value: TOnHashProgress); - procedure ProgIdsChanged; - function GetCodecIntf: ICodec; - procedure SetPassword( const NewPassword: string); -{$IFDEF UNICODE} - procedure SetUTF8Password( const NewPassword: string); -{$ENDIF} - procedure GenerateAsymetricKeyPairProgress_Event( - Sender: TObject; CountPrimalityTests: integer; - var doAbort: boolean); - function GetAsymetricKeySizeInBits: cardinal; - procedure SetAsymetricKeySizeInBits( value: cardinal); - function GetKey: TSymetricKey; - procedure BeginEncDec; - procedure EndEncDec; - procedure ClearPassword; -{$IFDEF UNICODE} - procedure ClearUTF8Password; -{$ENDIF} - function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; - procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); - function GetOnSetIV: TSetMemStreamProc; - Procedure SetOnSetIV( Value: TSetMemStreamProc); - - protected - procedure Notification( - AComponent: TComponent; Operation: TOperation); override; - procedure DefineProperties( Filer: TFiler); override; - function GetCipherDisplayName: string; virtual; - function GetChainDisplayName: string; virtual; - procedure Loaded; override; - - property InterfacesAreCached: boolean read FIntfCached write SetIntfCached; - - public - - FGenerateAsymetricKeyPairProgress_CountPrimalityTests: integer; - - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - - procedure Burn; - procedure Reset; - procedure SaveKeyToStream( Store: TStream); - procedure InitFromStream( Store: TStream); - - function GetAborted: boolean; - procedure SetAborted( Value: boolean); - - function isAsymetric: boolean; - function Asymetric_Engine: IAsymetric_Engine; - procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. - procedure InitFromGeneratedAsymetricKeyPair; - - procedure Begin_EncryptMemory( CipherText{out}: TStream); - procedure EncryptMemory( const Plaintext; PlaintextLen: integer); - procedure End_EncryptMemory; - - procedure Begin_DecryptMemory( Plaintext{out}: TStream); - procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); - procedure End_DecryptMemory; - - procedure EncryptStream( Plaintext, CipherText: TStream); - procedure DecryptStream( Plaintext, CipherText: TStream); - - procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); - procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); - - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; - -{$IFDEF UNICODE} - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; - - procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; - - procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; -{$ENDIF} - - function Speed: integer; // In KiB per second. Set to -1 for indeterminant. - - property Key: TSymetricKey read GetKey; - property StreamCipherId: string read FStreamCipherId write SetStreamCipherId; - property BlockCipherId: string read FBlockCipherId write SetBlockCipherId; - property ChainModeId: string read FChainId write SetChainId; - property Password: string read FPassword write SetPassword; -{$IFDEF UNICODE} - property UTF8Password: string read FUTF8Password write SetUTF8Password; -{$ENDIF} - property Mode: TCodecMode read GetMode; - property isUserAborted: boolean read GetAborted write SetAborted; - - property CountBytesProcessed: int64 read FCountBytes write FCountBytes; - property EstimatedWorkLoad : int64 read FWorkLoad write FWorkLoad; - property Duration : TDateTime read FDuration write FDuration; - - published - property Cipher: string read GetCipherDisplayName write Dummy stored False; - property ChainMode: string read GetChainDisplayName write Dummy stored False; - property AsymetricKeySizeInBits: cardinal read GetAsymetricKeySizeInBits - write SetAsymetricKeySizeInBits; - - property AdvancedOptions2: TSymetricEncryptionOptionSet read GetAdvancedOptions2 write SetAdvancedOptions2; - property CryptoLibrary: TCryptographicLibrary read FLib write SetLib; - property OnProgress : TOnHashProgress read GetOnProgress write SetOnProgress; - property OnSetIV: TSetMemStreamProc read GetOnSetIV write SetOnSetIV; - - end; - - - - - - - -implementation - - - - - - -uses Math, TPLB3.SHA1, TPLB3.ECB, TPLB3.Random, TPLB3.Decorators, - TPLB3.BinaryUtils, TPLB3.I18n -{$IF CompilerVersion >= 21} - , Rtti -{$IFEND} - ; - - - -const - SaltSize = 8; // 8 bytes or 64 bits of entropy to be injected. - Default_AsymetricKeySizeInBits = 1024; -{ TSimpleCodec } - -constructor TSimpleCodec.Create; -begin -FMode := cmUnitialized; -FStreamCipher := nil; -FParameterizedStreamCipher := nil; -FBlockCipher := nil; -FChainMode := nil; -FOnProgress := nil; -FKey := nil; -FEnc := nil; -FDec := nil; -FPasswordHasherObject := TSimpleHash.Create; -Supports( FPasswordHasherObject, IHash, FPasswordHasher); -FPasswordHasher.Hash := TSHA1.Create; -FisUserAborted := False; -FXtextCount := 0; -FOutput := nil; -FBuffer := TMemoryStream.Create; -FSender := self; -FDesalination := TDesalinationWriteStream.Create; -FisSalting := False; -FAsymetricKeySizeInBits := Default_AsymetricKeySizeInBits; -FAsymGenProgressEvent := nil -end; - - -destructor TSimpleCodec.Destroy; -begin -Burn( True); -FPasswordHasher := nil; -FPasswordHasherObject.Free; -FKey.Free; -FBuffer.Free; -FDesalination.Free; -inherited; -end; - - - -procedure TSimpleCodec.DoProgress; -begin -if FisUserAborted then exit; -if assigned( FCompOwner) and (FCompOwner is TCodec) then - TCodec( FCompOwner).FCountBytes := FXtextCount; -FisUserAborted := assigned( FOnProgress) and - (not FOnProgress( FSender, FXtextCount)) -end; - - - - -function TSimpleCodec.isAsymetric: boolean; -begin -if assigned( FStreamCipher) and (not assigned( FParameterizedStreamCipher)) then - begin - FParameterizedStreamCipher := FStreamCipher.Parameterize( self); - if not assigned( FParameterizedStreamCipher) then - FParameterizedStreamCipher := FStreamCipher - end; -result := assigned( FParameterizedStreamCipher) and - (afAsymetric in FParameterizedStreamCipher.Features) and - Supports( FParameterizedStreamCipher, IAsymetric_Engine) -end; - - - - -function TSimpleCodec.Asymetric_Engine: IAsymetric_Engine; -begin -result := nil; -if isAsymetric then - Supports( FParameterizedStreamCipher, IAsymetric_Engine, result) -end; - - - -function isVariableSeedSize( - const Cipher: IStreamCipher; var MinSize, MaxSize: integer): boolean; -// For Delphi 2010 and beyound, look for an IntegerRange range attribute -// on the SeedByteSize method. -// For older compilers, test for the IVariableSeedSize interface. -var - ControlObject: IControlObject; - Controller: TObject; - -{$IF compilerversion >= 21} - LContext: TRttiContext; - LType: TRttiType; - Meth: TRttiMethod; - Attr: TCustomAttribute; - IntRange: IntegerRange; -{$ELSE} - VariableSeedSize: IVariableSeedSize; -{$IFEND} - -begin -result := False; -Supports( Cipher, IControlObject, ControlObject); -if assigned( ControlObject) then - Controller := ControlObject.ControlObject - else - Controller := nil; -if not assigned( Controller) then exit; - -{$IF compilerversion >= 21} -IntRange := nil; -LContext := TRttiContext.Create; -try -LType := LContext.GetType( Controller.ClassType); -for Meth in LType.GetDeclaredMethods do - begin - if not SameText( Meth.Name, 'SeedByteSize') then continue; - for Attr in Meth.GetAttributes do - begin - if not (Attr is IntegerRange) then continue; - IntRange := IntegerRange( Attr); - break - end; - break - end; -result := assigned( IntRange); -if result then - begin - MinSize := IntRange.Min; - MaxSize := IntRange.Max - end -finally -LContext.Free -end -{$ELSE} - -result := Supports( Controller, IVariableSeedSize, VariableSeedSize); -if result then - begin - MinSize := VariableSeedSize.Min; - MaxSize := VariableSeedSize.Max - end -{$IFEND} -end; - - - -function ConstraintWithinRange( - Instrinsic, LowerBound, UpperBound: integer): integer; -// Find a value close to Instrinsic but within specified bounds. -begin -result := Instrinsic; -if result > UpperBound then - result := UpperBound - else if result < LowerBound then - result := LowerBound -end; - - -function CalculateOutputSeedSize( - const Cipher: IStreamCipher; - InputSeedSize: integer; var MinSize, MaxSize: integer) : integer; -// Calculate a convenient key seed size for the Cipher -// partly based on what resources we have. -begin -MinSize := 0; -MaxSize := 0; -result := Cipher.SeedByteSize; -if result = -1 then exit; -if isVariableSeedSize( Cipher, MinSize, MaxSize) then - result := ConstraintWithinRange( InputSeedSize, MinSize, MaxSize) - else - begin - MinSize := result; - MaxSize := result - end -end; - - - -procedure SpreadHashIntoBuffer( - Buffer: TMemoryStream; - const PasswordHasher: IHash; - MinSize, MaxSize, OutputSeedSize: integer); -// Used by the Init method to transfer the key seed data from -// the Hasher to a Buffer, and make sure it is a convenient size. -var - L, Diff, Amt: integer; -begin -Buffer.Size := 0; -Buffer.CopyFrom( PasswordHasher.HashOutputValue, 0); -PasswordHasher.Burn; -L := Buffer.Size; -if L = 0 then - raise Exception.Create( ES_HashFailed); -OutputSeedSize := ConstraintWithinRange( L, MinSize, MaxSize); -Diff := L - OutputSeedSize; -if Diff > 0 then - // Truncate - Buffer.Size := OutputSeedSize - - else if Diff < 0 then - begin // Extend by repetition. - Buffer.Seek( 0, soEnd); - Diff := - Diff; - repeat - Amt := Min( Diff, L); - Buffer.Write( Buffer.Memory^, Amt); - Dec( Diff, Amt) - until Diff <= 0 - end -end; - - -procedure TSimpleCodec.InitCheck; -begin -if FMode in [cmEncrypting, cmDecrypting] then - Reset; -FMode := cmUnitialized; -FXtextCount := 0; -FreeAndNil( FKey); -FisUserAborted := False; -if isAsymetric then - raise Exception.Create( ES_AsymPassword); -FEnc := nil; FDec := nil; -FisUserAborted := False; -end; - - - -procedure TSimpleCodec.Init( const Key: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -var - {$IFDEF UNICODE}KeyBytes: TBytes;{$ENDIF} - InputSeedSize, OutputSeedSize: integer; - MinSize, MaxSize: integer; -begin -if Key = '' then - raise Exception.Create( ES_NoPassword); -InitCheck; -// The key is based on a hash of the Key string for symetric ciphers. -try - {$IFDEF UNICODE} - KeyBytes := Encoding.GetBytes( Key); - InputSeedSize := Length( KeyBytes); - {$ELSE} - InputSeedSize := Length( Key) * SizeOf( Char); - {$ENDIF} - OutputSeedSize := CalculateOutputSeedSize( - FParameterizedStreamCipher, InputSeedSize, MinSize, MaxSize); - if OutputSeedSize = -1 then - // A SeedByteSize of -1 means that the seed (FBuffer) is irrelevant. - // This might be so in non-encryption type transformations. - FBuffer.Clear - else - begin - if InputSeedSize = OutputSeedSize then - begin - // No hash. The key seed is just perfect size. Just use it. - FBuffer.Size := InputSeedSize; - if InputSeedSize > 0 then - Move( {$IFDEF UNICODE}KeyBytes[0]{$ELSE}Key[1]{$ENDIF}, FBuffer.Memory^, InputSeedSize) - end - else - begin - {$IFDEF UNICODE} - FPasswordHasher.HashBytes( KeyBytes); - {$ELSE} - FPasswordHasher.HashString( Key); - {$ENDIF} - SpreadHashIntoBuffer( - FBuffer, FPasswordHasher, MinSize, MaxSize, OutputSeedSize) - end; - FBuffer.Position := 0 - end; - FKey := FParameterizedStreamCipher.GenerateKey( FBuffer) -finally - FPasswordHasher.Burn; - BurnMemoryStream( FBuffer) - end; -if FisUserAborted then - FMode := cmUnitialized - else - FMode := cmIdle; -FisSalting := False -end; - - - -{$IFDEF UNICODE} -procedure TSimpleCodec.Init( const Key: string); -begin - Init( Key, TEncoding.Unicode); -end; -{$ENDIF} - - - -{$IFDEF UNICODE} -procedure TSimpleCodec.InitA( const Key: string); -begin - Init( Key, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure TSimpleCodec.InitFromKey( Key: TSymetricKey); -begin -if FMode in [cmEncrypting, cmDecrypting] then - Reset; -FMode := cmUnitialized; -FXtextCount := 0; -FreeAndNil( FKey); -FisUserAborted := False; -if not assigned( FParameterizedStreamCipher) then - begin - FParameterizedStreamCipher := FStreamCipher.Parameterize( self); - if not assigned( FParameterizedStreamCipher) then - FParameterizedStreamCipher := FStreamCipher - end; -FEnc := nil; FDec := nil; -FKey := Key; // Ownership xferred. -FMode := cmIdle; -FisSalting := False -end; - - - -procedure TSimpleCodec.InitFromStream( Store: TStream); -begin -if FMode in [cmEncrypting, cmDecrypting] then - Reset; -FMode := cmUnitialized; -FXtextCount := 0; -FreeAndNil( FKey); -FisUserAborted := False; -if not assigned( FParameterizedStreamCipher) then - begin - FParameterizedStreamCipher := FStreamCipher.Parameterize( self); - if not assigned( FParameterizedStreamCipher) then - FParameterizedStreamCipher := FStreamCipher - end; -FEnc := nil; FDec := nil; -FKey := FParameterizedStreamCipher.LoadKeyFromStream( Store); -FMode := cmIdle; -FisSalting := False -end; - - -function TSimpleCodec.isNotBase64Converter: boolean; -begin -result := not Supports( FStreamCipher, IisBase64Converter) -end; - -function TSimpleCodec.GetAborted: boolean; -begin -result := FisUserAborted -end; - - -function TSimpleCodec.GetAdvancedOptions2: TSymetricEncryptionOptionSet; -begin -result := FAdvancedOptions2 -end; - -procedure TSimpleCodec.SetAborted( Value: boolean); -begin -FisUserAborted := Value -end; - - -procedure TSimpleCodec.SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); -begin -if FAdvancedOptions2 = Value then exit; -if not (FMode in [cmUnitialized, cmIdle]) then - raise Exception.Create( ES_Asym_CannotSetCipher); - -if Value <> [] then - raise Exception.Create( 'Advanced options are still in development and not yet available'#13#10 + - 'They should be available in the next release'#13#10 + - 'Please watch the shout-box on the LockBox home website for'#13#10 + - 'breaking news.'); - -FAdvancedOptions2 := Value; -FParameterizedStreamCipher := nil -end; - - -procedure TSimpleCodec.End_EncryptDecrypt; -begin -if assigned( FEnc) then - FEnc.Reset; // Alternative would be to release FEnc. -if assigned( FDec) then - FDec.Reset; -FMode := cmIdle; -FBuffer.Size := 0; -FisSalting := False; -FParameterizedStreamCipher := nil -end; - - -procedure TSimpleCodec.Reset; -begin -if FMode = cmUnitialized then - raise Exception.Create( ES_WrongModeReset); -End_EncryptDecrypt; -FXtextCount := 0; -FisUserAborted := False -end; - - -procedure TSimpleCodec.Begin_EncryptMemory( CipherText{out}: TStream); -begin -if FMode <> cmIdle then - raise Exception.Create( ES_WrongModeEncrypt); - -// Require: -// 1. assigned( FStreamCipher) -// 2. NOT afNotImplementedYet in FStreamCipher.Features; -// 3. if afBlockAdapter in FStreamCipher.Features then -// 3.1 assigned( FBlockCipher) -// 3.2 NOT afNotImplementedYet in FBlockCipher.Features; -// 3.3 assigned( FChainMode) -// 3.4 NOT afNotImplementedYet in FChainMode.Features; - -if (not assigned( FStreamCipher)) or - (afNotImplementedYet in FStreamCipher.Features) or - - ((afBlockAdapter in FStreamCipher.Features) and ( - (not assigned( FBlockCipher)) or - (afNotImplementedYet in FBlockCipher.Features) or - (not assigned( FChainMode)) or - (afNotImplementedYet in FChainMode.Features) - )) then - raise Exception.Create( ES_EncryptNoAlg); - -if not assigned( FParameterizedStreamCipher) then - begin - FParameterizedStreamCipher := FStreamCipher.Parameterize( self); - if not assigned( FParameterizedStreamCipher) then - FParameterizedStreamCipher := FStreamCipher; - FEnc := nil - end; - -FDec := nil; -if (not assigned( FEnc)) or (FOutput <> Ciphertext) then - begin - FEnc := nil; - FOutput := Ciphertext; - FEnc := FParameterizedStreamCipher.Start_Encrypt( FKey, FOutput) - end - else - FEnc.Reset; - -FMode := cmEncrypting; -FXtextCount := 0; -FisSalting := False; -FisUserAborted := False; -end; - - -procedure TSimpleCodec.Begin_DecryptMemory( Plaintext{out}: TStream); -var - useDesalination: boolean; - FinalOutput: TStream; -begin -if FMode <> cmIdle then - raise Exception.Create( ES_WrongModeDecrypt); -if (not assigned( FStreamCipher)) or - (afNotImplementedYet in FStreamCipher.Features) or - - ((afBlockAdapter in FStreamCipher.Features) and ( - (not assigned( FBlockCipher)) or - (afNotImplementedYet in FBlockCipher.Features) or - (not assigned( FChainMode)) or - (afNotImplementedYet in FChainMode.Features) - )) then - raise Exception.Create( ES_DecryptNoAlg); - -if not assigned( FParameterizedStreamCipher) then - begin - FParameterizedStreamCipher := FStreamCipher.Parameterize( self); - if not assigned( FParameterizedStreamCipher) then - FParameterizedStreamCipher := FStreamCipher; - FDec := nil - end; - -useDesalination := ([afCompressor, afConverter, afDoesNotNeedSalt] * - FParameterizedStreamCipher.Features) = []; - -if useDesalination then - FinalOutput := FDesalination.FreshwaterStream - else - FinalOutput := FOutput; - -FEnc := nil; -if (not assigned( FDec)) or (FinalOutput <> Plaintext) then - begin - FDec := nil; - FOutput := Plaintext; - if useDesalination then - begin - FDesalination.FreshwaterStream := FOutput; - FOutput := FDesalination; - FDesalination.SaltVolume := SaltSize - end; - FDec := FParameterizedStreamCipher.Start_Decrypt( FKey, FOutput) - end - else - FDec.Reset; - -FMode := cmDecrypting; -FXtextCount := 0; -FisUserAborted := False; -end; - - -procedure TSimpleCodec.Burn( doIncludeBurnKey: boolean); -begin -if assigned( FKey) and (not doIncludeBurnKey) and (FMode <> cmUnitialized) then - FMode := cmIdle - else - begin - FMode := cmUnitialized; - if assigned( FKey) then - begin - FKey.Burn; - FreeAndNil( FKey) - end - end; -FParameterizedStreamCipher := nil; -FEnc := nil; -FDec := nil; -FPasswordHasher.Burn; -FXtextCount := 0; -FisUserAborted := False; -BurnMemoryStream( FBuffer); -if FOutput = FDesalination then - begin - FDesalination.FreshwaterStream := nil; - FDesalination.SaltVolume := SaltSize - end; -FOutput := nil; -FisSalting := False -end; - - -{$IFDEF UNICODE} -procedure TSimpleCodec.DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - -{$IFDEF UNICODE} -procedure TSimpleCodec.DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); -end; -{$ENDIF} - - -const FileStreamOpenMode: array[ boolean ] of word = ( - {False, Not exists} fmCreate, {True, exists} fmOpenReadWrite); - - -procedure TSimpleCodec.DecryptFile( - const Plaintext_FileName, - CipherText_FileName: string); -var - Plaintext, ciphertext: TStream; - isPreExists: boolean; -begin -isPreExists := FileExists( Plaintext_FileName); -plaintext := TFileStream.Create( Plaintext_FileName, FileStreamOpenMode[ isPreExists]); -try - Ciphertext := TFileStream.Create( Ciphertext_FileName, fmOpenRead); - try - if isPreExists then - Plaintext.Size := 0; - DecryptStream( plaintext, ciphertext) - finally - CipherText.Free - end -finally - PlainText.Free; -end end; - - - - -procedure TSimpleCodec.DecryptStream( Plaintext, CipherText: TStream); -var - Temp: TMemoryStream; - BytesRead, Amnt: integer; -begin -Temp := TMemoryStream.Create; -try - Ciphertext.Position := 0; - Amnt := Max( Min( CipherText.Size, 1024), 1); - Temp.Size := Amnt; - Begin_DecryptMemory( PlainText); - repeat - if Temp.Size > Amnt then - BurnMemoryStream( Temp); - if Temp.Size <> Amnt then - Temp.Size := Amnt; - BytesRead := Ciphertext.Read( Temp.Memory^, Amnt); - if BytesRead = 0 then break; - DecryptMemory( Temp.Memory^, BytesRead); - DoProgress - until (BytesRead < Amnt) or FisUserAborted; - End_DecryptMemory -finally - BurnMemoryStream( Temp); - Temp.Free -end end; - - -procedure TSimpleCodec.DecryptString( - var Plaintext: string; - const CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -var - Temp, Ciphertext: TMemoryStream; - L: integer; -begin -Temp := TMemoryStream.Create; -Ciphertext := TMemoryStream.Create; -try - if isNotBase64Converter then - Base64_to_stream( CipherText_Base64, Ciphertext) - else - // If its already a Base64 encoder, no point in double-encoding it as base64. - String_to_stream( CipherText_Base64, Ciphertext{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); - Begin_DecryptMemory( Temp); - L := Ciphertext.Size; - if L > 0 then - DecryptMemory( Ciphertext.Memory^, L); - End_DecryptMemory; - if FisUserAborted then - SetLength( Plaintext, 0) - else - begin - Temp.Position := 0; - Plaintext := Stream_to_string( Temp{$IFDEF UNICODE}, Encoding{$ENDIF}); - end -finally - BurnMemoryStream( Temp); - BurnMemoryStream( Ciphertext); - Temp.Free; - Ciphertext.Free -end end; - - -{$IFDEF UNICODE} -procedure TSimpleCodec.DecryptString( - var Plaintext: string; - const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - -{$IFDEF UNICODE} -procedure TSimpleCodec.EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -{$IFDEF UNICODE} -procedure TSimpleCodec.EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); -end; -{$ENDIF} - - - -procedure TSimpleCodec.EncryptFile( - const Plaintext_FileName, - CipherText_FileName: string); -var - plaintext, ciphertext: TStream; - isPreExists: boolean; -begin -if Plaintext_FileName = '' then - raise Exception.Create( ES_PlaintextFN_Empty); -if Ciphertext_FileName = '' then - raise Exception.Create( ES_CiphertextFN_Empty); -plaintext := TFileStream.Create( Plaintext_FileName, fmOpenRead); -try - isPreExists := FileExists( Ciphertext_FileName); - Ciphertext := TFileStream.Create( - Ciphertext_FileName, FileStreamOpenMode[ isPreExists]); - try - if isPreExists then - Ciphertext.Size := 0; - EncryptStream( plaintext, ciphertext) - finally - CipherText.Free - end -finally - PlainText.Free - end -end; - - - -procedure TSimpleCodec.EncryptMemory( - const Plaintext; PlaintextLen: integer); -var - P: PByte; - L, Amt: integer; - Salt: packed array[ 0..SaltSize-1 ] of byte; -begin -if FisUserAborted then exit; -if FMode <> cmEncrypting then - raise Exception.Create( ES_WrongModeEncryptMem); -P := @Plaintext; -L := PlaintextLen; -if (FXtextCount = 0) and (L > 0) and (not FisSalting) and - (([afCompressor, afConverter, afDoesNotNeedSalt] * - FParameterizedStreamCipher.Features) = []) then - begin - FisSalting := True; - TRandomStream.Instance.Read( Salt, SaltSize); - EncryptMemory( Salt, SaltSize); - FisSalting := False - end; -try -// Break up the plaintext memory into at most 1 KiB chunks. -while (L > 0) and (not FisUserAborted) do - begin - Amt := Min( L, 1024); - if FBuffer.Size > Amt then - BurnMemoryStream( FBuffer); - if FBuffer.Size <> Amt then - FBuffer.Size := Amt; - Move( P^, FBuffer.Memory^, Amt); - FBuffer.Position := 0; - // Encrypt the chunk. - FEnc.Encrypt( FBuffer); - Dec( L, Amt); - Inc( P, Amt); - Inc( FXtextCount, Amt); - // Check for user abort. - if (L > 0) and (not FisSalting) then - DoProgress - end -finally -BurnMemoryStream( FBuffer) -end end; - - -procedure TSimpleCodec.DecryptMemory( - const CipherText{in}; CiphertextLen: integer); -var - P: PByte; - L, Amt: integer; -begin -if FisUserAborted then exit; -if FMode <> cmDecrypting then - raise Exception.Create( ES_WrongModeDecryptMem); -P := @CipherText; -L := CiphertextLen; -try -while (L > 0) and (not FisUserAborted) do - begin - Amt := Min( L, 1024); - if FBuffer.Size > Amt then - BurnMemoryStream( FBuffer); - if FBuffer.Size <> Amt then - FBuffer.Size := Amt; - Move( P^, FBuffer.Memory^, Amt); - FBuffer.Position := 0; - FDec.Decrypt( FBuffer); - Dec( L, Amt); - Inc( P, Amt); - Inc( FXtextCount, Amt); - if L > 0 then - DoProgress - end -finally -BurnMemoryStream( FBuffer) -end end; - - - -procedure TSimpleCodec.EncryptStream( Plaintext, CipherText: TStream); -var - Temp: TMemoryStream; - Amnt, BytesRead: integer; -begin -Temp := TMemoryStream.Create; -try - // Break up stream into at most 1 KiB blocks, but don't needlessly - // oversize the buffer. - Plaintext.Position := 0; - Amnt := Max( Min( PlainText.Size, 1024), 1); - Temp.Size := Amnt; - Begin_EncryptMemory( CipherText); - repeat - if Temp.Size > Amnt then - BurnMemoryStream( Temp); - if Temp.Size <> Amnt then - Temp.Size := Amnt; - BytesRead := PlainText.Read( Temp.Memory^, Amnt); - if BytesRead = 0 then break; - EncryptMemory( Temp.Memory^, BytesRead); - DoProgress - until (BytesRead < Amnt) or FisUserAborted; - End_EncryptMemory -finally - BurnMemoryStream( Temp); - Temp.Free -end end; - - -procedure TSimpleCodec.EncryptString( - const Plaintext: string; - var CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -var - L: integer; - {$IFDEF UNICODE}PlaintextBytes: TBytes;{$ENDIF} - Temp: TMemoryStream; -begin -Temp := TMemoryStream.Create; -try - Begin_EncryptMemory( Temp); - {$IFDEF UNICODE} - PlaintextBytes := Encoding.GetBytes( Plaintext); - L := Length( PlaintextBytes); - {$ELSE} - L := Length( Plaintext) * SizeOf( Char); - {$ENDIF} - EncryptMemory( {$IFDEF UNICODE}PlaintextBytes[0]{$ELSE}Plaintext[1]{$ENDIF}, L); - End_EncryptMemory; - if FisUserAborted then - CipherText_Base64 := '' - else - begin - Temp.Position := 0; - if isNotBase64Converter then - CipherText_Base64 := Stream_to_Base64( Temp) - else - // If its already a Base64 encoder, no point in double-encoding it as base64. - CipherText_Base64 := Stream_to_string( Temp{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}) - end -finally - Temp.Free -end end; - - - -{$IFDEF UNICODE} -procedure TSimpleCodec.EncryptString( - const Plaintext: string; - var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure TSimpleCodec.End_DecryptMemory; -begin -case FMode of - cmIdle: begin end; - - cmDecrypting: begin - if not FisUserAborted then - begin - if assigned( FDec) then - FDec.End_Decrypt; - DoProgress; - Reset - end - else - End_EncryptDecrypt - end; - - cmUnitialized, - cmEncrypting: - raise Exception.Create( ES_WrongModeEndDecryptMem); - end -end; - - -procedure TSimpleCodec.End_EncryptMemory; -begin -case FMode of - cmIdle: begin end; - - cmEncrypting: begin - if not FisUserAborted then - begin - if assigned( FEnc) then - FEnc.End_Encrypt; - DoProgress; - Reset - end - else - End_EncryptDecrypt - end; - - cmUnitialized, - cmDecrypting: - raise Exception.Create( ES_WrongModeEndEncryptMem); - end -end; - - - -function TSimpleCodec.GetAsymetricKeySizeInBits: cardinal; -begin -result := FAsymetricKeySizeInBits -end; - -function TSimpleCodec.GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; -begin -result := FAsymGenProgressEvent -end; - -function TSimpleCodec.GetBlockCipher: IBlockCipher; -begin -result := FBlockCipher -end; - -function TSimpleCodec.GetChainMode: IBlockChainingModel; -begin -result := FChainMode -end; - -function TSimpleCodec.GetCipherDisplayName( Lib: TCryptographicLibrary): string; -var - TempCipher: IStreamCipher; -begin -TempCipher := FParameterizedStreamCipher; -if not assigned( TempCipher) and assigned( FStreamCipher) then - TempCipher := FStreamCipher.Parameterize( self); -if not assigned( TempCipher) then - TempCipher := FStreamCipher; -if assigned( TempCipher) then - begin - if assigned( Lib) then - result := Lib.ComputeCipherDisplayName( TempCipher, FBlockCipher) - else - result := TCryptographicLibrary.ComputeCipherDisplayName( TempCipher, FBlockCipher) - end - else - result := '' -end; - - -function TSimpleCodec.GetKey: TSymetricKey; -begin -result := FKey -end; - -function TSimpleCodec.GetMode: TCodecMode; -begin -result := FMode -end; - -function TSimpleCodec.GetOnProgress: TOnEncDecProgress; -begin -result := FOnProgress -end; - - -function TSimpleCodec.GetOnSetIV: TSetMemStreamProc; -begin -result := FOnSetIV -end; - -function TSimpleCodec.GetStreamCipher: IStreamCipher; -begin -result := FStreamCipher -end; - - -function TSimpleCodec.hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; -begin - Proc := FOnSetIV; - result := assigned( FOnSetIV) -end; - - - -procedure TSimpleCodec.SaveKeyToStream( Store: TStream); -begin -if assigned( FKey) and assigned( Store) then - FKey.SaveToStream( Store) -end; - - - - - - -procedure TSimpleCodec.SetAsymetricKeySizeInBits( value: cardinal); -begin -if FAsymetricKeySizeInBits = Value then exit; -if FMode in [cmEncrypting, cmDecrypting] then - raise Exception.Create( ES_Asym_CannotSetParam); -FAsymetricKeySizeInBits := Value; -if FMode = cmIdle then - Burn( True); -end; - - - - -procedure TSimpleCodec.SetAsymGenProgressEvent( - Value: TGenerateAsymetricKeyPairProgress); -begin -FAsymGenProgressEvent := value -end; - - - -procedure TSimpleCodec.SetBlockCipher( const Value: IBlockCipher); -begin -if FBlockCipher = Value then exit; -if FMode in [cmEncrypting, cmDecrypting] then - raise Exception.Create( ES_Asym_CannotSetCipher); -if FMode = cmIdle then - Burn( True); -FBlockCipher := Value -end; - - -procedure TSimpleCodec.SetChainMode( const Value: IBlockChainingModel); -begin -if FChainMode = Value then exit; -if FMode in [cmEncrypting, cmDecrypting] then - raise Exception.Create( ES_Asym_CannotSetCipher); -if FMode = cmIdle then - Burn( True); -FChainMode := Value; -end; - - -procedure TSimpleCodec.SetEventSender( Sender: TObject); -begin -FSender := Sender; -if not assigned( FSender) then - FSender := self -end; - - -procedure TSimpleCodec.SetOnProgress( Value: TOnEncDecProgress); -begin -FOnProgress := Value -end; - - - -procedure TSimpleCodec.SetOnSetIV( Value: TSetMemStreamProc); -begin -FOnSetIV := Value -end; - - -procedure TSimpleCodec.SetStreamCipher( const Value: IStreamCipher); -begin -if FStreamCipher = Value then exit; -if FMode in [cmEncrypting, cmDecrypting] then - raise Exception.Create( ES_Asym_CannotSetCipher); -if FMode = cmIdle then - Burn( True); -FStreamCipher := Value -end; - - - - -procedure TSimpleCodec.InitFromGeneratedAsymetricKeyPair; -var - Asymetric_Engine: IAsymetric_Engine; - KeyPair: TAsymetricKeyPair; -begin -if FMode in [cmEncrypting, cmDecrypting] then - Reset; -FMode := cmUnitialized; -FXtextCount := 0; -FreeAndNil( FKey); -FisUserAborted := False; -FEnc := nil; FDec := nil; -FisUserAborted := False; -FisSalting := False; -if (not isAsymetric) or (not (Supports( FParameterizedStreamCipher, - IAsymetric_Engine, Asymetric_Engine))) then - raise Exception.Create( ES_AsymNotInitByStr); -FreeAndNil( FKey); -Asymetric_Engine.GenerateAsymetricKeyPair( - FAsymetricKeySizeInBits, FSender, FAsymGenProgressEvent, KeyPair, - FisUserAborted); -if FisUserAborted then - FMode := cmUnitialized - else - begin - FMode := cmIdle; - FKey := KeyPair - end -end; - - - -procedure TSimpleCodec.Sign( Document, Signature: TStream; - ProgressSender: TObject; ProgressEvent: TOnEncDecProgress; - SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean); -var - Engine: IASymetric_Engine; -// EstimatedWorkLoad: int64; -begin -wasAborted := False; -Engine := Asymetric_Engine; - // The FParameterizedStreamCipher cast as IAsymetric_Engine. - // Typically, this is an instance of TAsymetric_Engine. -// EstimatedWorkLoad := Document.Size; -Engine.Sign( Document, Signature, SigningKeys_PrivatePart as TAsymtricKeyPart, - ProgressSender, ProgressEvent, wasAborted) -end; - - - -function TSimpleCodec.VerifySignature( Document, Signature: TStream; - ProgressSender: TObject; ProgressEvent: TOnEncDecProgress; - SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean): boolean; -var - Engine: IASymetric_Engine; -// EstimatedWorkLoad: int64; -begin -wasAborted := False; -Engine := Asymetric_Engine; - // Typically, this is an instance of TAsymetric_Engine. -// EstimatedWorkLoad := Document.Size; -result := Engine.VerifySignature( - Document, Signature, - SigningKeys_PublicPart as TAsymtricKeyPart, - ProgressSender, ProgressEvent, wasAborted) -end; - - - - -{ TCodec } - -constructor TCodec.Create( AOwner: TComponent); -var - Origin: IEventOrigin; -begin -inherited Create( AOwner); -FCodecObj := TSimpleCodec.Create; -FCodec := FCodecObj as ICodec; -if Supports( FCodecObj, IEventOrigin, Origin) then - Origin.SetEventSender( self); -FCodecObj.FCompOwner := self; -FLib := nil; -FStreamCipherId := ''; -FBlockCipherId := ''; -FChainId := ''; -FIntfCached := False; -FCodec.OnAsymGenProgress := GenerateAsymetricKeyPairProgress_Event; -FCountBytes := 0; -FWorkLoad := 0; -FDuration := 0.0; -FStartTime := Now -end; - - -destructor TCodec.Destroy; -begin -FCodec.Burn( True); -SetLib( nil); -FCodec := nil; -FCodecObj.Free; -ClearPassword; -{$IFDEF UNICODE} -ClearUTF8Password; -{$ENDIF} -inherited -end; - - -procedure TCodec.DefineProperties( Filer: TFiler); -begin -inherited; -Filer.DefineProperty( 'StreamCipherId', ReadData_Stream, WriteData_Stream, True); -Filer.DefineProperty( 'BlockCipherId' , ReadData_Block , WriteData_Block , True); -Filer.DefineProperty( 'ChainId' , ReadData_Chain , WriteData_Chain , True) -end; - - - -procedure TCodec.BeginEncDec; -begin -FCountBytes := 0; -// User to set FWorkLoad -// FDuration to be computed at the end -FStartTime := Now -end; - - -procedure TCodec.EndEncDec; -begin -FDuration := Now - FStartTime -end; - - -procedure TCodec.Begin_EncryptMemory( CipherText: TStream); -begin -InterfacesAreCached := True; -BeginEncDec; -FCodec.Begin_EncryptMemory( Ciphertext) -end; - - -procedure TCodec.Begin_DecryptMemory( Plaintext: TStream); -begin -InterfacesAreCached := True; -BeginEncDec; -FCodec.Begin_DecryptMemory( Plaintext) -end; - - - -procedure TCodec.Burn; -begin -FCodec.Burn( False); -InterfacesAreCached := False; -FCountBytes := 0; -FWorkLoad := 0; -FDuration := 0.0; -FStartTime := 0.0 -end; - - - -{$IFDEF UNICODE} -procedure TCodec.DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -{$IFDEF UNICODE} -procedure TCodec.DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); -end; -{$ENDIF} - - -procedure TCodec.DecryptFile( - const Plaintext_FileName, CipherText_FileName: string); -begin -InterfacesAreCached := True; -BeginEncDec; -FWorkLoad := FileSize( CipherText_FileName); -FCodec.DecryptFile( Plaintext_FileName, CipherText_FileName); -EndEncDec -end; - - -procedure TCodec.DecryptMemory( const CipherText; CiphertextLen: integer); -begin -// No call to BeginEncDec because user should be calling -// Begin/End_EncryptMemory -InterfacesAreCached := True; -FCodec.DecryptMemory( CipherText, CiphertextLen) -end; - - - -procedure TCodec.DecryptStream( Plaintext, CipherText: TStream); -begin -InterfacesAreCached := True; -BeginEncDec; -FWorkLoad := Ciphertext.Size; -FCodec.DecryptStream( Plaintext, CipherText); -EndEncDec -end; - - - -procedure TCodec.DecryptString( - var Plaintext: string; const CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -begin -InterfacesAreCached := True; -BeginEncDec; -FWorkLoad := Length( CipherText_Base64) * SizeOf( Char); -FCodec.DecryptString( Plaintext, CipherText_Base64{$IFDEF UNICODE}, Encoding{$ENDIF}); -EndEncDec -end; - - - -{$IFDEF UNICODE} -procedure TCodec.DecryptString( - var Plaintext: string; const CipherText_Base64: string); -begin - DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure TCodec.Dummy( const Value: string); -begin -end; - - - -{$IFDEF UNICODE} -procedure TCodec.EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -{$IFDEF UNICODE} -procedure TCodec.EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); -end; -{$ENDIF} - -procedure TCodec.EncryptFile( - const Plaintext_FileName, CipherText_FileName: string); -begin -InterfacesAreCached := True; -BeginEncDec; -FWorkLoad := FileSize( Plaintext_FileName); -FCodec.EncryptFile( Plaintext_FileName, CipherText_FileName); -EndEncDec; -end; - - - -procedure TCodec.EncryptMemory( const Plaintext; PlaintextLen: integer); -begin -// No call to BeginEncDec because user should be calling -// Begin/End_EncryptMemory -InterfacesAreCached := True; -FCodec.EncryptMemory( Plaintext, PlaintextLen) -end; - - - -procedure TCodec.EncryptStream( Plaintext, CipherText: TStream); -begin -InterfacesAreCached := True; -BeginEncDec; -FWorkLoad := Plaintext.Size; -FCodec.EncryptStream( Plaintext, CipherText); -EndEncDec -end; - - - -procedure TCodec.EncryptString( - const Plaintext: string; var CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -begin -InterfacesAreCached := True; -BeginEncDec; -FCodec.EncryptString( Plaintext, CipherText_Base64{$IFDEF UNICODE}, Encoding{$ENDIF}); -EndEncDec -end; - - - -{$IFDEF UNICODE} -procedure TCodec.EncryptString( - const Plaintext: string; var CipherText_Base64: string); -begin - EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure TCodec.End_DecryptMemory; -begin -InterfacesAreCached := True; -FCodec.End_DecryptMemory; -EndEncDec -end; - - - -procedure TCodec.End_EncryptMemory; -begin -InterfacesAreCached := True; -FCodec.End_EncryptMemory; -EndEncDec -end; - - - -procedure TCodec.GenerateAsymetricKeyPairProgress_Event( - Sender: TObject; CountPrimalityTests: integer; var doAbort: boolean); -var - CountBytesProcessed1: int64; -begin -if assigned( FCodec.OnProgress) then - begin - CountBytesProcessed1 := -1; - FGenerateAsymetricKeyPairProgress_CountPrimalityTests := CountPrimalityTests; - doAbort := not FCodec.OnProgress( self, CountBytesProcessed1) - end -end; - - -function TCodec.GetAsymetricKeySizeInBits: cardinal; -begin -result := FCodec.AsymetricKeySizeInBits -end; - - -function TCodec.GetChainDisplayName: string; -begin -InterfacesAreCached := True; -if FCodec.ChainMode <> nil then - result := TCryptographicLibrary.ComputeChainDisplayName( FCodec.ChainMode) - else - result := '' -end; - - -function TCodec.GetCipherDisplayName: string; -begin -InterfacesAreCached := True; -result := FCodec.GetCipherDisplayName( FLib) -end; - - - -function TCodec.GetCodecIntf: ICodec; -begin -InterfacesAreCached := True; -result := FCodec -end; - - - -function TCodec.GetKey: TSymetricKey; -begin -InterfacesAreCached := True; -result := FCodec.Key -end; - - - -function TCodec.GetMode: TCodecMode; -begin -result := FCodec.Mode -end; - - -function TCodec.GetOnProgress: TOnHashProgress; -begin -result := FCodec.OnProgress -end; - - -function TCodec.isAsymetric: boolean; -begin -InterfacesAreCached := True; -result := FCodec.isAsymetric -end; - - - -function TCodec.Asymetric_Engine: IAsymetric_Engine; -var - AS1: ICodec_WithAsymetricSupport; -begin -result := nil; -InterfacesAreCached := True; -if Supports( FCodec, ICodec_WithAsymetricSupport, AS1) then - result := AS1.Asymetric_Engine -end; - - - - -function TCodec.GetAborted: boolean; -begin -result := FCodec.isUserAborted -end; - - -function TCodec.GetAdvancedOptions2: TSymetricEncryptionOptionSet; -begin -result := FCodec.GetAdvancedOptions2 -end; - -procedure TCodec.SetAborted( Value: boolean); -begin -FCodec.isUserAborted := Value -end; - - -procedure TCodec.SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); -begin -if FCodec.GetAdvancedOptions2 = Value then exit; -InterfacesAreCached := False; -FCodec.SetAdvancedOptions2( Value) -end; - -procedure TCodec.Loaded; -begin -inherited; -InterfacesAreCached := True -end; - - - -procedure TCodec.Notification( AComponent: TComponent; Operation: TOperation); -begin -inherited; -if (Operation = opRemove) and (AComponent = FLib) then - SetLib( nil) -end; - - - -procedure TCodec.ProgIdsChanged; -begin -InterfacesAreCached := False -end; - - - -procedure TCodec.ReadData_Stream( Reader: TReader); -begin -StreamCipherId := Reader.ReadString -end; - -procedure TCodec.ReadData_Block( Reader: TReader); -begin -BlockCipherId := Reader.ReadString -end; - -procedure TCodec.ReadData_Chain( Reader: TReader); -begin -ChainModeId := Reader.ReadString -end; - - - -procedure TCodec.Reset; -begin -FGenerateAsymetricKeyPairProgress_CountPrimalityTests := 0; -if Mode <> cmUnitialized then - FCodec.Reset; -FCountBytes := 0; -FWorkLoad := 0; -end; - - -procedure TCodec.InitFromGeneratedAsymetricKeyPair; -begin -InterfacesAreCached := True; -FCodec.InitFromGeneratedAsymetricKeyPair -end; - - -procedure TCodec.InitFromKey( Key: TSymetricKey); -begin -InterfacesAreCached := True; -FCodec.InitFromKey( Key) -end; - - -procedure TCodec.InitFromStream( Store: TStream); -begin -InterfacesAreCached := True; -FCodec.InitFromStream( Store); -ClearPassword; // Because not using a password. -{$IFDEF UNICODE} -ClearUTF8Password -{$ENDIF} -end; - - -procedure TCodec.SaveKeyToStream( Store: TStream); -begin -InterfacesAreCached := True; -FCodec.SaveKeyToStream( Store) -end; - - -procedure TCodec.SetAsymetricKeySizeInBits( value: cardinal); -begin -FCodec.AsymetricKeySizeInBits := Value -end; - - - -procedure TCodec.SetBlockCipherId( const Value: string); -begin -if FBlockCipherId = Value then exit; -InterfacesAreCached := False; -FBlockCipherId := Value -end; - - - -procedure TCodec.SetChainId( const Value: string); -begin -if FChainId = Value then exit; -InterfacesAreCached := False; -FChainId := Value -end; - - - -procedure TCodec.ClearPassword; -begin -if FPassword <> '' then - BurnMemory( FPassword[{$IFDEF STRINGHELPER}Low( FPassword){$ELSE}1{$ENDIF}], Length( FPassword) * SizeOf( Char)); -FPassword := '' -end; - -{$IFDEF UNICODE} -procedure TCodec.ClearUTF8Password; -var - PasswordBytes: TBytes; -begin -if FUTF8Password <> '' then - begin - PasswordBytes := TEncoding.UTF8.GetBytes( FUTF8Password); - BurnMemory( FUTF8Password[{$IFDEF STRINGHELPER}Low( FPassword){$ELSE}1{$ENDIF}], Length( PasswordBytes)); - BurnMemory( PasswordBytes[0], Length( PasswordBytes)); - FUTF8Password := '' - end; -end; -{$ENDIF} - -procedure TCodec.SetIntfCached( Value: boolean); -begin -if FIntfCached = Value then exit; -FIntfCached := Value; -FCodec.StreamCipher := nil; -FCodec.BlockCipher := nil; -FCodec.ChainMode := nil; -if FIntfCached and assigned( FLib) then - begin - FCodec.StreamCipher := FLib.StreamCipherIntfc( FStreamCipherId); - FCodec.BlockCipher := FLib.BlockCipherIntfc( FBlockCipherId); - FCodec.ChainMode := FLib.BlockChainingModelIntfc( FChainId); - {$IFDEF UNICODE} - if assigned( FCodec.StreamCipher) then - begin - if FPassword <> '' then - begin - if not FCodec.isAsymetric then - FCodec.Init( FPassword) - end - else if (FUTF8Password <> '') and (not FCodec.isAsymetric) then - FCodec.InitA( FUTF8Password) - end; - {$ELSE} - if (FPassword <> '') and assigned( FCodec.StreamCipher) and (not FCodec.isAsymetric) then - FCodec.Init( FPassword) - {$ENDIF} - end -end; - - - -procedure TCodec.SetLib( Value: TCryptographicLibrary); -var - OldLib: TCryptographicLibrary; -begin -if FLib = Value then exit; -if assigned( FLib) then - begin - OldLib := FLib; - FLib := nil; - OldLib.DegisterWatcher( self); - OldLib.RemoveFreeNotification( self) - end; -InterfacesAreCached := False; -FLib := Value; -if assigned( FLib) then - begin - FLib.FreeNotification( self); - FLib.RegisterWatcher ( self) - end -end; - - - - -procedure TCodec.SetOnProgress( const Value: TOnHashProgress); -begin -FCodec.OnProgress := Value -end; - - - -function TCodec.GetOnSetIV: TSetMemStreamProc; -begin -result := FCodec.GetOnSetIV(); -end; - - -procedure TCodec.SetOnSetIV( Value: TSetMemStreamProc); -begin -FCodec.SetOnSetIV( Value) -end; - -procedure TCodec.SetPassword( const NewPassword: string); -begin -FPassword := NewPassword; -{$IFDEF UNICODE} -if FPassword <> '' then - ClearUTF8Password; -{$ENDIF} -if InterfacesAreCached then - begin - if (FPassword <> '') and assigned( FCodec.StreamCipher) and - (not FCodec.isAsymetric) then - FCodec.Init( FPassword) - end - else - InterfacesAreCached := True -end; - - - -{$IFDEF UNICODE} -procedure TCodec.SetUTF8Password( const NewPassword: string); -begin -FUTF8Password := NewPassword; -if FUTF8Password <> '' then - ClearPassword; -if InterfacesAreCached then - begin - if (FUTF8Password <> '') and assigned( FCodec.StreamCipher) and - (not FCodec.isAsymetric) then - FCodec.InitA( FUTF8Password) - end - else - InterfacesAreCached := True -end; -{$ENDIF} - - - -procedure TCodec.SetStreamCipherId( const Value: string); -begin -if FStreamCipherId = Value then exit; -InterfacesAreCached := False; -FStreamCipherId := Value -end; - - - - -function TCodec.Speed: integer; // In KiB per second. -var - Duration: TDateTime; -begin -try -if FCodec.Mode in [cmEncrypting, cmDecrypting] then - Duration := Now - FStartTime - else - Duration := FDuration; -if Duration > 0.0 then - result := Round( FWorkLoad / (Duration * SecsPerDay * 1024.0)) - else - result := -1 -except - result := -1 -end end; - - -procedure TCodec.WriteData_Block( Writer: TWriter); -begin -Writer.WriteString( FBlockCipherId) -end; - - - -procedure TCodec.WriteData_Stream( Writer: TWriter); -begin -Writer.WriteString( FStreamCipherId) -end; - - - -procedure TCodec.WriteData_Chain( Writer: TWriter); -begin -Writer.WriteString( FChainId) -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Codec; +interface +uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, TPLB3.Asymetric, + TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, TPLB3.CodecIntf, + TPLB3.HashDsc, TPLB3.Hash, TPLB3.StreamUtils; + + +type +/// +/// Please remember to invoke TRandomStream.Instance.Randomize() at program start-up! +/// +TSimpleCodec = class( TInterfacedPersistent, ICodec, IBlockCipherSelector, + IBlockCipherSelectorEx2, IEventOrigin, ICodec_WithAsymetricSupport) + private + FMode: TCodecMode; + FStreamCipher: IStreamCipher; + FParameterizedStreamCipher: IStreamCipher; + FBlockCipher : IBlockCipher; + FChainMode : IBlockChainingModel; + FOnProgress : TOnEncDecProgress; + FSender: TObject; + + FKey: TSymetricKey; + FEnc: IStreamEncryptor; + FDec: IStreamDecryptor; + FPasswordHasher: IHash; + FPasswordHasherObject: TObject; // TSimpleHash + FXtextCount: int64; + FisUserAborted: boolean; + FOutput: TStream; + FBuffer: TMemoryStream; + FDesalination: TDesalinationWriteStream; + FisSalting: boolean; + + FAsymetricKeySizeInBits: cardinal; + FAsymGenProgressEvent : TGenerateAsymetricKeyPairProgress; + FCompOwner: TComponent; + FAdvancedOptions2 : TSymetricEncryptionOptionSet; + FOnSetIV: TSetMemStreamProc; + + procedure SetStreamCipher( const Value: IStreamCipher); + procedure SetBlockCipher ( const Value: IBlockCipher); + procedure SetChainMode ( const Value: IBlockChainingModel); + function GetMode: TCodecMode; + function GetStreamCipher: IStreamCipher; + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + function GetOnProgress : TOnEncDecProgress; + procedure SetOnProgress( Value: TOnEncDecProgress); + procedure SetEventSender( Sender: TObject); + function isNotBase64Converter: boolean; + function GetAsymetricKeySizeInBits: cardinal; + procedure SetAsymetricKeySizeInBits( value: cardinal); + function GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; + procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress); + function GetKey: TSymetricKey; + function Asymetric_Engine: IAsymetric_Engine; + procedure End_EncryptDecrypt; + procedure DoProgress; + procedure InitCheck; + function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; + procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); + function hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; + function GetOnSetIV: TSetMemStreamProc; + procedure SetOnSetIV( Value: TSetMemStreamProc); + + public + constructor Create; + destructor Destroy; override; + + procedure Init( const Key: string); overload; +{$IFDEF UNICODE} + procedure Init( const Key: string; Encoding: TEncoding); overload; + procedure InitA( const Key: string); +{$ENDIF} + procedure SaveKeyToStream( Store: TStream); + procedure InitFromStream( Store: TStream); + procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. + procedure Reset; + procedure Burn( doIncludeBurnKey: boolean); + + function isAsymetric: boolean; + procedure InitFromGeneratedAsymetricKeyPair; + + procedure Sign( + Document, Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean); + + function VerifySignature( + Document, Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean): boolean; + + procedure Begin_EncryptMemory( CipherText{out}: TStream); + procedure EncryptMemory( const Plaintext; PlaintextLen: integer); + procedure End_EncryptMemory; + + procedure Begin_DecryptMemory( Plaintext{out}: TStream); + procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); + procedure End_DecryptMemory; + + procedure EncryptStream( Plaintext, CipherText: TStream); + procedure DecryptStream( Plaintext, CipherText: TStream); + + procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); + procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); + + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; + +{$IFDEF UNICODE} + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; + + procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; + + procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; +{$ENDIF} + + function GetAborted: boolean; + procedure SetAborted( Value: boolean); + function GetCipherDisplayName( Lib: TCryptographicLibrary): string; + + property Mode: TCodecMode read GetMode; + property StreamCipher: IStreamCipher read GetStreamCipher write SetStreamCipher; + property BlockCipher : IBlockCipher read GetBlockCipher write SetBlockCipher; + property ChainMode : IBlockChainingModel read GetChainMode write SetChainMode; + property AdvancedOptions2: TSymetricEncryptionOptionSet read GetAdvancedOptions2 write SetAdvancedOptions2; + property OnProgress : TOnEncDecProgress read GetonProgress write SetOnProgress; + end; + + + + + + +ICodec_TestAccess = interface + // This method is ONLY to be used by unit test programs. + ['{1DCED340-E6C0-4B97-BBAA-98305B5D4F5E}'] + function GetCodecIntf: ICodec; + end; + + +/// +/// Please remember to invoke TRandomStream.Instance.Randomize() at program start-up! +/// +[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidAndroid)] +TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher, + ICodec_TestAccess) +{$IF CompilerVersion >= 17.0} + strict private +{$ELSE} + private +{$IFEND} + FPassword: string; +{$IFDEF UNICODE} + FUTF8Password: string; +{$ENDIF} + + private + FCodecObj: TSimpleCodec; + FCodec : ICodec; + FLib: TCryptographicLibrary; + FStreamCipherId: string; + FBlockCipherId: string; + FChainId: string; + FIntfCached: boolean; + FCountBytes: int64; + FWorkLoad: int64; + FDuration: TDateTime; + FStartTime: TDateTime; + + procedure SetLib( Value: TCryptographicLibrary); + procedure Dummy( const Value: string); + procedure SetStreamCipherId( const Value: string); + procedure SetBlockCipherId( const Value: string); + procedure SetChainId( const Value: string); + procedure SetIntfCached( Value: boolean); + procedure ReadData_Stream( Reader: TReader); + procedure WriteData_Stream( Writer: TWriter); + procedure ReadData_Block( Reader: TReader); + procedure WriteData_Block( Writer: TWriter); + procedure ReadData_Chain( Reader: TReader); + procedure WriteData_Chain( Writer: TWriter); + function GetMode: TCodecMode; + function GetOnProgress: TOnHashProgress; + procedure SetOnProgress(const Value: TOnHashProgress); + procedure ProgIdsChanged; + function GetCodecIntf: ICodec; + procedure SetPassword( const NewPassword: string); +{$IFDEF UNICODE} + procedure SetUTF8Password( const NewPassword: string); +{$ENDIF} + procedure GenerateAsymetricKeyPairProgress_Event( + Sender: TObject; CountPrimalityTests: integer; + var doAbort: boolean); + function GetAsymetricKeySizeInBits: cardinal; + procedure SetAsymetricKeySizeInBits( value: cardinal); + function GetKey: TSymetricKey; + procedure BeginEncDec; + procedure EndEncDec; + procedure ClearPassword; +{$IFDEF UNICODE} + procedure ClearUTF8Password; +{$ENDIF} + function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; + procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); + function GetOnSetIV: TSetMemStreamProc; + Procedure SetOnSetIV( Value: TSetMemStreamProc); + + protected + procedure Notification( + AComponent: TComponent; Operation: TOperation); override; + procedure DefineProperties( Filer: TFiler); override; + function GetCipherDisplayName: string; virtual; + function GetChainDisplayName: string; virtual; + procedure Loaded; override; + + property InterfacesAreCached: boolean read FIntfCached write SetIntfCached; + + public + + FGenerateAsymetricKeyPairProgress_CountPrimalityTests: integer; + + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + + procedure Burn; + procedure Reset; + procedure SaveKeyToStream( Store: TStream); + procedure InitFromStream( Store: TStream); + + function GetAborted: boolean; + procedure SetAborted( Value: boolean); + + function isAsymetric: boolean; + function Asymetric_Engine: IAsymetric_Engine; + procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. + procedure InitFromGeneratedAsymetricKeyPair; + + procedure Begin_EncryptMemory( CipherText{out}: TStream); + procedure EncryptMemory( const Plaintext; PlaintextLen: integer); + procedure End_EncryptMemory; + + procedure Begin_DecryptMemory( Plaintext{out}: TStream); + procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); + procedure End_DecryptMemory; + + procedure EncryptStream( Plaintext, CipherText: TStream); + procedure DecryptStream( Plaintext, CipherText: TStream); + + procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); + procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); + + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; + +{$IFDEF UNICODE} + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; + + procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; + + procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; +{$ENDIF} + + function Speed: integer; // In KiB per second. Set to -1 for indeterminant. + + property Key: TSymetricKey read GetKey; + property StreamCipherId: string read FStreamCipherId write SetStreamCipherId; + property BlockCipherId: string read FBlockCipherId write SetBlockCipherId; + property ChainModeId: string read FChainId write SetChainId; + property Password: string read FPassword write SetPassword; +{$IFDEF UNICODE} + property UTF8Password: string read FUTF8Password write SetUTF8Password; +{$ENDIF} + property Mode: TCodecMode read GetMode; + property isUserAborted: boolean read GetAborted write SetAborted; + + property CountBytesProcessed: int64 read FCountBytes write FCountBytes; + property EstimatedWorkLoad : int64 read FWorkLoad write FWorkLoad; + property Duration : TDateTime read FDuration write FDuration; + + published + property Cipher: string read GetCipherDisplayName write Dummy stored False; + property ChainMode: string read GetChainDisplayName write Dummy stored False; + property AsymetricKeySizeInBits: cardinal read GetAsymetricKeySizeInBits + write SetAsymetricKeySizeInBits; + + property AdvancedOptions2: TSymetricEncryptionOptionSet read GetAdvancedOptions2 write SetAdvancedOptions2; + property CryptoLibrary: TCryptographicLibrary read FLib write SetLib; + property OnProgress : TOnHashProgress read GetOnProgress write SetOnProgress; + property OnSetIV: TSetMemStreamProc read GetOnSetIV write SetOnSetIV; + + end; + + + + + + + +implementation + + + + + + +uses Math, TPLB3.SHA1, TPLB3.ECB, TPLB3.Random, TPLB3.Decorators, + TPLB3.BinaryUtils, TPLB3.I18n +{$IF CompilerVersion >= 21} + , Rtti +{$IFEND} + ; + + + +const + SaltSize = 8; // 8 bytes or 64 bits of entropy to be injected. + Default_AsymetricKeySizeInBits = 1024; +{ TSimpleCodec } + +constructor TSimpleCodec.Create; +begin +FMode := cmUnitialized; +FStreamCipher := nil; +FParameterizedStreamCipher := nil; +FBlockCipher := nil; +FChainMode := nil; +FOnProgress := nil; +FKey := nil; +FEnc := nil; +FDec := nil; +FPasswordHasherObject := TSimpleHash.Create; +Supports( FPasswordHasherObject, IHash, FPasswordHasher); +FPasswordHasher.Hash := TSHA1.Create; +FisUserAborted := False; +FXtextCount := 0; +FOutput := nil; +FBuffer := TMemoryStream.Create; +FSender := self; +FDesalination := TDesalinationWriteStream.Create; +FisSalting := False; +FAsymetricKeySizeInBits := Default_AsymetricKeySizeInBits; +FAsymGenProgressEvent := nil +end; + + +destructor TSimpleCodec.Destroy; +begin +Burn( True); +FPasswordHasher := nil; +FPasswordHasherObject.Free; +FKey.Free; +FBuffer.Free; +FDesalination.Free; +inherited; +end; + + + +procedure TSimpleCodec.DoProgress; +begin +if FisUserAborted then exit; +if assigned( FCompOwner) and (FCompOwner is TCodec) then + TCodec( FCompOwner).FCountBytes := FXtextCount; +FisUserAborted := assigned( FOnProgress) and + (not FOnProgress( FSender, FXtextCount)) +end; + + + + +function TSimpleCodec.isAsymetric: boolean; +begin +if assigned( FStreamCipher) and (not assigned( FParameterizedStreamCipher)) then + begin + FParameterizedStreamCipher := FStreamCipher.Parameterize( self); + if not assigned( FParameterizedStreamCipher) then + FParameterizedStreamCipher := FStreamCipher + end; +result := assigned( FParameterizedStreamCipher) and + (afAsymetric in FParameterizedStreamCipher.Features) and + Supports( FParameterizedStreamCipher, IAsymetric_Engine) +end; + + + + +function TSimpleCodec.Asymetric_Engine: IAsymetric_Engine; +begin +result := nil; +if isAsymetric then + Supports( FParameterizedStreamCipher, IAsymetric_Engine, result) +end; + + + +function isVariableSeedSize( + const Cipher: IStreamCipher; var MinSize, MaxSize: integer): boolean; +// For Delphi 2010 and beyound, look for an IntegerRange range attribute +// on the SeedByteSize method. +// For older compilers, test for the IVariableSeedSize interface. +var + ControlObject: IControlObject; + Controller: TObject; + +{$IF compilerversion >= 21} + LContext: TRttiContext; + LType: TRttiType; + Meth: TRttiMethod; + Attr: TCustomAttribute; + IntRange: IntegerRange; +{$ELSE} + VariableSeedSize: IVariableSeedSize; +{$IFEND} + +begin +result := False; +Supports( Cipher, IControlObject, ControlObject); +if assigned( ControlObject) then + Controller := ControlObject.ControlObject + else + Controller := nil; +if not assigned( Controller) then exit; + +{$IF compilerversion >= 21} +IntRange := nil; +LContext := TRttiContext.Create; +try +LType := LContext.GetType( Controller.ClassType); +for Meth in LType.GetDeclaredMethods do + begin + if not SameText( Meth.Name, 'SeedByteSize') then continue; + for Attr in Meth.GetAttributes do + begin + if not (Attr is IntegerRange) then continue; + IntRange := IntegerRange( Attr); + break + end; + break + end; +result := assigned( IntRange); +if result then + begin + MinSize := IntRange.Min; + MaxSize := IntRange.Max + end +finally +LContext.Free +end +{$ELSE} + +result := Supports( Controller, IVariableSeedSize, VariableSeedSize); +if result then + begin + MinSize := VariableSeedSize.Min; + MaxSize := VariableSeedSize.Max + end +{$IFEND} +end; + + + +function ConstraintWithinRange( + Instrinsic, LowerBound, UpperBound: integer): integer; +// Find a value close to Instrinsic but within specified bounds. +begin +result := Instrinsic; +if result > UpperBound then + result := UpperBound + else if result < LowerBound then + result := LowerBound +end; + + +function CalculateOutputSeedSize( + const Cipher: IStreamCipher; + InputSeedSize: integer; var MinSize, MaxSize: integer) : integer; +// Calculate a convenient key seed size for the Cipher +// partly based on what resources we have. +begin +MinSize := 0; +MaxSize := 0; +result := Cipher.SeedByteSize; +if result = -1 then exit; +if isVariableSeedSize( Cipher, MinSize, MaxSize) then + result := ConstraintWithinRange( InputSeedSize, MinSize, MaxSize) + else + begin + MinSize := result; + MaxSize := result + end +end; + + + +procedure SpreadHashIntoBuffer( + Buffer: TMemoryStream; + const PasswordHasher: IHash; + MinSize, MaxSize, OutputSeedSize: integer); +// Used by the Init method to transfer the key seed data from +// the Hasher to a Buffer, and make sure it is a convenient size. +var + L, Diff, Amt: integer; +begin +Buffer.Size := 0; +Buffer.CopyFrom( PasswordHasher.HashOutputValue, 0); +PasswordHasher.Burn; +L := Buffer.Size; +if L = 0 then + raise Exception.Create( ES_HashFailed); +OutputSeedSize := ConstraintWithinRange( L, MinSize, MaxSize); +Diff := L - OutputSeedSize; +if Diff > 0 then + // Truncate + Buffer.Size := OutputSeedSize + + else if Diff < 0 then + begin // Extend by repetition. + Buffer.Seek( 0, soEnd); + Diff := - Diff; + repeat + Amt := Min( Diff, L); + Buffer.Write( Buffer.Memory^, Amt); + Dec( Diff, Amt) + until Diff <= 0 + end +end; + + +procedure TSimpleCodec.InitCheck; +begin +if FMode in [cmEncrypting, cmDecrypting] then + Reset; +FMode := cmUnitialized; +FXtextCount := 0; +FreeAndNil( FKey); +FisUserAborted := False; +if isAsymetric then + raise Exception.Create( ES_AsymPassword); +FEnc := nil; FDec := nil; +FisUserAborted := False; +end; + + + +procedure TSimpleCodec.Init( const Key: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +var + {$IFDEF UNICODE}KeyBytes: TBytes;{$ENDIF} + InputSeedSize, OutputSeedSize: integer; + MinSize, MaxSize: integer; +begin +if Key = '' then + raise Exception.Create( ES_NoPassword); +InitCheck; +// The key is based on a hash of the Key string for symetric ciphers. +try + {$IFDEF UNICODE} + KeyBytes := Encoding.GetBytes( Key); + InputSeedSize := Length( KeyBytes); + {$ELSE} + InputSeedSize := Length( Key) * SizeOf( Char); + {$ENDIF} + OutputSeedSize := CalculateOutputSeedSize( + FParameterizedStreamCipher, InputSeedSize, MinSize, MaxSize); + if OutputSeedSize = -1 then + // A SeedByteSize of -1 means that the seed (FBuffer) is irrelevant. + // This might be so in non-encryption type transformations. + FBuffer.Clear + else + begin + if InputSeedSize = OutputSeedSize then + begin + // No hash. The key seed is just perfect size. Just use it. + FBuffer.Size := InputSeedSize; + if InputSeedSize > 0 then + Move( {$IFDEF UNICODE}KeyBytes[0]{$ELSE}Key[1]{$ENDIF}, FBuffer.Memory^, InputSeedSize) + end + else + begin + {$IFDEF UNICODE} + FPasswordHasher.HashBytes( KeyBytes); + {$ELSE} + FPasswordHasher.HashString( Key); + {$ENDIF} + SpreadHashIntoBuffer( + FBuffer, FPasswordHasher, MinSize, MaxSize, OutputSeedSize) + end; + FBuffer.Position := 0 + end; + FKey := FParameterizedStreamCipher.GenerateKey( FBuffer) +finally + FPasswordHasher.Burn; + BurnMemoryStream( FBuffer) + end; +if FisUserAborted then + FMode := cmUnitialized + else + FMode := cmIdle; +FisSalting := False +end; + + + +{$IFDEF UNICODE} +procedure TSimpleCodec.Init( const Key: string); +begin + Init( Key, TEncoding.Unicode); +end; +{$ENDIF} + + + +{$IFDEF UNICODE} +procedure TSimpleCodec.InitA( const Key: string); +begin + Init( Key, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure TSimpleCodec.InitFromKey( Key: TSymetricKey); +begin +if FMode in [cmEncrypting, cmDecrypting] then + Reset; +FMode := cmUnitialized; +FXtextCount := 0; +FreeAndNil( FKey); +FisUserAborted := False; +if not assigned( FParameterizedStreamCipher) then + begin + FParameterizedStreamCipher := FStreamCipher.Parameterize( self); + if not assigned( FParameterizedStreamCipher) then + FParameterizedStreamCipher := FStreamCipher + end; +FEnc := nil; FDec := nil; +FKey := Key; // Ownership xferred. +FMode := cmIdle; +FisSalting := False +end; + + + +procedure TSimpleCodec.InitFromStream( Store: TStream); +begin +if FMode in [cmEncrypting, cmDecrypting] then + Reset; +FMode := cmUnitialized; +FXtextCount := 0; +FreeAndNil( FKey); +FisUserAborted := False; +if not assigned( FParameterizedStreamCipher) then + begin + FParameterizedStreamCipher := FStreamCipher.Parameterize( self); + if not assigned( FParameterizedStreamCipher) then + FParameterizedStreamCipher := FStreamCipher + end; +FEnc := nil; FDec := nil; +FKey := FParameterizedStreamCipher.LoadKeyFromStream( Store); +FMode := cmIdle; +FisSalting := False +end; + + +function TSimpleCodec.isNotBase64Converter: boolean; +begin +result := not Supports( FStreamCipher, IisBase64Converter) +end; + +function TSimpleCodec.GetAborted: boolean; +begin +result := FisUserAborted +end; + + +function TSimpleCodec.GetAdvancedOptions2: TSymetricEncryptionOptionSet; +begin +result := FAdvancedOptions2 +end; + +procedure TSimpleCodec.SetAborted( Value: boolean); +begin +FisUserAborted := Value +end; + + +procedure TSimpleCodec.SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); +begin +if FAdvancedOptions2 = Value then exit; +if not (FMode in [cmUnitialized, cmIdle]) then + raise Exception.Create( ES_Asym_CannotSetCipher); +FAdvancedOptions2 := Value; +FParameterizedStreamCipher := nil +end; + + +procedure TSimpleCodec.End_EncryptDecrypt; +begin +if assigned( FEnc) then + FEnc.Reset; // Alternative would be to release FEnc. +if assigned( FDec) then + FDec.Reset; +FMode := cmIdle; +FBuffer.Size := 0; +FisSalting := False; +FParameterizedStreamCipher := nil +end; + + +procedure TSimpleCodec.Reset; +begin +if FMode = cmUnitialized then + raise Exception.Create( ES_WrongModeReset); +End_EncryptDecrypt; +FXtextCount := 0; +FisUserAborted := False +end; + + +procedure TSimpleCodec.Begin_EncryptMemory( CipherText{out}: TStream); +begin +if FMode <> cmIdle then + raise Exception.Create( ES_WrongModeEncrypt); + +// Require: +// 1. assigned( FStreamCipher) +// 2. NOT afNotImplementedYet in FStreamCipher.Features; +// 3. if afBlockAdapter in FStreamCipher.Features then +// 3.1 assigned( FBlockCipher) +// 3.2 NOT afNotImplementedYet in FBlockCipher.Features; +// 3.3 assigned( FChainMode) +// 3.4 NOT afNotImplementedYet in FChainMode.Features; + +if (not assigned( FStreamCipher)) or + (afNotImplementedYet in FStreamCipher.Features) or + + ((afBlockAdapter in FStreamCipher.Features) and ( + (not assigned( FBlockCipher)) or + (afNotImplementedYet in FBlockCipher.Features) or + (not assigned( FChainMode)) or + (afNotImplementedYet in FChainMode.Features) + )) then + raise Exception.Create( ES_EncryptNoAlg); + +if not assigned( FParameterizedStreamCipher) then + begin + FParameterizedStreamCipher := FStreamCipher.Parameterize( self); + if not assigned( FParameterizedStreamCipher) then + FParameterizedStreamCipher := FStreamCipher; + FEnc := nil + end; + +FDec := nil; +if (not assigned( FEnc)) or (FOutput <> Ciphertext) then + begin + FEnc := nil; + FOutput := Ciphertext; + FEnc := FParameterizedStreamCipher.Start_Encrypt( FKey, FOutput) + end + else + FEnc.Reset; + +FMode := cmEncrypting; +FXtextCount := 0; +FisSalting := False; +FisUserAborted := False; +end; + + +procedure TSimpleCodec.Begin_DecryptMemory( Plaintext{out}: TStream); +var + useDesalination: boolean; + FinalOutput: TStream; +begin +if FMode <> cmIdle then + raise Exception.Create( ES_WrongModeDecrypt); +if (not assigned( FStreamCipher)) or + (afNotImplementedYet in FStreamCipher.Features) or + + ((afBlockAdapter in FStreamCipher.Features) and ( + (not assigned( FBlockCipher)) or + (afNotImplementedYet in FBlockCipher.Features) or + (not assigned( FChainMode)) or + (afNotImplementedYet in FChainMode.Features) + )) then + raise Exception.Create( ES_DecryptNoAlg); + +if not assigned( FParameterizedStreamCipher) then + begin + FParameterizedStreamCipher := FStreamCipher.Parameterize( self); + if not assigned( FParameterizedStreamCipher) then + FParameterizedStreamCipher := FStreamCipher; + FDec := nil + end; + +useDesalination := ([afCompressor, afConverter, afDoesNotNeedSalt] * + FParameterizedStreamCipher.Features) = []; + +if useDesalination then + FinalOutput := FDesalination.FreshwaterStream + else + FinalOutput := FOutput; + +FEnc := nil; +if (not assigned( FDec)) or (FinalOutput <> Plaintext) then + begin + FDec := nil; + FOutput := Plaintext; + if useDesalination then + begin + FDesalination.FreshwaterStream := FOutput; + FOutput := FDesalination; + FDesalination.SaltVolume := SaltSize + end; + FDec := FParameterizedStreamCipher.Start_Decrypt( FKey, FOutput) + end + else + FDec.Reset; + +FMode := cmDecrypting; +FXtextCount := 0; +FisUserAborted := False; +end; + + +procedure TSimpleCodec.Burn( doIncludeBurnKey: boolean); +begin +if assigned( FKey) and (not doIncludeBurnKey) and (FMode <> cmUnitialized) then + FMode := cmIdle + else + begin + FMode := cmUnitialized; + if assigned( FKey) then + begin + FKey.Burn; + FreeAndNil( FKey) + end + end; +FParameterizedStreamCipher := nil; +FEnc := nil; +FDec := nil; +FPasswordHasher.Burn; +FXtextCount := 0; +FisUserAborted := False; +BurnMemoryStream( FBuffer); +if FOutput = FDesalination then + begin + FDesalination.FreshwaterStream := nil; + FDesalination.SaltVolume := SaltSize + end; +FOutput := nil; +FisSalting := False +end; + + +{$IFDEF UNICODE} +procedure TSimpleCodec.DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + +{$IFDEF UNICODE} +procedure TSimpleCodec.DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); +end; +{$ENDIF} + + +const FileStreamOpenMode: array[ boolean ] of word = ( + {False, Not exists} fmCreate, {True, exists} fmOpenReadWrite); + + +procedure TSimpleCodec.DecryptFile( + const Plaintext_FileName, + CipherText_FileName: string); +var + Plaintext, ciphertext: TStream; + isPreExists: boolean; +begin +isPreExists := FileExists( Plaintext_FileName); +plaintext := TFileStream.Create( Plaintext_FileName, FileStreamOpenMode[ isPreExists]); +try + Ciphertext := TFileStream.Create( Ciphertext_FileName, fmOpenRead); + try + if isPreExists then + Plaintext.Size := 0; + DecryptStream( plaintext, ciphertext) + finally + CipherText.Free + end +finally + PlainText.Free; +end end; + + + + +procedure TSimpleCodec.DecryptStream( Plaintext, CipherText: TStream); +var + Temp: TMemoryStream; + BytesRead, Amnt: integer; +begin +Temp := TMemoryStream.Create; +try + Ciphertext.Position := 0; + Amnt := Max( Min( CipherText.Size, 1024), 1); + Temp.Size := Amnt; + Begin_DecryptMemory( PlainText); + repeat + if Temp.Size > Amnt then + BurnMemoryStream( Temp); + if Temp.Size <> Amnt then + Temp.Size := Amnt; + BytesRead := Ciphertext.Read( Temp.Memory^, Amnt); + if BytesRead = 0 then break; + DecryptMemory( Temp.Memory^, BytesRead); + DoProgress + until (BytesRead < Amnt) or FisUserAborted; + End_DecryptMemory +finally + BurnMemoryStream( Temp); + Temp.Free +end end; + + +procedure TSimpleCodec.DecryptString( + var Plaintext: string; + const CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +var + Temp, Ciphertext: TMemoryStream; + L: integer; +begin +Temp := TMemoryStream.Create; +Ciphertext := TMemoryStream.Create; +try + if isNotBase64Converter then + Base64_to_stream( CipherText_Base64, Ciphertext) + else + // If its already a Base64 encoder, no point in double-encoding it as base64. + String_to_stream( CipherText_Base64, Ciphertext{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}); + Begin_DecryptMemory( Temp); + L := Ciphertext.Size; + if L > 0 then + DecryptMemory( Ciphertext.Memory^, L); + End_DecryptMemory; + if FisUserAborted then + SetLength( Plaintext, 0) + else + begin + Temp.Position := 0; + Plaintext := Stream_to_string( Temp{$IFDEF UNICODE}, Encoding{$ENDIF}); + end +finally + BurnMemoryStream( Temp); + BurnMemoryStream( Ciphertext); + Temp.Free; + Ciphertext.Free +end end; + + +{$IFDEF UNICODE} +procedure TSimpleCodec.DecryptString( + var Plaintext: string; + const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + +{$IFDEF UNICODE} +procedure TSimpleCodec.EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +{$IFDEF UNICODE} +procedure TSimpleCodec.EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); +end; +{$ENDIF} + + + +procedure TSimpleCodec.EncryptFile( + const Plaintext_FileName, + CipherText_FileName: string); +var + plaintext, ciphertext: TStream; + isPreExists: boolean; +begin +if Plaintext_FileName = '' then + raise Exception.Create( ES_PlaintextFN_Empty); +if Ciphertext_FileName = '' then + raise Exception.Create( ES_CiphertextFN_Empty); +plaintext := TFileStream.Create( Plaintext_FileName, fmOpenRead); +try + isPreExists := FileExists( Ciphertext_FileName); + Ciphertext := TFileStream.Create( + Ciphertext_FileName, FileStreamOpenMode[ isPreExists]); + try + if isPreExists then + Ciphertext.Size := 0; + EncryptStream( plaintext, ciphertext) + finally + CipherText.Free + end +finally + PlainText.Free + end +end; + + + +procedure TSimpleCodec.EncryptMemory( + const Plaintext; PlaintextLen: integer); +var + P: PByte; + L, Amt: integer; + Salt: packed array[ 0..SaltSize-1 ] of byte; +begin +if FisUserAborted then exit; +if FMode <> cmEncrypting then + raise Exception.Create( ES_WrongModeEncryptMem); +P := @Plaintext; +L := PlaintextLen; +if (FXtextCount = 0) and (L > 0) and (not FisSalting) and + (([afCompressor, afConverter, afDoesNotNeedSalt] * + FParameterizedStreamCipher.Features) = []) then + begin + FisSalting := True; + TRandomStream.Instance.Read( Salt, SaltSize); + EncryptMemory( Salt, SaltSize); + FisSalting := False + end; +try +// Break up the plaintext memory into at most 1 KiB chunks. +while (L > 0) and (not FisUserAborted) do + begin + Amt := Min( L, 1024); + if FBuffer.Size > Amt then + BurnMemoryStream( FBuffer); + if FBuffer.Size <> Amt then + FBuffer.Size := Amt; + Move( P^, FBuffer.Memory^, Amt); + FBuffer.Position := 0; + // Encrypt the chunk. + FEnc.Encrypt( FBuffer); + Dec( L, Amt); + Inc( P, Amt); + Inc( FXtextCount, Amt); + // Check for user abort. + if (L > 0) and (not FisSalting) then + DoProgress + end +finally +BurnMemoryStream( FBuffer) +end end; + + +procedure TSimpleCodec.DecryptMemory( + const CipherText{in}; CiphertextLen: integer); +var + P: PByte; + L, Amt: integer; +begin +if FisUserAborted then exit; +if FMode <> cmDecrypting then + raise Exception.Create( ES_WrongModeDecryptMem); +P := @CipherText; +L := CiphertextLen; +try +while (L > 0) and (not FisUserAborted) do + begin + Amt := Min( L, 1024); + if FBuffer.Size > Amt then + BurnMemoryStream( FBuffer); + if FBuffer.Size <> Amt then + FBuffer.Size := Amt; + Move( P^, FBuffer.Memory^, Amt); + FBuffer.Position := 0; + FDec.Decrypt( FBuffer); + Dec( L, Amt); + Inc( P, Amt); + Inc( FXtextCount, Amt); + if L > 0 then + DoProgress + end +finally +BurnMemoryStream( FBuffer) +end end; + + + +procedure TSimpleCodec.EncryptStream( Plaintext, CipherText: TStream); +var + Temp: TMemoryStream; + Amnt, BytesRead: integer; +begin +Temp := TMemoryStream.Create; +try + // Break up stream into at most 1 KiB blocks, but don't needlessly + // oversize the buffer. + Plaintext.Position := 0; + Amnt := Max( Min( PlainText.Size, 1024), 1); + Temp.Size := Amnt; + Begin_EncryptMemory( CipherText); + repeat + if Temp.Size > Amnt then + BurnMemoryStream( Temp); + if Temp.Size <> Amnt then + Temp.Size := Amnt; + BytesRead := PlainText.Read( Temp.Memory^, Amnt); + if BytesRead = 0 then break; + EncryptMemory( Temp.Memory^, BytesRead); + DoProgress + until (BytesRead < Amnt) or FisUserAborted; + End_EncryptMemory +finally + BurnMemoryStream( Temp); + Temp.Free +end end; + + +procedure TSimpleCodec.EncryptString( + const Plaintext: string; + var CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +var + L: integer; + {$IFDEF UNICODE}PlaintextBytes: TBytes;{$ENDIF} + Temp: TMemoryStream; +begin +Temp := TMemoryStream.Create; +try + Begin_EncryptMemory( Temp); + {$IFDEF UNICODE} + PlaintextBytes := Encoding.GetBytes( Plaintext); + L := Length( PlaintextBytes); + {$ELSE} + L := Length( Plaintext) * SizeOf( Char); + {$ENDIF} + EncryptMemory( {$IFDEF UNICODE}PlaintextBytes[0]{$ELSE}Plaintext[1]{$ENDIF}, L); + End_EncryptMemory; + if FisUserAborted then + CipherText_Base64 := '' + else + begin + Temp.Position := 0; + if isNotBase64Converter then + CipherText_Base64 := Stream_to_Base64( Temp) + else + // If its already a Base64 encoder, no point in double-encoding it as base64. + CipherText_Base64 := Stream_to_string( Temp{$IFDEF UNICODE}, TEncoding.UTF8{$ENDIF}) + end +finally + Temp.Free +end end; + + + +{$IFDEF UNICODE} +procedure TSimpleCodec.EncryptString( + const Plaintext: string; + var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure TSimpleCodec.End_DecryptMemory; +begin +case FMode of + cmIdle: begin end; + + cmDecrypting: begin + if not FisUserAborted then + begin + if assigned( FDec) then + FDec.End_Decrypt; + DoProgress; + Reset + end + else + End_EncryptDecrypt + end; + + cmUnitialized, + cmEncrypting: + raise Exception.Create( ES_WrongModeEndDecryptMem); + end +end; + + +procedure TSimpleCodec.End_EncryptMemory; +begin +case FMode of + cmIdle: begin end; + + cmEncrypting: begin + if not FisUserAborted then + begin + if assigned( FEnc) then + FEnc.End_Encrypt; + DoProgress; + Reset + end + else + End_EncryptDecrypt + end; + + cmUnitialized, + cmDecrypting: + raise Exception.Create( ES_WrongModeEndEncryptMem); + end +end; + + + +function TSimpleCodec.GetAsymetricKeySizeInBits: cardinal; +begin +result := FAsymetricKeySizeInBits +end; + +function TSimpleCodec.GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; +begin +result := FAsymGenProgressEvent +end; + +function TSimpleCodec.GetBlockCipher: IBlockCipher; +begin +result := FBlockCipher +end; + +function TSimpleCodec.GetChainMode: IBlockChainingModel; +begin +result := FChainMode +end; + +function TSimpleCodec.GetCipherDisplayName( Lib: TCryptographicLibrary): string; +var + TempCipher: IStreamCipher; +begin +TempCipher := FParameterizedStreamCipher; +if not assigned( TempCipher) and assigned( FStreamCipher) then + TempCipher := FStreamCipher.Parameterize( self); +if not assigned( TempCipher) then + TempCipher := FStreamCipher; +if assigned( TempCipher) then + begin + if assigned( Lib) then + result := Lib.ComputeCipherDisplayName( TempCipher, FBlockCipher) + else + result := TCryptographicLibrary.ComputeCipherDisplayName( TempCipher, FBlockCipher) + end + else + result := '' +end; + + +function TSimpleCodec.GetKey: TSymetricKey; +begin +result := FKey +end; + +function TSimpleCodec.GetMode: TCodecMode; +begin +result := FMode +end; + +function TSimpleCodec.GetOnProgress: TOnEncDecProgress; +begin +result := FOnProgress +end; + + +function TSimpleCodec.GetOnSetIV: TSetMemStreamProc; +begin +result := FOnSetIV +end; + +function TSimpleCodec.GetStreamCipher: IStreamCipher; +begin +result := FStreamCipher +end; + + +function TSimpleCodec.hasOnSetIVHandler( var Proc: TSetMemStreamProc): boolean; +begin + Proc := FOnSetIV; + result := assigned( FOnSetIV) +end; + + + +procedure TSimpleCodec.SaveKeyToStream( Store: TStream); +begin +if assigned( FKey) and assigned( Store) then + FKey.SaveToStream( Store) +end; + + + + + + +procedure TSimpleCodec.SetAsymetricKeySizeInBits( value: cardinal); +begin +if FAsymetricKeySizeInBits = Value then exit; +if FMode in [cmEncrypting, cmDecrypting] then + raise Exception.Create( ES_Asym_CannotSetParam); +FAsymetricKeySizeInBits := Value; +if FMode = cmIdle then + Burn( True); +end; + + + + +procedure TSimpleCodec.SetAsymGenProgressEvent( + Value: TGenerateAsymetricKeyPairProgress); +begin +FAsymGenProgressEvent := value +end; + + + +procedure TSimpleCodec.SetBlockCipher( const Value: IBlockCipher); +begin +if FBlockCipher = Value then exit; +if FMode in [cmEncrypting, cmDecrypting] then + raise Exception.Create( ES_Asym_CannotSetCipher); +if FMode = cmIdle then + Burn( True); +FBlockCipher := Value +end; + + +procedure TSimpleCodec.SetChainMode( const Value: IBlockChainingModel); +begin +if FChainMode = Value then exit; +if FMode in [cmEncrypting, cmDecrypting] then + raise Exception.Create( ES_Asym_CannotSetCipher); +if FMode = cmIdle then + Burn( True); +FChainMode := Value; +end; + + +procedure TSimpleCodec.SetEventSender( Sender: TObject); +begin +FSender := Sender; +if not assigned( FSender) then + FSender := self +end; + + +procedure TSimpleCodec.SetOnProgress( Value: TOnEncDecProgress); +begin +FOnProgress := Value +end; + + + +procedure TSimpleCodec.SetOnSetIV( Value: TSetMemStreamProc); +begin +FOnSetIV := Value +end; + + +procedure TSimpleCodec.SetStreamCipher( const Value: IStreamCipher); +begin +if FStreamCipher = Value then exit; +if FMode in [cmEncrypting, cmDecrypting] then + raise Exception.Create( ES_Asym_CannotSetCipher); +if FMode = cmIdle then + Burn( True); +FStreamCipher := Value +end; + + + + +procedure TSimpleCodec.InitFromGeneratedAsymetricKeyPair; +var + Asymetric_Engine: IAsymetric_Engine; + KeyPair: TAsymetricKeyPair; +begin +if FMode in [cmEncrypting, cmDecrypting] then + Reset; +FMode := cmUnitialized; +FXtextCount := 0; +FreeAndNil( FKey); +FisUserAborted := False; +FEnc := nil; FDec := nil; +FisUserAborted := False; +FisSalting := False; +if (not isAsymetric) or (not (Supports( FParameterizedStreamCipher, + IAsymetric_Engine, Asymetric_Engine))) then + raise Exception.Create( ES_AsymNotInitByStr); +FreeAndNil( FKey); +Asymetric_Engine.GenerateAsymetricKeyPair( + FAsymetricKeySizeInBits, FSender, FAsymGenProgressEvent, KeyPair, + FisUserAborted); +if FisUserAborted then + FMode := cmUnitialized + else + begin + FMode := cmIdle; + FKey := KeyPair + end +end; + + + +procedure TSimpleCodec.Sign( Document, Signature: TStream; + ProgressSender: TObject; ProgressEvent: TOnEncDecProgress; + SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean); +var + Engine: IASymetric_Engine; +// EstimatedWorkLoad: int64; +begin +wasAborted := False; +Engine := Asymetric_Engine; + // The FParameterizedStreamCipher cast as IAsymetric_Engine. + // Typically, this is an instance of TAsymetric_Engine. +// EstimatedWorkLoad := Document.Size; +Engine.Sign( Document, Signature, SigningKeys_PrivatePart as TAsymtricKeyPart, + ProgressSender, ProgressEvent, wasAborted) +end; + + + +function TSimpleCodec.VerifySignature( Document, Signature: TStream; + ProgressSender: TObject; ProgressEvent: TOnEncDecProgress; + SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean): boolean; +var + Engine: IASymetric_Engine; +// EstimatedWorkLoad: int64; +begin +wasAborted := False; +Engine := Asymetric_Engine; + // Typically, this is an instance of TAsymetric_Engine. +// EstimatedWorkLoad := Document.Size; +result := Engine.VerifySignature( + Document, Signature, + SigningKeys_PublicPart as TAsymtricKeyPart, + ProgressSender, ProgressEvent, wasAborted) +end; + + + + +{ TCodec } + +constructor TCodec.Create( AOwner: TComponent); +var + Origin: IEventOrigin; +begin +inherited Create( AOwner); +FCodecObj := TSimpleCodec.Create; +FCodec := FCodecObj as ICodec; +if Supports( FCodecObj, IEventOrigin, Origin) then + Origin.SetEventSender( self); +FCodecObj.FCompOwner := self; +FLib := nil; +FStreamCipherId := ''; +FBlockCipherId := ''; +FChainId := ''; +FIntfCached := False; +FCodec.OnAsymGenProgress := GenerateAsymetricKeyPairProgress_Event; +FCountBytes := 0; +FWorkLoad := 0; +FDuration := 0.0; +FStartTime := Now +end; + + +destructor TCodec.Destroy; +begin +FCodec.Burn( True); +SetLib( nil); +FCodec := nil; +FCodecObj.Free; +ClearPassword; +{$IFDEF UNICODE} +ClearUTF8Password; +{$ENDIF} +inherited +end; + + +procedure TCodec.DefineProperties( Filer: TFiler); +begin +inherited; +Filer.DefineProperty( 'StreamCipherId', ReadData_Stream, WriteData_Stream, True); +Filer.DefineProperty( 'BlockCipherId' , ReadData_Block , WriteData_Block , True); +Filer.DefineProperty( 'ChainId' , ReadData_Chain , WriteData_Chain , True) +end; + + + +procedure TCodec.BeginEncDec; +begin +FCountBytes := 0; +// User to set FWorkLoad +// FDuration to be computed at the end +FStartTime := Now +end; + + +procedure TCodec.EndEncDec; +begin +FDuration := Now - FStartTime +end; + + +procedure TCodec.Begin_EncryptMemory( CipherText: TStream); +begin +InterfacesAreCached := True; +BeginEncDec; +FCodec.Begin_EncryptMemory( Ciphertext) +end; + + +procedure TCodec.Begin_DecryptMemory( Plaintext: TStream); +begin +InterfacesAreCached := True; +BeginEncDec; +FCodec.Begin_DecryptMemory( Plaintext) +end; + + + +procedure TCodec.Burn; +begin +FCodec.Burn( False); +InterfacesAreCached := False; +FCountBytes := 0; +FWorkLoad := 0; +FDuration := 0.0; +FStartTime := 0.0 +end; + + + +{$IFDEF UNICODE} +procedure TCodec.DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +{$IFDEF UNICODE} +procedure TCodec.DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); +end; +{$ENDIF} + + +procedure TCodec.DecryptFile( + const Plaintext_FileName, CipherText_FileName: string); +begin +InterfacesAreCached := True; +BeginEncDec; +FWorkLoad := FileSize( CipherText_FileName); +FCodec.DecryptFile( Plaintext_FileName, CipherText_FileName); +EndEncDec +end; + + +procedure TCodec.DecryptMemory( const CipherText; CiphertextLen: integer); +begin +// No call to BeginEncDec because user should be calling +// Begin/End_EncryptMemory +InterfacesAreCached := True; +FCodec.DecryptMemory( CipherText, CiphertextLen) +end; + + + +procedure TCodec.DecryptStream( Plaintext, CipherText: TStream); +begin +InterfacesAreCached := True; +BeginEncDec; +FWorkLoad := Ciphertext.Size; +FCodec.DecryptStream( Plaintext, CipherText); +EndEncDec +end; + + + +procedure TCodec.DecryptString( + var Plaintext: string; const CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +begin +InterfacesAreCached := True; +BeginEncDec; +FWorkLoad := Length( CipherText_Base64) * SizeOf( Char); +FCodec.DecryptString( Plaintext, CipherText_Base64{$IFDEF UNICODE}, Encoding{$ENDIF}); +EndEncDec +end; + + + +{$IFDEF UNICODE} +procedure TCodec.DecryptString( + var Plaintext: string; const CipherText_Base64: string); +begin + DecryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure TCodec.Dummy( const Value: string); +begin +end; + + + +{$IFDEF UNICODE} +procedure TCodec.EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +{$IFDEF UNICODE} +procedure TCodec.EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.{$IFDEF ANSI}ANSI{$ELSE}ASCII{$ENDIF}); +end; +{$ENDIF} + +procedure TCodec.EncryptFile( + const Plaintext_FileName, CipherText_FileName: string); +begin +InterfacesAreCached := True; +BeginEncDec; +FWorkLoad := FileSize( Plaintext_FileName); +FCodec.EncryptFile( Plaintext_FileName, CipherText_FileName); +EndEncDec; +end; + + + +procedure TCodec.EncryptMemory( const Plaintext; PlaintextLen: integer); +begin +// No call to BeginEncDec because user should be calling +// Begin/End_EncryptMemory +InterfacesAreCached := True; +FCodec.EncryptMemory( Plaintext, PlaintextLen) +end; + + + +procedure TCodec.EncryptStream( Plaintext, CipherText: TStream); +begin +InterfacesAreCached := True; +BeginEncDec; +FWorkLoad := Plaintext.Size; +FCodec.EncryptStream( Plaintext, CipherText); +EndEncDec +end; + + + +procedure TCodec.EncryptString( + const Plaintext: string; var CipherText_Base64: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +begin +InterfacesAreCached := True; +BeginEncDec; +FCodec.EncryptString( Plaintext, CipherText_Base64{$IFDEF UNICODE}, Encoding{$ENDIF}); +EndEncDec +end; + + + +{$IFDEF UNICODE} +procedure TCodec.EncryptString( + const Plaintext: string; var CipherText_Base64: string); +begin + EncryptString( Plaintext, CipherText_Base64, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure TCodec.End_DecryptMemory; +begin +InterfacesAreCached := True; +FCodec.End_DecryptMemory; +EndEncDec +end; + + + +procedure TCodec.End_EncryptMemory; +begin +InterfacesAreCached := True; +FCodec.End_EncryptMemory; +EndEncDec +end; + + + +procedure TCodec.GenerateAsymetricKeyPairProgress_Event( + Sender: TObject; CountPrimalityTests: integer; var doAbort: boolean); +var + CountBytesProcessed1: int64; +begin +if assigned( FCodec.OnProgress) then + begin + CountBytesProcessed1 := -1; + FGenerateAsymetricKeyPairProgress_CountPrimalityTests := CountPrimalityTests; + doAbort := not FCodec.OnProgress( self, CountBytesProcessed1) + end +end; + + +function TCodec.GetAsymetricKeySizeInBits: cardinal; +begin +result := FCodec.AsymetricKeySizeInBits +end; + + +function TCodec.GetChainDisplayName: string; +begin +InterfacesAreCached := True; +if FCodec.ChainMode <> nil then + result := TCryptographicLibrary.ComputeChainDisplayName( FCodec.ChainMode) + else + result := '' +end; + + +function TCodec.GetCipherDisplayName: string; +begin +InterfacesAreCached := True; +result := FCodec.GetCipherDisplayName( FLib) +end; + + + +function TCodec.GetCodecIntf: ICodec; +begin +InterfacesAreCached := True; +result := FCodec +end; + + + +function TCodec.GetKey: TSymetricKey; +begin +InterfacesAreCached := True; +result := FCodec.Key +end; + + + +function TCodec.GetMode: TCodecMode; +begin +result := FCodec.Mode +end; + + +function TCodec.GetOnProgress: TOnHashProgress; +begin +result := FCodec.OnProgress +end; + + +function TCodec.isAsymetric: boolean; +begin +InterfacesAreCached := True; +result := FCodec.isAsymetric +end; + + + +function TCodec.Asymetric_Engine: IAsymetric_Engine; +var + AS1: ICodec_WithAsymetricSupport; +begin +result := nil; +InterfacesAreCached := True; +if Supports( FCodec, ICodec_WithAsymetricSupport, AS1) then + result := AS1.Asymetric_Engine +end; + + + + +function TCodec.GetAborted: boolean; +begin +result := FCodec.isUserAborted +end; + + +function TCodec.GetAdvancedOptions2: TSymetricEncryptionOptionSet; +begin +result := FCodec.GetAdvancedOptions2 +end; + +procedure TCodec.SetAborted( Value: boolean); +begin +FCodec.isUserAborted := Value +end; + + +procedure TCodec.SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); +begin +if FCodec.GetAdvancedOptions2 = Value then exit; +InterfacesAreCached := False; +FCodec.SetAdvancedOptions2( Value) +end; + +procedure TCodec.Loaded; +begin +inherited; +InterfacesAreCached := True +end; + + + +procedure TCodec.Notification( AComponent: TComponent; Operation: TOperation); +begin +inherited; +if (Operation = opRemove) and (AComponent = FLib) then + SetLib( nil) +end; + + + +procedure TCodec.ProgIdsChanged; +begin +InterfacesAreCached := False +end; + + + +procedure TCodec.ReadData_Stream( Reader: TReader); +begin +StreamCipherId := Reader.ReadString +end; + +procedure TCodec.ReadData_Block( Reader: TReader); +begin +BlockCipherId := Reader.ReadString +end; + +procedure TCodec.ReadData_Chain( Reader: TReader); +begin +ChainModeId := Reader.ReadString +end; + + + +procedure TCodec.Reset; +begin +FGenerateAsymetricKeyPairProgress_CountPrimalityTests := 0; +if Mode <> cmUnitialized then + FCodec.Reset; +FCountBytes := 0; +FWorkLoad := 0; +end; + + +procedure TCodec.InitFromGeneratedAsymetricKeyPair; +begin +InterfacesAreCached := True; +FCodec.InitFromGeneratedAsymetricKeyPair +end; + + +procedure TCodec.InitFromKey( Key: TSymetricKey); +begin +InterfacesAreCached := True; +FCodec.InitFromKey( Key) +end; + + +procedure TCodec.InitFromStream( Store: TStream); +begin +InterfacesAreCached := True; +FCodec.InitFromStream( Store); +ClearPassword; // Because not using a password. +{$IFDEF UNICODE} +ClearUTF8Password +{$ENDIF} +end; + + +procedure TCodec.SaveKeyToStream( Store: TStream); +begin +InterfacesAreCached := True; +FCodec.SaveKeyToStream( Store) +end; + + +procedure TCodec.SetAsymetricKeySizeInBits( value: cardinal); +begin +FCodec.AsymetricKeySizeInBits := Value +end; + + + +procedure TCodec.SetBlockCipherId( const Value: string); +begin +if FBlockCipherId = Value then exit; +InterfacesAreCached := False; +FBlockCipherId := Value +end; + + + +procedure TCodec.SetChainId( const Value: string); +begin +if FChainId = Value then exit; +InterfacesAreCached := False; +FChainId := Value +end; + + + +procedure TCodec.ClearPassword; +begin +if FPassword <> '' then + BurnMemory( FPassword[{$IFDEF STRINGHELPER}Low( FPassword){$ELSE}1{$ENDIF}], Length( FPassword) * SizeOf( Char)); +FPassword := '' +end; + +{$IFDEF UNICODE} +procedure TCodec.ClearUTF8Password; +var + PasswordBytes: TBytes; +begin +if FUTF8Password <> '' then + begin + PasswordBytes := TEncoding.UTF8.GetBytes( FUTF8Password); + BurnMemory( FUTF8Password[{$IFDEF STRINGHELPER}Low( FPassword){$ELSE}1{$ENDIF}], Length( PasswordBytes)); + BurnMemory( PasswordBytes[0], Length( PasswordBytes)); + FUTF8Password := '' + end; +end; +{$ENDIF} + +procedure TCodec.SetIntfCached( Value: boolean); +begin +if FIntfCached = Value then exit; +FIntfCached := Value; +FCodec.StreamCipher := nil; +FCodec.BlockCipher := nil; +FCodec.ChainMode := nil; +if FIntfCached and assigned( FLib) then + begin + FCodec.StreamCipher := FLib.StreamCipherIntfc( FStreamCipherId); + FCodec.BlockCipher := FLib.BlockCipherIntfc( FBlockCipherId); + FCodec.ChainMode := FLib.BlockChainingModelIntfc( FChainId); + {$IFDEF UNICODE} + if assigned( FCodec.StreamCipher) then + begin + if FPassword <> '' then + begin + if not FCodec.isAsymetric then + FCodec.Init( FPassword) + end + else if (FUTF8Password <> '') and (not FCodec.isAsymetric) then + FCodec.InitA( FUTF8Password) + end; + {$ELSE} + if (FPassword <> '') and assigned( FCodec.StreamCipher) and (not FCodec.isAsymetric) then + FCodec.Init( FPassword) + {$ENDIF} + end +end; + + + +procedure TCodec.SetLib( Value: TCryptographicLibrary); +var + OldLib: TCryptographicLibrary; +begin +if FLib = Value then exit; +if assigned( FLib) then + begin + OldLib := FLib; + FLib := nil; + OldLib.DegisterWatcher( self); + OldLib.RemoveFreeNotification( self) + end; +InterfacesAreCached := False; +FLib := Value; +if assigned( FLib) then + begin + FLib.FreeNotification( self); + FLib.RegisterWatcher ( self) + end +end; + + + + +procedure TCodec.SetOnProgress( const Value: TOnHashProgress); +begin +FCodec.OnProgress := Value +end; + + + +function TCodec.GetOnSetIV: TSetMemStreamProc; +begin +result := FCodec.GetOnSetIV(); +end; + + +procedure TCodec.SetOnSetIV( Value: TSetMemStreamProc); +begin +FCodec.SetOnSetIV( Value) +end; + +procedure TCodec.SetPassword( const NewPassword: string); +begin +FPassword := NewPassword; +{$IFDEF UNICODE} +if FPassword <> '' then + ClearUTF8Password; +{$ENDIF} +if InterfacesAreCached then + begin + if (FPassword <> '') and assigned( FCodec.StreamCipher) and + (not FCodec.isAsymetric) then + FCodec.Init( FPassword) + end + else + InterfacesAreCached := True +end; + + + +{$IFDEF UNICODE} +procedure TCodec.SetUTF8Password( const NewPassword: string); +begin +FUTF8Password := NewPassword; +if FUTF8Password <> '' then + ClearPassword; +if InterfacesAreCached then + begin + if (FUTF8Password <> '') and assigned( FCodec.StreamCipher) and + (not FCodec.isAsymetric) then + FCodec.InitA( FUTF8Password) + end + else + InterfacesAreCached := True +end; +{$ENDIF} + + + +procedure TCodec.SetStreamCipherId( const Value: string); +begin +if FStreamCipherId = Value then exit; +InterfacesAreCached := False; +FStreamCipherId := Value +end; + + + + +function TCodec.Speed: integer; // In KiB per second. +var + Duration: TDateTime; +begin +try +if FCodec.Mode in [cmEncrypting, cmDecrypting] then + Duration := Now - FStartTime + else + Duration := FDuration; +if Duration > 0.0 then + result := Round( FWorkLoad / (Duration * SecsPerDay * 1024.0)) + else + result := -1 +except + result := -1 +end end; + + +procedure TCodec.WriteData_Block( Writer: TWriter); +begin +Writer.WriteString( FBlockCipherId) +end; + + + +procedure TCodec.WriteData_Stream( Writer: TWriter); +begin +Writer.WriteString( FStreamCipherId) +end; + + + +procedure TCodec.WriteData_Chain( Writer: TWriter); +begin +Writer.WriteString( FChainId) +end; + +end. diff --git a/run/TPLB3.CodecIntf.pas b/LockBox3/run/TPLB3.CodecIntf.pas similarity index 97% rename from run/TPLB3.CodecIntf.pas rename to LockBox3/run/TPLB3.CodecIntf.pas index 5670bdd..fcf04fa 100644 --- a/run/TPLB3.CodecIntf.pas +++ b/LockBox3/run/TPLB3.CodecIntf.pas @@ -1,152 +1,152 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CodecIntf; -interface -uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, - TPLB3.CryptographicLibrary; - -type -TCodecMode = (cmUnitialized, cmIdle, cmEncrypting, cmDecrypting); - -TOnEncDecProgress = function ( Sender: TObject; CountBytesProcessed: int64): boolean of object; - -TGenerateAsymetricKeyPairProgress = procedure ( - Sender: TObject; CountPrimalityTests: integer; - var doAbort: boolean) of object; - -{$M-} -ICodec = interface -{$IFDEF UNICODE} - ['{48B3116A-5681-4E79-9013-8EC89BAC5B35}'] -{$ELSE} - ['{721D22EB-66C7-45B7-B926-D7E5C964AED8}'] -{$ENDIF} - procedure SetStreamCipher( const Value: IStreamCipher); - procedure SetBlockCipher ( const Value: IBlockCipher); - procedure SetChainMode ( const Value: IBlockChainingModel); - function GetMode: TCodecMode; - function GetStreamCipher: IStreamCipher; - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - function GetOnProgress : TOnEncDecProgress; - procedure SetOnProgress( Value: TOnEncDecProgress); - function GetAsymetricKeySizeInBits: cardinal; - procedure SetAsymetricKeySizeInBits( value: cardinal); - function GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; - procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress); - function GetKey: TSymetricKey; - - function GetCipherDisplayName( Lib: TCryptographicLibrary): string; - - procedure Init( const Key: string); overload; -{$IFDEF UNICODE} - procedure Init( const Key: string; Encoding: TEncoding); overload; - procedure InitA( const Key: string); -{$ENDIF} - procedure SaveKeyToStream( Store: TStream); - procedure InitFromStream( Store: TStream); - procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. - procedure Reset; - procedure Burn( doIncludeBurnKey: boolean); - - // Asymetric support - function isAsymetric: boolean; - procedure InitFromGeneratedAsymetricKeyPair; - - procedure Sign( - Document, Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean); - - function VerifySignature( - Document, Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart - var wasAborted: boolean): boolean; - - - procedure Begin_EncryptMemory( CipherText{out}: TStream); - procedure EncryptMemory( const Plaintext{in}; PlaintextLen: integer); - procedure End_EncryptMemory; - - procedure Begin_DecryptMemory( PlainText{out}: TStream); - procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); - procedure End_DecryptMemory; - - procedure EncryptStream( Plaintext, CipherText: TStream); - procedure DecryptStream( Plaintext, CipherText: TStream); - - procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); - procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); - - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; - -{$IFDEF UNICODE} - procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; - procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; - - procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; - - procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; - procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; -{$ENDIF} - - function GetAborted: boolean; - procedure SetAborted( Value: boolean); - function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; - procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); - function GetOnSetIV: TSetMemStreamProc; - procedure SetOnSetIV( Value: TSetMemStreamProc); - - property Mode: TCodecMode read GetMode; - property Key: TSymetricKey read GetKey; - property StreamCipher: IStreamCipher read GetStreamCipher write SetStreamCipher; - property BlockCipher : IBlockCipher read GetBlockCipher write SetBlockCipher; - property ChainMode : IBlockChainingModel read GetChainMode write SetChainMode; - property OnProgress : TOnEncDecProgress read GetonProgress write SetOnProgress; - property AsymetricKeySizeInBits: cardinal read GetAsymetricKeySizeInBits - write SetAsymetricKeySizeInBits; - property OnAsymGenProgress: TGenerateAsymetricKeyPairProgress - read GetAsymGenProgressEvent write SetAsymGenProgressEvent; - property isUserAborted: boolean read GetAborted write SetAborted; - end; - - -implementation - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CodecIntf; +interface +uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, + TPLB3.CryptographicLibrary; + +type +TCodecMode = (cmUnitialized, cmIdle, cmEncrypting, cmDecrypting); + +TOnEncDecProgress = function ( Sender: TObject; CountBytesProcessed: int64): boolean of object; + +TGenerateAsymetricKeyPairProgress = procedure ( + Sender: TObject; CountPrimalityTests: integer; + var doAbort: boolean) of object; + +{$M-} +ICodec = interface +{$IFDEF UNICODE} + ['{48B3116A-5681-4E79-9013-8EC89BAC5B35}'] +{$ELSE} + ['{721D22EB-66C7-45B7-B926-D7E5C964AED8}'] +{$ENDIF} + procedure SetStreamCipher( const Value: IStreamCipher); + procedure SetBlockCipher ( const Value: IBlockCipher); + procedure SetChainMode ( const Value: IBlockChainingModel); + function GetMode: TCodecMode; + function GetStreamCipher: IStreamCipher; + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + function GetOnProgress : TOnEncDecProgress; + procedure SetOnProgress( Value: TOnEncDecProgress); + function GetAsymetricKeySizeInBits: cardinal; + procedure SetAsymetricKeySizeInBits( value: cardinal); + function GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress; + procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress); + function GetKey: TSymetricKey; + + function GetCipherDisplayName( Lib: TCryptographicLibrary): string; + + procedure Init( const Key: string); overload; +{$IFDEF UNICODE} + procedure Init( const Key: string; Encoding: TEncoding); overload; + procedure InitA( const Key: string); +{$ENDIF} + procedure SaveKeyToStream( Store: TStream); + procedure InitFromStream( Store: TStream); + procedure InitFromKey( Key: TSymetricKey); // Transfers ownership. + procedure Reset; + procedure Burn( doIncludeBurnKey: boolean); + + // Asymetric support + function isAsymetric: boolean; + procedure InitFromGeneratedAsymetricKeyPair; + + procedure Sign( + Document, Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + SigningKeys_PrivatePart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean); + + function VerifySignature( + Document, Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + SigningKeys_PublicPart: TObject; // Must be TPLB3.Asymetric.TAsymtricKeyPart + var wasAborted: boolean): boolean; + + + procedure Begin_EncryptMemory( CipherText{out}: TStream); + procedure EncryptMemory( const Plaintext{in}; PlaintextLen: integer); + procedure End_EncryptMemory; + + procedure Begin_DecryptMemory( PlainText{out}: TStream); + procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer); + procedure End_DecryptMemory; + + procedure EncryptStream( Plaintext, CipherText: TStream); + procedure DecryptStream( Plaintext, CipherText: TStream); + + procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string); + procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string); + + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string); overload; + +{$IFDEF UNICODE} + procedure EncryptString( const Plaintext: string; var CipherText_Base64: string; Encoding: TEncoding); overload; + procedure DecryptString( var Plaintext: string; const CipherText_Base64: string; Encoding: TEncoding); overload; + + procedure EncryptAnsistring( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptAnsistring( var Plaintext: string; const CipherText_Base64: string); deprecated; + + procedure EncryptUtf8string( const Plaintext: string; var CipherText_Base64: string); deprecated; + procedure DecryptUtf8string( var Plaintext: string; const CipherText_Base64: string); deprecated; +{$ENDIF} + + function GetAborted: boolean; + procedure SetAborted( Value: boolean); + function GetAdvancedOptions2 : TSymetricEncryptionOptionSet; + procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet); + function GetOnSetIV: TSetMemStreamProc; + procedure SetOnSetIV( Value: TSetMemStreamProc); + + property Mode: TCodecMode read GetMode; + property Key: TSymetricKey read GetKey; + property StreamCipher: IStreamCipher read GetStreamCipher write SetStreamCipher; + property BlockCipher : IBlockCipher read GetBlockCipher write SetBlockCipher; + property ChainMode : IBlockChainingModel read GetChainMode write SetChainMode; + property OnProgress : TOnEncDecProgress read GetonProgress write SetOnProgress; + property AsymetricKeySizeInBits: cardinal read GetAsymetricKeySizeInBits + write SetAsymetricKeySizeInBits; + property OnAsymGenProgress: TGenerateAsymetricKeyPairProgress + read GetAsymGenProgressEvent write SetAsymGenProgressEvent; + property isUserAborted: boolean read GetAborted write SetAborted; + end; + + +implementation + +end. diff --git a/run/TPLB3.Common.inc b/LockBox3/run/TPLB3.Common.inc similarity index 96% rename from run/TPLB3.Common.inc rename to LockBox3/run/TPLB3.Common.inc index fb73ca1..e886c5d 100644 --- a/run/TPLB3.Common.inc +++ b/LockBox3/run/TPLB3.Common.inc @@ -1,41 +1,41 @@ -// XE4 introduces the ability to terminate $IF blocks with $ENDIF, -// and the next-generation (i.e. mobile) compilers deprecate $IFEND -// altogether. This directive suppresses deprecation warnings on -// next-generation compilers. -{$IF CompilerVersion >= 25} - {$LEGACYIFEND ON} -{$IFEND} - -// 2009 introduces TStringBuilder for efficient, future-proof -// concatenation. (Strings will eventually be made immutable on -// next-generation compilers.) -{$IF CompilerVersion >= 21} - {$DEFINE STRINGBUILDER} -{$IFEND} - -// While generics were introduced in 2009, using them in that version -// breaks the build in mysterious ways, so we only enable generics for -// 2010 and above. -{$IF CompilerVersion >= 21} - {$DEFINE GENERICS} -{$IFEND} - -// XE2 and above have built-in ASSEMBLER and CPUX* conditionals. On XE -// and below, assembly is implicitly supported on the Win32 platform. -{$IF CompilerVersion < 23} - {$IFDEF WIN32} - {$DEFINE ASSEMBLER} - {$DEFINE CPUX86} - {$ENDIF} -{$IFEND} - -// XE2 introduces the TEncoding.ANSI character encoding. -{$IF CompilerVersion >= 23} - {$DEFINE ANSI} -{$IFEND} - -// XE3 introduces TStringHelper and support for long strings in Low(). -{$IF CompilerVersion >= 24} - {$DEFINE STRINGHELPER} -{$IFEND} - +// XE4 introduces the ability to terminate $IF blocks with $ENDIF, +// and the next-generation (i.e. mobile) compilers deprecate $IFEND +// altogether. This directive suppresses deprecation warnings on +// next-generation compilers. +{$IF CompilerVersion >= 25} + {$LEGACYIFEND ON} +{$IFEND} + +// 2009 introduces TStringBuilder for efficient, future-proof +// concatenation. (Strings will eventually be made immutable on +// next-generation compilers.) +{$IF CompilerVersion >= 21} + {$DEFINE STRINGBUILDER} +{$IFEND} + +// While generics were introduced in 2009, using them in that version +// breaks the build in mysterious ways, so we only enable generics for +// 2010 and above. +{$IF CompilerVersion >= 21} + {$DEFINE GENERICS} +{$IFEND} + +// XE2 and above have built-in ASSEMBLER and CPUX* conditionals. On XE +// and below, assembly is implicitly supported on the Win32 platform. +{$IF CompilerVersion < 23} + {$IFDEF WIN32} + {$DEFINE ASSEMBLER} + {$DEFINE CPUX86} + {$ENDIF} +{$IFEND} + +// XE2 introduces the TEncoding.ANSI character encoding. +{$IF CompilerVersion >= 23} + {$DEFINE ANSI} +{$IFEND} + +// XE3 introduces TStringHelper and support for long strings in Low(). +{$IF CompilerVersion >= 24} + {$DEFINE STRINGHELPER} +{$IFEND} + diff --git a/run/TPLB3.Compatibility.pas b/LockBox3/run/TPLB3.Compatibility.pas similarity index 95% rename from run/TPLB3.Compatibility.pas rename to LockBox3/run/TPLB3.Compatibility.pas index 5731a7b..7368294 100644 --- a/run/TPLB3.Compatibility.pas +++ b/LockBox3/run/TPLB3.Compatibility.pas @@ -1,48 +1,48 @@ -unit TPLB3.Compatibility; - -interface - -{$IFDEF MSWINDOWS} -uses - Windows; -{$ENDIF} - -{$IF CompilerVersion <= 18} -type - TBytes = packed array of Byte; -{$IFEND} - -// X3 and above have built-in, cross-platform atomic operations (System.Atomic*). -// On XE2 and below, fall back to the Win32 API on MSWINDOWS and non-atomic operations -// on other platforms. -{$IF CompilerVersion < 24} - function AtomicIncrement(var Target: Integer): Integer; - function AtomicDecrement(var Target: Integer): Integer; -{$IFEND} - -implementation - -{$IF CompilerVersion < 24} - function AtomicIncrement(var Target: Integer): Integer; - begin - {$IFDEF MSWINDOWS} - Result := InterlockedIncrement(Target); - {$ELSE} - // TODO: find a platform-specific way of doing this atomically - Inc(Target); - {$ENDIF} - end; - - function AtomicDecrement(var Target: Integer): Integer; - begin - {$IFDEF MSWINDOWS} - Result := InterlockedDecrement(Target); - {$ELSE} - // TODO: find a platform-specific way of doing this atomically - Dec(Target); - {$ENDIF} - end; -{$IFEND} - -end. - +unit TPLB3.Compatibility; + +interface + +{$IFDEF MSWINDOWS} +uses + Windows; +{$ENDIF} + +{$IF CompilerVersion <= 18} +type + TBytes = packed array of Byte; +{$IFEND} + +// X3 and above have built-in, cross-platform atomic operations (System.Atomic*). +// On XE2 and below, fall back to the Win32 API on MSWINDOWS and non-atomic operations +// on other platforms. +{$IF CompilerVersion < 24} + function AtomicIncrement(var Target: Integer): Integer; + function AtomicDecrement(var Target: Integer): Integer; +{$IFEND} + +implementation + +{$IF CompilerVersion < 24} + function AtomicIncrement(var Target: Integer): Integer; + begin + {$IFDEF MSWINDOWS} + Result := InterlockedIncrement(Target); + {$ELSE} + // TODO: find a platform-specific way of doing this atomically + Inc(Target); + {$ENDIF} + end; + + function AtomicDecrement(var Target: Integer): Integer; + begin + {$IFDEF MSWINDOWS} + Result := InterlockedDecrement(Target); + {$ELSE} + // TODO: find a platform-specific way of doing this atomically + Dec(Target); + {$ENDIF} + end; +{$IFEND} + +end. + diff --git a/run/TPLB3.Constants.pas b/LockBox3/run/TPLB3.Constants.pas similarity index 97% rename from run/TPLB3.Constants.pas rename to LockBox3/run/TPLB3.Constants.pas index db704db..abd4d9f 100644 --- a/run/TPLB3.Constants.pas +++ b/LockBox3/run/TPLB3.Constants.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,58 +12,58 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Constants; -interface - -const - -AES_ProgId = 'native.AES-%d'; -Base64_ProgId = 'native.base64'; -CBC_ProgId = 'native.CBC'; -CFB8bit_ProgId = 'native.CFB-8bit'; -CFB_ProgId = 'native.CFB'; -CTR_ProgId = 'native.CTR'; -ECB_ProgId = 'native.ECB'; -MD5_ProgId = 'native.hash.MD5'; -OFB_ProgId = 'native.OFB'; -PCBC_ProgId = 'native.PCBC'; -SHA1_ProgId = 'native.hash.SHA-1'; -SHA224_ProgId = 'native.hash.SHA-224'; -SHA256_ProgId = 'native.hash.SHA-256'; -SHA384_ProgId = 'native.hash.SHA-384'; -SHA512_ProgId = 'native.hash.SHA-512'; -SHA512_224_ProgId = 'native.hash.SHA-512/224'; -SHA512_256_ProgId = 'native.hash.SHA-512/256'; -RSA_ProgId = 'native.RSA'; -BlockCipher_ProgId = 'native.StreamToBlock'; -DES_ProgId = 'native.DES'; -TripleDES_ProgId = 'native.3DES.2'; -TripleDES_KO1_ProgId = 'native.3DES.1'; -Blowfish_ProgId = 'native.Blowfish'; -Twofish_ProgId = 'native.Twofish'; -XXTEA_Large_ProgId = 'native.XXTEA.Large.Littleend'; - - - - -implementation - -end. +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Constants; +interface + +const + +AES_ProgId = 'native.AES-%d'; +Base64_ProgId = 'native.base64'; +CBC_ProgId = 'native.CBC'; +CFB8bit_ProgId = 'native.CFB-8bit'; +CFB_ProgId = 'native.CFB'; +CTR_ProgId = 'native.CTR'; +ECB_ProgId = 'native.ECB'; +MD5_ProgId = 'native.hash.MD5'; +OFB_ProgId = 'native.OFB'; +PCBC_ProgId = 'native.PCBC'; +SHA1_ProgId = 'native.hash.SHA-1'; +SHA224_ProgId = 'native.hash.SHA-224'; +SHA256_ProgId = 'native.hash.SHA-256'; +SHA384_ProgId = 'native.hash.SHA-384'; +SHA512_ProgId = 'native.hash.SHA-512'; +SHA512_224_ProgId = 'native.hash.SHA-512/224'; +SHA512_256_ProgId = 'native.hash.SHA-512/256'; +RSA_ProgId = 'native.RSA'; +BlockCipher_ProgId = 'native.StreamToBlock'; +DES_ProgId = 'native.DES'; +TripleDES_ProgId = 'native.3DES.2'; +TripleDES_KO1_ProgId = 'native.3DES.1'; +Blowfish_ProgId = 'native.Blowfish'; +Twofish_ProgId = 'native.Twofish'; +XXTEA_Large_ProgId = 'native.XXTEA.Large.Littleend'; + + + + +implementation + +end. diff --git a/run/TPLB3.CryptographicLibrary.pas b/LockBox3/run/TPLB3.CryptographicLibrary.pas similarity index 96% rename from run/TPLB3.CryptographicLibrary.pas rename to LockBox3/run/TPLB3.CryptographicLibrary.pas index 80acbdd..8bce731 100644 --- a/run/TPLB3.CryptographicLibrary.pas +++ b/LockBox3/run/TPLB3.CryptographicLibrary.pas @@ -1,1542 +1,1542 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.CryptographicLibrary; -interface -uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.StreamCipher, - TPLB3.BlockCipher, TPLB3.HashDsc, TPLB3.SimpleBlockCipher, - {$IFDEF GENERICS}Generics.Collections{$ELSE}Contnrs{$ENDIF}; - -type - -// The following type is for internal use only. -TCryptoLibStringRef = (cStreamId, sStreamName, cBlockId, cBlockName, - cChainId, cChainName, cHashId, cHashName); - -TCryptographicLibrary = class; - -TOnGenerateKeyFunc = function( Lib: TCryptographicLibrary; Seed: TStream) - : TSymetricKey of object; - -TOnStart_EncryptFunc = function( Lib: TCryptographicLibrary; Key: TSymetricKey; - CipherText: TStream): IStreamEncryptor of object; - -TOnStart_DecryptFunc = function( Lib: TCryptographicLibrary; Key: TSymetricKey; - PlainText : TStream): IStreamDecryptor of object; - -TCustomStreamCipher = class( TPersistent) - private - FLib: TCryptographicLibrary; - FDisplayName: string; - FProgId: string; - FFeatures: TAlgorithmicFeatureSet; - FSeedByteSize: integer; -// FOnGenerateKeyFunc: TOnGenerateKeyFunc; -// FOnStart_EncryptFunc: TOnStart_EncryptFunc; -// FOnStart_DecryptFunc: TOnStart_DecryptFunc; - - procedure SetDisplayName( const Value: string); - procedure SetProgId( const Value: string); - procedure SetFeatures( Value: TAlgorithmicFeatureSet); - procedure SetSeedByteSize( Value: integer); - - constructor Create( Lib1: TCryptographicLibrary); - - public - destructor Destroy; override; - - published - property DisplayName: string read FDisplayName write SetDisplayName; - property ProgId: string read FProgId write SetProgId; - property Features: TAlgorithmicFeatureSet read FFeatures write SetFeatures; - property SeedByteSize: integer read FSeedByteSize write SetSeedByteSize; -// property OnGenerateKey: TOnGenerateKeyFunc read FOnGenerateKeyFunc write FOnGenerateKeyFunc; -// property OnStart_Encrypt: TOnStart_EncryptFunc read FOnStart_EncryptFunc write FOnStart_EncryptFunc; -// property OnStart_Decrypt: TOnStart_DecryptFunc read FOnStart_DecryptFunc write FOnStart_DecryptFunc; - end; - - - -ICryptographicLibraryWatcher = interface - ['{A9170972-FDF5-406B-9010-230E661DAF5C}'] - procedure ProgIdsChanged; - end; - -[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidAndroid)] -TCryptographicLibrary = class( TTPLb_BaseNonVisualComponent) - private - FStreamCiphers: IInterfaceList; // of IStreamCipher - FBlockCiphers : IInterfaceList; // of IBlockCipher - FChainModes : IInterfaceList; // of IBlockChainingModel - FHashes : IInterfaceList; // of IHashDsc - FStreamCiphers_ByProgId: TStrings; - FStreamCiphers_ByDisplayName: TStrings; - FBlockCiphers_ByProgId: TStrings; - FBlockCiphers_ByDisplayName: TStrings; - FChainModes_ByProgId: TStrings; - FChainModes_ByDisplayName: TStrings; - FHashs_ByProgId: TStrings; - FHashs_ByDisplayName: TStrings; - FCustomStreamCipher: TCustomStreamCipher; - FCustomCipherIntf : IStreamCipher; - FWatchers: IInterfaceList; - FOnGenerateKeyFunc: TOnGenerateKeyFunc; - FOnStart_EncryptFunc: TOnStart_EncryptFunc; - FOnStart_DecryptFunc: TOnStart_DecryptFunc; - - function GetStreamCiphers_ByProgId: TStrings; - function GetStreamCiphers_ByDisplayName: TStrings; - function GetStreamCipherDisplayNames( const ProgIdx: string): string; - - function GetBlockCiphers_ByProgId: TStrings; - function GetBlockCiphers_ByDisplayName: TStrings; - function GetBlockCipherDisplayNames( const ProgIdx: string): string; - - function GetChainModes_ByProgId: TStrings; - function GetChainModes_ByDisplayName: TStrings; - function GetChainModesDisplayNames( const ProgIdx: string): string; - - function GetHashs_ByProgId: TStrings; - function GetHashs_ByDisplayName: TStrings; - function GetHashDisplayNames( const ProgIdx: string): string; - - function MeasureDepthUp ( MeasureLimit: integer): integer; - function MeasureDepthDown( MeasureLimit: integer): integer; - - protected - FisDestroying: boolean; - FParentLibrary: TCryptographicLibrary; - FChildLibraries: TObjectList{$IFDEF GENERICS}{$ENDIF}; // of children TCryptographicLibrary. - - procedure SetParentLibrary( Value: TCryptographicLibrary); - procedure Notification( - AComponent: TComponent; Operation: TOperation); override; - - procedure StockStreamCiphers; virtual; - procedure StockBlockCiphers; virtual; - procedure StockHashes; virtual; - procedure StockChainModes; virtual; - - public - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - - function StreamCipherIntfc( const ProgIdx: string): IStreamCipher; - procedure RegisterStreamCipher ( const Registrant: IStreamCipher); - procedure DeregisterStreamCipher( const Registrant: IStreamCipher); - - function BlockCipherIntfc( const ProgIdx: string): IBlockCipher; - procedure RegisterBlockCipher ( const Registrant: IBlockCipher); - procedure DeregisterBlockCipher( const Registrant: IBlockCipher); - - function BlockChainingModelIntfc( const ProgIdx: string): IBlockChainingModel; - procedure RegisterBlockChainingModel ( const Registrant: IBlockChainingModel); - procedure DeregisterBlockChainingModel( const Registrant: IBlockChainingModel); - - function HashIntfc( const ProgIdx: string): IHashDsc; - procedure RegisterHash ( const Registrant: IHashDsc); - procedure DeregisterHash( const Registrant: IHashDsc); - - procedure RegisterWatcher( const Registrant: ICryptographicLibraryWatcher); - procedure DegisterWatcher( const Registrant: ICryptographicLibraryWatcher); - procedure ProgIdsChanged( StackLimit: integer); virtual; - - function RegisterSimpleBlockTransform( - Cls: TSimpleBlockCipherClass; - const ProgId1: string; - const DisplayName1: string; - Features1: TAlgorithmicFeatureSet; - BlockSizeInBytes1: integer - ): string; - - function GetCipherChoices: IInterfaceList; // of ICipherChoice. See below. - class function ComputeCipherDisplayName( - const SCipher: IStreamCipher; const BCipher: IBlockCipher): string; - function GetHashChoices: IInterfaceList; // of IHashDsc. - - class function ComputeHashDisplayName( - const Hash: IHashDsc): string; - - function GetChainChoices: IInterfaceList; // of IChainMode. - - class function ComputeChainDisplayName( - const Chain: IBlockChainingModel): string; - - property StreamCiphers_ByProgId: TStrings read GetStreamCiphers_ByProgId; - property StreamCiphers_ByDisplayName: TStrings read GetStreamCiphers_ByDisplayName; - property StreamCipherDisplayNames[ const ProgIdx: string]: string - read GetStreamCipherDisplayNames; - - property BlockCiphers_ByProgId: TStrings read GetBlockCiphers_ByProgId; - property BlockCiphers_ByDisplayName: TStrings read GetBlockCiphers_ByDisplayName; - property BlockCipherDisplayNames[ const ProgIdx: string]: string - read GetBlockCipherDisplayNames; - - property ChainModes_ByProgId: TStrings read GetChainModes_ByProgId; - property ChainModes_ByDisplayName: TStrings read GetChainModes_ByDisplayName; - property ChainModesDisplayNames[ const ProgIdx: string]: string - read GetChainModesDisplayNames; - - property Hashs_ByProgId: TStrings read GetHashs_ByProgId; - property Hashs_ByDisplayName: TStrings read GetHashs_ByDisplayName; - property HashDisplayNames[ const ProgIdx: string]: string - read GetHashDisplayNames; - published - property ParentLibrary: TCryptographicLibrary - read FParentLibrary - write SetParentLibrary; - - property CustomCipher: TCustomStreamCipher read FCustomStreamCipher; - - property OnCustomCipherGenerateKey: TOnGenerateKeyFunc read FOnGenerateKeyFunc write FOnGenerateKeyFunc; - property OnCustomCipherStart_Encrypt: TOnStart_EncryptFunc read FOnStart_EncryptFunc write FOnStart_EncryptFunc; - property OnCustomCipherStart_Decrypt: TOnStart_DecryptFunc read FOnStart_DecryptFunc write FOnStart_DecryptFunc; - - end; - - -ICipherChoice = interface - ['{62873B03-DB18-4C36-95BF-31B82F38D89E}'] - procedure GetChoiceParams( - var CipherDisplayName: string; - var isBlockCipher: boolean; - var StreamCipherId: string; - var BlockCipherId: string); - end; - -implementation - - - - - - - - - - - -uses - Math, SysUtils, TPLB3.I18n, - - // Chain modes: - TPLB3.ECB, TPLB3.CBC, TPLB3.PCBC, - TPLB3.CFB_Block, TPLB3.CFB_8Bit, TPLB3.OFB, - TPLB3.CTR, - - // Hashes - TPLB3.SHA1, TPLB3.SHA2, TPLB3.MD5, - - // Stream mode - TPLB3.StreamToBlock, TPLB3.Base64, TPLB3.RSA_Engine, TPLB3.XXTEA, - - // Block mode - TPLB3.AES, TPLB3.DES, TPLB3.TDES, TPLB3.BlowFish, TPLB3.TwoFish; - - -const - MaxProgIdChangeCallFrames = 100; - -type -TCryptLibStrings = class( TStrings) - private - FReference: TCryptoLibStringRef; - FLib: TCryptographicLibrary; - FisDestroying: boolean; - - protected - function Get( Index: Integer): string; override; - function GetCount: Integer; override; - - public - constructor Create( Ref1: TCryptoLibStringRef; - Lib1: TCryptographicLibrary); - destructor Destroy; override; - - procedure Clear; override; - procedure Delete(Index: Integer); override; - procedure Insert(Index: Integer; const S: string); override; -end; - - - -{ TCryptographicLibrary } - -class function TCryptographicLibrary.ComputeChainDisplayName( - const Chain: IBlockChainingModel): string; -begin -result := ''; -if not assigned( Chain) then exit; -result := Chain.DisplayName; -if afStar in Chain.Features then - result := result + ' *'; - -if afNotImplementedYet in Chain.Features then - result := result + ' ' + ES_NotImplementedNot_Suffix -end; - - - -class function TCryptographicLibrary.ComputeCipherDisplayName( - const SCipher: IStreamCipher; const BCipher: IBlockCipher): string; -var - Features: TAlgorithmicFeatureSet; - isBlock: boolean; - SizeParam: integer; -begin -Features := []; -isBlock := False; -if assigned( SCipher) then - result := SCipher.DisplayName - else - result := ''; - -if result = '' then - exit - - else if (afBlockAdapter in SCipher.Features) and - assigned( BCipher) then - begin - isBlock := True; - Features := BCipher.Features; - if afDisplayNameOnKeySize in Features then - SizeParam := BCipher.KeySize - else - SizeParam := BCipher.BlockSize; - if (SizeParam > 0) and - {$IFDEF STRINGHELPER}(result.IndexOf( '%d') <> -1){$ELSE}(Pos( '%d', result) > 0){$ENDIF} then - // Block Cipher adapted into a stream cipher. - // The block size is embedded in the display name. - result := Format( result, [SizeParam]) - end - - else - Features := SCipher.Features; - -if afStar in Features then - result := result + ' *'; - -if afNotImplementedYet in Features then - result := result + ' ' + ES_NotImplementedNot_Suffix; - -if isBlock then - result := '[' + result + ']' -end; - - - -class function TCryptographicLibrary.ComputeHashDisplayName( - const Hash: IHashDsc): string; -begin -result := ''; -if not assigned( Hash) then exit; -result := Hash.DisplayName; - -if {$IFDEF STRINGHELPER}(result.IndexOf( '%d') <> -1){$ELSE}Pos( '%d', result) > 0{$ENDIF} then - result := Format( result, [Hash.UpdateSize]); - -if afStar in Hash.Features then - result := result + ' *'; - -if afNotImplementedYet in Hash.Features then - result := result + ' ' + ES_NotImplementedNot_Suffix -end; - - - -constructor TCryptographicLibrary.Create( AOwner: TComponent); -var - j: TCryptoLibStringRef; - -begin -inherited Create( AOwner); -FWatchers := TInterfaceList.Create; -FChainModes := TInterfaceList.Create; -FBlockCiphers := TInterfaceList.Create; -FStreamCiphers := TInterfaceList.Create; -FHashes := TInterfaceList.Create; -for j := Low( TCryptoLibStringRef) to High( TCryptoLibStringRef) do - TCryptLibStrings.Create( j, self); -FParentLibrary := nil; -FChildLibraries := TObjectList{$IFDEF GENERICS}{$ENDIF}.Create( False); // of children TCryptographicLibrary. -TCustomStreamCipher.Create( self); -StockStreamCiphers; -StockBlockCiphers; -StockHashes; -StockChainModes -end; - - -procedure TCryptographicLibrary.StockStreamCiphers; -begin -FStreamCiphers.Add( TStreamToBlock_Adapter.Create); -FStreamCiphers.Add( TBase64Converter.Create); -FStreamCiphers.Add( TRSA_Engine.Create); -FStreamCiphers.Add( TXXTEA_LargeBlock.Create) -end; - - -procedure TCryptographicLibrary.StockBlockCiphers; -begin -FBlockCiphers.Add( TAES.Create( 128)); -FBlockCiphers.Add( TAES.Create( 192)); -FBlockCiphers.Add( TAES.Create( 256)); -FBlockCiphers.Add( TDES.Create); -FBlockCiphers.Add( T3DES.Create); -FBlockCiphers.Add( T3DES_KO1.Create); -FBlockCiphers.Add( TBlowfish.Create); -FBlockCiphers.Add( TTwofish.Create); - -// Uncomment the following when they are ready. -// FBlockCiphers.Add( TMyCodec.Create) - -// and more ... - -end; - - - -procedure TCryptographicLibrary.StockHashes; -var - j: TSHA2FamilyMember; -begin -FHashes.Add( TSHA1.Create); -for j := Low( TSHA2FamilyMember) to High( TSHA2FamilyMember) do - FHashes.Add( TSHA2.Create( j)); -FHashes.Add( TMD5.Create) -// more tbd - -end; - -procedure TCryptographicLibrary.StockChainModes; -begin -FChainModes.Add( TECB.Create); -FChainModes.Add( TCBC.Create); -FChainModes.Add( TCFB_Block.Create); -FChainModes.Add( TOFB.Create); -FChainModes.Add( TCTR.Create); -FChainModes.Add( TCFB_8Bit.Create); -FChainModes.Add( TPCBC.Create); -end; - - - - -destructor TCryptographicLibrary.Destroy; -begin -FisDestroying := True; -ProgIdsChanged( MaxProgIdChangeCallFrames); -SetParentLibrary( nil); -FStreamCiphers_ByProgId.Free; -FStreamCiphers_ByDisplayName.Free; -FBlockCiphers_ByProgId.Free; -FBlockCiphers_ByDisplayName.Free; -FChainModes_ByProgId.Free; -FChainModes_ByDisplayName.Free; -FHashs_ByProgId.Free; -FHashs_ByDisplayName.Free; -FCustomCipherIntf := nil; -FCustomStreamCipher.Free; -inherited; -FChildLibraries.Free; -end; - - -function TCryptographicLibrary.BlockChainingModelIntfc( - const ProgIdx: string): IBlockChainingModel; -var - Idx, j: integer; -begin -result := nil; -if FisDestroying then exit; -Idx := ChainModes_ByProgId.IndexOf( ProgIdx); -if Idx <> -1 then - result := FChainModes[ Idx] as IBlockChainingModel - else - result := nil; -if assigned( result) then exit; -for j := 0 to FChildLibraries.Count - 1 do - begin - result := (FChildLibraries[j] as TCryptographicLibrary) - .BlockChainingModelIntfc( ProgIdx); - if assigned( result) then break - end -end; - - - -function TCryptographicLibrary.BlockCipherIntfc( - const ProgIdx: string): IBlockCipher; -var - Idx, j: integer; -begin -result := nil; -if FisDestroying then exit; -Idx := BlockCiphers_ByProgId.IndexOf( ProgIdx); -if Idx <> -1 then - result := FBlockCiphers[ Idx] as IBlockCipher - else - result := nil; -if assigned( result) then exit; -for j := 0 to FChildLibraries.Count - 1 do - begin - result := (FChildLibraries[j] as TCryptographicLibrary) - .BlockCipherIntfc( ProgIdx); - if assigned( result) then break - end -end; - - - -procedure TCryptographicLibrary.DegisterWatcher( - const Registrant: ICryptographicLibraryWatcher); -begin -FWatchers.Remove( Registrant) -end; - - - -procedure TCryptographicLibrary.DeregisterBlockChainingModel( - const Registrant: IBlockChainingModel); -begin -FChainModes.Remove( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.DeregisterBlockCipher( - const Registrant: IBlockCipher); -begin -FBlockCiphers.Remove( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.DeregisterHash( const Registrant: IHashDsc); -begin -FHashes.Remove( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.DeregisterStreamCipher( - const Registrant: IStreamCipher); -begin -FStreamCiphers.Remove( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - -function TCryptographicLibrary.GetBlockCipherDisplayNames( - const ProgIdx: string): string; -var - Cipher: IBlockCipher; -begin -Cipher := BlockCipherIntfc( ProgIdx); -if assigned( Cipher) then - result := Cipher.DisplayName - else - result := '' -end; - - -function TCryptographicLibrary.GetBlockCiphers_ByDisplayName: TStrings; -begin -if not assigned( FBlockCiphers_ByDisplayName) then - TCryptLibStrings.Create( cBlockName, self); -result := FBlockCiphers_ByDisplayName -end; - - -function TCryptographicLibrary.GetBlockCiphers_ByProgId: TStrings; -begin -if not assigned( FBlockCiphers_ByProgId) then - TCryptLibStrings.Create( cBlockId, self); -result := FBlockCiphers_ByProgId -end; - - - - -function TCryptographicLibrary.GetChainModesDisplayNames( - const ProgIdx: string): string; -var - Cipher: IBlockChainingModel; -begin -Cipher := BlockChainingModelIntfc( ProgIdx); -if assigned( Cipher) then - result := Cipher.DisplayName - else - result := '' -end; - - - -function TCryptographicLibrary.GetChainModes_ByDisplayName: TStrings; -begin -if not assigned( FChainModes_ByDisplayName) then - TCryptLibStrings.Create( cChainName, self); -result := FChainModes_ByDisplayName -end; - - - -function TCryptographicLibrary.GetChainModes_ByProgId: TStrings; -begin -if not assigned( FChainModes_ByProgId) then - TCryptLibStrings.Create( cChainId, self); -result := FChainModes_ByProgId -end; - - -type TCipherChoice = class( TInterfacedObject, - ICipherChoice, IBlockCipherSelector) - private - FBlockCipher: IBlockCipher; - FStreamCipher: IStreamCipher; - FParamStreamCipher: IStreamCipher; - FDisplayName: string; - FisBlockCipher: boolean; - - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - procedure GetChoiceParams( - var CipherDisplayName: string; - var isBlockCipher: boolean; - var StreamCipherId: string; - var BlockCipherId: string); - - constructor Create( const BlockCipher1: IBlockCipher; - const StreamCipher1: IStreamCipher); - end; - - - -function TCryptographicLibrary.GetCipherChoices: IInterfaceList; -var - StreamProgIds, BlockProgIds: TStrings; - BaseStreamCiphers: IInterfaceList; - BaseBlockCiphers: IInterfaceList; - k, l: integer; - StreamCipher2: IStreamCipher; - BlockCipher2: IBlockCipher; - isBlockCipher: boolean; - Addend: TCipherChoice; - DisplayNames: TStrings; - - procedure FindStreamProgIds( Lib: TCryptographicLibrary); - var - j: integer; - StreamCipher1: IStreamCipher; - PId: string; - begin - Pid := FCustomStreamCipher.FProgId; - if (Pid <> '') and (StreamProgIds.IndexOf( StreamCipher1.ProgId) = -1) then - begin - StreamProgIds.Add( Pid); - BaseStreamCiphers.Add( FCustomCipherIntf) - end; - for j := 0 to Lib.FStreamCiphers.Count - 1 do - if Supports( Lib.FStreamCiphers[j], IStreamCipher, StreamCipher1) and - (StreamProgIds.IndexOf( StreamCipher1.ProgId) = -1) then - begin - StreamProgIds.Add( StreamCipher1.ProgId); - BaseStreamCiphers.Add( StreamCipher1) - end; - for j := 0 to FChildLibraries.Count - 1 do - FindStreamProgIds( FChildLibraries[j] as TCryptographicLibrary) - end; - - procedure FindBlockProgIds( Lib: TCryptographicLibrary); - var - j: integer; - BlockCipher1: IBlockCipher; - begin - for j := 0 to Lib.FBlockCiphers.Count - 1 do - if Supports( Lib.FBlockCiphers[j], IBlockCipher, BlockCipher1) and - (BlockProgIds.IndexOf( BlockCipher1.ProgId) = -1) then - begin - BlockProgIds.Add( BlockCipher1.ProgId); - BaseBlockCiphers.Add( BlockCipher1) - end; - for j := 0 to FChildLibraries.Count - 1 do - FindBlockProgIds( FChildLibraries[j] as TCryptographicLibrary) - end; - - procedure IncludeUniqueAddend; - begin - if assigned( Addend) and - (DisplayNames.IndexOf( Addend.FDisplayName) = -1) and - (not (afForRunTimeOnly in Addend.FParamStreamCipher.Features)) then - begin - DisplayNames.Add( Addend.FDisplayName); - result.Add( Addend); - Addend := nil - end - end; - -begin -result := nil; -if FisDestroying then exit; -result := TInterfaceList.Create; -DisplayNames := TStringList.Create; -Addend := nil; -StreamProgIds := TStringList.Create; -BaseStreamCiphers := TInterfaceList.Create; -BlockProgIds := TStringList.Create; -BaseBlockCiphers := TInterfaceList.Create; - -try -FindStreamProgIds( self); -FindBlockProgIds( self); -for k := 0 to StreamProgIds.Count - 1 do - begin - StreamCipher2 := BaseStreamCiphers[k] as IStreamCipher; - isBlockCipher := afBlockAdapter in StreamCipher2.Features; - if not isBlockCipher then - begin - Addend := TCipherChoice.Create( nil, StreamCipher2); - IncludeUniqueAddend; - FreeAndNil( Addend) // Destroy any rejected ones. - end - else - for l := 0 to BlockProgIds.Count - 1 do - begin - BlockCipher2 := BaseBlockCiphers[l] as IBlockCipher; - Addend := TCipherChoice.Create( BlockCipher2, StreamCipher2); - IncludeUniqueAddend; - FreeAndNil( Addend) // Destroy any rejected ones. - end; - end -finally -DisplayNames.Free; -Addend.Free; -StreamProgIds.Free; -BlockProgIds.Free -end end; - - - -function TCryptographicLibrary.GetChainChoices: IInterfaceList; -var - ChainProgIds: TStrings; - DisplayNames: TStrings; - - procedure FindChainProgIds( Lib: TCryptographicLibrary); - var - j: integer; - Chain: IBlockChainingModel; - begin - for j := 0 to Lib.FChainModes.Count - 1 do - if Supports( Lib.FChainModes[j], IBlockChainingModel, Chain) and - (ChainProgIds.IndexOf( Chain.ProgId) = -1) and - (DisplayNames.IndexOf( Chain.DisplayName) = -1) and - (not (afForRunTimeOnly in Chain.Features)) then - begin - ChainProgIds.Add( Chain.ProgId); - DisplayNames.Add( Chain.DisplayName); - result.Add( Chain) - end; - for j := 0 to FChildLibraries.Count - 1 do - FindChainProgIds( FChildLibraries[j] as TCryptographicLibrary) - end; -begin -result := nil; -if FisDestroying then exit; -result := TInterfaceList.Create; -ChainProgIds := TStringList.Create; -DisplayNames := TStringList.Create; -try - FindChainProgIds( self); -finally - ChainProgIds.Free; - DisplayNames.Free -end end; - - - - -function TCryptographicLibrary.GetHashChoices: IInterfaceList; -var - HashProgIds: TStrings; - DisplayNames: TStrings; - - procedure FindHashProgIds( Lib: TCryptographicLibrary); - var - j: integer; - Hash: IHashDsc; - begin - for j := 0 to Lib.FHashes.Count - 1 do - if Supports( Lib.FHashes[j], IHashDsc, Hash) and - (HashProgIds.IndexOf( Hash.ProgId) = -1) and - (DisplayNames.IndexOf( Hash.DisplayName) = -1) and - (not (afForRunTimeOnly in Hash.Features)) then - begin - HashProgIds.Add( Hash.ProgId); - DisplayNames.Add( Hash.DisplayName); - result.Add( Hash) - end; - for j := 0 to FChildLibraries.Count - 1 do - FindHashProgIds( FChildLibraries[j] as TCryptographicLibrary) - end; -begin -result := nil; -if FisDestroying then exit; -result := TInterfaceList.Create; -HashProgIds := TStringList.Create; -DisplayNames := TStringList.Create; -try - FindHashProgIds( self); -finally - HashProgIds.Free; - DisplayNames.Free -end end; - - - - - - - -function TCryptographicLibrary.GetHashDisplayNames( - const ProgIdx: string): string; -var - Hash: IHashDsc; -begin -Hash := HashIntfc( ProgIdx); -if assigned( Hash) then - result := Hash.DisplayName - else - result := '' -end; - - - -function TCryptographicLibrary.GetHashs_ByDisplayName: TStrings; -begin -if not assigned( FHashs_ByDisplayName) then - TCryptLibStrings.Create( cHashName, self); -result := FHashs_ByDisplayName -end; - - - -function TCryptographicLibrary.GetHashs_ByProgId: TStrings; -begin -if not assigned( FHashs_ByProgId) then - TCryptLibStrings.Create( cHashId, self); -result := FHashs_ByProgId -end; - - -function TCryptographicLibrary.GetStreamCipherDisplayNames( - const ProgIdx: string): string; -var - Cipher: IStreamCipher; -begin -Cipher := StreamCipherIntfc( ProgIdx); -if assigned( Cipher) then - result := Cipher.DisplayName - else - result := '' -end; - - - -function TCryptographicLibrary.GetStreamCiphers_ByDisplayName: TStrings; -begin -if not assigned( FStreamCiphers_ByDisplayName) then - TCryptLibStrings.Create( sStreamName, self); -result := FStreamCiphers_ByDisplayName -end; - - - -function TCryptographicLibrary.GetStreamCiphers_ByProgId: TStrings; -begin -if not assigned( FStreamCiphers_ByProgId) then - TCryptLibStrings.Create( cStreamId, self); -result := FStreamCiphers_ByProgId -end; - - - -function TCryptographicLibrary.HashIntfc( const ProgIdx: string): IHashDsc; -var - Idx, j: integer; -begin -result := nil; -if FisDestroying then exit; -Idx := Hashs_ByProgId.IndexOf( ProgIdx); -if Idx <> -1 then - result := FHashes[ Idx] as IHashDsc - else - result := nil; -if assigned( result) then exit; -for j := 0 to FChildLibraries.Count - 1 do - begin - result := (FChildLibraries[j] as TCryptographicLibrary) - .HashIntfc( ProgIdx); - if assigned( result) then break - end -end; - - - -procedure TCryptographicLibrary.RegisterBlockChainingModel( - const Registrant: IBlockChainingModel); -var - Idx: integer; -begin -Idx := FChainModes.IndexOf( Registrant); -if Idx <> -1 then exit; -Idx := ChainModes_ByProgId.IndexOf( Registrant.ProgId); -if Idx <> -1 then - FChainModes.Delete( Idx); // Resolve name conflict -FChainModes.Add( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.RegisterBlockCipher( - const Registrant: IBlockCipher); -var - Idx: integer; -begin -Idx := FBlockCiphers.IndexOf( Registrant); -if Idx <> -1 then exit; -Idx := BlockCiphers_ByProgId.IndexOf( Registrant.ProgId); -if Idx <> -1 then - FBlockCiphers.Delete( Idx); // Resolve name conflict -FBlockCiphers.Add( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.RegisterHash( const Registrant: IHashDsc); -var - Idx: integer; -begin -Idx := FHashes.IndexOf( Registrant); -if Idx <> -1 then exit; -Idx := Hashs_ByProgId.IndexOf( Registrant.ProgId); -if Idx <> -1 then - FHashes.Delete( Idx); // Resolve name conflict -FHashes.Add( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - -function TCryptographicLibrary.RegisterSimpleBlockTransform( - Cls: TSimpleBlockCipherClass; const ProgId1, DisplayName1: string; - Features1: TAlgorithmicFeatureSet; BlockSizeInBytes1: integer): string; -var - Cipher: TSimpleBlockCipher; -begin -Cipher := Cls.Create( ProgId1, DisplayName1, Features1, BlockSizeInBytes1); -result := ProgId1; -RegisterBlockCipher( Cipher) -end; - - - -procedure TCryptographicLibrary.RegisterStreamCipher( - const Registrant: IStreamCipher); -var - Idx: integer; -begin -Idx := FStreamCiphers.IndexOf( Registrant); -if Idx <> -1 then exit; -Idx := StreamCiphers_ByProgId.IndexOf( Registrant.ProgId); -if Idx <> -1 then - FStreamCiphers.Delete( Idx); // Resolve name conflict -FStreamCiphers.Add( Registrant); -ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCryptographicLibrary.RegisterWatcher( - const Registrant: ICryptographicLibraryWatcher); -begin -FWatchers.Add( Registrant) -end; - - - -function TCryptographicLibrary.StreamCipherIntfc( - const ProgIdx: string): IStreamCipher; -var - Idx, j: integer; -begin -result := nil; -if FisDestroying then exit; -if (FCustomStreamCipher.FProgId <> '') and - (FCustomStreamCipher.FProgId = ProgIdx) then - begin - result := FCustomCipherIntf; - exit - end; -Idx := StreamCiphers_ByProgId.IndexOf( ProgIdx); -if Idx <> -1 then - result := FStreamCiphers[ Idx] as IStreamCipher - else - result := nil; -if assigned( result) then exit; -for j := 0 to FChildLibraries.Count - 1 do - begin - result := (FChildLibraries[j] as TCryptographicLibrary) - .StreamCipherIntfc( ProgIdx); - if assigned( result) then break - end -end; - - -function TCryptographicLibrary.MeasureDepthDown( MeasureLimit: integer): integer; -var - W: TCryptographicLibrary; - j, M: integer; -begin -result := 0; -for j := 0 to FChildLibraries.Count - 1 do - begin - W := FChildLibraries[j] as TCryptographicLibrary; - if MeasureLimit > 0 then - M := W.MeasureDepthDown( MeasureLimit-1) - else - M := -1; - if M = -1 then - begin - result := -1; - break - end; - result := Max( result, M + 1) - end; -end; - -function TCryptographicLibrary.MeasureDepthUp( MeasureLimit: integer): integer; -var - W: TCryptographicLibrary; -begin -result := -1; -W := self; -while assigned( W) do - begin - W := W.FParentLibrary; - Inc( result); - if result < MeasureLimit then continue; - result := -1; - break - end -end; - -const MaxDepth = 10; - -procedure TCryptographicLibrary.SetParentLibrary( Value: TCryptographicLibrary); -var - Depth, DepthDown, DepthDown1, DepthDown2, DepthUp: integer; - W: TCryptographicLibrary; - isCircular: boolean; - j: integer; -begin -if FParentLibrary = Value then exit; - -if assigned( Value) then - begin - DepthDown1 := MeasureDepthDown( MaxDepth); - if assigned( Value) then - DepthDown2 := Value.MeasureDepthDown( MaxDepth) - else - DepthDown2 := 0; - if DepthDown1 <> -1 then - Inc( DepthDown1); - if (DepthDown1 <> -1) and (DepthDown2 <> -1) then - DepthDown := Max( DepthDown1, DepthDown2) - else - DepthDown := -1; - if assigned( Value) then - DepthUp := Value.MeasureDepthUp( MaxDepth) - else - DepthUp := 0; - if (DepthDown <> -1) and (DepthUp <> -1) then - Depth := DepthDown + DepthUp - else - Depth := -1; - if (Depth = -1) or (Depth > MaxDepth) then - raise Exception.CreateFmt( ES_LibsChainTooDeep, [MaxDepth]); - W := Value; - isCircular := False; - for j := 0 to 2 * MaxDepth do - begin - if not assigned( W) then break; - isCircular := (W = self) or ((j > 0) and (W = Value)); - if isCircular then break; - W := W.FParentLibrary - end; - if isCircular then - raise Exception.Create( ES_CircularLibs); - end; - -if assigned( FParentLibrary) then - begin - FParentLibrary.RemoveFreeNotification( self); - FParentLibrary.FChildLibraries.Remove( self); - FParentLibrary.ProgIdsChanged( MaxProgIdChangeCallFrames); - FParentLibrary := nil - end; - -FParentLibrary := Value; - -if assigned( FParentLibrary) then - begin - FParentLibrary.FreeNotification( self); - if FParentLibrary.FChildLibraries.IndexOf( self) = -1 then - FParentLibrary.FChildLibraries.Add( self); - FParentLibrary.ProgIdsChanged( MaxProgIdChangeCallFrames) - end; - -end; - - -procedure TCryptographicLibrary.Notification( - AComponent: TComponent; Operation: TOperation); -begin -inherited; -if Operation = opRemove then - begin - if AComponent = FParentLibrary then - SetParentLibrary( nil); - - if FChildLibraries.IndexOf( AComponent) <> -1 then - (AComponent as TCryptographicLibrary).SetParentLibrary( nil) - end; -end; - - -procedure TCryptographicLibrary.ProgIdsChanged( StackLimit: integer); -var - j: integer; - W: ICryptographicLibraryWatcher; -begin -if StackLimit <= 0 then exit; // Protect against stack overflow. -for j := 0 to FWatchers.Count - 1 do - if Supports( FWatchers[j], ICryptographicLibraryWatcher, W) then - W.ProgIdsChanged; - -if assigned( FParentLibrary) then - FParentLibrary.ProgIdsChanged( StackLimit - 1) -end; - - - -{ TCryptLibStrings } - -constructor TCryptLibStrings.Create( - Ref1: TCryptoLibStringRef; Lib1: TCryptographicLibrary); -var - ParentRef: ^TStrings; -begin -FReference := Ref1; -FLib := Lib1; -FisDestroying := False; -ParentRef := nil; -if assigned( FLib) then - case FReference of - cStreamId: ParentRef := @ FLib.FStreamCiphers_ByProgId; - sStreamName: ParentRef := @ FLib.FStreamCiphers_ByDisplayName; - cBlockId: ParentRef := @ FLib.FBlockCiphers_ByProgId; - cBlockName: ParentRef := @ FLib.FBlockCiphers_ByDisplayName; - cChainId: ParentRef := @ FLib.FChainModes_ByProgId; - cChainName: ParentRef := @ FLib.FChainModes_ByDisplayName; - cHashId: ParentRef := @ FLib.FHashs_ByProgId; - cHashName: ParentRef := @ FLib.FHashs_ByDisplayName; - end; -if ParentRef^ = nil then - ParentRef^ := self -end; - -procedure TCryptLibStrings.Clear; -begin -end; - - -procedure TCryptLibStrings.Delete( Index: Integer); -begin -end; - - -destructor TCryptLibStrings.Destroy; -var - ParentRef: ^TStrings; -begin -FisDestroying := True; -ParentRef := nil; -if assigned( FLib) then - case FReference of - cStreamId: ParentRef := @ FLib.FStreamCiphers_ByProgId; - sStreamName: ParentRef := @ FLib.FStreamCiphers_ByDisplayName; - cBlockId: ParentRef := @ FLib.FBlockCiphers_ByProgId; - cBlockName: ParentRef := @ FLib.FBlockCiphers_ByDisplayName; - cChainId: ParentRef := @ FLib.FChainModes_ByProgId; - cChainName: ParentRef := @ FLib.FChainModes_ByDisplayName; - cHashId: ParentRef := @ FLib.FHashs_ByProgId; - cHashName: ParentRef := @ FLib.FHashs_ByDisplayName; - end; -if ParentRef^ = self then - ParentRef^ := nil; -inherited -end; - - -function TCryptLibStrings.Get( Index: Integer): string; -begin -result := ''; -if assigned( FLib) then - case FReference of - cStreamId: result := (FLib.FStreamCiphers[ Index] as IStreamCipher).ProgId; - sStreamName: result := (FLib.FStreamCiphers[ Index] as IStreamCipher ).DisplayName; - cBlockId: result := (FLib.FBlockCiphers [ Index] as IBlockCipher ).ProgId; - cBlockName: result := (FLib.FBlockCiphers [ Index] as IBlockCipher ).DisplayName; - cChainId: result := (FLib.FChainModes [ Index] as IBlockChainingModel).ProgId; - cChainName: result := (FLib.FChainModes [ Index] as IBlockChainingModel).DisplayName; - cHashId: result := (FLib.FHashes [ Index] as IHashDsc ).ProgId; - cHashName: result := (FLib.FHashes [ Index] as IHashDsc ).DisplayName; - end -end; - - - -function TCryptLibStrings.GetCount: Integer; -begin -result := 0; -if assigned( FLib) then - case FReference of - cStreamId, - sStreamName: result := FLib.FStreamCiphers.Count; - cBlockId, - cBlockName: result := FLib.FBlockCiphers.Count; - cChainId, - cChainName: result := FLib.FChainModes.Count; - cHashId, - cHashName: result := FLib.FHashes.Count; - end -end; - - - -procedure TCryptLibStrings.Insert( Index: Integer; const S: string); -begin -end; - - - -{ TCipherChoice } - -constructor TCipherChoice.Create( - const BlockCipher1: IBlockCipher; const StreamCipher1: IStreamCipher); -begin -FBlockCipher := BlockCipher1; -FStreamCipher := StreamCipher1; -FisBlockCipher := assigned( FBlockCipher); -FParamStreamCipher := nil; -if assigned( FStreamCipher) then - FParamStreamCipher := FStreamCipher.Parameterize( self); -if not assigned( FParamStreamCipher) then - FParamStreamCipher := FStreamCipher; -FDisplayName := TCryptographicLibrary - .ComputeCipherDisplayName( FParamStreamCipher, FBlockCipher) -end; - - - -function TCipherChoice.GetBlockCipher: IBlockCipher; -begin -result := FBlockCipher -end; - - - -function TCipherChoice.GetChainMode: IBlockChainingModel; -begin -result := nil -end; - - -procedure TCipherChoice.GetChoiceParams( - var CipherDisplayName: string; - var isBlockCipher: boolean; var StreamCipherId, BlockCipherId: string); -begin -CipherDisplayName := FDisplayName; -isBlockCipher := FisBlockCipher; -if assigned( FStreamCipher) then - StreamCipherId := FStreamCipher.ProgId - else - StreamCipherId := ''; -if assigned( FBlockCipher) then - BlockCipherId := FBlockCipher.ProgId - else - BlockCipherId := ''; -end; - -type -TCustomStreamCipherObj = class( TInterfacedObject, - ICryptoGraphicAlgorithm, IStreamCipher) - private - FPrstnt: TCustomStreamCipher; - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; - function DefinitionURL: string; - function WikipediaReference: string; - constructor Create( Prstnt1: TCustomStreamCipher); - end; - -{ TCustomStreamCipher } - -constructor TCustomStreamCipher.Create( Lib1: TCryptographicLibrary); -begin -FLib := Lib1; -FLib.FCustomStreamCipher := self; -FLib.FCustomCipherIntf := TCustomStreamCipherObj.Create( self) -end; - -destructor TCustomStreamCipher.Destroy; -begin -FLib.FCustomCipherIntf := nil; -FLib.FCustomStreamCipher := nil; -inherited -end; - - -procedure TCustomStreamCipher.SetDisplayName(const Value: string); -begin -if FDisplayName = Value then exit; -FDisplayName := Value; -FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCustomStreamCipher.SetFeatures( Value: TAlgorithmicFeatureSet); -begin -if FFeatures = Value then exit; -FFeatures := Value; -FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCustomStreamCipher.SetProgId( const Value: string); -begin -if FProgId = Value then exit; -FProgId := Value; -FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - - - -procedure TCustomStreamCipher.SetSeedByteSize( Value: integer); -begin -if FSeedByteSize = Value then exit; -FSeedByteSize := Value; -FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) -end; - -{ TCustomStreamCipherObj } - -constructor TCustomStreamCipherObj.Create( Prstnt1: TCustomStreamCipher); -begin -FPrstnt := Prstnt1 -end; - - - -function TCustomStreamCipherObj.DefinitionURL: string; -begin -result := '' -end; - -function TCustomStreamCipherObj.DisplayName: string; -begin -result := FPrstnt.DisplayName -end; - - - -function TCustomStreamCipherObj.Features: TAlgorithmicFeatureSet; -begin -result := FPrstnt.Features -end; - - - - -function TCustomStreamCipherObj.GenerateKey( Seed: TStream): TSymetricKey; -begin -if assigned( FPrstnt.FLib.FOnGenerateKeyFunc) then - result := FPrstnt.FLib.FOnGenerateKeyFunc( FPrstnt.FLib, Seed) - else - result := nil -end; - - - -function TCustomStreamCipherObj.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := nil -end; - - -function TCustomStreamCipherObj.Parameterize( - const Params: IInterface): IStreamCipher; -begin -result := nil -end; - - - -function TCustomStreamCipherObj.ProgId: string; -begin -result := FPrstnt.FProgId -end; - - - -function TCustomStreamCipherObj.SeedByteSize: integer; -begin -result := FPrstnt.FSeedByteSize -end; - - - -function TCustomStreamCipherObj.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin -if assigned( FPrstnt.FLib.FOnStart_DecryptFunc) then - result := FPrstnt.FLib.FOnStart_DecryptFunc( FPrstnt.FLib, Key, PlainText) - else - result := nil -end; - - -function TCustomStreamCipherObj.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -if assigned( FPrstnt.FLib.FOnStart_EncryptFunc) then - result := FPrstnt.FLib.FOnStart_EncryptFunc( FPrstnt.FLib, Key, CipherText) - else - result := nil -end; - -function TCustomStreamCipherObj.WikipediaReference: string; -begin -result := '' -end; - -{ -LockBox 2 Hashes -================ -MD5 -SHA1 - -DCP Hashes -========== -havel -MD4 -MD5 -RIPEMD128 -RIPEMD160 -SHA1 -SHA256 -SHA384 -SHA512 -Tiger - -LockBox 2 Ciphers -================= -Blowfish -DES -3DES -Rijndael - -DCP Ciphers -=========== -Blowfish -cast128 -cast256 -DES -3DES -gost -ice -ThinIce -ice2 -idea -mars -misty1 -rc2 -rc4 -rc5 -rc6 -Rijndael -serpent -tea -twofish - -Ciphers for best standards support -================================== -AES-128 -AES-192 -AES-256 -3DES -IDEA -CAST-128 -Serpent -TwoFish - -LockBox 2 Extras -================ -RSA -DSA -RSA SSA -} -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.CryptographicLibrary; +interface +uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.StreamCipher, + TPLB3.BlockCipher, TPLB3.HashDsc, TPLB3.SimpleBlockCipher, + {$IFDEF GENERICS}Generics.Collections{$ELSE}Contnrs{$ENDIF}; + +type + +// The following type is for internal use only. +TCryptoLibStringRef = (cStreamId, sStreamName, cBlockId, cBlockName, + cChainId, cChainName, cHashId, cHashName); + +TCryptographicLibrary = class; + +TOnGenerateKeyFunc = function( Lib: TCryptographicLibrary; Seed: TStream) + : TSymetricKey of object; + +TOnStart_EncryptFunc = function( Lib: TCryptographicLibrary; Key: TSymetricKey; + CipherText: TStream): IStreamEncryptor of object; + +TOnStart_DecryptFunc = function( Lib: TCryptographicLibrary; Key: TSymetricKey; + PlainText : TStream): IStreamDecryptor of object; + +TCustomStreamCipher = class( TPersistent) + private + FLib: TCryptographicLibrary; + FDisplayName: string; + FProgId: string; + FFeatures: TAlgorithmicFeatureSet; + FSeedByteSize: integer; +// FOnGenerateKeyFunc: TOnGenerateKeyFunc; +// FOnStart_EncryptFunc: TOnStart_EncryptFunc; +// FOnStart_DecryptFunc: TOnStart_DecryptFunc; + + procedure SetDisplayName( const Value: string); + procedure SetProgId( const Value: string); + procedure SetFeatures( Value: TAlgorithmicFeatureSet); + procedure SetSeedByteSize( Value: integer); + + constructor Create( Lib1: TCryptographicLibrary); + + public + destructor Destroy; override; + + published + property DisplayName: string read FDisplayName write SetDisplayName; + property ProgId: string read FProgId write SetProgId; + property Features: TAlgorithmicFeatureSet read FFeatures write SetFeatures; + property SeedByteSize: integer read FSeedByteSize write SetSeedByteSize; +// property OnGenerateKey: TOnGenerateKeyFunc read FOnGenerateKeyFunc write FOnGenerateKeyFunc; +// property OnStart_Encrypt: TOnStart_EncryptFunc read FOnStart_EncryptFunc write FOnStart_EncryptFunc; +// property OnStart_Decrypt: TOnStart_DecryptFunc read FOnStart_DecryptFunc write FOnStart_DecryptFunc; + end; + + + +ICryptographicLibraryWatcher = interface + ['{A9170972-FDF5-406B-9010-230E661DAF5C}'] + procedure ProgIdsChanged; + end; + +[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidAndroid)] +TCryptographicLibrary = class( TTPLb_BaseNonVisualComponent) + private + FStreamCiphers: IInterfaceList; // of IStreamCipher + FBlockCiphers : IInterfaceList; // of IBlockCipher + FChainModes : IInterfaceList; // of IBlockChainingModel + FHashes : IInterfaceList; // of IHashDsc + FStreamCiphers_ByProgId: TStrings; + FStreamCiphers_ByDisplayName: TStrings; + FBlockCiphers_ByProgId: TStrings; + FBlockCiphers_ByDisplayName: TStrings; + FChainModes_ByProgId: TStrings; + FChainModes_ByDisplayName: TStrings; + FHashs_ByProgId: TStrings; + FHashs_ByDisplayName: TStrings; + FCustomStreamCipher: TCustomStreamCipher; + FCustomCipherIntf : IStreamCipher; + FWatchers: IInterfaceList; + FOnGenerateKeyFunc: TOnGenerateKeyFunc; + FOnStart_EncryptFunc: TOnStart_EncryptFunc; + FOnStart_DecryptFunc: TOnStart_DecryptFunc; + + function GetStreamCiphers_ByProgId: TStrings; + function GetStreamCiphers_ByDisplayName: TStrings; + function GetStreamCipherDisplayNames( const ProgIdx: string): string; + + function GetBlockCiphers_ByProgId: TStrings; + function GetBlockCiphers_ByDisplayName: TStrings; + function GetBlockCipherDisplayNames( const ProgIdx: string): string; + + function GetChainModes_ByProgId: TStrings; + function GetChainModes_ByDisplayName: TStrings; + function GetChainModesDisplayNames( const ProgIdx: string): string; + + function GetHashs_ByProgId: TStrings; + function GetHashs_ByDisplayName: TStrings; + function GetHashDisplayNames( const ProgIdx: string): string; + + function MeasureDepthUp ( MeasureLimit: integer): integer; + function MeasureDepthDown( MeasureLimit: integer): integer; + + protected + FisDestroying: boolean; + FParentLibrary: TCryptographicLibrary; + FChildLibraries: TObjectList{$IFDEF GENERICS}{$ENDIF}; // of children TCryptographicLibrary. + + procedure SetParentLibrary( Value: TCryptographicLibrary); + procedure Notification( + AComponent: TComponent; Operation: TOperation); override; + + procedure StockStreamCiphers; virtual; + procedure StockBlockCiphers; virtual; + procedure StockHashes; virtual; + procedure StockChainModes; virtual; + + public + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + + function StreamCipherIntfc( const ProgIdx: string): IStreamCipher; + procedure RegisterStreamCipher ( const Registrant: IStreamCipher); + procedure DeregisterStreamCipher( const Registrant: IStreamCipher); + + function BlockCipherIntfc( const ProgIdx: string): IBlockCipher; + procedure RegisterBlockCipher ( const Registrant: IBlockCipher); + procedure DeregisterBlockCipher( const Registrant: IBlockCipher); + + function BlockChainingModelIntfc( const ProgIdx: string): IBlockChainingModel; + procedure RegisterBlockChainingModel ( const Registrant: IBlockChainingModel); + procedure DeregisterBlockChainingModel( const Registrant: IBlockChainingModel); + + function HashIntfc( const ProgIdx: string): IHashDsc; + procedure RegisterHash ( const Registrant: IHashDsc); + procedure DeregisterHash( const Registrant: IHashDsc); + + procedure RegisterWatcher( const Registrant: ICryptographicLibraryWatcher); + procedure DegisterWatcher( const Registrant: ICryptographicLibraryWatcher); + procedure ProgIdsChanged( StackLimit: integer); virtual; + + function RegisterSimpleBlockTransform( + Cls: TSimpleBlockCipherClass; + const ProgId1: string; + const DisplayName1: string; + Features1: TAlgorithmicFeatureSet; + BlockSizeInBytes1: integer + ): string; + + function GetCipherChoices: IInterfaceList; // of ICipherChoice. See below. + class function ComputeCipherDisplayName( + const SCipher: IStreamCipher; const BCipher: IBlockCipher): string; + function GetHashChoices: IInterfaceList; // of IHashDsc. + + class function ComputeHashDisplayName( + const Hash: IHashDsc): string; + + function GetChainChoices: IInterfaceList; // of IChainMode. + + class function ComputeChainDisplayName( + const Chain: IBlockChainingModel): string; + + property StreamCiphers_ByProgId: TStrings read GetStreamCiphers_ByProgId; + property StreamCiphers_ByDisplayName: TStrings read GetStreamCiphers_ByDisplayName; + property StreamCipherDisplayNames[ const ProgIdx: string]: string + read GetStreamCipherDisplayNames; + + property BlockCiphers_ByProgId: TStrings read GetBlockCiphers_ByProgId; + property BlockCiphers_ByDisplayName: TStrings read GetBlockCiphers_ByDisplayName; + property BlockCipherDisplayNames[ const ProgIdx: string]: string + read GetBlockCipherDisplayNames; + + property ChainModes_ByProgId: TStrings read GetChainModes_ByProgId; + property ChainModes_ByDisplayName: TStrings read GetChainModes_ByDisplayName; + property ChainModesDisplayNames[ const ProgIdx: string]: string + read GetChainModesDisplayNames; + + property Hashs_ByProgId: TStrings read GetHashs_ByProgId; + property Hashs_ByDisplayName: TStrings read GetHashs_ByDisplayName; + property HashDisplayNames[ const ProgIdx: string]: string + read GetHashDisplayNames; + published + property ParentLibrary: TCryptographicLibrary + read FParentLibrary + write SetParentLibrary; + + property CustomCipher: TCustomStreamCipher read FCustomStreamCipher; + + property OnCustomCipherGenerateKey: TOnGenerateKeyFunc read FOnGenerateKeyFunc write FOnGenerateKeyFunc; + property OnCustomCipherStart_Encrypt: TOnStart_EncryptFunc read FOnStart_EncryptFunc write FOnStart_EncryptFunc; + property OnCustomCipherStart_Decrypt: TOnStart_DecryptFunc read FOnStart_DecryptFunc write FOnStart_DecryptFunc; + + end; + + +ICipherChoice = interface + ['{62873B03-DB18-4C36-95BF-31B82F38D89E}'] + procedure GetChoiceParams( + var CipherDisplayName: string; + var isBlockCipher: boolean; + var StreamCipherId: string; + var BlockCipherId: string); + end; + +implementation + + + + + + + + + + + +uses + Math, SysUtils, TPLB3.I18n, + + // Chain modes: + TPLB3.ECB, TPLB3.CBC, TPLB3.PCBC, + TPLB3.CFB_Block, TPLB3.CFB_8Bit, TPLB3.OFB, + TPLB3.CTR, + + // Hashes + TPLB3.SHA1, TPLB3.SHA2, TPLB3.MD5, + + // Stream mode + TPLB3.StreamToBlock, TPLB3.Base64, TPLB3.RSA_Engine, TPLB3.XXTEA, + + // Block mode + TPLB3.AES, TPLB3.DES, TPLB3.TDES, TPLB3.BlowFish, TPLB3.TwoFish; + + +const + MaxProgIdChangeCallFrames = 100; + +type +TCryptLibStrings = class( TStrings) + private + FReference: TCryptoLibStringRef; + FLib: TCryptographicLibrary; + FisDestroying: boolean; + + protected + function Get( Index: Integer): string; override; + function GetCount: Integer; override; + + public + constructor Create( Ref1: TCryptoLibStringRef; + Lib1: TCryptographicLibrary); + destructor Destroy; override; + + procedure Clear; override; + procedure Delete(Index: Integer); override; + procedure Insert(Index: Integer; const S: string); override; +end; + + + +{ TCryptographicLibrary } + +class function TCryptographicLibrary.ComputeChainDisplayName( + const Chain: IBlockChainingModel): string; +begin +result := ''; +if not assigned( Chain) then exit; +result := Chain.DisplayName; +if afStar in Chain.Features then + result := result + ' *'; + +if afNotImplementedYet in Chain.Features then + result := result + ' ' + ES_NotImplementedNot_Suffix +end; + + + +class function TCryptographicLibrary.ComputeCipherDisplayName( + const SCipher: IStreamCipher; const BCipher: IBlockCipher): string; +var + Features: TAlgorithmicFeatureSet; + isBlock: boolean; + SizeParam: integer; +begin +Features := []; +isBlock := False; +if assigned( SCipher) then + result := SCipher.DisplayName + else + result := ''; + +if result = '' then + exit + + else if (afBlockAdapter in SCipher.Features) and + assigned( BCipher) then + begin + isBlock := True; + Features := BCipher.Features; + if afDisplayNameOnKeySize in Features then + SizeParam := BCipher.KeySize + else + SizeParam := BCipher.BlockSize; + if (SizeParam > 0) and + {$IFDEF STRINGHELPER}(result.IndexOf( '%d') <> -1){$ELSE}(Pos( '%d', result) > 0){$ENDIF} then + // Block Cipher adapted into a stream cipher. + // The block size is embedded in the display name. + result := Format( result, [SizeParam]) + end + + else + Features := SCipher.Features; + +if afStar in Features then + result := result + ' *'; + +if afNotImplementedYet in Features then + result := result + ' ' + ES_NotImplementedNot_Suffix; + +if isBlock then + result := '[' + result + ']' +end; + + + +class function TCryptographicLibrary.ComputeHashDisplayName( + const Hash: IHashDsc): string; +begin +result := ''; +if not assigned( Hash) then exit; +result := Hash.DisplayName; + +if {$IFDEF STRINGHELPER}(result.IndexOf( '%d') <> -1){$ELSE}Pos( '%d', result) > 0{$ENDIF} then + result := Format( result, [Hash.UpdateSize]); + +if afStar in Hash.Features then + result := result + ' *'; + +if afNotImplementedYet in Hash.Features then + result := result + ' ' + ES_NotImplementedNot_Suffix +end; + + + +constructor TCryptographicLibrary.Create( AOwner: TComponent); +var + j: TCryptoLibStringRef; + +begin +inherited Create( AOwner); +FWatchers := TInterfaceList.Create; +FChainModes := TInterfaceList.Create; +FBlockCiphers := TInterfaceList.Create; +FStreamCiphers := TInterfaceList.Create; +FHashes := TInterfaceList.Create; +for j := Low( TCryptoLibStringRef) to High( TCryptoLibStringRef) do + TCryptLibStrings.Create( j, self); +FParentLibrary := nil; +FChildLibraries := TObjectList{$IFDEF GENERICS}{$ENDIF}.Create( False); // of children TCryptographicLibrary. +TCustomStreamCipher.Create( self); +StockStreamCiphers; +StockBlockCiphers; +StockHashes; +StockChainModes +end; + + +procedure TCryptographicLibrary.StockStreamCiphers; +begin +FStreamCiphers.Add( TStreamToBlock_Adapter.Create); +FStreamCiphers.Add( TBase64Converter.Create); +FStreamCiphers.Add( TRSA_Engine.Create); +FStreamCiphers.Add( TXXTEA_LargeBlock.Create) +end; + + +procedure TCryptographicLibrary.StockBlockCiphers; +begin +FBlockCiphers.Add( TAES.Create( 128)); +FBlockCiphers.Add( TAES.Create( 192)); +FBlockCiphers.Add( TAES.Create( 256)); +FBlockCiphers.Add( TDES.Create); +FBlockCiphers.Add( T3DES.Create); +FBlockCiphers.Add( T3DES_KO1.Create); +FBlockCiphers.Add( TBlowfish.Create); +FBlockCiphers.Add( TTwofish.Create); + +// Uncomment the following when they are ready. +// FBlockCiphers.Add( TMyCodec.Create) + +// and more ... + +end; + + + +procedure TCryptographicLibrary.StockHashes; +var + j: TSHA2FamilyMember; +begin +FHashes.Add( TSHA1.Create); +for j := Low( TSHA2FamilyMember) to High( TSHA2FamilyMember) do + FHashes.Add( TSHA2.Create( j)); +FHashes.Add( TMD5.Create) +// more tbd + +end; + +procedure TCryptographicLibrary.StockChainModes; +begin +FChainModes.Add( TECB.Create); +FChainModes.Add( TCBC.Create); +FChainModes.Add( TCFB_Block.Create); +FChainModes.Add( TOFB.Create); +FChainModes.Add( TCTR.Create); +FChainModes.Add( TCFB_8Bit.Create); +FChainModes.Add( TPCBC.Create); +end; + + + + +destructor TCryptographicLibrary.Destroy; +begin +FisDestroying := True; +ProgIdsChanged( MaxProgIdChangeCallFrames); +SetParentLibrary( nil); +FStreamCiphers_ByProgId.Free; +FStreamCiphers_ByDisplayName.Free; +FBlockCiphers_ByProgId.Free; +FBlockCiphers_ByDisplayName.Free; +FChainModes_ByProgId.Free; +FChainModes_ByDisplayName.Free; +FHashs_ByProgId.Free; +FHashs_ByDisplayName.Free; +FCustomCipherIntf := nil; +FCustomStreamCipher.Free; +inherited; +FChildLibraries.Free; +end; + + +function TCryptographicLibrary.BlockChainingModelIntfc( + const ProgIdx: string): IBlockChainingModel; +var + Idx, j: integer; +begin +result := nil; +if FisDestroying then exit; +Idx := ChainModes_ByProgId.IndexOf( ProgIdx); +if Idx <> -1 then + result := FChainModes[ Idx] as IBlockChainingModel + else + result := nil; +if assigned( result) then exit; +for j := 0 to FChildLibraries.Count - 1 do + begin + result := (FChildLibraries[j] as TCryptographicLibrary) + .BlockChainingModelIntfc( ProgIdx); + if assigned( result) then break + end +end; + + + +function TCryptographicLibrary.BlockCipherIntfc( + const ProgIdx: string): IBlockCipher; +var + Idx, j: integer; +begin +result := nil; +if FisDestroying then exit; +Idx := BlockCiphers_ByProgId.IndexOf( ProgIdx); +if Idx <> -1 then + result := FBlockCiphers[ Idx] as IBlockCipher + else + result := nil; +if assigned( result) then exit; +for j := 0 to FChildLibraries.Count - 1 do + begin + result := (FChildLibraries[j] as TCryptographicLibrary) + .BlockCipherIntfc( ProgIdx); + if assigned( result) then break + end +end; + + + +procedure TCryptographicLibrary.DegisterWatcher( + const Registrant: ICryptographicLibraryWatcher); +begin +FWatchers.Remove( Registrant) +end; + + + +procedure TCryptographicLibrary.DeregisterBlockChainingModel( + const Registrant: IBlockChainingModel); +begin +FChainModes.Remove( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.DeregisterBlockCipher( + const Registrant: IBlockCipher); +begin +FBlockCiphers.Remove( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.DeregisterHash( const Registrant: IHashDsc); +begin +FHashes.Remove( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.DeregisterStreamCipher( + const Registrant: IStreamCipher); +begin +FStreamCiphers.Remove( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + +function TCryptographicLibrary.GetBlockCipherDisplayNames( + const ProgIdx: string): string; +var + Cipher: IBlockCipher; +begin +Cipher := BlockCipherIntfc( ProgIdx); +if assigned( Cipher) then + result := Cipher.DisplayName + else + result := '' +end; + + +function TCryptographicLibrary.GetBlockCiphers_ByDisplayName: TStrings; +begin +if not assigned( FBlockCiphers_ByDisplayName) then + TCryptLibStrings.Create( cBlockName, self); +result := FBlockCiphers_ByDisplayName +end; + + +function TCryptographicLibrary.GetBlockCiphers_ByProgId: TStrings; +begin +if not assigned( FBlockCiphers_ByProgId) then + TCryptLibStrings.Create( cBlockId, self); +result := FBlockCiphers_ByProgId +end; + + + + +function TCryptographicLibrary.GetChainModesDisplayNames( + const ProgIdx: string): string; +var + Cipher: IBlockChainingModel; +begin +Cipher := BlockChainingModelIntfc( ProgIdx); +if assigned( Cipher) then + result := Cipher.DisplayName + else + result := '' +end; + + + +function TCryptographicLibrary.GetChainModes_ByDisplayName: TStrings; +begin +if not assigned( FChainModes_ByDisplayName) then + TCryptLibStrings.Create( cChainName, self); +result := FChainModes_ByDisplayName +end; + + + +function TCryptographicLibrary.GetChainModes_ByProgId: TStrings; +begin +if not assigned( FChainModes_ByProgId) then + TCryptLibStrings.Create( cChainId, self); +result := FChainModes_ByProgId +end; + + +type TCipherChoice = class( TInterfacedObject, + ICipherChoice, IBlockCipherSelector) + private + FBlockCipher: IBlockCipher; + FStreamCipher: IStreamCipher; + FParamStreamCipher: IStreamCipher; + FDisplayName: string; + FisBlockCipher: boolean; + + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + procedure GetChoiceParams( + var CipherDisplayName: string; + var isBlockCipher: boolean; + var StreamCipherId: string; + var BlockCipherId: string); + + constructor Create( const BlockCipher1: IBlockCipher; + const StreamCipher1: IStreamCipher); + end; + + + +function TCryptographicLibrary.GetCipherChoices: IInterfaceList; +var + StreamProgIds, BlockProgIds: TStrings; + BaseStreamCiphers: IInterfaceList; + BaseBlockCiphers: IInterfaceList; + k, l: integer; + StreamCipher2: IStreamCipher; + BlockCipher2: IBlockCipher; + isBlockCipher: boolean; + Addend: TCipherChoice; + DisplayNames: TStrings; + + procedure FindStreamProgIds( Lib: TCryptographicLibrary); + var + j: integer; + StreamCipher1: IStreamCipher; + PId: string; + begin + Pid := FCustomStreamCipher.FProgId; + if (Pid <> '') and (StreamProgIds.IndexOf( StreamCipher1.ProgId) = -1) then + begin + StreamProgIds.Add( Pid); + BaseStreamCiphers.Add( FCustomCipherIntf) + end; + for j := 0 to Lib.FStreamCiphers.Count - 1 do + if Supports( Lib.FStreamCiphers[j], IStreamCipher, StreamCipher1) and + (StreamProgIds.IndexOf( StreamCipher1.ProgId) = -1) then + begin + StreamProgIds.Add( StreamCipher1.ProgId); + BaseStreamCiphers.Add( StreamCipher1) + end; + for j := 0 to FChildLibraries.Count - 1 do + FindStreamProgIds( FChildLibraries[j] as TCryptographicLibrary) + end; + + procedure FindBlockProgIds( Lib: TCryptographicLibrary); + var + j: integer; + BlockCipher1: IBlockCipher; + begin + for j := 0 to Lib.FBlockCiphers.Count - 1 do + if Supports( Lib.FBlockCiphers[j], IBlockCipher, BlockCipher1) and + (BlockProgIds.IndexOf( BlockCipher1.ProgId) = -1) then + begin + BlockProgIds.Add( BlockCipher1.ProgId); + BaseBlockCiphers.Add( BlockCipher1) + end; + for j := 0 to FChildLibraries.Count - 1 do + FindBlockProgIds( FChildLibraries[j] as TCryptographicLibrary) + end; + + procedure IncludeUniqueAddend; + begin + if assigned( Addend) and + (DisplayNames.IndexOf( Addend.FDisplayName) = -1) and + (not (afForRunTimeOnly in Addend.FParamStreamCipher.Features)) then + begin + DisplayNames.Add( Addend.FDisplayName); + result.Add( Addend); + Addend := nil + end + end; + +begin +result := nil; +if FisDestroying then exit; +result := TInterfaceList.Create; +DisplayNames := TStringList.Create; +Addend := nil; +StreamProgIds := TStringList.Create; +BaseStreamCiphers := TInterfaceList.Create; +BlockProgIds := TStringList.Create; +BaseBlockCiphers := TInterfaceList.Create; + +try +FindStreamProgIds( self); +FindBlockProgIds( self); +for k := 0 to StreamProgIds.Count - 1 do + begin + StreamCipher2 := BaseStreamCiphers[k] as IStreamCipher; + isBlockCipher := afBlockAdapter in StreamCipher2.Features; + if not isBlockCipher then + begin + Addend := TCipherChoice.Create( nil, StreamCipher2); + IncludeUniqueAddend; + FreeAndNil( Addend) // Destroy any rejected ones. + end + else + for l := 0 to BlockProgIds.Count - 1 do + begin + BlockCipher2 := BaseBlockCiphers[l] as IBlockCipher; + Addend := TCipherChoice.Create( BlockCipher2, StreamCipher2); + IncludeUniqueAddend; + FreeAndNil( Addend) // Destroy any rejected ones. + end; + end +finally +DisplayNames.Free; +Addend.Free; +StreamProgIds.Free; +BlockProgIds.Free +end end; + + + +function TCryptographicLibrary.GetChainChoices: IInterfaceList; +var + ChainProgIds: TStrings; + DisplayNames: TStrings; + + procedure FindChainProgIds( Lib: TCryptographicLibrary); + var + j: integer; + Chain: IBlockChainingModel; + begin + for j := 0 to Lib.FChainModes.Count - 1 do + if Supports( Lib.FChainModes[j], IBlockChainingModel, Chain) and + (ChainProgIds.IndexOf( Chain.ProgId) = -1) and + (DisplayNames.IndexOf( Chain.DisplayName) = -1) and + (not (afForRunTimeOnly in Chain.Features)) then + begin + ChainProgIds.Add( Chain.ProgId); + DisplayNames.Add( Chain.DisplayName); + result.Add( Chain) + end; + for j := 0 to FChildLibraries.Count - 1 do + FindChainProgIds( FChildLibraries[j] as TCryptographicLibrary) + end; +begin +result := nil; +if FisDestroying then exit; +result := TInterfaceList.Create; +ChainProgIds := TStringList.Create; +DisplayNames := TStringList.Create; +try + FindChainProgIds( self); +finally + ChainProgIds.Free; + DisplayNames.Free +end end; + + + + +function TCryptographicLibrary.GetHashChoices: IInterfaceList; +var + HashProgIds: TStrings; + DisplayNames: TStrings; + + procedure FindHashProgIds( Lib: TCryptographicLibrary); + var + j: integer; + Hash: IHashDsc; + begin + for j := 0 to Lib.FHashes.Count - 1 do + if Supports( Lib.FHashes[j], IHashDsc, Hash) and + (HashProgIds.IndexOf( Hash.ProgId) = -1) and + (DisplayNames.IndexOf( Hash.DisplayName) = -1) and + (not (afForRunTimeOnly in Hash.Features)) then + begin + HashProgIds.Add( Hash.ProgId); + DisplayNames.Add( Hash.DisplayName); + result.Add( Hash) + end; + for j := 0 to FChildLibraries.Count - 1 do + FindHashProgIds( FChildLibraries[j] as TCryptographicLibrary) + end; +begin +result := nil; +if FisDestroying then exit; +result := TInterfaceList.Create; +HashProgIds := TStringList.Create; +DisplayNames := TStringList.Create; +try + FindHashProgIds( self); +finally + HashProgIds.Free; + DisplayNames.Free +end end; + + + + + + + +function TCryptographicLibrary.GetHashDisplayNames( + const ProgIdx: string): string; +var + Hash: IHashDsc; +begin +Hash := HashIntfc( ProgIdx); +if assigned( Hash) then + result := Hash.DisplayName + else + result := '' +end; + + + +function TCryptographicLibrary.GetHashs_ByDisplayName: TStrings; +begin +if not assigned( FHashs_ByDisplayName) then + TCryptLibStrings.Create( cHashName, self); +result := FHashs_ByDisplayName +end; + + + +function TCryptographicLibrary.GetHashs_ByProgId: TStrings; +begin +if not assigned( FHashs_ByProgId) then + TCryptLibStrings.Create( cHashId, self); +result := FHashs_ByProgId +end; + + +function TCryptographicLibrary.GetStreamCipherDisplayNames( + const ProgIdx: string): string; +var + Cipher: IStreamCipher; +begin +Cipher := StreamCipherIntfc( ProgIdx); +if assigned( Cipher) then + result := Cipher.DisplayName + else + result := '' +end; + + + +function TCryptographicLibrary.GetStreamCiphers_ByDisplayName: TStrings; +begin +if not assigned( FStreamCiphers_ByDisplayName) then + TCryptLibStrings.Create( sStreamName, self); +result := FStreamCiphers_ByDisplayName +end; + + + +function TCryptographicLibrary.GetStreamCiphers_ByProgId: TStrings; +begin +if not assigned( FStreamCiphers_ByProgId) then + TCryptLibStrings.Create( cStreamId, self); +result := FStreamCiphers_ByProgId +end; + + + +function TCryptographicLibrary.HashIntfc( const ProgIdx: string): IHashDsc; +var + Idx, j: integer; +begin +result := nil; +if FisDestroying then exit; +Idx := Hashs_ByProgId.IndexOf( ProgIdx); +if Idx <> -1 then + result := FHashes[ Idx] as IHashDsc + else + result := nil; +if assigned( result) then exit; +for j := 0 to FChildLibraries.Count - 1 do + begin + result := (FChildLibraries[j] as TCryptographicLibrary) + .HashIntfc( ProgIdx); + if assigned( result) then break + end +end; + + + +procedure TCryptographicLibrary.RegisterBlockChainingModel( + const Registrant: IBlockChainingModel); +var + Idx: integer; +begin +Idx := FChainModes.IndexOf( Registrant); +if Idx <> -1 then exit; +Idx := ChainModes_ByProgId.IndexOf( Registrant.ProgId); +if Idx <> -1 then + FChainModes.Delete( Idx); // Resolve name conflict +FChainModes.Add( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.RegisterBlockCipher( + const Registrant: IBlockCipher); +var + Idx: integer; +begin +Idx := FBlockCiphers.IndexOf( Registrant); +if Idx <> -1 then exit; +Idx := BlockCiphers_ByProgId.IndexOf( Registrant.ProgId); +if Idx <> -1 then + FBlockCiphers.Delete( Idx); // Resolve name conflict +FBlockCiphers.Add( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.RegisterHash( const Registrant: IHashDsc); +var + Idx: integer; +begin +Idx := FHashes.IndexOf( Registrant); +if Idx <> -1 then exit; +Idx := Hashs_ByProgId.IndexOf( Registrant.ProgId); +if Idx <> -1 then + FHashes.Delete( Idx); // Resolve name conflict +FHashes.Add( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + +function TCryptographicLibrary.RegisterSimpleBlockTransform( + Cls: TSimpleBlockCipherClass; const ProgId1, DisplayName1: string; + Features1: TAlgorithmicFeatureSet; BlockSizeInBytes1: integer): string; +var + Cipher: TSimpleBlockCipher; +begin +Cipher := Cls.Create( ProgId1, DisplayName1, Features1, BlockSizeInBytes1); +result := ProgId1; +RegisterBlockCipher( Cipher) +end; + + + +procedure TCryptographicLibrary.RegisterStreamCipher( + const Registrant: IStreamCipher); +var + Idx: integer; +begin +Idx := FStreamCiphers.IndexOf( Registrant); +if Idx <> -1 then exit; +Idx := StreamCiphers_ByProgId.IndexOf( Registrant.ProgId); +if Idx <> -1 then + FStreamCiphers.Delete( Idx); // Resolve name conflict +FStreamCiphers.Add( Registrant); +ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCryptographicLibrary.RegisterWatcher( + const Registrant: ICryptographicLibraryWatcher); +begin +FWatchers.Add( Registrant) +end; + + + +function TCryptographicLibrary.StreamCipherIntfc( + const ProgIdx: string): IStreamCipher; +var + Idx, j: integer; +begin +result := nil; +if FisDestroying then exit; +if (FCustomStreamCipher.FProgId <> '') and + (FCustomStreamCipher.FProgId = ProgIdx) then + begin + result := FCustomCipherIntf; + exit + end; +Idx := StreamCiphers_ByProgId.IndexOf( ProgIdx); +if Idx <> -1 then + result := FStreamCiphers[ Idx] as IStreamCipher + else + result := nil; +if assigned( result) then exit; +for j := 0 to FChildLibraries.Count - 1 do + begin + result := (FChildLibraries[j] as TCryptographicLibrary) + .StreamCipherIntfc( ProgIdx); + if assigned( result) then break + end +end; + + +function TCryptographicLibrary.MeasureDepthDown( MeasureLimit: integer): integer; +var + W: TCryptographicLibrary; + j, M: integer; +begin +result := 0; +for j := 0 to FChildLibraries.Count - 1 do + begin + W := FChildLibraries[j] as TCryptographicLibrary; + if MeasureLimit > 0 then + M := W.MeasureDepthDown( MeasureLimit-1) + else + M := -1; + if M = -1 then + begin + result := -1; + break + end; + result := Max( result, M + 1) + end; +end; + +function TCryptographicLibrary.MeasureDepthUp( MeasureLimit: integer): integer; +var + W: TCryptographicLibrary; +begin +result := -1; +W := self; +while assigned( W) do + begin + W := W.FParentLibrary; + Inc( result); + if result < MeasureLimit then continue; + result := -1; + break + end +end; + +const MaxDepth = 10; + +procedure TCryptographicLibrary.SetParentLibrary( Value: TCryptographicLibrary); +var + Depth, DepthDown, DepthDown1, DepthDown2, DepthUp: integer; + W: TCryptographicLibrary; + isCircular: boolean; + j: integer; +begin +if FParentLibrary = Value then exit; + +if assigned( Value) then + begin + DepthDown1 := MeasureDepthDown( MaxDepth); + if assigned( Value) then + DepthDown2 := Value.MeasureDepthDown( MaxDepth) + else + DepthDown2 := 0; + if DepthDown1 <> -1 then + Inc( DepthDown1); + if (DepthDown1 <> -1) and (DepthDown2 <> -1) then + DepthDown := Max( DepthDown1, DepthDown2) + else + DepthDown := -1; + if assigned( Value) then + DepthUp := Value.MeasureDepthUp( MaxDepth) + else + DepthUp := 0; + if (DepthDown <> -1) and (DepthUp <> -1) then + Depth := DepthDown + DepthUp + else + Depth := -1; + if (Depth = -1) or (Depth > MaxDepth) then + raise Exception.CreateFmt( ES_LibsChainTooDeep, [MaxDepth]); + W := Value; + isCircular := False; + for j := 0 to 2 * MaxDepth do + begin + if not assigned( W) then break; + isCircular := (W = self) or ((j > 0) and (W = Value)); + if isCircular then break; + W := W.FParentLibrary + end; + if isCircular then + raise Exception.Create( ES_CircularLibs); + end; + +if assigned( FParentLibrary) then + begin + FParentLibrary.RemoveFreeNotification( self); + FParentLibrary.FChildLibraries.Remove( self); + FParentLibrary.ProgIdsChanged( MaxProgIdChangeCallFrames); + FParentLibrary := nil + end; + +FParentLibrary := Value; + +if assigned( FParentLibrary) then + begin + FParentLibrary.FreeNotification( self); + if FParentLibrary.FChildLibraries.IndexOf( self) = -1 then + FParentLibrary.FChildLibraries.Add( self); + FParentLibrary.ProgIdsChanged( MaxProgIdChangeCallFrames) + end; + +end; + + +procedure TCryptographicLibrary.Notification( + AComponent: TComponent; Operation: TOperation); +begin +inherited; +if Operation = opRemove then + begin + if AComponent = FParentLibrary then + SetParentLibrary( nil); + + if FChildLibraries.IndexOf( AComponent) <> -1 then + (AComponent as TCryptographicLibrary).SetParentLibrary( nil) + end; +end; + + +procedure TCryptographicLibrary.ProgIdsChanged( StackLimit: integer); +var + j: integer; + W: ICryptographicLibraryWatcher; +begin +if StackLimit <= 0 then exit; // Protect against stack overflow. +for j := 0 to FWatchers.Count - 1 do + if Supports( FWatchers[j], ICryptographicLibraryWatcher, W) then + W.ProgIdsChanged; + +if assigned( FParentLibrary) then + FParentLibrary.ProgIdsChanged( StackLimit - 1) +end; + + + +{ TCryptLibStrings } + +constructor TCryptLibStrings.Create( + Ref1: TCryptoLibStringRef; Lib1: TCryptographicLibrary); +var + ParentRef: ^TStrings; +begin +FReference := Ref1; +FLib := Lib1; +FisDestroying := False; +ParentRef := nil; +if assigned( FLib) then + case FReference of + cStreamId: ParentRef := @ FLib.FStreamCiphers_ByProgId; + sStreamName: ParentRef := @ FLib.FStreamCiphers_ByDisplayName; + cBlockId: ParentRef := @ FLib.FBlockCiphers_ByProgId; + cBlockName: ParentRef := @ FLib.FBlockCiphers_ByDisplayName; + cChainId: ParentRef := @ FLib.FChainModes_ByProgId; + cChainName: ParentRef := @ FLib.FChainModes_ByDisplayName; + cHashId: ParentRef := @ FLib.FHashs_ByProgId; + cHashName: ParentRef := @ FLib.FHashs_ByDisplayName; + end; +if ParentRef^ = nil then + ParentRef^ := self +end; + +procedure TCryptLibStrings.Clear; +begin +end; + + +procedure TCryptLibStrings.Delete( Index: Integer); +begin +end; + + +destructor TCryptLibStrings.Destroy; +var + ParentRef: ^TStrings; +begin +FisDestroying := True; +ParentRef := nil; +if assigned( FLib) then + case FReference of + cStreamId: ParentRef := @ FLib.FStreamCiphers_ByProgId; + sStreamName: ParentRef := @ FLib.FStreamCiphers_ByDisplayName; + cBlockId: ParentRef := @ FLib.FBlockCiphers_ByProgId; + cBlockName: ParentRef := @ FLib.FBlockCiphers_ByDisplayName; + cChainId: ParentRef := @ FLib.FChainModes_ByProgId; + cChainName: ParentRef := @ FLib.FChainModes_ByDisplayName; + cHashId: ParentRef := @ FLib.FHashs_ByProgId; + cHashName: ParentRef := @ FLib.FHashs_ByDisplayName; + end; +if ParentRef^ = self then + ParentRef^ := nil; +inherited +end; + + +function TCryptLibStrings.Get( Index: Integer): string; +begin +result := ''; +if assigned( FLib) then + case FReference of + cStreamId: result := (FLib.FStreamCiphers[ Index] as IStreamCipher).ProgId; + sStreamName: result := (FLib.FStreamCiphers[ Index] as IStreamCipher ).DisplayName; + cBlockId: result := (FLib.FBlockCiphers [ Index] as IBlockCipher ).ProgId; + cBlockName: result := (FLib.FBlockCiphers [ Index] as IBlockCipher ).DisplayName; + cChainId: result := (FLib.FChainModes [ Index] as IBlockChainingModel).ProgId; + cChainName: result := (FLib.FChainModes [ Index] as IBlockChainingModel).DisplayName; + cHashId: result := (FLib.FHashes [ Index] as IHashDsc ).ProgId; + cHashName: result := (FLib.FHashes [ Index] as IHashDsc ).DisplayName; + end +end; + + + +function TCryptLibStrings.GetCount: Integer; +begin +result := 0; +if assigned( FLib) then + case FReference of + cStreamId, + sStreamName: result := FLib.FStreamCiphers.Count; + cBlockId, + cBlockName: result := FLib.FBlockCiphers.Count; + cChainId, + cChainName: result := FLib.FChainModes.Count; + cHashId, + cHashName: result := FLib.FHashes.Count; + end +end; + + + +procedure TCryptLibStrings.Insert( Index: Integer; const S: string); +begin +end; + + + +{ TCipherChoice } + +constructor TCipherChoice.Create( + const BlockCipher1: IBlockCipher; const StreamCipher1: IStreamCipher); +begin +FBlockCipher := BlockCipher1; +FStreamCipher := StreamCipher1; +FisBlockCipher := assigned( FBlockCipher); +FParamStreamCipher := nil; +if assigned( FStreamCipher) then + FParamStreamCipher := FStreamCipher.Parameterize( self); +if not assigned( FParamStreamCipher) then + FParamStreamCipher := FStreamCipher; +FDisplayName := TCryptographicLibrary + .ComputeCipherDisplayName( FParamStreamCipher, FBlockCipher) +end; + + + +function TCipherChoice.GetBlockCipher: IBlockCipher; +begin +result := FBlockCipher +end; + + + +function TCipherChoice.GetChainMode: IBlockChainingModel; +begin +result := nil +end; + + +procedure TCipherChoice.GetChoiceParams( + var CipherDisplayName: string; + var isBlockCipher: boolean; var StreamCipherId, BlockCipherId: string); +begin +CipherDisplayName := FDisplayName; +isBlockCipher := FisBlockCipher; +if assigned( FStreamCipher) then + StreamCipherId := FStreamCipher.ProgId + else + StreamCipherId := ''; +if assigned( FBlockCipher) then + BlockCipherId := FBlockCipher.ProgId + else + BlockCipherId := ''; +end; + +type +TCustomStreamCipherObj = class( TInterfacedObject, + ICryptoGraphicAlgorithm, IStreamCipher) + private + FPrstnt: TCustomStreamCipher; + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; + function DefinitionURL: string; + function WikipediaReference: string; + constructor Create( Prstnt1: TCustomStreamCipher); + end; + +{ TCustomStreamCipher } + +constructor TCustomStreamCipher.Create( Lib1: TCryptographicLibrary); +begin +FLib := Lib1; +FLib.FCustomStreamCipher := self; +FLib.FCustomCipherIntf := TCustomStreamCipherObj.Create( self) +end; + +destructor TCustomStreamCipher.Destroy; +begin +FLib.FCustomCipherIntf := nil; +FLib.FCustomStreamCipher := nil; +inherited +end; + + +procedure TCustomStreamCipher.SetDisplayName(const Value: string); +begin +if FDisplayName = Value then exit; +FDisplayName := Value; +FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCustomStreamCipher.SetFeatures( Value: TAlgorithmicFeatureSet); +begin +if FFeatures = Value then exit; +FFeatures := Value; +FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCustomStreamCipher.SetProgId( const Value: string); +begin +if FProgId = Value then exit; +FProgId := Value; +FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + + + +procedure TCustomStreamCipher.SetSeedByteSize( Value: integer); +begin +if FSeedByteSize = Value then exit; +FSeedByteSize := Value; +FLib.ProgIdsChanged( MaxProgIdChangeCallFrames) +end; + +{ TCustomStreamCipherObj } + +constructor TCustomStreamCipherObj.Create( Prstnt1: TCustomStreamCipher); +begin +FPrstnt := Prstnt1 +end; + + + +function TCustomStreamCipherObj.DefinitionURL: string; +begin +result := '' +end; + +function TCustomStreamCipherObj.DisplayName: string; +begin +result := FPrstnt.DisplayName +end; + + + +function TCustomStreamCipherObj.Features: TAlgorithmicFeatureSet; +begin +result := FPrstnt.Features +end; + + + + +function TCustomStreamCipherObj.GenerateKey( Seed: TStream): TSymetricKey; +begin +if assigned( FPrstnt.FLib.FOnGenerateKeyFunc) then + result := FPrstnt.FLib.FOnGenerateKeyFunc( FPrstnt.FLib, Seed) + else + result := nil +end; + + + +function TCustomStreamCipherObj.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := nil +end; + + +function TCustomStreamCipherObj.Parameterize( + const Params: IInterface): IStreamCipher; +begin +result := nil +end; + + + +function TCustomStreamCipherObj.ProgId: string; +begin +result := FPrstnt.FProgId +end; + + + +function TCustomStreamCipherObj.SeedByteSize: integer; +begin +result := FPrstnt.FSeedByteSize +end; + + + +function TCustomStreamCipherObj.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin +if assigned( FPrstnt.FLib.FOnStart_DecryptFunc) then + result := FPrstnt.FLib.FOnStart_DecryptFunc( FPrstnt.FLib, Key, PlainText) + else + result := nil +end; + + +function TCustomStreamCipherObj.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +if assigned( FPrstnt.FLib.FOnStart_EncryptFunc) then + result := FPrstnt.FLib.FOnStart_EncryptFunc( FPrstnt.FLib, Key, CipherText) + else + result := nil +end; + +function TCustomStreamCipherObj.WikipediaReference: string; +begin +result := '' +end; + +{ +LockBox 2 Hashes +================ +MD5 +SHA1 + +DCP Hashes +========== +havel +MD4 +MD5 +RIPEMD128 +RIPEMD160 +SHA1 +SHA256 +SHA384 +SHA512 +Tiger + +LockBox 2 Ciphers +================= +Blowfish +DES +3DES +Rijndael + +DCP Ciphers +=========== +Blowfish +cast128 +cast256 +DES +3DES +gost +ice +ThinIce +ice2 +idea +mars +misty1 +rc2 +rc4 +rc5 +rc6 +Rijndael +serpent +tea +twofish + +Ciphers for best standards support +================================== +AES-128 +AES-192 +AES-256 +3DES +IDEA +CAST-128 +Serpent +TwoFish + +LockBox 2 Extras +================ +RSA +DSA +RSA SSA +} +end. diff --git a/run/TPLB3.DCP.twofish_Modified.pas b/LockBox3/run/TPLB3.DCP.twofish_Modified.pas similarity index 97% rename from run/TPLB3.DCP.twofish_Modified.pas rename to LockBox3/run/TPLB3.DCP.twofish_Modified.pas index 98b894d..bb1d03f 100644 --- a/run/TPLB3.DCP.twofish_Modified.pas +++ b/LockBox3/run/TPLB3.DCP.twofish_Modified.pas @@ -1,579 +1,579 @@ -{******************************************************************************} -{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} -{******************************************************************************} -{* A binary compatible implementation of Twofish ******************************} -{******************************************************************************} -{* Copyright (c) 1999-2002 David Barton *} -{* Permission is hereby granted, free of charge, to any person obtaining a *} -{* copy of this software and associated documentation files (the "Software"), *} -{* to deal in the Software without restriction, including without limitation *} -{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *} -{* and/or sell copies of the Software, and to permit persons to whom the *} -{* Software is furnished to do so, subject to the following conditions: *} -{* *} -{* The above copyright notice and this permission notice shall be included in *} -{* all copies or substantial portions of the Software. *} -{* *} -{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *} -{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *} -{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *} -{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *} -{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *} -{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *} -{* DEALINGS IN THE SOFTWARE. *} -{******************************************************************************} - -{$I TPLB3.Common.inc} - -unit TPLB3.DCP.twofish_Modified; -// The original unit name was DCPtwofish . -// This unit is not part of the LockBox Project, but is used by it. -// It is a modified version of Dave Barton's DCPtwofish unit of -// the DCPCrypt library. It has been cut down to just the primitives. - -interface -uses - Classes, Sysutils; - -const - INPUTWHITEN= 0; - OUTPUTWHITEN= 4; - NUMROUNDS= 16; - ROUNDSUBKEYS= (OUTPUTWHITEN + 4); - TOTALSUBKEYS= (ROUNDSUBKEYS + NUMROUNDS * 2); - RS_GF_FDBK= $14d; - MDS_GF_FDBK= $169; - SK_STEP= $02020202; - SK_BUMP= $01010101; - SK_ROTL= 9; - - -type - -TSubKeys = array[ 0.. TOTALSUBKEYS - 1] of Cardinal; -TSBox = array[ 0..3, 0..255] of Cardinal; -T128 = packed array[ 0..3 ] of Cardinal; -T256 = packed array[ 0..7 ] of Cardinal; -T2048 = packed array[ 0..255 ] of byte; -Tp8x8 = packed array[ 0..1 ] of T2048; - -procedure DCP_towfish_Precomp; - -procedure DCP_twofish_InitKey( - const Key; Size: longword; - var SubKeys: TSubKeys; var SBox: TSBox); - -procedure DCP_twofish_EncryptECB( - const SubKeys: TSubKeys; const SBox: TSBox; - const InData: T128; var OutData: T128); - -procedure DCP_twofish_DecryptECB( - const SubKeys: TSubKeys; const SBox: TSBox; - const InData: T128; var OutData: T128); - - -implementation - - - -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} - -var - MDS: TSBox; - -function LFSR1( x: Cardinal): Cardinal; -begin - if (x and 1)<> 0 then - Result:= (x shr 1) xor (MDS_GF_FDBK div 2) - else - Result:= (x shr 1); -end; - -function LFSR2(x: Cardinal): Cardinal; -begin - if (x and 2)<> 0 then - if (x and 1)<> 0 then - Result:= (x shr 2) xor (MDS_GF_FDBK div 2) xor (MDS_GF_FDBK div 4) - else - Result:= (x shr 2) xor (MDS_GF_FDBK div 2) - else - if (x and 1)<> 0 then - Result:= (x shr 2) xor (MDS_GF_FDBK div 4) - else - Result:= (x shr 2); -end; -function Mul_X(x: Cardinal): Cardinal; -begin - Result:= x xor LFSR2(x); -end; -function Mul_Y(x: Cardinal): Cardinal; -begin - Result:= x xor LFSR1(x) xor LFSR2(x); -end; - -function RS_MDS_Encode(lK0, lK1: Cardinal): Cardinal; -var - lR, nJ, lG2, lG3: Cardinal; - bB: byte; -begin - lR:= lK1; - for nJ:= 0 to 3 do - begin - bB:= lR shr 24; - if (bB and $80)<> 0 then - lG2:= ((bB shl 1) xor RS_GF_FDBK) and $FF - else - lG2:= (bB shl 1) and $FF; - if (bB and 1)<> 0 then - lG3:= ((bB shr 1) and $7f) xor (RS_GF_FDBK shr 1) xor lG2 - else - lG3:= ((bB shr 1) and $7f) xor lG2; - lR:= (lR shl 8) xor (lG3 shl 24) xor (lG2 shl 16) xor (lG3 shl 8) xor bB; - end; - lR:= lR xor lK0; - for nJ:= 0 to 3 do - begin - bB:= lR shr 24; - if (bB and $80)<> 0 then - lG2:= ((bB shl 1) xor RS_GF_FDBK) and $FF - else - lG2:= (bB shl 1) and $FF; - if (bB and 1)<> 0 then - lG3:= ((bB shr 1) and $7f) xor (RS_GF_FDBK shr 1) xor lG2 - else - lG3:= ((bB shr 1) and $7f) xor lG2; - lR:= (lR shl 8) xor (lG3 shl 24) xor (lG2 shl 16) xor (lG3 shl 8) xor bB; - end; - Result:= lR; -end; - - -const - p8x8: Tp8x8= (( - $a9, $67, $b3, $e8, $04, $fd, $a3, $76, - $9a, $92, $80, $78, $e4, $dd, $d1, $38, - $0d, $c6, $35, $98, $18, $f7, $ec, $6c, - $43, $75, $37, $26, $fa, $13, $94, $48, - $f2, $d0, $8b, $30, $84, $54, $df, $23, - $19, $5b, $3d, $59, $f3, $ae, $a2, $82, - $63, $01, $83, $2e, $d9, $51, $9b, $7c, - $a6, $eb, $a5, $be, $16, $0c, $e3, $61, - $c0, $8c, $3a, $f5, $73, $2c, $25, $0b, - $bb, $4e, $89, $6b, $53, $6a, $b4, $f1, - $e1, $e6, $bd, $45, $e2, $f4, $b6, $66, - $cc, $95, $03, $56, $d4, $1c, $1e, $d7, - $fb, $c3, $8e, $b5, $e9, $cf, $bf, $ba, - $ea, $77, $39, $af, $33, $c9, $62, $71, - $81, $79, $09, $ad, $24, $cd, $f9, $d8, - $e5, $c5, $b9, $4d, $44, $08, $86, $e7, - $a1, $1d, $aa, $ed, $06, $70, $b2, $d2, - $41, $7b, $a0, $11, $31, $c2, $27, $90, - $20, $f6, $60, $ff, $96, $5c, $b1, $ab, - $9e, $9c, $52, $1b, $5f, $93, $0a, $ef, - $91, $85, $49, $ee, $2d, $4f, $8f, $3b, - $47, $87, $6d, $46, $d6, $3e, $69, $64, - $2a, $ce, $cb, $2f, $fc, $97, $05, $7a, - $ac, $7f, $d5, $1a, $4b, $0e, $a7, $5a, - $28, $14, $3f, $29, $88, $3c, $4c, $02, - $b8, $da, $b0, $17, $55, $1f, $8a, $7d, - $57, $c7, $8d, $74, $b7, $c4, $9f, $72, - $7e, $15, $22, $12, $58, $07, $99, $34, - $6e, $50, $de, $68, $65, $bc, $db, $f8, - $c8, $a8, $2b, $40, $dc, $fe, $32, $a4, - $ca, $10, $21, $f0, $d3, $5d, $0f, $00, - $6f, $9d, $36, $42, $4a, $5e, $c1, $e0),( - $75, $f3, $c6, $f4, $db, $7b, $fb, $c8, - $4a, $d3, $e6, $6b, $45, $7d, $e8, $4b, - $d6, $32, $d8, $fd, $37, $71, $f1, $e1, - $30, $0f, $f8, $1b, $87, $fa, $06, $3f, - $5e, $ba, $ae, $5b, $8a, $00, $bc, $9d, - $6d, $c1, $b1, $0e, $80, $5d, $d2, $d5, - $a0, $84, $07, $14, $b5, $90, $2c, $a3, - $b2, $73, $4c, $54, $92, $74, $36, $51, - $38, $b0, $bd, $5a, $fc, $60, $62, $96, - $6c, $42, $f7, $10, $7c, $28, $27, $8c, - $13, $95, $9c, $c7, $24, $46, $3b, $70, - $ca, $e3, $85, $cb, $11, $d0, $93, $b8, - $a6, $83, $20, $ff, $9f, $77, $c3, $cc, - $03, $6f, $08, $bf, $40, $e7, $2b, $e2, - $79, $0c, $aa, $82, $41, $3a, $ea, $b9, - $e4, $9a, $a4, $97, $7e, $da, $7a, $17, - $66, $94, $a1, $1d, $3d, $f0, $de, $b3, - $0b, $72, $a7, $1c, $ef, $d1, $53, $3e, - $8f, $33, $26, $5f, $ec, $76, $2a, $49, - $81, $88, $ee, $21, $c4, $1a, $eb, $d9, - $c5, $39, $99, $cd, $ad, $31, $8b, $01, - $18, $23, $dd, $1f, $4e, $2d, $f9, $48, - $4f, $f2, $65, $8e, $78, $5c, $58, $19, - $8d, $e5, $98, $57, $67, $7f, $05, $64, - $af, $63, $b6, $fe, $f5, $b7, $3c, $a5, - $ce, $e9, $68, $44, $e0, $4d, $43, $69, - $29, $2e, $ac, $15, $59, $a8, $0a, $9e, - $6e, $47, $df, $34, $35, $6a, $cf, $dc, - $22, $c9, $c0, $9b, $89, $d4, $ed, $ab, - $12, $a2, $0d, $52, $bb, $02, $2f, $a9, - $d7, $61, $1e, $b4, $50, $04, $f6, $c2, - $16, $25, $86, $56, $55, $09, $be, $91)); - -function f32( x: Cardinal; const K32: T128; Len: Cardinal): Cardinal; -var - t0, t1, t2, t3: Cardinal; -begin - t0:= x and $FF; - t1:= (x shr 8) and $FF; - t2:= (x shr 16) and $FF; - t3:= x shr 24; - if Len= 256 then - begin - t0:= p8x8[1,t0] xor ((K32[3]) and $FF); - t1:= p8x8[0,t1] xor ((K32[3] shr 8) and $FF); - t2:= p8x8[0,t2] xor ((K32[3] shr 16) and $FF); - t3:= p8x8[1,t3] xor ((K32[3] shr 24)); - end; - if Len>= 192 then - begin - t0:= p8x8[1,t0] xor ((K32[2]) and $FF); - t1:= p8x8[1,t1] xor ((K32[2] shr 8) and $FF); - t2:= p8x8[0,t2] xor ((K32[2] shr 16) and $FF); - t3:= p8x8[0,t3] xor ((K32[2] shr 24)); - end; - Result:= MDS[0,p8x8[0,p8x8[0,t0] xor ((K32[1]) and $FF)] xor ((K32[0]) and $FF)] xor - MDS[1,p8x8[0,p8x8[1,t1] xor ((K32[1] shr 8) and $FF)] xor ((K32[0] shr 8) and $FF)] xor - MDS[2,p8x8[1,p8x8[0,t2] xor ((K32[1] shr 16) and $FF)] xor ((K32[0] shr 16) and $FF)] xor - MDS[3,p8x8[1,p8x8[1,t3] xor ((K32[1] shr 24))] xor ((K32[0] shr 24))]; -end; - - -procedure Xor256( var Dst: T2048; const Src: T2048; v: byte); -var - i, j: Cardinal; - PDst, PSrc: PCardinal; -begin -j := v * $01010101; -PDst := @Dst; -PSrc := @Src; -for i := 0 to 63 do - begin - PDst^ := PSrc^ xor j; - Inc( PSrc); - Inc( PDst) - end -end; - -procedure DCP_twofish_InitKey( - const Key; Size: longword; - var SubKeys: TSubKeys; var SBox: TSBox); -const - subkeyCnt= ROUNDSUBKEYS + 2*NUMROUNDS; -var - key32: T256; - k32e, k32o, sboxkeys: T128; - k64Cnt, i, j, A, B, q: Cardinal; - L0, L1: T2048; -begin - FillChar(Key32,Sizeof(Key32),0); - Move( Key, Key32, Size div 8); - if Size<= 128 then { pad the key to either 128bit, 192bit or 256bit} - Size:= 128 - else if Size<= 192 then - Size:= 192 - else - Size:= 256; - k64Cnt:= Size div 64; - j:= k64Cnt-1; - for i:= 0 to j do - begin - k32e[i]:= key32[2*i]; - k32o[i]:= key32[2*i+1]; - sboxKeys[j]:= RS_MDS_Encode(k32e[i],k32o[i]); - Dec(j); - end; - q:= 0; - for i:= 0 to ((subkeyCnt div 2)-1) do - begin - A:= f32(q,k32e,Size); - B:= f32(q+SK_BUMP,k32o,Size); - B:= (B shl 8) or (B shr 24); - SubKeys[2*i]:= A+B; - B:= A + 2*B; - SubKeys[2*i+1]:= (B shl SK_ROTL) or (B shr (32 - SK_ROTL)); - Inc(q,SK_STEP); - end; - case Size of - 128: begin - Xor256(L0,p8x8[0],(sboxKeys[1] and $FF)); - A:= (sboxKeys[0] and $FF); - i:= 0; - while i< 256 do - begin - sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,L0[i]] xor A]; - sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,L0[i+1]] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[1],(sboxKeys[1] shr 8) and $FF); - A:= (sboxKeys[0] shr 8) and $FF; - i:= 0; - while i< 256 do - begin - sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,L0[i]] xor A]; - sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,L0[i+1]] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[0],(sboxKeys[1] shr 16) and $FF); - A:= (sboxKeys[0] shr 16) and $FF; - i:= 0; - while i< 256 do - begin - sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,L0[i]] xor A]; - sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,L0[i+1]] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[1],(sboxKeys[1] shr 24)); - A:= (sboxKeys[0] shr 24); - i:= 0; - while i< 256 do - begin - sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,L0[i]] xor A]; - sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,L0[i+1]] xor A]; - Inc(i,2); - end; - end; - 192: begin - Xor256(L0,p8x8[1],sboxKeys[2] and $FF); - A:= sboxKeys[0] and $FF; - B:= sboxKeys[1] and $FF; - i:= 0; - while i< 256 do - begin - sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,p8x8[0,L0[i]] xor B] xor A]; - sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,p8x8[0,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[1],(sboxKeys[2] shr 8) and $FF); - A:= (sboxKeys[0] shr 8) and $FF; - B:= (sboxKeys[1] shr 8) and $FF; - i:= 0; - while i< 256 do - begin - sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,p8x8[1,L0[i]] xor B] xor A]; - sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,p8x8[1,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[0],(sboxKeys[2] shr 16) and $FF); - A:= (sboxKeys[0] shr 16) and $FF; - B:= (sboxKeys[1] shr 16) and $FF; - i:= 0; - while i< 256 do - begin - sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,p8x8[0,L0[i]] xor B] xor A]; - sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,p8x8[0,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - Xor256(L0,p8x8[0],(sboxKeys[2] shr 24)); - A:= (sboxKeys[0] shr 24); - B:= (sboxKeys[1] shr 24); - i:= 0; - while i< 256 do - begin - sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,p8x8[1,L0[i]] xor B] xor A]; - sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,p8x8[1,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - end; - 256: begin - Xor256(L1,p8x8[1],(sboxKeys[3]) and $FF); - i:= 0; - while i< 256 do - begin - L0[i ]:= p8x8[1,L1[i]]; - L0[i+1]:= p8x8[1,L1[i+1]]; - Inc(i,2); - end; - Xor256(L0,L0,(sboxKeys[2]) and $FF); - A:= (sboxKeys[0]) and $FF; - B:= (sboxKeys[1]) and $FF; - i:= 0; - while i< 256 do - begin - sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,p8x8[0,L0[i]] xor B] xor A]; - sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,p8x8[0,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - Xor256(L1,p8x8[0],(sboxKeys[3] shr 8) and $FF); - i:= 0; - while i< 256 do - begin - L0[i ]:= p8x8[1,L1[i]]; - L0[i+1]:= p8x8[1,L1[i+1]]; - Inc(i,2); - end; - Xor256(L0,L0,(sboxKeys[2] shr 8) and $FF); - A:= (sboxKeys[0] shr 8) and $FF; - B:= (sboxKeys[1] shr 8) and $FF; - i:= 0; - while i< 256 do - begin - sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,p8x8[1,L0[i]] xor B] xor A]; - sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,p8x8[1,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - - Xor256(L1,p8x8[0],(sboxKeys[3] shr 16) and $FF); - i:= 0; - while i< 256 do - begin - L0[i ]:= p8x8[0,L1[i]]; - L0[i+1]:= p8x8[0,L1[i+1]]; - Inc(i,2); - end; - Xor256(L0,L0,(sboxKeys[2] shr 16) and $FF); - A:= (sboxKeys[0] shr 16) and $FF; - B:= (sboxKeys[1] shr 16) and $FF; - i:= 0; - while i< 256 do - begin - sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,p8x8[0,L0[i]] xor B] xor A]; - sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,p8x8[0,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - Xor256(L1,p8x8[1],(sboxKeys[3] shr 24)); - i:= 0; - while i< 256 do - begin - L0[i ]:= p8x8[0,L1[i]]; - L0[i+1]:= p8x8[0,L1[i+1]]; - Inc(i,2); - end; - Xor256(L0,L0,(sboxKeys[2] shr 24)); - A:= (sboxKeys[0] shr 24); - B:= (sboxKeys[1] shr 24); - i:= 0; - while i< 256 do - begin - sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,p8x8[1,L0[i]] xor B] xor A]; - sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,p8x8[1,L0[i+1]] xor B] xor A]; - Inc(i,2); - end; - end; - end; -end; - - - - -procedure DCP_twofish_EncryptECB( - const SubKeys: TSubKeys; const SBox: TSBox; - const InData: T128; var OutData: T128); -var - i: longword; - t0, t1: Cardinal; - X: T128; - k: integer; -begin - for k := 0 to 3 do - x[k] := InData[k] xor SubKeys[INPUTWHITEN+k]; - i:= 0; - while i<= NUMROUNDS-2 do - begin - t0:= sBox[0,(x[0] shl 1) and $1fe] xor sBox[0,((x[0] shr 7) and $1fe)+1] - xor sBox[2,(x[0] shr 15) and $1fe] xor sBox[2,((x[0] shr 23) and $1fe)+1]; - t1:= sBox[0,((x[1] shr 23) and $1fe)] xor sBox[0,((x[1] shl 1) and $1fe)+1] - xor sBox[2,((x[1] shr 7) and $1fe)] xor sBox[2,((x[1] shr 15) and $1fe)+1]; - x[3]:= (x[3] shl 1) or (x[3] shr 31); - x[2]:= x[2] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*i]); - x[3]:= x[3] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*i+1]); - x[2]:= (x[2] shr 1) or (x[2] shl 31); - - t0:= sBox[0,(x[2] shl 1) and $1fe] xor sBox[0,((x[2] shr 7) and $1fe)+1] - xor sBox[2,((x[2] shr 15) and $1fe)] xor sBox[2,((x[2] shr 23) and $1fe)+1]; - t1:= sBox[0,((x[3] shr 23) and $1fe)] xor sBox[0,((x[3] shl 1) and $1fe)+1] - xor sBox[2,((x[3] shr 7) and $1fe)] xor sBox[2,((x[3] shr 15) and $1fe)+1]; - x[1]:= (x[1] shl 1) or (x[1] shr 31); - x[0]:= x[0] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)]); - x[1]:= x[1] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)+1]); - x[0]:= (x[0] shr 1) or (x[0] shl 31); - Inc(i,2); - end; - OutData[ 0] := x[2] xor SubKeys[OUTPUTWHITEN]; - OutData[ 1] := x[3] xor SubKeys[OUTPUTWHITEN+1]; - OutData[ 2] := x[0] xor SubKeys[OUTPUTWHITEN+2]; - OutData[ 3] := x[1] xor SubKeys[OUTPUTWHITEN+3]; -end; - - -procedure DCP_twofish_DecryptECB( - const SubKeys: TSubKeys; const SBox: TSBox; - const InData: T128; var OutData: T128); -var - i, k: integer; - t0, t1: Cardinal; - X: T128; -begin - X[2] := InData[0] xor SubKeys[OUTPUTWHITEN]; - X[3] := InData[1] xor SubKeys[OUTPUTWHITEN+1]; - X[0] := InData[2] xor SubKeys[OUTPUTWHITEN+2]; - X[1] := InData[3] xor SubKeys[OUTPUTWHITEN+3]; - i:= NUMROUNDS-2; - while i>= 0 do - begin - t0:= sBox[0,(x[2] shl 1) and $1fe] xor sBox[0,((x[2] shr 7) and $1fe)+1] - xor sBox[2,((x[2] shr 15) and $1fe)] xor sBox[2,((x[2] shr 23) and $1fe)+1]; - t1:= sBox[0,((x[3] shr 23) and $1fe)] xor sBox[0,((x[3] shl 1) and $1fe)+1] - xor sBox[2,((x[3] shr 7) and $1fe)] xor sBox[2,((x[3] shr 15) and $1fe)+1]; - x[0]:= (x[0] shl 1) or (x[0] shr 31); - x[0]:= x[0] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)]); - x[1]:= x[1] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)+1]); - x[1]:= (x[1] shr 1) or (x[1] shl 31); - - t0:= sBox[0,(x[0] shl 1) and $1fe] xor sBox[0,((x[0] shr 7) and $1fe)+1] - xor sBox[2,(x[0] shr 15) and $1fe] xor sBox[2,((x[0] shr 23) and $1fe)+1]; - t1:= sBox[0,((x[1] shr 23) and $1fe)] xor sBox[0,((x[1] shl 1) and $1fe)+1] - xor sBox[2,((x[1] shr 7) and $1fe)] xor sBox[2,((x[1] shr 15) and $1fe)+1]; - x[2]:= (x[2] shl 1) or (x[2] shr 31); - x[2]:= x[2] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*i]); - x[3]:= x[3] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*i+1]); - x[3]:= (x[3] shr 1) or (x[3] shl 31); - Dec(i,2); - end; - for k := 0 to 3 do - OutData[k] := X[k] xor SubKeys[INPUTWHITEN+k] -end; - - -procedure DCP_towfish_Precomp; -var - m1, mx, my: array[0..1] of Cardinal; - nI: longword; -begin - for nI:= 0 to 255 do - begin - m1[0]:= p8x8[0,nI]; - mx[0]:= Mul_X(m1[0]); - my[0]:= Mul_Y(m1[0]); - m1[1]:= p8x8[1,nI]; - mx[1]:= Mul_X(m1[1]); - my[1]:= Mul_Y(m1[1]); - mds[0,nI]:= (m1[1] shl 0) or - (mx[1] shl 8) or - (my[1] shl 16) or - (my[1] shl 24); - mds[1,nI]:= (my[0] shl 0) or - (my[0] shl 8) or - (mx[0] shl 16) or - (m1[0] shl 24); - mds[2,nI]:= (mx[1] shl 0) or - (my[1] shl 8) or - (m1[1] shl 16) or - (my[1] shl 24); - mds[3,nI]:= (mx[0] shl 0) or - (m1[0] shl 8) or - (my[0] shl 16) or - (mx[0] shl 24); - end; -end; - - - -end. - +{******************************************************************************} +{* DCPcrypt v2.0 written by David Barton (crypto@cityinthesky.co.uk) **********} +{******************************************************************************} +{* A binary compatible implementation of Twofish ******************************} +{******************************************************************************} +{* Copyright (c) 1999-2002 David Barton *} +{* Permission is hereby granted, free of charge, to any person obtaining a *} +{* copy of this software and associated documentation files (the "Software"), *} +{* to deal in the Software without restriction, including without limitation *} +{* the rights to use, copy, modify, merge, publish, distribute, sublicense, *} +{* and/or sell copies of the Software, and to permit persons to whom the *} +{* Software is furnished to do so, subject to the following conditions: *} +{* *} +{* The above copyright notice and this permission notice shall be included in *} +{* all copies or substantial portions of the Software. *} +{* *} +{* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *} +{* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *} +{* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *} +{* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *} +{* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *} +{* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *} +{* DEALINGS IN THE SOFTWARE. *} +{******************************************************************************} + +{$I TPLB3.Common.inc} + +unit TPLB3.DCP.twofish_Modified; +// The original unit name was DCPtwofish . +// This unit is not part of the LockBox Project, but is used by it. +// It is a modified version of Dave Barton's DCPtwofish unit of +// the DCPCrypt library. It has been cut down to just the primitives. + +interface +uses + Classes, Sysutils; + +const + INPUTWHITEN= 0; + OUTPUTWHITEN= 4; + NUMROUNDS= 16; + ROUNDSUBKEYS= (OUTPUTWHITEN + 4); + TOTALSUBKEYS= (ROUNDSUBKEYS + NUMROUNDS * 2); + RS_GF_FDBK= $14d; + MDS_GF_FDBK= $169; + SK_STEP= $02020202; + SK_BUMP= $01010101; + SK_ROTL= 9; + + +type + +TSubKeys = array[ 0.. TOTALSUBKEYS - 1] of Cardinal; +TSBox = array[ 0..3, 0..255] of Cardinal; +T128 = packed array[ 0..3 ] of Cardinal; +T256 = packed array[ 0..7 ] of Cardinal; +T2048 = packed array[ 0..255 ] of byte; +Tp8x8 = packed array[ 0..1 ] of T2048; + +procedure DCP_towfish_Precomp; + +procedure DCP_twofish_InitKey( + const Key; Size: longword; + var SubKeys: TSubKeys; var SBox: TSBox); + +procedure DCP_twofish_EncryptECB( + const SubKeys: TSubKeys; const SBox: TSBox; + const InData: T128; var OutData: T128); + +procedure DCP_twofish_DecryptECB( + const SubKeys: TSubKeys; const SBox: TSBox; + const InData: T128; var OutData: T128); + + +implementation + + + +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} + +var + MDS: TSBox; + +function LFSR1( x: Cardinal): Cardinal; +begin + if (x and 1)<> 0 then + Result:= (x shr 1) xor (MDS_GF_FDBK div 2) + else + Result:= (x shr 1); +end; + +function LFSR2(x: Cardinal): Cardinal; +begin + if (x and 2)<> 0 then + if (x and 1)<> 0 then + Result:= (x shr 2) xor (MDS_GF_FDBK div 2) xor (MDS_GF_FDBK div 4) + else + Result:= (x shr 2) xor (MDS_GF_FDBK div 2) + else + if (x and 1)<> 0 then + Result:= (x shr 2) xor (MDS_GF_FDBK div 4) + else + Result:= (x shr 2); +end; +function Mul_X(x: Cardinal): Cardinal; +begin + Result:= x xor LFSR2(x); +end; +function Mul_Y(x: Cardinal): Cardinal; +begin + Result:= x xor LFSR1(x) xor LFSR2(x); +end; + +function RS_MDS_Encode(lK0, lK1: Cardinal): Cardinal; +var + lR, nJ, lG2, lG3: Cardinal; + bB: byte; +begin + lR:= lK1; + for nJ:= 0 to 3 do + begin + bB:= lR shr 24; + if (bB and $80)<> 0 then + lG2:= ((bB shl 1) xor RS_GF_FDBK) and $FF + else + lG2:= (bB shl 1) and $FF; + if (bB and 1)<> 0 then + lG3:= ((bB shr 1) and $7f) xor (RS_GF_FDBK shr 1) xor lG2 + else + lG3:= ((bB shr 1) and $7f) xor lG2; + lR:= (lR shl 8) xor (lG3 shl 24) xor (lG2 shl 16) xor (lG3 shl 8) xor bB; + end; + lR:= lR xor lK0; + for nJ:= 0 to 3 do + begin + bB:= lR shr 24; + if (bB and $80)<> 0 then + lG2:= ((bB shl 1) xor RS_GF_FDBK) and $FF + else + lG2:= (bB shl 1) and $FF; + if (bB and 1)<> 0 then + lG3:= ((bB shr 1) and $7f) xor (RS_GF_FDBK shr 1) xor lG2 + else + lG3:= ((bB shr 1) and $7f) xor lG2; + lR:= (lR shl 8) xor (lG3 shl 24) xor (lG2 shl 16) xor (lG3 shl 8) xor bB; + end; + Result:= lR; +end; + + +const + p8x8: Tp8x8= (( + $a9, $67, $b3, $e8, $04, $fd, $a3, $76, + $9a, $92, $80, $78, $e4, $dd, $d1, $38, + $0d, $c6, $35, $98, $18, $f7, $ec, $6c, + $43, $75, $37, $26, $fa, $13, $94, $48, + $f2, $d0, $8b, $30, $84, $54, $df, $23, + $19, $5b, $3d, $59, $f3, $ae, $a2, $82, + $63, $01, $83, $2e, $d9, $51, $9b, $7c, + $a6, $eb, $a5, $be, $16, $0c, $e3, $61, + $c0, $8c, $3a, $f5, $73, $2c, $25, $0b, + $bb, $4e, $89, $6b, $53, $6a, $b4, $f1, + $e1, $e6, $bd, $45, $e2, $f4, $b6, $66, + $cc, $95, $03, $56, $d4, $1c, $1e, $d7, + $fb, $c3, $8e, $b5, $e9, $cf, $bf, $ba, + $ea, $77, $39, $af, $33, $c9, $62, $71, + $81, $79, $09, $ad, $24, $cd, $f9, $d8, + $e5, $c5, $b9, $4d, $44, $08, $86, $e7, + $a1, $1d, $aa, $ed, $06, $70, $b2, $d2, + $41, $7b, $a0, $11, $31, $c2, $27, $90, + $20, $f6, $60, $ff, $96, $5c, $b1, $ab, + $9e, $9c, $52, $1b, $5f, $93, $0a, $ef, + $91, $85, $49, $ee, $2d, $4f, $8f, $3b, + $47, $87, $6d, $46, $d6, $3e, $69, $64, + $2a, $ce, $cb, $2f, $fc, $97, $05, $7a, + $ac, $7f, $d5, $1a, $4b, $0e, $a7, $5a, + $28, $14, $3f, $29, $88, $3c, $4c, $02, + $b8, $da, $b0, $17, $55, $1f, $8a, $7d, + $57, $c7, $8d, $74, $b7, $c4, $9f, $72, + $7e, $15, $22, $12, $58, $07, $99, $34, + $6e, $50, $de, $68, $65, $bc, $db, $f8, + $c8, $a8, $2b, $40, $dc, $fe, $32, $a4, + $ca, $10, $21, $f0, $d3, $5d, $0f, $00, + $6f, $9d, $36, $42, $4a, $5e, $c1, $e0),( + $75, $f3, $c6, $f4, $db, $7b, $fb, $c8, + $4a, $d3, $e6, $6b, $45, $7d, $e8, $4b, + $d6, $32, $d8, $fd, $37, $71, $f1, $e1, + $30, $0f, $f8, $1b, $87, $fa, $06, $3f, + $5e, $ba, $ae, $5b, $8a, $00, $bc, $9d, + $6d, $c1, $b1, $0e, $80, $5d, $d2, $d5, + $a0, $84, $07, $14, $b5, $90, $2c, $a3, + $b2, $73, $4c, $54, $92, $74, $36, $51, + $38, $b0, $bd, $5a, $fc, $60, $62, $96, + $6c, $42, $f7, $10, $7c, $28, $27, $8c, + $13, $95, $9c, $c7, $24, $46, $3b, $70, + $ca, $e3, $85, $cb, $11, $d0, $93, $b8, + $a6, $83, $20, $ff, $9f, $77, $c3, $cc, + $03, $6f, $08, $bf, $40, $e7, $2b, $e2, + $79, $0c, $aa, $82, $41, $3a, $ea, $b9, + $e4, $9a, $a4, $97, $7e, $da, $7a, $17, + $66, $94, $a1, $1d, $3d, $f0, $de, $b3, + $0b, $72, $a7, $1c, $ef, $d1, $53, $3e, + $8f, $33, $26, $5f, $ec, $76, $2a, $49, + $81, $88, $ee, $21, $c4, $1a, $eb, $d9, + $c5, $39, $99, $cd, $ad, $31, $8b, $01, + $18, $23, $dd, $1f, $4e, $2d, $f9, $48, + $4f, $f2, $65, $8e, $78, $5c, $58, $19, + $8d, $e5, $98, $57, $67, $7f, $05, $64, + $af, $63, $b6, $fe, $f5, $b7, $3c, $a5, + $ce, $e9, $68, $44, $e0, $4d, $43, $69, + $29, $2e, $ac, $15, $59, $a8, $0a, $9e, + $6e, $47, $df, $34, $35, $6a, $cf, $dc, + $22, $c9, $c0, $9b, $89, $d4, $ed, $ab, + $12, $a2, $0d, $52, $bb, $02, $2f, $a9, + $d7, $61, $1e, $b4, $50, $04, $f6, $c2, + $16, $25, $86, $56, $55, $09, $be, $91)); + +function f32( x: Cardinal; const K32: T128; Len: Cardinal): Cardinal; +var + t0, t1, t2, t3: Cardinal; +begin + t0:= x and $FF; + t1:= (x shr 8) and $FF; + t2:= (x shr 16) and $FF; + t3:= x shr 24; + if Len= 256 then + begin + t0:= p8x8[1,t0] xor ((K32[3]) and $FF); + t1:= p8x8[0,t1] xor ((K32[3] shr 8) and $FF); + t2:= p8x8[0,t2] xor ((K32[3] shr 16) and $FF); + t3:= p8x8[1,t3] xor ((K32[3] shr 24)); + end; + if Len>= 192 then + begin + t0:= p8x8[1,t0] xor ((K32[2]) and $FF); + t1:= p8x8[1,t1] xor ((K32[2] shr 8) and $FF); + t2:= p8x8[0,t2] xor ((K32[2] shr 16) and $FF); + t3:= p8x8[0,t3] xor ((K32[2] shr 24)); + end; + Result:= MDS[0,p8x8[0,p8x8[0,t0] xor ((K32[1]) and $FF)] xor ((K32[0]) and $FF)] xor + MDS[1,p8x8[0,p8x8[1,t1] xor ((K32[1] shr 8) and $FF)] xor ((K32[0] shr 8) and $FF)] xor + MDS[2,p8x8[1,p8x8[0,t2] xor ((K32[1] shr 16) and $FF)] xor ((K32[0] shr 16) and $FF)] xor + MDS[3,p8x8[1,p8x8[1,t3] xor ((K32[1] shr 24))] xor ((K32[0] shr 24))]; +end; + + +procedure Xor256( var Dst: T2048; const Src: T2048; v: byte); +var + i, j: Cardinal; + PDst, PSrc: PCardinal; +begin +j := v * $01010101; +PDst := @Dst; +PSrc := @Src; +for i := 0 to 63 do + begin + PDst^ := PSrc^ xor j; + Inc( PSrc); + Inc( PDst) + end +end; + +procedure DCP_twofish_InitKey( + const Key; Size: longword; + var SubKeys: TSubKeys; var SBox: TSBox); +const + subkeyCnt= ROUNDSUBKEYS + 2*NUMROUNDS; +var + key32: T256; + k32e, k32o, sboxkeys: T128; + k64Cnt, i, j, A, B, q: Cardinal; + L0, L1: T2048; +begin + FillChar(Key32,Sizeof(Key32),0); + Move( Key, Key32, Size div 8); + if Size<= 128 then { pad the key to either 128bit, 192bit or 256bit} + Size:= 128 + else if Size<= 192 then + Size:= 192 + else + Size:= 256; + k64Cnt:= Size div 64; + j:= k64Cnt-1; + for i:= 0 to j do + begin + k32e[i]:= key32[2*i]; + k32o[i]:= key32[2*i+1]; + sboxKeys[j]:= RS_MDS_Encode(k32e[i],k32o[i]); + Dec(j); + end; + q:= 0; + for i:= 0 to ((subkeyCnt div 2)-1) do + begin + A:= f32(q,k32e,Size); + B:= f32(q+SK_BUMP,k32o,Size); + B:= (B shl 8) or (B shr 24); + SubKeys[2*i]:= A+B; + B:= A + 2*B; + SubKeys[2*i+1]:= (B shl SK_ROTL) or (B shr (32 - SK_ROTL)); + Inc(q,SK_STEP); + end; + case Size of + 128: begin + Xor256(L0,p8x8[0],(sboxKeys[1] and $FF)); + A:= (sboxKeys[0] and $FF); + i:= 0; + while i< 256 do + begin + sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,L0[i]] xor A]; + sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,L0[i+1]] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[1],(sboxKeys[1] shr 8) and $FF); + A:= (sboxKeys[0] shr 8) and $FF; + i:= 0; + while i< 256 do + begin + sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,L0[i]] xor A]; + sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,L0[i+1]] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[0],(sboxKeys[1] shr 16) and $FF); + A:= (sboxKeys[0] shr 16) and $FF; + i:= 0; + while i< 256 do + begin + sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,L0[i]] xor A]; + sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,L0[i+1]] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[1],(sboxKeys[1] shr 24)); + A:= (sboxKeys[0] shr 24); + i:= 0; + while i< 256 do + begin + sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,L0[i]] xor A]; + sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,L0[i+1]] xor A]; + Inc(i,2); + end; + end; + 192: begin + Xor256(L0,p8x8[1],sboxKeys[2] and $FF); + A:= sboxKeys[0] and $FF; + B:= sboxKeys[1] and $FF; + i:= 0; + while i< 256 do + begin + sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,p8x8[0,L0[i]] xor B] xor A]; + sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,p8x8[0,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[1],(sboxKeys[2] shr 8) and $FF); + A:= (sboxKeys[0] shr 8) and $FF; + B:= (sboxKeys[1] shr 8) and $FF; + i:= 0; + while i< 256 do + begin + sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,p8x8[1,L0[i]] xor B] xor A]; + sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,p8x8[1,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[0],(sboxKeys[2] shr 16) and $FF); + A:= (sboxKeys[0] shr 16) and $FF; + B:= (sboxKeys[1] shr 16) and $FF; + i:= 0; + while i< 256 do + begin + sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,p8x8[0,L0[i]] xor B] xor A]; + sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,p8x8[0,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + Xor256(L0,p8x8[0],(sboxKeys[2] shr 24)); + A:= (sboxKeys[0] shr 24); + B:= (sboxKeys[1] shr 24); + i:= 0; + while i< 256 do + begin + sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,p8x8[1,L0[i]] xor B] xor A]; + sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,p8x8[1,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + end; + 256: begin + Xor256(L1,p8x8[1],(sboxKeys[3]) and $FF); + i:= 0; + while i< 256 do + begin + L0[i ]:= p8x8[1,L1[i]]; + L0[i+1]:= p8x8[1,L1[i+1]]; + Inc(i,2); + end; + Xor256(L0,L0,(sboxKeys[2]) and $FF); + A:= (sboxKeys[0]) and $FF; + B:= (sboxKeys[1]) and $FF; + i:= 0; + while i< 256 do + begin + sBox[0 and 2,2*i+(0 and 1)]:= MDS[0,p8x8[0,p8x8[0,L0[i]] xor B] xor A]; + sBox[0 and 2,2*i+(0 and 1)+2]:= MDS[0,p8x8[0,p8x8[0,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + Xor256(L1,p8x8[0],(sboxKeys[3] shr 8) and $FF); + i:= 0; + while i< 256 do + begin + L0[i ]:= p8x8[1,L1[i]]; + L0[i+1]:= p8x8[1,L1[i+1]]; + Inc(i,2); + end; + Xor256(L0,L0,(sboxKeys[2] shr 8) and $FF); + A:= (sboxKeys[0] shr 8) and $FF; + B:= (sboxKeys[1] shr 8) and $FF; + i:= 0; + while i< 256 do + begin + sBox[1 and 2,2*i+(1 and 1)]:= MDS[1,p8x8[0,p8x8[1,L0[i]] xor B] xor A]; + sBox[1 and 2,2*i+(1 and 1)+2]:= MDS[1,p8x8[0,p8x8[1,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + + Xor256(L1,p8x8[0],(sboxKeys[3] shr 16) and $FF); + i:= 0; + while i< 256 do + begin + L0[i ]:= p8x8[0,L1[i]]; + L0[i+1]:= p8x8[0,L1[i+1]]; + Inc(i,2); + end; + Xor256(L0,L0,(sboxKeys[2] shr 16) and $FF); + A:= (sboxKeys[0] shr 16) and $FF; + B:= (sboxKeys[1] shr 16) and $FF; + i:= 0; + while i< 256 do + begin + sBox[2 and 2,2*i+(2 and 1)]:= MDS[2,p8x8[1,p8x8[0,L0[i]] xor B] xor A]; + sBox[2 and 2,2*i+(2 and 1)+2]:= MDS[2,p8x8[1,p8x8[0,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + Xor256(L1,p8x8[1],(sboxKeys[3] shr 24)); + i:= 0; + while i< 256 do + begin + L0[i ]:= p8x8[0,L1[i]]; + L0[i+1]:= p8x8[0,L1[i+1]]; + Inc(i,2); + end; + Xor256(L0,L0,(sboxKeys[2] shr 24)); + A:= (sboxKeys[0] shr 24); + B:= (sboxKeys[1] shr 24); + i:= 0; + while i< 256 do + begin + sBox[3 and 2,2*i+(3 and 1)]:= MDS[3,p8x8[1,p8x8[1,L0[i]] xor B] xor A]; + sBox[3 and 2,2*i+(3 and 1)+2]:= MDS[3,p8x8[1,p8x8[1,L0[i+1]] xor B] xor A]; + Inc(i,2); + end; + end; + end; +end; + + + + +procedure DCP_twofish_EncryptECB( + const SubKeys: TSubKeys; const SBox: TSBox; + const InData: T128; var OutData: T128); +var + i: longword; + t0, t1: Cardinal; + X: T128; + k: integer; +begin + for k := 0 to 3 do + x[k] := InData[k] xor SubKeys[INPUTWHITEN+k]; + i:= 0; + while i<= NUMROUNDS-2 do + begin + t0:= sBox[0,(x[0] shl 1) and $1fe] xor sBox[0,((x[0] shr 7) and $1fe)+1] + xor sBox[2,(x[0] shr 15) and $1fe] xor sBox[2,((x[0] shr 23) and $1fe)+1]; + t1:= sBox[0,((x[1] shr 23) and $1fe)] xor sBox[0,((x[1] shl 1) and $1fe)+1] + xor sBox[2,((x[1] shr 7) and $1fe)] xor sBox[2,((x[1] shr 15) and $1fe)+1]; + x[3]:= (x[3] shl 1) or (x[3] shr 31); + x[2]:= x[2] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*i]); + x[3]:= x[3] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*i+1]); + x[2]:= (x[2] shr 1) or (x[2] shl 31); + + t0:= sBox[0,(x[2] shl 1) and $1fe] xor sBox[0,((x[2] shr 7) and $1fe)+1] + xor sBox[2,((x[2] shr 15) and $1fe)] xor sBox[2,((x[2] shr 23) and $1fe)+1]; + t1:= sBox[0,((x[3] shr 23) and $1fe)] xor sBox[0,((x[3] shl 1) and $1fe)+1] + xor sBox[2,((x[3] shr 7) and $1fe)] xor sBox[2,((x[3] shr 15) and $1fe)+1]; + x[1]:= (x[1] shl 1) or (x[1] shr 31); + x[0]:= x[0] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)]); + x[1]:= x[1] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)+1]); + x[0]:= (x[0] shr 1) or (x[0] shl 31); + Inc(i,2); + end; + OutData[ 0] := x[2] xor SubKeys[OUTPUTWHITEN]; + OutData[ 1] := x[3] xor SubKeys[OUTPUTWHITEN+1]; + OutData[ 2] := x[0] xor SubKeys[OUTPUTWHITEN+2]; + OutData[ 3] := x[1] xor SubKeys[OUTPUTWHITEN+3]; +end; + + +procedure DCP_twofish_DecryptECB( + const SubKeys: TSubKeys; const SBox: TSBox; + const InData: T128; var OutData: T128); +var + i, k: integer; + t0, t1: Cardinal; + X: T128; +begin + X[2] := InData[0] xor SubKeys[OUTPUTWHITEN]; + X[3] := InData[1] xor SubKeys[OUTPUTWHITEN+1]; + X[0] := InData[2] xor SubKeys[OUTPUTWHITEN+2]; + X[1] := InData[3] xor SubKeys[OUTPUTWHITEN+3]; + i:= NUMROUNDS-2; + while i>= 0 do + begin + t0:= sBox[0,(x[2] shl 1) and $1fe] xor sBox[0,((x[2] shr 7) and $1fe)+1] + xor sBox[2,((x[2] shr 15) and $1fe)] xor sBox[2,((x[2] shr 23) and $1fe)+1]; + t1:= sBox[0,((x[3] shr 23) and $1fe)] xor sBox[0,((x[3] shl 1) and $1fe)+1] + xor sBox[2,((x[3] shr 7) and $1fe)] xor sBox[2,((x[3] shr 15) and $1fe)+1]; + x[0]:= (x[0] shl 1) or (x[0] shr 31); + x[0]:= x[0] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)]); + x[1]:= x[1] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*(i+1)+1]); + x[1]:= (x[1] shr 1) or (x[1] shl 31); + + t0:= sBox[0,(x[0] shl 1) and $1fe] xor sBox[0,((x[0] shr 7) and $1fe)+1] + xor sBox[2,(x[0] shr 15) and $1fe] xor sBox[2,((x[0] shr 23) and $1fe)+1]; + t1:= sBox[0,((x[1] shr 23) and $1fe)] xor sBox[0,((x[1] shl 1) and $1fe)+1] + xor sBox[2,((x[1] shr 7) and $1fe)] xor sBox[2,((x[1] shr 15) and $1fe)+1]; + x[2]:= (x[2] shl 1) or (x[2] shr 31); + x[2]:= x[2] xor (t0 + t1 + SubKeys[ROUNDSUBKEYS+2*i]); + x[3]:= x[3] xor (t0 + 2*t1 + SubKeys[ROUNDSUBKEYS+2*i+1]); + x[3]:= (x[3] shr 1) or (x[3] shl 31); + Dec(i,2); + end; + for k := 0 to 3 do + OutData[k] := X[k] xor SubKeys[INPUTWHITEN+k] +end; + + +procedure DCP_towfish_Precomp; +var + m1, mx, my: array[0..1] of Cardinal; + nI: longword; +begin + for nI:= 0 to 255 do + begin + m1[0]:= p8x8[0,nI]; + mx[0]:= Mul_X(m1[0]); + my[0]:= Mul_Y(m1[0]); + m1[1]:= p8x8[1,nI]; + mx[1]:= Mul_X(m1[1]); + my[1]:= Mul_Y(m1[1]); + mds[0,nI]:= (m1[1] shl 0) or + (mx[1] shl 8) or + (my[1] shl 16) or + (my[1] shl 24); + mds[1,nI]:= (my[0] shl 0) or + (my[0] shl 8) or + (mx[0] shl 16) or + (m1[0] shl 24); + mds[2,nI]:= (mx[1] shl 0) or + (my[1] shl 8) or + (m1[1] shl 16) or + (my[1] shl 24); + mds[3,nI]:= (mx[0] shl 0) or + (m1[0] shl 8) or + (my[0] shl 16) or + (mx[0] shl 24); + end; +end; + + + +end. + diff --git a/run/TPLB3.DES.pas b/LockBox3/run/TPLB3.DES.pas similarity index 97% rename from run/TPLB3.DES.pas rename to LockBox3/run/TPLB3.DES.pas index ce3255d..b0bd0c4 100644 --- a/run/TPLB3.DES.pas +++ b/LockBox3/run/TPLB3.DES.pas @@ -1,1390 +1,1390 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.DES; -interface -uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher; - -type - -TDES = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; // in units of bits. Must be a multiple of 8. - function KeySize: integer; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - - public - constructor Create; - end; - - -TExpandedKey = array[ 0 .. 15 ] of uint64; - -{$IF CompilerVersion < 21} -uint32 = cardinal; -{$IFEND} -// The following routines are exposed only for the sake of D-Unit tests. -procedure IP_Transform( Datum: uint64; var L, R: uint32); -procedure IP_InverseTransform( L, R: uint32; var Datum: uint64); -procedure DES_EncryptBlock( - Plaintext: uint64; var Ciphertext: uint64; const Key: TExpandedKey); -procedure DES_DecryptBlock( - Ciphertext: uint64; var Plaintext: uint64; const Key: TExpandedKey); -procedure ExpandKey( Key: uint64; var Ex: TExpandedKey); -function PC_1( K: uint64): uint64; -function PC_2( L, R: uint32): uint64; -function E_Bit_Selection( R: uint32): uint64; -procedure SetParityBitsOnKey( var K: uint64); -function hasCorrectParity( K: uint64): boolean; - -implementation - - - - - - - - - -uses TPLB3.Constants, SysUtils, TPLB3.I18n; - -{ Information Resources - ===================== -(1) http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf -(2) http://www.tropsoft.com/strongenc/des.htm -(3) http://orlingrabbe.com/des.htm -(4) http://en.wikipedia.org/wiki/Data_Encryption_Standard -(5) http://www.itl.nist.gov/fipspubs/fip81.htm - -} - - - -{ The DES standard describes a transform of 64 bits to 64 bits, with -the bits numbered from 1 to 64 (see figure 1 of FIBS PUB 46-3). -Somewhat annoyingly it does not define how these 64 bits are encoded -in an 8-bit byte stream, in relation to endien-ness. There are at least -4 different endien encodings possible. This ambiguity in the standard is not -cryptographically significant, but it does impact on implementation. - -In LockBox 3, the DES algorithm will use the following endien encoding: - * Bit 1 (designated b1) is encoded in the most significant bit (MSB) of byte address 0. - * Bit 2 (designated b2) is encoded in the 2nd MSB of byte address 0. - * b8 is encoded in the LSB of byte address 0. - * b9 is encoded in the MSB of byte address 1. - * b64 is encoded in the LSB of byte address 7. -} - -type -TDESKey = class( TSymetricKey) - private - FNativeKey : uint64; - FExpandedKey: TExpandedKey; - - public - constructor Create( NativeKey1: uint64); - constructor CreateFromStream( Store: TStream); - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -TDESCodec = class( TInterfacedObject, IBlockCodec) - private - FLockBoxKey: TDESKey; - - constructor Create( LockBoxKey1: TDESKey); - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - end; - - - -function PC_1( K: uint64): uint64; -var - L, R: uint32; - t8: byte; - t32: uint32; - t16: word; -begin -// input K = 57 58 59 60 61 62 63 64 | 49 50 51 52 53 54 55 56 | 41 42 43 44 45 46 47 48 | 33 34 35 36 37 38 39 40 | 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 - -//PC-1 output = -//57 49 41 33 25 17 9 -// 1 58 50 42 34 26 18 -//10 2 59 51 43 35 27 -//19 11 3 60 52 44 36 -//63 55 47 39 31 23 15 -// 7 62 54 46 38 30 22 -//14 6 61 53 45 37 29 -//21 13 5 28 20 12 4 - -// We desire result, such that: -// result.Bytes[0] = 57 49 41 33 25 17 9 1 -// result.Bytes[1] = 58 50 42 34 26 18 10 2 -// result.Bytes[2] = 59 51 43 35 27 19 11 3 -// result.Bytes[3] = 60 52 44 36 63 55 47 39 -// result.Bytes[4] = 31 23 15 7 62 54 46 38 -// result.Bytes[5] = 30 22 14 6 61 53 45 37 -// result.Bytes[6] = 29 21 13 5 28 20 12 4 -// result.Bytes[7] = 0 0 0 0 0 0 0 0 - -// In other words we wish to go from LR to L'R' where: -//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 -//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 -// -//L' = 60 52 44 36 63 55 47 39 59 51 43 35 27 19 11 3 58 50 42 34 26 18 10 2 57 49 41 33 25 17 9 1 -//R' = 0 0 0 0 0 0 0 0 29 21 13 5 28 20 12 4 30 22 14 6 61 53 45 37 31 23 15 7 62 54 46 38 - -// Sample data: -//K = (big-endien) 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 -//K = (little-endien) 11110001 11011111 10111100 10011011 01111001 01010111 00110100 00010011 -//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 -// 0 1 1 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 -//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 -// 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 - -// Origin. Start with: -L := Int64Rec( K).Lo; -R := Int64Rec( K).Hi; -//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 -//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 -// 0 1 1 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 -// 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 - - -// Step 1. Center byte swap. -t8 := LongRec( L).Bytes[2]; -LongRec( L).Bytes[2] := LongRec( L).Bytes[1]; -LongRec( L).Bytes[1] := t8; -t8 := LongRec( R).Bytes[2]; -LongRec( R).Bytes[2] := LongRec( R).Bytes[1]; -LongRec( R).Bytes[1] := t8; -//L = 25 26 27 28 29 30 31 32 | 9 10 11 12 13 14 15 16 | 17 18 19 20 21 22 23 24 | 1 2 3 4 5 6 7 8 -//R = 57 58 59 60 61 62 63 64 | 41 42 43 44 45 46 47 48 | 49 50 51 52 53 54 55 56 | 33 34 35 36 37 38 39 40 -// 0 1 1 1 1 0 0 1 | 0 0 1 1 0 1 0 0 | 0 1 0 1 0 1 1 1 | 0 0 0 1 0 0 1 1 -// 1 1 1 1 0 0 0 1 | 1 0 1 1 1 1 0 0 | 1 1 0 1 1 1 1 1 | 1 0 0 1 1 0 1 1 - -// Step 2. Swap nibbles in each L byte. -L := ((L shl 4) and $F0F0F0F0) or ((L shr 4) and $0F0F0F0F); -//L = 29 30 31 32 25 26 27 28 | 13 14 15 16 9 10 11 12 | 21 22 23 24 17 18 19 20 | 5 6 7 8 1 2 3 4 -//R = 57 58 59 60 61 62 63 64 | 41 42 43 44 45 46 47 48 | 49 50 51 52 53 54 55 56 | 33 34 35 36 37 38 39 40 - -// Step 3. Swap high nibbles between L & R -t32 := (L and $0F0F0F0F) or (R and $F0F0F0F0); -R := (L and $F0F0F0F0) or (R and $0F0F0F0F); -L := t32; -//L = 57 58 59 60 25 26 27 28 | 41 42 43 44 9 10 11 12 | 49 50 51 52 17 18 19 20 | 33 34 35 36 1 2 3 4 -//R = 29 30 31 32 61 62 63 64 | 13 14 15 16 45 46 47 48 | 21 22 23 24 53 54 55 56 | 5 6 7 8 37 38 39 40 - -// Step 4. Swap bytes -t8 := LongRec( L).Bytes[1]; -LongRec( L).Bytes[1] := LongRec( R).Bytes[0]; -LongRec( R).Bytes[0] := t8; -t8 := LongRec( L).Bytes[3]; -LongRec( L).Bytes[3] := LongRec( R).Bytes[2]; -LongRec( R).Bytes[2] := t8; -//L = 13 14 15 16 45 46 47 48 | 41 42 43 44 9 10 11 12 | 5 6 7 8 37 38 39 40 | 33 34 35 36 1 2 3 4 -//R = 29 30 31 32 61 62 63 64 | 57 58 59 60 25 26 27 28 | 21 22 23 24 53 54 55 56 | 49 50 51 52 17 18 19 20 - -// Step 5. 2-bit swap -// L = a-->d b -// R = c d-->a -T32 := ((L shr 2) xor R) and $33333333; -R := R xor T32; -L := L xor (T32 shl 2); -//L = 31 32 15 16 63 64 47 48 | 59 60 43 44 27 28 11 12 | 23 24 7 8 55 56 39 40 | 51 52 35 36 19 20 3 4 -//R = 29 30 13 14 61 62 45 46 | 57 58 41 42 25 26 9 10 | 21 22 5 6 53 54 37 38 | 49 50 33 34 17 18 1 2 - -// Step 5. Word swap -t16 := LongRec( L).Lo; -LongRec( L).Lo := LongRec( R).Hi; -LongRec( R).Hi := t16; -//L = 31 32 15 16 63 64 47 48 | 59 60 43 44 27 28 11 12 | 29 30 13 14 61 62 45 46 | 57 58 41 42 25 26 9 10 -//R = 23 24 7 8 55 56 39 40 | 51 52 35 36 19 20 3 4 | 21 22 5 6 53 54 37 38 | 49 50 33 34 17 18 1 2 - -// Step 6. 1-bit swap -// L = a b-->c -// R = c-->b d -T32 := ((R shr 1) xor L) and $55555555; -L := L xor T32; -R := R xor (T32 shl 1); -//L = 31 23 15 7 63 55 47 39 | 59 51 43 35 27 19 11 3 | 29 21 13 5 61 53 45 37 | 57 49 41 33 25 17 9 1 -//R = 32 24 16 8 64 56 48 40 | 60 52 44 36 28 20 12 4 | 30 22 14 6 62 54 46 38 | 58 50 42 34 26 18 10 2 - -// Step 6. byte swap -t8 := LongRec( R).Bytes[0]; -LongRec( R).Bytes[0] := LongRec( L).Bytes[1]; -LongRec( L).Bytes[1] := t8; -t8 := LongRec( R).Bytes[2]; -LongRec( R).Bytes[2] := LongRec( L).Bytes[3]; -LongRec( L).Bytes[3] := t8; -//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 -//R = 32 24 16 8 64 56 48 40 | 31 23 15 7 63 55 47 39 | 30 22 14 6 62 54 46 38 | 29 21 13 5 61 53 45 37 - -// Step 7. Clear R high byte. -LongRec( R).Bytes[3] := 0; -//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 -//R = 0 0 0 0 0 0 0 0 | 31 23 15 7 63 55 47 39 | 30 22 14 6 62 54 46 38 | 29 21 13 5 61 53 45 37 - -// Step 8. Swap nibbles: R[0].LoN <--> R[1].LoN . -t8 := LongRec( R).Bytes[0] and $0F; -LongRec( R).Bytes[0] := (LongRec( R).Bytes[0] and $F0) or (LongRec( R).Bytes[1] and $0F); -LongRec( R).Bytes[1] := (LongRec( R).Bytes[1] and $F0) or t8; -//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 -//R = 0 0 0 0 0 0 0 0 | 31 23 15 7 63 55 47 39 | 30 22 14 6 61 53 45 37 | 29 21 13 5 62 54 46 38 - -// Step 9. Swap nibbles: L[3].LoN <--> R[2].LoN . and -// R[2].HiN <--> R[0].HiN -t8 := LongRec( R).Bytes[2]; -LongRec( R).Bytes[2] := (LongRec( R).Bytes[0] and $F0) or (LongRec( L).Bytes[3] and $0F); -LongRec( L).Bytes[3] := (LongRec( L).Bytes[3] and $F0) or (t8 and $0F); -LongRec( R).Bytes[0] := (t8 and $F0) or (LongRec( R).Bytes[0] and $0F); -//L = 60 52 44 36 63 55 47 39 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 -//R = 0 0 0 0 0 0 0 0 | 29 21 13 5 28 20 12 4 | 30 22 14 6 61 53 45 37 | 31 23 15 7 62 54 46 38 - -// ... which is our desired final result! -//L' = 60 52 44 36 63 55 47 39 59 51 43 35 27 19 11 3 58 50 42 34 26 18 10 2 57 49 41 33 25 17 9 1 -//R' = 0 0 0 0 0 0 0 0 29 21 13 5 28 20 12 4 30 22 14 6 61 53 45 37 31 23 15 7 62 54 46 38 - -// Marshal the return. -Int64Rec( result).Lo := L; -Int64Rec( result).Hi := R -end; - - - - - - -function PC_2( L, R: uint32): uint64; -// input L = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 (Little-endien) -// input R = 53 54 55 56 0 0 0 0 | 45 46 47 48 49 50 51 52 | 37 28 39 40 41 42 43 44 | 29 30 31 32 33 34 35 36 - -//PC-2 output = -//14 17 11 24 1 5 -// 3 28 15 6 21 10 -//23 19 12 4 26 8 -//16 7 27 20 13 2 -//41 52 31 37 47 55 -//30 40 51 45 33 48 -//44 49 39 56 34 53 -//46 42 50 36 29 32 - -// Unlike PC-1 in which we marshaled the result by packing the bits, -// for this return, we want to marshal the result into 8 times 6 bits, -// with the result in the low 6 bits of each byte. -// We desire result, such that: -// result.Bytes[0] = 0 0 14 17 11 24 1 5 -// result.Bytes[1] = 0 0 3 28 15 6 21 10 -// result.Bytes[2] = 0 0 23 19 12 4 26 8 -// result.Bytes[3] = 0 0 16 7 27 20 13 2 -// result.Bytes[4] = 0 0 41 52 31 37 47 55 -// result.Bytes[5] = 0 0 30 40 51 45 33 48 -// result.Bytes[6] = 0 0 44 49 39 56 34 53 -// result.Bytes[7] = 0 0 46 42 50 36 29 32 - -// In other words we wish to go from LR to L'R' where: -// L = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 -// R = 53 54 55 56 0 0 0 0 | 45 46 47 48 49 50 51 52 | 37 28 39 40 41 42 43 44 | 29 30 31 32 33 34 35 36 -// -// L' = 0 0 16 7 27 20 13 2 | 0 0 23 19 12 4 26 8 | 0 0 3 28 15 6 21 10 | 0 0 14 17 11 24 1 5 -// R' = 0 0 46 42 50 36 29 32 | 0 0 44 49 39 56 34 53 | 0 0 30 40 51 45 33 48 | 0 0 41 52 31 37 47 55 - -// Ex. 1: $3201073F2F0B3006 = PC_2( $F05599E1, $E0F1CCAA); -// Ex. 2: $25273C36193B1A1E = PC_2( $F0AB32C3, $D0E39955); - -// http://orlingrabbe.com/des.htm test data: -// C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (big-endien compact 56 bits) -// L = 1110000 1100110 0101010 1011111 (big-endien compact 28 bits; 7 bit groups) -// L = 11100001 10011001 01010101 11110000 (big-endien 32 bits; 8 bit groups) -// L = 1111 0000 0101 0101 1001 1001 1110 0001 (little-endien 32 bits; 4 bit groups) -// L = $F05599E1; (Delphi) -// R = 1010101 0110011 0011110 0011110 (big-endien compact 28 bits; 7 bit groups) -// R = 10101010 11001100 11110001 11100000 (big-endien 32 bits; 8 bit groups) -// R = 1110 0000 | 1111 0001 | 1100 1100 | 1010 1010 (little-endien 32 bits; 4 bit groups) -// R = $E0F1CCAA (Delphi) -// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien compact 48 bits; 6 bit rows) -// K1 = 00000110 00110000 00001011 00101111 00111111 00000111 00000001 00110010 (big-endien 64 bits; 8 bit rows) -// K1 = 0011 0010 | 0000 0001 | 0000 0111 | 0011 1111 | 0010 1111 | 00001 011 | 0011 0000 | 0000 0110 (little-endien 64 bits; 4 bit rows) -// K1 = $3201073F2F0B3006; (Delphi) - -var - b0, b1, b2, b3, b4, b5, b6, b7: byte; -begin -// Sledge-hammer approach. This implementation is not as efficient as it -// could be. The reader is invited to exlore more efficient solutions. -// Please keep me advised. -b0 := LongRec( L).Bytes[0]; // $E1 -b1 := LongRec( L).Bytes[1]; // $99 -b2 := LongRec( L).Bytes[2]; // $55 -b3 := LongRec( L).Bytes[3]; // $F0 -b4 := LongRec( R).Bytes[0]; // $AA -b5 := LongRec( R).Bytes[1]; // $CC -b6 := LongRec( R).Bytes[2]; // $F1 -b7 := LongRec( R).Bytes[3]; // $E0 -// The following code was programmatically generated, deriving from the -// published PC-2 table. -Int64Rec( result).Bytes[ 0] := ((b1 and $04) shl 3) or // DONE - ((b2 and $80) shr 3) or - ((b1 and $20) shr 2) or - ((b2 and $01) shl 2) or - ((b0 and $80) shr 6) or - ((b0 and $08) shr 3); // Expect = $06 - -Int64Rec( result).Bytes[ 1] := (b0 and $20) or // DONE - (b3 and $10) or - ((b1 and $02) shl 2) or - (b0 and $04) or - ((b2 and $08) shr 2) or - ((b1 and $40) shr 6); // Expect = $30 - -Int64Rec( result).Bytes[ 2] := ((b2 and $02) shl 4) or // DONE - ((b2 and $20) shr 1) or - ((b1 and $10) shr 1) or - ((b0 and $10) shr 2) or - ((b3 and $40) shr 5) or - (b0 and $01) ; // Expect = $0B - -Int64Rec( result).Bytes[ 3] := ((b1 and $01) shl 5) or // DONE - ((b0 and $02) shl 3) or - ((b3 and $20) shr 2) or - ((b2 and $10) shr 2) or - ((b1 and $08) shr 2) or - ((b0 and $40) shr 6); // Expect = $2F - -// 0 0 41 52 31 37 47 55 -Int64Rec( result).Bytes[ 4] := ((b5 and $08) shl 2) or // DONE - ((b6 and $01) shl 4) or // - ((b4 and $20) shr 2) or // - ((b5 and $80) shr 5) or // - ((b6 and $20) shr 4) or // - ((b7 and $20) shr 5); // Expect = $3F bit 55; e=1;g=0 - -// 0 0 30 40 51 45 33 48 -Int64Rec( result).Bytes[ 5] := ((b4 and $40) shr 1) or // DONE - (b5 and $10) or // - ((b6 and $02) shl 2) or // - ((b6 and $80) shr 5) or // - ((b4 and $08) shr 2) or // - ((b6 and $10) shr 4); // Expect = $07 - -// 0 0 44 49 39 56 34 53 -Int64Rec( result).Bytes[ 6] := ((b5 and $01) shl 5) or // DONE - ((b6 and $08) shl 1) or // - ((b5 and $20) shr 2) or // - ((b7 and $10) shr 2) or // e=1;g=0 - ((b4 and $04) shr 1) or // - ((b7 and $80) shr 7); // Expect = $01 - -// 0 0 46 42 50 36 29 32 -Int64Rec( result).Bytes[ 7] := ((b6 and $40) shr 1) or // DONE - ((b5 and $04) shl 2) or - ((b6 and $04) shl 1) or - ((b4 and $01) shl 2) or - ((b4 and $80) shr 6) or - ((b4 and $10) shr 4); // Expect = $32 -end; - - - -procedure Roll1( var Value: uint32); -// Does a big-endien roll left 1 -// going from C to C' thus: -// C = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 -// C' = 26 27 28 1 0 0 0 0 | 18 19 20 21 22 23 24 25 |10 11 12 13 14 15 16 17 | 2 3 4 5 6 7 8 9 -begin -Value := ((Value shl 1) and $EEFEFEFE) or - ((Value and $80808000) shr 15) or - ((Value and $00000080) shl 21) -end; - - - -procedure ExpandKey( Key: uint64; var Ex: TExpandedKey); -const - isTwoRolls: array[0..15] of boolean = ( - False, False, True, True, True , True , True, True, - False, True , True, True, True , True , True, False); -var - CD: uint64; - C, D: uint32; - i: integer; -begin -CD := PC_1( Key); -C := int64Rec( CD).Lo and $F0FFFFFF ; // Low 28 big-endien bits. -D := ((int64Rec( CD).Lo shr 20) and $000000F0) or // Next 28 big-endien bits. - ((int64Rec( CD).Hi shl 12) and $F0F0F000) or - ((int64Rec( CD).Hi shr 4) and $0F0F0F0F); - -for i := 0 to 15 do - begin - // Example test data from http://orlingrabbe.com/des.htm - // C0 = 1111000011001100101010101111 (big-endien; 28 bits) - // C0 = 11110000110011001010101011110000 (big-endien; 32 bits = 28 + 4 zeroes at the end) - // C0 = 1111 0000 | 1100 1100 | 1010 1010 | 1111 0000 (big-endien; 32 bits = 28 + 4 zeroes at the end) - // C0 = 1111 0000 | 1010 1010 | 1100 1100 | 1111 0000 (litte-endien 32 bits) - // C0 = F 0 A A C C F 0 (litte-endien hex) - // C0 = $F0AACCF0; (Delphi) - // C1 = C0 [big-endien roll left] 1 - // C1 = 1110000110011001010101011111 (big-endien 28 bits) - // C1 = 1110 0001 | 1001 1001 | 0101 0101 | 1111 0000 (big-endien 32 bits) - // C1 = 1111 0000 | 0101 0101 | 1001 1001 | 1110 0001 (little-endien 32 bits) - // C1 = $F05599E1; (Delphi) - Roll1( C); - // For test data case and i=0, check C = $F05599E1 - Roll1( D); - if isTwoRolls[i] then - begin - Roll1( C); - Roll1( D); - end; - Ex[i] := PC_2( C, D) - // K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien 48; 6-bit groups) - // K1 = 110010 000001 000111 111111 101111 001011 110000 000110 (little-endien 48; 6-bit groups) - // K1 = 00110010 00000001 00000111 00111111 00101111 00001011 00110000 00000110 (little-endien 64; 8-bit groups = 48 bits + 2MSB zeros) - // K1 = $3201073F2F0B3006; (Delphi) - // Ex[0] = $3201073F2F0B3006 = PC_2( $F05599E1, $E0F1CCAA); - // Ex[1] = $25273C36193B1A1E = PC_2( $F0AB32C3, $D0E39955); - end -end; - - - -procedure IP_Transform( Datum: uint64; var L, R: uint32); -// See IP_InverseTransform for an explaination of how this works. -var - T32: uint32; - T16: word; - T8: byte; -begin -L := Int64Rec( Datum).Lo; -R := Int64Rec( Datum).Hi; -T32 := ((L shr 4) xor R) and $0F0F0F0F; -R := R xor T32; -L := L xor (T32 shl 4); -T16 := LongRec(L).Lo; -LongRec(L).Lo := LongRec(R).Hi; -LongRec(R).Hi := T16; -T32 := ((R shr 2) xor L) and $33333333; -L := L xor T32; -R := R xor (T32 shl 2); -T8 := LongRec(R).Bytes[0]; -LongRec(R).Bytes[0] := LongRec(L).Bytes[1]; -LongRec(L).Bytes[1] := T8; -T8 := LongRec(R).Bytes[2]; -LongRec(R).Bytes[2] := LongRec(L).Bytes[3]; -LongRec(L).Bytes[3] := T8; -T32 := ((L shr 1) xor R) and $55555555; -R := R xor T32; -L := L xor (T32 shl 1) -{ http://orlingrabbe.com/des.htm gives an example in a binary - lowest-address=byte-left, MSB-within-byte-left format: -M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 -IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 - -In our native format drawing format, this is equivalent to: -M = $EFCDAB8967452301; -L = $FFCC00CC; -R = $AAF0AAF0 - -} -end; - - - -procedure IP_InverseTransform( L, R: uint32; var Datum: uint64); -var - T32: uint32; - T16: word; - T8: byte; -{ -Start with input 64 bits (MLB left) -58 50 42 34 26 18 10 2 -60 52 44 36 28 20 12 4 -62 54 46 38 30 22 14 6 -64 56 48 40 32 24 16 8 -57 49 41 33 25 17 9 1 -59 51 43 35 27 19 11 3 -61 53 45 37 29 21 13 5 -63 55 47 39 31 23 15 7 - -Your may recognise this as the IP table on page 10 of the standard. -The above is drawn 1 byte per row, with the lowest address byte on the top -row and the highest address byte on the bottom row. In a little-endien -architecture, the first row is the Least Significant byte. In a big-endien -architecture, the first row is the Most Significant byte. In either case, -the first row is the lowest address byte. -Within a byte, the bits are drawn from MSB on the left to LSB on the right. -The numbers in the matrix are the DES designation for bits. The standard -designates the 'first' bit to be bit 1 (or B1). I interpret 'first' bit -to mean MSB. - -We can split these 64 bits into two 32 two bit native (little-endien) integers. -L is first, followed by R. - -So .... -L = 64 56 48 40 32 24 16 8 62 54 46 38 30 22 14 6 60 52 44 36 28 20 12 4 58 50 42 34 26 18 10 2 -R = 63 55 47 39 31 23 15 7 61 53 45 37 29 21 13 5 59 51 43 35 27 19 11 3 57 49 41 33 25 17 9 1 - -The L, R is drawn from MSB on the left to LSB on the right. - -NOTE: -The standard and most examples you can find are terribly endien-biggoted. -They implicitly assume a big-endien architecture and are often ambigious -in a little-endien context. - -For example, refer to "http://orlingrabbe.com/des.htm", section "How DES Works in Detail". -In this example, - M = the mathematical, unencoded number $123456789ABCDEF; -but DES does not operate on numbers, it transforms blocks of 8 bytes. -The article really means - M = the 8 bytes (lowest address byte left-most): $01 $23 $45 $67 $89 $AB $CD $EF -On a little-endien machine, this is the encoded form of the number $EFCDAB8967351201. - or M: uint64 = $EFCDAB8967351201; -The first byte is $01, and the first bit of the first byte is 0. -In a binary lowest-address=byte-left, MSB-within-byte-left format, this datum is drawn: - M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 - L = 0000 0001 0010 0011 0100 0101 0110 0111 - R = 1000 1001 1010 1011 1100 1101 1110 1111 - -However, the same datum, drawn in a 'native' format (highest-address=byte-left, MSB-within-byte-left format) is drawn thus: - M = 1110 1111 1100 1101 1010 1011 1000 1001 0110 0111 0100 0101 0010 0011 0000 0001 - L = 0110 0111 0100 0101 0010 0011 0000 0001 - R = 1110 1111 1100 1101 1010 1011 1000 1001 - -The word 'native' means in respect of how, in a little-endien machine, -the drawing of an encoded number harmonises with the 'shl' operator shifting -LEFT, and the shr operator shifting RIGHT. - -Reading these endien biggoted source documents can get really confusing -until you acknowledge that there is more than one way to draw the same datum. - -Our goal is to reach ... - 1 2 3 4 5 6 7 8 - 9 10 11 12 13 14 15 16 - 17 18 19 20 21 22 23 24 - 25 26 27 28 29 30 31 32 - 33 34 35 36 37 38 39 40 - 41 42 43 44 45 46 47 48 - 49 50 51 52 53 54 55 56 - 57 58 59 60 61 62 63 64 - -or equivalently .... -L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 -R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 -} - - -begin -// Test case data: -// L = $34324243 -// R = $95D94C0A ==> -// Datum = $05B40A0F5413E885 - -// convert ciphertext LR to plaintext M -// L = 64 56 48 40 32 24 16 8 62 54 46 38 30 22 14 6 60 52 44 36 28 20 12 4 58 50 42 34 26 18 10 2 -// R = 63 55 47 39 31 23 15 7 61 53 45 37 29 21 13 5 59 51 43 35 27 19 11 3 57 49 41 33 25 17 9 1 - -// Step 1. Do a 1 bit cross-over. -// L = a-->d b -// R = c d-->a -T32 := ((L shr 1) xor R) and $55555555; -R := R xor T32; -L := L xor (T32 shl 1); - -// L = 55 56 39 40 23 24 7 8 53 54 37 38 21 22 5 6 51 52 35 36 19 20 3 4 49 50 33 34 17 18 1 2 -// R = 63 64 47 48 31 32 15 16 61 62 45 46 29 30 13 14 59 60 43 44 27 28 11 12 57 58 41 42 25 26 9 10 - -// Step 2. Do a byte cross-over. -// L = a-->d b -// R = c d-->a -T8 := LongRec(R).Bytes[0]; -LongRec(R).Bytes[0] := LongRec(L).Bytes[1]; -LongRec(L).Bytes[1] := T8; -T8 := LongRec(R).Bytes[2]; -LongRec(R).Bytes[2] := LongRec(L).Bytes[3]; -LongRec(L).Bytes[3] := T8; - -// L = 61 62 45 46 29 30 13 14 | 53 54 37 38 21 22 5 6 | 57 58 41 42 25 26 9 10 | 49 50 33 34 17 18 1 2 -// R = 63 64 47 48 31 32 15 16 | 55 56 39 40 23 24 7 8 | 59 60 43 44 27 28 11 12 | 51 52 35 36 19 20 3 4 - -// Step 3. Do a 2 bit cross-over. -// L = a b-->c -// R = c-->b d -T32 := ((R shr 2) xor L) and $33333333; -L := L xor T32; -R := R xor (T32 shl 2); - -// L = 61 62 63 64 29 30 31 32 | 53 54 55 56 21 22 23 24 | 57 58 59 60 25 26 27 28 | 49 50 51 52 17 18 19 20 -// R = 45 46 47 48 13 14 15 16 | 37 38 39 40 5 6 7 8 | 41 42 43 44 9 10 11 12 | 33 34 35 36 1 2 3 4 - -// Step 4. Do a word cross-over. -// L = a b-->c -// R = c-->b d Change here -T16 := LongRec(L).Lo; -LongRec(L).Lo := LongRec(R).Hi; -LongRec(R).Hi := T16; - -// L = 61 62 63 64 29 30 31 32 | 53 54 55 56 21 22 23 24 | 45 46 47 48 13 14 15 16 | 37 38 39 40 5 6 7 8 -// R = 57 58 59 60 25 26 27 28 | 49 50 51 52 17 18 19 20 | 41 42 43 44 9 10 11 12 | 33 34 35 36 1 2 3 4 - -// Step 5. Do a nibble cross-over -// L = a-->d b -// R = c d-->a -T32 := ((L shr 4) xor R) and $0F0F0F0F; -R := R xor T32; -L := L xor (T32 shl 4); - -// L = 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 -// R = 57 58 59 60 61 62 63 64 | 49 50 51 52 53 54 55 56 | 41 42 43 44 45 46 47 48 | 33 34 35 36 37 38 39 40 - -Int64Rec( Datum).Lo := L; -Int64Rec( Datum).Hi := R -end; - - - -function E_Bit_Selection( R: uint32): uint64; -var - i, j, k: integer; -begin -// E-bit selection table is ... -//32 1 2 3 4 5 -// 4 5 6 7 8 9 -// 8 9 10 11 12 13 -//12 13 14 15 16 17 -//16 17 18 19 20 21 -//20 21 22 23 24 25 -//24 25 26 27 28 29 -//28 29 30 31 32 1 - -// where R is ... -// R = 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 - -// Example data from http://orlingrabbe.com/des.htm -// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien 32) -// R0 = $AAF0AAF0; -// E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (big-endien 48) -// E(R0) = 010101 010101 100001 011110 010101 010101 100001 011110 (little-endien 48) -// E(R0) = 00010101 00010101 00100001 00011110 00010101 00010101 00100001 00011110 (little-endien 64 = 48 + 2MBS zeros per row) -// E(R0) = 00010101 00010101 00100001 00011110 00010101 00010101 00100001 00011110 (little-endien 64 = 48 + 2MBS zeros per row) -// E(R0) = $1515211E1515211E; (Delphi) -j := 1; -for i := 0 to 3 do - begin - k := i + 1; - if k = 4 then - k := 0; - Int64Rec( result).Bytes[j] := ((LongRec( R).Bytes[i] shl 1) and $3F) xor (LongRec( R).Bytes[k] shr 7); - Inc( j); - if j = 8 then - j := 0; - Int64Rec( result).Bytes[j] := ((LongRec( R).Bytes[i] shl 5) and $3F) xor (LongRec( R).Bytes[k] shr 3); - Inc( j) - end; -end; - - - -const SBox: array[ {Subkey:}0..7, {B-value:}0..63] of 0.. 15 = ( -{Subkey 0} ( -14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, -3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, -4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, -15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13), - -{Subkey 1} ( -15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, -9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, -0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, -5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9), - -{Subkey 2} ( -10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, -1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, -13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, -11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12), - -{Subkey 3} ( -7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, -1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, -10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, -15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14), - -{Subkey 4} ( -2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, -8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, -4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, -15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3), - -{Subkey 5} ( -12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, -0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, -9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, -7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13), - -{Subkey 6} ( -4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, -3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, -1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, -10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12), - -{Subkey 7} ( -13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, -10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, -7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, -0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11)); - - -BytePermute_8_6_7_2_5_3_4_1: array[ byte ] of byte = ( - $00, $80, $20, $A0, $40, $C0, $60, $E0, $08, $88, $28, $A8, $48, $C8, $68, $E8, - $02, $82, $22, $A2, $42, $C2, $62, $E2, $0A, $8A, $2A, $AA, $4A, $CA, $6A, $EA, - $04, $84, $24, $A4, $44, $C4, $64, $E4, $0C, $8C, $2C, $AC, $4C, $CC, $6C, $EC, - $06, $86, $26, $A6, $46, $C6, $66, $E6, $0E, $8E, $2E, $AE, $4E, $CE, $6E, $EE, - $10, $90, $30, $B0, $50, $D0, $70, $F0, $18, $98, $38, $B8, $58, $D8, $78, $F8, - $12, $92, $32, $B2, $52, $D2, $72, $F2, $1A, $9A, $3A, $BA, $5A, $DA, $7A, $FA, - $14, $94, $34, $B4, $54, $D4, $74, $F4, $1C, $9C, $3C, $BC, $5C, $DC, $7C, $FC, - $16, $96, $36, $B6, $56, $D6, $76, $F6, $1E, $9E, $3E, $BE, $5E, $DE, $7E, $FE, - $01, $81, $21, $A1, $41, $C1, $61, $E1, $09, $89, $29, $A9, $49, $C9, $69, $E9, - $03, $83, $23, $A3, $43, $C3, $63, $E3, $0B, $8B, $2B, $AB, $4B, $CB, $6B, $EB, - $05, $85, $25, $A5, $45, $C5, $65, $E5, $0D, $8D, $2D, $AD, $4D, $CD, $6D, $ED, - $07, $87, $27, $A7, $47, $C7, $67, $E7, $0F, $8F, $2F, $AF, $4F, $CF, $6F, $EF, - $11, $91, $31, $B1, $51, $D1, $71, $F1, $19, $99, $39, $B9, $59, $D9, $79, $F9, - $13, $93, $33, $B3, $53, $D3, $73, $F3, $1B, $9B, $3B, $BB, $5B, $DB, $7B, $FB, - $15, $95, $35, $B5, $55, $D5, $75, $F5, $1D, $9D, $3D, $BD, $5D, $DD, $7D, $FD, - $17, $97, $37, $B7, $57, $D7, $77, $F7, $1F, $9F, $3F, $BF, $5F, $DF, $7F, $FF); - - - -BytePermute_3_8_4_5_6_2_7_1: array[ byte ] of byte = ( - $00, $40, $02, $42, $08, $48, $0A, $4A, $10, $50, $12, $52, $18, $58, $1A, $5A, - $20, $60, $22, $62, $28, $68, $2A, $6A, $30, $70, $32, $72, $38, $78, $3A, $7A, - $80, $C0, $82, $C2, $88, $C8, $8A, $CA, $90, $D0, $92, $D2, $98, $D8, $9A, $DA, - $A0, $E0, $A2, $E2, $A8, $E8, $AA, $EA, $B0, $F0, $B2, $F2, $B8, $F8, $BA, $FA, - $04, $44, $06, $46, $0C, $4C, $0E, $4E, $14, $54, $16, $56, $1C, $5C, $1E, $5E, - $24, $64, $26, $66, $2C, $6C, $2E, $6E, $34, $74, $36, $76, $3C, $7C, $3E, $7E, - $84, $C4, $86, $C6, $8C, $CC, $8E, $CE, $94, $D4, $96, $D6, $9C, $DC, $9E, $DE, - $A4, $E4, $A6, $E6, $AC, $EC, $AE, $EE, $B4, $F4, $B6, $F6, $BC, $FC, $BE, $FE, - $01, $41, $03, $43, $09, $49, $0B, $4B, $11, $51, $13, $53, $19, $59, $1B, $5B, - $21, $61, $23, $63, $29, $69, $2B, $6B, $31, $71, $33, $73, $39, $79, $3B, $7B, - $81, $C1, $83, $C3, $89, $C9, $8B, $CB, $91, $D1, $93, $D3, $99, $D9, $9B, $DB, - $A1, $E1, $A3, $E3, $A9, $E9, $AB, $EB, $B1, $F1, $B3, $F3, $B9, $F9, $BB, $FB, - $05, $45, $07, $47, $0D, $4D, $0F, $4F, $15, $55, $17, $57, $1D, $5D, $1F, $5F, - $25, $65, $27, $67, $2D, $6D, $2F, $6F, $35, $75, $37, $77, $3D, $7D, $3F, $7F, - $85, $C5, $87, $C7, $8D, $CD, $8F, $CF, $95, $D5, $97, $D7, $9D, $DD, $9F, $DF, - $A5, $E5, $A7, $E7, $AD, $ED, $AF, $EF, $B5, $F5, $B7, $F7, $BD, $FD, $BF, $FF); - - - -BytePermute_1_2_7_4_5_6_3_8: array[ byte ] of byte = ( - $00, $01, $20, $21, $04, $05, $24, $25, $08, $09, $28, $29, $0C, $0D, $2C, $2D, - $10, $11, $30, $31, $14, $15, $34, $35, $18, $19, $38, $39, $1C, $1D, $3C, $3D, - $02, $03, $22, $23, $06, $07, $26, $27, $0A, $0B, $2A, $2B, $0E, $0F, $2E, $2F, - $12, $13, $32, $33, $16, $17, $36, $37, $1A, $1B, $3A, $3B, $1E, $1F, $3E, $3F, - $40, $41, $60, $61, $44, $45, $64, $65, $48, $49, $68, $69, $4C, $4D, $6C, $6D, - $50, $51, $70, $71, $54, $55, $74, $75, $58, $59, $78, $79, $5C, $5D, $7C, $7D, - $42, $43, $62, $63, $46, $47, $66, $67, $4A, $4B, $6A, $6B, $4E, $4F, $6E, $6F, - $52, $53, $72, $73, $56, $57, $76, $77, $5A, $5B, $7A, $7B, $5E, $5F, $7E, $7F, - $80, $81, $A0, $A1, $84, $85, $A4, $A5, $88, $89, $A8, $A9, $8C, $8D, $AC, $AD, - $90, $91, $B0, $B1, $94, $95, $B4, $B5, $98, $99, $B8, $B9, $9C, $9D, $BC, $BD, - $82, $83, $A2, $A3, $86, $87, $A6, $A7, $8A, $8B, $AA, $AB, $8E, $8F, $AE, $AF, - $92, $93, $B2, $B3, $96, $97, $B6, $B7, $9A, $9B, $BA, $BB, $9E, $9F, $BE, $BF, - $C0, $C1, $E0, $E1, $C4, $C5, $E4, $E5, $C8, $C9, $E8, $E9, $CC, $CD, $EC, $ED, - $D0, $D1, $F0, $F1, $D4, $D5, $F4, $F5, $D8, $D9, $F8, $F9, $DC, $DD, $FC, $FD, - $C2, $C3, $E2, $E3, $C6, $C7, $E6, $E7, $CA, $CB, $EA, $EB, $CE, $CF, $EE, $EF, - $D2, $D3, $F2, $F3, $D6, $D7, $F6, $F7, $DA, $DB, $FA, $FB, $DE, $DF, $FE, $FF); - - - -BytePermute_1_7_8_6_2_5_3_4: array[ byte ] of byte = ( - $00, $20, $40, $60, $10, $30, $50, $70, $04, $24, $44, $64, $14, $34, $54, $74, - $01, $21, $41, $61, $11, $31, $51, $71, $05, $25, $45, $65, $15, $35, $55, $75, - $02, $22, $42, $62, $12, $32, $52, $72, $06, $26, $46, $66, $16, $36, $56, $76, - $03, $23, $43, $63, $13, $33, $53, $73, $07, $27, $47, $67, $17, $37, $57, $77, - $08, $28, $48, $68, $18, $38, $58, $78, $0C, $2C, $4C, $6C, $1C, $3C, $5C, $7C, - $09, $29, $49, $69, $19, $39, $59, $79, $0D, $2D, $4D, $6D, $1D, $3D, $5D, $7D, - $0A, $2A, $4A, $6A, $1A, $3A, $5A, $7A, $0E, $2E, $4E, $6E, $1E, $3E, $5E, $7E, - $0B, $2B, $4B, $6B, $1B, $3B, $5B, $7B, $0F, $2F, $4F, $6F, $1F, $3F, $5F, $7F, - $80, $A0, $C0, $E0, $90, $B0, $D0, $F0, $84, $A4, $C4, $E4, $94, $B4, $D4, $F4, - $81, $A1, $C1, $E1, $91, $B1, $D1, $F1, $85, $A5, $C5, $E5, $95, $B5, $D5, $F5, - $82, $A2, $C2, $E2, $92, $B2, $D2, $F2, $86, $A6, $C6, $E6, $96, $B6, $D6, $F6, - $83, $A3, $C3, $E3, $93, $B3, $D3, $F3, $87, $A7, $C7, $E7, $97, $B7, $D7, $F7, - $88, $A8, $C8, $E8, $98, $B8, $D8, $F8, $8C, $AC, $CC, $EC, $9C, $BC, $DC, $FC, - $89, $A9, $C9, $E9, $99, $B9, $D9, $F9, $8D, $AD, $CD, $ED, $9D, $BD, $DD, $FD, - $8A, $AA, $CA, $EA, $9A, $BA, $DA, $FA, $8E, $AE, $CE, $EE, $9E, $BE, $DE, $FE, - $8B, $AB, $CB, $EB, $9B, $BB, $DB, $FB, $8F, $AF, $CF, $EF, $9F, $BF, $DF, $FF); - - - -BytePermute_8_7_5_6_4_3_1_2: array[ byte ] of byte = ( - $00, $80, $40, $C0, $10, $90, $50, $D0, $20, $A0, $60, $E0, $30, $B0, $70, $F0, - $08, $88, $48, $C8, $18, $98, $58, $D8, $28, $A8, $68, $E8, $38, $B8, $78, $F8, - $04, $84, $44, $C4, $14, $94, $54, $D4, $24, $A4, $64, $E4, $34, $B4, $74, $F4, - $0C, $8C, $4C, $CC, $1C, $9C, $5C, $DC, $2C, $AC, $6C, $EC, $3C, $BC, $7C, $FC, - $01, $81, $41, $C1, $11, $91, $51, $D1, $21, $A1, $61, $E1, $31, $B1, $71, $F1, - $09, $89, $49, $C9, $19, $99, $59, $D9, $29, $A9, $69, $E9, $39, $B9, $79, $F9, - $05, $85, $45, $C5, $15, $95, $55, $D5, $25, $A5, $65, $E5, $35, $B5, $75, $F5, - $0D, $8D, $4D, $CD, $1D, $9D, $5D, $DD, $2D, $AD, $6D, $ED, $3D, $BD, $7D, $FD, - $02, $82, $42, $C2, $12, $92, $52, $D2, $22, $A2, $62, $E2, $32, $B2, $72, $F2, - $0A, $8A, $4A, $CA, $1A, $9A, $5A, $DA, $2A, $AA, $6A, $EA, $3A, $BA, $7A, $FA, - $06, $86, $46, $C6, $16, $96, $56, $D6, $26, $A6, $66, $E6, $36, $B6, $76, $F6, - $0E, $8E, $4E, $CE, $1E, $9E, $5E, $DE, $2E, $AE, $6E, $EE, $3E, $BE, $7E, $FE, - $03, $83, $43, $C3, $13, $93, $53, $D3, $23, $A3, $63, $E3, $33, $B3, $73, $F3, - $0B, $8B, $4B, $CB, $1B, $9B, $5B, $DB, $2B, $AB, $6B, $EB, $3B, $BB, $7B, $FB, - $07, $87, $47, $C7, $17, $97, $57, $D7, $27, $A7, $67, $E7, $37, $B7, $77, $F7, - $0F, $8F, $4F, $CF, $1F, $9F, $5F, $DF, $2F, $AF, $6F, $EF, $3F, $BF, $7F, $FF); - - - - - -function DES_Permute( - SubKeyRound: integer; R: uint32; const Key: TExpandedKey): uint32; -// NOT WORKING YET !!! -var - i, j: integer; - T48, E: uint64; - b: ^byte; - b0, b1, b2, b3, t8: byte; - b1b0, b3b2: word; - t16: word; -begin -// SubKeyRound = 0; -// R= $AAF0AAF0; -// Key = as per http://orlingrabbe.com/des.htm example. -// result should be = 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien) -E := E_Bit_Selection( R); -T48 := E xor Key[ SubKeyRound]; -// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) = $AAF0AAF0; -// E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (big-endien) -// = $1515211E1515211E; -// K1 = Key[0] = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien) -// = $3201073F2F0B3006; -// f = K1+E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111 (big-endien) -// = $271426213A1E1118; -b := @T48; -for j := 0 to 7 do - begin - // b = @Int64Rec( T48).Bytes[ j]; - b^ := SBox[ j, b^]; - Inc( b, 1) - end; -// S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) -// = 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien compact) -// = $0709050B02080C05; -j := 0; -for i := 0 to 3 do - begin - LongRec( result).Bytes[i] := (Int64Rec( T48).Bytes[j ] shl 4) xor - Int64Rec( T48).Bytes[j+1]; - Inc( j, 2) - end; -// = 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien 32) -// = $97B5825C; - -// In the following fragment, we do the P-32 transform. This is ... -// P-32 transform -// 16 7 20 21 -// 29 12 28 17 -// 1 15 23 26 -// 5 18 31 10 -// 2 8 24 14 -// 32 27 3 9 -// 19 13 30 6 -// 22 11 4 25 -// which should transform 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien 32) = $97B5825C -// to 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien 32) = $BBA94A23 - -// Equivalently in bytes ... -// 16 7 20 21 29 12 28 17 -// 1 15 23 26 5 18 31 10 -// 2 8 24 14 32 27 3 9 -// 19 13 30 6 22 11 4 25 - -// Start with .. -b0 := LongRec( result).Bytes[0]; // 1 2 3 4 5 6 7 8 -b1 := LongRec( result).Bytes[1]; // 9 10 11 12 13 14 15 16 -b2 := LongRec( result).Bytes[2]; // 17 18 19 20 21 22 23 24 -b3 := LongRec( result).Bytes[3]; // 25 26 27 28 29 30 31 32 -// Case Study numbers. -// b0 = 92 (decimal) = $5C = [0 1 0 1 | 1 1 0 0] (binary; MSB..LSB) -// b1 = 130 (decimal) = $82 = [1 0 0 0 | 0 0 1 0] -// b2 = 181 (decimal) = $B5 = [1 0 1 1 | 0 1 0 1] -// b3 = 151 (decimal) = $97 = [1 0 0 1 | 0 1 1 1] - -// [25 26 27 28 29 30 31 32] --> [32 30 31 26 29 27 28 25] -b3 := BytePermute_8_6_7_2_5_3_4_1[ b3]; -// Case Study: b3 = [1 1 1 0 0 0 1 1] = $E3 - -// [17 18 19 20 21 22 23 24] --> [19 24 20 21 22 18 23 17] -b2 := BytePermute_3_8_4_5_6_2_7_1[ b2]; -// Case Study: b2 = [1 1 1 0 1 0 0 1] = $E9 - -// b2 = 19 24 20 21 22 18 23 17 -// b3 = 32 30 31 26 29 27 28 25 -// Swap these bits, between b2 and b3: -// swaps: ** ** ** ** - -t8 := (b2 xor b3) and $8E; -b2 := b2 xor t8; -b3 := b3 xor t8; - -// b2 = 32 24 20 21 29 27 28 17 -// b3 = 19 30 31 26 22 18 23 25 - -// Case Study: b2 = [1 1 1 0 0 0 1 1] = $E3 -// Case Study: b3 = [1 1 1 0 1 0 0 1] = $E9 - -// Swap these bits on b3: -// vv xx -// 19 30 31 26 22 18 23 25 - -// [19 30 31 26 22 18 23 25] --> [19 30 31 26 22 18 23 25] -b3 := BytePermute_1_2_7_4_5_6_3_8[ b3]; -// Or equivalently, we could have put: -// t8 := (b3 xor (b3 shr 4)) and $02; -// b3 := b3 xor t8 xor (t8 shl 4); - -// to get ... -// 19 30 23 26 22 18 31 25 - -// Case Study: b3 = [1 1 0 0 1 0 1 1] = $CB - -// Back to the first two bytes. -// b0 = 1 2 3 4 5 6 7 8 -// b1 = 9 10 11 12 13 14 15 16 - -// [1 2 3 4 5 6 7 8] --> [1 7 8 6 2 5 3 4] -b0 := BytePermute_1_7_8_6_2_5_3_4[ b0]; -// Case Study: b0 = [0 0 0 1 1 1 0 1] = $1D - -// [9 10 11 12 13 14 15 16] --> [16 15 13 14 12 11 9 10] -b1 := BytePermute_8_7_5_6_4_3_1_2[ b1]; -// Case Study: b1 = [0 1 0 0 0 0 1 0] = $42 - -// b0 = 1 7 8 6 2 5 3 4 -// b1 = 16 15 13 14 12 11 9 10 - -//Now swap these bits ... -// b0 = 1 7 8 6 2 5 3 4 -// ** ** -// b1 = 16 15 13 14 12 11 9 10 - -t8 := (b0 xor b1) and $90; -b0 := b0 xor t8; -b1 := b1 xor t8; - -//to get this -// b0 = 16 7 8 14 2 5 3 4 -// b1 = 1 15 13 6 12 11 9 10 - -// Case Study: b0 = [0 0 0 0 1 1 0 1] = $0D -// Case Study: b1 = [0 1 0 1 0 0 1 0] = $52 - -// Now switch these bits ... -// b0 = 16 7 8 14 2 5 3 4 -// ^^ ^^ -// vv vv -// b1 = 1 15 13 6 12 11 9 10 - -t8 := (b0 xor (b1 shr 1)) and $05; -b0 := b0 xor t8; -b1 := b1 xor (t8 shl 1); - -//to get this ... -// b0 = 16 7 8 14 2 12 3 9 -// b1 = 1 15 13 6 5 11 4 10 - -// Case Study: b0 = [0 0 0 0 1 0 0 1] = $09 -// Case Study: b1 = [0 1 0 1 1 0 1 0] = $5A - -// Now swap these bits ... -// b1|b0= 1 15 13 6 5 11 4 10 16 7 8 14 2 12 3 9 (little-endien) -// ** ** ** ** ** ** ** ** ** -// b3|b2=19 30 23 26 22 18 31 25 32 24 20 21 29 27 28 17 - -WordRec( b1b0).Lo := b0; -WordRec( b1b0).Hi := b1; -WordRec( b3b2).Lo := b2; -WordRec( b3b2).Hi := b3; -// Case Study: b1b0 = $5A09 -// Case Study: b3b2 = $CBE3 -t16 := (b1b0 xor b3b2) and $363B; -b1b0 := b1b0 xor t16; -b3b2 := b3b2 xor t16; -//to get this ... -// b1|b0= 1 15 23 26 5 18 31 10 16 7 20 21 29 12 28 17 -// b3|b2=19 30 13 6 22 11 4 25 32 24 8 14 2 27 3 9 - -// Case Study: b1b0 = [0 1 0 0 | 1 0 1 0 | 0 0 1 0 | 0 0 1 1] = $4A23 -// Case Study: b3b2 = [1 1 0 1 | 1 0 1 1 | 1 1 0 0 | 1 0 0 1] = $DBC9 - -// Now switch these bits ... -// vv xx -// b3|b2=19 30 13 6 22 11 4 25 32 24 8 14 2 27 3 9 -t16 := (b3b2 xor (b3b2 shr 4)) and $0008; -b3b2 := b3b2 xor t16 xor (t16 shl 4); - -//to get this ... -// b3|b2=19 30 13 6 22 11 4 25 2 24 8 14 32 27 3 9 - -// Case Study: b3b2 = [1 1 0 1 | 1 0 1 1 | 1 1 0 0 | 1 0 0 1] = $DBC9 - -// Now switch these bits ... -// vv xx vv xx -// b3|b2=19 30 13 6 22 11 4 25 2 24 8 14 32 27 3 9 -t16 := (b3b2 xor (b3b2 shr 1)) and $2020; -b3b2 := b3b2 xor t16 xor (t16 shl 1); - -//to get this ... -// b3|b2=19 13 30 6 22 11 4 25 2 8 24 14 32 27 3 9 - -// Case Study numbers. -// 9 10 11 12 | 13 14 15 16 | 1 2 3 4 | 5 6 7 8 = [1 0 0 0 | 0 0 1 0 | 0 1 0 1 | 1 1 0 0] -// 25 26 27 28 | 29 30 31 32 |17 18 19 20 | 21 22 23 24 = [1 0 0 1 | 0 1 1 1 | 1 0 1 1 | 0 1 0 1] -// Case Study: b3b2 = [1 0 1 1 | 1 0 1 1 | 1 0 1 0 | 1 0 0 1] = $BBA9 - -// End result rendered as words.. -// b1|b0= 1 15 23 26 5 18 31 10 16 7 20 21 29 12 28 17 -// b3|b2=19 13 30 6 22 11 4 25 2 8 24 14 32 27 3 9 - -LongRec( result).Lo := b1b0; -LongRec( result).Hi := b3b2 - -// End result rendered as bytes.. -// b0 = 16 7 20 21 29 12 28 17 -// b1 = 1 15 23 26 5 18 31 10 -// b2= 2 8 24 14 32 27 3 9 -// b3= 19 13 30 6 22 11 4 25 - -// End result rendered as nibbles.. -// 16 7 20 21 -// 29 12 28 17 -// 1 15 23 26 -// 5 18 31 10 -// 2 8 24 14 -// 32 27 3 9 -// 19 13 30 6 -// 22 11 4 25 - -// which is the P-32 transform. -end; - - - -procedure DES_EncryptBlock( - Plaintext: uint64; var Ciphertext: uint64; const Key: TExpandedKey); -var - L, R, T32: uint32; - i: integer; -begin -IP_Transform( Plaintext, L, R); -// L0 = 1100 1100 0000 0000 1100 1100 1111 1111 (big-endien) -// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) -// L = $FFCC00CC -// R = $AAF0AAF0 -for i := 0 to 15 do - begin - T32 := DES_Permute( i, R, Key) xor L; - // DES_Permute(i=0) = 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien) = $BBA94A23 - // L(i=0)= $FFCC00CC - // T32(i=0)= 1110 1111 0100 1010 0110 0101 0100 0100 (big-endien) = $44654AEF - L := R; - R := T32 - end; -// L16 = 0100 0011 0100 0010 0011 0010 0011 0100 (big-endien) = $34324243 -// R16 = 0000 1010 0100 1100 1101 1001 1001 0101 (big-endien) = $95D94C0A -// Now Swap L & R and call the inverse IP transform. -IP_InverseTransform( R, L, Ciphertext) -// IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101 (big-endien) -// This is the encrypted form of M = 0123456789ABCDEF (big-endien): -// namely, C = 85E813540F0AB405 (big-endien) OR -// C = $05B40A0F5413E885 (delphi). -end; - - -procedure DES_DecryptBlock( - Ciphertext: uint64; var Plaintext: uint64; const Key: TExpandedKey); -var - L, R, T32: uint32; - i: integer; -begin -IP_Transform( Ciphertext, R, L); // L & R swapped. -for i := 15 downto 0 do - begin - T32 := R; - R := L; - L := DES_Permute( i, R, Key) xor T32 - end; -IP_InverseTransform( L, R, Plaintext) -end; - - -{ TDES } - -function TDES.BlockSize: integer; -begin -result := 64 -end; - - -constructor TDES.Create; -begin -end; - - -function TDES.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf' -end; - - -function TDES.DisplayName: string; -begin -result := 'DES' -end; - - -function TDES.Features: TAlgorithmicFeatureSet; -begin -result := [ - afCryptographicallyWeak, - afOpenSourceSoftware] -end; - - -function TDES.GenerateKey( Seed: TStream): TSymetricKey; -var - SeedKey: uint64; -begin -Seed.ReadBuffer( SeedKey, 8); -result := TDESKey.Create( SeedKey) -end; - - -function TDES.KeySize: integer; -begin -result := 56 -end; - - -function TDES.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TDESKey.CreateFromStream( Store) -end; - -function TDES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := TDESCodec.Create( Key as TDESKey) -end; - - - -function TDES.ProgId: string; -begin -result := DES_ProgId -end; - -function TDES.SeedByteSize: integer; -begin -result := 8 -end; - - - -function TDES.SelfTest_Plaintext: string; -{ This from "FIPS PUB 81 - DES MODES OF OPERATION" -(http://www.itl.nist.gov/fipspubs/fip81.htm) -TABLE B1: AN EXAMPLE OF THE ELECTRONIC CODEBOOK (ECB) MODE - -The ECB mode in the encrypt state has been selected. -Cryptographic Key = 0123456789abcdef - -The plain text is the ASCII code for "Now is the time for all ." These seven-bit characters are written in hexadecimal notation -(0,b7,b6,...,b1). - TIME PLAINTEXT | DES INPUT BLOCK | DES OUTPUT BLOCK | CIPHERTEXT - 1. 4e6f772069732074 | 4e6f772069732074 | 3fa40e8a984d4315 | 3fa40e8a984d4815 - 2. 68652074696d652o | 68652074696d652o | 6a271787ab8883f9 | 6a271787ab8883f9 - 3. 666f7220616c6c20 | 666f7220616c6c20 | 893d51ec4b563b53 | 893d51ec4b563b53 - -The ECB mode in the decrypt state has been selected. - TIME PLAINTEXT | DES INPUT BLOCK | DES OUTPUT BLOCK | CIPHERTEXT - 1. 3fa40e8a984d4815 | 3fa40e8a984d4815 | 4e6f772o69732o74 | 4e6f772069732074 - 2. 6a271787ab8883f9 | 6a271787ab8883f9 | 68652074696d6520 | 68652074696d6520 - 3. 893d51ec4b563b53 | 893d51ec4b563b53 | 666f7220616c6c20 | 666f7220616c6c20} -begin -result := '4e6f772069732074' -end; - - -function TDES.SelfTest_Ciphertext: string; -begin -result := '3fa40e8a984d4815' -end; - -function TDES.SelfTest_Key: string; -begin -result := '0123456789abcdef' -end; - -function TDES.WikipediaReference: string; -begin -result := 'Data_Encryption_Standard' -end; - - - -procedure SetParityBitsOnKey( var K: uint64); -var - ByteIndex, BitIdx: integer; - Byte1: byte; - Parity: byte; -begin -for ByteIndex := 0 to 7 do - begin - Byte1 := Int64Rec( K).Bytes[ ByteIndex]; - Parity := $00; - for BitIdx := 7 downto 1 do - Parity := Parity xor ((Byte1 shr BitIdx) and $01); - Int64Rec( K).Bytes[ ByteIndex] := (Byte1 and $FE) or Parity - end -end; - - -function hasCorrectParity( K: uint64): boolean; -var - ByteIndex, BitIdx: integer; - Byte1: byte; - Parity: byte; -begin -for ByteIndex := 0 to 7 do - begin - Byte1 := Int64Rec( K).Bytes[ ByteIndex]; - Parity := $00; - for BitIdx := 7 downto 1 do - Parity := Parity xor ((Byte1 shr BitIdx) and $01); - result := (Byte1 and $01) = Parity - end -end; - - - - - -{ TDESKey } - -constructor TDESKey.Create( NativeKey1: uint64); -begin -FNativeKey := NativeKey1; -SetParityBitsOnKey( FNativeKey); -ExpandKey( FNativeKey, FExpandedKey) -end; - - -constructor TDESKey.CreateFromStream( Store: TStream); -begin -Store.ReadBuffer( FNativeKey, 8); -if not hasCorrectParity( FNativeKey) then - raise Exception.Create( ES_InvalidKey); -ExpandKey( FNativeKey, FExpandedKey) -end; - - - -procedure TDESKey.SaveToStream(Stream: TStream); -begin -Stream.Write( FNativeKey, 8) -end; - - -procedure TDESKey.Burn; -begin -FNativeKey := 0; -FillChar( FExpandedKey, SizeOf( FExpandedKey), 0) -end; - - -{ TDESCodec } - -constructor TDESCodec.Create( LockBoxKey1: TDESKey); -begin -FLockBoxKey := LockBoxKey1 -end; - -procedure TDESCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Plaintext.Memory^, PlaintextBlock, 8); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey); -Move( CiphertextBlock, Ciphertext.Memory^, 8) -end; - - -procedure TDESCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Ciphertext.Memory^, CiphertextBlock, 8); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey); -Move( PlaintextBlock, Plaintext.Memory^, 8) -end; - - -procedure TDESCodec.Reset; -begin -end; - - -procedure TDESCodec.Burn; -begin -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.DES; +interface +uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher; + +type + +TDES = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; // in units of bits. Must be a multiple of 8. + function KeySize: integer; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + + public + constructor Create; + end; + + +TExpandedKey = array[ 0 .. 15 ] of uint64; + +{$IF CompilerVersion < 21} +uint32 = cardinal; +{$IFEND} +// The following routines are exposed only for the sake of D-Unit tests. +procedure IP_Transform( Datum: uint64; var L, R: uint32); +procedure IP_InverseTransform( L, R: uint32; var Datum: uint64); +procedure DES_EncryptBlock( + Plaintext: uint64; var Ciphertext: uint64; const Key: TExpandedKey); +procedure DES_DecryptBlock( + Ciphertext: uint64; var Plaintext: uint64; const Key: TExpandedKey); +procedure ExpandKey( Key: uint64; var Ex: TExpandedKey); +function PC_1( K: uint64): uint64; +function PC_2( L, R: uint32): uint64; +function E_Bit_Selection( R: uint32): uint64; +procedure SetParityBitsOnKey( var K: uint64); +function hasCorrectParity( K: uint64): boolean; + +implementation + + + + + + + + + +uses TPLB3.Constants, SysUtils, TPLB3.I18n; + +{ Information Resources + ===================== +(1) http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf +(2) http://www.tropsoft.com/strongenc/des.htm +(3) http://orlingrabbe.com/des.htm +(4) http://en.wikipedia.org/wiki/Data_Encryption_Standard +(5) http://www.itl.nist.gov/fipspubs/fip81.htm + +} + + + +{ The DES standard describes a transform of 64 bits to 64 bits, with +the bits numbered from 1 to 64 (see figure 1 of FIBS PUB 46-3). +Somewhat annoyingly it does not define how these 64 bits are encoded +in an 8-bit byte stream, in relation to endien-ness. There are at least +4 different endien encodings possible. This ambiguity in the standard is not +cryptographically significant, but it does impact on implementation. + +In LockBox 3, the DES algorithm will use the following endien encoding: + * Bit 1 (designated b1) is encoded in the most significant bit (MSB) of byte address 0. + * Bit 2 (designated b2) is encoded in the 2nd MSB of byte address 0. + * b8 is encoded in the LSB of byte address 0. + * b9 is encoded in the MSB of byte address 1. + * b64 is encoded in the LSB of byte address 7. +} + +type +TDESKey = class( TSymetricKey) + private + FNativeKey : uint64; + FExpandedKey: TExpandedKey; + + public + constructor Create( NativeKey1: uint64); + constructor CreateFromStream( Store: TStream); + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +TDESCodec = class( TInterfacedObject, IBlockCodec) + private + FLockBoxKey: TDESKey; + + constructor Create( LockBoxKey1: TDESKey); + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + end; + + + +function PC_1( K: uint64): uint64; +var + L, R: uint32; + t8: byte; + t32: uint32; + t16: word; +begin +// input K = 57 58 59 60 61 62 63 64 | 49 50 51 52 53 54 55 56 | 41 42 43 44 45 46 47 48 | 33 34 35 36 37 38 39 40 | 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 + +//PC-1 output = +//57 49 41 33 25 17 9 +// 1 58 50 42 34 26 18 +//10 2 59 51 43 35 27 +//19 11 3 60 52 44 36 +//63 55 47 39 31 23 15 +// 7 62 54 46 38 30 22 +//14 6 61 53 45 37 29 +//21 13 5 28 20 12 4 + +// We desire result, such that: +// result.Bytes[0] = 57 49 41 33 25 17 9 1 +// result.Bytes[1] = 58 50 42 34 26 18 10 2 +// result.Bytes[2] = 59 51 43 35 27 19 11 3 +// result.Bytes[3] = 60 52 44 36 63 55 47 39 +// result.Bytes[4] = 31 23 15 7 62 54 46 38 +// result.Bytes[5] = 30 22 14 6 61 53 45 37 +// result.Bytes[6] = 29 21 13 5 28 20 12 4 +// result.Bytes[7] = 0 0 0 0 0 0 0 0 + +// In other words we wish to go from LR to L'R' where: +//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 +//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 +// +//L' = 60 52 44 36 63 55 47 39 59 51 43 35 27 19 11 3 58 50 42 34 26 18 10 2 57 49 41 33 25 17 9 1 +//R' = 0 0 0 0 0 0 0 0 29 21 13 5 28 20 12 4 30 22 14 6 61 53 45 37 31 23 15 7 62 54 46 38 + +// Sample data: +//K = (big-endien) 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 +//K = (little-endien) 11110001 11011111 10111100 10011011 01111001 01010111 00110100 00010011 +//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 +// 0 1 1 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 +//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 +// 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 + +// Origin. Start with: +L := Int64Rec( K).Lo; +R := Int64Rec( K).Hi; +//L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 +//R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 +// 0 1 1 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 +// 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 + + +// Step 1. Center byte swap. +t8 := LongRec( L).Bytes[2]; +LongRec( L).Bytes[2] := LongRec( L).Bytes[1]; +LongRec( L).Bytes[1] := t8; +t8 := LongRec( R).Bytes[2]; +LongRec( R).Bytes[2] := LongRec( R).Bytes[1]; +LongRec( R).Bytes[1] := t8; +//L = 25 26 27 28 29 30 31 32 | 9 10 11 12 13 14 15 16 | 17 18 19 20 21 22 23 24 | 1 2 3 4 5 6 7 8 +//R = 57 58 59 60 61 62 63 64 | 41 42 43 44 45 46 47 48 | 49 50 51 52 53 54 55 56 | 33 34 35 36 37 38 39 40 +// 0 1 1 1 1 0 0 1 | 0 0 1 1 0 1 0 0 | 0 1 0 1 0 1 1 1 | 0 0 0 1 0 0 1 1 +// 1 1 1 1 0 0 0 1 | 1 0 1 1 1 1 0 0 | 1 1 0 1 1 1 1 1 | 1 0 0 1 1 0 1 1 + +// Step 2. Swap nibbles in each L byte. +L := ((L shl 4) and $F0F0F0F0) or ((L shr 4) and $0F0F0F0F); +//L = 29 30 31 32 25 26 27 28 | 13 14 15 16 9 10 11 12 | 21 22 23 24 17 18 19 20 | 5 6 7 8 1 2 3 4 +//R = 57 58 59 60 61 62 63 64 | 41 42 43 44 45 46 47 48 | 49 50 51 52 53 54 55 56 | 33 34 35 36 37 38 39 40 + +// Step 3. Swap high nibbles between L & R +t32 := (L and $0F0F0F0F) or (R and $F0F0F0F0); +R := (L and $F0F0F0F0) or (R and $0F0F0F0F); +L := t32; +//L = 57 58 59 60 25 26 27 28 | 41 42 43 44 9 10 11 12 | 49 50 51 52 17 18 19 20 | 33 34 35 36 1 2 3 4 +//R = 29 30 31 32 61 62 63 64 | 13 14 15 16 45 46 47 48 | 21 22 23 24 53 54 55 56 | 5 6 7 8 37 38 39 40 + +// Step 4. Swap bytes +t8 := LongRec( L).Bytes[1]; +LongRec( L).Bytes[1] := LongRec( R).Bytes[0]; +LongRec( R).Bytes[0] := t8; +t8 := LongRec( L).Bytes[3]; +LongRec( L).Bytes[3] := LongRec( R).Bytes[2]; +LongRec( R).Bytes[2] := t8; +//L = 13 14 15 16 45 46 47 48 | 41 42 43 44 9 10 11 12 | 5 6 7 8 37 38 39 40 | 33 34 35 36 1 2 3 4 +//R = 29 30 31 32 61 62 63 64 | 57 58 59 60 25 26 27 28 | 21 22 23 24 53 54 55 56 | 49 50 51 52 17 18 19 20 + +// Step 5. 2-bit swap +// L = a-->d b +// R = c d-->a +T32 := ((L shr 2) xor R) and $33333333; +R := R xor T32; +L := L xor (T32 shl 2); +//L = 31 32 15 16 63 64 47 48 | 59 60 43 44 27 28 11 12 | 23 24 7 8 55 56 39 40 | 51 52 35 36 19 20 3 4 +//R = 29 30 13 14 61 62 45 46 | 57 58 41 42 25 26 9 10 | 21 22 5 6 53 54 37 38 | 49 50 33 34 17 18 1 2 + +// Step 5. Word swap +t16 := LongRec( L).Lo; +LongRec( L).Lo := LongRec( R).Hi; +LongRec( R).Hi := t16; +//L = 31 32 15 16 63 64 47 48 | 59 60 43 44 27 28 11 12 | 29 30 13 14 61 62 45 46 | 57 58 41 42 25 26 9 10 +//R = 23 24 7 8 55 56 39 40 | 51 52 35 36 19 20 3 4 | 21 22 5 6 53 54 37 38 | 49 50 33 34 17 18 1 2 + +// Step 6. 1-bit swap +// L = a b-->c +// R = c-->b d +T32 := ((R shr 1) xor L) and $55555555; +L := L xor T32; +R := R xor (T32 shl 1); +//L = 31 23 15 7 63 55 47 39 | 59 51 43 35 27 19 11 3 | 29 21 13 5 61 53 45 37 | 57 49 41 33 25 17 9 1 +//R = 32 24 16 8 64 56 48 40 | 60 52 44 36 28 20 12 4 | 30 22 14 6 62 54 46 38 | 58 50 42 34 26 18 10 2 + +// Step 6. byte swap +t8 := LongRec( R).Bytes[0]; +LongRec( R).Bytes[0] := LongRec( L).Bytes[1]; +LongRec( L).Bytes[1] := t8; +t8 := LongRec( R).Bytes[2]; +LongRec( R).Bytes[2] := LongRec( L).Bytes[3]; +LongRec( L).Bytes[3] := t8; +//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 +//R = 32 24 16 8 64 56 48 40 | 31 23 15 7 63 55 47 39 | 30 22 14 6 62 54 46 38 | 29 21 13 5 61 53 45 37 + +// Step 7. Clear R high byte. +LongRec( R).Bytes[3] := 0; +//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 +//R = 0 0 0 0 0 0 0 0 | 31 23 15 7 63 55 47 39 | 30 22 14 6 62 54 46 38 | 29 21 13 5 61 53 45 37 + +// Step 8. Swap nibbles: R[0].LoN <--> R[1].LoN . +t8 := LongRec( R).Bytes[0] and $0F; +LongRec( R).Bytes[0] := (LongRec( R).Bytes[0] and $F0) or (LongRec( R).Bytes[1] and $0F); +LongRec( R).Bytes[1] := (LongRec( R).Bytes[1] and $F0) or t8; +//L = 60 52 44 36 28 20 12 4 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 +//R = 0 0 0 0 0 0 0 0 | 31 23 15 7 63 55 47 39 | 30 22 14 6 61 53 45 37 | 29 21 13 5 62 54 46 38 + +// Step 9. Swap nibbles: L[3].LoN <--> R[2].LoN . and +// R[2].HiN <--> R[0].HiN +t8 := LongRec( R).Bytes[2]; +LongRec( R).Bytes[2] := (LongRec( R).Bytes[0] and $F0) or (LongRec( L).Bytes[3] and $0F); +LongRec( L).Bytes[3] := (LongRec( L).Bytes[3] and $F0) or (t8 and $0F); +LongRec( R).Bytes[0] := (t8 and $F0) or (LongRec( R).Bytes[0] and $0F); +//L = 60 52 44 36 63 55 47 39 | 59 51 43 35 27 19 11 3 | 58 50 42 34 26 18 10 2 | 57 49 41 33 25 17 9 1 +//R = 0 0 0 0 0 0 0 0 | 29 21 13 5 28 20 12 4 | 30 22 14 6 61 53 45 37 | 31 23 15 7 62 54 46 38 + +// ... which is our desired final result! +//L' = 60 52 44 36 63 55 47 39 59 51 43 35 27 19 11 3 58 50 42 34 26 18 10 2 57 49 41 33 25 17 9 1 +//R' = 0 0 0 0 0 0 0 0 29 21 13 5 28 20 12 4 30 22 14 6 61 53 45 37 31 23 15 7 62 54 46 38 + +// Marshal the return. +Int64Rec( result).Lo := L; +Int64Rec( result).Hi := R +end; + + + + + + +function PC_2( L, R: uint32): uint64; +// input L = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 (Little-endien) +// input R = 53 54 55 56 0 0 0 0 | 45 46 47 48 49 50 51 52 | 37 28 39 40 41 42 43 44 | 29 30 31 32 33 34 35 36 + +//PC-2 output = +//14 17 11 24 1 5 +// 3 28 15 6 21 10 +//23 19 12 4 26 8 +//16 7 27 20 13 2 +//41 52 31 37 47 55 +//30 40 51 45 33 48 +//44 49 39 56 34 53 +//46 42 50 36 29 32 + +// Unlike PC-1 in which we marshaled the result by packing the bits, +// for this return, we want to marshal the result into 8 times 6 bits, +// with the result in the low 6 bits of each byte. +// We desire result, such that: +// result.Bytes[0] = 0 0 14 17 11 24 1 5 +// result.Bytes[1] = 0 0 3 28 15 6 21 10 +// result.Bytes[2] = 0 0 23 19 12 4 26 8 +// result.Bytes[3] = 0 0 16 7 27 20 13 2 +// result.Bytes[4] = 0 0 41 52 31 37 47 55 +// result.Bytes[5] = 0 0 30 40 51 45 33 48 +// result.Bytes[6] = 0 0 44 49 39 56 34 53 +// result.Bytes[7] = 0 0 46 42 50 36 29 32 + +// In other words we wish to go from LR to L'R' where: +// L = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 +// R = 53 54 55 56 0 0 0 0 | 45 46 47 48 49 50 51 52 | 37 28 39 40 41 42 43 44 | 29 30 31 32 33 34 35 36 +// +// L' = 0 0 16 7 27 20 13 2 | 0 0 23 19 12 4 26 8 | 0 0 3 28 15 6 21 10 | 0 0 14 17 11 24 1 5 +// R' = 0 0 46 42 50 36 29 32 | 0 0 44 49 39 56 34 53 | 0 0 30 40 51 45 33 48 | 0 0 41 52 31 37 47 55 + +// Ex. 1: $3201073F2F0B3006 = PC_2( $F05599E1, $E0F1CCAA); +// Ex. 2: $25273C36193B1A1E = PC_2( $F0AB32C3, $D0E39955); + +// http://orlingrabbe.com/des.htm test data: +// C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (big-endien compact 56 bits) +// L = 1110000 1100110 0101010 1011111 (big-endien compact 28 bits; 7 bit groups) +// L = 11100001 10011001 01010101 11110000 (big-endien 32 bits; 8 bit groups) +// L = 1111 0000 0101 0101 1001 1001 1110 0001 (little-endien 32 bits; 4 bit groups) +// L = $F05599E1; (Delphi) +// R = 1010101 0110011 0011110 0011110 (big-endien compact 28 bits; 7 bit groups) +// R = 10101010 11001100 11110001 11100000 (big-endien 32 bits; 8 bit groups) +// R = 1110 0000 | 1111 0001 | 1100 1100 | 1010 1010 (little-endien 32 bits; 4 bit groups) +// R = $E0F1CCAA (Delphi) +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien compact 48 bits; 6 bit rows) +// K1 = 00000110 00110000 00001011 00101111 00111111 00000111 00000001 00110010 (big-endien 64 bits; 8 bit rows) +// K1 = 0011 0010 | 0000 0001 | 0000 0111 | 0011 1111 | 0010 1111 | 00001 011 | 0011 0000 | 0000 0110 (little-endien 64 bits; 4 bit rows) +// K1 = $3201073F2F0B3006; (Delphi) + +var + b0, b1, b2, b3, b4, b5, b6, b7: byte; +begin +// Sledge-hammer approach. This implementation is not as efficient as it +// could be. The reader is invited to exlore more efficient solutions. +// Please keep me advised. +b0 := LongRec( L).Bytes[0]; // $E1 +b1 := LongRec( L).Bytes[1]; // $99 +b2 := LongRec( L).Bytes[2]; // $55 +b3 := LongRec( L).Bytes[3]; // $F0 +b4 := LongRec( R).Bytes[0]; // $AA +b5 := LongRec( R).Bytes[1]; // $CC +b6 := LongRec( R).Bytes[2]; // $F1 +b7 := LongRec( R).Bytes[3]; // $E0 +// The following code was programmatically generated, deriving from the +// published PC-2 table. +Int64Rec( result).Bytes[ 0] := ((b1 and $04) shl 3) or // DONE + ((b2 and $80) shr 3) or + ((b1 and $20) shr 2) or + ((b2 and $01) shl 2) or + ((b0 and $80) shr 6) or + ((b0 and $08) shr 3); // Expect = $06 + +Int64Rec( result).Bytes[ 1] := (b0 and $20) or // DONE + (b3 and $10) or + ((b1 and $02) shl 2) or + (b0 and $04) or + ((b2 and $08) shr 2) or + ((b1 and $40) shr 6); // Expect = $30 + +Int64Rec( result).Bytes[ 2] := ((b2 and $02) shl 4) or // DONE + ((b2 and $20) shr 1) or + ((b1 and $10) shr 1) or + ((b0 and $10) shr 2) or + ((b3 and $40) shr 5) or + (b0 and $01) ; // Expect = $0B + +Int64Rec( result).Bytes[ 3] := ((b1 and $01) shl 5) or // DONE + ((b0 and $02) shl 3) or + ((b3 and $20) shr 2) or + ((b2 and $10) shr 2) or + ((b1 and $08) shr 2) or + ((b0 and $40) shr 6); // Expect = $2F + +// 0 0 41 52 31 37 47 55 +Int64Rec( result).Bytes[ 4] := ((b5 and $08) shl 2) or // DONE + ((b6 and $01) shl 4) or // + ((b4 and $20) shr 2) or // + ((b5 and $80) shr 5) or // + ((b6 and $20) shr 4) or // + ((b7 and $20) shr 5); // Expect = $3F bit 55; e=1;g=0 + +// 0 0 30 40 51 45 33 48 +Int64Rec( result).Bytes[ 5] := ((b4 and $40) shr 1) or // DONE + (b5 and $10) or // + ((b6 and $02) shl 2) or // + ((b6 and $80) shr 5) or // + ((b4 and $08) shr 2) or // + ((b6 and $10) shr 4); // Expect = $07 + +// 0 0 44 49 39 56 34 53 +Int64Rec( result).Bytes[ 6] := ((b5 and $01) shl 5) or // DONE + ((b6 and $08) shl 1) or // + ((b5 and $20) shr 2) or // + ((b7 and $10) shr 2) or // e=1;g=0 + ((b4 and $04) shr 1) or // + ((b7 and $80) shr 7); // Expect = $01 + +// 0 0 46 42 50 36 29 32 +Int64Rec( result).Bytes[ 7] := ((b6 and $40) shr 1) or // DONE + ((b5 and $04) shl 2) or + ((b6 and $04) shl 1) or + ((b4 and $01) shl 2) or + ((b4 and $80) shr 6) or + ((b4 and $10) shr 4); // Expect = $32 +end; + + + +procedure Roll1( var Value: uint32); +// Does a big-endien roll left 1 +// going from C to C' thus: +// C = 25 26 27 28 0 0 0 0 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 +// C' = 26 27 28 1 0 0 0 0 | 18 19 20 21 22 23 24 25 |10 11 12 13 14 15 16 17 | 2 3 4 5 6 7 8 9 +begin +Value := ((Value shl 1) and $EEFEFEFE) or + ((Value and $80808000) shr 15) or + ((Value and $00000080) shl 21) +end; + + + +procedure ExpandKey( Key: uint64; var Ex: TExpandedKey); +const + isTwoRolls: array[0..15] of boolean = ( + False, False, True, True, True , True , True, True, + False, True , True, True, True , True , True, False); +var + CD: uint64; + C, D: uint32; + i: integer; +begin +CD := PC_1( Key); +C := int64Rec( CD).Lo and $F0FFFFFF ; // Low 28 big-endien bits. +D := ((int64Rec( CD).Lo shr 20) and $000000F0) or // Next 28 big-endien bits. + ((int64Rec( CD).Hi shl 12) and $F0F0F000) or + ((int64Rec( CD).Hi shr 4) and $0F0F0F0F); + +for i := 0 to 15 do + begin + // Example test data from http://orlingrabbe.com/des.htm + // C0 = 1111000011001100101010101111 (big-endien; 28 bits) + // C0 = 11110000110011001010101011110000 (big-endien; 32 bits = 28 + 4 zeroes at the end) + // C0 = 1111 0000 | 1100 1100 | 1010 1010 | 1111 0000 (big-endien; 32 bits = 28 + 4 zeroes at the end) + // C0 = 1111 0000 | 1010 1010 | 1100 1100 | 1111 0000 (litte-endien 32 bits) + // C0 = F 0 A A C C F 0 (litte-endien hex) + // C0 = $F0AACCF0; (Delphi) + // C1 = C0 [big-endien roll left] 1 + // C1 = 1110000110011001010101011111 (big-endien 28 bits) + // C1 = 1110 0001 | 1001 1001 | 0101 0101 | 1111 0000 (big-endien 32 bits) + // C1 = 1111 0000 | 0101 0101 | 1001 1001 | 1110 0001 (little-endien 32 bits) + // C1 = $F05599E1; (Delphi) + Roll1( C); + // For test data case and i=0, check C = $F05599E1 + Roll1( D); + if isTwoRolls[i] then + begin + Roll1( C); + Roll1( D); + end; + Ex[i] := PC_2( C, D) + // K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien 48; 6-bit groups) + // K1 = 110010 000001 000111 111111 101111 001011 110000 000110 (little-endien 48; 6-bit groups) + // K1 = 00110010 00000001 00000111 00111111 00101111 00001011 00110000 00000110 (little-endien 64; 8-bit groups = 48 bits + 2MSB zeros) + // K1 = $3201073F2F0B3006; (Delphi) + // Ex[0] = $3201073F2F0B3006 = PC_2( $F05599E1, $E0F1CCAA); + // Ex[1] = $25273C36193B1A1E = PC_2( $F0AB32C3, $D0E39955); + end +end; + + + +procedure IP_Transform( Datum: uint64; var L, R: uint32); +// See IP_InverseTransform for an explaination of how this works. +var + T32: uint32; + T16: word; + T8: byte; +begin +L := Int64Rec( Datum).Lo; +R := Int64Rec( Datum).Hi; +T32 := ((L shr 4) xor R) and $0F0F0F0F; +R := R xor T32; +L := L xor (T32 shl 4); +T16 := LongRec(L).Lo; +LongRec(L).Lo := LongRec(R).Hi; +LongRec(R).Hi := T16; +T32 := ((R shr 2) xor L) and $33333333; +L := L xor T32; +R := R xor (T32 shl 2); +T8 := LongRec(R).Bytes[0]; +LongRec(R).Bytes[0] := LongRec(L).Bytes[1]; +LongRec(L).Bytes[1] := T8; +T8 := LongRec(R).Bytes[2]; +LongRec(R).Bytes[2] := LongRec(L).Bytes[3]; +LongRec(L).Bytes[3] := T8; +T32 := ((L shr 1) xor R) and $55555555; +R := R xor T32; +L := L xor (T32 shl 1) +{ http://orlingrabbe.com/des.htm gives an example in a binary + lowest-address=byte-left, MSB-within-byte-left format: +M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 +IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 + +In our native format drawing format, this is equivalent to: +M = $EFCDAB8967452301; +L = $FFCC00CC; +R = $AAF0AAF0 + +} +end; + + + +procedure IP_InverseTransform( L, R: uint32; var Datum: uint64); +var + T32: uint32; + T16: word; + T8: byte; +{ +Start with input 64 bits (MLB left) +58 50 42 34 26 18 10 2 +60 52 44 36 28 20 12 4 +62 54 46 38 30 22 14 6 +64 56 48 40 32 24 16 8 +57 49 41 33 25 17 9 1 +59 51 43 35 27 19 11 3 +61 53 45 37 29 21 13 5 +63 55 47 39 31 23 15 7 + +Your may recognise this as the IP table on page 10 of the standard. +The above is drawn 1 byte per row, with the lowest address byte on the top +row and the highest address byte on the bottom row. In a little-endien +architecture, the first row is the Least Significant byte. In a big-endien +architecture, the first row is the Most Significant byte. In either case, +the first row is the lowest address byte. +Within a byte, the bits are drawn from MSB on the left to LSB on the right. +The numbers in the matrix are the DES designation for bits. The standard +designates the 'first' bit to be bit 1 (or B1). I interpret 'first' bit +to mean MSB. + +We can split these 64 bits into two 32 two bit native (little-endien) integers. +L is first, followed by R. + +So .... +L = 64 56 48 40 32 24 16 8 62 54 46 38 30 22 14 6 60 52 44 36 28 20 12 4 58 50 42 34 26 18 10 2 +R = 63 55 47 39 31 23 15 7 61 53 45 37 29 21 13 5 59 51 43 35 27 19 11 3 57 49 41 33 25 17 9 1 + +The L, R is drawn from MSB on the left to LSB on the right. + +NOTE: +The standard and most examples you can find are terribly endien-biggoted. +They implicitly assume a big-endien architecture and are often ambigious +in a little-endien context. + +For example, refer to "http://orlingrabbe.com/des.htm", section "How DES Works in Detail". +In this example, + M = the mathematical, unencoded number $123456789ABCDEF; +but DES does not operate on numbers, it transforms blocks of 8 bytes. +The article really means + M = the 8 bytes (lowest address byte left-most): $01 $23 $45 $67 $89 $AB $CD $EF +On a little-endien machine, this is the encoded form of the number $EFCDAB8967351201. + or M: uint64 = $EFCDAB8967351201; +The first byte is $01, and the first bit of the first byte is 0. +In a binary lowest-address=byte-left, MSB-within-byte-left format, this datum is drawn: + M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 + L = 0000 0001 0010 0011 0100 0101 0110 0111 + R = 1000 1001 1010 1011 1100 1101 1110 1111 + +However, the same datum, drawn in a 'native' format (highest-address=byte-left, MSB-within-byte-left format) is drawn thus: + M = 1110 1111 1100 1101 1010 1011 1000 1001 0110 0111 0100 0101 0010 0011 0000 0001 + L = 0110 0111 0100 0101 0010 0011 0000 0001 + R = 1110 1111 1100 1101 1010 1011 1000 1001 + +The word 'native' means in respect of how, in a little-endien machine, +the drawing of an encoded number harmonises with the 'shl' operator shifting +LEFT, and the shr operator shifting RIGHT. + +Reading these endien biggoted source documents can get really confusing +until you acknowledge that there is more than one way to draw the same datum. + +Our goal is to reach ... + 1 2 3 4 5 6 7 8 + 9 10 11 12 13 14 15 16 + 17 18 19 20 21 22 23 24 + 25 26 27 28 29 30 31 32 + 33 34 35 36 37 38 39 40 + 41 42 43 44 45 46 47 48 + 49 50 51 52 53 54 55 56 + 57 58 59 60 61 62 63 64 + +or equivalently .... +L = 25 26 27 28 29 30 31 32 17 18 19 20 21 22 23 24 9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 +R = 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 +} + + +begin +// Test case data: +// L = $34324243 +// R = $95D94C0A ==> +// Datum = $05B40A0F5413E885 + +// convert ciphertext LR to plaintext M +// L = 64 56 48 40 32 24 16 8 62 54 46 38 30 22 14 6 60 52 44 36 28 20 12 4 58 50 42 34 26 18 10 2 +// R = 63 55 47 39 31 23 15 7 61 53 45 37 29 21 13 5 59 51 43 35 27 19 11 3 57 49 41 33 25 17 9 1 + +// Step 1. Do a 1 bit cross-over. +// L = a-->d b +// R = c d-->a +T32 := ((L shr 1) xor R) and $55555555; +R := R xor T32; +L := L xor (T32 shl 1); + +// L = 55 56 39 40 23 24 7 8 53 54 37 38 21 22 5 6 51 52 35 36 19 20 3 4 49 50 33 34 17 18 1 2 +// R = 63 64 47 48 31 32 15 16 61 62 45 46 29 30 13 14 59 60 43 44 27 28 11 12 57 58 41 42 25 26 9 10 + +// Step 2. Do a byte cross-over. +// L = a-->d b +// R = c d-->a +T8 := LongRec(R).Bytes[0]; +LongRec(R).Bytes[0] := LongRec(L).Bytes[1]; +LongRec(L).Bytes[1] := T8; +T8 := LongRec(R).Bytes[2]; +LongRec(R).Bytes[2] := LongRec(L).Bytes[3]; +LongRec(L).Bytes[3] := T8; + +// L = 61 62 45 46 29 30 13 14 | 53 54 37 38 21 22 5 6 | 57 58 41 42 25 26 9 10 | 49 50 33 34 17 18 1 2 +// R = 63 64 47 48 31 32 15 16 | 55 56 39 40 23 24 7 8 | 59 60 43 44 27 28 11 12 | 51 52 35 36 19 20 3 4 + +// Step 3. Do a 2 bit cross-over. +// L = a b-->c +// R = c-->b d +T32 := ((R shr 2) xor L) and $33333333; +L := L xor T32; +R := R xor (T32 shl 2); + +// L = 61 62 63 64 29 30 31 32 | 53 54 55 56 21 22 23 24 | 57 58 59 60 25 26 27 28 | 49 50 51 52 17 18 19 20 +// R = 45 46 47 48 13 14 15 16 | 37 38 39 40 5 6 7 8 | 41 42 43 44 9 10 11 12 | 33 34 35 36 1 2 3 4 + +// Step 4. Do a word cross-over. +// L = a b-->c +// R = c-->b d Change here +T16 := LongRec(L).Lo; +LongRec(L).Lo := LongRec(R).Hi; +LongRec(R).Hi := T16; + +// L = 61 62 63 64 29 30 31 32 | 53 54 55 56 21 22 23 24 | 45 46 47 48 13 14 15 16 | 37 38 39 40 5 6 7 8 +// R = 57 58 59 60 25 26 27 28 | 49 50 51 52 17 18 19 20 | 41 42 43 44 9 10 11 12 | 33 34 35 36 1 2 3 4 + +// Step 5. Do a nibble cross-over +// L = a-->d b +// R = c d-->a +T32 := ((L shr 4) xor R) and $0F0F0F0F; +R := R xor T32; +L := L xor (T32 shl 4); + +// L = 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 +// R = 57 58 59 60 61 62 63 64 | 49 50 51 52 53 54 55 56 | 41 42 43 44 45 46 47 48 | 33 34 35 36 37 38 39 40 + +Int64Rec( Datum).Lo := L; +Int64Rec( Datum).Hi := R +end; + + + +function E_Bit_Selection( R: uint32): uint64; +var + i, j, k: integer; +begin +// E-bit selection table is ... +//32 1 2 3 4 5 +// 4 5 6 7 8 9 +// 8 9 10 11 12 13 +//12 13 14 15 16 17 +//16 17 18 19 20 21 +//20 21 22 23 24 25 +//24 25 26 27 28 29 +//28 29 30 31 32 1 + +// where R is ... +// R = 25 26 27 28 29 30 31 32 | 17 18 19 20 21 22 23 24 | 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 + +// Example data from http://orlingrabbe.com/des.htm +// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien 32) +// R0 = $AAF0AAF0; +// E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (big-endien 48) +// E(R0) = 010101 010101 100001 011110 010101 010101 100001 011110 (little-endien 48) +// E(R0) = 00010101 00010101 00100001 00011110 00010101 00010101 00100001 00011110 (little-endien 64 = 48 + 2MBS zeros per row) +// E(R0) = 00010101 00010101 00100001 00011110 00010101 00010101 00100001 00011110 (little-endien 64 = 48 + 2MBS zeros per row) +// E(R0) = $1515211E1515211E; (Delphi) +j := 1; +for i := 0 to 3 do + begin + k := i + 1; + if k = 4 then + k := 0; + Int64Rec( result).Bytes[j] := ((LongRec( R).Bytes[i] shl 1) and $3F) xor (LongRec( R).Bytes[k] shr 7); + Inc( j); + if j = 8 then + j := 0; + Int64Rec( result).Bytes[j] := ((LongRec( R).Bytes[i] shl 5) and $3F) xor (LongRec( R).Bytes[k] shr 3); + Inc( j) + end; +end; + + + +const SBox: array[ {Subkey:}0..7, {B-value:}0..63] of 0.. 15 = ( +{Subkey 0} ( +14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, +3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, +4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, +15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13), + +{Subkey 1} ( +15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, +9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, +0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, +5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9), + +{Subkey 2} ( +10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, +1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, +13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, +11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12), + +{Subkey 3} ( +7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, +1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, +10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, +15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14), + +{Subkey 4} ( +2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, +8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, +4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, +15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3), + +{Subkey 5} ( +12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, +0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, +9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, +7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13), + +{Subkey 6} ( +4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, +3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, +1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, +10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12), + +{Subkey 7} ( +13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, +10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, +7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, +0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11)); + + +BytePermute_8_6_7_2_5_3_4_1: array[ byte ] of byte = ( + $00, $80, $20, $A0, $40, $C0, $60, $E0, $08, $88, $28, $A8, $48, $C8, $68, $E8, + $02, $82, $22, $A2, $42, $C2, $62, $E2, $0A, $8A, $2A, $AA, $4A, $CA, $6A, $EA, + $04, $84, $24, $A4, $44, $C4, $64, $E4, $0C, $8C, $2C, $AC, $4C, $CC, $6C, $EC, + $06, $86, $26, $A6, $46, $C6, $66, $E6, $0E, $8E, $2E, $AE, $4E, $CE, $6E, $EE, + $10, $90, $30, $B0, $50, $D0, $70, $F0, $18, $98, $38, $B8, $58, $D8, $78, $F8, + $12, $92, $32, $B2, $52, $D2, $72, $F2, $1A, $9A, $3A, $BA, $5A, $DA, $7A, $FA, + $14, $94, $34, $B4, $54, $D4, $74, $F4, $1C, $9C, $3C, $BC, $5C, $DC, $7C, $FC, + $16, $96, $36, $B6, $56, $D6, $76, $F6, $1E, $9E, $3E, $BE, $5E, $DE, $7E, $FE, + $01, $81, $21, $A1, $41, $C1, $61, $E1, $09, $89, $29, $A9, $49, $C9, $69, $E9, + $03, $83, $23, $A3, $43, $C3, $63, $E3, $0B, $8B, $2B, $AB, $4B, $CB, $6B, $EB, + $05, $85, $25, $A5, $45, $C5, $65, $E5, $0D, $8D, $2D, $AD, $4D, $CD, $6D, $ED, + $07, $87, $27, $A7, $47, $C7, $67, $E7, $0F, $8F, $2F, $AF, $4F, $CF, $6F, $EF, + $11, $91, $31, $B1, $51, $D1, $71, $F1, $19, $99, $39, $B9, $59, $D9, $79, $F9, + $13, $93, $33, $B3, $53, $D3, $73, $F3, $1B, $9B, $3B, $BB, $5B, $DB, $7B, $FB, + $15, $95, $35, $B5, $55, $D5, $75, $F5, $1D, $9D, $3D, $BD, $5D, $DD, $7D, $FD, + $17, $97, $37, $B7, $57, $D7, $77, $F7, $1F, $9F, $3F, $BF, $5F, $DF, $7F, $FF); + + + +BytePermute_3_8_4_5_6_2_7_1: array[ byte ] of byte = ( + $00, $40, $02, $42, $08, $48, $0A, $4A, $10, $50, $12, $52, $18, $58, $1A, $5A, + $20, $60, $22, $62, $28, $68, $2A, $6A, $30, $70, $32, $72, $38, $78, $3A, $7A, + $80, $C0, $82, $C2, $88, $C8, $8A, $CA, $90, $D0, $92, $D2, $98, $D8, $9A, $DA, + $A0, $E0, $A2, $E2, $A8, $E8, $AA, $EA, $B0, $F0, $B2, $F2, $B8, $F8, $BA, $FA, + $04, $44, $06, $46, $0C, $4C, $0E, $4E, $14, $54, $16, $56, $1C, $5C, $1E, $5E, + $24, $64, $26, $66, $2C, $6C, $2E, $6E, $34, $74, $36, $76, $3C, $7C, $3E, $7E, + $84, $C4, $86, $C6, $8C, $CC, $8E, $CE, $94, $D4, $96, $D6, $9C, $DC, $9E, $DE, + $A4, $E4, $A6, $E6, $AC, $EC, $AE, $EE, $B4, $F4, $B6, $F6, $BC, $FC, $BE, $FE, + $01, $41, $03, $43, $09, $49, $0B, $4B, $11, $51, $13, $53, $19, $59, $1B, $5B, + $21, $61, $23, $63, $29, $69, $2B, $6B, $31, $71, $33, $73, $39, $79, $3B, $7B, + $81, $C1, $83, $C3, $89, $C9, $8B, $CB, $91, $D1, $93, $D3, $99, $D9, $9B, $DB, + $A1, $E1, $A3, $E3, $A9, $E9, $AB, $EB, $B1, $F1, $B3, $F3, $B9, $F9, $BB, $FB, + $05, $45, $07, $47, $0D, $4D, $0F, $4F, $15, $55, $17, $57, $1D, $5D, $1F, $5F, + $25, $65, $27, $67, $2D, $6D, $2F, $6F, $35, $75, $37, $77, $3D, $7D, $3F, $7F, + $85, $C5, $87, $C7, $8D, $CD, $8F, $CF, $95, $D5, $97, $D7, $9D, $DD, $9F, $DF, + $A5, $E5, $A7, $E7, $AD, $ED, $AF, $EF, $B5, $F5, $B7, $F7, $BD, $FD, $BF, $FF); + + + +BytePermute_1_2_7_4_5_6_3_8: array[ byte ] of byte = ( + $00, $01, $20, $21, $04, $05, $24, $25, $08, $09, $28, $29, $0C, $0D, $2C, $2D, + $10, $11, $30, $31, $14, $15, $34, $35, $18, $19, $38, $39, $1C, $1D, $3C, $3D, + $02, $03, $22, $23, $06, $07, $26, $27, $0A, $0B, $2A, $2B, $0E, $0F, $2E, $2F, + $12, $13, $32, $33, $16, $17, $36, $37, $1A, $1B, $3A, $3B, $1E, $1F, $3E, $3F, + $40, $41, $60, $61, $44, $45, $64, $65, $48, $49, $68, $69, $4C, $4D, $6C, $6D, + $50, $51, $70, $71, $54, $55, $74, $75, $58, $59, $78, $79, $5C, $5D, $7C, $7D, + $42, $43, $62, $63, $46, $47, $66, $67, $4A, $4B, $6A, $6B, $4E, $4F, $6E, $6F, + $52, $53, $72, $73, $56, $57, $76, $77, $5A, $5B, $7A, $7B, $5E, $5F, $7E, $7F, + $80, $81, $A0, $A1, $84, $85, $A4, $A5, $88, $89, $A8, $A9, $8C, $8D, $AC, $AD, + $90, $91, $B0, $B1, $94, $95, $B4, $B5, $98, $99, $B8, $B9, $9C, $9D, $BC, $BD, + $82, $83, $A2, $A3, $86, $87, $A6, $A7, $8A, $8B, $AA, $AB, $8E, $8F, $AE, $AF, + $92, $93, $B2, $B3, $96, $97, $B6, $B7, $9A, $9B, $BA, $BB, $9E, $9F, $BE, $BF, + $C0, $C1, $E0, $E1, $C4, $C5, $E4, $E5, $C8, $C9, $E8, $E9, $CC, $CD, $EC, $ED, + $D0, $D1, $F0, $F1, $D4, $D5, $F4, $F5, $D8, $D9, $F8, $F9, $DC, $DD, $FC, $FD, + $C2, $C3, $E2, $E3, $C6, $C7, $E6, $E7, $CA, $CB, $EA, $EB, $CE, $CF, $EE, $EF, + $D2, $D3, $F2, $F3, $D6, $D7, $F6, $F7, $DA, $DB, $FA, $FB, $DE, $DF, $FE, $FF); + + + +BytePermute_1_7_8_6_2_5_3_4: array[ byte ] of byte = ( + $00, $20, $40, $60, $10, $30, $50, $70, $04, $24, $44, $64, $14, $34, $54, $74, + $01, $21, $41, $61, $11, $31, $51, $71, $05, $25, $45, $65, $15, $35, $55, $75, + $02, $22, $42, $62, $12, $32, $52, $72, $06, $26, $46, $66, $16, $36, $56, $76, + $03, $23, $43, $63, $13, $33, $53, $73, $07, $27, $47, $67, $17, $37, $57, $77, + $08, $28, $48, $68, $18, $38, $58, $78, $0C, $2C, $4C, $6C, $1C, $3C, $5C, $7C, + $09, $29, $49, $69, $19, $39, $59, $79, $0D, $2D, $4D, $6D, $1D, $3D, $5D, $7D, + $0A, $2A, $4A, $6A, $1A, $3A, $5A, $7A, $0E, $2E, $4E, $6E, $1E, $3E, $5E, $7E, + $0B, $2B, $4B, $6B, $1B, $3B, $5B, $7B, $0F, $2F, $4F, $6F, $1F, $3F, $5F, $7F, + $80, $A0, $C0, $E0, $90, $B0, $D0, $F0, $84, $A4, $C4, $E4, $94, $B4, $D4, $F4, + $81, $A1, $C1, $E1, $91, $B1, $D1, $F1, $85, $A5, $C5, $E5, $95, $B5, $D5, $F5, + $82, $A2, $C2, $E2, $92, $B2, $D2, $F2, $86, $A6, $C6, $E6, $96, $B6, $D6, $F6, + $83, $A3, $C3, $E3, $93, $B3, $D3, $F3, $87, $A7, $C7, $E7, $97, $B7, $D7, $F7, + $88, $A8, $C8, $E8, $98, $B8, $D8, $F8, $8C, $AC, $CC, $EC, $9C, $BC, $DC, $FC, + $89, $A9, $C9, $E9, $99, $B9, $D9, $F9, $8D, $AD, $CD, $ED, $9D, $BD, $DD, $FD, + $8A, $AA, $CA, $EA, $9A, $BA, $DA, $FA, $8E, $AE, $CE, $EE, $9E, $BE, $DE, $FE, + $8B, $AB, $CB, $EB, $9B, $BB, $DB, $FB, $8F, $AF, $CF, $EF, $9F, $BF, $DF, $FF); + + + +BytePermute_8_7_5_6_4_3_1_2: array[ byte ] of byte = ( + $00, $80, $40, $C0, $10, $90, $50, $D0, $20, $A0, $60, $E0, $30, $B0, $70, $F0, + $08, $88, $48, $C8, $18, $98, $58, $D8, $28, $A8, $68, $E8, $38, $B8, $78, $F8, + $04, $84, $44, $C4, $14, $94, $54, $D4, $24, $A4, $64, $E4, $34, $B4, $74, $F4, + $0C, $8C, $4C, $CC, $1C, $9C, $5C, $DC, $2C, $AC, $6C, $EC, $3C, $BC, $7C, $FC, + $01, $81, $41, $C1, $11, $91, $51, $D1, $21, $A1, $61, $E1, $31, $B1, $71, $F1, + $09, $89, $49, $C9, $19, $99, $59, $D9, $29, $A9, $69, $E9, $39, $B9, $79, $F9, + $05, $85, $45, $C5, $15, $95, $55, $D5, $25, $A5, $65, $E5, $35, $B5, $75, $F5, + $0D, $8D, $4D, $CD, $1D, $9D, $5D, $DD, $2D, $AD, $6D, $ED, $3D, $BD, $7D, $FD, + $02, $82, $42, $C2, $12, $92, $52, $D2, $22, $A2, $62, $E2, $32, $B2, $72, $F2, + $0A, $8A, $4A, $CA, $1A, $9A, $5A, $DA, $2A, $AA, $6A, $EA, $3A, $BA, $7A, $FA, + $06, $86, $46, $C6, $16, $96, $56, $D6, $26, $A6, $66, $E6, $36, $B6, $76, $F6, + $0E, $8E, $4E, $CE, $1E, $9E, $5E, $DE, $2E, $AE, $6E, $EE, $3E, $BE, $7E, $FE, + $03, $83, $43, $C3, $13, $93, $53, $D3, $23, $A3, $63, $E3, $33, $B3, $73, $F3, + $0B, $8B, $4B, $CB, $1B, $9B, $5B, $DB, $2B, $AB, $6B, $EB, $3B, $BB, $7B, $FB, + $07, $87, $47, $C7, $17, $97, $57, $D7, $27, $A7, $67, $E7, $37, $B7, $77, $F7, + $0F, $8F, $4F, $CF, $1F, $9F, $5F, $DF, $2F, $AF, $6F, $EF, $3F, $BF, $7F, $FF); + + + + + +function DES_Permute( + SubKeyRound: integer; R: uint32; const Key: TExpandedKey): uint32; +// NOT WORKING YET !!! +var + i, j: integer; + T48, E: uint64; + b: ^byte; + b0, b1, b2, b3, t8: byte; + b1b0, b3b2: word; + t16: word; +begin +// SubKeyRound = 0; +// R= $AAF0AAF0; +// Key = as per http://orlingrabbe.com/des.htm example. +// result should be = 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien) +E := E_Bit_Selection( R); +T48 := E xor Key[ SubKeyRound]; +// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) = $AAF0AAF0; +// E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (big-endien) +// = $1515211E1515211E; +// K1 = Key[0] = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien) +// = $3201073F2F0B3006; +// f = K1+E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111 (big-endien) +// = $271426213A1E1118; +b := @T48; +for j := 0 to 7 do + begin + // b = @Int64Rec( T48).Bytes[ j]; + b^ := SBox[ j, b^]; + Inc( b, 1) + end; +// S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) +// = 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien compact) +// = $0709050B02080C05; +j := 0; +for i := 0 to 3 do + begin + LongRec( result).Bytes[i] := (Int64Rec( T48).Bytes[j ] shl 4) xor + Int64Rec( T48).Bytes[j+1]; + Inc( j, 2) + end; +// = 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien 32) +// = $97B5825C; + +// In the following fragment, we do the P-32 transform. This is ... +// P-32 transform +// 16 7 20 21 +// 29 12 28 17 +// 1 15 23 26 +// 5 18 31 10 +// 2 8 24 14 +// 32 27 3 9 +// 19 13 30 6 +// 22 11 4 25 +// which should transform 0101 1100 1000 0010 1011 0101 1001 0111 (big-endien 32) = $97B5825C +// to 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien 32) = $BBA94A23 + +// Equivalently in bytes ... +// 16 7 20 21 29 12 28 17 +// 1 15 23 26 5 18 31 10 +// 2 8 24 14 32 27 3 9 +// 19 13 30 6 22 11 4 25 + +// Start with .. +b0 := LongRec( result).Bytes[0]; // 1 2 3 4 5 6 7 8 +b1 := LongRec( result).Bytes[1]; // 9 10 11 12 13 14 15 16 +b2 := LongRec( result).Bytes[2]; // 17 18 19 20 21 22 23 24 +b3 := LongRec( result).Bytes[3]; // 25 26 27 28 29 30 31 32 +// Case Study numbers. +// b0 = 92 (decimal) = $5C = [0 1 0 1 | 1 1 0 0] (binary; MSB..LSB) +// b1 = 130 (decimal) = $82 = [1 0 0 0 | 0 0 1 0] +// b2 = 181 (decimal) = $B5 = [1 0 1 1 | 0 1 0 1] +// b3 = 151 (decimal) = $97 = [1 0 0 1 | 0 1 1 1] + +// [25 26 27 28 29 30 31 32] --> [32 30 31 26 29 27 28 25] +b3 := BytePermute_8_6_7_2_5_3_4_1[ b3]; +// Case Study: b3 = [1 1 1 0 0 0 1 1] = $E3 + +// [17 18 19 20 21 22 23 24] --> [19 24 20 21 22 18 23 17] +b2 := BytePermute_3_8_4_5_6_2_7_1[ b2]; +// Case Study: b2 = [1 1 1 0 1 0 0 1] = $E9 + +// b2 = 19 24 20 21 22 18 23 17 +// b3 = 32 30 31 26 29 27 28 25 +// Swap these bits, between b2 and b3: +// swaps: ** ** ** ** + +t8 := (b2 xor b3) and $8E; +b2 := b2 xor t8; +b3 := b3 xor t8; + +// b2 = 32 24 20 21 29 27 28 17 +// b3 = 19 30 31 26 22 18 23 25 + +// Case Study: b2 = [1 1 1 0 0 0 1 1] = $E3 +// Case Study: b3 = [1 1 1 0 1 0 0 1] = $E9 + +// Swap these bits on b3: +// vv xx +// 19 30 31 26 22 18 23 25 + +// [19 30 31 26 22 18 23 25] --> [19 30 31 26 22 18 23 25] +b3 := BytePermute_1_2_7_4_5_6_3_8[ b3]; +// Or equivalently, we could have put: +// t8 := (b3 xor (b3 shr 4)) and $02; +// b3 := b3 xor t8 xor (t8 shl 4); + +// to get ... +// 19 30 23 26 22 18 31 25 + +// Case Study: b3 = [1 1 0 0 1 0 1 1] = $CB + +// Back to the first two bytes. +// b0 = 1 2 3 4 5 6 7 8 +// b1 = 9 10 11 12 13 14 15 16 + +// [1 2 3 4 5 6 7 8] --> [1 7 8 6 2 5 3 4] +b0 := BytePermute_1_7_8_6_2_5_3_4[ b0]; +// Case Study: b0 = [0 0 0 1 1 1 0 1] = $1D + +// [9 10 11 12 13 14 15 16] --> [16 15 13 14 12 11 9 10] +b1 := BytePermute_8_7_5_6_4_3_1_2[ b1]; +// Case Study: b1 = [0 1 0 0 0 0 1 0] = $42 + +// b0 = 1 7 8 6 2 5 3 4 +// b1 = 16 15 13 14 12 11 9 10 + +//Now swap these bits ... +// b0 = 1 7 8 6 2 5 3 4 +// ** ** +// b1 = 16 15 13 14 12 11 9 10 + +t8 := (b0 xor b1) and $90; +b0 := b0 xor t8; +b1 := b1 xor t8; + +//to get this +// b0 = 16 7 8 14 2 5 3 4 +// b1 = 1 15 13 6 12 11 9 10 + +// Case Study: b0 = [0 0 0 0 1 1 0 1] = $0D +// Case Study: b1 = [0 1 0 1 0 0 1 0] = $52 + +// Now switch these bits ... +// b0 = 16 7 8 14 2 5 3 4 +// ^^ ^^ +// vv vv +// b1 = 1 15 13 6 12 11 9 10 + +t8 := (b0 xor (b1 shr 1)) and $05; +b0 := b0 xor t8; +b1 := b1 xor (t8 shl 1); + +//to get this ... +// b0 = 16 7 8 14 2 12 3 9 +// b1 = 1 15 13 6 5 11 4 10 + +// Case Study: b0 = [0 0 0 0 1 0 0 1] = $09 +// Case Study: b1 = [0 1 0 1 1 0 1 0] = $5A + +// Now swap these bits ... +// b1|b0= 1 15 13 6 5 11 4 10 16 7 8 14 2 12 3 9 (little-endien) +// ** ** ** ** ** ** ** ** ** +// b3|b2=19 30 23 26 22 18 31 25 32 24 20 21 29 27 28 17 + +WordRec( b1b0).Lo := b0; +WordRec( b1b0).Hi := b1; +WordRec( b3b2).Lo := b2; +WordRec( b3b2).Hi := b3; +// Case Study: b1b0 = $5A09 +// Case Study: b3b2 = $CBE3 +t16 := (b1b0 xor b3b2) and $363B; +b1b0 := b1b0 xor t16; +b3b2 := b3b2 xor t16; +//to get this ... +// b1|b0= 1 15 23 26 5 18 31 10 16 7 20 21 29 12 28 17 +// b3|b2=19 30 13 6 22 11 4 25 32 24 8 14 2 27 3 9 + +// Case Study: b1b0 = [0 1 0 0 | 1 0 1 0 | 0 0 1 0 | 0 0 1 1] = $4A23 +// Case Study: b3b2 = [1 1 0 1 | 1 0 1 1 | 1 1 0 0 | 1 0 0 1] = $DBC9 + +// Now switch these bits ... +// vv xx +// b3|b2=19 30 13 6 22 11 4 25 32 24 8 14 2 27 3 9 +t16 := (b3b2 xor (b3b2 shr 4)) and $0008; +b3b2 := b3b2 xor t16 xor (t16 shl 4); + +//to get this ... +// b3|b2=19 30 13 6 22 11 4 25 2 24 8 14 32 27 3 9 + +// Case Study: b3b2 = [1 1 0 1 | 1 0 1 1 | 1 1 0 0 | 1 0 0 1] = $DBC9 + +// Now switch these bits ... +// vv xx vv xx +// b3|b2=19 30 13 6 22 11 4 25 2 24 8 14 32 27 3 9 +t16 := (b3b2 xor (b3b2 shr 1)) and $2020; +b3b2 := b3b2 xor t16 xor (t16 shl 1); + +//to get this ... +// b3|b2=19 13 30 6 22 11 4 25 2 8 24 14 32 27 3 9 + +// Case Study numbers. +// 9 10 11 12 | 13 14 15 16 | 1 2 3 4 | 5 6 7 8 = [1 0 0 0 | 0 0 1 0 | 0 1 0 1 | 1 1 0 0] +// 25 26 27 28 | 29 30 31 32 |17 18 19 20 | 21 22 23 24 = [1 0 0 1 | 0 1 1 1 | 1 0 1 1 | 0 1 0 1] +// Case Study: b3b2 = [1 0 1 1 | 1 0 1 1 | 1 0 1 0 | 1 0 0 1] = $BBA9 + +// End result rendered as words.. +// b1|b0= 1 15 23 26 5 18 31 10 16 7 20 21 29 12 28 17 +// b3|b2=19 13 30 6 22 11 4 25 2 8 24 14 32 27 3 9 + +LongRec( result).Lo := b1b0; +LongRec( result).Hi := b3b2 + +// End result rendered as bytes.. +// b0 = 16 7 20 21 29 12 28 17 +// b1 = 1 15 23 26 5 18 31 10 +// b2= 2 8 24 14 32 27 3 9 +// b3= 19 13 30 6 22 11 4 25 + +// End result rendered as nibbles.. +// 16 7 20 21 +// 29 12 28 17 +// 1 15 23 26 +// 5 18 31 10 +// 2 8 24 14 +// 32 27 3 9 +// 19 13 30 6 +// 22 11 4 25 + +// which is the P-32 transform. +end; + + + +procedure DES_EncryptBlock( + Plaintext: uint64; var Ciphertext: uint64; const Key: TExpandedKey); +var + L, R, T32: uint32; + i: integer; +begin +IP_Transform( Plaintext, L, R); +// L0 = 1100 1100 0000 0000 1100 1100 1111 1111 (big-endien) +// R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) +// L = $FFCC00CC +// R = $AAF0AAF0 +for i := 0 to 15 do + begin + T32 := DES_Permute( i, R, Key) xor L; + // DES_Permute(i=0) = 0010 0011 0100 1010 1010 1001 1011 1011 (big-endien) = $BBA94A23 + // L(i=0)= $FFCC00CC + // T32(i=0)= 1110 1111 0100 1010 0110 0101 0100 0100 (big-endien) = $44654AEF + L := R; + R := T32 + end; +// L16 = 0100 0011 0100 0010 0011 0010 0011 0100 (big-endien) = $34324243 +// R16 = 0000 1010 0100 1100 1101 1001 1001 0101 (big-endien) = $95D94C0A +// Now Swap L & R and call the inverse IP transform. +IP_InverseTransform( R, L, Ciphertext) +// IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101 (big-endien) +// This is the encrypted form of M = 0123456789ABCDEF (big-endien): +// namely, C = 85E813540F0AB405 (big-endien) OR +// C = $05B40A0F5413E885 (delphi). +end; + + +procedure DES_DecryptBlock( + Ciphertext: uint64; var Plaintext: uint64; const Key: TExpandedKey); +var + L, R, T32: uint32; + i: integer; +begin +IP_Transform( Ciphertext, R, L); // L & R swapped. +for i := 15 downto 0 do + begin + T32 := R; + R := L; + L := DES_Permute( i, R, Key) xor T32 + end; +IP_InverseTransform( L, R, Plaintext) +end; + + +{ TDES } + +function TDES.BlockSize: integer; +begin +result := 64 +end; + + +constructor TDES.Create; +begin +end; + + +function TDES.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf' +end; + + +function TDES.DisplayName: string; +begin +result := 'DES' +end; + + +function TDES.Features: TAlgorithmicFeatureSet; +begin +result := [ + afCryptographicallyWeak, + afOpenSourceSoftware] +end; + + +function TDES.GenerateKey( Seed: TStream): TSymetricKey; +var + SeedKey: uint64; +begin +Seed.ReadBuffer( SeedKey, 8); +result := TDESKey.Create( SeedKey) +end; + + +function TDES.KeySize: integer; +begin +result := 56 +end; + + +function TDES.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TDESKey.CreateFromStream( Store) +end; + +function TDES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := TDESCodec.Create( Key as TDESKey) +end; + + + +function TDES.ProgId: string; +begin +result := DES_ProgId +end; + +function TDES.SeedByteSize: integer; +begin +result := 8 +end; + + + +function TDES.SelfTest_Plaintext: string; +{ This from "FIPS PUB 81 - DES MODES OF OPERATION" +(http://www.itl.nist.gov/fipspubs/fip81.htm) +TABLE B1: AN EXAMPLE OF THE ELECTRONIC CODEBOOK (ECB) MODE + +The ECB mode in the encrypt state has been selected. +Cryptographic Key = 0123456789abcdef + +The plain text is the ASCII code for "Now is the time for all ." These seven-bit characters are written in hexadecimal notation +(0,b7,b6,...,b1). + TIME PLAINTEXT | DES INPUT BLOCK | DES OUTPUT BLOCK | CIPHERTEXT + 1. 4e6f772069732074 | 4e6f772069732074 | 3fa40e8a984d4315 | 3fa40e8a984d4815 + 2. 68652074696d652o | 68652074696d652o | 6a271787ab8883f9 | 6a271787ab8883f9 + 3. 666f7220616c6c20 | 666f7220616c6c20 | 893d51ec4b563b53 | 893d51ec4b563b53 + +The ECB mode in the decrypt state has been selected. + TIME PLAINTEXT | DES INPUT BLOCK | DES OUTPUT BLOCK | CIPHERTEXT + 1. 3fa40e8a984d4815 | 3fa40e8a984d4815 | 4e6f772o69732o74 | 4e6f772069732074 + 2. 6a271787ab8883f9 | 6a271787ab8883f9 | 68652074696d6520 | 68652074696d6520 + 3. 893d51ec4b563b53 | 893d51ec4b563b53 | 666f7220616c6c20 | 666f7220616c6c20} +begin +result := '4e6f772069732074' +end; + + +function TDES.SelfTest_Ciphertext: string; +begin +result := '3fa40e8a984d4815' +end; + +function TDES.SelfTest_Key: string; +begin +result := '0123456789abcdef' +end; + +function TDES.WikipediaReference: string; +begin +result := 'Data_Encryption_Standard' +end; + + + +procedure SetParityBitsOnKey( var K: uint64); +var + ByteIndex, BitIdx: integer; + Byte1: byte; + Parity: byte; +begin +for ByteIndex := 0 to 7 do + begin + Byte1 := Int64Rec( K).Bytes[ ByteIndex]; + Parity := $00; + for BitIdx := 7 downto 1 do + Parity := Parity xor ((Byte1 shr BitIdx) and $01); + Int64Rec( K).Bytes[ ByteIndex] := (Byte1 and $FE) or Parity + end +end; + + +function hasCorrectParity( K: uint64): boolean; +var + ByteIndex, BitIdx: integer; + Byte1: byte; + Parity: byte; +begin +for ByteIndex := 0 to 7 do + begin + Byte1 := Int64Rec( K).Bytes[ ByteIndex]; + Parity := $00; + for BitIdx := 7 downto 1 do + Parity := Parity xor ((Byte1 shr BitIdx) and $01); + result := (Byte1 and $01) = Parity + end +end; + + + + + +{ TDESKey } + +constructor TDESKey.Create( NativeKey1: uint64); +begin +FNativeKey := NativeKey1; +SetParityBitsOnKey( FNativeKey); +ExpandKey( FNativeKey, FExpandedKey) +end; + + +constructor TDESKey.CreateFromStream( Store: TStream); +begin +Store.ReadBuffer( FNativeKey, 8); +if not hasCorrectParity( FNativeKey) then + raise Exception.Create( ES_InvalidKey); +ExpandKey( FNativeKey, FExpandedKey) +end; + + + +procedure TDESKey.SaveToStream(Stream: TStream); +begin +Stream.Write( FNativeKey, 8) +end; + + +procedure TDESKey.Burn; +begin +FNativeKey := 0; +FillChar( FExpandedKey, SizeOf( FExpandedKey), 0) +end; + + +{ TDESCodec } + +constructor TDESCodec.Create( LockBoxKey1: TDESKey); +begin +FLockBoxKey := LockBoxKey1 +end; + +procedure TDESCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Plaintext.Memory^, PlaintextBlock, 8); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey); +Move( CiphertextBlock, Ciphertext.Memory^, 8) +end; + + +procedure TDESCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Ciphertext.Memory^, CiphertextBlock, 8); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey); +Move( PlaintextBlock, Plaintext.Memory^, 8) +end; + + +procedure TDESCodec.Reset; +begin +end; + + +procedure TDESCodec.Burn; +begin +end; + + +end. diff --git a/run/TPLB3.Decorators.pas b/LockBox3/run/TPLB3.Decorators.pas similarity index 96% rename from run/TPLB3.Decorators.pas rename to LockBox3/run/TPLB3.Decorators.pas index c4ca947..19bc90f 100644 --- a/run/TPLB3.Decorators.pas +++ b/LockBox3/run/TPLB3.Decorators.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,82 +12,82 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Decorators; -interface - -type -IControlObject = interface - ['{420914AC-6242-417E-8D18-7B163056DA60}'] - function ControlObject: TObject; - end; - -{$IF compilerversion >= 21} -IntegerRange = class( TCustomAttribute) - private - FMin, FMax: Integer; - - public - constructor Create( Min1, Max1: Integer); - property Min : integer read FMin; - property Max : Integer read FMax; - end; - -DesignDescription = class( TCustomAttribute) - private - FDescription: string; - public - constructor Create( const Description1: string); - property Description: string read FDescription; - end; -{$IFEND} - - -IVariableSeedSize = Interface -['{38096CBB-5ACB-43D7-826A-C21812F6E447}'] - function MinSeedByteSize: integer; - function MaxSeedByteSize: integer; - - property Min : integer read MinSeedByteSize; - property Max : Integer read MaxSeedByteSize; - end; - - - -implementation - - - -{$IF compilerversion >= 21} -constructor IntegerRange.Create( Min1, Max1: Integer); -begin -FMin := Min1; -FMax := Max1 -end; - -constructor DesignDescription.Create( const Description1: string); -begin -FDescription := Description1 -end; - -{$IFEND} - - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Decorators; +interface + +type +IControlObject = interface + ['{420914AC-6242-417E-8D18-7B163056DA60}'] + function ControlObject: TObject; + end; + +{$IF compilerversion >= 21} +IntegerRange = class( TCustomAttribute) + private + FMin, FMax: Integer; + + public + constructor Create( Min1, Max1: Integer); + property Min : integer read FMin; + property Max : Integer read FMax; + end; + +DesignDescription = class( TCustomAttribute) + private + FDescription: string; + public + constructor Create( const Description1: string); + property Description: string read FDescription; + end; +{$IFEND} + + +IVariableSeedSize = Interface +['{38096CBB-5ACB-43D7-826A-C21812F6E447}'] + function MinSeedByteSize: integer; + function MaxSeedByteSize: integer; + + property Min : integer read MinSeedByteSize; + property Max : Integer read MaxSeedByteSize; + end; + + + +implementation + + + +{$IF compilerversion >= 21} +constructor IntegerRange.Create( Min1, Max1: Integer); +begin +FMin := Min1; +FMax := Max1 +end; + +constructor DesignDescription.Create( const Description1: string); +begin +FDescription := Description1 +end; + +{$IFEND} + + +end. diff --git a/run/TPLB3.ECB.pas b/LockBox3/run/TPLB3.ECB.pas similarity index 96% rename from run/TPLB3.ECB.pas rename to LockBox3/run/TPLB3.ECB.pas index 65daeda..2779873 100644 --- a/run/TPLB3.ECB.pas +++ b/LockBox3/run/TPLB3.ECB.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,140 +12,140 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.ECB; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TECB = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; virtual; - function ChainingFeatures: TChainingFeatureSet; virtual; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TECBLink = class( TBlockChainLink) - public - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - - - - -uses TPLB3.Constants, TPLB3.I18n; -{ TECB } - -function TECB.ChainingFeatures: TChainingFeatureSet; -begin -result := [cfNoNounce] -end; - -function TECB.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TECBLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TECB.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TECBLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TECB.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.1' -end; - - - -function TECB.DisplayName: string; -begin -result := ECB_DisplayName -end; - - - -function TECB.Features: TAlgorithmicFeatureSet; -begin -result := [afCryptographicallyWeak, afOpenSourceSoftware] -end; - - - -function TECB.ProgId: string; -begin -result := ECB_ProgId -end; - - - - - -function TECB.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29' -end; - - - -{ TECBLink } - -procedure TECBLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Decrypt_Block( Plaintext, Ciphertext) -end; - - - -procedure TECBLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( Plaintext, Ciphertext) -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.ECB; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TECB = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; virtual; + function ChainingFeatures: TChainingFeatureSet; virtual; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TECBLink = class( TBlockChainLink) + public + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + + + + +uses TPLB3.Constants, TPLB3.I18n; +{ TECB } + +function TECB.ChainingFeatures: TChainingFeatureSet; +begin +result := [cfNoNounce] +end; + +function TECB.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TECBLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TECB.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TECBLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TECB.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.1' +end; + + + +function TECB.DisplayName: string; +begin +result := ECB_DisplayName +end; + + + +function TECB.Features: TAlgorithmicFeatureSet; +begin +result := [afCryptographicallyWeak, afOpenSourceSoftware] +end; + + + +function TECB.ProgId: string; +begin +result := ECB_ProgId +end; + + + + + +function TECB.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29' +end; + + + +{ TECBLink } + +procedure TECBLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Decrypt_Block( Plaintext, Ciphertext) +end; + + + +procedure TECBLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( Plaintext, Ciphertext) +end; + +end. diff --git a/run/TPLB3.Hash.pas b/LockBox3/run/TPLB3.Hash.pas similarity index 95% rename from run/TPLB3.Hash.pas rename to LockBox3/run/TPLB3.Hash.pas index 45d0279..66b6cba 100644 --- a/run/TPLB3.Hash.pas +++ b/LockBox3/run/TPLB3.Hash.pas @@ -1,777 +1,777 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009, 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Hash; -interface -uses Classes, SysUtils, TPLB3.StreamCipher, - TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, - TPLB3.HashDsc, TPLB3.Compatibility; - -type - -TOnHashProgress = function( Sender: TObject; - CountBytesProcessed: int64): boolean of object; - -{$M-} -IHash = interface - ['{97CF303A-B823-42F3-98F6-7022015FDCB5}'] - function GetIsHashing: boolean; - function GetHash: IHashDsc; - procedure SetHash( const Value: IHashDsc); - function GetHashOutput: TStream; - function GetonProgress: TOnHashProgress; - procedure SetOnProgress( Value: TOnHashProgress); - - procedure Begin_Hash; - procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); - procedure End_Hash; - procedure Burn; - - procedure HashStream( Plaintext: TStream); - procedure HashFile ( const PlaintextFileName: string); - procedure HashBytes( const Plaintext: TBytes); - procedure HashString( const Plaintext: string); overload; -{$IFDEF UNICODE} - procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; - procedure Hashutf8string( const Plaintext: string); deprecated; -{$ENDIF} - - function isUserAborted: boolean; - procedure WriteHashOutputToStream( Dest: TStream); - procedure WriteHashOutputToMemory( var Dest); - - property isHashing: boolean read GetIsHashing; - property Hash: IHashDsc read GetHash write SetHash; - property HashOutputValue: TStream read GetHashOutput; - property OnProgress : TOnHashProgress read GetonProgress write SetOnProgress; - end; - - -IHash_TestAccess = interface - // This method is ONLY to be used by unit test programs. - ['{E6604CED-09A1-4EA6-BE22-B3371379218B}'] - function GetHasher: IHasher; - end; - -TSimpleHash = class( TInterfacedPersistent, IHash, IEventOrigin, IHash_TestAccess) - private - FSender: TObject; - - function GetIsHashing: boolean; - function GetHash: IHashDsc; - procedure SetHash( const Value: IHashDsc); - function GetHashOutput: TStream; - function GetonProgress: TOnHashProgress; - procedure SetOnProgress( Value: TOnHashProgress); - procedure Begin_Hash; - procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); - procedure End_Hash; - procedure Burn; - procedure HashStream( Plaintext: TStream); - procedure HashFile ( const PlaintextFileName: string); - procedure HashBytes( const Plaintext: TBytes); - procedure HashString( const Plaintext: string); overload; -{$IFDEF UNICODE} - procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; - procedure Hashutf8string( const Plaintext: string); deprecated; -{$ENDIF} - function isUserAborted: boolean; - procedure SetEventSender( Sender: TObject); - procedure WriteHashOutputToStream( Dest: TStream); - procedure WriteHashOutputToMemory( var Dest); - - // IHash_TestAccess. Just for testing - function GetHasher: IHasher; - - protected - FHashDsc: IHashDsc; - FHasher: IHasher; - FInputBufferLen: integer; // Physical length of FInputBuffer. - FInputBuffer: TMemoryStream; - // FInputBuffer will have the physical length of the hash block size. - // Its logical length will be indication by the stream position. - FOutputValue: TMemoryStream; - FOnProgress: TOnHashProgress; - FCount: int64; - FisUserAborted: boolean; - - public - constructor Create; - destructor Destroy; override; - end; - - -THash = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher, IHash_TestAccess) - private - FHashObj: TSimpleHash; - FHash : IHash; - FLib: TCryptographicLibrary; - FHashId: string; - FIntfCached: boolean; - - function GetIsHashing: boolean; - function GetHashOutput: TStream; - function GetonProgress: TOnHashProgress; - procedure SetOnProgress( Value: TOnHashProgress); - procedure ProgIdsChanged; - - procedure SetLib( Value: TCryptographicLibrary); - procedure Dummy( const Value: string); - procedure SetHashId( const Value: string); - procedure SetIntfCached( Value: boolean); - function GetFeatures: TAlgorithmicFeatureSet; - procedure ReadData( Reader: TReader); - procedure WriteData( Writer: TWriter); - - // IHash_TestAccess. Just for testing - function GetHasher: IHasher; - - protected - procedure Notification( - AComponent: TComponent; Operation: TOperation); override; - procedure DefineProperties( Filer: TFiler); override; - function GetHashDisplayName: string; virtual; - procedure Loaded; override; - - property InterfacesAreCached: boolean read FIntfCached write SetIntfCached; - - public - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - - procedure Begin_Hash; - procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); - procedure End_Hash; - procedure Burn; - - procedure HashStream( Plaintext: TStream); - procedure HashFile ( const PlaintextFileName: string); - procedure HashBytes( const Plaintext: TBytes); - procedure HashString( const Plaintext: string); overload; -{$IFDEF UNICODE} - procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; - procedure Hashutf8string( const Plaintext: string); deprecated; -{$ENDIF} - - function isUserAborted: boolean; - - property isHashing: boolean read GetIsHashing; - property HashId: string read FHashId write SetHashId; - property HashOutputValue: TStream read GetHashOutput; - - published - property Hash: string read GetHashDisplayName write Dummy stored False; - property Features: TAlgorithmicFeatureSet read GetFeatures stored False; - - property CryptoLibrary: TCryptographicLibrary read FLib write SetLib; - property OnProgress : TOnHashProgress read GetonProgress write SetOnProgress; - - end; - - - -implementation - - - -uses TPLB3.StreamUtils, TPLB3.BinaryUtils, Math; - - - - - - - - - - - -{ TSimpleHash } - -constructor TSimpleHash.Create; -begin -FInputBufferLen := 0; -FInputBuffer := TMemoryStream.Create; -FOutputValue := TMemoryStream.Create; -FSender := self -end; - - - - -destructor TSimpleHash.Destroy; -begin -Burn; -FInputBuffer.Free; -FOutputValue.Free; -FisUserAborted := False; -inherited -end; - - - - -procedure TSimpleHash.Begin_Hash; -begin -if not assigned( FHashDsc) then - raise Exception.Create( 'TSimpleHash.Begin_Hash - without undefined hash algorithm.'); -FHasher := nil; -if assigned( FHashDsc) then - begin - FHasher := FHashDsc.MakeHasher( self); - FInputBufferLen := FHashDsc.UpdateSize div 8; - FOutputValue.Size := FHashDsc.DigestSize div 8 - end; -FInputBuffer.Size := FInputBufferLen; -FInputBuffer.Position := 0; -FCount := 0; -FisUserAborted := False -end; - - - -procedure TSimpleHash.Burn; -begin -if assigned( FHasher) then - begin - FHasher.Burn; - FHasher := nil - end; -BurnMemoryStream( FInputBuffer); -BurnMemoryStream( FOutputValue); -FCount := 0; -FisUserAborted := False -end; - -procedure TSimpleHash.End_Hash; -begin -if FisUserAborted then - FOutputValue.Clear - else - begin - FOutputValue.Size := FHashDsc.DigestSize div 8; - FOutputValue.Position := 0; - FHasher.End_Hash( FInputBuffer, FOutputValue); - FOutputValue.Position := 0 - end; -FHasher := nil; -FCount := 0 -end; - - -function TSimpleHash.GetHash: IHashDsc; -begin -result := FHashDsc -end; - - -function TSimpleHash.GetHasher: IHasher; -begin -result := FHasher -end; - - -function TSimpleHash.GetHashOutput: TStream; -begin -result := FOutputValue -end; - - -function TSimpleHash.GetIsHashing: boolean; -begin -result := assigned( FHasher) -end; - -function TSimpleHash.GetonProgress: TOnHashProgress; -begin -result := FOnProgress -end; - - -{$IFDEF UNICODE} -procedure TSimpleHash.Hashutf8string( const Plaintext: string); -begin - HashString( Plaintext, TEncoding.UTF8); -end; -{$ENDIF} - - -procedure TSimpleHash.HashFile( const PlaintextFileName: string); -var - Plaintext: TStream; -begin -Plaintext := TFileStream.Create( PlaintextFileName, fmOpenRead); -try - HashStream( Plaintext) -finally - Plaintext.Free - end -end; - - - -procedure TSimpleHash.HashStream( Plaintext: TStream); -var - Buffer: packed array[ 0..128 ] of byte; - TargetBufSize: integer; - BufSize: integer; -begin -Begin_Hash; -try - Plaintext.Seek( 0, soBeginning); - TargetBufSize := SizeOf( Buffer); - repeat - BufSize := Plaintext.Read( Buffer, TargetBufSize); - if BufSize > 0 then - UpdateMemory( Buffer, BufSize) - until (BufSize <> TargetBufSize) or FisUserAborted -finally -End_Hash -end end; - - - -{$IFDEF UNICODE} -procedure TSimpleHash.HashString( const Plaintext: string); -begin - HashString( Plaintext, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure TSimpleHash.HashString( const Plaintext: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -{$IFDEF UNICODE} -var - PlaintextBytes: TBytes; -{$ENDIF} -begin -if Plaintext <> '' then - begin - {$IFDEF UNICODE} - PlaintextBytes := Encoding.GetBytes( Plaintext); - HashBytes( PlaintextBytes) - {$ELSE} - Begin_Hash; - try - // STRINGHELPER not defined if UNICODE is undefined. - UpdateMemory( Plaintext[ 1], Length( Plaintext) * SizeOf( Char)) - finally - End_Hash - end - {$ENDIF} - end; -end; - - - - -procedure TSimpleHash.HashBytes( const Plaintext: TBytes); -var - PlaintextLength: Integer; -begin -Begin_Hash; -try -PlaintextLength := Length( Plaintext); -if PlaintextLength <> 0 then - UpdateMemory( Plaintext[0], PlaintextLength); -finally -End_Hash -end end; - - - -function TSimpleHash.isUserAborted: boolean; -begin -result := FisUserAborted -end; - - -procedure TSimpleHash.SetEventSender( Sender: TObject); -begin -FSender := Sender -end; - - - -procedure TSimpleHash.SetHash( const Value: IHashDsc); -begin -if FHashDsc = Value then exit; -//if assigned( FHasher) then -// raise Exception.Create( 'TSimpleHash.SetHash - Cannot change hash ' + -// 'algorithm while a hash operation is underway.'); -FHasher := nil; -FHashDsc := Value; -if assigned( FHashDsc) then - begin - FHasher := FHashDsc.MakeHasher( self); - FInputBufferLen := FHashDsc.UpdateSize div 8; - FOutputValue.Size := FHashDsc.DigestSize div 8 - end - else - FOutputValue.Clear; -FInputBuffer.Size := FInputBufferLen -end; - - - - -procedure TSimpleHash.SetOnProgress( Value: TOnHashProgress); -begin -FOnProgress := Value -end; - - - - -procedure TSimpleHash.UpdateMemory( const Plaintext; PlaintextLen: integer); -var - Count: integer; - PlaintextP: PByte; - Xfer: integer; - InSize: integer; -begin -if not assigned( FHasher) then - raise Exception.Create( 'TSimpleHash.UpdateMemory - hashing not started.'); -PlaintextP := @Plaintext; -Count := PlaintextLen; -InSize := FInputBuffer.Position; -// FCount == Total count of input bytes hashed since BeginHash. -// Count == For this call, the remaining count of input bytes to be processed. -// InSize == Logical size of the input buffer. A shadow to FInputBuffer.Position -// FInputBufferLen == Physical length of the input buffer, or equivalently, the hash update block size. -// Xfer == Amount of input bytes to be processed in one hit. -// FInputBuffer.Position == Logical size of the input buffer. -// PlaintextP == Cursor into the plaintext (input bytes to be processed). -while (Count > 0) and (not FisUserAborted) do - begin - Xfer := Min( FInputBufferLen - InSize, Count); - if Xfer > 0 then - begin - FInputBuffer.Write( PlaintextP^, Xfer); - Inc( PlaintextP, Xfer); - Inc( InSize, Xfer); - Dec( Count, Xfer); - Inc( FCount, Xfer) - end; - if InSize < FInputBufferLen - then break; - FHasher.Update( FInputBuffer); - FInputBuffer.Position := 0; - InSize := 0; - if assigned( FOnProgress) and - (not FOnProgress( FSender, FCount)) then - begin - FisUserAborted := True; - End_Hash; - break - end; - end -end; - - - -procedure TSimpleHash.WriteHashOutputToMemory( var Dest); -begin -FOutputValue.Position := 0; -FOutputValue.Read( Dest, FOutputValue.Size); -FOutputValue.Position := 0 -end; - - -procedure TSimpleHash.WriteHashOutputToStream( Dest: TStream); -begin -Dest.CopyFrom( FOutputValue, 0); -FOutputValue.Position := 0 -end; - - -{ THash } - -constructor THash.Create( AOwner: TComponent); -var - Origin: IEventOrigin; -begin -inherited Create( AOwner); -FHashObj := TSimpleHash.Create; -FHash := FHashObj as IHash; -if Supports( FHashObj, IEventOrigin, Origin) then - Origin.SetEventSender( self); -FLib := nil; -FHashId := ''; -FIntfCached := False -end; - - -destructor THash.Destroy; -begin -FHash.Burn; -SetLib( nil); -FHash := nil; -FHashObj.Free; -inherited -end; - - - -procedure THash.Begin_Hash; -begin -InterfacesAreCached := True; -FHash.Begin_Hash -end; - - -procedure THash.Burn; -begin -FHash.Burn -end; - - - -procedure THash.DefineProperties( Filer: TFiler); -begin -inherited; -Filer.DefineProperty('HashId', ReadData, WriteData, True) -end; - - - -procedure THash.Dummy( const Value: string); -begin -end; - - - -procedure THash.End_Hash; -begin -FHash.Burn -end; - - - -function THash.GetFeatures: TAlgorithmicFeatureSet; -begin -InterfacesAreCached := True; -if FHash.Hash <> nil then - result := FHash.Hash.Features - else - result := [afNotImplementedYet] -end; - - - -function THash.GetHashDisplayName: string; -begin -InterfacesAreCached := True; -if FHash.Hash <> nil then - result := TCryptographicLibrary.ComputeHashDisplayName( FHash.Hash) - else - result := '' -end; - - - -function THash.GetHasher: IHasher; -var - TestAccess: IHash_TestAccess; -begin -InterfacesAreCached := True; -if Supports( FHash, IHash_TestAccess, TestAccess) then - result := TestAccess.GetHasher - else - result := nil -end; - - -function THash.GetHashOutput: TStream; -begin -result := FHash.HashOutputValue -end; - - - -function THash.GetIsHashing: boolean; -begin -result := FHash.isHashing -end; - - -function THash.GetonProgress: TOnHashProgress; -begin -result := FHash.OnProgress -end; - - -{$IFDEF UNICODE} -procedure THash.Hashutf8string( const Plaintext: string); -begin - HashString( Plaintext, TEncoding.UTF8); -end; -{$ENDIF} - - -procedure THash.HashFile( const PlaintextFileName: string); -begin -InterfacesAreCached := True; -FHash.HashFile( PlaintextFileName) -end; - - - -procedure THash.HashStream( Plaintext: TStream); -begin -InterfacesAreCached := True; -FHash.HashStream( Plaintext) -end; - - - -{$IFDEF UNICODE} -procedure THash.HashString( const Plaintext: string); -begin - HashString( Plaintext, TEncoding.UTF8); -end; -{$ENDIF} - - - -procedure THash.HashString( const Plaintext: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -begin -InterfacesAreCached := True; -FHash.HashString( Plaintext{$IFDEF UNICODE}, Encoding{$ENDIF}) -end; - - - -procedure THash.HashBytes( const Plaintext: TBytes); -begin -InterfacesAreCached := True; -FHash.HashBytes( Plaintext) -end; - - - -function THash.isUserAborted: boolean; -begin -result := FHash.isUserAborted -end; - - - -procedure THash.Loaded; -begin - inherited; -InterfacesAreCached := True -end; - -procedure THash.Notification( AComponent: TComponent; Operation: TOperation); -begin -inherited; -if (Operation = opRemove) and (AComponent = FLib) then - SetLib( nil) -end; - - -procedure THash.ProgIdsChanged; -begin -InterfacesAreCached := False -end; - - -procedure THash.SetHashId( const Value: string); -begin -if FHashId = Value then exit; -InterfacesAreCached := False; -FHashId := Value -end; - - - -procedure THash.SetIntfCached( Value: boolean); -begin -if FIntfCached = Value then exit; -FIntfCached := Value; -FHash.Hash := nil; -if FIntfCached and assigned( FLib) then - FHash.Hash := FLib.HashIntfc( FHashId) -end; - - - -procedure THash.SetLib( Value: TCryptographicLibrary); -var - OldLib: TCryptographicLibrary; -begin -if FLib = Value then exit; -if assigned( FLib) then - begin - OldLib := FLib; - FLib := nil; - OldLib.DegisterWatcher( self); - OldLib.RemoveFreeNotification( self) - end; -InterfacesAreCached := False; -FLib := Value; -if assigned( FLib) then - begin - FLib.FreeNotification( self); - FLib.RegisterWatcher ( self) - end -end; - - - -procedure THash.SetOnProgress( Value: TOnHashProgress); -begin -FHash.OnProgress := Value -end; - - - -procedure THash.UpdateMemory( const Plaintext; PlaintextLen: integer); -begin -FHash.UpdateMemory( Plaintext, PlaintextLen) -end; - -procedure THash.WriteData( Writer: TWriter); -begin -Writer.WriteString( FHashId) -end; - - -procedure THash.ReadData( Reader: TReader); -begin -HashId := Reader.ReadString -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009, 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Hash; +interface +uses Classes, SysUtils, TPLB3.StreamCipher, + TPLB3.BaseNonVisualComponent, TPLB3.CryptographicLibrary, + TPLB3.HashDsc, TPLB3.Compatibility; + +type + +TOnHashProgress = function( Sender: TObject; + CountBytesProcessed: int64): boolean of object; + +{$M-} +IHash = interface + ['{97CF303A-B823-42F3-98F6-7022015FDCB5}'] + function GetIsHashing: boolean; + function GetHash: IHashDsc; + procedure SetHash( const Value: IHashDsc); + function GetHashOutput: TStream; + function GetonProgress: TOnHashProgress; + procedure SetOnProgress( Value: TOnHashProgress); + + procedure Begin_Hash; + procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); + procedure End_Hash; + procedure Burn; + + procedure HashStream( Plaintext: TStream); + procedure HashFile ( const PlaintextFileName: string); + procedure HashBytes( const Plaintext: TBytes); + procedure HashString( const Plaintext: string); overload; +{$IFDEF UNICODE} + procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; + procedure Hashutf8string( const Plaintext: string); deprecated; +{$ENDIF} + + function isUserAborted: boolean; + procedure WriteHashOutputToStream( Dest: TStream); + procedure WriteHashOutputToMemory( var Dest); + + property isHashing: boolean read GetIsHashing; + property Hash: IHashDsc read GetHash write SetHash; + property HashOutputValue: TStream read GetHashOutput; + property OnProgress : TOnHashProgress read GetonProgress write SetOnProgress; + end; + + +IHash_TestAccess = interface + // This method is ONLY to be used by unit test programs. + ['{E6604CED-09A1-4EA6-BE22-B3371379218B}'] + function GetHasher: IHasher; + end; + +TSimpleHash = class( TInterfacedPersistent, IHash, IEventOrigin, IHash_TestAccess) + private + FSender: TObject; + + function GetIsHashing: boolean; + function GetHash: IHashDsc; + procedure SetHash( const Value: IHashDsc); + function GetHashOutput: TStream; + function GetonProgress: TOnHashProgress; + procedure SetOnProgress( Value: TOnHashProgress); + procedure Begin_Hash; + procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); + procedure End_Hash; + procedure Burn; + procedure HashStream( Plaintext: TStream); + procedure HashFile ( const PlaintextFileName: string); + procedure HashBytes( const Plaintext: TBytes); + procedure HashString( const Plaintext: string); overload; +{$IFDEF UNICODE} + procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; + procedure Hashutf8string( const Plaintext: string); deprecated; +{$ENDIF} + function isUserAborted: boolean; + procedure SetEventSender( Sender: TObject); + procedure WriteHashOutputToStream( Dest: TStream); + procedure WriteHashOutputToMemory( var Dest); + + // IHash_TestAccess. Just for testing + function GetHasher: IHasher; + + protected + FHashDsc: IHashDsc; + FHasher: IHasher; + FInputBufferLen: integer; // Physical length of FInputBuffer. + FInputBuffer: TMemoryStream; + // FInputBuffer will have the physical length of the hash block size. + // Its logical length will be indication by the stream position. + FOutputValue: TMemoryStream; + FOnProgress: TOnHashProgress; + FCount: int64; + FisUserAborted: boolean; + + public + constructor Create; + destructor Destroy; override; + end; + + +THash = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher, IHash_TestAccess) + private + FHashObj: TSimpleHash; + FHash : IHash; + FLib: TCryptographicLibrary; + FHashId: string; + FIntfCached: boolean; + + function GetIsHashing: boolean; + function GetHashOutput: TStream; + function GetonProgress: TOnHashProgress; + procedure SetOnProgress( Value: TOnHashProgress); + procedure ProgIdsChanged; + + procedure SetLib( Value: TCryptographicLibrary); + procedure Dummy( const Value: string); + procedure SetHashId( const Value: string); + procedure SetIntfCached( Value: boolean); + function GetFeatures: TAlgorithmicFeatureSet; + procedure ReadData( Reader: TReader); + procedure WriteData( Writer: TWriter); + + // IHash_TestAccess. Just for testing + function GetHasher: IHasher; + + protected + procedure Notification( + AComponent: TComponent; Operation: TOperation); override; + procedure DefineProperties( Filer: TFiler); override; + function GetHashDisplayName: string; virtual; + procedure Loaded; override; + + property InterfacesAreCached: boolean read FIntfCached write SetIntfCached; + + public + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + + procedure Begin_Hash; + procedure UpdateMemory( const Plaintext{in}; PlaintextLen: integer); + procedure End_Hash; + procedure Burn; + + procedure HashStream( Plaintext: TStream); + procedure HashFile ( const PlaintextFileName: string); + procedure HashBytes( const Plaintext: TBytes); + procedure HashString( const Plaintext: string); overload; +{$IFDEF UNICODE} + procedure HashString( const Plaintext: string; Encoding: TEncoding); overload; + procedure Hashutf8string( const Plaintext: string); deprecated; +{$ENDIF} + + function isUserAborted: boolean; + + property isHashing: boolean read GetIsHashing; + property HashId: string read FHashId write SetHashId; + property HashOutputValue: TStream read GetHashOutput; + + published + property Hash: string read GetHashDisplayName write Dummy stored False; + property Features: TAlgorithmicFeatureSet read GetFeatures stored False; + + property CryptoLibrary: TCryptographicLibrary read FLib write SetLib; + property OnProgress : TOnHashProgress read GetonProgress write SetOnProgress; + + end; + + + +implementation + + + +uses TPLB3.StreamUtils, TPLB3.BinaryUtils, Math; + + + + + + + + + + + +{ TSimpleHash } + +constructor TSimpleHash.Create; +begin +FInputBufferLen := 0; +FInputBuffer := TMemoryStream.Create; +FOutputValue := TMemoryStream.Create; +FSender := self +end; + + + + +destructor TSimpleHash.Destroy; +begin +Burn; +FInputBuffer.Free; +FOutputValue.Free; +FisUserAborted := False; +inherited +end; + + + + +procedure TSimpleHash.Begin_Hash; +begin +if not assigned( FHashDsc) then + raise Exception.Create( 'TSimpleHash.Begin_Hash - without undefined hash algorithm.'); +FHasher := nil; +if assigned( FHashDsc) then + begin + FHasher := FHashDsc.MakeHasher( self); + FInputBufferLen := FHashDsc.UpdateSize div 8; + FOutputValue.Size := FHashDsc.DigestSize div 8 + end; +FInputBuffer.Size := FInputBufferLen; +FInputBuffer.Position := 0; +FCount := 0; +FisUserAborted := False +end; + + + +procedure TSimpleHash.Burn; +begin +if assigned( FHasher) then + begin + FHasher.Burn; + FHasher := nil + end; +BurnMemoryStream( FInputBuffer); +BurnMemoryStream( FOutputValue); +FCount := 0; +FisUserAborted := False +end; + +procedure TSimpleHash.End_Hash; +begin +if FisUserAborted then + FOutputValue.Clear + else + begin + FOutputValue.Size := FHashDsc.DigestSize div 8; + FOutputValue.Position := 0; + FHasher.End_Hash( FInputBuffer, FOutputValue); + FOutputValue.Position := 0 + end; +FHasher := nil; +FCount := 0 +end; + + +function TSimpleHash.GetHash: IHashDsc; +begin +result := FHashDsc +end; + + +function TSimpleHash.GetHasher: IHasher; +begin +result := FHasher +end; + + +function TSimpleHash.GetHashOutput: TStream; +begin +result := FOutputValue +end; + + +function TSimpleHash.GetIsHashing: boolean; +begin +result := assigned( FHasher) +end; + +function TSimpleHash.GetonProgress: TOnHashProgress; +begin +result := FOnProgress +end; + + +{$IFDEF UNICODE} +procedure TSimpleHash.Hashutf8string( const Plaintext: string); +begin + HashString( Plaintext, TEncoding.UTF8); +end; +{$ENDIF} + + +procedure TSimpleHash.HashFile( const PlaintextFileName: string); +var + Plaintext: TStream; +begin +Plaintext := TFileStream.Create( PlaintextFileName, fmOpenRead); +try + HashStream( Plaintext) +finally + Plaintext.Free + end +end; + + + +procedure TSimpleHash.HashStream( Plaintext: TStream); +var + Buffer: packed array[ 0..128 ] of byte; + TargetBufSize: integer; + BufSize: integer; +begin +Begin_Hash; +try + Plaintext.Seek( 0, soBeginning); + TargetBufSize := SizeOf( Buffer); + repeat + BufSize := Plaintext.Read( Buffer, TargetBufSize); + if BufSize > 0 then + UpdateMemory( Buffer, BufSize) + until (BufSize <> TargetBufSize) or FisUserAborted +finally +End_Hash +end end; + + + +{$IFDEF UNICODE} +procedure TSimpleHash.HashString( const Plaintext: string); +begin + HashString( Plaintext, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure TSimpleHash.HashString( const Plaintext: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +{$IFDEF UNICODE} +var + PlaintextBytes: TBytes; +{$ENDIF} +begin +if Plaintext <> '' then + begin + {$IFDEF UNICODE} + PlaintextBytes := Encoding.GetBytes( Plaintext); + HashBytes( PlaintextBytes) + {$ELSE} + Begin_Hash; + try + // STRINGHELPER not defined if UNICODE is undefined. + UpdateMemory( Plaintext[ 1], Length( Plaintext) * SizeOf( Char)) + finally + End_Hash + end + {$ENDIF} + end; +end; + + + + +procedure TSimpleHash.HashBytes( const Plaintext: TBytes); +var + PlaintextLength: Integer; +begin +Begin_Hash; +try +PlaintextLength := Length( Plaintext); +if PlaintextLength <> 0 then + UpdateMemory( Plaintext[0], PlaintextLength); +finally +End_Hash +end end; + + + +function TSimpleHash.isUserAborted: boolean; +begin +result := FisUserAborted +end; + + +procedure TSimpleHash.SetEventSender( Sender: TObject); +begin +FSender := Sender +end; + + + +procedure TSimpleHash.SetHash( const Value: IHashDsc); +begin +if FHashDsc = Value then exit; +//if assigned( FHasher) then +// raise Exception.Create( 'TSimpleHash.SetHash - Cannot change hash ' + +// 'algorithm while a hash operation is underway.'); +FHasher := nil; +FHashDsc := Value; +if assigned( FHashDsc) then + begin + FHasher := FHashDsc.MakeHasher( self); + FInputBufferLen := FHashDsc.UpdateSize div 8; + FOutputValue.Size := FHashDsc.DigestSize div 8 + end + else + FOutputValue.Clear; +FInputBuffer.Size := FInputBufferLen +end; + + + + +procedure TSimpleHash.SetOnProgress( Value: TOnHashProgress); +begin +FOnProgress := Value +end; + + + + +procedure TSimpleHash.UpdateMemory( const Plaintext; PlaintextLen: integer); +var + Count: integer; + PlaintextP: PByte; + Xfer: integer; + InSize: integer; +begin +if not assigned( FHasher) then + raise Exception.Create( 'TSimpleHash.UpdateMemory - hashing not started.'); +PlaintextP := @Plaintext; +Count := PlaintextLen; +InSize := FInputBuffer.Position; +// FCount == Total count of input bytes hashed since BeginHash. +// Count == For this call, the remaining count of input bytes to be processed. +// InSize == Logical size of the input buffer. A shadow to FInputBuffer.Position +// FInputBufferLen == Physical length of the input buffer, or equivalently, the hash update block size. +// Xfer == Amount of input bytes to be processed in one hit. +// FInputBuffer.Position == Logical size of the input buffer. +// PlaintextP == Cursor into the plaintext (input bytes to be processed). +while (Count > 0) and (not FisUserAborted) do + begin + Xfer := Min( FInputBufferLen - InSize, Count); + if Xfer > 0 then + begin + FInputBuffer.Write( PlaintextP^, Xfer); + Inc( PlaintextP, Xfer); + Inc( InSize, Xfer); + Dec( Count, Xfer); + Inc( FCount, Xfer) + end; + if InSize < FInputBufferLen + then break; + FHasher.Update( FInputBuffer); + FInputBuffer.Position := 0; + InSize := 0; + if assigned( FOnProgress) and + (not FOnProgress( FSender, FCount)) then + begin + FisUserAborted := True; + End_Hash; + break + end; + end +end; + + + +procedure TSimpleHash.WriteHashOutputToMemory( var Dest); +begin +FOutputValue.Position := 0; +FOutputValue.Read( Dest, FOutputValue.Size); +FOutputValue.Position := 0 +end; + + +procedure TSimpleHash.WriteHashOutputToStream( Dest: TStream); +begin +Dest.CopyFrom( FOutputValue, 0); +FOutputValue.Position := 0 +end; + + +{ THash } + +constructor THash.Create( AOwner: TComponent); +var + Origin: IEventOrigin; +begin +inherited Create( AOwner); +FHashObj := TSimpleHash.Create; +FHash := FHashObj as IHash; +if Supports( FHashObj, IEventOrigin, Origin) then + Origin.SetEventSender( self); +FLib := nil; +FHashId := ''; +FIntfCached := False +end; + + +destructor THash.Destroy; +begin +FHash.Burn; +SetLib( nil); +FHash := nil; +FHashObj.Free; +inherited +end; + + + +procedure THash.Begin_Hash; +begin +InterfacesAreCached := True; +FHash.Begin_Hash +end; + + +procedure THash.Burn; +begin +FHash.Burn +end; + + + +procedure THash.DefineProperties( Filer: TFiler); +begin +inherited; +Filer.DefineProperty('HashId', ReadData, WriteData, True) +end; + + + +procedure THash.Dummy( const Value: string); +begin +end; + + + +procedure THash.End_Hash; +begin +FHash.Burn +end; + + + +function THash.GetFeatures: TAlgorithmicFeatureSet; +begin +InterfacesAreCached := True; +if FHash.Hash <> nil then + result := FHash.Hash.Features + else + result := [afNotImplementedYet] +end; + + + +function THash.GetHashDisplayName: string; +begin +InterfacesAreCached := True; +if FHash.Hash <> nil then + result := TCryptographicLibrary.ComputeHashDisplayName( FHash.Hash) + else + result := '' +end; + + + +function THash.GetHasher: IHasher; +var + TestAccess: IHash_TestAccess; +begin +InterfacesAreCached := True; +if Supports( FHash, IHash_TestAccess, TestAccess) then + result := TestAccess.GetHasher + else + result := nil +end; + + +function THash.GetHashOutput: TStream; +begin +result := FHash.HashOutputValue +end; + + + +function THash.GetIsHashing: boolean; +begin +result := FHash.isHashing +end; + + +function THash.GetonProgress: TOnHashProgress; +begin +result := FHash.OnProgress +end; + + +{$IFDEF UNICODE} +procedure THash.Hashutf8string( const Plaintext: string); +begin + HashString( Plaintext, TEncoding.UTF8); +end; +{$ENDIF} + + +procedure THash.HashFile( const PlaintextFileName: string); +begin +InterfacesAreCached := True; +FHash.HashFile( PlaintextFileName) +end; + + + +procedure THash.HashStream( Plaintext: TStream); +begin +InterfacesAreCached := True; +FHash.HashStream( Plaintext) +end; + + + +{$IFDEF UNICODE} +procedure THash.HashString( const Plaintext: string); +begin + HashString( Plaintext, TEncoding.UTF8); +end; +{$ENDIF} + + + +procedure THash.HashString( const Plaintext: string{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +begin +InterfacesAreCached := True; +FHash.HashString( Plaintext{$IFDEF UNICODE}, Encoding{$ENDIF}) +end; + + + +procedure THash.HashBytes( const Plaintext: TBytes); +begin +InterfacesAreCached := True; +FHash.HashBytes( Plaintext) +end; + + + +function THash.isUserAborted: boolean; +begin +result := FHash.isUserAborted +end; + + + +procedure THash.Loaded; +begin + inherited; +InterfacesAreCached := True +end; + +procedure THash.Notification( AComponent: TComponent; Operation: TOperation); +begin +inherited; +if (Operation = opRemove) and (AComponent = FLib) then + SetLib( nil) +end; + + +procedure THash.ProgIdsChanged; +begin +InterfacesAreCached := False +end; + + +procedure THash.SetHashId( const Value: string); +begin +if FHashId = Value then exit; +InterfacesAreCached := False; +FHashId := Value +end; + + + +procedure THash.SetIntfCached( Value: boolean); +begin +if FIntfCached = Value then exit; +FIntfCached := Value; +FHash.Hash := nil; +if FIntfCached and assigned( FLib) then + FHash.Hash := FLib.HashIntfc( FHashId) +end; + + + +procedure THash.SetLib( Value: TCryptographicLibrary); +var + OldLib: TCryptographicLibrary; +begin +if FLib = Value then exit; +if assigned( FLib) then + begin + OldLib := FLib; + FLib := nil; + OldLib.DegisterWatcher( self); + OldLib.RemoveFreeNotification( self) + end; +InterfacesAreCached := False; +FLib := Value; +if assigned( FLib) then + begin + FLib.FreeNotification( self); + FLib.RegisterWatcher ( self) + end +end; + + + +procedure THash.SetOnProgress( Value: TOnHashProgress); +begin +FHash.OnProgress := Value +end; + + + +procedure THash.UpdateMemory( const Plaintext; PlaintextLen: integer); +begin +FHash.UpdateMemory( Plaintext, PlaintextLen) +end; + +procedure THash.WriteData( Writer: TWriter); +begin +Writer.WriteString( FHashId) +end; + + +procedure THash.ReadData( Reader: TReader); +begin +HashId := Reader.ReadString +end; + + +end. diff --git a/run/TPLB3.HashDsc.pas b/LockBox3/run/TPLB3.HashDsc.pas similarity index 97% rename from run/TPLB3.HashDsc.pas rename to LockBox3/run/TPLB3.HashDsc.pas index 5939d0a..b7bf633 100644 --- a/run/TPLB3.HashDsc.pas +++ b/LockBox3/run/TPLB3.HashDsc.pas @@ -1,68 +1,68 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.HashDsc; -interface -uses Classes, TPLB3.StreamCipher; - -type - -IHasher = interface - ['{982870E4-EC9B-48CD-B882-17F58F0A7D1A}'] - procedure Update( Source{in}: TMemoryStream); - // Source length in bytes must be EXACTLY the UpdateSize/8 . - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); - // PartBlock is the final source content. The length in bytes of the - // payload is indicated by the stream position (not stream size). And this - // must be less than or equal to UpdateSize/8. It may be zero. - // It is the responsibility of the client to set initializer the - // Digest position and size prior to invocation of End_Hash. - // End_Hash simply writes DigestSize/8 bytes to the Digest stream - // from its current position. - procedure Burn; - function SelfTest_Source: string; // Bigendien hex string, oriented into u32 groups.; - function SelfTest_ReferenceHashValue: string; // as above - end; - -IHashDsc = interface( ICryptoGraphicAlgorithm) - // Hash descriptor. Describes a hashing algorithm. - ['{A3922AFC-C917-4364-9FD1-FD84A3E37558}'] - function DigestSize: integer; // in units of bits. Must be a multiple of 8. - function UpdateSize: integer; // Size that the input to the Update must be. - - function MakeHasher( const Params: IInterface): IHasher; - end; - - -implementation - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.HashDsc; +interface +uses Classes, TPLB3.StreamCipher; + +type + +IHasher = interface + ['{982870E4-EC9B-48CD-B882-17F58F0A7D1A}'] + procedure Update( Source{in}: TMemoryStream); + // Source length in bytes must be EXACTLY the UpdateSize/8 . + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); + // PartBlock is the final source content. The length in bytes of the + // payload is indicated by the stream position (not stream size). And this + // must be less than or equal to UpdateSize/8. It may be zero. + // It is the responsibility of the client to set initializer the + // Digest position and size prior to invocation of End_Hash. + // End_Hash simply writes DigestSize/8 bytes to the Digest stream + // from its current position. + procedure Burn; + function SelfTest_Source: string; // Bigendien hex string, oriented into u32 groups.; + function SelfTest_ReferenceHashValue: string; // as above + end; + +IHashDsc = interface( ICryptoGraphicAlgorithm) + // Hash descriptor. Describes a hashing algorithm. + ['{A3922AFC-C917-4364-9FD1-FD84A3E37558}'] + function DigestSize: integer; // in units of bits. Must be a multiple of 8. + function UpdateSize: integer; // Size that the input to the Update must be. + + function MakeHasher( const Params: IInterface): IHasher; + end; + + +implementation + +end. diff --git a/run/TPLB3.HugeCardinal.pas b/LockBox3/run/TPLB3.HugeCardinal.pas similarity index 96% rename from run/TPLB3.HugeCardinal.pas rename to LockBox3/run/TPLB3.HugeCardinal.pas index fa2ea1a..7cc1355 100644 --- a/run/TPLB3.HugeCardinal.pas +++ b/LockBox3/run/TPLB3.HugeCardinal.pas @@ -1,2208 +1,2209 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.HugeCardinal; -{.$define profiling} -interface -uses Classes, TPLB3.IntegerUtils, TPLB3.MemoryStreamPool -{$IFDEF profiling} - , Generics.Collections -{$ENDIF} - ; - -type - {$define SI} -TCompareResult = (rGreaterThan, rEqualTo, rLessThan); -TByteOrder = (LittleEndien, BigEndien); -TProgress = procedure ( Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean) of object; - -{$if CompilerVersion >= 21.00} -THugeCardinal = class sealed -{$else} -THugeCardinal = class -{$ifend} - - // An instance of this class represents a very large non-negative integer. - private - FMaxBits: integer; // Maximum number of bits of storage. - // For efficiency reasons, we will not allow - // re-allocation/resizing. - FBits: integer; // Cached value of the bit length of the value; -{$IFNDEF SI} - FValue: TMemoryStream; // Little-endien. -{$ENDIF} - - procedure CheckBits; - class function ComputedNeededSize( RequestedBits: integer): integer; - procedure ClearMem( Offset, Length: integer); - procedure DividePrimitive( - Divisor: THugeCardinal; - var Quotient, Remainder: THugeCardinal; - RequiresQuotient: boolean); - function GetAsHexString: string; - - procedure MulPower2_OldAlgorithm( ShiftAmnt: integer); - procedure MulPower2_NewAlgorithm( ShiftAmnt: integer); - procedure MultiplyMod_Old( Factor, Modulus: THugeCardinal); - procedure MultiplyMod_New( Factor, Modulus: THugeCardinal); - - - protected - function NewMemoryStream( InitBitSize: integer): TMemoryStream; - function ValuePntr( ByteIndex: integer): PByte; - - public -{$IFDEF SI} - FValue: TMemoryStream; // Little-endien. -{$ENDIF} - - FPool: IMemoryStreamPool; - - // Life-cycle methods. - constructor CreateSimple( Value: uint64); - constructor CreateZero( MaxBits1: integer; const Pool1: IMemoryStreamPool); - constructor CreateRandom( Bits1, MaxBits1: integer; ExactBitLength: boolean; const Pool1: IMemoryStreamPool); - // CreateRandom creates a random number up to Bits1 bits long. - // If ExactBitLength is True, then the resultant bit length will be - // exactly Bits1 long. Otherwise it may range anywhere down to zero. - - constructor CreateSmall( Value: uint64; MaxBits1: integer; const Pool1: IMemoryStreamPool); - constructor CreateAsClone( Master: THugeCardinal; const Pool1: IMemoryStreamPool); - constructor CreateAsSizedClone( MaxBits1: integer; Master: THugeCardinal; const Pool1: IMemoryStreamPool); - constructor CreateFromStreamIn( - MaxBits1: integer; ByteOrder: - TByteOrder; Stream: TStream; const Pool1: IMemoryStreamPool); - destructor Destroy; override; - function Clone: THugeCardinal; - function CloneSized( MaxBits1: integer): THugeCardinal; - procedure Resize( NewMaxBit1: integer); - procedure Burn; - - // Size properties. - function BitLength: integer; - function MaxBits: integer; - function CapacityInBits: integer; - - // Assignment. - procedure Assign( Source: THugeCardinal); - procedure AssignFromStreamIn( ByteOrder: TByteOrder; Stream: TStream); - procedure AssignSmall( Value: uint64); - procedure Swap( Peer: THugeCardinal); - - // Random numbers. - procedure Random( UpperBound: THugeCardinal); - // ^ Results in a random number x, such that: - // 0 <= x < UpperBound. - // Requires (UpperBound >= 1) and (UpperBound.BitLength <= MaxBits) - procedure RandomBits( BitsOfRandom: integer; ExactBitLength: boolean); - // ^ if ExactBitLength = False, results in .... - // 0 <= x < (2 ** BitsOfRandom) . - // In other words ..... - // x.BitLength <= BitsOfRandom - // If ExactBitLength = True, results in .... - // (2 ** BitsOfRandom-1) <= x < (2 ** BitsOfRandom) . - // In other words ..... - // x.BitLength = BitsOfRandom - // Assumes BitsOfRandom >= 1. - - // Comparison - function Compare( Reference: THugeCardinal): TCompareResult; - function CompareSmall( Reference: uint64): TCompareResult; - function isZero: boolean; - function isOdd: boolean; - - // Small ops. - procedure Zeroise; - function isSmall: boolean; - function ExtractSmall: uint64; - function ModSmall( Modulus: uint64): uint64; - - // Addition. - procedure Add( Addend: THugeCardinal); - procedure Increment( Addend: int64); - procedure Subtract( Subtractend: THugeCardinal); - procedure AddMod( Addend, Modulus: THugeCardinal); - - // Multiplication. - procedure MulSmall( Factor: uint32); - function Multiply( Factor: THugeCardinal): THugeCardinal; - procedure MultiplyMod( Factor, Modulus: THugeCardinal); - procedure SquareMod( Modulus: THugeCardinal); - procedure MulPower2( ShiftAmnt: integer); - - // Division - function Modulo( Modulus: THugeCardinal): THugeCardinal; - procedure Divide( Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal); - - // Exponentiation. - function PowerMod( Exponent, Modulus: THugeCardinal; OnProgress: TProgress): boolean; - // ^ Return True if not aborted. - - function PowerMod_WithChineseRemainderAlgorithm( - Exponent, // d - Modulus: THugeCardinal; // n := p * q - FactorP, // p - FactorQ, // q - ExponentModFactorP, // dp := d mod p-1 - ExponentModFactorQ, // dq := d mod q-1 - InverseQ : THugeCardinal; // qinv := q ** -1 mod p - // result := self ** d mod n - OnProgress: TProgress): boolean; - // ^ Return True if not aborted. - - procedure SmallExponent_PowerMod( Exponent: uint64; Modulus: THugeCardinal); - procedure SmallExponent_Power( Exponent: uint32); // Only used for unit-test purposes. - - // Streaming. - procedure StreamOut( ByteOrder: TByteOrder; Stream: TStream; - SizeToOutput: integer = -1); - // ^ Streams the low order SizeToOutput bytes out to the stream. - // If SizeToOutput is -1, then this is interpreted as (MaxBits + 7) div 8 - property AsHexString: string read GetAsHexString; - end; - -procedure SafeAssign( Destin, Source: THugeCardinal); // Both parameters must pre-exist. -procedure SafeAdd( Sum, Addend1, Addend2: THugeCardinal); // All 3 parameters must pre-exist. - -type - TProfileSection = ( - proc_Add, proc_Increment, proc_Subtract, proc_AddMod, - proc_MulSmall, func_Multiply, proc_MultiplyMod, proc_SquareMod, - proc_MulPower2, func_Modulo, proc_Divide, func_PowerMod, - proc_SmallExponent_PowerMod); - TProfileSectionSet = set of TProfileSection; - - TProfileSectionResult = record - Section: TProfileSection; - Sum, Start: Int64; - end; - -var - ActiveProfileSections: TProfileSectionSet = -[proc_MultiplyMod, proc_SquareMod, proc_MulPower2, func_Modulo]; - -{$IFDEF profiling} -var - SectionStack: TStack = nil; -{$ENDIF} - -var - HugeCardinal_InstanceCount: integer = 0; - doUseMulPower2_NewAlgorithm: boolean = True; - doUseMultiplyMod_NewAlgorithm: boolean = True; - doProfiling: boolean = False; - - ExecutionTimes: array[ TProfileSection] of Int64; - ExecutionPercentages: array[ TProfileSection] of cardinal; - -procedure InitExecutionTimes; -procedure DoneExecutionTimes; -procedure CalcExecutionPercentages; - -implementation - - - - - - - - - - - - - - - - - - -uses SysUtils, TPLB3.StreamUtils, Math, TPLB3.Random, TPLB3.I18n, - TPLB3.PointerArithmetic, TPLB3.Compatibility; - - -{$IFDEF profiling} -type -TProfileSectionHold = class( TInterfacedObject) - private - doFrame: boolean; - public - constructor Create( Entry: TProfileSection); - destructor Destroy; override; - end; -{$ENDIF} - -function EnterProfileSection( Entry: TProfileSection): IInterface; -begin -{$IFDEF profiling} -if Entry in ActiveProfileSections then - result := TProfileSectionHold.Create( Entry) - else -{$ENDIF} -{$IFNDEF profiling} -result := nil -{$ENDIF} -end; - -procedure InitExecutionTimes; -var - j: TProfileSection; -begin -for j := Low( TProfileSection) to High( TProfileSection) do - ExecutionTimes[j] := 0; -{$IFDEF profiling} -SectionStack.Free; -SectionStack := TStack.Create -{$ENDIF} -end; - -procedure DoneExecutionTimes; -begin -{$IFDEF profiling} -SectionStack.Free; -SectionStack := nil -{$ENDIF} -end; - - -{$IFDEF profiling} -constructor TProfileSectionHold.Create( Entry: TProfileSection); -var - Now1: Int64; - ProfSectRes: TProfileSectionResult; - isEmpty: boolean; -begin - isEmpty := SectionStack.Count = 0; - doFrame := isEmpty or (SectionStack.Peek.Section <> Entry); - if not doFrame then exit; - if not isEmpty then - ProfSectRes := SectionStack.Pop; - QueryPerformanceCounter( Now1); - if (not isEmpty) and (ProfSectRes.Start > 0) then - begin - ProfSectRes.Sum := ProfSectRes.Sum + (Now1 - ProfSectRes.Start); - ProfSectRes.Start := 0; - SectionStack.Push( ProfSectRes) - end; - ProfSectRes.Section := Entry; - ProfSectRes.Sum := 0; - ProfSectRes.Start := Now1; - SectionStack.Push( ProfSectRes) -end; - -destructor TProfileSectionHold.Destroy; -var - Now1: Int64; - ProfSectRes: TProfileSectionResult; - isEmpty: boolean; -begin -if doFrame then - begin - QueryPerformanceCounter( Now1); - ProfSectRes := SectionStack.Pop; - if ProfSectRes.Start > 0 then - ProfSectRes.Sum := ProfSectRes.Sum + (Now1 - ProfSectRes.Start); - ExecutionTimes[ProfSectRes.Section] := ExecutionTimes[ProfSectRes.Section] + ProfSectRes.Sum; - if SectionStack.Count > 0 then - begin - ProfSectRes := SectionStack.Pop; - ProfSectRes.Start := Now1; - SectionStack.Push( ProfSectRes) - end - end; -inherited -end; -{$ENDIF} - - -procedure CalcExecutionPercentages; -var - j: TProfileSection; - Sum: Int64; -begin -Sum := 0; -for j := Low( TProfileSection) to High( TProfileSection) do - if j in ActiveProfileSections then - Sum := Sum + ExecutionTimes[j]; -for j := Low( TProfileSection) to High( TProfileSection) do - if (Sum = 0) or (ExecutionTimes[j] = 0) or (not (j in ActiveProfileSections)) then - ExecutionPercentages[j] := 0 - else - ExecutionPercentages[j] := Round( (ExecutionTimes[j] / Sum) * 100.0) -end; - - procedure SafeAssign( Destin, Source: THugeCardinal); - begin - Destin.Zeroise; - if Source.BitLength > Destin.MaxBits then - Destin.Resize( Source.BitLength); - Destin.Assign( Source) - end; - - procedure SafeAdd( Sum, Addend1, Addend2: THugeCardinal); - var - Tmp: THugeCardinal; - begin - Tmp := THugeCardinal.CreateAsSizedClone( Max( Addend1.BitLength, Addend2.BitLength) + 1, Addend1, Addend1.FPool); - Tmp.Add( Addend2); - SafeAssign( Sum, Tmp); - Tmp.Free - end; - - -{ THugeCardinal } - - -procedure SetBit( Number: THugeCardinal; BitIndex: integer); -var - P: PByte; -begin -P := MemStrmOffset( Number.FValue, BitIndex div 8); -P^ := P^ or (1 shl (BitIndex mod 8)) -end; - - -procedure ClearBit( Number: THugeCardinal; BitIndex: integer); -var - P: PByte; -begin -P := MemStrmOffset( Number.FValue, BitIndex div 8); -P^ := P^ and (not (1 shl (BitIndex mod 8))) -end; - -function TestBit( Number: THugeCardinal; BitIndex: integer): boolean; -var - P: PByte; -begin -P := MemStrmOffset( Number.FValue, BitIndex div 8); -result := (P^ and (1 shl (BitIndex mod 8))) <> 0 -end; - - -class function THugeCardinal.ComputedNeededSize( - RequestedBits: integer): integer; -begin -result := Max( RequestedBits, 64); -if (result mod 8) <> 0 then - result := result + 8 - (result mod 8) -end; - - - -constructor THugeCardinal.CreateAsClone( Master: THugeCardinal; const Pool1: IMemoryStreamPool); -begin -FPool := Pool1; -FMaxBits := Master.MaxBits; -FBits := Master.FBits; -FValue := NewMemoryStream( Master.FValue.Size * 8); -Move( Master.FValue.Memory^, FValue.Memory^, FValue.Size); -AtomicIncrement( HugeCardinal_InstanceCount) -end; - - -constructor THugeCardinal.CreateAsSizedClone( MaxBits1: integer; Master: THugeCardinal; const Pool1: IMemoryStreamPool); -var - DataByteLen: integer; -begin -FPool := Pool1; -FMaxBits := ComputedNeededSize( MaxBits1); -if Master.BitLength > FMaxBits then - raise Exception.Create( ES_HugeCardinal_CloneOverflow); -DataByteLen := (Master.BitLength + 7) div 8; -FValue := NewMemoryStream( FMaxBits); -if DataByteLen > 0 then - Move( Master.FValue.Memory^, FValue.Memory^, DataByteLen); -ClearMem( DataByteLen, FValue.Size - DataByteLen); -FBits := Master.BitLength; -AtomicIncrement( HugeCardinal_InstanceCount) -end; - - -constructor THugeCardinal.CreateFromStreamIn( - MaxBits1: integer; ByteOrder: TByteOrder; Stream: TStream; const Pool1: IMemoryStreamPool); -begin -FPool := Pool1; -FMaxBits := ComputedNeededSize( MaxBits1); -FValue := NewMemoryStream( FMaxBits); -AssignFromStreamIn( ByteOrder, Stream); -AtomicIncrement( HugeCardinal_InstanceCount) -end; - - - -constructor THugeCardinal.CreateRandom( - Bits1, MaxBits1: integer; ExactBitLength: boolean; - const Pool1: IMemoryStreamPool); -begin -CreateZero( MaxBits1, Pool1); -if Bits1 > FMaxBits then - Bits1 := FMaxBits; -RandomBits( Bits1, ExactBitLength) -end; - - -procedure THugeCardinal.Random( UpperBound: THugeCardinal); -begin -if not UpperBound.isZero then - repeat - RandomBits( UpperBound.BitLength, False) - until Compare( UpperBound) = rLessThan -end; - - - -procedure THugeCardinal.RandomBits( BitsOfRandom: integer; - ExactBitLength: boolean); -var - R: TStream; - Bits, j: integer; - Bytes, OldBytes: integer; - HighByte, Mask: byte; -begin -if BitsOfRandom <= 0 then exit; -R := TRandomStream.Instance; -CheckBits; -Bits := BitsOfRandom; -Bytes := ((Bits + 7) div 8) - 1; -OldBytes := ((FBits + 7) div 8); -FBits := -1; -if Bytes > 0 then - begin - // Determine all the bytes, except the most significant byte. - R.Read( FValue.Memory^, Bytes); - Dec( Bits, Bytes * 8) - end; -if Bits > 0 then - begin - // Determine the most significant byte. - R.Read( HighByte, 1); - Mask := 1; - for j := 2 to Bits do - Mask := (Mask shl 1) + 1; - HighByte := HighByte and Mask; - FValue.Position := Bytes; - FValue.Write( HighByte, 1); - Inc( Bytes); - if ((HighByte shr (Bits - 1)) and $01) = $01 then - FBits := BitsOfRandom - end; -if OldBytes > Bytes then - BurnMemory( ValuePntr( Bytes)^, OldBytes - Bytes); -if ExactBitLength then - begin - SetBit( self, BitsOfRandom-1); - FBits := BitsOfRandom - end -end; - - -constructor THugeCardinal.CreateSimple( Value: uint64); -begin -CreateSmall( Value, 0, nil) -end; - - - -constructor THugeCardinal.CreateSmall( Value: uint64; MaxBits1: integer; const Pool1: IMemoryStreamPool); -begin -CreateZero( MaxBits1, Pool1); -if Value > 0 then - begin - FValue.Write( Value, SizeOf( Value)); - FBits := BitCount_64( Value) - end -end; - - -constructor THugeCardinal.CreateZero( MaxBits1: integer; const Pool1: IMemoryStreamPool); -begin -FPool := Pool1; -FMaxBits := ComputedNeededSize( MaxBits1); -FBits := 0; -FValue := NewMemoryStream( FMaxBits); -ZeroFillStream( FValue); -AtomicIncrement( HugeCardinal_InstanceCount) -end; - - -destructor THugeCardinal.Destroy; -begin -AtomicDecrement( HugeCardinal_InstanceCount); -FValue.Free; -inherited -end; - - -function THugeCardinal.ExtractSmall: uint64; -begin -Move( FValue.Memory^, result, 8) -end; - -function THugeCardinal.GetAsHexString: string; -var - // Temp: THugeCardinal; - ValueByte: byte; - Idx: integer; - P1: PByte; - StrIdx: integer; - {$IFDEF STRINGHELPER}Output: TStringBuilder;{$ENDIF} - - function CharOfNibble( Nibble: byte): Char; - begin - if Nibble <= 9 then - result := Chr( Ord('0') + Nibble) - else - result := Chr( Ord('A') + Nibble - 10) - end; - -begin -// Temp := Clone; -Idx := (BitLength + 7) div 8; -{$IFDEF STRINGHELPER} -Output := TStringBuilder.Create; -Output.Length := Idx * 2; -{$ELSE} -SetLength( result, Idx * 2); -{$ENDIF} -P1 := ValuePntr( Idx); -StrIdx := -1; -while Idx > 0 do - begin - Dec( P1, 1); - Dec( Idx); - Inc( StrIdx, 2); - ValueByte := P1^; - {$IFDEF STRINGHELPER} - Output.Chars[StrIdx-1] := CharOfNibble( ValueByte shr 4); - Output.Chars[StrIdx ] := CharOfNibble( ValueByte and $0F) - {$ELSE} - result[StrIdx ] := CharOfNibble( ValueByte shr 4); - result[StrIdx+1] := CharOfNibble( ValueByte and $0F) - {$ENDIF} - end; -{$IFDEF STRINGHELPER} -if (Output.Length > 0) and (Output.Chars[0] = '0') and (not isZero) then - Output.Remove( 0, 1); -result := Output.ToString; -Output.Free; -{$ELSE} -if (Length( result) > 0) and (result[1] = '0') and (not isZero) then - Delete( result, 1, 1); -{$ENDIF} -if Length( result) = 0 then - result := '0'; -end; - -type Puint64 = ^uint64; - -procedure THugeCardinal.Add( Addend: THugeCardinal); -var - P1, P2: PByte; - I1, D1, D2: integer; - Carry: boolean; - Sum: uint16; - v: uint64; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_AddOverflow) - end; - -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_Add); -{$ENDIF} -if Addend.isZero then exit; -if isZero then - begin - Assign( Addend); - exit - end; -if Addend.isSmall then - begin - v := Addend.ExtractSmall; - if v <= $7FFFFFFFFFFFFFFF then - begin - Increment( v); - exit - end - end; -if Addend.BitLength > MaxBits then - Overflow; -P1 := FValue.Memory; // Cursor into the accumulator. -I1 := FValue.Size; // Complement of offset into P1. -D1 := (BitLength + 7) div 8; // Number of original data bytes in the accumulator. - -P2 := Addend.FValue.Memory; -D2 := (Addend.BitLength + 7) div 8; - -Carry := False; -while (D1 > 0) or (D2 > 0) or Carry do - begin - if (D1 >= 8) and (D2 >= 8) then - begin - Puint64( P1)^ := Add_uint64_WithCarry( Puint64( P1)^, Puint64( P2)^, Carry); - Inc( P1, 8); - Inc( P2, 8); - Dec( D1, 8); - Dec( D2, 8); - Dec( I1, 8) - end - - else - begin - if D1 > 0 then - Sum := P1^ - else - Sum := 0; - - if D2 > 0 then - Inc( Sum, P2^); - - if Carry then - Inc( Sum); - - if I1 > 0 then - begin - P1^ := WordRec( Sum).Lo; - Carry := WordRec( Sum).Hi <> 0 - end - else if Sum = 0 then - Carry := False - else - Overflow; - Inc( P1, 1); - Inc( P2, 1); - Dec( I1, 1); - Dec( D1, 1); - Dec( D2, 1) - end - end; -FBits := -1 -end; - - - -procedure THugeCardinal.AddMod( Addend, Modulus: THugeCardinal); -var - RequiredBits: integer; - Sum, Remainder: THugeCardinal; -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_AddMod); -{$ENDIF} -RequiredBits := Max( BitLength, Addend.BitLength) + 1; -if RequiredBits < MaxBits then - Sum := self - else - Sum := CloneSized( RequiredBits); -try - Sum.Add( Addend); - Remainder := Sum.Modulo( Modulus); - try - Assign( Remainder) - finally - Remainder.Free - end -finally -if Sum <> self then - Sum.Free -end end; - - - -procedure THugeCardinal.Assign( Source: THugeCardinal); -var - SourceBytes: integer; -begin -SourceBytes := (Source.BitLength + 7) div 8; -if SourceBytes > FValue.Size then - raise Exception.Create( ES_CannotAssignHuge_BecauseSourceTooBig); -if SourceBytes > 0 then - Move( Source.FValue.Memory^, FValue.Memory^, SourceBytes); -ClearMem( SourceBytes, FValue.Size - SourceBytes); -FBits := Source.BitLength -end; - - - -procedure THugeCardinal.AssignSmall( Value: uint64); -begin -if BitLength > 64 then - Zeroise; -Move( Value, FValue.Memory^, SizeOf( Value)); -FBits := -1 -end; - - -function THugeCardinal.BitLength: integer; -begin -CheckBits; -result := FBits -end; - - -procedure THugeCardinal.Burn; -begin -BurnMemoryStream( FValue); -FBits := 0 -end; - - -procedure THugeCardinal.CheckBits; -var - P32: ^uint32; - P8: PByte; - LastBits: integer; -begin -if FBits <> -1 then exit; -FBits := FValue.Size * 8; -if FBits = 0 then exit; -P8 := ValuePntr( FBits div 8); -LastBits := 0; -while (FBits > 0) and (LastBits = 0) do - begin - if (FBits >= 32) and isAligned32( P8) then - begin - Dec( P8, 4); - P32 := pointer( P8); - LastBits := BitCount_32( P32^); - Dec( FBits, 32 - LastBits) - end - else - begin - Dec( P8, 1); - LastBits := BitCount_8( P8^); - Dec( FBits, 8 - LastBits) - end - end -end; - - - -procedure THugeCardinal.ClearMem( Offset, Length: integer); -begin -ClearMemory( FValue, Offset, Length) -end; - - -function THugeCardinal.Clone: THugeCardinal; -begin -result := THugeCardinal.CreateAsClone( self, FPool) -end; - - - -function THugeCardinal.CloneSized( MaxBits1: integer): THugeCardinal; -begin -result := THugeCardinal.CreateAsSizedClone( MaxBits1, self, FPool) -end; - - -function THugeCardinal.Compare( Reference: THugeCardinal): TCompareResult; -var - Diff: integer; - P1, P2: PByte; - Idx: integer; -begin -Diff := BitLength - Reference.BitLength; -if Diff <> 0 then - begin - if Diff > 0 then - result := rGreaterThan - else - result := rLessThan - end - - else - begin - result := rEqualTo; - if BitLength <> 0 then - begin - Idx := (BitLength + 7) div 8; - P1 := ValuePntr( Idx); - P2 := Reference.ValuePntr( Idx); - while (Idx > 0) and (result = rEqualTo) do - begin - Dec( P1, 1); - Dec( P2, 1); - Dec( Idx); - Diff := P1^; - Diff := Diff - P2^; - if Diff > 0 then - result := rGreaterThan - else if Diff < 0 then - result := rLessThan - end - end - end -end; - - - -function THugeCardinal.CompareSmall( Reference: uint64): TCompareResult; -var - V: uint64; -begin -if isSmall then - begin - V := ExtractSmall; - if V > Reference then - result := rGreaterThan - else if V < Reference then - result := rLessThan - else - result := rEqualTo - end - else - result := rGreaterThan -end; - - - -procedure THugeCardinal.Increment( Addend: int64); -var - P1: PByte; - I1, Stop_I1: integer; - Carry, Borrow: boolean; - Sum: uint16; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_IncrementOverflow) - end; - -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_Increment); -{$ENDIF} -if Addend = 0 then exit; - -if MaxBits < 8 then - Overflow; - -P1 := FValue.Memory; -I1 := (BitLength + 7) div 8; -Stop_I1 := I1 - FValue.Size; // -ve of spare capacity. - - -if Addend > 0 then - begin - Carry := False; - Puint64( P1)^ := Add_uint64_WithCarry( Puint64( P1)^, Addend, Carry); - Inc( P1, 8); - Dec( I1, 8); - while (I1 > 0) or Carry do - begin - if I1 <= Stop_I1 then - Overflow; - - if I1 > 0 then - Sum := P1^ - else - Sum := 0; - - if Carry then - Inc( Sum); - - P1^ := WordRec( Sum).Lo; - Carry := WordRec( Sum).Hi <> 0; - Inc( P1, 1); - Dec( I1, 1); - end - end - else - begin // -ve case - Borrow := False; - Puint64( P1)^ := Subtract_uint64_WithBorrow( Puint64( P1)^, -Addend, Borrow); - Inc( P1, 8); - Dec( I1, 8); - while (I1 > 0) or Borrow do - begin - if I1 <= Stop_I1 then - Overflow; - - if I1 > 0 then - Sum := P1^ - else - Sum := 0; - - if Borrow then - begin - if Sum = 0 then - Sum := 255 - else - begin - Dec( Sum); - Borrow := False - end - end; - P1^ := WordRec( Sum).Lo; - Inc( P1, 1); - Dec( I1, 1); - end - end; -FBits := -1 -end; - - -function THugeCardinal.isOdd: boolean; -var - LowByte: byte; -begin -CheckBits; -result := FBits > 0; -if not result then exit; -FValue.Position := 0; -FValue.Read( LowByte, 1); -result := Odd( LowByte) -end; - - - -function THugeCardinal.isSmall: boolean; -begin -result := BitLength <= 64 -end; - - -function THugeCardinal.isZero: boolean; -begin -CheckBits; -result := FBits = 0 -end; - - -function THugeCardinal.MaxBits: integer; -begin -result := FMaxBits -end; - - - - -function THugeCardinal.ModSmall( Modulus: uint64): uint64; -var - Mask, Low64: uint64; - Quot, Mod1: THugeCardinal; -begin -if Modulus <= 1 then - result := 0 - else if Modulus = 2 then - result := Ord( isOdd) - else - begin - Low64 := ExtractSmall; - if CountSetBits_64( Modulus) = 1 then - // Modulus = 4, 8, 16 etc. - begin - Mask := Modulus - 1; // Mask = $03, $07, $0F etc. - result := Low64 and Mask - end - else if isSmall and (int64rec( Modulus).Hi = 0) and - (int64rec( Low64 ).Hi = 0) then - // Pure 32 bit operation. - result := int64rec( Low64).Lo mod int64rec( Modulus).Lo - // 64-bit mod might be possible, but I dont trust the compiler to - // get it right. - else - begin - Mod1 := nil; - Quot := nil; - try - Mod1 := THugeCardinal.CreateSmall( Modulus, 0, FPool); - Quot := Modulo( Mod1); - result := Quot.ExtractSmall - finally - Mod1.Free; - Quot.Free - end - end - end -end; - - -function THugeCardinal.Modulo( Modulus: THugeCardinal): THugeCardinal; -var - Dummy: THugeCardinal; -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( func_Modulo); -{$ENDIF} -Dummy := nil; -DividePrimitive( Modulus, Dummy, result, False); -Dummy.Free -end; - - - -procedure THugeCardinal.Divide( - Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal); -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_Divide); -{$ENDIF} -DividePrimitive( Divisor, Quotient, Remainder, True) -end; - - -procedure THugeCardinal.DividePrimitive( - Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal; - RequiresQuotient: boolean); -var - ShiftedMod: THugeCardinal; - ShiftAmnt: integer; - RemainderBits, ModulusBits, DiffBits: integer; - Compare: TCompareResult; - LeftShift: integer; - QuotientByte: PByte; - Mask: byte; - -begin -QuotientByte := nil; -Remainder := CloneSized( BitLength); -if RequiresQuotient then - Quotient := THugeCardinal.CreateZero( Max( BitLength, Divisor.BitLength), FPool); -if BitLength > Divisor.BitLength then - ShiftedMod := Divisor.CloneSized( BitLength) - else - ShiftedMod := Divisor.Clone; -try -ShiftAmnt := 0; -RemainderBits := Remainder.BitLength; -ModulusBits := Divisor.BitLength; -DiffBits := RemainderBits - ModulusBits; -if DiffBits > 0 then - Compare := rGreaterThan - else if DiffBits < 0 then - Compare := rLessThan - else - Compare := Remainder.Compare( Divisor); -while ((Compare in [rGreaterThan, rEqualTo]) or (ShiftAmnt > 0)) and - (RemainderBits > 0) do - begin - LeftShift := DiffBits; - if (LeftShift < 0) and ((-LeftShift) > ShiftAmnt) then - LeftShift := - ShiftAmnt; - if (ShiftAmnt + LeftShift) = 0 then - ShiftedMod.Assign( Divisor) - else - ShiftedMod.MulPower2( LeftShift); - Inc( ShiftAmnt, LeftShift); - if LeftShift <> 0 then - Compare := Remainder.Compare( ShiftedMod); - if (Compare = rLessThan) and (ShiftAmnt > 0) then - begin - if ShiftAmnt = 1 then - ShiftedMod.Assign( Divisor) - else - ShiftedMod.MulPower2( -1); - Dec( ShiftAmnt); - Compare := rGreaterThan - end; - if Compare in [rGreaterThan, rEqualTo] then - begin - Remainder.Subtract( ShiftedMod); - RemainderBits := Remainder.BitLength; - Compare := rLessThan; - // set bit ShiftAmnt of Quotient - if RequiresQuotient and (ShiftAmnt > Quotient.MaxBits) then - raise Exception.Create( ES_HugeCardinal_DivideOverflow); - if RequiresQuotient then - QuotientByte := Quotient.ValuePntr( ShiftAmnt div 8); - Mask := 1 shl (ShiftAmnt mod 8); - if RequiresQuotient then - begin - Assert( (QuotientByte^ and Mask) = 0, - AS_HugeCardinal_DivideLogicFail); - QuotientByte^ := QuotientByte^ or Mask - end - end; - DiffBits := RemainderBits - (ModulusBits + ShiftAmnt) - end; -finally -ShiftedMod.Free -end; -if RequiresQuotient then - Quotient.FBits := -1 -end; - - - -procedure THugeCardinal.MulPower2( ShiftAmnt: integer); -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_MulPower2); -{$ENDIF} -if doUseMulPower2_NewAlgorithm then - MulPower2_NewAlgorithm( ShiftAmnt) - else - MulPower2_OldAlgorithm( ShiftAmnt) -end; - -procedure THugeCardinal.MulPower2_OldAlgorithm( ShiftAmnt: integer); -var - P8: PByte; - P32: ^uint32; - Carry: byte; - Remaining, ShiftBytes: integer; - b8_1, b8_2: byte; - b32_1, b32_2: uint32; - DataLen: integer; - Idx: integer; // index into data value pointed to by the write pointer P8. - InitialBits: integer; - InitialShiftAmnt: integer; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_Power2) - end; - -begin -if (ShiftAmnt = 0) or isZero then exit; - -InitialBits := BitLength; -if (InitialBits + ShiftAmnt) > MaxBits then - Overflow; - -InitialShiftAmnt := ShiftAmnt; - -if ShiftAmnt > 0 then - ShiftBytes := ShiftAmnt div 8 - else - ShiftBytes := -((-ShiftAmnt + 7) div 8); - -Dec( ShiftAmnt, ShiftBytes * 8); -DataLen := (FBits + 7) div 8; -P8 := FValue.Memory; -Idx := 0; -Remaining := DataLen; - -if ShiftBytes >= 1 then - begin - // Here, we want to shift-left the value data by ShiftBytes (bytes). - // Shift-left is equivalent to multiplication by a positive power of 2. - // The newly shifted out area must be cleared. - // In the context of little-endien byte order, picture data bytes as - // laid out from right (offset zero, least signficant), traversing - // to left (offset Size-1, most signficant). And picture the bits - // within the bytes as bit 0 (LSB) on the right-hand side, traversing - // bits horizontally to bit 7 (MSB) of the byte on the left-hand side. - // In a big-endien system, bytes would be laid out pictorially in the - // reverse order. - // ShiftAmnt is now an amount of bits to be shift-left, ranging - // from 0 to 7. - if (ShiftBytes + DataLen) > FValue.Size then - Overflow; - P8 := ValuePntr( ShiftBytes); - Idx := ShiftBytes; - Move( FValue.Memory^, P8^, DataLen); - ClearMem( 0, ShiftBytes); - Inc( FBits, ShiftBytes * 8) - end; - -Carry := 0; - -if ShiftBytes <= -1 then - begin - ShiftBytes := - ShiftBytes; - // Here, we want to shift-right the value data by ShiftBytes. - if ((ShiftBytes - 1) < DataLen) and (ShiftAmnt > 0) then - begin - // We shift-right a few bits too far, so save these bits - // to be shift-lefted back in later. - P8 := ValuePntr( ShiftBytes - 1); - Carry := P8^ shr (8 - ShiftAmnt) - end; - if ShiftBytes < DataLen then - begin - P8 := ValuePntr( ShiftBytes); - Idx := DataLen - ShiftBytes; - Move( P8^, FValue.Memory^, Idx); - ClearMem( Idx, ShiftBytes); - Dec( FBits, ShiftBytes * 8); - Dec( Remaining, ShiftBytes) - end - else - begin - ClearMem( 0, DataLen); - FBits := 0; - Remaining := 0 - end; - P8 := FValue.Memory; - Idx := 0 - end; - -if ShiftAmnt = 0 then exit; - -// Here, we want to shift-left the value data by ShiftAmnt bits, -// where ShiftAmnt ranges from 1 to 7. -while Remaining > 0 do - begin - if (Remaining >= 4) and isAligned32( P8) then - begin - P32 := pointer( P8); - b32_1 := P32^ shr (32 - ShiftAmnt); - b32_2 := Carry; - Carry := LongRec( b32_1).Bytes[0]; - b32_1 := P32^ shl ShiftAmnt; - P32^ := b32_1 or b32_2; - Inc( P8, 4); - Dec( Remaining, 4); - Inc( Idx, 4) - end - else - begin - b8_1 := P8^ shr (8 - ShiftAmnt); - b8_2 := Carry; - Carry := b8_1; - b8_1 := P8^ shl ShiftAmnt; - P8^ := b8_1 or b8_2; - Inc( P8); - Dec( Remaining); - Dec( Idx) - end; - end; - -if Carry > 0 then - // Here, we have shifted all the main data, but we have a few bits - // of carry left over. - begin - if Idx < FValue.Size then - P8^ := Carry - else - Overflow - end; -FBits := InitialBits + InitialShiftAmnt; -if FBits < 0 then - FBits := 0 -end; - - - -procedure THugeCardinal.MulPower2_NewAlgorithm( ShiftAmnt: integer); -var - LogicalBitCount : integer; - LogicalByteCount : integer; - PhysicalByteCount: integer; - ShiftBytesLeft, ShiftBitsLeft: integer; - ShiftBytesRight, ShiftBitsRight: integer; - // FinalByteIndex: integer; - isLeftShift: boolean; - Remaining: integer; - P8: PByte; - P32: ^uint32; - Carry: byte; - // ShiftBytes: integer; - b8_1, b8_2: byte; - b32_1, b32_2: uint32; - ShiftComp8, ShiftComp32: integer; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_Power2) - end; - -begin -if (ShiftAmnt = 0) or isZero then exit; -LogicalBitCount := BitLength; -LogicalByteCount := (LogicalBitCount + 7) div 8; -PhysicalByteCount := FValue.Size; -if ShiftAmnt > 0 then - begin - ShiftBytesLeft := ShiftAmnt div 8; - ShiftBitsLeft := ShiftAmnt mod 8; - ShiftBitsRight := 0; -// if (ShiftBitsLeft > 0) and ((ShiftBytesLeft + LogicalByteCount) < PhysicalByteCount) then -// begin -// Inc( ShiftBytesLeft); -// ShiftBitsRight := 8 - ShiftBitsLeft; -// ShiftBitsLeft := 0 -// end; - if (ShiftBytesLeft + LogicalByteCount) > PhysicalByteCount then - Overflow; - if ShiftBytesLeft > 0 then - begin - Move( FValue.Memory^, ValuePntr( ShiftBytesLeft)^, LogicalByteCount); - ClearMem( 0, ShiftBytesLeft); - Inc( FBits, ShiftBytesLeft * 8) - end; - end - else - begin - ShiftAmnt := - ShiftAmnt; - ShiftBytesRight := ShiftAmnt div 8; - ShiftBitsRight := ShiftAmnt mod 8; - ShiftBitsLeft := 0; - if ShiftBytesRight >= LogicalByteCount then - begin - ClearMem( 0, LogicalByteCount); - FBits := 0 - end - else if ShiftBytesRight > 0 then - begin - Move( ValuePntr( ShiftBytesRight)^, FValue.Memory^, LogicalByteCount - ShiftBytesRight); - ClearMem( LogicalByteCount - ShiftBytesRight, ShiftBytesRight); - Dec( FBits, ShiftBytesRight * 8) - end; - end; -if ((ShiftBitsLeft + ShiftBitsRight) > 0) and (FBits > 0) then - begin - isLeftShift := ShiftBitsLeft > 0; - Remaining := (FBits + 7) div 8; - Carry := 0; - if isLeftShift then - ShiftAmnt := ShiftBitsLeft - else - ShiftAmnt := ShiftBitsRight; - ShiftComp32 := 32 - ShiftAmnt; - ShiftComp8 := 8 - ShiftAmnt; - if isLeftShift then - begin - P8 := ValuePntr( 0); - while Remaining > -1 do - begin - if (Remaining >= 4) and isAligned32( P8) then - begin - P32 := pointer( P8); - b32_1 := P32^ shr ShiftComp32; - b32_2 := Carry; - Carry := LongRec( b32_1).Bytes[0]; - b32_1 := P32^ shl ShiftAmnt; - P32^ := b32_1 or b32_2; - Inc( P8, 4); - Dec( Remaining, 4) - end - else - begin - if Remaining > 0 then - b8_1 := P8^ shr ShiftComp8 - else - b8_1 := 0; - b8_2 := Carry; - Carry := b8_1; - b8_1 := P8^ shl ShiftAmnt; - P8^ := b8_1 or b8_2; - Inc( P8); - Dec( Remaining) - end - end; - Inc( FBits, ShiftBitsLeft) - end - else - begin - P8 := ValuePntr( Remaining - 1); - while Remaining > 0 do - begin - {$if CompilerVersion >= 21.00} - if (Remaining >= 4) and isAligned32( P8 - 3) then - {$else} - if (Remaining >= 4) and isAligned32( pointer( TrueNativeInt( P8) - 3)) then - {$ifend} - begin - Dec( P8, 3); - P32 := pointer( P8); - b32_1 := P32^ shl ShiftComp32; - b32_2 := 0; - LongRec( b32_2).Bytes[3] := Carry; - Carry := LongRec( b32_1).Bytes[3]; - b32_1 := P32^ shr ShiftAmnt; - P32^ := b32_1 or b32_2; - Dec( P8); - Dec( Remaining, 4) - end - else - begin - b8_1 := P8^ shl ShiftComp8; - b8_2 := Carry; - Carry := b8_1; - b8_1 := P8^ shr ShiftAmnt; - P8^ := b8_1 or b8_2; - Dec( P8); - Dec( Remaining) - end - end; - Dec( FBits, ShiftBitsRight); - if FBits < 0 then - FBits := 0 - end; - end -end; - - - -procedure THugeCardinal.MulSmall( Factor: uint32); -var - Done: boolean; - PoweredFactor, Power, iFactor: integer; - j: Integer; - DataLen, Remaining: integer; - P32: ^uint32; - Carry, Factor1: uint32; - Product: uint64; - Idx: integer; - FactorBytes: integer; - LastBits: integer; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_MulSmallOverflow) - end; - -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_MulSmall); -{$ENDIF} -if isZero then exit; -Done := False; -if Factor = 0 then - begin - Zeroise; - Done := True - end - else if Factor = 1 then - Done := True - else - begin - iFactor := Factor; - PoweredFactor := 1; - for Power := 1 to 10 do - begin - PoweredFactor := PoweredFactor * 2; - if PoweredFactor > iFactor then break; - if PoweredFactor < iFactor then continue; - MulPower2( Power); - Done := True; - break - end - end; -if Done then exit; -if (BitLength + BitCount_32( Factor) - 1) > MaxBits then - Overflow; -DataLen := (BitLength + 7) div 8; -Remaining := DataLen; -P32 := FValue.Memory; -Idx := 0; -Carry := 0; -for j := 0 to (DataLen div 4) - 1 do - begin - Factor1 := P32^; - Product := Factor1; // Widen. - Product := Product * Factor + Carry; - Factor1 := int64rec( Product).Lo; - P32^ := Factor1; - Carry := int64rec( Product).Hi; - P32 := Offset( P32, 4); - Dec( Remaining, 4); - Inc( Idx, 4) - end; -Factor1 := 0; -if Remaining > 0 then - Move( P32^, Factor1, Remaining); -Product := Factor1; // widen. -Product := Product * Factor + Carry; -if Product <> 0 then - begin - LastBits := BitCount_64( Product); - FactorBytes := (LastBits + 7) div 8; - if (Idx + FactorBytes) > FValue.Size then - Overflow; - Move( Product, P32^, FactorBytes) - end; -FBits := -1 -end; - - - -function THugeCardinal.Multiply( Factor: THugeCardinal): THugeCardinal; -var - Addend: THugeCardinal; - Factor2: uint32; - j: integer; -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( func_Multiply); -{$ENDIF} -result := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); -if isZero then exit; -Addend := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); -try - Factor.FValue.Position := 0; - for j := 0 to ((Factor.BitLength + 31) div 32) - 1 do - begin - Factor2 := 0; - Factor.FValue.Read( Factor2, 4); - if Factor2 = 0 then continue; - Addend.Assign( self); - Addend.MulSmall( Factor2); - Addend.MulPower2( j * 32); - result.Add( Addend) - end -finally - Addend.Free - end -end; - - -procedure THugeCardinal.MultiplyMod( Factor, Modulus: THugeCardinal); -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_MultiplyMod); -{$ENDIF} -if doUseMultiplyMod_NewAlgorithm then - MultiplyMod_New( Factor, Modulus) - else - MultiplyMod_Old( Factor, Modulus) -end; - - -procedure THugeCardinal.MultiplyMod_Old( Factor, Modulus: THugeCardinal); -var - Product, Remainder: THugeCardinal; -begin -Product := Multiply( Factor); -try -Remainder := Product.Modulo( Modulus); -try -Assign( Remainder) -finally -Remainder.Free -end -finally -Product.Free -end end; - - -procedure THugeCardinal.MultiplyMod_New( Factor, Modulus: THugeCardinal); -var - Product{, Remainder}: THugeCardinal; - Addend: THugeCardinal; - Factor2: uint32; - j: integer; - LogicalByteCount, PhysicalByteCount, ShiftBytesLeft: integer; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_AddOverflow) - end; - - procedure MakeProductModulo; - var - Remainder: THugeCardinal; - begin - Remainder := Product.Modulo( Modulus); - try - Product.Assign( Remainder) - finally - Remainder.Free - end - end; - -begin -if isZero then exit; -Product := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); -try - Addend := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); - try - Factor.FValue.Position := 0; - for j := 0 to ((Factor.BitLength + 31) div 32) - 1 do - begin - Factor2 := 0; - Factor.FValue.Read( Factor2, 4); - if Factor2 = 0 then continue; - Addend.Assign( self); - Addend.MulSmall( Factor2); - if j > 0 then - with Addend do - begin - LogicalByteCount := (Addend.BitLength+ 7) div 8; - PhysicalByteCount := Addend.FValue.Size; - ShiftBytesLeft := j * 4; - if (ShiftBytesLeft + LogicalByteCount) > PhysicalByteCount then - Overflow; - Move( Addend.FValue.Memory^, Addend.ValuePntr( ShiftBytesLeft)^, LogicalByteCount); - Addend.ClearMem( 0, ShiftBytesLeft); - Inc( Addend.FBits, ShiftBytesLeft * 8) - end; - Product.Add( Addend); - // MakeProductModulo - end - finally - Addend.Free - end; - MakeProductModulo; - Assign( Product) -finally - Product.Free - end -end; - - - -function THugeCardinal.NewMemoryStream( InitBitSize: integer): TMemoryStream; -var - InitSize: integer; -begin -InitSize := InitBitSize div 8; -if assigned( FPool) then - result := FPool.NewMemoryStream( InitSize) - else - begin - result := TMemoryStream.Create; - if InitSize > 0 then - result.Size := InitSize - end -end; - - - -procedure THugeCardinal.Resize( NewMaxBit1: integer); -var - NewMaxBits: integer; - NewValue: TMemoryStream; - DataBytesLen: integer; -begin -NewMaxBits := ComputedNeededSize( NewMaxBit1); -if NewMaxBits = MaxBits then exit; -if BitLength > NewMaxBits then - raise Exception.Create( ES_HugeCardinal_ResizeOverflow); -NewValue := NewMemoryStream( NewMaxBits); -DataBytesLen := (BitLength + 7) div 8; -if DataBytesLen > 0 then - Move( FValue.Memory^, NewValue.Memory^, DataBytesLen); -ClearMemory( NewValue, DataBytesLen, NewValue.Size - DataBytesLen); -FValue.Free; -FValue := NewValue -end; - - -procedure THugeCardinal.SquareMod( Modulus: THugeCardinal); -var - C: uint64; - Remainder: THugeCardinal; -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_SquareMod); -{$ENDIF} -if isZero then exit; -if BitLength <= 32 then - begin - C := ExtractSmall; - AssignSmall( C * C); - Remainder := Modulo( Modulus); - try - Assign( Remainder) - finally - Remainder.Free - end end - else - MultiplyMod( self, Modulus) -end; - - - -procedure THugeCardinal.SmallExponent_Power( Exponent: uint32); -var - Odd1: boolean; - Base, Product: THugeCardinal; - RequiredBits: uint64; - - procedure Mult( Factor: THugeCardinal); - begin - Product := Multiply( Factor); - try - Assign( Product) - finally - FreeAndNil( Product) - end end; - -begin -// First, deal with special cases. -if isZero then - begin - Assert( Exponent <> 0, AS_ZeroToZero); - exit - end; -if Exponent = 0 then - begin - AssignSmall( 1); - exit - end; -RequiredBits := cardinal( BitLength) * Exponent; -if (RequiredBits < Exponent) or (RequiredBits > MaxBits) then - raise Exception.Create( ES_HugeCardinal_PowerOverflow); - -// Russian Peasant Algorithm. -Base := THugeCardinal.CreateZero( RequiredBits, FPool); -try -while Exponent >= 2 do - begin - Odd1 := Odd( Exponent); - if Odd1 then - Base.Assign( self); - Exponent := Exponent shr 1; - Mult( self); - if Odd1 then - Mult( Base) - end -finally -Base.Free -end end; - - -procedure THugeCardinal.SmallExponent_PowerMod( - Exponent: uint64; Modulus: THugeCardinal); -var - Base, Factor: THugeCardinal; -begin -// First, deal with special cases. -if isZero then exit; -if Exponent = 0 then - begin - AssignSmall( 1); - exit - end; -// Russian Peasant Algorithm. -Factor := nil; -try -if Compare( Modulus) <> rLessThan then - begin - Base := Modulo( Modulus); - try - Assign( Base) - finally - Base.Free - end - end; -Base := THugeCardinal.CreateZero( Modulus.BitLength, FPool); -try -while Exponent >= 2 do - begin - if Odd( int64Rec( Exponent).Lo) then - begin - if not assigned( Factor) then - Factor := CloneSized( Modulus.BitLength) - else - Factor.MultiplyMod( self, Modulus) - end; - Exponent := Exponent shr 1; - SquareMod( Modulus) - end -finally -Base.Free -end; -if assigned( Factor) then - MultiplyMod( Factor, Modulus) -finally -Factor.Free -end end; - - -function THugeCardinal.PowerMod( Exponent, Modulus: THugeCardinal; OnProgress: TProgress): boolean; -var - Base: THugeCardinal; - Expo: THugeCardinal; - Factor: THugeCardinal; - BitsProcessed, TotalBits: int64; - doAbort: boolean; -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( func_PowerMod); -{$ENDIF} -Factor := nil; -try -if not Exponent.isSmall then - begin - doAbort := False; - // Russian Peasant Algorithm. - if Compare( Modulus) <> rLessThan then - begin - Base := Modulo( Modulus); - try - Assign( Base) - finally - Base.Free; - end - end; - Base := THugeCardinal.CreateZero( Modulus.BitLength, FPool); - Expo := Exponent.CloneSized( Exponent.BitLength); - TotalBits := Exponent.BitLength; - try - while (not Expo.isSmall) and (not doAbort) do - begin - if Expo.isOdd then - begin - if not assigned( Factor) then - Factor := CloneSized( Modulus.BitLength) - else - Factor.MultiplyMod( self, Modulus) - end; - Expo.MulPower2( -1); - SquareMod( Modulus); - if assigned( OnProgress) then - begin - BitsProcessed := TotalBits - Expo.BitLength; - OnProgress( self, BitsProcessed, TotalBits, doAbort) - end - end; - if not doAbort then - SmallExponent_PowerMod( Expo.ExtractSmall, Modulus) - finally - Base.Free; - Expo.Free - end - end - else - SmallExponent_PowerMod( Exponent.ExtractSmall, Modulus); -result := not doAbort; -if result and assigned( Factor) then - MultiplyMod( Factor, Modulus) -finally -Factor.Free -end end; - - - -function THugeCardinal.PowerMod_WithChineseRemainderAlgorithm( - Exponent, // d - Modulus: THugeCardinal; // n := p * q - FactorP, // p - FactorQ, // q - ExponentModFactorP, // dp := d mod p-1 - ExponentModFactorQ, // dq := d mod q-1 - InverseQ : THugeCardinal; // qinv := q ** -1 mod p - OnProgress: TProgress - ): boolean; // result := self ** d mod n -var - x2, CRT_Result: THugeCardinal; -begin -if (not assigned( FactorP)) or (not assigned( FactorQ)) then - result := PowerMod( Exponent, Modulus, OnProgress) - else - begin - // With CRT, we can short-cut ... - // x := y ** d mod n - // as ... - // x1 := y ** dp mod p - // x2 := y ** dq mod q - // if x1 >= x2: - // h := qinv * (x1 - x2) mod p - // else: - // h := qinv * (x1 + p - x2) mod p - // x := x2 + h * q - x2 := Clone; - try - result := PowerMod( ExponentModFactorP, FactorP, OnProgress) and - x2.PowerMod( ExponentModFactorQ, FactorQ, OnProgress); - if result then - begin - if Compare( x2) = rLessThan then - Add( FactorP); - Subtract( x2); - MultiplyMod( InverseQ, FactorP); - CRT_Result := Multiply( FactorQ); - CRT_Result.Add( x2); - Assign( CRT_Result); - CRT_Result.Free - end; - finally - x2.Free - end - end -end; - - -procedure THugeCardinal.Subtract( Subtractend: THugeCardinal); -var - P1, P2: PByte; - Borrow: boolean; - Bytes, j, Idx: integer; - V1, V2, V3: uint64; - SubBytes, D2: integer; - - procedure Overflow; - begin - FBits := -1; - raise Exception.Create( ES_HugeCardinal_SubractOverflow) - end; - -begin -{$IFDEF profiling} -if doProfiling then EnterProfileSection( proc_Subtract); -{$ENDIF} -Bytes := (BitLength + 7) div 8; -SubBytes := (Subtractend.BitLength + 7) div 8; -if SubBytes > Bytes then - Overflow; -P1 := FValue.Memory; -P2 := Subtractend.FValue.Memory; -Borrow := False; -Idx := 0; -D2 := Subtractend.FValue.Size; -FBits := -1; -for j := 0 to (Bytes div 8) - 1 do - begin - V1 := Puint64( P1)^; - V2 := 0; - if D2 > 0 then - Move( P2^, V2, Min( D2, 8)); - if (V2 = 0) and (not Borrow) and (Idx >= SubBytes) then exit; - V3 := Subtract_uint64_WithBorrow( V1, V2, Borrow); - Puint64( P1)^ := V3; - Inc( P1, 8); - Inc( P2, 8); - Inc( Idx, 8); - Dec( D2, 8) - end; -if (Bytes mod 8) <> 0 then - begin - V1 := 0; - Move( P1^, V1, bytes mod 8); - V2 := 0; - if D2 > 0 then - Move( P2^, V2, Min( D2, 8)); - V3 := Subtract_uint64_WithBorrow( V1, V2, Borrow); - Move( V3, P1^, bytes mod 8) - end; -if Borrow then - Overflow -end; - - - - -procedure THugeCardinal.Swap( Peer: THugeCardinal); -var - TempMaxBits: integer; - TempBits: integer; - TempValue: TMemoryStream; -begin -TempMaxBits := FMaxBits; -TempBits := FBits; -TempValue := FValue; - -FMaxBits := Peer.FMaxBits; -FBits := Peer.FBits; -FValue := Peer.FValue; - -Peer.FMaxBits := TempMaxBits; -Peer.FBits := TempBits; -Peer.FValue := TempValue -end; - - - -function THugeCardinal.ValuePntr( ByteIndex: integer): PByte; -begin -result := MemStrmOffset( FValue, ByteIndex) -end; - - -procedure THugeCardinal.Zeroise; -begin -CheckBits; -if isZero then exit; -ClearMem( 0, (FBits + 7) div 8); -FBits := 0 -end; - - - - - -procedure THugeCardinal.StreamOut( - ByteOrder: TByteOrder; Stream: TStream; SizeToOutput: integer = -1); -// ^ Streams the low order SizeToOutput bytes out to the stream. -// If SizeToOutput is -1, then this is interpreted as (MaxBits + 7) div 8 -var - P8: PByte; - PayloadByte, ZeroByte: byte; - j: integer; - ZeroFillCount: integer; - MaxBytes: cardinal; - MSB_Index: cardinal; -begin -// MaxBytes = (MaxBits = 7) div 8 = N; -// Case 1: Little-endien; MaxBytes > SizeToOutput -// FValue = X[0](=LSB) X[1] ... X[N-1](=MSB) -// Stream := X[0] .. X[SizeToOutput-1] -// If any discarded data (X[SizeToOutput]..X[N-1]) is non-zero, this is an error. - -// Case 2: Little-endien; MaxBytes < SizeToOutput -// FValue = X[0](=LSB) X[1] ... X[N](=MSB) -// Stream := X[0] .. X[N-1] 0 0 0 0 (0 is repeated SizeToOutput - MaxBytes times). - -// Case 3: Big-endien; MaxBytes > SizeToOutput -// FValue = X[0](=LSB) X[1] ... X[N-1](=MSB) -// Stream := X[SizeToOutput-1] .. X[1] X[0] -// If any discarded data (X[SizeToOutput]..X[N-1]) is non-zero, this is an error. - -// Case 4: Big-endien; MaxBytes < SizeToOutput -// FValue = X[0](=LSB) X[1] ... X[N](=MSB) -// Stream := 0 0 0 0 X[N-1] .. X[0] (At the start, 0 is repeated SizeToOutput - MaxBytes times). - -MaxBytes := FValue.Size; -if SizeToOutput < 0 then - SizeToOutput := MaxBytes; // = (MaxBits + 7) div 8 -if SizeToOutput = 0 then exit; -ZeroFillCount := SizeToOutput - integer( MaxBytes); -if SizeToOutput < ((BitLength + 7) div 8) then - raise Exception.Create( ES_HugeCardinal_StreamOutOverflow); -ZeroByte := 0; -MSB_Index := Min( SizeToOutput, MaxBytes); -case ByteOrder of - LittleEndien: - begin - Stream.Write( FValue.Memory^, MSB_Index); - for j := 0 to ZeroFillCount - 1 do - Stream.Write( ZeroByte, 1) - end; - BigEndien: - begin - for j := 0 to ZeroFillCount - 1 do - Stream.Write( ZeroByte, 1); - P8 := ValuePntr( MSB_Index - 1); - for j := MSB_Index - 1 downto 0 do - begin - PayloadByte := P8^; - Stream.Write( PayloadByte, 1); - Dec( P8) - end - end - end -end; - - -procedure THugeCardinal.AssignFromStreamIn( - ByteOrder: TByteOrder; Stream: TStream); -var - P8: PByte; - PayloadByte: byte; - j: integer; - SourceLen, MaxBytes, MSB_Index, ZeroFillCount: integer; - - procedure CheckDiscardedData; - var - Ok: boolean; - jj: integer; - begin - if ZeroFillCount >= 0 then exit; - // if dont check then do the following instead. - // if ZeroFillCount < 0 then - // Stream.Seek( -ZeroFillCount, soCurrent); - Ok := True; - for jj := 0 to (-ZeroFillCount) - 1 do - begin - Stream.Read( PayloadByte, 1); - Ok := PayloadByte = 0; - if Ok then continue; - Stream.Seek( (-ZeroFillCount) - jj - 1, soCurrent); - break - end; - if not Ok then - raise Exception.Create( ES_HugeCardinal_StreamInOverflow) - end; - -begin -// MaxBytes = Stream.Size = N; -// SizeToInput = Stream.Size - Stream.Position; -// Case 1: Little-endien; MaxBytes > SizeToInput -// Stream = X[0] .. X[SizeToInput-1] -// FValue := X[0](=LSB) X[1] ... X[SizeToInput-1](=MSB) 0 0 0 0 (0 is repeated MaxBytes - SizeToInput times). - -// Case 2: Little-endien; MaxBytes < SizeToInput -// Stream = X[0] .. X[N-1] X[N] X[SizeToInput-1] -// ^-------------------^ All this discarded. -// FValue := X[0] .. X[N-1] -// If any discarded data (X[N]..X[SizeToInput-1]) is non-zero, this is an error. - -// Case 3: Big-endien; MaxBytes > SizeToInput -// Stream = X[SizeToInput-1] .. X[1] X[0] -// FValue := X[0](=LSB) X[1] ... X[SizeToInput-1] 0 0 0 0 (0 is repeated MaxBytes - SizeToInput times). - -// Case 4: Big-endien; MaxBytes < SizeToInput -// Stream = X[SizeToInput-1] .. X[N] X[N-1] .. X[0] -// ^---------------------^ All this discarded. -// FValue := X[0](=LSB) X[1] ... X[N-1](=MSB) -// If any discarded data (X[SizeToInput-1]..X[N]) is non-zero, this is an error. -SourceLen := Stream.Size - Stream.Position; -MaxBytes := FValue.Size; -MSB_Index := Min( SourceLen, MaxBytes); -ZeroFillCount := MaxBytes - SourceLen; -Case ByteOrder of - LittleEndien: - begin - if MSB_Index > 0 then - Stream.Read( FValue.Memory^, MSB_Index); - if ZeroFillCount > 0 then - ClearMemory( FValue, MSB_Index, ZeroFillCount); // case 1 zeros - CheckDiscardedData // case 2 discard - end; - BigEndien: - begin - CheckDiscardedData; // case 4 discard - P8 := ValuePntr( MSB_Index - 1); - for j := MSB_Index - 1 downto 0 do - begin - Stream.Read( PayloadByte, 1); - P8^ := PayloadByte; - Dec( P8) - end; - if ZeroFillCount > 0 then - ClearMemory( FValue, MSB_Index, ZeroFillCount) // case 3 zeros - end - end; -FBits := -1 -end; - - - -function THugeCardinal.CapacityInBits: integer; -begin -result := FValue.Size * 8 -end; - - -initialization -InitExecutionTimes; - -finalization -DoneExecutionTimes; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.HugeCardinal; +{$R-} +{.$define profiling} +interface +uses Classes, TPLB3.IntegerUtils, TPLB3.MemoryStreamPool +{$IFDEF profiling} + , Generics.Collections +{$ENDIF} + ; + +type + {$define SI} +TCompareResult = (rGreaterThan, rEqualTo, rLessThan); +TByteOrder = (LittleEndien, BigEndien); +TProgress = procedure ( Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean) of object; + +{$if CompilerVersion >= 21.00} +THugeCardinal = class sealed +{$else} +THugeCardinal = class +{$ifend} + + // An instance of this class represents a very large non-negative integer. + private + FMaxBits: integer; // Maximum number of bits of storage. + // For efficiency reasons, we will not allow + // re-allocation/resizing. + FBits: integer; // Cached value of the bit length of the value; +{$IFNDEF SI} + FValue: TMemoryStream; // Little-endien. +{$ENDIF} + + procedure CheckBits; + class function ComputedNeededSize( RequestedBits: integer): integer; + procedure ClearMem( Offset, Length: integer); + procedure DividePrimitive( + Divisor: THugeCardinal; + var Quotient, Remainder: THugeCardinal; + RequiresQuotient: boolean); + function GetAsHexString: string; + + procedure MulPower2_OldAlgorithm( ShiftAmnt: integer); + procedure MulPower2_NewAlgorithm( ShiftAmnt: integer); + procedure MultiplyMod_Old( Factor, Modulus: THugeCardinal); + procedure MultiplyMod_New( Factor, Modulus: THugeCardinal); + + + protected + function NewMemoryStream( InitBitSize: integer): TMemoryStream; + function ValuePntr( ByteIndex: integer): PByte; + + public +{$IFDEF SI} + FValue: TMemoryStream; // Little-endien. +{$ENDIF} + + FPool: IMemoryStreamPool; + + // Life-cycle methods. + constructor CreateSimple( Value: uint64); + constructor CreateZero( MaxBits1: integer; const Pool1: IMemoryStreamPool); + constructor CreateRandom( Bits1, MaxBits1: integer; ExactBitLength: boolean; const Pool1: IMemoryStreamPool); + // CreateRandom creates a random number up to Bits1 bits long. + // If ExactBitLength is True, then the resultant bit length will be + // exactly Bits1 long. Otherwise it may range anywhere down to zero. + + constructor CreateSmall( Value: uint64; MaxBits1: integer; const Pool1: IMemoryStreamPool); + constructor CreateAsClone( Master: THugeCardinal; const Pool1: IMemoryStreamPool); + constructor CreateAsSizedClone( MaxBits1: integer; Master: THugeCardinal; const Pool1: IMemoryStreamPool); + constructor CreateFromStreamIn( + MaxBits1: integer; ByteOrder: + TByteOrder; Stream: TStream; const Pool1: IMemoryStreamPool); + destructor Destroy; override; + function Clone: THugeCardinal; + function CloneSized( MaxBits1: integer): THugeCardinal; + procedure Resize( NewMaxBit1: integer); + procedure Burn; + + // Size properties. + function BitLength: integer; + function MaxBits: integer; + function CapacityInBits: integer; + + // Assignment. + procedure Assign( Source: THugeCardinal); + procedure AssignFromStreamIn( ByteOrder: TByteOrder; Stream: TStream); + procedure AssignSmall( Value: uint64); + procedure Swap( Peer: THugeCardinal); + + // Random numbers. + procedure Random( UpperBound: THugeCardinal); + // ^ Results in a random number x, such that: + // 0 <= x < UpperBound. + // Requires (UpperBound >= 1) and (UpperBound.BitLength <= MaxBits) + procedure RandomBits( BitsOfRandom: integer; ExactBitLength: boolean); + // ^ if ExactBitLength = False, results in .... + // 0 <= x < (2 ** BitsOfRandom) . + // In other words ..... + // x.BitLength <= BitsOfRandom + // If ExactBitLength = True, results in .... + // (2 ** BitsOfRandom-1) <= x < (2 ** BitsOfRandom) . + // In other words ..... + // x.BitLength = BitsOfRandom + // Assumes BitsOfRandom >= 1. + + // Comparison + function Compare( Reference: THugeCardinal): TCompareResult; + function CompareSmall( Reference: uint64): TCompareResult; + function isZero: boolean; + function isOdd: boolean; + + // Small ops. + procedure Zeroise; + function isSmall: boolean; + function ExtractSmall: uint64; + function ModSmall( Modulus: uint64): uint64; + + // Addition. + procedure Add( Addend: THugeCardinal); + procedure Increment( Addend: int64); + procedure Subtract( Subtractend: THugeCardinal); + procedure AddMod( Addend, Modulus: THugeCardinal); + + // Multiplication. + procedure MulSmall( Factor: uint32); + function Multiply( Factor: THugeCardinal): THugeCardinal; + procedure MultiplyMod( Factor, Modulus: THugeCardinal); + procedure SquareMod( Modulus: THugeCardinal); + procedure MulPower2( ShiftAmnt: integer); + + // Division + function Modulo( Modulus: THugeCardinal): THugeCardinal; + procedure Divide( Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal); + + // Exponentiation. + function PowerMod( Exponent, Modulus: THugeCardinal; OnProgress: TProgress): boolean; + // ^ Return True if not aborted. + + function PowerMod_WithChineseRemainderAlgorithm( + Exponent, // d + Modulus: THugeCardinal; // n := p * q + FactorP, // p + FactorQ, // q + ExponentModFactorP, // dp := d mod p-1 + ExponentModFactorQ, // dq := d mod q-1 + InverseQ : THugeCardinal; // qinv := q ** -1 mod p + // result := self ** d mod n + OnProgress: TProgress): boolean; + // ^ Return True if not aborted. + + procedure SmallExponent_PowerMod( Exponent: uint64; Modulus: THugeCardinal); + procedure SmallExponent_Power( Exponent: uint32); // Only used for unit-test purposes. + + // Streaming. + procedure StreamOut( ByteOrder: TByteOrder; Stream: TStream; + SizeToOutput: integer = -1); + // ^ Streams the low order SizeToOutput bytes out to the stream. + // If SizeToOutput is -1, then this is interpreted as (MaxBits + 7) div 8 + property AsHexString: string read GetAsHexString; + end; + +procedure SafeAssign( Destin, Source: THugeCardinal); // Both parameters must pre-exist. +procedure SafeAdd( Sum, Addend1, Addend2: THugeCardinal); // All 3 parameters must pre-exist. + +type + TProfileSection = ( + proc_Add, proc_Increment, proc_Subtract, proc_AddMod, + proc_MulSmall, func_Multiply, proc_MultiplyMod, proc_SquareMod, + proc_MulPower2, func_Modulo, proc_Divide, func_PowerMod, + proc_SmallExponent_PowerMod); + TProfileSectionSet = set of TProfileSection; + + TProfileSectionResult = record + Section: TProfileSection; + Sum, Start: Int64; + end; + +var + ActiveProfileSections: TProfileSectionSet = +[proc_MultiplyMod, proc_SquareMod, proc_MulPower2, func_Modulo]; + +{$IFDEF profiling} +var + SectionStack: TStack = nil; +{$ENDIF} + +var + HugeCardinal_InstanceCount: integer = 0; + doUseMulPower2_NewAlgorithm: boolean = True; + doUseMultiplyMod_NewAlgorithm: boolean = True; + doProfiling: boolean = False; + + ExecutionTimes: array[ TProfileSection] of Int64; + ExecutionPercentages: array[ TProfileSection] of cardinal; + +procedure InitExecutionTimes; +procedure DoneExecutionTimes; +procedure CalcExecutionPercentages; + +implementation + + + + + + + + + + + + + + + + + + +uses SysUtils, TPLB3.StreamUtils, Math, TPLB3.Random, TPLB3.I18n, + TPLB3.PointerArithmetic, TPLB3.Compatibility; + + +{$IFDEF profiling} +type +TProfileSectionHold = class( TInterfacedObject) + private + doFrame: boolean; + public + constructor Create( Entry: TProfileSection); + destructor Destroy; override; + end; +{$ENDIF} + +function EnterProfileSection( Entry: TProfileSection): IInterface; +begin +{$IFDEF profiling} +if Entry in ActiveProfileSections then + result := TProfileSectionHold.Create( Entry) + else +{$ENDIF} +{$IFNDEF profiling} +result := nil +{$ENDIF} +end; + +procedure InitExecutionTimes; +var + j: TProfileSection; +begin +for j := Low( TProfileSection) to High( TProfileSection) do + ExecutionTimes[j] := 0; +{$IFDEF profiling} +SectionStack.Free; +SectionStack := TStack.Create +{$ENDIF} +end; + +procedure DoneExecutionTimes; +begin +{$IFDEF profiling} +SectionStack.Free; +SectionStack := nil +{$ENDIF} +end; + + +{$IFDEF profiling} +constructor TProfileSectionHold.Create( Entry: TProfileSection); +var + Now1: Int64; + ProfSectRes: TProfileSectionResult; + isEmpty: boolean; +begin + isEmpty := SectionStack.Count = 0; + doFrame := isEmpty or (SectionStack.Peek.Section <> Entry); + if not doFrame then exit; + if not isEmpty then + ProfSectRes := SectionStack.Pop; + QueryPerformanceCounter( Now1); + if (not isEmpty) and (ProfSectRes.Start > 0) then + begin + ProfSectRes.Sum := ProfSectRes.Sum + (Now1 - ProfSectRes.Start); + ProfSectRes.Start := 0; + SectionStack.Push( ProfSectRes) + end; + ProfSectRes.Section := Entry; + ProfSectRes.Sum := 0; + ProfSectRes.Start := Now1; + SectionStack.Push( ProfSectRes) +end; + +destructor TProfileSectionHold.Destroy; +var + Now1: Int64; + ProfSectRes: TProfileSectionResult; + isEmpty: boolean; +begin +if doFrame then + begin + QueryPerformanceCounter( Now1); + ProfSectRes := SectionStack.Pop; + if ProfSectRes.Start > 0 then + ProfSectRes.Sum := ProfSectRes.Sum + (Now1 - ProfSectRes.Start); + ExecutionTimes[ProfSectRes.Section] := ExecutionTimes[ProfSectRes.Section] + ProfSectRes.Sum; + if SectionStack.Count > 0 then + begin + ProfSectRes := SectionStack.Pop; + ProfSectRes.Start := Now1; + SectionStack.Push( ProfSectRes) + end + end; +inherited +end; +{$ENDIF} + + +procedure CalcExecutionPercentages; +var + j: TProfileSection; + Sum: Int64; +begin +Sum := 0; +for j := Low( TProfileSection) to High( TProfileSection) do + if j in ActiveProfileSections then + Sum := Sum + ExecutionTimes[j]; +for j := Low( TProfileSection) to High( TProfileSection) do + if (Sum = 0) or (ExecutionTimes[j] = 0) or (not (j in ActiveProfileSections)) then + ExecutionPercentages[j] := 0 + else + ExecutionPercentages[j] := Round( (ExecutionTimes[j] / Sum) * 100.0) +end; + + procedure SafeAssign( Destin, Source: THugeCardinal); + begin + Destin.Zeroise; + if Source.BitLength > Destin.MaxBits then + Destin.Resize( Source.BitLength); + Destin.Assign( Source) + end; + + procedure SafeAdd( Sum, Addend1, Addend2: THugeCardinal); + var + Tmp: THugeCardinal; + begin + Tmp := THugeCardinal.CreateAsSizedClone( Max( Addend1.BitLength, Addend2.BitLength) + 1, Addend1, Addend1.FPool); + Tmp.Add( Addend2); + SafeAssign( Sum, Tmp); + Tmp.Free + end; + + +{ THugeCardinal } + + +procedure SetBit( Number: THugeCardinal; BitIndex: integer); +var + P: PByte; +begin +P := MemStrmOffset( Number.FValue, BitIndex div 8); +P^ := P^ or (1 shl (BitIndex mod 8)) +end; + + +procedure ClearBit( Number: THugeCardinal; BitIndex: integer); +var + P: PByte; +begin +P := MemStrmOffset( Number.FValue, BitIndex div 8); +P^ := P^ and (not (1 shl (BitIndex mod 8))) +end; + +function TestBit( Number: THugeCardinal; BitIndex: integer): boolean; +var + P: PByte; +begin +P := MemStrmOffset( Number.FValue, BitIndex div 8); +result := (P^ and (1 shl (BitIndex mod 8))) <> 0 +end; + + +class function THugeCardinal.ComputedNeededSize( + RequestedBits: integer): integer; +begin +result := Max( RequestedBits, 64); +if (result mod 8) <> 0 then + result := result + 8 - (result mod 8) +end; + + + +constructor THugeCardinal.CreateAsClone( Master: THugeCardinal; const Pool1: IMemoryStreamPool); +begin +FPool := Pool1; +FMaxBits := Master.MaxBits; +FBits := Master.FBits; +FValue := NewMemoryStream( Master.FValue.Size * 8); +Move( Master.FValue.Memory^, FValue.Memory^, FValue.Size); +AtomicIncrement( HugeCardinal_InstanceCount) +end; + + +constructor THugeCardinal.CreateAsSizedClone( MaxBits1: integer; Master: THugeCardinal; const Pool1: IMemoryStreamPool); +var + DataByteLen: integer; +begin +FPool := Pool1; +FMaxBits := ComputedNeededSize( MaxBits1); +if Master.BitLength > FMaxBits then + raise Exception.Create( ES_HugeCardinal_CloneOverflow); +DataByteLen := (Master.BitLength + 7) div 8; +FValue := NewMemoryStream( FMaxBits); +if DataByteLen > 0 then + Move( Master.FValue.Memory^, FValue.Memory^, DataByteLen); +ClearMem( DataByteLen, FValue.Size - DataByteLen); +FBits := Master.BitLength; +AtomicIncrement( HugeCardinal_InstanceCount) +end; + + +constructor THugeCardinal.CreateFromStreamIn( + MaxBits1: integer; ByteOrder: TByteOrder; Stream: TStream; const Pool1: IMemoryStreamPool); +begin +FPool := Pool1; +FMaxBits := ComputedNeededSize( MaxBits1); +FValue := NewMemoryStream( FMaxBits); +AssignFromStreamIn( ByteOrder, Stream); +AtomicIncrement( HugeCardinal_InstanceCount) +end; + + + +constructor THugeCardinal.CreateRandom( + Bits1, MaxBits1: integer; ExactBitLength: boolean; + const Pool1: IMemoryStreamPool); +begin +CreateZero( MaxBits1, Pool1); +if Bits1 > FMaxBits then + Bits1 := FMaxBits; +RandomBits( Bits1, ExactBitLength) +end; + + +procedure THugeCardinal.Random( UpperBound: THugeCardinal); +begin +if not UpperBound.isZero then + repeat + RandomBits( UpperBound.BitLength, False) + until Compare( UpperBound) = rLessThan +end; + + + +procedure THugeCardinal.RandomBits( BitsOfRandom: integer; + ExactBitLength: boolean); +var + R: TStream; + Bits, j: integer; + Bytes, OldBytes: integer; + HighByte, Mask: byte; +begin +if BitsOfRandom <= 0 then exit; +R := TRandomStream.Instance; +CheckBits; +Bits := BitsOfRandom; +Bytes := ((Bits + 7) div 8) - 1; +OldBytes := ((FBits + 7) div 8); +FBits := -1; +if Bytes > 0 then + begin + // Determine all the bytes, except the most significant byte. + R.Read( FValue.Memory^, Bytes); + Dec( Bits, Bytes * 8) + end; +if Bits > 0 then + begin + // Determine the most significant byte. + R.Read( HighByte, 1); + Mask := 1; + for j := 2 to Bits do + Mask := (Mask shl 1) + 1; + HighByte := HighByte and Mask; + FValue.Position := Bytes; + FValue.Write( HighByte, 1); + Inc( Bytes); + if ((HighByte shr (Bits - 1)) and $01) = $01 then + FBits := BitsOfRandom + end; +if OldBytes > Bytes then + BurnMemory( ValuePntr( Bytes)^, OldBytes - Bytes); +if ExactBitLength then + begin + SetBit( self, BitsOfRandom-1); + FBits := BitsOfRandom + end +end; + + +constructor THugeCardinal.CreateSimple( Value: uint64); +begin +CreateSmall( Value, 0, nil) +end; + + + +constructor THugeCardinal.CreateSmall( Value: uint64; MaxBits1: integer; const Pool1: IMemoryStreamPool); +begin +CreateZero( MaxBits1, Pool1); +if Value > 0 then + begin + FValue.Write( Value, SizeOf( Value)); + FBits := BitCount_64( Value) + end +end; + + +constructor THugeCardinal.CreateZero( MaxBits1: integer; const Pool1: IMemoryStreamPool); +begin +FPool := Pool1; +FMaxBits := ComputedNeededSize( MaxBits1); +FBits := 0; +FValue := NewMemoryStream( FMaxBits); +ZeroFillStream( FValue); +AtomicIncrement( HugeCardinal_InstanceCount) +end; + + +destructor THugeCardinal.Destroy; +begin +AtomicDecrement( HugeCardinal_InstanceCount); +FValue.Free; +inherited +end; + + +function THugeCardinal.ExtractSmall: uint64; +begin +Move( FValue.Memory^, result, 8) +end; + +function THugeCardinal.GetAsHexString: string; +var + // Temp: THugeCardinal; + ValueByte: byte; + Idx: integer; + P1: PByte; + StrIdx: integer; + {$IFDEF STRINGHELPER}Output: TStringBuilder;{$ENDIF} + + function CharOfNibble( Nibble: byte): Char; + begin + if Nibble <= 9 then + result := Chr( Ord('0') + Nibble) + else + result := Chr( Ord('A') + Nibble - 10) + end; + +begin +// Temp := Clone; +Idx := (BitLength + 7) div 8; +{$IFDEF STRINGHELPER} +Output := TStringBuilder.Create; +Output.Length := Idx * 2; +{$ELSE} +SetLength( result, Idx * 2); +{$ENDIF} +P1 := ValuePntr( Idx); +StrIdx := -1; +while Idx > 0 do + begin + Dec( P1, 1); + Dec( Idx); + Inc( StrIdx, 2); + ValueByte := P1^; + {$IFDEF STRINGHELPER} + Output.Chars[StrIdx-1] := CharOfNibble( ValueByte shr 4); + Output.Chars[StrIdx ] := CharOfNibble( ValueByte and $0F) + {$ELSE} + result[StrIdx ] := CharOfNibble( ValueByte shr 4); + result[StrIdx+1] := CharOfNibble( ValueByte and $0F) + {$ENDIF} + end; +{$IFDEF STRINGHELPER} +if (Output.Length > 0) and (Output.Chars[0] = '0') and (not isZero) then + Output.Remove( 0, 1); +result := Output.ToString; +Output.Free; +{$ELSE} +if (Length( result) > 0) and (result[1] = '0') and (not isZero) then + Delete( result, 1, 1); +{$ENDIF} +if Length( result) = 0 then + result := '0'; +end; + +type Puint64 = ^uint64; + +procedure THugeCardinal.Add( Addend: THugeCardinal); +var + P1, P2: PByte; + I1, D1, D2: integer; + Carry: boolean; + Sum: uint16; + v: uint64; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_AddOverflow) + end; + +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_Add); +{$ENDIF} +if Addend.isZero then exit; +if isZero then + begin + Assign( Addend); + exit + end; +if Addend.isSmall then + begin + v := Addend.ExtractSmall; + if v <= $7FFFFFFFFFFFFFFF then + begin + Increment( v); + exit + end + end; +if Addend.BitLength > MaxBits then + Overflow; +P1 := FValue.Memory; // Cursor into the accumulator. +I1 := FValue.Size; // Complement of offset into P1. +D1 := (BitLength + 7) div 8; // Number of original data bytes in the accumulator. + +P2 := Addend.FValue.Memory; +D2 := (Addend.BitLength + 7) div 8; + +Carry := False; +while (D1 > 0) or (D2 > 0) or Carry do + begin + if (D1 >= 8) and (D2 >= 8) then + begin + Puint64( P1)^ := Add_uint64_WithCarry( Puint64( P1)^, Puint64( P2)^, Carry); + Inc( P1, 8); + Inc( P2, 8); + Dec( D1, 8); + Dec( D2, 8); + Dec( I1, 8) + end + + else + begin + if D1 > 0 then + Sum := P1^ + else + Sum := 0; + + if D2 > 0 then + Inc( Sum, P2^); + + if Carry then + Inc( Sum); + + if I1 > 0 then + begin + P1^ := WordRec( Sum).Lo; + Carry := WordRec( Sum).Hi <> 0 + end + else if Sum = 0 then + Carry := False + else + Overflow; + Inc( P1, 1); + Inc( P2, 1); + Dec( I1, 1); + Dec( D1, 1); + Dec( D2, 1) + end + end; +FBits := -1 +end; + + + +procedure THugeCardinal.AddMod( Addend, Modulus: THugeCardinal); +var + RequiredBits: integer; + Sum, Remainder: THugeCardinal; +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_AddMod); +{$ENDIF} +RequiredBits := Max( BitLength, Addend.BitLength) + 1; +if RequiredBits < MaxBits then + Sum := self + else + Sum := CloneSized( RequiredBits); +try + Sum.Add( Addend); + Remainder := Sum.Modulo( Modulus); + try + Assign( Remainder) + finally + Remainder.Free + end +finally +if Sum <> self then + Sum.Free +end end; + + + +procedure THugeCardinal.Assign( Source: THugeCardinal); +var + SourceBytes: integer; +begin +SourceBytes := (Source.BitLength + 7) div 8; +if SourceBytes > FValue.Size then + raise Exception.Create( ES_CannotAssignHuge_BecauseSourceTooBig); +if SourceBytes > 0 then + Move( Source.FValue.Memory^, FValue.Memory^, SourceBytes); +ClearMem( SourceBytes, FValue.Size - SourceBytes); +FBits := Source.BitLength +end; + + + +procedure THugeCardinal.AssignSmall( Value: uint64); +begin +if BitLength > 64 then + Zeroise; +Move( Value, FValue.Memory^, SizeOf( Value)); +FBits := -1 +end; + + +function THugeCardinal.BitLength: integer; +begin +CheckBits; +result := FBits +end; + + +procedure THugeCardinal.Burn; +begin +BurnMemoryStream( FValue); +FBits := 0 +end; + + +procedure THugeCardinal.CheckBits; +var + P32: ^uint32; + P8: PByte; + LastBits: integer; +begin +if FBits <> -1 then exit; +FBits := FValue.Size * 8; +if FBits = 0 then exit; +P8 := ValuePntr( FBits div 8); +LastBits := 0; +while (FBits > 0) and (LastBits = 0) do + begin + if (FBits >= 32) and isAligned32( P8) then + begin + Dec( P8, 4); + P32 := pointer( P8); + LastBits := BitCount_32( P32^); + Dec( FBits, 32 - LastBits) + end + else + begin + Dec( P8, 1); + LastBits := BitCount_8( P8^); + Dec( FBits, 8 - LastBits) + end + end +end; + + + +procedure THugeCardinal.ClearMem( Offset, Length: integer); +begin +ClearMemory( FValue, Offset, Length) +end; + + +function THugeCardinal.Clone: THugeCardinal; +begin +result := THugeCardinal.CreateAsClone( self, FPool) +end; + + + +function THugeCardinal.CloneSized( MaxBits1: integer): THugeCardinal; +begin +result := THugeCardinal.CreateAsSizedClone( MaxBits1, self, FPool) +end; + + +function THugeCardinal.Compare( Reference: THugeCardinal): TCompareResult; +var + Diff: integer; + P1, P2: PByte; + Idx: integer; +begin +Diff := BitLength - Reference.BitLength; +if Diff <> 0 then + begin + if Diff > 0 then + result := rGreaterThan + else + result := rLessThan + end + + else + begin + result := rEqualTo; + if BitLength <> 0 then + begin + Idx := (BitLength + 7) div 8; + P1 := ValuePntr( Idx); + P2 := Reference.ValuePntr( Idx); + while (Idx > 0) and (result = rEqualTo) do + begin + Dec( P1, 1); + Dec( P2, 1); + Dec( Idx); + Diff := P1^; + Diff := Diff - P2^; + if Diff > 0 then + result := rGreaterThan + else if Diff < 0 then + result := rLessThan + end + end + end +end; + + + +function THugeCardinal.CompareSmall( Reference: uint64): TCompareResult; +var + V: uint64; +begin +if isSmall then + begin + V := ExtractSmall; + if V > Reference then + result := rGreaterThan + else if V < Reference then + result := rLessThan + else + result := rEqualTo + end + else + result := rGreaterThan +end; + + + +procedure THugeCardinal.Increment( Addend: int64); +var + P1: PByte; + I1, Stop_I1: integer; + Carry, Borrow: boolean; + Sum: uint16; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_IncrementOverflow) + end; + +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_Increment); +{$ENDIF} +if Addend = 0 then exit; + +if MaxBits < 8 then + Overflow; + +P1 := FValue.Memory; +I1 := (BitLength + 7) div 8; +Stop_I1 := I1 - FValue.Size; // -ve of spare capacity. + + +if Addend > 0 then + begin + Carry := False; + Puint64( P1)^ := Add_uint64_WithCarry( Puint64( P1)^, Addend, Carry); + Inc( P1, 8); + Dec( I1, 8); + while (I1 > 0) or Carry do + begin + if I1 <= Stop_I1 then + Overflow; + + if I1 > 0 then + Sum := P1^ + else + Sum := 0; + + if Carry then + Inc( Sum); + + P1^ := WordRec( Sum).Lo; + Carry := WordRec( Sum).Hi <> 0; + Inc( P1, 1); + Dec( I1, 1); + end + end + else + begin // -ve case + Borrow := False; + Puint64( P1)^ := Subtract_uint64_WithBorrow( Puint64( P1)^, -Addend, Borrow); + Inc( P1, 8); + Dec( I1, 8); + while (I1 > 0) or Borrow do + begin + if I1 <= Stop_I1 then + Overflow; + + if I1 > 0 then + Sum := P1^ + else + Sum := 0; + + if Borrow then + begin + if Sum = 0 then + Sum := 255 + else + begin + Dec( Sum); + Borrow := False + end + end; + P1^ := WordRec( Sum).Lo; + Inc( P1, 1); + Dec( I1, 1); + end + end; +FBits := -1 +end; + + +function THugeCardinal.isOdd: boolean; +var + LowByte: byte; +begin +CheckBits; +result := FBits > 0; +if not result then exit; +FValue.Position := 0; +FValue.Read( LowByte, 1); +result := Odd( LowByte) +end; + + + +function THugeCardinal.isSmall: boolean; +begin +result := BitLength <= 64 +end; + + +function THugeCardinal.isZero: boolean; +begin +CheckBits; +result := FBits = 0 +end; + + +function THugeCardinal.MaxBits: integer; +begin +result := FMaxBits +end; + + + + +function THugeCardinal.ModSmall( Modulus: uint64): uint64; +var + Mask, Low64: uint64; + Quot, Mod1: THugeCardinal; +begin +if Modulus <= 1 then + result := 0 + else if Modulus = 2 then + result := Ord( isOdd) + else + begin + Low64 := ExtractSmall; + if CountSetBits_64( Modulus) = 1 then + // Modulus = 4, 8, 16 etc. + begin + Mask := Modulus - 1; // Mask = $03, $07, $0F etc. + result := Low64 and Mask + end + else if isSmall and (int64rec( Modulus).Hi = 0) and + (int64rec( Low64 ).Hi = 0) then + // Pure 32 bit operation. + result := int64rec( Low64).Lo mod int64rec( Modulus).Lo + // 64-bit mod might be possible, but I dont trust the compiler to + // get it right. + else + begin + Mod1 := nil; + Quot := nil; + try + Mod1 := THugeCardinal.CreateSmall( Modulus, 0, FPool); + Quot := Modulo( Mod1); + result := Quot.ExtractSmall + finally + Mod1.Free; + Quot.Free + end + end + end +end; + + +function THugeCardinal.Modulo( Modulus: THugeCardinal): THugeCardinal; +var + Dummy: THugeCardinal; +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( func_Modulo); +{$ENDIF} +Dummy := nil; +DividePrimitive( Modulus, Dummy, result, False); +Dummy.Free +end; + + + +procedure THugeCardinal.Divide( + Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal); +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_Divide); +{$ENDIF} +DividePrimitive( Divisor, Quotient, Remainder, True) +end; + + +procedure THugeCardinal.DividePrimitive( + Divisor: THugeCardinal; var Quotient, Remainder: THugeCardinal; + RequiresQuotient: boolean); +var + ShiftedMod: THugeCardinal; + ShiftAmnt: integer; + RemainderBits, ModulusBits, DiffBits: integer; + Compare: TCompareResult; + LeftShift: integer; + QuotientByte: PByte; + Mask: byte; + +begin +QuotientByte := nil; +Remainder := CloneSized( BitLength); +if RequiresQuotient then + Quotient := THugeCardinal.CreateZero( Max( BitLength, Divisor.BitLength), FPool); +if BitLength > Divisor.BitLength then + ShiftedMod := Divisor.CloneSized( BitLength) + else + ShiftedMod := Divisor.Clone; +try +ShiftAmnt := 0; +RemainderBits := Remainder.BitLength; +ModulusBits := Divisor.BitLength; +DiffBits := RemainderBits - ModulusBits; +if DiffBits > 0 then + Compare := rGreaterThan + else if DiffBits < 0 then + Compare := rLessThan + else + Compare := Remainder.Compare( Divisor); +while ((Compare in [rGreaterThan, rEqualTo]) or (ShiftAmnt > 0)) and + (RemainderBits > 0) do + begin + LeftShift := DiffBits; + if (LeftShift < 0) and ((-LeftShift) > ShiftAmnt) then + LeftShift := - ShiftAmnt; + if (ShiftAmnt + LeftShift) = 0 then + ShiftedMod.Assign( Divisor) + else + ShiftedMod.MulPower2( LeftShift); + Inc( ShiftAmnt, LeftShift); + if LeftShift <> 0 then + Compare := Remainder.Compare( ShiftedMod); + if (Compare = rLessThan) and (ShiftAmnt > 0) then + begin + if ShiftAmnt = 1 then + ShiftedMod.Assign( Divisor) + else + ShiftedMod.MulPower2( -1); + Dec( ShiftAmnt); + Compare := rGreaterThan + end; + if Compare in [rGreaterThan, rEqualTo] then + begin + Remainder.Subtract( ShiftedMod); + RemainderBits := Remainder.BitLength; + Compare := rLessThan; + // set bit ShiftAmnt of Quotient + if RequiresQuotient and (ShiftAmnt > Quotient.MaxBits) then + raise Exception.Create( ES_HugeCardinal_DivideOverflow); + if RequiresQuotient then + QuotientByte := Quotient.ValuePntr( ShiftAmnt div 8); + Mask := 1 shl (ShiftAmnt mod 8); + if RequiresQuotient then + begin + Assert( (QuotientByte^ and Mask) = 0, + AS_HugeCardinal_DivideLogicFail); + QuotientByte^ := QuotientByte^ or Mask + end + end; + DiffBits := RemainderBits - (ModulusBits + ShiftAmnt) + end; +finally +ShiftedMod.Free +end; +if RequiresQuotient then + Quotient.FBits := -1 +end; + + + +procedure THugeCardinal.MulPower2( ShiftAmnt: integer); +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_MulPower2); +{$ENDIF} +if doUseMulPower2_NewAlgorithm then + MulPower2_NewAlgorithm( ShiftAmnt) + else + MulPower2_OldAlgorithm( ShiftAmnt) +end; + +procedure THugeCardinal.MulPower2_OldAlgorithm( ShiftAmnt: integer); +var + P8: PByte; + P32: ^uint32; + Carry: byte; + Remaining, ShiftBytes: integer; + b8_1, b8_2: byte; + b32_1, b32_2: uint32; + DataLen: integer; + Idx: integer; // index into data value pointed to by the write pointer P8. + InitialBits: integer; + InitialShiftAmnt: integer; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_Power2) + end; + +begin +if (ShiftAmnt = 0) or isZero then exit; + +InitialBits := BitLength; +if (InitialBits + ShiftAmnt) > MaxBits then + Overflow; + +InitialShiftAmnt := ShiftAmnt; + +if ShiftAmnt > 0 then + ShiftBytes := ShiftAmnt div 8 + else + ShiftBytes := -((-ShiftAmnt + 7) div 8); + +Dec( ShiftAmnt, ShiftBytes * 8); +DataLen := (FBits + 7) div 8; +P8 := FValue.Memory; +Idx := 0; +Remaining := DataLen; + +if ShiftBytes >= 1 then + begin + // Here, we want to shift-left the value data by ShiftBytes (bytes). + // Shift-left is equivalent to multiplication by a positive power of 2. + // The newly shifted out area must be cleared. + // In the context of little-endien byte order, picture data bytes as + // laid out from right (offset zero, least signficant), traversing + // to left (offset Size-1, most signficant). And picture the bits + // within the bytes as bit 0 (LSB) on the right-hand side, traversing + // bits horizontally to bit 7 (MSB) of the byte on the left-hand side. + // In a big-endien system, bytes would be laid out pictorially in the + // reverse order. + // ShiftAmnt is now an amount of bits to be shift-left, ranging + // from 0 to 7. + if (ShiftBytes + DataLen) > FValue.Size then + Overflow; + P8 := ValuePntr( ShiftBytes); + Idx := ShiftBytes; + Move( FValue.Memory^, P8^, DataLen); + ClearMem( 0, ShiftBytes); + Inc( FBits, ShiftBytes * 8) + end; + +Carry := 0; + +if ShiftBytes <= -1 then + begin + ShiftBytes := - ShiftBytes; + // Here, we want to shift-right the value data by ShiftBytes. + if ((ShiftBytes - 1) < DataLen) and (ShiftAmnt > 0) then + begin + // We shift-right a few bits too far, so save these bits + // to be shift-lefted back in later. + P8 := ValuePntr( ShiftBytes - 1); + Carry := P8^ shr (8 - ShiftAmnt) + end; + if ShiftBytes < DataLen then + begin + P8 := ValuePntr( ShiftBytes); + Idx := DataLen - ShiftBytes; + Move( P8^, FValue.Memory^, Idx); + ClearMem( Idx, ShiftBytes); + Dec( FBits, ShiftBytes * 8); + Dec( Remaining, ShiftBytes) + end + else + begin + ClearMem( 0, DataLen); + FBits := 0; + Remaining := 0 + end; + P8 := FValue.Memory; + Idx := 0 + end; + +if ShiftAmnt = 0 then exit; + +// Here, we want to shift-left the value data by ShiftAmnt bits, +// where ShiftAmnt ranges from 1 to 7. +while Remaining > 0 do + begin + if (Remaining >= 4) and isAligned32( P8) then + begin + P32 := pointer( P8); + b32_1 := P32^ shr (32 - ShiftAmnt); + b32_2 := Carry; + Carry := LongRec( b32_1).Bytes[0]; + b32_1 := P32^ shl ShiftAmnt; + P32^ := b32_1 or b32_2; + Inc( P8, 4); + Dec( Remaining, 4); + Inc( Idx, 4) + end + else + begin + b8_1 := P8^ shr (8 - ShiftAmnt); + b8_2 := Carry; + Carry := b8_1; + b8_1 := P8^ shl ShiftAmnt; + P8^ := b8_1 or b8_2; + Inc( P8); + Dec( Remaining); + Dec( Idx) + end; + end; + +if Carry > 0 then + // Here, we have shifted all the main data, but we have a few bits + // of carry left over. + begin + if Idx < FValue.Size then + P8^ := Carry + else + Overflow + end; +FBits := InitialBits + InitialShiftAmnt; +if FBits < 0 then + FBits := 0 +end; + + + +procedure THugeCardinal.MulPower2_NewAlgorithm( ShiftAmnt: integer); +var + LogicalBitCount : integer; + LogicalByteCount : integer; + PhysicalByteCount: integer; + ShiftBytesLeft, ShiftBitsLeft: integer; + ShiftBytesRight, ShiftBitsRight: integer; + // FinalByteIndex: integer; + isLeftShift: boolean; + Remaining: integer; + P8: PByte; + P32: ^uint32; + Carry: byte; + // ShiftBytes: integer; + b8_1, b8_2: byte; + b32_1, b32_2: uint32; + ShiftComp8, ShiftComp32: integer; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_Power2) + end; + +begin +if (ShiftAmnt = 0) or isZero then exit; +LogicalBitCount := BitLength; +LogicalByteCount := (LogicalBitCount + 7) div 8; +PhysicalByteCount := FValue.Size; +if ShiftAmnt > 0 then + begin + ShiftBytesLeft := ShiftAmnt div 8; + ShiftBitsLeft := ShiftAmnt mod 8; + ShiftBitsRight := 0; +// if (ShiftBitsLeft > 0) and ((ShiftBytesLeft + LogicalByteCount) < PhysicalByteCount) then +// begin +// Inc( ShiftBytesLeft); +// ShiftBitsRight := 8 - ShiftBitsLeft; +// ShiftBitsLeft := 0 +// end; + if (ShiftBytesLeft + LogicalByteCount) > PhysicalByteCount then + Overflow; + if ShiftBytesLeft > 0 then + begin + Move( FValue.Memory^, ValuePntr( ShiftBytesLeft)^, LogicalByteCount); + ClearMem( 0, ShiftBytesLeft); + Inc( FBits, ShiftBytesLeft * 8) + end; + end + else + begin + ShiftAmnt := - ShiftAmnt; + ShiftBytesRight := ShiftAmnt div 8; + ShiftBitsRight := ShiftAmnt mod 8; + ShiftBitsLeft := 0; + if ShiftBytesRight >= LogicalByteCount then + begin + ClearMem( 0, LogicalByteCount); + FBits := 0 + end + else if ShiftBytesRight > 0 then + begin + Move( ValuePntr( ShiftBytesRight)^, FValue.Memory^, LogicalByteCount - ShiftBytesRight); + ClearMem( LogicalByteCount - ShiftBytesRight, ShiftBytesRight); + Dec( FBits, ShiftBytesRight * 8) + end; + end; +if ((ShiftBitsLeft + ShiftBitsRight) > 0) and (FBits > 0) then + begin + isLeftShift := ShiftBitsLeft > 0; + Remaining := (FBits + 7) div 8; + Carry := 0; + if isLeftShift then + ShiftAmnt := ShiftBitsLeft + else + ShiftAmnt := ShiftBitsRight; + ShiftComp32 := 32 - ShiftAmnt; + ShiftComp8 := 8 - ShiftAmnt; + if isLeftShift then + begin + P8 := ValuePntr( 0); + while Remaining > -1 do + begin + if (Remaining >= 4) and isAligned32( P8) then + begin + P32 := pointer( P8); + b32_1 := P32^ shr ShiftComp32; + b32_2 := Carry; + Carry := LongRec( b32_1).Bytes[0]; + b32_1 := P32^ shl ShiftAmnt; + P32^ := b32_1 or b32_2; + Inc( P8, 4); + Dec( Remaining, 4) + end + else + begin + if Remaining > 0 then + b8_1 := P8^ shr ShiftComp8 + else + b8_1 := 0; + b8_2 := Carry; + Carry := b8_1; + b8_1 := P8^ shl ShiftAmnt; + P8^ := b8_1 or b8_2; + Inc( P8); + Dec( Remaining) + end + end; + Inc( FBits, ShiftBitsLeft) + end + else + begin + P8 := ValuePntr( Remaining - 1); + while Remaining > 0 do + begin + {$if CompilerVersion >= 21.00} + if (Remaining >= 4) and isAligned32( P8 - 3) then + {$else} + if (Remaining >= 4) and isAligned32( pointer( TrueNativeInt( P8) - 3)) then + {$ifend} + begin + Dec( P8, 3); + P32 := pointer( P8); + b32_1 := P32^ shl ShiftComp32; + b32_2 := 0; + LongRec( b32_2).Bytes[3] := Carry; + Carry := LongRec( b32_1).Bytes[3]; + b32_1 := P32^ shr ShiftAmnt; + P32^ := b32_1 or b32_2; + Dec( P8); + Dec( Remaining, 4) + end + else + begin + b8_1 := P8^ shl ShiftComp8; + b8_2 := Carry; + Carry := b8_1; + b8_1 := P8^ shr ShiftAmnt; + P8^ := b8_1 or b8_2; + Dec( P8); + Dec( Remaining) + end + end; + Dec( FBits, ShiftBitsRight); + if FBits < 0 then + FBits := 0 + end; + end +end; + + + +procedure THugeCardinal.MulSmall( Factor: uint32); +var + Done: boolean; + PoweredFactor, Power, iFactor: integer; + j: Integer; + DataLen, Remaining: integer; + P32: ^uint32; + Carry, Factor1: uint32; + Product: uint64; + Idx: integer; + FactorBytes: integer; + LastBits: integer; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_MulSmallOverflow) + end; + +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_MulSmall); +{$ENDIF} +if isZero then exit; +Done := False; +if Factor = 0 then + begin + Zeroise; + Done := True + end + else if Factor = 1 then + Done := True + else + begin + iFactor := Factor; + PoweredFactor := 1; + for Power := 1 to 10 do + begin + PoweredFactor := PoweredFactor * 2; + if PoweredFactor > iFactor then break; + if PoweredFactor < iFactor then continue; + MulPower2( Power); + Done := True; + break + end + end; +if Done then exit; +if (BitLength + BitCount_32( Factor) - 1) > MaxBits then + Overflow; +DataLen := (BitLength + 7) div 8; +Remaining := DataLen; +P32 := FValue.Memory; +Idx := 0; +Carry := 0; +for j := 0 to (DataLen div 4) - 1 do + begin + Factor1 := P32^; + Product := Factor1; // Widen. + Product := Product * Factor + Carry; + Factor1 := int64rec( Product).Lo; + P32^ := Factor1; + Carry := int64rec( Product).Hi; + P32 := Offset( P32, 4); + Dec( Remaining, 4); + Inc( Idx, 4) + end; +Factor1 := 0; +if Remaining > 0 then + Move( P32^, Factor1, Remaining); +Product := Factor1; // widen. +Product := Product * Factor + Carry; +if Product <> 0 then + begin + LastBits := BitCount_64( Product); + FactorBytes := (LastBits + 7) div 8; + if (Idx + FactorBytes) > FValue.Size then + Overflow; + Move( Product, P32^, FactorBytes) + end; +FBits := -1 +end; + + + +function THugeCardinal.Multiply( Factor: THugeCardinal): THugeCardinal; +var + Addend: THugeCardinal; + Factor2: uint32; + j: integer; +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( func_Multiply); +{$ENDIF} +result := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); +if isZero then exit; +Addend := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); +try + Factor.FValue.Position := 0; + for j := 0 to ((Factor.BitLength + 31) div 32) - 1 do + begin + Factor2 := 0; + Factor.FValue.Read( Factor2, 4); + if Factor2 = 0 then continue; + Addend.Assign( self); + Addend.MulSmall( Factor2); + Addend.MulPower2( j * 32); + result.Add( Addend) + end +finally + Addend.Free + end +end; + + +procedure THugeCardinal.MultiplyMod( Factor, Modulus: THugeCardinal); +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_MultiplyMod); +{$ENDIF} +if doUseMultiplyMod_NewAlgorithm then + MultiplyMod_New( Factor, Modulus) + else + MultiplyMod_Old( Factor, Modulus) +end; + + +procedure THugeCardinal.MultiplyMod_Old( Factor, Modulus: THugeCardinal); +var + Product, Remainder: THugeCardinal; +begin +Product := Multiply( Factor); +try +Remainder := Product.Modulo( Modulus); +try +Assign( Remainder) +finally +Remainder.Free +end +finally +Product.Free +end end; + + +procedure THugeCardinal.MultiplyMod_New( Factor, Modulus: THugeCardinal); +var + Product{, Remainder}: THugeCardinal; + Addend: THugeCardinal; + Factor2: uint32; + j: integer; + LogicalByteCount, PhysicalByteCount, ShiftBytesLeft: integer; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_AddOverflow) + end; + + procedure MakeProductModulo; + var + Remainder: THugeCardinal; + begin + Remainder := Product.Modulo( Modulus); + try + Product.Assign( Remainder) + finally + Remainder.Free + end + end; + +begin +if isZero then exit; +Product := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); +try + Addend := THugeCardinal.CreateZero( BitLength + Factor.BitLength + 32, FPool); + try + Factor.FValue.Position := 0; + for j := 0 to ((Factor.BitLength + 31) div 32) - 1 do + begin + Factor2 := 0; + Factor.FValue.Read( Factor2, 4); + if Factor2 = 0 then continue; + Addend.Assign( self); + Addend.MulSmall( Factor2); + if j > 0 then + with Addend do + begin + LogicalByteCount := (Addend.BitLength+ 7) div 8; + PhysicalByteCount := Addend.FValue.Size; + ShiftBytesLeft := j * 4; + if (ShiftBytesLeft + LogicalByteCount) > PhysicalByteCount then + Overflow; + Move( Addend.FValue.Memory^, Addend.ValuePntr( ShiftBytesLeft)^, LogicalByteCount); + Addend.ClearMem( 0, ShiftBytesLeft); + Inc( Addend.FBits, ShiftBytesLeft * 8) + end; + Product.Add( Addend); + // MakeProductModulo + end + finally + Addend.Free + end; + MakeProductModulo; + Assign( Product) +finally + Product.Free + end +end; + + + +function THugeCardinal.NewMemoryStream( InitBitSize: integer): TMemoryStream; +var + InitSize: integer; +begin +InitSize := InitBitSize div 8; +if assigned( FPool) then + result := FPool.NewMemoryStream( InitSize) + else + begin + result := TMemoryStream.Create; + if InitSize > 0 then + result.Size := InitSize + end +end; + + + +procedure THugeCardinal.Resize( NewMaxBit1: integer); +var + NewMaxBits: integer; + NewValue: TMemoryStream; + DataBytesLen: integer; +begin +NewMaxBits := ComputedNeededSize( NewMaxBit1); +if NewMaxBits = MaxBits then exit; +if BitLength > NewMaxBits then + raise Exception.Create( ES_HugeCardinal_ResizeOverflow); +NewValue := NewMemoryStream( NewMaxBits); +DataBytesLen := (BitLength + 7) div 8; +if DataBytesLen > 0 then + Move( FValue.Memory^, NewValue.Memory^, DataBytesLen); +ClearMemory( NewValue, DataBytesLen, NewValue.Size - DataBytesLen); +FValue.Free; +FValue := NewValue +end; + + +procedure THugeCardinal.SquareMod( Modulus: THugeCardinal); +var + C: uint64; + Remainder: THugeCardinal; +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_SquareMod); +{$ENDIF} +if isZero then exit; +if BitLength <= 32 then + begin + C := ExtractSmall; + AssignSmall( C * C); + Remainder := Modulo( Modulus); + try + Assign( Remainder) + finally + Remainder.Free + end end + else + MultiplyMod( self, Modulus) +end; + + + +procedure THugeCardinal.SmallExponent_Power( Exponent: uint32); +var + Odd1: boolean; + Base, Product: THugeCardinal; + RequiredBits: uint64; + + procedure Mult( Factor: THugeCardinal); + begin + Product := Multiply( Factor); + try + Assign( Product) + finally + FreeAndNil( Product) + end end; + +begin +// First, deal with special cases. +if isZero then + begin + Assert( Exponent <> 0, AS_ZeroToZero); + exit + end; +if Exponent = 0 then + begin + AssignSmall( 1); + exit + end; +RequiredBits := cardinal( BitLength) * Exponent; +if (RequiredBits < Exponent) or (RequiredBits > MaxBits) then + raise Exception.Create( ES_HugeCardinal_PowerOverflow); + +// Russian Peasant Algorithm. +Base := THugeCardinal.CreateZero( RequiredBits, FPool); +try +while Exponent >= 2 do + begin + Odd1 := Odd( Exponent); + if Odd1 then + Base.Assign( self); + Exponent := Exponent shr 1; + Mult( self); + if Odd1 then + Mult( Base) + end +finally +Base.Free +end end; + + +procedure THugeCardinal.SmallExponent_PowerMod( + Exponent: uint64; Modulus: THugeCardinal); +var + Base, Factor: THugeCardinal; +begin +// First, deal with special cases. +if isZero then exit; +if Exponent = 0 then + begin + AssignSmall( 1); + exit + end; +// Russian Peasant Algorithm. +Factor := nil; +try +if Compare( Modulus) <> rLessThan then + begin + Base := Modulo( Modulus); + try + Assign( Base) + finally + Base.Free + end + end; +Base := THugeCardinal.CreateZero( Modulus.BitLength, FPool); +try +while Exponent >= 2 do + begin + if Odd( int64Rec( Exponent).Lo) then + begin + if not assigned( Factor) then + Factor := CloneSized( Modulus.BitLength) + else + Factor.MultiplyMod( self, Modulus) + end; + Exponent := Exponent shr 1; + SquareMod( Modulus) + end +finally +Base.Free +end; +if assigned( Factor) then + MultiplyMod( Factor, Modulus) +finally +Factor.Free +end end; + + +function THugeCardinal.PowerMod( Exponent, Modulus: THugeCardinal; OnProgress: TProgress): boolean; +var + Base: THugeCardinal; + Expo: THugeCardinal; + Factor: THugeCardinal; + BitsProcessed, TotalBits: int64; + doAbort: boolean; +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( func_PowerMod); +{$ENDIF} +Factor := nil; +try +if not Exponent.isSmall then + begin + doAbort := False; + // Russian Peasant Algorithm. + if Compare( Modulus) <> rLessThan then + begin + Base := Modulo( Modulus); + try + Assign( Base) + finally + Base.Free; + end + end; + Base := THugeCardinal.CreateZero( Modulus.BitLength, FPool); + Expo := Exponent.CloneSized( Exponent.BitLength); + TotalBits := Exponent.BitLength; + try + while (not Expo.isSmall) and (not doAbort) do + begin + if Expo.isOdd then + begin + if not assigned( Factor) then + Factor := CloneSized( Modulus.BitLength) + else + Factor.MultiplyMod( self, Modulus) + end; + Expo.MulPower2( -1); + SquareMod( Modulus); + if assigned( OnProgress) then + begin + BitsProcessed := TotalBits - Expo.BitLength; + OnProgress( self, BitsProcessed, TotalBits, doAbort) + end + end; + if not doAbort then + SmallExponent_PowerMod( Expo.ExtractSmall, Modulus) + finally + Base.Free; + Expo.Free + end + end + else + SmallExponent_PowerMod( Exponent.ExtractSmall, Modulus); +result := not doAbort; +if result and assigned( Factor) then + MultiplyMod( Factor, Modulus) +finally +Factor.Free +end end; + + + +function THugeCardinal.PowerMod_WithChineseRemainderAlgorithm( + Exponent, // d + Modulus: THugeCardinal; // n := p * q + FactorP, // p + FactorQ, // q + ExponentModFactorP, // dp := d mod p-1 + ExponentModFactorQ, // dq := d mod q-1 + InverseQ : THugeCardinal; // qinv := q ** -1 mod p + OnProgress: TProgress + ): boolean; // result := self ** d mod n +var + x2, CRT_Result: THugeCardinal; +begin +if (not assigned( FactorP)) or (not assigned( FactorQ)) then + result := PowerMod( Exponent, Modulus, OnProgress) + else + begin + // With CRT, we can short-cut ... + // x := y ** d mod n + // as ... + // x1 := y ** dp mod p + // x2 := y ** dq mod q + // if x1 >= x2: + // h := qinv * (x1 - x2) mod p + // else: + // h := qinv * (x1 + p - x2) mod p + // x := x2 + h * q + x2 := Clone; + try + result := PowerMod( ExponentModFactorP, FactorP, OnProgress) and + x2.PowerMod( ExponentModFactorQ, FactorQ, OnProgress); + if result then + begin + if Compare( x2) = rLessThan then + Add( FactorP); + Subtract( x2); + MultiplyMod( InverseQ, FactorP); + CRT_Result := Multiply( FactorQ); + CRT_Result.Add( x2); + Assign( CRT_Result); + CRT_Result.Free + end; + finally + x2.Free + end + end +end; + + +procedure THugeCardinal.Subtract( Subtractend: THugeCardinal); +var + P1, P2: PByte; + Borrow: boolean; + Bytes, j, Idx: integer; + V1, V2, V3: uint64; + SubBytes, D2: integer; + + procedure Overflow; + begin + FBits := -1; + raise Exception.Create( ES_HugeCardinal_SubractOverflow) + end; + +begin +{$IFDEF profiling} +if doProfiling then EnterProfileSection( proc_Subtract); +{$ENDIF} +Bytes := (BitLength + 7) div 8; +SubBytes := (Subtractend.BitLength + 7) div 8; +if SubBytes > Bytes then + Overflow; +P1 := FValue.Memory; +P2 := Subtractend.FValue.Memory; +Borrow := False; +Idx := 0; +D2 := Subtractend.FValue.Size; +FBits := -1; +for j := 0 to (Bytes div 8) - 1 do + begin + V1 := Puint64( P1)^; + V2 := 0; + if D2 > 0 then + Move( P2^, V2, Min( D2, 8)); + if (V2 = 0) and (not Borrow) and (Idx >= SubBytes) then exit; + V3 := Subtract_uint64_WithBorrow( V1, V2, Borrow); + Puint64( P1)^ := V3; + Inc( P1, 8); + Inc( P2, 8); + Inc( Idx, 8); + Dec( D2, 8) + end; +if (Bytes mod 8) <> 0 then + begin + V1 := 0; + Move( P1^, V1, bytes mod 8); + V2 := 0; + if D2 > 0 then + Move( P2^, V2, Min( D2, 8)); + V3 := Subtract_uint64_WithBorrow( V1, V2, Borrow); + Move( V3, P1^, bytes mod 8) + end; +if Borrow then + Overflow +end; + + + + +procedure THugeCardinal.Swap( Peer: THugeCardinal); +var + TempMaxBits: integer; + TempBits: integer; + TempValue: TMemoryStream; +begin +TempMaxBits := FMaxBits; +TempBits := FBits; +TempValue := FValue; + +FMaxBits := Peer.FMaxBits; +FBits := Peer.FBits; +FValue := Peer.FValue; + +Peer.FMaxBits := TempMaxBits; +Peer.FBits := TempBits; +Peer.FValue := TempValue +end; + + + +function THugeCardinal.ValuePntr( ByteIndex: integer): PByte; +begin +result := MemStrmOffset( FValue, ByteIndex) +end; + + +procedure THugeCardinal.Zeroise; +begin +CheckBits; +if isZero then exit; +ClearMem( 0, (FBits + 7) div 8); +FBits := 0 +end; + + + + + +procedure THugeCardinal.StreamOut( + ByteOrder: TByteOrder; Stream: TStream; SizeToOutput: integer = -1); +// ^ Streams the low order SizeToOutput bytes out to the stream. +// If SizeToOutput is -1, then this is interpreted as (MaxBits + 7) div 8 +var + P8: PByte; + PayloadByte, ZeroByte: byte; + j: integer; + ZeroFillCount: integer; + MaxBytes: cardinal; + MSB_Index: cardinal; +begin +// MaxBytes = (MaxBits = 7) div 8 = N; +// Case 1: Little-endien; MaxBytes > SizeToOutput +// FValue = X[0](=LSB) X[1] ... X[N-1](=MSB) +// Stream := X[0] .. X[SizeToOutput-1] +// If any discarded data (X[SizeToOutput]..X[N-1]) is non-zero, this is an error. + +// Case 2: Little-endien; MaxBytes < SizeToOutput +// FValue = X[0](=LSB) X[1] ... X[N](=MSB) +// Stream := X[0] .. X[N-1] 0 0 0 0 (0 is repeated SizeToOutput - MaxBytes times). + +// Case 3: Big-endien; MaxBytes > SizeToOutput +// FValue = X[0](=LSB) X[1] ... X[N-1](=MSB) +// Stream := X[SizeToOutput-1] .. X[1] X[0] +// If any discarded data (X[SizeToOutput]..X[N-1]) is non-zero, this is an error. + +// Case 4: Big-endien; MaxBytes < SizeToOutput +// FValue = X[0](=LSB) X[1] ... X[N](=MSB) +// Stream := 0 0 0 0 X[N-1] .. X[0] (At the start, 0 is repeated SizeToOutput - MaxBytes times). + +MaxBytes := FValue.Size; +if SizeToOutput < 0 then + SizeToOutput := MaxBytes; // = (MaxBits + 7) div 8 +if SizeToOutput = 0 then exit; +ZeroFillCount := SizeToOutput - integer( MaxBytes); +if SizeToOutput < ((BitLength + 7) div 8) then + raise Exception.Create( ES_HugeCardinal_StreamOutOverflow); +ZeroByte := 0; +MSB_Index := Min( SizeToOutput, MaxBytes); +case ByteOrder of + LittleEndien: + begin + Stream.Write( FValue.Memory^, MSB_Index); + for j := 0 to ZeroFillCount - 1 do + Stream.Write( ZeroByte, 1) + end; + BigEndien: + begin + for j := 0 to ZeroFillCount - 1 do + Stream.Write( ZeroByte, 1); + P8 := ValuePntr( MSB_Index - 1); + for j := MSB_Index - 1 downto 0 do + begin + PayloadByte := P8^; + Stream.Write( PayloadByte, 1); + Dec( P8) + end + end + end +end; + + +procedure THugeCardinal.AssignFromStreamIn( + ByteOrder: TByteOrder; Stream: TStream); +var + P8: PByte; + PayloadByte: byte; + j: integer; + SourceLen, MaxBytes, MSB_Index, ZeroFillCount: integer; + + procedure CheckDiscardedData; + var + Ok: boolean; + jj: integer; + begin + if ZeroFillCount >= 0 then exit; + // if dont check then do the following instead. + // if ZeroFillCount < 0 then + // Stream.Seek( -ZeroFillCount, soCurrent); + Ok := True; + for jj := 0 to (-ZeroFillCount) - 1 do + begin + Stream.Read( PayloadByte, 1); + Ok := PayloadByte = 0; + if Ok then continue; + Stream.Seek( (-ZeroFillCount) - jj - 1, soCurrent); + break + end; + if not Ok then + raise Exception.Create( ES_HugeCardinal_StreamInOverflow) + end; + +begin +// MaxBytes = Stream.Size = N; +// SizeToInput = Stream.Size - Stream.Position; +// Case 1: Little-endien; MaxBytes > SizeToInput +// Stream = X[0] .. X[SizeToInput-1] +// FValue := X[0](=LSB) X[1] ... X[SizeToInput-1](=MSB) 0 0 0 0 (0 is repeated MaxBytes - SizeToInput times). + +// Case 2: Little-endien; MaxBytes < SizeToInput +// Stream = X[0] .. X[N-1] X[N] X[SizeToInput-1] +// ^-------------------^ All this discarded. +// FValue := X[0] .. X[N-1] +// If any discarded data (X[N]..X[SizeToInput-1]) is non-zero, this is an error. + +// Case 3: Big-endien; MaxBytes > SizeToInput +// Stream = X[SizeToInput-1] .. X[1] X[0] +// FValue := X[0](=LSB) X[1] ... X[SizeToInput-1] 0 0 0 0 (0 is repeated MaxBytes - SizeToInput times). + +// Case 4: Big-endien; MaxBytes < SizeToInput +// Stream = X[SizeToInput-1] .. X[N] X[N-1] .. X[0] +// ^---------------------^ All this discarded. +// FValue := X[0](=LSB) X[1] ... X[N-1](=MSB) +// If any discarded data (X[SizeToInput-1]..X[N]) is non-zero, this is an error. +SourceLen := Stream.Size - Stream.Position; +MaxBytes := FValue.Size; +MSB_Index := Min( SourceLen, MaxBytes); +ZeroFillCount := MaxBytes - SourceLen; +Case ByteOrder of + LittleEndien: + begin + if MSB_Index > 0 then + Stream.Read( FValue.Memory^, MSB_Index); + if ZeroFillCount > 0 then + ClearMemory( FValue, MSB_Index, ZeroFillCount); // case 1 zeros + CheckDiscardedData // case 2 discard + end; + BigEndien: + begin + CheckDiscardedData; // case 4 discard + P8 := ValuePntr( MSB_Index - 1); + for j := MSB_Index - 1 downto 0 do + begin + Stream.Read( PayloadByte, 1); + P8^ := PayloadByte; + Dec( P8) + end; + if ZeroFillCount > 0 then + ClearMemory( FValue, MSB_Index, ZeroFillCount) // case 3 zeros + end + end; +FBits := -1 +end; + + + +function THugeCardinal.CapacityInBits: integer; +begin +result := FValue.Size * 8 +end; + + +initialization +InitExecutionTimes; + +finalization +DoneExecutionTimes; + +end. diff --git a/run/TPLB3.HugeCardinalUtils.pas b/LockBox3/run/TPLB3.HugeCardinalUtils.pas similarity index 96% rename from run/TPLB3.HugeCardinalUtils.pas rename to LockBox3/run/TPLB3.HugeCardinalUtils.pas index 7258399..75a2c49 100644 --- a/run/TPLB3.HugeCardinalUtils.pas +++ b/LockBox3/run/TPLB3.HugeCardinalUtils.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,1032 +12,1032 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.HugeCardinalUtils; -interface -uses TPLB3.HugeCardinal, TPLB3.MemoryStreamPool; - - -type -TPrimalityTestNoticeProc = procedure( CountPrimalityTests: integer) of object; - -function gcd( a, b: THugeCardinal): THugeCardinal; -// Computes the Greatest Common Divisor of a and b. -// A and b may be trashed as a result. -// The result is a new object. - - -function lcm( a, b: THugeCardinal): THugeCardinal; -// Computes the Least Common Multiple of a and b. -// A and b may be trashed as a result. -// The result is a new object. - - -function isCoPrime( a, b: THugeCardinal): boolean; -// Returns True if and only if a and b are co-prime. -// A and b may be trashed as a result. - - -function isProbablyPrime( p: THugeCardinal; OnProgress: TProgress; var wasAborted: boolean): boolean; -// True means that p is almost certainly prime. -// False means that p is composite. -// The Fermat Primality test is used with only 1 pass. -// p is preserved. - - -function hasSmallFactor( p: THugeCardinal): boolean; -// True means that p does not have a small factor. -// It is a good candidate for testing for primality. -// False means that p is composite, and indeed, at least one of its -// factors is a small number. - - -function GeneratePrime( NumBits: integer; - OnProgress: TProgress; - OnPrimalityTest: TPrimalityTestNoticeProc; - PassCount: integer; - const Pool1: IMemoryStreamPool; - var Prime: THugeCardinal; - var NumbersTested: integer): boolean; -// Returns True if Prime was succesfully generated. -// Returns False if user aborted. -// On input, Prime is nil. -// Upon output, if user did not abort, Prime is a prime number -// of NumBits bits. PassCount passes of the Fermat Primality test -// are used to test primality of random candidates. - - -function Inverse( Prime, Modulus: THugeCardinal; var TestPassed: boolean): THugeCardinal; -// Computes multiplicative inverse of Prime over modulus. -// Assumes: -// Modulus >= 3 -// 2 <= Prime < Modulus -// 'Prime' is a prime number. - - -const - StandardExponent = 65537; - -procedure Compute_RSA_Fundamentals_2Factors( - RequiredBitLengthOfN: integer; - Fixed_e: uint64; // Put as -1 to generate a random number. - // A value of StandardExponent is recommended. - var N, e, d, Totient: THugeCardinal; - var p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. - OnProgress: TProgress; - OnPrimalityTest: TPrimalityTestNoticeProc; - GeneratePrimePassCount: integer; // 1 .. 20; - const Pool1: IMemoryStreamPool; - var NumbersTested: integer; - var wasAborted: boolean); - - -function Validate_RSA_Fundamentals( - var N, e, d, Totient: THugeCardinal): boolean; - - -var - GreatestPassCount: integer = 0; // Investigative tool used for tweeking the algorithm. - RSA_FailCount: integer = 0; - -implementation - - - - - - - - - - - - -uses SysUtils, Classes, TPLB3.PointerArithmetic, TPLB3.IntegerUtils, - TPLB3.I18n, Math; - -const - SmallPrimeSetCardinality = 200; - EratosthenesSieveSize = 2000; // Must choose value such that: - // SmallPrimeSetCardinality'th prime number < EratosthenesSieveSize - -var - SmallPrimes: array[ 0.. SmallPrimeSetCardinality-1] of integer; - - -procedure PreComputeSmallPrimes; forward; -// The above computes the set of small prime numbers. - -procedure InitUnit_HugeCardinalUtils; -begin -FillChar( SmallPrimes, SizeOf( SmallPrimes), 0); -PreComputeSmallPrimes -end; - - -procedure DoneUnit_HugeCardinalUtils; -begin -end; - - -procedure PreComputeSmallPrimes; -// Uses the sieve of Eratosthenes algorithm. -var - p, j, k: integer; - Numbers: TBits; -begin -p := 2; -Numbers := TBits.Create; -try -Numbers.Size := EratosthenesSieveSize; -// Numbers[j] = False means that j is possibly prime. -// Numbers[j] = True means that j is composite. -for j := 0 to SmallPrimeSetCardinality-1 do - begin - // p is a prime. - k := 2 * p; - while k < EratosthenesSieveSize do - begin - Numbers[k] := True; - Inc( k, p) - end; - SmallPrimes[j] := p; - repeat - Inc( p) - until (p >= EratosthenesSieveSize) or (not Numbers[p]); - if p >= EratosthenesSieveSize then - raise Exception.CreateFmt( - ES_EratosthenesSievSizeTooSmall, - [EratosthenesSieveSize, SmallPrimeSetCardinality]) - end; -finally -Numbers.Free -end end; - - - -function gcd( a, b: THugeCardinal): THugeCardinal; -// Uses Stein's algorithm. -// TO DO: Implement an alternate implementation using Euclid and -// measure the performance difference. -var - ResultBitShifts: integer; - isA_Odd, isB_Odd: boolean; -begin -ResultBitShifts := 0; -result := nil; -repeat - if a.isZero then - result := b - else if b.isZero then - result := a - else - begin - isA_Odd := a.isOdd; - isB_Odd := b.isOdd; - if (not isA_Odd) and (not isB_Odd) then - begin - Inc( ResultBitShifts); - a.MulPower2( -1); // a := a / 2; - b.MulPower2( -1); // b := b / 2; - end - - else if isA_Odd and (not isB_odd) then - b.MulPower2( -1) - - else if (not isA_Odd) and isB_odd then - a.MulPower2( -1) - - else - case a.Compare( b) of - rGreaterThan: - begin - a.Subtract( b); - a.MulPower2( -1) - end; - - rEqualTo: - result := a; - - rLessThan: - begin - b.Subtract( a); - b.MulPower2( -1) - end; - end; - end; -until Assigned( result); -result := result.CloneSized( result.BitLength + ResultBitShifts); -result.MulPower2( ResultBitShifts) -end; - - -function lcm( a, b: THugeCardinal): THugeCardinal; -var - gcd1, Temp, Quotient, Remainder: THugeCardinal; -begin -Quotient := nil; -Remainder := nil; -result := a.Multiply( b); -gcd1 := gcd( a, b); -try -if (not gcd1.isSmall) or (gcd1.ExtractSmall <> 1) then - begin - result.Divide( gcd1, Quotient, Remainder); - Assert( Remainder.isZero, AS_LCM_Fail); - Temp := result; - result := Quotient; - Quotient := Temp - end -finally - gcd1.Free; - Quotient.Free; - Remainder.Free -end end; - - - -function isCoPrime( a, b: THugeCardinal): boolean; -var - gcd1: THugeCardinal; -begin -gcd1 := gcd( a, b); -result := gcd1.isSmall and (gcd1.ExtractSmall = 1); -gcd1.Free -end; - - -function isProbablyPrime( p: THugeCardinal; OnProgress: TProgress; var wasAborted: boolean): boolean; -var - Witness: THugeCardinal; - pMinusOne: THugeCardinal; -begin -pMinusOne := nil; -wasAborted := False; -if p.isSmall and (p.ExtractSmall <= 3) then - begin - result := True; - exit - end; -Witness := nil; -try -repeat - FreeAndNil( Witness); - Witness := THugeCardinal.CreateZero( p.BitLength, p.FPool); - Witness.Random( p); -until (not Witness.isSmall) or (Witness.ExtractSmall > 1); -// 2 <= Witness < p -pMinusOne := p.Clone; -try -pMinusOne.Increment( -1); -wasAborted := not Witness.PowerMod( pMinusOne, p, OnProgress); -// isPrime := (Witness ** (p-1) mod p) = 1 -result := Witness.isSmall and (Witness.ExtractSmall = 1) -finally -Witness.Free -end -finally -pMinusOne.Free -end -end; - - - - -function hasSmallFactor( p: THugeCardinal): boolean; -var - j, q: integer; - Modulus, TestValue, TestValue2: THugeCardinal; - doSmallTest: boolean; - pValue: uint64; -begin -result := not p.isOdd; -if result then exit; -doSmallTest := p.isSmall; -if doSmallTest then - pValue := p.ExtractSmall - else - pValue := 0; -Modulus := THugeCardinal.CreateZero( 0, p.FPool); -TestValue := THugeCardinal.CreateZero( p.MaxBits, p.FPool); -try - for j := 1 to SmallPrimeSetCardinality-1 do - begin - q := SmallPrimes[j]; // q is a small prime number. - if doSmallTest and (q >= pValue) then break; - Modulus.AssignSmall( q); - TestValue.Assign( p); - TestValue2 := TestValue.Modulo( Modulus); - result := TestValue2.isZero; - TestValue2.Free; - if result then break - end -finally - Modulus.Free; - TestValue.Free - end -end; - - -function GeneratePrime( NumBits: integer; - OnProgress: TProgress; - OnPrimalityTest: TPrimalityTestNoticeProc; - PassCount: integer; - const Pool1: IMemoryStreamPool; - var Prime: THugeCardinal; - var NumbersTested: integer): boolean; -// Returns True if Prime was succesfully generated. -// Returns False if user aborted. -const - PrimeDeltas: array[ 0..7 ] of integer = (6, 4, 2, 4, 2, 2, 6, 2); -var - Thirty, Temp, Temp2: THugeCardinal; - Delta: int64; - Idx, j: integer; - FoundPrime: boolean; - wasAborted: boolean; -begin -if PassCount <= 0 then - PassCount := 1; -if PassCount > 20 then - PassCount := 20; -// generate p1 -Prime := THugeCardinal.CreateRandom( NumBits, NumBits + 2, True, Pool1); -Thirty := THugeCardinal.CreateSmall( 30, 0, Pool1); -Temp := nil; Temp2 := nil; -try - Temp := Prime.Clone; - Temp2 := Temp.Modulo( Thirty); - Delta := 31 - Temp2.ExtractSmall; -finally - Thirty.Free; - Temp.Free; Temp2.Free - end; -// p := p1 - (p1 mod 30) + 1; -Prime.Increment( Delta); -// So now, p mod 30 = 1 - -// i := 0; -Idx := 0; -result := True; -wasAborted := False; -repeat - FoundPrime := not hasSmallFactor( Prime); - if FoundPrime then - for j := 1 to PassCount do - begin - FoundPrime := isProbablyPrime( Prime, OnProgress, wasAborted); - result := not wasAborted; - if result and (not FoundPrime) and (j > GreatestPassCount) then - GreatestPassCount := j; - if (not FoundPrime) or (not result) then break; - end; - Inc( NumbersTested); - if (not wasAborted) and assigned( OnPrimalityTest) then - OnPrimalityTest( NumbersTested); - if FoundPrime or (not result) then break; - // This candidate failed, so try the next likely one. - // p += (6,4,2,4,2,2,6,2)[i]; - Delta := PrimeDeltas[ Idx]; - Prime.Increment( Delta); - if Idx >= 7 then - Idx := 0 - else - Inc( Idx) -until FoundPrime or (not result); -if not result then - FreeAndNil( Prime) -end; - - -function extended_gcd( a, b: THugeCardinal; - var x, y: THugeCardinal; - var xPve, yPve: boolean; - var gcd : THugeCardinal): boolean; -// Solve: -// a*x + b*y = gcd(a,b) -// Using Extended Euclidean algorithm. -var - NextX, NextY, a1, b1, SwapTemp: THugeCardinal; - Quotient, Remainder: THugeCardinal; - NextXpve, NextYpve, SwapPve: boolean; - QxNextXY: THugeCardinal; - Cmp: TCompareResult; - gcd_factor1, gcd_factor2: THugeCardinal; - gcdPve: boolean; -// s: string; - -begin -NextX := THugeCardinal.CreateSimple(0); NextXpve := True; -x := THugeCardinal.CreateSimple(1); xPve := True; -NextY := THugeCardinal.CreateSimple(1); NextYpve := True; -y := THugeCardinal.CreateSimple(0); yPve := True; -a1 := a.Clone; -b1 := b.Clone; -SwapTemp := THugeCardinal.CreateSimple( 0); -while not b1.isZero do - begin - a1.Divide( b1, Quotient, Remainder); - SafeAssign( a1, b1); - b1.Free; - b1 := Remainder; - Remainder := nil; - - SafeAssign( SwapTemp, NextX); SwapPve := NextXpve; - QxNextXY := Quotient.Multiply( NextX); - Cmp := x.Compare( QxNextXY); - if Xpve = NextXpve then - begin - if Cmp in [rGreaterThan, rEqualTo] then - begin - SafeAssign( NextX, x); - NextX.Subtract( QxNextXY); - NextXpve := xPve - end - else - begin - SafeAssign( NextX, QxNextXY); - NextX.Subtract( x); - NextXpve := not xPve - end - end - else - begin - SafeAdd( NextX, x, QxNextXY); - NextXpve := xPve - end; - SafeAssign( x, SwapTemp); - xPve := SwapPve; - QxNextXY.Free; - - SafeAssign( SwapTemp, NextY); SwapPve := NextYpve; - QxNextXY := Quotient.Multiply( NextY); - Cmp := y.Compare( QxNextXY); - if Ypve = NextYpve then - begin - if Cmp in [rGreaterThan, rEqualTo] then - begin - SafeAssign( NextY, y); - NextY.Subtract( QxNextXY); - NextYpve := yPve - end - else - begin - SafeAssign( NextY, QxNextXY); - NextY.Subtract( y); - NextYpve := not yPve - end - end - else - begin - SafeAdd( NextY, y, QxNextXY); - NextYpve := yPve - end; - SafeAssign( y, SwapTemp); - yPve := SwapPve; - QxNextXY.Free; - Quotient.Free; - end; -gcd_factor1 := a.Multiply( x); -gcd_factor2 := b.Multiply( y); -if xPve = yPve then - begin - gcd := THugeCardinal.CreateSimple( 0); - SafeAdd( gcd, gcd_factor1, gcd_factor2); - gcdPve := xPve - end - else if gcd_factor1.Compare( gcd_factor2) in [rGreaterThan, rEqualTo] then - begin - gcd := gcd_factor1.Clone; - gcd.Subtract( gcd_factor2); - gcdPve := xPve - end - else - begin - gcd := gcd_factor2.Clone; - gcd.Subtract( gcd_factor1); - gcdPve := yPve - end; -result := (gcd.CompareSmall( 1) = rEqualTo) and gcdPve; -NextX.Free; -NextY.Free; -a1.Free; -b1.Free; -SwapTemp.Free; -Quotient.Free; -// gcd_factor1.Free; -gcd_factor2.Free -end; - -function Inverse( Prime, Modulus: THugeCardinal; var TestPassed: boolean): THugeCardinal; -// Computes multiplicative inverse of Prime over modulus. -// Assumes: -// Modulus >= 3 -// 2 <= Prime < Modulus -// 'Prime' is a prime number. -var - xPrev: THugeCardinal; - xPrevPve: boolean; - x: THugeCardinal; - xPve: boolean; - r: THugeCardinal; - rPrev: THugeCardinal; - div1: THugeCardinal; - rem1: THugeCardinal; - Delta: THugeCardinal; - xNext: THugeCardinal; - xNextPve: boolean; - Bits: integer; - Pool: IMemoryStreamPool; - Cmp: TCompareResult; - //Tmp: THugeCardinal; - //Ok: boolean; - //s: string; - Dummy1, Dummy2: THugeCardinal; - resultPve, DummyBool2: boolean; - - function IsInverse( Candidate: THugeCardinal): boolean; - var - Tmp2: THugeCardinal; - begin - // result * Prime mod Modulus == 1 - Tmp2 := Candidate.Clone; - Tmp2.MultiplyMod( Prime, Modulus); - result := Tmp2.CompareSmall( 1) = rEqualTo; - Tmp2.Free - end; - - procedure Negate( ModValue: THugeCardinal); - var - Tmp2: THugeCardinal; - begin - Tmp2 := Modulus.Clone; - Tmp2.Subtract( ModValue); - SafeAssign( ModValue, Tmp2); - Tmp2.Free - end; - -begin -Bits := Modulus.BitLength; -Pool := Modulus.FPool; -xPrev := THugeCardinal.CreateZero( Bits, Pool); -xPrevPve := True; -x := THugeCardinal.CreateSmall( 1, Bits, Pool); -xPve := True; -r := Prime.CloneSized( Bits); -rPrev := Modulus.Clone; -div1 := nil; -rem1 := nil; -Delta := nil; -xNext := nil; -try -while (not r.isSmall) or (r.ExtractSmall > 1) do - begin - FreeAndNil( div1); FreeAndNil( rem1); - rPrev.Divide( r, div1, rem1); - rPrev.Assign( r); - r.Assign( rem1); - FreeAndNil( Delta); - Delta := x.Multiply( div1); - FreeAndNil( xNext); - xNext := xPrev.Clone; - if xPve = xPrevPve then - begin - Cmp := xPrev.Compare( Delta); - if Cmp in [rGreaterThan, rEqualTo] then - begin - xNext.Subtract( Delta); - xNextPve := xPve - end - else - begin - xNext.Assign( Delta); - xNext.Subtract( xPrev); - xNextPve := not xPve - end; - end - else - begin - xNext.Add( Delta); - xNextPve := xPrevPve - end; - xPrev.Assign( x); - xPrevPve := xPve; - x.Assign( xNext); - xPve := xNextPve - end -finally -result := x; -xPrev.Free; -r.Free; -rPrev.Free; -div1.Free; -rem1.Free; -Delta.Free; -xNext.Free; -end; - -TestPassed := IsInverse( result); -if not TestPassed then - begin - Negate( result); - TestPassed := IsInverse( result); - end; - -if not TestPassed then - begin - result.Free; - TestPassed := extended_gcd( - Prime, Modulus, result, Dummy1, resultPve, DummyBool2, Dummy2); - // a b x y x+ve y+ve gcd - if not resultPve then - Negate( result); - TestPassed := TestPassed and IsInverse( result); - Dummy1.Free; Dummy2.Free; - end; -end; - - - -function isAllSmallFactors( Number: THugeCardinal): boolean; -var - Rem: THugeCardinal; - j, SmallPrime: integer; - Divisor, Quotient, Remainder: THugeCardinal; -begin -Rem := Number.Clone; -while (not Rem.isZero) and (not Rem.isOdd) do - Rem.MulPower2( -1); -Divisor := THugeCardinal.CreateZero( 0, Number.FPool); -Quotient := nil; -Remainder := nil; -try -for j := Low( SmallPrimes) + 1 to High( SmallPrimes) do - begin - SmallPrime := SmallPrimes[j]; - if (SmallPrime = 0) or - (Rem.CompareSmall( SmallPrime) in [rEqualTo, rLessThan]) then break; - Divisor.AssignSmall( SmallPrime); - repeat - FreeAndNil( Quotient); - FreeAndNil( Remainder); - Rem.Divide( Divisor, Quotient, Remainder); - if Remainder.isZero then - Rem.Assign( Quotient); - until (not Remainder.isZero) or (Rem.Compare( Divisor) in [rEqualTo, rLessThan]) - end; -result := Rem.BitLength <= 16; -finally -Rem.Free; -Divisor.Free; -Quotient.Free; -Remainder.Free -end end; - -function Validate_CRT_Numbers( - n, e, d, p, q, dp, dq, qinv: THugeCardinal): boolean; -var - c, c1, c2: THugeCardinal; - pMinus1, qMinus1: THugeCardinal; - Temp, Totient: THugeCardinal; - InverseIsGood, Ok: boolean; -begin -// dp = d mod (p - 1) -pMinus1 := p.Clone; -pMinus1.Increment( -1); -Temp := d.Modulo( pMinus1); -result := dp.Compare( Temp) = rEqualTo; -Temp.Free; - -// dq = d mod (q - 1) -qMinus1 := q.Clone; -qMinus1.Increment( -1); -Temp := d.Modulo( qMinus1); -Ok := dq.Compare( Temp) = rEqualTo; -result := result and Ok; -Temp.Free; - -// qinv = q ** -1 mod p -Temp := Inverse( q, p, InverseIsGood); -Ok := (qinv.Compare( Temp) = rEqualTo) and InverseIsGood; -result := result and Ok; -Temp.Free; - -// ((qinv * q) mod p) = 1 -Temp := qinv.CloneSized( qinv.BitLength + q.BitLength + 1); -Temp.MultiplyMod( q, p); // but this is p-1 -Ok := Temp.CompareSmall( 1) = rEqualTo; -result := result and Ok; -Temp.Free; - -// n = p * q -Temp := p.Multiply( q); -Ok := Temp.Compare( n) = rEqualTo; -result := result and Ok; -Temp.Free; - -// (d * e) mod (lcm(p-1, q-1))) = 1 -Totient := LCM( pMinus1, qMinus1); -pMinus1.Free; -qMinus1.Free; -Temp := d.Clone; -Temp.MultiplyMod( e, Totient); -Ok := Temp.CompareSmall( 1) = rEqualTo; -result := result and Ok; -Totient.Free; -Temp.Free; - -if not result then exit; - -c := THugeCardinal.CreateRandom( n.BitLength, n.BitLength, False, nil); -c1 := c.Modulo( n); -c2 := c1.Clone; -c.Free; -c1.PowerMod( d, n, nil); -c2.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil); -result := c1.Compare( c2) = rEqualTo; -c1.Free; -c2.Free; -end; - - -procedure Compute_RSA_Fundamentals_2Factors( - RequiredBitLengthOfN: integer; - Fixed_e: uint64; // Put as -1 to generate a random number. - // A value of StandardExponent is recommended. - var N, e, d, Totient: THugeCardinal; - var p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. - OnProgress: TProgress; - OnPrimalityTest: TPrimalityTestNoticeProc; - GeneratePrimePassCount: integer; // 1 .. 20; 20 is good. - const Pool1: IMemoryStreamPool; - var NumbersTested: integer; - var wasAborted: boolean); -// Refer: http://en.wikipedia.org/wiki/Rsa#Key_generation_2 -// This could easily be adapted to multiple factors, but for the -// time being, two will do. -// At the moment CRT exponents and co-efficients are not returned. -// In future, speed improvements could be made to Signature and Descryption -// operations by leveraging the Chinese Remainder Theroum (CRT). - - procedure CopyHugeCard( var Dest: THugeCardinal; Source: THugeCardinal); - begin - if assigned( Dest) and (Dest.MaxBits >= Source.BitLength) then - Dest.Assign( Source) - else - begin - FreeAndNil( Dest); - Dest := Source.Clone - end - end; - -var - p_bits, q_bits: integer; - pMinus1, qMinus1: THugeCardinal; - Dummy: integer; - e_TrashCopy, Totient_TrashCopy: THugeCardinal; - Ok, InverseIsGood: boolean; - -begin -// Algorithm to generate RSA fundamental numbers: -// 1. Compute p bits p.bits := n.bits div 2 + 2; -// 2. Compute q bits q.bits := n.bits div 2 - 2; -// 3. Compute p & p-1 p := Random Prime with exactly p.bits bits. -// 4. Test for Pollard attack on p Check (p-1) is not ONLY small factors. -// 5. Compute q & q-1 q := Random Prime with exactly q.bits bits. -// 6. Test for Pollard attack on q Check (q-1) is not ONLY small factors. -// 7. Compute Totient (Carmichael function) := lcm( p-1, q-1) -// 8. Compute n := p * q; -// 9. Test N.Bits not too small n.bits should not be 16 or more, smaller than the target. -// 10. Compute e e := 65537 -// 10.5 Test that e and Totient are co-prime. -// 11. Compute d d := Inverse( e, Totient); -// 12. Test Wiener attack on d Checks d.bits >= ((n.bits div 4) + 4) -// If any test fails, loop back to step 3 and retry. -// If user abort at any point, then break loop. - - -dp := nil; -dq := nil; -qinv:= nil; -Assert( RequiredBitLengthOfN >= 32, AS_HugeCardinal_N_tooSmall); -Assert( RequiredBitLengthOfN <= 32768, AS_HugeCardinal_N_tooBig); -if Fixed_e <> -1 then - Assert( (RequiredBitLengthOfN - BitCount_64( Fixed_e)) >= 16, - AS_HugeCardinal_N_tooSmall_for_n); -p := nil; -q := nil; -dp := nil; -dq := nil; -qinv := nil; -pMinus1 := nil; -qMinus1 := nil; -wasAborted := False; -N := nil; -e := nil; -d := nil; -Totient := nil; -Dummy := 0; -e_TrashCopy := nil; -Totient_TrashCopy := nil; - -// Steps 1 & 2; -q_bits := (RequiredBitLengthOfN div 2) - 2; -p_bits := RequiredBitLengthOfN - q_bits; - -try try -repeat - // Step 3 - FreeAndNil( p); - wasAborted := not GeneratePrime( - p_bits, OnProgress, OnPrimalityTest, GeneratePrimePassCount, Pool1, - p, NumbersTested); - if wasAborted then break; - CopyHugeCard( pMinus1, p); - pMinus1.Increment( -1); - - // Step 4 test: Test for Pollard attack on p - if isAllSmallFactors( pMinus1) then - continue; - - // Step 5 - FreeAndNil( q); - wasAborted := not GeneratePrime( - q_bits, OnProgress, OnPrimalityTest, GeneratePrimePassCount, Pool1, - q, NumbersTested); - if wasAborted then break; - CopyHugeCard( qMinus1, q); - qMinus1.Increment( -1); - - // Step 6 test: Test for Pollard attack on q - if isAllSmallFactors( qMinus1) then - continue; - - // Step 7. - FreeAndNil( Totient); - Totient := lcm( pMinus1, qMinus1); - - // Step 8. - FreeAndNil( n); - n := p.Multiply( q); - - // Step 9 - if (RequiredBitLengthOfN - n.BitLength) >= 16 then - continue; - - // Step 10 - if not assigned( e) then - begin - if Fixed_e = -1 then - // We require e and Totient to be co-prime. - // e does not have to be prime, however, its just easier - // to generate a small prime number. - GeneratePrime( 18, nil, nil, 10, Pool1, e, Dummy) - else - e := THugeCardinal.CreateSmall( Fixed_e, 0, Pool1); - // The popular choice for Fixed_e is 2**16+1 - end; - - // Step 10.5 - // For a specified choice of e, check that e is co-prime to the Totient. - if Fixed_e <> -1 then - begin - e_TrashCopy := e.Clone; - Totient_TrashCopy := Totient.Clone; - try - Ok := isCoPrime( e_TrashCopy, Totient_TrashCopy); - finally - FreeAndNil( e_TrashCopy); - FreeAndNil( Totient_TrashCopy) - end; - if not Ok then - continue // Totient not compatible with e. Try another totient! - end; - - // Step 11. - FreeAndNil( d); - d := Inverse( e, Totient, InverseIsGood); - - // 12. Test Wiener attack on d Checks d.bits >= ((n.bits div 4) + 4) - if d.BitLength < ((n.BitLength div 4) + 4) then - continue; - - // The Sanity Clause. - // Two more tests... - // Test: e * d (mod Totient) == 1 - // Test: m**e**d = m where m is a random number. 1 trial. - // TO DO: Boost the number of inversion trials (2nd test). - if not Validate_RSA_Fundamentals( n, e, d, Totient) then - begin - // This can happen if we get bad luck with False Primality Witnesses. - // Some-what counter-intuitively, this event seems to be more frequent - // with lower key sizes. - Inc( RSA_FailCount); - continue - end; - - // Prior to CRT implementation, we compute just: - // e := 65537 -- set at higher level. - // n := p * q -- step 8. - // d := e ** -1 mod Phi(n) -- step 11. - - // But now with CRT, we need additionally: - // dp := d mod p-1 - // dq := d mod q-1 - // qinv := q ** -1 mod p - - FreeAndNil( dp); - CopyHugeCard( pMinus1, p); - pMinus1.Increment( -1); - dp := d.Modulo( pMinus1); - - FreeAndNil( dq); - CopyHugeCard( qMinus1, q); - qMinus1.Increment( -1); - dq := d.Modulo( qMinus1); - FreeAndNil( qinv); - qinv := Inverse( q, p, InverseIsGood); - if Validate_CRT_Numbers( n, e, d, p, q, dp, dq, qinv) then - break -until wasAborted -finally - FreeAndNil( pMinus1); FreeAndNil( qMinus1) - end; -except - begin - FreeAndNil( N); - FreeAndNil( e); - FreeAndNil( d); - FreeAndNil( p); FreeAndNil( q); - FreeAndNil( dp); FreeAndNil( dq); FreeAndNil( qinv); - FreeAndNil( Totient); - raise - end - end -end; - - -function Validate_RSA_Fundamentals( - var N, e, d, Totient: THugeCardinal): boolean; -var - TestVector, Reconstruction: THugeCardinal; - eCopy: THugeCardinal; -begin -if assigned( Totient) then - begin - // Test: e * d (mod Totient) == 1 - ecopy := e.CloneSized( N.BitLength); - ecopy.MultiplyMod( d, Totient); - result := ecopy.isSmall and (ecopy.ExtractSmall = 1); - FreeAndNil( ecopy) - end - else - result := True; -if not result then exit; - -// Test for: m**e**d = m -try - TestVector := THugeCardinal.CreateZero( N.BitLength, N.FPool); - try - TestVector.Random( N); - Reconstruction := TestVector.Clone; - try - Reconstruction.PowerMod( e, N, nil); - Reconstruction.PowerMod( d, N, nil); - result := TestVector.Compare( Reconstruction) = rEqualTo - finally - Reconstruction.Free - end - finally - TestVector.Free - end -except - result := False - end -end; - -initialization -InitUnit_HugeCardinalUtils; - - -finalization -DoneUnit_HugeCardinalUtils; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.HugeCardinalUtils; +interface +uses TPLB3.HugeCardinal, TPLB3.MemoryStreamPool; + + +type +TPrimalityTestNoticeProc = procedure( CountPrimalityTests: integer) of object; + +function gcd( a, b: THugeCardinal): THugeCardinal; +// Computes the Greatest Common Divisor of a and b. +// A and b may be trashed as a result. +// The result is a new object. + + +function lcm( a, b: THugeCardinal): THugeCardinal; +// Computes the Least Common Multiple of a and b. +// A and b may be trashed as a result. +// The result is a new object. + + +function isCoPrime( a, b: THugeCardinal): boolean; +// Returns True if and only if a and b are co-prime. +// A and b may be trashed as a result. + + +function isProbablyPrime( p: THugeCardinal; OnProgress: TProgress; var wasAborted: boolean): boolean; +// True means that p is almost certainly prime. +// False means that p is composite. +// The Fermat Primality test is used with only 1 pass. +// p is preserved. + + +function hasSmallFactor( p: THugeCardinal): boolean; +// True means that p does not have a small factor. +// It is a good candidate for testing for primality. +// False means that p is composite, and indeed, at least one of its +// factors is a small number. + + +function GeneratePrime( NumBits: integer; + OnProgress: TProgress; + OnPrimalityTest: TPrimalityTestNoticeProc; + PassCount: integer; + const Pool1: IMemoryStreamPool; + var Prime: THugeCardinal; + var NumbersTested: integer): boolean; +// Returns True if Prime was succesfully generated. +// Returns False if user aborted. +// On input, Prime is nil. +// Upon output, if user did not abort, Prime is a prime number +// of NumBits bits. PassCount passes of the Fermat Primality test +// are used to test primality of random candidates. + + +function Inverse( Prime, Modulus: THugeCardinal; var TestPassed: boolean): THugeCardinal; +// Computes multiplicative inverse of Prime over modulus. +// Assumes: +// Modulus >= 3 +// 2 <= Prime < Modulus +// 'Prime' is a prime number. + + +const + StandardExponent = 65537; + +procedure Compute_RSA_Fundamentals_2Factors( + RequiredBitLengthOfN: integer; + Fixed_e: uint64; // Put as -1 to generate a random number. + // A value of StandardExponent is recommended. + var N, e, d, Totient: THugeCardinal; + var p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. + OnProgress: TProgress; + OnPrimalityTest: TPrimalityTestNoticeProc; + GeneratePrimePassCount: integer; // 1 .. 20; + const Pool1: IMemoryStreamPool; + var NumbersTested: integer; + var wasAborted: boolean); + + +function Validate_RSA_Fundamentals( + var N, e, d, Totient: THugeCardinal): boolean; + + +var + GreatestPassCount: integer = 0; // Investigative tool used for tweeking the algorithm. + RSA_FailCount: integer = 0; + +implementation + + + + + + + + + + + + +uses SysUtils, Classes, TPLB3.PointerArithmetic, TPLB3.IntegerUtils, + TPLB3.I18n, Math; + +const + SmallPrimeSetCardinality = 200; + EratosthenesSieveSize = 2000; // Must choose value such that: + // SmallPrimeSetCardinality'th prime number < EratosthenesSieveSize + +var + SmallPrimes: array[ 0.. SmallPrimeSetCardinality-1] of integer; + + +procedure PreComputeSmallPrimes; forward; +// The above computes the set of small prime numbers. + +procedure InitUnit_HugeCardinalUtils; +begin +FillChar( SmallPrimes, SizeOf( SmallPrimes), 0); +PreComputeSmallPrimes +end; + + +procedure DoneUnit_HugeCardinalUtils; +begin +end; + + +procedure PreComputeSmallPrimes; +// Uses the sieve of Eratosthenes algorithm. +var + p, j, k: integer; + Numbers: TBits; +begin +p := 2; +Numbers := TBits.Create; +try +Numbers.Size := EratosthenesSieveSize; +// Numbers[j] = False means that j is possibly prime. +// Numbers[j] = True means that j is composite. +for j := 0 to SmallPrimeSetCardinality-1 do + begin + // p is a prime. + k := 2 * p; + while k < EratosthenesSieveSize do + begin + Numbers[k] := True; + Inc( k, p) + end; + SmallPrimes[j] := p; + repeat + Inc( p) + until (p >= EratosthenesSieveSize) or (not Numbers[p]); + if p >= EratosthenesSieveSize then + raise Exception.CreateFmt( + ES_EratosthenesSievSizeTooSmall, + [EratosthenesSieveSize, SmallPrimeSetCardinality]) + end; +finally +Numbers.Free +end end; + + + +function gcd( a, b: THugeCardinal): THugeCardinal; +// Uses Stein's algorithm. +// TO DO: Implement an alternate implementation using Euclid and +// measure the performance difference. +var + ResultBitShifts: integer; + isA_Odd, isB_Odd: boolean; +begin +ResultBitShifts := 0; +result := nil; +repeat + if a.isZero then + result := b + else if b.isZero then + result := a + else + begin + isA_Odd := a.isOdd; + isB_Odd := b.isOdd; + if (not isA_Odd) and (not isB_Odd) then + begin + Inc( ResultBitShifts); + a.MulPower2( -1); // a := a / 2; + b.MulPower2( -1); // b := b / 2; + end + + else if isA_Odd and (not isB_odd) then + b.MulPower2( -1) + + else if (not isA_Odd) and isB_odd then + a.MulPower2( -1) + + else + case a.Compare( b) of + rGreaterThan: + begin + a.Subtract( b); + a.MulPower2( -1) + end; + + rEqualTo: + result := a; + + rLessThan: + begin + b.Subtract( a); + b.MulPower2( -1) + end; + end; + end; +until Assigned( result); +result := result.CloneSized( result.BitLength + ResultBitShifts); +result.MulPower2( ResultBitShifts) +end; + + +function lcm( a, b: THugeCardinal): THugeCardinal; +var + gcd1, Temp, Quotient, Remainder: THugeCardinal; +begin +Quotient := nil; +Remainder := nil; +result := a.Multiply( b); +gcd1 := gcd( a, b); +try +if (not gcd1.isSmall) or (gcd1.ExtractSmall <> 1) then + begin + result.Divide( gcd1, Quotient, Remainder); + Assert( Remainder.isZero, AS_LCM_Fail); + Temp := result; + result := Quotient; + Quotient := Temp + end +finally + gcd1.Free; + Quotient.Free; + Remainder.Free +end end; + + + +function isCoPrime( a, b: THugeCardinal): boolean; +var + gcd1: THugeCardinal; +begin +gcd1 := gcd( a, b); +result := gcd1.isSmall and (gcd1.ExtractSmall = 1); +gcd1.Free +end; + + +function isProbablyPrime( p: THugeCardinal; OnProgress: TProgress; var wasAborted: boolean): boolean; +var + Witness: THugeCardinal; + pMinusOne: THugeCardinal; +begin +pMinusOne := nil; +wasAborted := False; +if p.isSmall and (p.ExtractSmall <= 3) then + begin + result := True; + exit + end; +Witness := nil; +try +repeat + FreeAndNil( Witness); + Witness := THugeCardinal.CreateZero( p.BitLength, p.FPool); + Witness.Random( p); +until (not Witness.isSmall) or (Witness.ExtractSmall > 1); +// 2 <= Witness < p +pMinusOne := p.Clone; +try +pMinusOne.Increment( -1); +wasAborted := not Witness.PowerMod( pMinusOne, p, OnProgress); +// isPrime := (Witness ** (p-1) mod p) = 1 +result := Witness.isSmall and (Witness.ExtractSmall = 1) +finally +Witness.Free +end +finally +pMinusOne.Free +end +end; + + + + +function hasSmallFactor( p: THugeCardinal): boolean; +var + j, q: integer; + Modulus, TestValue, TestValue2: THugeCardinal; + doSmallTest: boolean; + pValue: uint64; +begin +result := not p.isOdd; +if result then exit; +doSmallTest := p.isSmall; +if doSmallTest then + pValue := p.ExtractSmall + else + pValue := 0; +Modulus := THugeCardinal.CreateZero( 0, p.FPool); +TestValue := THugeCardinal.CreateZero( p.MaxBits, p.FPool); +try + for j := 1 to SmallPrimeSetCardinality-1 do + begin + q := SmallPrimes[j]; // q is a small prime number. + if doSmallTest and (q >= pValue) then break; + Modulus.AssignSmall( q); + TestValue.Assign( p); + TestValue2 := TestValue.Modulo( Modulus); + result := TestValue2.isZero; + TestValue2.Free; + if result then break + end +finally + Modulus.Free; + TestValue.Free + end +end; + + +function GeneratePrime( NumBits: integer; + OnProgress: TProgress; + OnPrimalityTest: TPrimalityTestNoticeProc; + PassCount: integer; + const Pool1: IMemoryStreamPool; + var Prime: THugeCardinal; + var NumbersTested: integer): boolean; +// Returns True if Prime was succesfully generated. +// Returns False if user aborted. +const + PrimeDeltas: array[ 0..7 ] of integer = (6, 4, 2, 4, 2, 2, 6, 2); +var + Thirty, Temp, Temp2: THugeCardinal; + Delta: int64; + Idx, j: integer; + FoundPrime: boolean; + wasAborted: boolean; +begin +if PassCount <= 0 then + PassCount := 1; +if PassCount > 20 then + PassCount := 20; +// generate p1 +Prime := THugeCardinal.CreateRandom( NumBits, NumBits + 2, True, Pool1); +Thirty := THugeCardinal.CreateSmall( 30, 0, Pool1); +Temp := nil; Temp2 := nil; +try + Temp := Prime.Clone; + Temp2 := Temp.Modulo( Thirty); + Delta := 31 - Temp2.ExtractSmall; +finally + Thirty.Free; + Temp.Free; Temp2.Free + end; +// p := p1 - (p1 mod 30) + 1; +Prime.Increment( Delta); +// So now, p mod 30 = 1 + +// i := 0; +Idx := 0; +result := True; +wasAborted := False; +repeat + FoundPrime := not hasSmallFactor( Prime); + if FoundPrime then + for j := 1 to PassCount do + begin + FoundPrime := isProbablyPrime( Prime, OnProgress, wasAborted); + result := not wasAborted; + if result and (not FoundPrime) and (j > GreatestPassCount) then + GreatestPassCount := j; + if (not FoundPrime) or (not result) then break; + end; + Inc( NumbersTested); + if (not wasAborted) and assigned( OnPrimalityTest) then + OnPrimalityTest( NumbersTested); + if FoundPrime or (not result) then break; + // This candidate failed, so try the next likely one. + // p += (6,4,2,4,2,2,6,2)[i]; + Delta := PrimeDeltas[ Idx]; + Prime.Increment( Delta); + if Idx >= 7 then + Idx := 0 + else + Inc( Idx) +until FoundPrime or (not result); +if not result then + FreeAndNil( Prime) +end; + + +function extended_gcd( a, b: THugeCardinal; + var x, y: THugeCardinal; + var xPve, yPve: boolean; + var gcd : THugeCardinal): boolean; +// Solve: +// a*x + b*y = gcd(a,b) +// Using Extended Euclidean algorithm. +var + NextX, NextY, a1, b1, SwapTemp: THugeCardinal; + Quotient, Remainder: THugeCardinal; + NextXpve, NextYpve, SwapPve: boolean; + QxNextXY: THugeCardinal; + Cmp: TCompareResult; + gcd_factor1, gcd_factor2: THugeCardinal; + gcdPve: boolean; +// s: string; + +begin +NextX := THugeCardinal.CreateSimple(0); NextXpve := True; +x := THugeCardinal.CreateSimple(1); xPve := True; +NextY := THugeCardinal.CreateSimple(1); NextYpve := True; +y := THugeCardinal.CreateSimple(0); yPve := True; +a1 := a.Clone; +b1 := b.Clone; +SwapTemp := THugeCardinal.CreateSimple( 0); +while not b1.isZero do + begin + a1.Divide( b1, Quotient, Remainder); + SafeAssign( a1, b1); + b1.Free; + b1 := Remainder; + Remainder := nil; + + SafeAssign( SwapTemp, NextX); SwapPve := NextXpve; + QxNextXY := Quotient.Multiply( NextX); + Cmp := x.Compare( QxNextXY); + if Xpve = NextXpve then + begin + if Cmp in [rGreaterThan, rEqualTo] then + begin + SafeAssign( NextX, x); + NextX.Subtract( QxNextXY); + NextXpve := xPve + end + else + begin + SafeAssign( NextX, QxNextXY); + NextX.Subtract( x); + NextXpve := not xPve + end + end + else + begin + SafeAdd( NextX, x, QxNextXY); + NextXpve := xPve + end; + SafeAssign( x, SwapTemp); + xPve := SwapPve; + QxNextXY.Free; + + SafeAssign( SwapTemp, NextY); SwapPve := NextYpve; + QxNextXY := Quotient.Multiply( NextY); + Cmp := y.Compare( QxNextXY); + if Ypve = NextYpve then + begin + if Cmp in [rGreaterThan, rEqualTo] then + begin + SafeAssign( NextY, y); + NextY.Subtract( QxNextXY); + NextYpve := yPve + end + else + begin + SafeAssign( NextY, QxNextXY); + NextY.Subtract( y); + NextYpve := not yPve + end + end + else + begin + SafeAdd( NextY, y, QxNextXY); + NextYpve := yPve + end; + SafeAssign( y, SwapTemp); + yPve := SwapPve; + QxNextXY.Free; + Quotient.Free; + end; +gcd_factor1 := a.Multiply( x); +gcd_factor2 := b.Multiply( y); +if xPve = yPve then + begin + gcd := THugeCardinal.CreateSimple( 0); + SafeAdd( gcd, gcd_factor1, gcd_factor2); + gcdPve := xPve + end + else if gcd_factor1.Compare( gcd_factor2) in [rGreaterThan, rEqualTo] then + begin + gcd := gcd_factor1.Clone; + gcd.Subtract( gcd_factor2); + gcdPve := xPve + end + else + begin + gcd := gcd_factor2.Clone; + gcd.Subtract( gcd_factor1); + gcdPve := yPve + end; +result := (gcd.CompareSmall( 1) = rEqualTo) and gcdPve; +NextX.Free; +NextY.Free; +a1.Free; +b1.Free; +SwapTemp.Free; +Quotient.Free; +// gcd_factor1.Free; +gcd_factor2.Free +end; + +function Inverse( Prime, Modulus: THugeCardinal; var TestPassed: boolean): THugeCardinal; +// Computes multiplicative inverse of Prime over modulus. +// Assumes: +// Modulus >= 3 +// 2 <= Prime < Modulus +// 'Prime' is a prime number. +var + xPrev: THugeCardinal; + xPrevPve: boolean; + x: THugeCardinal; + xPve: boolean; + r: THugeCardinal; + rPrev: THugeCardinal; + div1: THugeCardinal; + rem1: THugeCardinal; + Delta: THugeCardinal; + xNext: THugeCardinal; + xNextPve: boolean; + Bits: integer; + Pool: IMemoryStreamPool; + Cmp: TCompareResult; + //Tmp: THugeCardinal; + //Ok: boolean; + //s: string; + Dummy1, Dummy2: THugeCardinal; + resultPve, DummyBool2: boolean; + + function IsInverse( Candidate: THugeCardinal): boolean; + var + Tmp2: THugeCardinal; + begin + // result * Prime mod Modulus == 1 + Tmp2 := Candidate.Clone; + Tmp2.MultiplyMod( Prime, Modulus); + result := Tmp2.CompareSmall( 1) = rEqualTo; + Tmp2.Free + end; + + procedure Negate( ModValue: THugeCardinal); + var + Tmp2: THugeCardinal; + begin + Tmp2 := Modulus.Clone; + Tmp2.Subtract( ModValue); + SafeAssign( ModValue, Tmp2); + Tmp2.Free + end; + +begin +Bits := Modulus.BitLength; +Pool := Modulus.FPool; +xPrev := THugeCardinal.CreateZero( Bits, Pool); +xPrevPve := True; +x := THugeCardinal.CreateSmall( 1, Bits, Pool); +xPve := True; +r := Prime.CloneSized( Bits); +rPrev := Modulus.Clone; +div1 := nil; +rem1 := nil; +Delta := nil; +xNext := nil; +try +while (not r.isSmall) or (r.ExtractSmall > 1) do + begin + FreeAndNil( div1); FreeAndNil( rem1); + rPrev.Divide( r, div1, rem1); + rPrev.Assign( r); + r.Assign( rem1); + FreeAndNil( Delta); + Delta := x.Multiply( div1); + FreeAndNil( xNext); + xNext := xPrev.Clone; + if xPve = xPrevPve then + begin + Cmp := xPrev.Compare( Delta); + if Cmp in [rGreaterThan, rEqualTo] then + begin + xNext.Subtract( Delta); + xNextPve := xPve + end + else + begin + xNext.Assign( Delta); + xNext.Subtract( xPrev); + xNextPve := not xPve + end; + end + else + begin + xNext.Add( Delta); + xNextPve := xPrevPve + end; + xPrev.Assign( x); + xPrevPve := xPve; + x.Assign( xNext); + xPve := xNextPve + end +finally +result := x; +xPrev.Free; +r.Free; +rPrev.Free; +div1.Free; +rem1.Free; +Delta.Free; +xNext.Free; +end; + +TestPassed := IsInverse( result); +if not TestPassed then + begin + Negate( result); + TestPassed := IsInverse( result); + end; + +if not TestPassed then + begin + result.Free; + TestPassed := extended_gcd( + Prime, Modulus, result, Dummy1, resultPve, DummyBool2, Dummy2); + // a b x y x+ve y+ve gcd + if not resultPve then + Negate( result); + TestPassed := TestPassed and IsInverse( result); + Dummy1.Free; Dummy2.Free; + end; +end; + + + +function isAllSmallFactors( Number: THugeCardinal): boolean; +var + Rem: THugeCardinal; + j, SmallPrime: integer; + Divisor, Quotient, Remainder: THugeCardinal; +begin +Rem := Number.Clone; +while (not Rem.isZero) and (not Rem.isOdd) do + Rem.MulPower2( -1); +Divisor := THugeCardinal.CreateZero( 0, Number.FPool); +Quotient := nil; +Remainder := nil; +try +for j := Low( SmallPrimes) + 1 to High( SmallPrimes) do + begin + SmallPrime := SmallPrimes[j]; + if (SmallPrime = 0) or + (Rem.CompareSmall( SmallPrime) in [rEqualTo, rLessThan]) then break; + Divisor.AssignSmall( SmallPrime); + repeat + FreeAndNil( Quotient); + FreeAndNil( Remainder); + Rem.Divide( Divisor, Quotient, Remainder); + if Remainder.isZero then + Rem.Assign( Quotient); + until (not Remainder.isZero) or (Rem.Compare( Divisor) in [rEqualTo, rLessThan]) + end; +result := Rem.BitLength <= 16; +finally +Rem.Free; +Divisor.Free; +Quotient.Free; +Remainder.Free +end end; + +function Validate_CRT_Numbers( + n, e, d, p, q, dp, dq, qinv: THugeCardinal): boolean; +var + c, c1, c2: THugeCardinal; + pMinus1, qMinus1: THugeCardinal; + Temp, Totient: THugeCardinal; + InverseIsGood, Ok: boolean; +begin +// dp = d mod (p - 1) +pMinus1 := p.Clone; +pMinus1.Increment( -1); +Temp := d.Modulo( pMinus1); +result := dp.Compare( Temp) = rEqualTo; +Temp.Free; + +// dq = d mod (q - 1) +qMinus1 := q.Clone; +qMinus1.Increment( -1); +Temp := d.Modulo( qMinus1); +Ok := dq.Compare( Temp) = rEqualTo; +result := result and Ok; +Temp.Free; + +// qinv = q ** -1 mod p +Temp := Inverse( q, p, InverseIsGood); +Ok := (qinv.Compare( Temp) = rEqualTo) and InverseIsGood; +result := result and Ok; +Temp.Free; + +// ((qinv * q) mod p) = 1 +Temp := qinv.CloneSized( qinv.BitLength + q.BitLength + 1); +Temp.MultiplyMod( q, p); // but this is p-1 +Ok := Temp.CompareSmall( 1) = rEqualTo; +result := result and Ok; +Temp.Free; + +// n = p * q +Temp := p.Multiply( q); +Ok := Temp.Compare( n) = rEqualTo; +result := result and Ok; +Temp.Free; + +// (d * e) mod (lcm(p-1, q-1))) = 1 +Totient := LCM( pMinus1, qMinus1); +pMinus1.Free; +qMinus1.Free; +Temp := d.Clone; +Temp.MultiplyMod( e, Totient); +Ok := Temp.CompareSmall( 1) = rEqualTo; +result := result and Ok; +Totient.Free; +Temp.Free; + +if not result then exit; + +c := THugeCardinal.CreateRandom( n.BitLength, n.BitLength, False, nil); +c1 := c.Modulo( n); +c2 := c1.Clone; +c.Free; +c1.PowerMod( d, n, nil); +c2.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil); +result := c1.Compare( c2) = rEqualTo; +c1.Free; +c2.Free; +end; + + +procedure Compute_RSA_Fundamentals_2Factors( + RequiredBitLengthOfN: integer; + Fixed_e: uint64; // Put as -1 to generate a random number. + // A value of StandardExponent is recommended. + var N, e, d, Totient: THugeCardinal; + var p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. + OnProgress: TProgress; + OnPrimalityTest: TPrimalityTestNoticeProc; + GeneratePrimePassCount: integer; // 1 .. 20; 20 is good. + const Pool1: IMemoryStreamPool; + var NumbersTested: integer; + var wasAborted: boolean); +// Refer: http://en.wikipedia.org/wiki/Rsa#Key_generation_2 +// This could easily be adapted to multiple factors, but for the +// time being, two will do. +// At the moment CRT exponents and co-efficients are not returned. +// In future, speed improvements could be made to Signature and Descryption +// operations by leveraging the Chinese Remainder Theroum (CRT). + + procedure CopyHugeCard( var Dest: THugeCardinal; Source: THugeCardinal); + begin + if assigned( Dest) and (Dest.MaxBits >= Source.BitLength) then + Dest.Assign( Source) + else + begin + FreeAndNil( Dest); + Dest := Source.Clone + end + end; + +var + p_bits, q_bits: integer; + pMinus1, qMinus1: THugeCardinal; + Dummy: integer; + e_TrashCopy, Totient_TrashCopy: THugeCardinal; + Ok, InverseIsGood: boolean; + +begin +// Algorithm to generate RSA fundamental numbers: +// 1. Compute p bits p.bits := n.bits div 2 + 2; +// 2. Compute q bits q.bits := n.bits div 2 - 2; +// 3. Compute p & p-1 p := Random Prime with exactly p.bits bits. +// 4. Test for Pollard attack on p Check (p-1) is not ONLY small factors. +// 5. Compute q & q-1 q := Random Prime with exactly q.bits bits. +// 6. Test for Pollard attack on q Check (q-1) is not ONLY small factors. +// 7. Compute Totient (Carmichael function) := lcm( p-1, q-1) +// 8. Compute n := p * q; +// 9. Test N.Bits not too small n.bits should not be 16 or more, smaller than the target. +// 10. Compute e e := 65537 +// 10.5 Test that e and Totient are co-prime. +// 11. Compute d d := Inverse( e, Totient); +// 12. Test Wiener attack on d Checks d.bits >= ((n.bits div 4) + 4) +// If any test fails, loop back to step 3 and retry. +// If user abort at any point, then break loop. + + +dp := nil; +dq := nil; +qinv:= nil; +Assert( RequiredBitLengthOfN >= 32, AS_HugeCardinal_N_tooSmall); +Assert( RequiredBitLengthOfN <= 32768, AS_HugeCardinal_N_tooBig); +if Fixed_e <> -1 then + Assert( (RequiredBitLengthOfN - BitCount_64( Fixed_e)) >= 16, + AS_HugeCardinal_N_tooSmall_for_n); +p := nil; +q := nil; +dp := nil; +dq := nil; +qinv := nil; +pMinus1 := nil; +qMinus1 := nil; +wasAborted := False; +N := nil; +e := nil; +d := nil; +Totient := nil; +Dummy := 0; +e_TrashCopy := nil; +Totient_TrashCopy := nil; + +// Steps 1 & 2; +q_bits := (RequiredBitLengthOfN div 2) - 2; +p_bits := RequiredBitLengthOfN - q_bits; + +try try +repeat + // Step 3 + FreeAndNil( p); + wasAborted := not GeneratePrime( + p_bits, OnProgress, OnPrimalityTest, GeneratePrimePassCount, Pool1, + p, NumbersTested); + if wasAborted then break; + CopyHugeCard( pMinus1, p); + pMinus1.Increment( -1); + + // Step 4 test: Test for Pollard attack on p + if isAllSmallFactors( pMinus1) then + continue; + + // Step 5 + FreeAndNil( q); + wasAborted := not GeneratePrime( + q_bits, OnProgress, OnPrimalityTest, GeneratePrimePassCount, Pool1, + q, NumbersTested); + if wasAborted then break; + CopyHugeCard( qMinus1, q); + qMinus1.Increment( -1); + + // Step 6 test: Test for Pollard attack on q + if isAllSmallFactors( qMinus1) then + continue; + + // Step 7. + FreeAndNil( Totient); + Totient := lcm( pMinus1, qMinus1); + + // Step 8. + FreeAndNil( n); + n := p.Multiply( q); + + // Step 9 + if (RequiredBitLengthOfN - n.BitLength) >= 16 then + continue; + + // Step 10 + if not assigned( e) then + begin + if Fixed_e = -1 then + // We require e and Totient to be co-prime. + // e does not have to be prime, however, its just easier + // to generate a small prime number. + GeneratePrime( 18, nil, nil, 10, Pool1, e, Dummy) + else + e := THugeCardinal.CreateSmall( Fixed_e, 0, Pool1); + // The popular choice for Fixed_e is 2**16+1 + end; + + // Step 10.5 + // For a specified choice of e, check that e is co-prime to the Totient. + if Fixed_e <> -1 then + begin + e_TrashCopy := e.Clone; + Totient_TrashCopy := Totient.Clone; + try + Ok := isCoPrime( e_TrashCopy, Totient_TrashCopy); + finally + FreeAndNil( e_TrashCopy); + FreeAndNil( Totient_TrashCopy) + end; + if not Ok then + continue // Totient not compatible with e. Try another totient! + end; + + // Step 11. + FreeAndNil( d); + d := Inverse( e, Totient, InverseIsGood); + + // 12. Test Wiener attack on d Checks d.bits >= ((n.bits div 4) + 4) + if d.BitLength < ((n.BitLength div 4) + 4) then + continue; + + // The Sanity Clause. + // Two more tests... + // Test: e * d (mod Totient) == 1 + // Test: m**e**d = m where m is a random number. 1 trial. + // TO DO: Boost the number of inversion trials (2nd test). + if not Validate_RSA_Fundamentals( n, e, d, Totient) then + begin + // This can happen if we get bad luck with False Primality Witnesses. + // Some-what counter-intuitively, this event seems to be more frequent + // with lower key sizes. + Inc( RSA_FailCount); + continue + end; + + // Prior to CRT implementation, we compute just: + // e := 65537 -- set at higher level. + // n := p * q -- step 8. + // d := e ** -1 mod Phi(n) -- step 11. + + // But now with CRT, we need additionally: + // dp := d mod p-1 + // dq := d mod q-1 + // qinv := q ** -1 mod p + + FreeAndNil( dp); + CopyHugeCard( pMinus1, p); + pMinus1.Increment( -1); + dp := d.Modulo( pMinus1); + + FreeAndNil( dq); + CopyHugeCard( qMinus1, q); + qMinus1.Increment( -1); + dq := d.Modulo( qMinus1); + FreeAndNil( qinv); + qinv := Inverse( q, p, InverseIsGood); + if Validate_CRT_Numbers( n, e, d, p, q, dp, dq, qinv) then + break +until wasAborted +finally + FreeAndNil( pMinus1); FreeAndNil( qMinus1) + end; +except + begin + FreeAndNil( N); + FreeAndNil( e); + FreeAndNil( d); + FreeAndNil( p); FreeAndNil( q); + FreeAndNil( dp); FreeAndNil( dq); FreeAndNil( qinv); + FreeAndNil( Totient); + raise + end + end +end; + + +function Validate_RSA_Fundamentals( + var N, e, d, Totient: THugeCardinal): boolean; +var + TestVector, Reconstruction: THugeCardinal; + eCopy: THugeCardinal; +begin +if assigned( Totient) then + begin + // Test: e * d (mod Totient) == 1 + ecopy := e.CloneSized( N.BitLength); + ecopy.MultiplyMod( d, Totient); + result := ecopy.isSmall and (ecopy.ExtractSmall = 1); + FreeAndNil( ecopy) + end + else + result := True; +if not result then exit; + +// Test for: m**e**d = m +try + TestVector := THugeCardinal.CreateZero( N.BitLength, N.FPool); + try + TestVector.Random( N); + Reconstruction := TestVector.Clone; + try + Reconstruction.PowerMod( e, N, nil); + Reconstruction.PowerMod( d, N, nil); + result := TestVector.Compare( Reconstruction) = rEqualTo + finally + Reconstruction.Free + end + finally + TestVector.Free + end +except + result := False + end +end; + +initialization +InitUnit_HugeCardinalUtils; + + +finalization +DoneUnit_HugeCardinalUtils; + +end. diff --git a/run/TPLB3.I18n.pas b/LockBox3/run/TPLB3.I18n.pas similarity index 97% rename from run/TPLB3.I18n.pas rename to LockBox3/run/TPLB3.I18n.pas index 17049dd..f03ae4e 100644 --- a/run/TPLB3.I18n.pas +++ b/LockBox3/run/TPLB3.I18n.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,117 +12,117 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.I18n; - -interface - -resourcestring - -// Exception messages -ES_NoPassword = 'TSimpleCodec.Init - No password.'; -ES_AsymPassword = 'TSimpleCodec.Init - Asymetric codecs are not initialized by string.'; -ES_HashFailed = 'TSimpleCodec.Init - Hash failed.'; -ES_WrongModeReset = 'TSimpleCodec.Init - Reset when not intialized.'; -ES_WrongModeEncrypt = 'TSimpleCodec.Begin_EncryptMemory - Wrong mode.'; -ES_EncryptNoAlg = 'TSimpleCodec.Begin_EncryptMemory - Algorithms not set.'; -ES_WrongModeDecrypt = 'TSimpleCodec.Begin_DecryptMemory - Wrong mode.'; -ES_DecryptNoAlg = 'TSimpleCodec.Begin_DecryptMemory - Algorithms not set.'; -ES_WrongModeEncryptMem = 'TSimpleCodec.EncryptMemory - Wrong mode.'; -ES_WrongModeDecryptMem = 'TSimpleCodec.DecryptMemory - Wrong mode.'; -ES_WrongModeEndDecryptMem = 'TSimpleCodec.End_DecryptMemory - Wrong mode.'; -ES_WrongModeEndEncryptMem = 'TSimpleCodec.End_EncryptMemory - Wrong mode.'; -ES_Asym_CannotSetParam = 'TSimpleCodec.AsymetricKeySizeInBits - Cannot set parameter whilst enc/decrypting.'; -ES_Asym_CannotSetCipher = 'TSimpleCodec.Init - Cannot set Cipher whilst enc/decrypting.'; -ES_AsymNotInitByStr = 'TSimpleCodec.Init - Asymetric codecs are not initialized by string.'; -ES_NotImplementedNot_Suffix = '(not implemented yet!)'; -ES_LibsChainTooDeep = 'TCryptographicLibrarys cannot chain more than %d deep.'; -ES_CircularLibs = 'Circular TCryptographicLibrary chaining is prohibited.'; -ES_HugeCardinal_CloneOverflow = 'THugeCardinal.CreateAsSizedClone overflow.'; -ES_HugeCardinal_AddOverflow = 'THugeCardinal.Add overflow.'; -ES_CannotAssignHuge_BecauseSourceTooBig = - 'Cannot assign THugeCardinal because source is too big' + - ' and resizing is not allowed.'; -ES_HugeCardinal_IncrementOverflow = 'THugeCardinal.Increment overflow.'; -ES_HugeCardinal_DivideOverflow = 'THugeCardinal.Divide overflow.'; -ES_HugeCardinal_Power2 = 'MulPower2 overflow.'; -ES_HugeCardinal_MulSmallOverflow = 'MulSmall overflow.'; -ES_HugeCardinal_ResizeOverflow = 'THugeCardinal.Resize overflow'; -ES_HugeCardinal_PowerOverflow = 'Power overflow'; -ES_HugeCardinal_SubractOverflow = 'THugeCardinal.Subtract overflow.'; -ES_HugeCardinal_StreamOutOverflow = 'THugeCardinal.StreamOut overflow.'; -ES_HugeCardinal_StreamInOverflow = 'THugeCardinal.StreamIn overflow.'; -ES_EratosthenesSievSizeTooSmall = - 'EratosthenesSieveSize value (%d) too small for required number of ' + - 'pre-computed small primes (%d primes)'; -ES_InternalError_Suffix = 'internal error.'; -ES_InvalidKey = 'Invalid key.'; -ES_PlaintextFN_Empty = 'TSimpleCodec.EncryptFile - plaintext filename parameter was empty.'; -ES_CiphertextFN_Empty = 'TSimpleCodec.EncryptFile - ciphertext filename parameter was empty.'; -ES_NoOpenSSLCompat = 'Cipher %s does not support OpenSSL Compatibility mode.'; -ES_OpenSSLCompat_RequiresIV = 'OpenSSL Compability mode requires an explicit IV (except ECB mode).'; - - -// Assert failure messages -AS_HugeCardinal_DivideLogicFail = 'THugeCardinal.Divide internal logic failure.'; -AS_ZeroToZero = 'Zero raised to zero is an invalid operation.'; -AS_LCM_Fail = 'function lcm failed.'; - -AS_HugeCardinal_N_tooSmall = 'RequiredBitLengthOfN too small.'; -AS_HugeCardinal_N_tooBig = 'RequiredBitLengthOfN absurdly large.'; -AS_HugeCardinal_N_tooSmall_for_n = 'RequiredBitLengthOfN too small for n.'; - -AS_BlockToStream_EndEncrypt_InternalMarshalling = - 'TNoncibleEncryptor.End_Encrypt - Internal marshalling error.'; -AS_BlockToStream_EndDecrypt_InternalMarshalling = - 'TNoncibleDecryptor.End_Encrypt - Internal marshalling error.'; - -AS_BlockPaddingCorrupt = 'Invalid ciphertext - block padding is corrupted.'; - -// SmartInspect -{$IFDEF SI}; -SIS_Hello = 'Hello'; -{$ENDIF} - - -// Algorithmic Display Names -RSA_DisplayName = 'RSA public key encryption system'; -BlockCipher_DisplayName = 'Block mode'; -Base64_DisplayName = 'Base64'; -CFB8bit_DisplayName = 'CFB 8-bit'; -ECB_DisplayName = 'ECB (with block padding)'; - - -// Design-time messages -DS_Email = 'email: '; -DS_Web = 'web: '; -DS_RunTimeIs = 'Run-time package %s is version %s .'; -DS_DesignTimeIs = 'Design-time package %s is version %s .'; -DS_HashNotSelected = '(THash not selected)'; -DS_BlockSizeEqs = 'Block size = %d bits'; -DS_DigestSizeEqs = 'Digest size = %d bits'; -DS_ChainModeNotSelected = '(Chain mode not selected)'; -DS_CodecNotSelected = '(TCodec not selected)'; -DS_MixedLibraries = '(Libraries mixed or not set)'; - - -implementation - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.I18n; + +interface + +resourcestring + +// Exception messages +ES_NoPassword = 'TSimpleCodec.Init - No password.'; +ES_AsymPassword = 'TSimpleCodec.Init - Asymetric codecs are not initialized by string.'; +ES_HashFailed = 'TSimpleCodec.Init - Hash failed.'; +ES_WrongModeReset = 'TSimpleCodec.Init - Reset when not intialized.'; +ES_WrongModeEncrypt = 'TSimpleCodec.Begin_EncryptMemory - Wrong mode.'; +ES_EncryptNoAlg = 'TSimpleCodec.Begin_EncryptMemory - Algorithms not set.'; +ES_WrongModeDecrypt = 'TSimpleCodec.Begin_DecryptMemory - Wrong mode.'; +ES_DecryptNoAlg = 'TSimpleCodec.Begin_DecryptMemory - Algorithms not set.'; +ES_WrongModeEncryptMem = 'TSimpleCodec.EncryptMemory - Wrong mode.'; +ES_WrongModeDecryptMem = 'TSimpleCodec.DecryptMemory - Wrong mode.'; +ES_WrongModeEndDecryptMem = 'TSimpleCodec.End_DecryptMemory - Wrong mode.'; +ES_WrongModeEndEncryptMem = 'TSimpleCodec.End_EncryptMemory - Wrong mode.'; +ES_Asym_CannotSetParam = 'TSimpleCodec.AsymetricKeySizeInBits - Cannot set parameter whilst enc/decrypting.'; +ES_Asym_CannotSetCipher = 'TSimpleCodec.Init - Cannot set Cipher whilst enc/decrypting.'; +ES_AsymNotInitByStr = 'TSimpleCodec.Init - Asymetric codecs are not initialized by string.'; +ES_NotImplementedNot_Suffix = '(not implemented yet!)'; +ES_LibsChainTooDeep = 'TCryptographicLibrarys cannot chain more than %d deep.'; +ES_CircularLibs = 'Circular TCryptographicLibrary chaining is prohibited.'; +ES_HugeCardinal_CloneOverflow = 'THugeCardinal.CreateAsSizedClone overflow.'; +ES_HugeCardinal_AddOverflow = 'THugeCardinal.Add overflow.'; +ES_CannotAssignHuge_BecauseSourceTooBig = + 'Cannot assign THugeCardinal because source is too big' + + ' and resizing is not allowed.'; +ES_HugeCardinal_IncrementOverflow = 'THugeCardinal.Increment overflow.'; +ES_HugeCardinal_DivideOverflow = 'THugeCardinal.Divide overflow.'; +ES_HugeCardinal_Power2 = 'MulPower2 overflow.'; +ES_HugeCardinal_MulSmallOverflow = 'MulSmall overflow.'; +ES_HugeCardinal_ResizeOverflow = 'THugeCardinal.Resize overflow'; +ES_HugeCardinal_PowerOverflow = 'Power overflow'; +ES_HugeCardinal_SubractOverflow = 'THugeCardinal.Subtract overflow.'; +ES_HugeCardinal_StreamOutOverflow = 'THugeCardinal.StreamOut overflow.'; +ES_HugeCardinal_StreamInOverflow = 'THugeCardinal.StreamIn overflow.'; +ES_EratosthenesSievSizeTooSmall = + 'EratosthenesSieveSize value (%d) too small for required number of ' + + 'pre-computed small primes (%d primes)'; +ES_InternalError_Suffix = 'internal error.'; +ES_InvalidKey = 'Invalid key.'; +ES_PlaintextFN_Empty = 'TSimpleCodec.EncryptFile - plaintext filename parameter was empty.'; +ES_CiphertextFN_Empty = 'TSimpleCodec.EncryptFile - ciphertext filename parameter was empty.'; +ES_NoOpenSSLCompat = 'Cipher %s does not support OpenSSL Compatibility mode.'; +ES_OpenSSLCompat_RequiresIV = 'OpenSSL Compability mode requires an explicit IV (except ECB mode).'; + + +// Assert failure messages +AS_HugeCardinal_DivideLogicFail = 'THugeCardinal.Divide internal logic failure.'; +AS_ZeroToZero = 'Zero raised to zero is an invalid operation.'; +AS_LCM_Fail = 'function lcm failed.'; + +AS_HugeCardinal_N_tooSmall = 'RequiredBitLengthOfN too small.'; +AS_HugeCardinal_N_tooBig = 'RequiredBitLengthOfN absurdly large.'; +AS_HugeCardinal_N_tooSmall_for_n = 'RequiredBitLengthOfN too small for n.'; + +AS_BlockToStream_EndEncrypt_InternalMarshalling = + 'TNoncibleEncryptor.End_Encrypt - Internal marshalling error.'; +AS_BlockToStream_EndDecrypt_InternalMarshalling = + 'TNoncibleDecryptor.End_Encrypt - Internal marshalling error.'; + +AS_BlockPaddingCorrupt = 'Invalid ciphertext - block padding is corrupted.'; + +// SmartInspect +{$IFDEF SI}; +SIS_Hello = 'Hello'; +{$ENDIF} + + +// Algorithmic Display Names +RSA_DisplayName = 'RSA public key encryption system'; +BlockCipher_DisplayName = 'Block mode'; +Base64_DisplayName = 'Base64'; +CFB8bit_DisplayName = 'CFB 8-bit'; +ECB_DisplayName = 'ECB (with block padding)'; + + +// Design-time messages +DS_Email = 'email: '; +DS_Web = 'web: '; +DS_RunTimeIs = 'Run-time package %s is version %s .'; +DS_DesignTimeIs = 'Design-time package %s is version %s .'; +DS_HashNotSelected = '(THash not selected)'; +DS_BlockSizeEqs = 'Block size = %d bits'; +DS_DigestSizeEqs = 'Digest size = %d bits'; +DS_ChainModeNotSelected = '(Chain mode not selected)'; +DS_CodecNotSelected = '(TCodec not selected)'; +DS_MixedLibraries = '(Libraries mixed or not set)'; + + +implementation + +end. diff --git a/run/TPLB3.IntegerUtils.pas b/LockBox3/run/TPLB3.IntegerUtils.pas similarity index 96% rename from run/TPLB3.IntegerUtils.pas rename to LockBox3/run/TPLB3.IntegerUtils.pas index 25edd9b..d7aee09 100644 --- a/run/TPLB3.IntegerUtils.pas +++ b/LockBox3/run/TPLB3.IntegerUtils.pas @@ -1,303 +1,303 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.IntegerUtils; -interface - - -{$IF CompilerVersion < 21.00} // Meaning "before Delphi 2010". -type - uint32 = cardinal; // Must be unsigned 32 bit 2's complement integer - // with native operational support. - uint16 = word; -{$ifend} - -// NOTE: In Delphi 2010, uint32 is a standard type defined in the system unit. - - - -function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; -function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; - -function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; -function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; - -function BitCount_8 ( Value: byte): integer; -function BitCount_16( Value: uint16): integer; -function BitCount_32( Value: uint32): integer; -function BitCount_64( Value: uint64): integer; -function CountSetBits_64( Value: uint64): integer; - - -implementation - - - - - -uses SysUtils, TPLB3.Compatibility; - - -{.$define PUREPASCAL} - - - - - -{$define IntegerUtils_ASM64_NotYetImplemented} -// Undefine the above, when someone has implemented 64-bit ASM for -// unsigned integer arithmetic. - - -{$undef IntegerUtils_Pascal} -{$undef IntegerUtils_ASM32} -{$undef IntegerUtils_ASM64} - -{$IF Defined(PUREPASCAL) or not Defined(ASSEMBLER)} - {$DEFINE IntegerUtils_Pascal} -{$ELSE} - {$IF Defined(CPUX64) and not Defined(IntegerUtils_ASM64_NotYetImplemented)} - {$DEFINE IntegerUtils_ASM64} - {$ELSEIF Defined(CPUX86)} - {$DEFINE IntegerUtils_ASM32} - {$ELSE} - {$DEFINE IntegerUtils_Pascal} - {$IFEND} -{$IFEND} - -{$IFDEF IntegerUtils_ASM32} -function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; -// The following code was inspired by -// http://www.delphi3000.com/articles/article_3772.asp?SK= -// from Ernesto De Spirito. -asm -// The following 3 lines sets the carry flag (CF) if Carry is True. -// Otherwise the CF is cleared. -// The third parameter is in ecx . -test byte ptr [ecx], $01 // True == $01 -jz @@t1 -stc -@@t1: -adc eax, edx // result := x + y + Carry -setc byte ptr [ecx] // Puts CF back into Carry -end; -{$ENDIF} - -{$IFDEF IntegerUtils_ASM64} -function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; -asm -// TO BE DEVELOPED. -end; -{$ENDIF} - -{$IFDEF IntegerUtils_Pascal} -{$OVERFLOWCHECKS OFF} -function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; inline; -begin -// To do: make an 64-bit asm implementation. -result := x + y; -if Carry then - Inc( result); -Carry := (result < x) or ((result = x) and ((y <> 0) or Carry)) -end; -{$OVERFLOWCHECKS ON} -{$ENDIF} - -{$IFDEF IntegerUtils_ASM32} -function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; -asm -// The third parameter is in ecx . -test byte ptr [ecx], $01 -jz @@t1 -stc // CF = Ord( Borrow) -@@t1: -sbb eax, edx // result := x - y + (CF * 2^32) -setc byte ptr [ecx] // Borrow := CF = 1 -end; -{$ENDIF} - -{$IFDEF IntegerUtils_ASM64} -function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; -asm -// TO BE DEVELOPED. -end; -{$ENDIF} - - - -{$IFDEF IntegerUtils_Pascal} -{$OVERFLOWCHECKS OFF} -function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; inline; -begin -// To do: make an 64-bit asm implementation. -result := x - y; -if Borrow then - Dec( result); -Borrow := (result > x) or ((result = x) and ((y <> 0) or Borrow)) -end; -{$OVERFLOWCHECKS ON} -{$ENDIF} - - - -{$IFDEF IntegerUtils_ASM32} -function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; -asm -// The third parameter is in eax . Contrast with the 32 bit version of this function. -mov ecx,eax -test byte ptr [ecx], $01 // CF := 0; ZF := not Carry; -jz @@t1 // if not ZF then -stc // CF := 1; -@@t1: -mov eax,[ebp+$10] // eax := x.l; -mov edx,[ebp+$14] // edx := x.h; -adc eax,[ebp+$08] // eax := eax + y.l + CF; CF = new CF of this addition; -adc edx,[ebp+$0c] // edx := edx + y.h + CF; CF = new CF of this addition; -setc byte ptr [ecx] // Carry := CF = 1 -end; -{$ENDIF} - -{$IFDEF IntegerUtils_ASM64} -function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; -asm -// TO BE DEVELOPED. -end; -{$ENDIF} - -{$IFDEF IntegerUtils_Pascal} -{$OVERFLOWCHECKS OFF} -function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; inline; -begin -// To do: make an 64-bit asm implementation. -result := x + y; -if Carry then - Inc( result); -Carry := (result < x) or ((result = x) and ((y <> 0) or Carry)) -end; -{$OVERFLOWCHECKS ON} -{$ENDIF} - - -{$IFDEF IntegerUtils_ASM32} -function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; -asm -// The third parameter is in eax . -mov ecx,eax -test byte ptr [ecx], $01 // CF := 0; ZF := not Borrow; -jz @@t1 // if not ZF then -stc // CF := 1; -@@t1: -mov eax,[ebp+$10] // eax := x.l; -mov edx,[ebp+$14] // edx := x.h; -sbb eax,[ebp+$08] // eax := eax - y.l + (CF * 2^32); CF = new CF of this subtraction; -sbb edx,[ebp+$0c] // edx := edx - y.h + (CF * 2^32); CF = new CF of this subtraction; -setc byte ptr [ecx] // Borrow := CF = 1 -end; -{$ENDIF} - -{$IFDEF IntegerUtils_ASM64} -function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; -asm -// TO BE DEVELOPED. -end; -{$ENDIF} - - -{$IFDEF IntegerUtils_Pascal} -{$OVERFLOWCHECKS OFF} -function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; inline; -begin -// To do: make an 64-bit asm implementation. -result := x - y; -if Borrow then - Dec( result); -Borrow := (result > x) or ((result = x) and ((y <> 0) or Borrow)) -end; -{$OVERFLOWCHECKS ON} -{$ENDIF} - - - - -function BitCount_8( Value: byte): integer; -begin -result := 0; -while Value <> 0 do - begin - Value := Value shr 1; - Inc( result) - end -end; - -function BitCount_16( Value: uint16): integer; -begin -result := 0; -while Value <> 0 do - begin - Value := Value shr 1; - Inc( result) - end -end; - -function BitCount_32( Value: uint32): integer; -begin -result := 0; -while Value <> 0 do - begin - Value := Value shr 1; - Inc( result) - end -end; - -function BitCount_64( Value: uint64): integer; -begin -result := 0; -while Value <> 0 do - begin - Value := Value shr 1; - Inc( result) - end -end; - - -function CountSetBits_64( Value: uint64): integer; -begin -result := 0; -while Value <> 0 do - begin - if Odd( Value) then - Inc( result); - Value := Value shr 1 - end -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.IntegerUtils; +interface + + +{$IF CompilerVersion < 21.00} // Meaning "before Delphi 2010". +type + uint32 = cardinal; // Must be unsigned 32 bit 2's complement integer + // with native operational support. + uint16 = word; +{$ifend} + +// NOTE: In Delphi 2010, uint32 is a standard type defined in the system unit. + + + +function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; +function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; + +function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; +function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; + +function BitCount_8 ( Value: byte): integer; +function BitCount_16( Value: uint16): integer; +function BitCount_32( Value: uint32): integer; +function BitCount_64( Value: uint64): integer; +function CountSetBits_64( Value: uint64): integer; + + +implementation + + + + + +uses SysUtils, TPLB3.Compatibility; + + +{.$define PUREPASCAL} + + + + + +{$define IntegerUtils_ASM64_NotYetImplemented} +// Undefine the above, when someone has implemented 64-bit ASM for +// unsigned integer arithmetic. + + +{$undef IntegerUtils_Pascal} +{$undef IntegerUtils_ASM32} +{$undef IntegerUtils_ASM64} + +{$IF Defined(PUREPASCAL) or not Defined(ASSEMBLER)} + {$DEFINE IntegerUtils_Pascal} +{$ELSE} + {$IF Defined(CPUX64) and not Defined(IntegerUtils_ASM64_NotYetImplemented)} + {$DEFINE IntegerUtils_ASM64} + {$ELSEIF Defined(CPUX86)} + {$DEFINE IntegerUtils_ASM32} + {$ELSE} + {$DEFINE IntegerUtils_Pascal} + {$IFEND} +{$IFEND} + +{$IFDEF IntegerUtils_ASM32} +function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; +// The following code was inspired by +// http://www.delphi3000.com/articles/article_3772.asp?SK= +// from Ernesto De Spirito. +asm +// The following 3 lines sets the carry flag (CF) if Carry is True. +// Otherwise the CF is cleared. +// The third parameter is in ecx . +test byte ptr [ecx], $01 // True == $01 +jz @@t1 +stc +@@t1: +adc eax, edx // result := x + y + Carry +setc byte ptr [ecx] // Puts CF back into Carry +end; +{$ENDIF} + +{$IFDEF IntegerUtils_ASM64} +function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; +asm +// TO BE DEVELOPED. +end; +{$ENDIF} + +{$IFDEF IntegerUtils_Pascal} +{$OVERFLOWCHECKS OFF} +function Add_uint32_WithCarry( x, y: uint32; var Carry: Boolean): uint32; inline; +begin +// To do: make an 64-bit asm implementation. +result := x + y; +if Carry then + Inc( result); +Carry := (result < x) or ((result = x) and ((y <> 0) or Carry)) +end; +{$OVERFLOWCHECKS ON} +{$ENDIF} + +{$IFDEF IntegerUtils_ASM32} +function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; +asm +// The third parameter is in ecx . +test byte ptr [ecx], $01 +jz @@t1 +stc // CF = Ord( Borrow) +@@t1: +sbb eax, edx // result := x - y + (CF * 2^32) +setc byte ptr [ecx] // Borrow := CF = 1 +end; +{$ENDIF} + +{$IFDEF IntegerUtils_ASM64} +function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; +asm +// TO BE DEVELOPED. +end; +{$ENDIF} + + + +{$IFDEF IntegerUtils_Pascal} +{$OVERFLOWCHECKS OFF} +function Subtract_uint32_WithBorrow( x, y: uint32; var Borrow: Boolean): uint32; inline; +begin +// To do: make an 64-bit asm implementation. +result := x - y; +if Borrow then + Dec( result); +Borrow := (result > x) or ((result = x) and ((y <> 0) or Borrow)) +end; +{$OVERFLOWCHECKS ON} +{$ENDIF} + + + +{$IFDEF IntegerUtils_ASM32} +function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; +asm +// The third parameter is in eax . Contrast with the 32 bit version of this function. +mov ecx,eax +test byte ptr [ecx], $01 // CF := 0; ZF := not Carry; +jz @@t1 // if not ZF then +stc // CF := 1; +@@t1: +mov eax,[ebp+$10] // eax := x.l; +mov edx,[ebp+$14] // edx := x.h; +adc eax,[ebp+$08] // eax := eax + y.l + CF; CF = new CF of this addition; +adc edx,[ebp+$0c] // edx := edx + y.h + CF; CF = new CF of this addition; +setc byte ptr [ecx] // Carry := CF = 1 +end; +{$ENDIF} + +{$IFDEF IntegerUtils_ASM64} +function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; +asm +// TO BE DEVELOPED. +end; +{$ENDIF} + +{$IFDEF IntegerUtils_Pascal} +{$OVERFLOWCHECKS OFF} +function Add_uint64_WithCarry( x, y: uint64; var Carry: Boolean): uint64; inline; +begin +// To do: make an 64-bit asm implementation. +result := x + y; +if Carry then + Inc( result); +Carry := (result < x) or ((result = x) and ((y <> 0) or Carry)) +end; +{$OVERFLOWCHECKS ON} +{$ENDIF} + + +{$IFDEF IntegerUtils_ASM32} +function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; +asm +// The third parameter is in eax . +mov ecx,eax +test byte ptr [ecx], $01 // CF := 0; ZF := not Borrow; +jz @@t1 // if not ZF then +stc // CF := 1; +@@t1: +mov eax,[ebp+$10] // eax := x.l; +mov edx,[ebp+$14] // edx := x.h; +sbb eax,[ebp+$08] // eax := eax - y.l + (CF * 2^32); CF = new CF of this subtraction; +sbb edx,[ebp+$0c] // edx := edx - y.h + (CF * 2^32); CF = new CF of this subtraction; +setc byte ptr [ecx] // Borrow := CF = 1 +end; +{$ENDIF} + +{$IFDEF IntegerUtils_ASM64} +function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; +asm +// TO BE DEVELOPED. +end; +{$ENDIF} + + +{$IFDEF IntegerUtils_Pascal} +{$OVERFLOWCHECKS OFF} +function Subtract_uint64_WithBorrow( x, y: uint64; var Borrow: Boolean): uint64; inline; +begin +// To do: make an 64-bit asm implementation. +result := x - y; +if Borrow then + Dec( result); +Borrow := (result > x) or ((result = x) and ((y <> 0) or Borrow)) +end; +{$OVERFLOWCHECKS ON} +{$ENDIF} + + + + +function BitCount_8( Value: byte): integer; +begin +result := 0; +while Value <> 0 do + begin + Value := Value shr 1; + Inc( result) + end +end; + +function BitCount_16( Value: uint16): integer; +begin +result := 0; +while Value <> 0 do + begin + Value := Value shr 1; + Inc( result) + end +end; + +function BitCount_32( Value: uint32): integer; +begin +result := 0; +while Value <> 0 do + begin + Value := Value shr 1; + Inc( result) + end +end; + +function BitCount_64( Value: uint64): integer; +begin +result := 0; +while Value <> 0 do + begin + Value := Value shr 1; + Inc( result) + end +end; + + +function CountSetBits_64( Value: uint64): integer; +begin +result := 0; +while Value <> 0 do + begin + if Odd( Value) then + Inc( result); + Value := Value shr 1 + end +end; + +end. diff --git a/run/TPLB3.MD5.pas b/LockBox3/run/TPLB3.MD5.pas similarity index 95% rename from run/TPLB3.MD5.pas rename to LockBox3/run/TPLB3.MD5.pas index 11702f8..c78ed9c 100644 --- a/run/TPLB3.MD5.pas +++ b/LockBox3/run/TPLB3.MD5.pas @@ -1,332 +1,334 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.MD5; -interface -uses classes, TPLB3.HashDsc, TPLB3.StreamCipher; - -type - -TMD5 = class( TInterfacedObject, IHashDsc, ICryptoGraphicAlgorithm) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DigestSize: integer; // in units of bits. Must be a multiple of 8. - function UpdateSize: integer; // Size that the input to the Update must be. - function MakeHasher( const Params: IInterface): IHasher; - function DefinitionURL: string; - function WikipediaReference: string; - end; - - - -implementation - - - - - - - - - - - - -uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, - TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; - -type -TMD5_Hasher = class( TInterfacedObject, IHasher) - private - ABCD: array[ 0.. 3 ] of uint32; - FCount: int64; - - constructor Create; - procedure Update( Source{in}: TMemoryStream); - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); - procedure Burn; - function SelfTest_Source: string; - function SelfTest_ReferenceHashValue: string; - end; - - - - -{ TMD5 } - -function TMD5.DefinitionURL: string; -begin -result := 'http://tools.ietf.org/html/rfc1321' -end; - - - -function TMD5.DigestSize: integer; -begin -result := 128 -end; - - - -function TMD5.DisplayName: string; -begin -result := 'MD5' -end; - - - -function TMD5.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afCryptographicallyWeak] -end; - - - -function TMD5.MakeHasher(const Params: IInterface): IHasher; -begin -result := TMD5_Hasher.Create -end; - - - -function TMD5.ProgId: string; -begin -result := MD5_ProgId -end; - - - -function TMD5.UpdateSize: integer; -begin -result := 512 -end; - - - -function TMD5.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} 'MD5' -end; - - - - - -{ TMD5_Hasher } - -constructor TMD5_Hasher.Create; -begin -ABCD[ 0]:= $67452301; -ABCD[ 1]:= $efcdab89; -ABCD[ 2]:= $98badcfe; -ABCD[ 3]:= $10325476 -end; - - - -procedure TMD5_Hasher.Burn; -var - a: integer; -begin -for a := 0 to 3 do - ABCD[ a] := 0; -FCount := 0 -end; - - -procedure TMD5_Hasher.End_Hash( PartBlock: TMemoryStream; Digest: TStream); -var - L, j: integer; - Pad: integer; - PadByte: byte; - Injection, Block: TMemoryStream; - Sentinal: byte; - lwDigest: uint32; -begin -L := PartBlock.Position; -Assert( L <= 64, 'TSHA1_Hasher.End_Hash - Wrong block size.'); -Inc( FCount, L * 8); -Pad := (64 - ((L + 9) mod 64)) mod 64; -Injection := TMemoryStream.Create; -Block := TMemoryStream.Create; -try -if L > 0 then - Injection.Write( PartBlock.Memory^, L); -Sentinal := $80; -Injection.Write( Sentinal, 1); -PadByte := $00; -for j := 1 to Pad do - Injection.Write( PadByte, 1); -Injection.Write( FCount, 8); -Block.Size := 64; -Inc( L, Pad + 9); -repeat - Move( Injection.Memory^, Block.Memory^, 64); - if L > 64 then - Move( MemStrmOffset( Injection, 64)^, Injection.Memory^, L - 64); - Dec( L, 64); - Injection.Size := L; - Update( Block) -until L <= 0 -finally -BurnMemoryStream( Injection); -Injection.Free; -BurnMemoryStream( Block); -Block.Free; -end; -Digest.Position := 0; -for j := 0 to 3 do - begin - lwDigest := ABCD[j]; - Digest.WriteBuffer( lwDigest, 4) - end; -Digest.Position := 0; -// Burning -lwDigest := 0 -end; - - -function TMD5_Hasher.SelfTest_ReferenceHashValue: string; -begin -result := 'f96b697d 7cb7938d 525a2f31 aaf161d0' -end; - -function TMD5_Hasher.SelfTest_Source: string; -begin -result := 'message digest' -end; - - - - -function RotateLeft_u32( Value: uint32; Rot: integer): uint32; -begin -result := (Value shl Rot) or (Value shr (32 - Rot)) -end; - - - -const - T: array[ 0..63] of uint32 = ( - $d76aa478, $e8c7b756, $242070db, $c1bdceee, $f57c0faf, $4787c62a, $a8304613, $fd469501, - $698098d8, $8b44f7af, $ffff5bb1, $895cd7be, $6b901122, $fd987193, $a679438e, $49b40821, - $f61e2562, $c040b340, $265e5a51, $e9b6c7aa, $d62f105d, $02441453, $d8a1e681, $e7d3fbc8, - $21e1cde6, $c33707d6, $f4d50d87, $455a14ed, $a9e3e905, $fcefa3f8, $676f02d9, $8d2a4c8a, - $fffa3942, $8771f681, $6d9d6122, $fde5380c, $a4beea44, $4bdecfa9, $f6bb4b60, $bebfbc70, - $289b7ec6, $eaa127fa, $d4ef3085, $04881d05, $d9d4d039, $e6db99e5, $1fa27cf8, $c4ac5665, - $f4292244, $432aff97, $ab9423a7, $fc93a039, $655b59c3, $8f0ccc92, $ffeff47d, $85845dd1, - $6fa87e4f, $fe2ce6e0, $a3014314, $4e0811a1, $f7537e82, $bd3af235, $2ad7d2bb, $eb86d391); - - sValues: array[ {round}0..3, {a}0..3] of integer = ( - {round 1} ( 7, 22, 17, 12), - {round 2} ( 5, 20, 14, 9), - {round 3} ( 4, 23, 16, 11), - {round 4} ( 6, 21, 15, 10)); - - kFactors: array[ {round}0..3] of integer = (1, 5, 3, 7); - kOffsets: array[ {round}0..3] of integer = (0, 1, 5, 0); - - -procedure TMD5_Hasher.Update( Source: TMemoryStream); -var - X: array[ 0..15 ] of uint32; - a, k, s, i, j: integer; - FGHI: uint32; - Round, Cycle: integer; - AABBCCDD: array[ 0.. 3 ] of uint32; - aIndicies: array[0..3] of integer; // 0..3 indexing into ABCD[] - -begin -Assert( Source.Size = 64, 'TMD5_Hasher.Update - Wrong block size.'); -Inc( FCount, 512); -Move( Source.Memory^, X, 64); -FGHI := 0; - -for a := 0 to 3 do - AABBCCDD[a] := ABCD[a]; - -for i := 0 to 3 do - aIndicies[ i] := i; - -Round := 0; -Cycle := 0; -k := 0; -for i := 0 to 63 do - begin -// aIndexes = (4 - (i mod 4)) mod 4; -// Round = i div 16; - case Round of - 0: // Round 1 - FGHI := (ABCD[ aIndicies[1]] and ABCD[ aIndicies[2]]) or // F(X=b,Y=c,Z=d) = XY v not(X) Z - ((not ABCD[ aIndicies[1]]) and ABCD[ aIndicies[3]]); - - 1: // Round 2 - FGHI := (ABCD[ aIndicies[1]] and ABCD[ aIndicies[3]]) or // G(X=b,Y=c,Z=d) = XZ v Y not(Z) - ((not ABCD[ aIndicies[3]]) and ABCD[ aIndicies[2]]); - - 2: // Round 3 - FGHI := ABCD[ aIndicies[1]] xor ABCD[ aIndicies[2]] xor ABCD[ aIndicies[3]]; // H(X=b,Y=c,Z=d) = X xor Y xor Z - - 3: // Round 4 - FGHI := ABCD[ aIndicies[2]] xor // I(X=b,Y=c,Z=d) = Y xor (X v not(Z)) - (ABCD[ aIndicies[1]] or (not ABCD[ aIndicies[3]])) - end; - s := sValues[ Round, aIndicies[0]]; - ABCD[ aIndicies[0]] := ABCD[ aIndicies[1]] + - RotateLeft_u32( ABCD[ aIndicies[0]] + FGHI + X[k] + T[i], s); - for j := 0 to 3 do - begin - Dec( aIndicies[j]); - if aIndicies[j] = -1 then - aIndicies[j] := 3 - end; - if Cycle <= 14 then - begin - Inc( Cycle); - Inc( k, kFactors[ Round]); - if k >= 16 then - Dec( k, 16) - end - else - begin - Cycle := 0; - Inc( Round); - k := kOffsets[ Round] - end - end; -for a := 0 to 3 do - ABCD[a] := ABCD[a] + AABBCCDD[a] -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.MD5; +{$R-} +{$OVERFLOWCHECKS OFF} +interface +uses classes, TPLB3.HashDsc, TPLB3.StreamCipher; + +type + +TMD5 = class( TInterfacedObject, IHashDsc, ICryptoGraphicAlgorithm) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DigestSize: integer; // in units of bits. Must be a multiple of 8. + function UpdateSize: integer; // Size that the input to the Update must be. + function MakeHasher( const Params: IInterface): IHasher; + function DefinitionURL: string; + function WikipediaReference: string; + end; + + + +implementation + + + + + + + + + + + + +uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, + TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; + +type +TMD5_Hasher = class( TInterfacedObject, IHasher) + private + ABCD: array[ 0.. 3 ] of uint32; + FCount: int64; + + constructor Create; + procedure Update( Source{in}: TMemoryStream); + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); + procedure Burn; + function SelfTest_Source: string; + function SelfTest_ReferenceHashValue: string; + end; + + + + +{ TMD5 } + +function TMD5.DefinitionURL: string; +begin +result := 'http://tools.ietf.org/html/rfc1321' +end; + + + +function TMD5.DigestSize: integer; +begin +result := 128 +end; + + + +function TMD5.DisplayName: string; +begin +result := 'MD5' +end; + + + +function TMD5.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afCryptographicallyWeak] +end; + + + +function TMD5.MakeHasher(const Params: IInterface): IHasher; +begin +result := TMD5_Hasher.Create +end; + + + +function TMD5.ProgId: string; +begin +result := MD5_ProgId +end; + + + +function TMD5.UpdateSize: integer; +begin +result := 512 +end; + + + +function TMD5.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} 'MD5' +end; + + + + + +{ TMD5_Hasher } + +constructor TMD5_Hasher.Create; +begin +ABCD[ 0]:= $67452301; +ABCD[ 1]:= $efcdab89; +ABCD[ 2]:= $98badcfe; +ABCD[ 3]:= $10325476 +end; + + + +procedure TMD5_Hasher.Burn; +var + a: integer; +begin +for a := 0 to 3 do + ABCD[ a] := 0; +FCount := 0 +end; + + +procedure TMD5_Hasher.End_Hash( PartBlock: TMemoryStream; Digest: TStream); +var + L, j: integer; + Pad: integer; + PadByte: byte; + Injection, Block: TMemoryStream; + Sentinal: byte; + lwDigest: uint32; +begin +L := PartBlock.Position; +Assert( L <= 64, 'TSHA1_Hasher.End_Hash - Wrong block size.'); +Inc( FCount, L * 8); +Pad := (64 - ((L + 9) mod 64)) mod 64; +Injection := TMemoryStream.Create; +Block := TMemoryStream.Create; +try +if L > 0 then + Injection.Write( PartBlock.Memory^, L); +Sentinal := $80; +Injection.Write( Sentinal, 1); +PadByte := $00; +for j := 1 to Pad do + Injection.Write( PadByte, 1); +Injection.Write( FCount, 8); +Block.Size := 64; +Inc( L, Pad + 9); +repeat + Move( Injection.Memory^, Block.Memory^, 64); + if L > 64 then + Move( MemStrmOffset( Injection, 64)^, Injection.Memory^, L - 64); + Dec( L, 64); + Injection.Size := L; + Update( Block) +until L <= 0 +finally +BurnMemoryStream( Injection); +Injection.Free; +BurnMemoryStream( Block); +Block.Free; +end; +Digest.Position := 0; +for j := 0 to 3 do + begin + lwDigest := ABCD[j]; + Digest.WriteBuffer( lwDigest, 4) + end; +Digest.Position := 0; +// Burning +lwDigest := 0 +end; + + +function TMD5_Hasher.SelfTest_ReferenceHashValue: string; +begin +result := 'f96b697d 7cb7938d 525a2f31 aaf161d0' +end; + +function TMD5_Hasher.SelfTest_Source: string; +begin +result := 'message digest' +end; + + + + +function RotateLeft_u32( Value: uint32; Rot: integer): uint32; +begin +result := (Value shl Rot) or (Value shr (32 - Rot)) +end; + + + +const + T: array[ 0..63] of uint32 = ( + $d76aa478, $e8c7b756, $242070db, $c1bdceee, $f57c0faf, $4787c62a, $a8304613, $fd469501, + $698098d8, $8b44f7af, $ffff5bb1, $895cd7be, $6b901122, $fd987193, $a679438e, $49b40821, + $f61e2562, $c040b340, $265e5a51, $e9b6c7aa, $d62f105d, $02441453, $d8a1e681, $e7d3fbc8, + $21e1cde6, $c33707d6, $f4d50d87, $455a14ed, $a9e3e905, $fcefa3f8, $676f02d9, $8d2a4c8a, + $fffa3942, $8771f681, $6d9d6122, $fde5380c, $a4beea44, $4bdecfa9, $f6bb4b60, $bebfbc70, + $289b7ec6, $eaa127fa, $d4ef3085, $04881d05, $d9d4d039, $e6db99e5, $1fa27cf8, $c4ac5665, + $f4292244, $432aff97, $ab9423a7, $fc93a039, $655b59c3, $8f0ccc92, $ffeff47d, $85845dd1, + $6fa87e4f, $fe2ce6e0, $a3014314, $4e0811a1, $f7537e82, $bd3af235, $2ad7d2bb, $eb86d391); + + sValues: array[ {round}0..3, {a}0..3] of integer = ( + {round 1} ( 7, 22, 17, 12), + {round 2} ( 5, 20, 14, 9), + {round 3} ( 4, 23, 16, 11), + {round 4} ( 6, 21, 15, 10)); + + kFactors: array[ {round}0..3] of integer = (1, 5, 3, 7); + kOffsets: array[ {round}0..3] of integer = (0, 1, 5, 0); + + +procedure TMD5_Hasher.Update( Source: TMemoryStream); +var + X: array[ 0..15 ] of uint32; + a, k, s, i, j: integer; + FGHI: uint32; + Round, Cycle: integer; + AABBCCDD: array[ 0.. 3 ] of uint32; + aIndicies: array[0..3] of integer; // 0..3 indexing into ABCD[] + +begin +Assert( Source.Size = 64, 'TMD5_Hasher.Update - Wrong block size.'); +Inc( FCount, 512); +Move( Source.Memory^, X, 64); +FGHI := 0; + +for a := 0 to 3 do + AABBCCDD[a] := ABCD[a]; + +for i := 0 to 3 do + aIndicies[ i] := i; + +Round := 0; +Cycle := 0; +k := 0; +for i := 0 to 63 do + begin +// aIndexes = (4 - (i mod 4)) mod 4; +// Round = i div 16; + case Round of + 0: // Round 1 + FGHI := (ABCD[ aIndicies[1]] and ABCD[ aIndicies[2]]) or // F(X=b,Y=c,Z=d) = XY v not(X) Z + ((not ABCD[ aIndicies[1]]) and ABCD[ aIndicies[3]]); + + 1: // Round 2 + FGHI := (ABCD[ aIndicies[1]] and ABCD[ aIndicies[3]]) or // G(X=b,Y=c,Z=d) = XZ v Y not(Z) + ((not ABCD[ aIndicies[3]]) and ABCD[ aIndicies[2]]); + + 2: // Round 3 + FGHI := ABCD[ aIndicies[1]] xor ABCD[ aIndicies[2]] xor ABCD[ aIndicies[3]]; // H(X=b,Y=c,Z=d) = X xor Y xor Z + + 3: // Round 4 + FGHI := ABCD[ aIndicies[2]] xor // I(X=b,Y=c,Z=d) = Y xor (X v not(Z)) + (ABCD[ aIndicies[1]] or (not ABCD[ aIndicies[3]])) + end; + s := sValues[ Round, aIndicies[0]]; + ABCD[ aIndicies[0]] := ABCD[ aIndicies[1]] + + RotateLeft_u32( ABCD[ aIndicies[0]] + FGHI + X[k] + T[i], s); + for j := 0 to 3 do + begin + Dec( aIndicies[j]); + if aIndicies[j] = -1 then + aIndicies[j] := 3 + end; + if Cycle <= 14 then + begin + Inc( Cycle); + Inc( k, kFactors[ Round]); + if k >= 16 then + Dec( k, 16) + end + else + begin + Cycle := 0; + Inc( Round); + k := kOffsets[ Round] + end + end; +for a := 0 to 3 do + ABCD[a] := ABCD[a] + AABBCCDD[a] +end; + +end. diff --git a/run/TPLB3.MemoryStreamPool.pas b/LockBox3/run/TPLB3.MemoryStreamPool.pas similarity index 96% rename from run/TPLB3.MemoryStreamPool.pas rename to LockBox3/run/TPLB3.MemoryStreamPool.pas index b681326..e884933 100644 --- a/run/TPLB3.MemoryStreamPool.pas +++ b/LockBox3/run/TPLB3.MemoryStreamPool.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,458 +12,458 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.MemoryStreamPool; -interface -uses Classes; - -type - -IMemoryStreamPool = interface - ['{ADB2D4BA-40F6-4249-923E-201D4719609B}'] - function BayCount: integer; - procedure GetUsage( Size: integer; var Current, Peak: integer); - function GetSize( Idx: Integer): integer; - function NewMemoryStream( InitSize: integer): TMemoryStream; - end; - -TPooledMemoryStream = class( TMemoryStream) - protected - FPool: IMemoryStreamPool; - FCoVector: integer; - - function Realloc( var NewCapacity: Longint): Pointer; override; - - public - constructor Create( const Pool1: IMemoryStreamPool); - end; - - -function NewPool: IMemoryStreamPool; - -implementation - - - - - - -uses RTLConsts, SysUtils, TPLB3.PointerArithmetic; - - - -const - iNullCoVector = -1; - MemoryDelta = $200; // Copy from implementation section of Classes. - CacheSegmentSize = MemoryDelta * 2; // Should be the same or a multiple of MemoryDelta. - AnticipatedPeakUsage = 30; - -type - -IMemoryStreamPoolEx = interface - ['{0F24C5E3-3331-4A47-8342-CF50DBAFF4FF}'] - function NullCoVector: integer; - procedure GetMem1 ( var p: pointer; var CoVector: integer; Size: Integer); - procedure FreeMem1 ( P: Pointer; CoVector: integer; Size: Integer); - procedure ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); - function CanManageSize( Size: integer): boolean; - end; - -{$IF CompilerVersion > 15} -TMemoryStreamPool = class( TInterfacedObject, IMemoryStreamPool, IMemoryStreamPoolEx) - private -{$IFEND} - - type IAllocationRecordList = interface - ['{ECDAD2EC-C47E-4D24-B583-F36E62D3FDBB}'] - function GetSize( Idx: integer): integer; - - procedure RecordUsage( Size: integer); - procedure RecordReturn( Size: integer); - procedure GetUsage( Size: integer; var Current, Peak: integer); - function Count: integer; - property Sizes[ Idx: Integer]: integer read GetSize; - end; - -{$IF CompilerVersion <= 15} -TMemoryStreamPool = class( TInterfacedObject, IMemoryStreamPool, IMemoryStreamPoolEx) -{$IFEND} - private - FAllocRecords: IAllocationRecordList; - FCache: pointer; - FCacheSegmentInUse: TBits; - FCachedCount: integer; - - protected - procedure GetMem1 ( var p: pointer; var CoVector: integer; Size: Integer); virtual; - procedure FreeMem1 ( P: Pointer; CoVector: integer; Size: Integer); virtual; - procedure ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); virtual; - function NullCoVector: integer; virtual; - function CanManageSize( Size: integer): boolean; virtual; - - public - function BayCount: integer; - procedure GetUsage( Size: integer; var Current, Peak: integer); - function GetSize( Idx: Integer): integer; - - function NewMemoryStream( InitSize: integer): TMemoryStream; virtual; - constructor Create; - destructor Destroy; override; - end; - - -function NewPool: IMemoryStreamPool; -begin -result := TMemoryStreamPool.Create -end; - -type -PAllocationRecord = ^TAllocationRecord; -TAllocationRecord = record - FSize: integer; - FCurrentUsage: integer; - FPeakUsage: integer; - end; - - -{$IF CompilerVersion > 15} -TAllocationRecordListObj = class( TInterfacedObject, TMemoryStreamPool.IAllocationRecordList) -{$ELSE} -TAllocationRecordListObj = class( TInterfacedObject, IAllocationRecordList) -{$IFEND} - private - FAllocRecs: TList; // of AllocationRecord - function GetSize( Idx: integer): integer; - procedure RecordUsage( Size: integer); - procedure RecordReturn( Size: integer); - procedure GetUsage( Size: integer; var Current, Peak: integer); - function Count: integer; - public - constructor Create; - destructor Destroy; override; - end; - -{ TMemoryStreamPool } - -function TMemoryStreamPool.NewMemoryStream( InitSize: integer): TMemoryStream; -begin -result := TPooledMemoryStream.Create( self); -if InitSize > 0 then - result.Size := InitSize -end; - -function TMemoryStreamPool.NullCoVector: integer; -begin -result := iNullCoVector -end; - - -{ TPooledMemoryStream } - -constructor TPooledMemoryStream.Create( const Pool1: IMemoryStreamPool); -var - Ex: IMemoryStreamPoolEx; -begin -FPool := Pool1; -if Supports( FPool, IMemoryStreamPoolEx, Ex) then - FCoVector := Ex.NullCoVector; -inherited Create -end; - - - -function TPooledMemoryStream.Realloc( var NewCapacity: Integer): Pointer; -// Fragments of this method were copied from the Classes unit and modified. -var - Ex: IMemoryStreamPoolEx; -begin -if (NewCapacity > 0) and (NewCapacity <> Size) then - NewCapacity := (NewCapacity + (MemoryDelta - 1)) and not (MemoryDelta - 1); -result := Memory; -if NewCapacity <> Capacity then - begin - if NewCapacity = 0 then - begin - if Supports( FPool, IMemoryStreamPoolEx, Ex) then - begin - Ex.FreeMem1( Memory, FCoVector, Capacity); - FCoVector := Ex.NullCoVector - end - else - FreeMem( Memory); - result := nil - end - else - begin - if Capacity = 0 then - begin - if Supports( FPool, IMemoryStreamPoolEx, Ex) then - Ex.GetMem1( result, FCoVector, NewCapacity) - else - GetMem( result, NewCapacity); - end - else - begin - if Supports( FPool, IMemoryStreamPoolEx, Ex) then - Ex.ReallocMem1( result, FCoVector, Capacity, NewCapacity) - else - ReallocMem( result, NewCapacity); - end; - if Result = nil then - raise EStreamError.CreateRes( @SMemoryStreamError) - end - end -end; - - - - - - - - - - -function TMemoryStreamPool.BayCount: integer; -begin -result := FAllocRecords.Count -end; - - -function TMemoryStreamPool.CanManageSize( Size: integer): boolean; -begin -result := (Size <= CacheSegmentSize) and (FCachedCount < AnticipatedPeakUsage) -end; - - - - -constructor TMemoryStreamPool.Create; -begin -FAllocRecords := TAllocationRecordListObj.Create; -GetMem( FCache, CacheSegmentSize * AnticipatedPeakUsage); -FCacheSegmentInUse := TBits.Create; -FCacheSegmentInUse.Size := AnticipatedPeakUsage; -FCachedCount := 0 -end; - - -destructor TMemoryStreamPool.Destroy; -begin -FAllocRecords := nil; -FCacheSegmentInUse.Free; -FreeMem( FCache); -inherited -end; - - -procedure TMemoryStreamPool.FreeMem1( P: Pointer; CoVector: integer; Size: integer); -// Note: Size = -1 means size unknown. -begin -if CoVector = iNullCoVector then - FreeMem( P) - else - begin - if (CoVector >= 0) and (CoVector < FCacheSegmentInUse.Size) then - FCacheSegmentInUse[ CoVector] := False; - if FCachedCount > 0 then - Dec( FCachedCount) - end; -FAllocRecords.RecordReturn( Size) -end; - - - -procedure TMemoryStreamPool.GetMem1( var p: pointer; var CoVector: integer; Size: Integer); -var - j, Idx: integer; -begin -Idx := -1; -if CanManageSize( Size) then - for j := 0 to AnticipatedPeakUsage - 1 do - begin - if j >= FCacheSegmentInUse.Size then break; - if FCacheSegmentInUse[j] then continue; - Idx := j; - break - end; -if Idx <> -1 then - begin - p := Offset( FCache, Idx * CacheSegmentSize); - CoVector := Idx; - FCacheSegmentInUse[ Idx] := True; - Inc( FCachedCount) - end - else - begin - GetMem( p, Size); - CoVector := iNullCoVector - end; -FAllocRecords.RecordUsage( Size); -end; - - - -function TMemoryStreamPool.GetSize( Idx: Integer): integer; -begin -result := FAllocRecords.Sizes[ Idx] -end; - - - -procedure TMemoryStreamPool.GetUsage( Size: integer; var Current, Peak: integer); -begin -FAllocRecords.GetUsage( Size, Current, Peak) -end; - - - -procedure TMemoryStreamPool.ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); -var - isNewManaged: boolean; -begin -isNewManaged := CanManageSize( Size); -// TO DO: Override and implement efficient caching. -if (CoVector <> iNullCoVector) and isNewManaged then - begin - // Old AND new managed - // Do nothing. Old and New both fit in the same physical space. - end - else if (CoVector = iNullCoVector) and (not isNewManaged) then - begin // neither Old NOR New new managed - ReallocMem( P, Size); - // CoVector = iNullCoVector - end - else - begin // Old, new mixed managed - FreeMem1( P, CoVector, OldSize); // -1 means old size not given. - GetMem1( p, CoVector, Size) - end -end; - - -{ TAllocationRecordListObj } - -function TAllocationRecordListObj.Count: integer; -begin -result := FAllocRecs.Count -end; - -constructor TAllocationRecordListObj.Create; -begin -FAllocRecs := TList.Create -end; - -destructor TAllocationRecordListObj.Destroy; -var - j: integer; - P: pointer; -begin -for j := 0 to FAllocRecs.Count - 1 do - begin - P := FAllocRecs[j]; - FreeMem( P) - end; -FAllocRecs.Free; -inherited; -end; - -function TAllocationRecordListObj.GetSize( Idx: integer): integer; -begin -result := PAllocationRecord( FAllocRecs[ Idx])^.FSize -end; - - -procedure TAllocationRecordListObj.GetUsage( - Size: integer; var Current, Peak: integer); -var - j: integer; - P: PAllocationRecord; -begin -Current := 0; -Peak := 0; -for j := 0 to FAllocRecs.Count - 1 do - begin - P := PAllocationRecord( FAllocRecs[j]); - if P^.FSize <> Size then continue; - Current := P^.FCurrentUsage; - Peak := P^.FPeakUsage; - break - end -end; - - -procedure TAllocationRecordListObj.RecordReturn( Size: integer); -var - j: integer; - P: PAllocationRecord; - Current: integer; -begin -P := nil; -Current := 0; -for j := 0 to FAllocRecs.Count - 1 do - begin - P := PAllocationRecord( FAllocRecs[j]); - if P^.FSize <> Size then continue; - Current := P^.FCurrentUsage; - break - end; -if Current > 0 then - P^.FCurrentUsage := Current - 1 -end; - - - -procedure TAllocationRecordListObj.RecordUsage( Size: integer); -var - j: integer; - Pntr: pointer; - P, Q: PAllocationRecord; - Current, Peak: integer; - //s: string; -begin -Current := 0; -Peak := 0; -P := nil; -for j := 0 to FAllocRecs.Count - 1 do - begin - Q := PAllocationRecord( FAllocRecs[j]); - if Q^.FSize <> Size then continue; - Current := Q^.FCurrentUsage; - Peak := Q^.FPeakUsage; - P := Q; - break - end; -if not assigned( P) then - begin - // New( P); - GetMem( Pntr, SizeOf( TAllocationRecord)); - P := PAllocationRecord( Pntr); - P^.FSize := Size; - FAllocRecs.Add( P) - end; -Inc( Current); -if Current > Peak then - Peak := Current; -P^.FCurrentUsage := Current; -P^.FPeakUsage := Peak -end; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.MemoryStreamPool; +interface +uses Classes; + +type + +IMemoryStreamPool = interface + ['{ADB2D4BA-40F6-4249-923E-201D4719609B}'] + function BayCount: integer; + procedure GetUsage( Size: integer; var Current, Peak: integer); + function GetSize( Idx: Integer): integer; + function NewMemoryStream( InitSize: integer): TMemoryStream; + end; + +TPooledMemoryStream = class( TMemoryStream) + protected + FPool: IMemoryStreamPool; + FCoVector: integer; + + function Realloc( var NewCapacity: Longint): Pointer; override; + + public + constructor Create( const Pool1: IMemoryStreamPool); + end; + + +function NewPool: IMemoryStreamPool; + +implementation + + + + + + +uses RTLConsts, SysUtils, TPLB3.PointerArithmetic; + + + +const + iNullCoVector = -1; + MemoryDelta = $200; // Copy from implementation section of Classes. + CacheSegmentSize = MemoryDelta * 2; // Should be the same or a multiple of MemoryDelta. + AnticipatedPeakUsage = 30; + +type + +IMemoryStreamPoolEx = interface + ['{0F24C5E3-3331-4A47-8342-CF50DBAFF4FF}'] + function NullCoVector: integer; + procedure GetMem1 ( var p: pointer; var CoVector: integer; Size: Integer); + procedure FreeMem1 ( P: Pointer; CoVector: integer; Size: Integer); + procedure ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); + function CanManageSize( Size: integer): boolean; + end; + +{$IF CompilerVersion > 15} +TMemoryStreamPool = class( TInterfacedObject, IMemoryStreamPool, IMemoryStreamPoolEx) + private +{$IFEND} + + type IAllocationRecordList = interface + ['{ECDAD2EC-C47E-4D24-B583-F36E62D3FDBB}'] + function GetSize( Idx: integer): integer; + + procedure RecordUsage( Size: integer); + procedure RecordReturn( Size: integer); + procedure GetUsage( Size: integer; var Current, Peak: integer); + function Count: integer; + property Sizes[ Idx: Integer]: integer read GetSize; + end; + +{$IF CompilerVersion <= 15} +TMemoryStreamPool = class( TInterfacedObject, IMemoryStreamPool, IMemoryStreamPoolEx) +{$IFEND} + private + FAllocRecords: IAllocationRecordList; + FCache: pointer; + FCacheSegmentInUse: TBits; + FCachedCount: integer; + + protected + procedure GetMem1 ( var p: pointer; var CoVector: integer; Size: Integer); virtual; + procedure FreeMem1 ( P: Pointer; CoVector: integer; Size: Integer); virtual; + procedure ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); virtual; + function NullCoVector: integer; virtual; + function CanManageSize( Size: integer): boolean; virtual; + + public + function BayCount: integer; + procedure GetUsage( Size: integer; var Current, Peak: integer); + function GetSize( Idx: Integer): integer; + + function NewMemoryStream( InitSize: integer): TMemoryStream; virtual; + constructor Create; + destructor Destroy; override; + end; + + +function NewPool: IMemoryStreamPool; +begin +result := TMemoryStreamPool.Create +end; + +type +PAllocationRecord = ^TAllocationRecord; +TAllocationRecord = record + FSize: integer; + FCurrentUsage: integer; + FPeakUsage: integer; + end; + + +{$IF CompilerVersion > 15} +TAllocationRecordListObj = class( TInterfacedObject, TMemoryStreamPool.IAllocationRecordList) +{$ELSE} +TAllocationRecordListObj = class( TInterfacedObject, IAllocationRecordList) +{$IFEND} + private + FAllocRecs: TList; // of AllocationRecord + function GetSize( Idx: integer): integer; + procedure RecordUsage( Size: integer); + procedure RecordReturn( Size: integer); + procedure GetUsage( Size: integer; var Current, Peak: integer); + function Count: integer; + public + constructor Create; + destructor Destroy; override; + end; + +{ TMemoryStreamPool } + +function TMemoryStreamPool.NewMemoryStream( InitSize: integer): TMemoryStream; +begin +result := TPooledMemoryStream.Create( self); +if InitSize > 0 then + result.Size := InitSize +end; + +function TMemoryStreamPool.NullCoVector: integer; +begin +result := iNullCoVector +end; + + +{ TPooledMemoryStream } + +constructor TPooledMemoryStream.Create( const Pool1: IMemoryStreamPool); +var + Ex: IMemoryStreamPoolEx; +begin +FPool := Pool1; +if Supports( FPool, IMemoryStreamPoolEx, Ex) then + FCoVector := Ex.NullCoVector; +inherited Create +end; + + + +function TPooledMemoryStream.Realloc( var NewCapacity: Integer): Pointer; +// Fragments of this method were copied from the Classes unit and modified. +var + Ex: IMemoryStreamPoolEx; +begin +if (NewCapacity > 0) and (NewCapacity <> Size) then + NewCapacity := (NewCapacity + (MemoryDelta - 1)) and not (MemoryDelta - 1); +result := Memory; +if NewCapacity <> Capacity then + begin + if NewCapacity = 0 then + begin + if Supports( FPool, IMemoryStreamPoolEx, Ex) then + begin + Ex.FreeMem1( Memory, FCoVector, Capacity); + FCoVector := Ex.NullCoVector + end + else + FreeMem( Memory); + result := nil + end + else + begin + if Capacity = 0 then + begin + if Supports( FPool, IMemoryStreamPoolEx, Ex) then + Ex.GetMem1( result, FCoVector, NewCapacity) + else + GetMem( result, NewCapacity); + end + else + begin + if Supports( FPool, IMemoryStreamPoolEx, Ex) then + Ex.ReallocMem1( result, FCoVector, Capacity, NewCapacity) + else + ReallocMem( result, NewCapacity); + end; + if Result = nil then + raise EStreamError.CreateRes( @SMemoryStreamError) + end + end +end; + + + + + + + + + + +function TMemoryStreamPool.BayCount: integer; +begin +result := FAllocRecords.Count +end; + + +function TMemoryStreamPool.CanManageSize( Size: integer): boolean; +begin +result := (Size <= CacheSegmentSize) and (FCachedCount < AnticipatedPeakUsage) +end; + + + + +constructor TMemoryStreamPool.Create; +begin +FAllocRecords := TAllocationRecordListObj.Create; +GetMem( FCache, CacheSegmentSize * AnticipatedPeakUsage); +FCacheSegmentInUse := TBits.Create; +FCacheSegmentInUse.Size := AnticipatedPeakUsage; +FCachedCount := 0 +end; + + +destructor TMemoryStreamPool.Destroy; +begin +FAllocRecords := nil; +FCacheSegmentInUse.Free; +FreeMem( FCache); +inherited +end; + + +procedure TMemoryStreamPool.FreeMem1( P: Pointer; CoVector: integer; Size: integer); +// Note: Size = -1 means size unknown. +begin +if CoVector = iNullCoVector then + FreeMem( P) + else + begin + if (CoVector >= 0) and (CoVector < FCacheSegmentInUse.Size) then + FCacheSegmentInUse[ CoVector] := False; + if FCachedCount > 0 then + Dec( FCachedCount) + end; +FAllocRecords.RecordReturn( Size) +end; + + + +procedure TMemoryStreamPool.GetMem1( var p: pointer; var CoVector: integer; Size: Integer); +var + j, Idx: integer; +begin +Idx := -1; +if CanManageSize( Size) then + for j := 0 to AnticipatedPeakUsage - 1 do + begin + if j >= FCacheSegmentInUse.Size then break; + if FCacheSegmentInUse[j] then continue; + Idx := j; + break + end; +if Idx <> -1 then + begin + p := Offset( FCache, Idx * CacheSegmentSize); + CoVector := Idx; + FCacheSegmentInUse[ Idx] := True; + Inc( FCachedCount) + end + else + begin + GetMem( p, Size); + CoVector := iNullCoVector + end; +FAllocRecords.RecordUsage( Size); +end; + + + +function TMemoryStreamPool.GetSize( Idx: Integer): integer; +begin +result := FAllocRecords.Sizes[ Idx] +end; + + + +procedure TMemoryStreamPool.GetUsage( Size: integer; var Current, Peak: integer); +begin +FAllocRecords.GetUsage( Size, Current, Peak) +end; + + + +procedure TMemoryStreamPool.ReallocMem1( var p: Pointer; var CoVector: integer; OldSize, Size: Integer); +var + isNewManaged: boolean; +begin +isNewManaged := CanManageSize( Size); +// TO DO: Override and implement efficient caching. +if (CoVector <> iNullCoVector) and isNewManaged then + begin + // Old AND new managed + // Do nothing. Old and New both fit in the same physical space. + end + else if (CoVector = iNullCoVector) and (not isNewManaged) then + begin // neither Old NOR New new managed + ReallocMem( P, Size); + // CoVector = iNullCoVector + end + else + begin // Old, new mixed managed + FreeMem1( P, CoVector, OldSize); // -1 means old size not given. + GetMem1( p, CoVector, Size) + end +end; + + +{ TAllocationRecordListObj } + +function TAllocationRecordListObj.Count: integer; +begin +result := FAllocRecs.Count +end; + +constructor TAllocationRecordListObj.Create; +begin +FAllocRecs := TList.Create +end; + +destructor TAllocationRecordListObj.Destroy; +var + j: integer; + P: pointer; +begin +for j := 0 to FAllocRecs.Count - 1 do + begin + P := FAllocRecs[j]; + FreeMem( P) + end; +FAllocRecs.Free; +inherited; +end; + +function TAllocationRecordListObj.GetSize( Idx: integer): integer; +begin +result := PAllocationRecord( FAllocRecs[ Idx])^.FSize +end; + + +procedure TAllocationRecordListObj.GetUsage( + Size: integer; var Current, Peak: integer); +var + j: integer; + P: PAllocationRecord; +begin +Current := 0; +Peak := 0; +for j := 0 to FAllocRecs.Count - 1 do + begin + P := PAllocationRecord( FAllocRecs[j]); + if P^.FSize <> Size then continue; + Current := P^.FCurrentUsage; + Peak := P^.FPeakUsage; + break + end +end; + + +procedure TAllocationRecordListObj.RecordReturn( Size: integer); +var + j: integer; + P: PAllocationRecord; + Current: integer; +begin +P := nil; +Current := 0; +for j := 0 to FAllocRecs.Count - 1 do + begin + P := PAllocationRecord( FAllocRecs[j]); + if P^.FSize <> Size then continue; + Current := P^.FCurrentUsage; + break + end; +if Current > 0 then + P^.FCurrentUsage := Current - 1 +end; + + + +procedure TAllocationRecordListObj.RecordUsage( Size: integer); +var + j: integer; + Pntr: pointer; + P, Q: PAllocationRecord; + Current, Peak: integer; + //s: string; +begin +Current := 0; +Peak := 0; +P := nil; +for j := 0 to FAllocRecs.Count - 1 do + begin + Q := PAllocationRecord( FAllocRecs[j]); + if Q^.FSize <> Size then continue; + Current := Q^.FCurrentUsage; + Peak := Q^.FPeakUsage; + P := Q; + break + end; +if not assigned( P) then + begin + // New( P); + GetMem( Pntr, SizeOf( TAllocationRecord)); + P := PAllocationRecord( Pntr); + P^.FSize := Size; + FAllocRecs.Add( P) + end; +Inc( Current); +if Current > Peak then + Peak := Current; +P^.FCurrentUsage := Current; +P^.FPeakUsage := Peak +end; + +end. diff --git a/run/TPLB3.OFB.pas b/LockBox3/run/TPLB3.OFB.pas similarity index 96% rename from run/TPLB3.OFB.pas rename to LockBox3/run/TPLB3.OFB.pas index cb9a45d..7d45c90 100644 --- a/run/TPLB3.OFB.pas +++ b/LockBox3/run/TPLB3.OFB.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,143 +12,143 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.OFB; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TOFB = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TOFBLink = class( TBlockChainLink) - public - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - -uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; - -{ TOFB } - -function TOFB.ChainingFeatures: TChainingFeatureSet; -begin -result := [cfKeyStream, cfAutoXOR] -end; - - -function TOFB.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TOFBLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TOFB.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TOFBLink.BaseCreate( Key, InitializationVector, Cipher) -end; - - - -function TOFB.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + - '|section 6.4' -end; - -function TOFB.DisplayName: string; -begin -result := 'OFB' -end; - - - -function TOFB.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afCryptographicallyWeak] -end; - - -function TOFB.ProgId: string; -begin -result := OFB_ProgId -end; - - - - - -function TOFB.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Output_feedback_.28OFB.29' -end; - -{ TOFBLink } - -procedure TOFBLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Ciphertext); -// The plaintext block will automatically be xored with the product -// of the above by virture of the cfAutoXOR feature. -CopyMemoryStream( Ciphertext, FCV) -end; - - -procedure TOFBLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -FCipher.Encrypt_Block( FCV, Plaintext); -// The ciphertext block will automatically be xored with the product -// of the above by virture of the cfAutoXOR feature. -CopyMemoryStream( Plaintext, FCV) -end; - - - - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.OFB; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TOFB = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TOFBLink = class( TBlockChainLink) + public + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; + +{ TOFB } + +function TOFB.ChainingFeatures: TChainingFeatureSet; +begin +result := [cfKeyStream, cfAutoXOR] +end; + + +function TOFB.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TOFBLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TOFB.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TOFBLink.BaseCreate( Key, InitializationVector, Cipher) +end; + + + +function TOFB.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf' + + '|section 6.4' +end; + +function TOFB.DisplayName: string; +begin +result := 'OFB' +end; + + + +function TOFB.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afCryptographicallyWeak] +end; + + +function TOFB.ProgId: string; +begin +result := OFB_ProgId +end; + + + + + +function TOFB.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Output_feedback_.28OFB.29' +end; + +{ TOFBLink } + +procedure TOFBLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Ciphertext); +// The plaintext block will automatically be xored with the product +// of the above by virture of the cfAutoXOR feature. +CopyMemoryStream( Ciphertext, FCV) +end; + + +procedure TOFBLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +FCipher.Encrypt_Block( FCV, Plaintext); +// The ciphertext block will automatically be xored with the product +// of the above by virture of the cfAutoXOR feature. +CopyMemoryStream( Plaintext, FCV) +end; + + + + +end. + diff --git a/run/TPLB3.OpenSSL.pas b/LockBox3/run/TPLB3.OpenSSL.pas similarity index 96% rename from run/TPLB3.OpenSSL.pas rename to LockBox3/run/TPLB3.OpenSSL.pas index 90e5cc7..e5a9e7b 100644 --- a/run/TPLB3.OpenSSL.pas +++ b/LockBox3/run/TPLB3.OpenSSL.pas @@ -1,2555 +1,2555 @@ -{* ***** BEGIN LICENSE BLOCK ***** -This file is a wrapper around the OpenSSL dynamic link library, using -its published API. As a consequence, there are some identifiers in this -file which are copied from or derived from the OpenSSL source code header files. - -Although the use here, of the OpenSSL headers are sufficiently limited, -that copying of this file in relation to the OpenSSL copyright is defended -by the doctrine of fair use, as a measure of respect, please note the following -license conditions for the redistribution of the OpenSSL project products. - - - -======================================================================== -======================================================================== -========== BEGINNING OF THE OPENSSL LICENSE DISCLOSURE =============== -======================================================================== -======================================================================== - - LICENSE ISSUES - ============== - - The OpenSSL toolkit stays under a dual license, i.e. both the conditions of - the OpenSSL License and the original SSLeay license apply to the toolkit. - See below for the actual license texts. Actually both licenses are BSD-style - Open Source licenses. In case of any license issues related to OpenSSL - please contact openssl-core@openssl.org. - - OpenSSL License - --------------- - -/* ==================================================================== - * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - - Original SSLeay License - ----------------------- - -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - LICENSE ISSUES - ============== - - The OpenSSL toolkit stays under a dual license, i.e. both the conditions of - the OpenSSL License and the original SSLeay license apply to the toolkit. - See below for the actual license texts. Actually both licenses are BSD-style - Open Source licenses. In case of any license issues related to OpenSSL - please contact openssl-core@openssl.org. - - OpenSSL License - --------------- - -/* ==================================================================== - * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - - Original SSLeay License - ----------------------- - -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -======================================================================== -======================================================================== -========== END OF THE OPENSSL LICENSE DISCLOSURE ====================== -======================================================================== -======================================================================== - - - - - - - -======================================================================== -======================================================================== -========== BEGINNING OF COPYRIGHT NOTICE AND ========================== -========== STATEMENT OF COPYING PERMISSION FOR THIS FILE =========== -======================================================================== -======================================================================== - -Copyright 2011 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - - -======================================================================== -======================================================================== -========== END OF COPYRIGHT NOTICE AND ================================ -========== STATEMENT OF COPYING PERMISSION FOR THIS FILE =========== -======================================================================== -======================================================================== - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.OpenSSL experimental; -// {$IFDEF VER150} -// unit uTPLb_OpenSSL; -// {$ENDIF} -// -// {$IF compilerversion > 16} -// unit TPLB3.OpenSSL experimental; -// {$IFEND} - -{$define OpenSSL_Win64_NotYetSupported} -// Undefine the above, when someone has tested the TOpenSSL_Signatory component -// for 64-bit platform. - - -interface -uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.Signatory, - TPLB3.Asymetric, SysUtils, {$IFDEF MSWINDOWS}Windows,{$ENDIF} Types, - TPLB3.Compatibility; - -const -{$IF Defined(WIN32)} - LibEay = 'libeay32.dll'; -{$ELSEIF Defined(WIN64)} - LibEay = 'libeay64.dll'; -{$ELSEIF not Defined(WIN32) and not Defined(WIN64)} - LibEay = ''; -{$IFEND} - Default_AsymetricKeySizeInBits = 2048; - -// OpenSSL is not supported on NEXTGEN platforms; these aliases are just to -// keep the compiler happy. -{$IFDEF NEXTGEN} -type - AnsiChar = Char; - AnsiString = string; - PAnsiChar = PWideChar; - PAnsiString = ^AnsiString; - UTF8String = string; -{$ENDIF} - -type -TOpenLibError = ( - erNull, - erSetDLLDirectory, - erLoadFailed, - erException, - erVersionTooLow, - erSignatureAbsent, - erPlatformNotSupported - ); - - -type - -TCipherToEncryptPrivateKeyWith = ( - cipher_InTheClear, - cipher_des_ede3_cbc, - cipher_des_cbc , - cipher_idea_cbc , - cipher_seed_cbc , - cipher_aes_128_cbc, - cipher_aes_192_cbc , - cipher_aes_256_cbc , - cipher_aes_256_ofb , - cipher_camellia_128_cbc, - cipher_camellia_192_cbc, - cipher_camellia_256_cbc); - - -const - EVP_MAX_MD_SIZE = 64; - EVP_MAX_KEY_LENGTH = 32; - EVP_MAX_IV_LENGTH = 16; - EVP_MAX_BLOCK_LENGTH = 32; - -type -EVP_CIPHER_CTX = packed record - cipher: pointer; // to EVP_CIPHER - engine: pointer; // to ENGINE *engine; Functional reference if 'cipher' is ENGINE-provided - encrypt: integer; // encrypt or decrypt - buf_len: integer; // number we have left - - oiv: array[0..EVP_MAX_IV_LENGTH-1] of byte; // original iv - iv : array[0..EVP_MAX_IV_LENGTH-1] of byte; // working iv - buf: array[0..EVP_MAX_BLOCK_LENGTH-1] of byte; // saved partial block - num: integer; // used by cfb/ofb mode - app_data: pointer; // application stuff - key_len: integer; // May change for variable length cipher - flags: longword; // Various flags - cipher_data: pointer; // per EVP data - final_used: integer; - block_mask: integer; - final1: array[0..EVP_MAX_BLOCK_LENGTH-1] of byte; // possible final block */ - xtra: array[0..100] of byte; - end; - -EVP_CIPHER_varProc = procedure( var a: EVP_CIPHER_CTX); cdecl; -EVP_CIPHER_intFunc = function ( var a: EVP_CIPHER_CTX): integer; cdecl; - -PBIO = pointer; // For the curious, you can find a more transparent - // definition of BIO/PBIO in unit IdSSLOpenSSLHeaders, - // or go directly to the OpenSSL header files. - -TOpenSSL_Signatory = class; - - -TBIO = class( TObject) - protected - FLib: TOpenSSL_Signatory; - FBIOobj: pBIO; - - function InitBIO_Object: pBIO; virtual; abstract; - - public - constructor Create( Lib1: TOpenSSL_Signatory); - function Readansistring: ansistring; - // Actually the character encoding must be determined by the context. - // It is not necessarily ansi. It could be a raw byte data. - destructor Destroy; override; - end; - -TMemoryBIO = class( TBIO) - protected - function InitBIO_Object: pBIO; override; - - public - end; - -TReadOnlyBIO = class( TBIO) - private - FData: TBytes; - - protected - function InitBIO_Object: pBIO; override; - - public - constructor Create( Lib1: TOpenSSL_Signatory; Data: pointer; DataLen: integer); - destructor Destroy; override; - end; - - -PBN_GENCB = ^BN_GENCB; -BN_GENCB = packed record - ver : longword; // WILL be 2. - arg : pointer; - cb_2: function( p1, p2 : longint; p3: PBN_GENCB): longint; cdecl; - end; - -pem_password_cb = function( buf: PAnsistring; size, rwflag: longint; - userdata: pointer): longint; cdecl; - -TSigHashKind = ( // How was the input message to sign/verify computed from the source document? - hshSHA1, // The document was hashed with SHA1 to produce the input message. NID_sha1 = 64 - hshRipemd160, // The hash algorithm was ripemd160. NID_ripemd160 = 117 - hshMD5); // The hash was MD5. NID_md5 = 4 - -BIGNUM = packed record - d : longword; - top : longint; - dmax : longint; - neg : longint; - flags: longint; - end; -PBIGNUM = ^BIGNUM; - -CRYPTO_EX_DATA = packed record - sk : pointer; - dummy: longint; - end; - -RSA = packed record - pad : longint; - version : longword; - engine : pointer; // PENGINE - n : PBIGNUM; - e : PBIGNUM; - d : PBIGNUM; - p : PBIGNUM; - q : PBIGNUM; - dmp1 : PBIGNUM; - dmq1 : PBIGNUM; - iqmp : PBIGNUM; - ex_data : CRYPTO_EX_DATA; - references: longint; - flags : longint; - _method_mod_n : pointer; - _method_mod_p : pointer; - _method_mod_q : pointer; - bignum_data : PAnsichar; - blinding : pointer; - mt_blinding : pointer; - end; -PRSA = ^RSA; -PPRSA = ^PRSA; - -Pbio_info_cb = procedure( _para1: PBIO; _para2: longint; - _para3: PAnsichar; _para4: longint; _para5, _para6: longword); cdecl; - -BIO_METHOD = packed record - _type: longint; - name : PAnsichar; - bwrite : function (_para1: PBIO; _para2 : PAnsichar; _para3 : longint): longint; cdecl; - bread : function (_para1: PBIO; _para2: PAnsiChar; _para3: longint): longint; cdecl; - bputs : function (_para1: PBIO; _para2 : PAnsichar): longint; cdecl; - bgets : function (_para1: PBIO; _para2 : PAnsichar; _para3: longint): longint; cdecl; - ctrl : function (_para1: PBIO; _para2 : longint; _para3: longword; _para4: pointer): longword; cdecl; - create : function (_para1: PBIO): longint; cdecl; - destroy : function (_para1: PBIO): longint; cdecl; - callback_ctrl: function (_para1: PBIO; _para2: longint; _para : pbio_info_cb): longword; cdecl; - end; -PBIO_METHOD = ^BIO_METHOD; - -PEVP_CIPHER = pointer; - -TOpenSLL_CipherFunc = function: PEVP_CIPHER; cdecl; - -TOnOpenSSLProgress = function( Sender: TObject; p1, p2: integer): boolean of object; - - -TOpenSSL_Base = class -{$IF CompilerVersion > 15} - abstract -{$IFEND} - ( TTPLb_BaseNonVisualComponent) - private - FHandle: HMODULE; - FLibPath: string; - FLibName: string; - FFileName: string; // LibPath + LibName - FDLLDir: string; // dir of needed DLL's. - FRqrMajorV: integer; - FRqrMinorV: integer; - FRqrReleaseV: integer; - FRqrBuildV: integer; - FErr: TOpenLibError; - FWindowsError: DWORD; - FErrMsg: string; - FMajorV, FMinorV, FReleaseV, FBuildV: integer; - FhaveTriedToOpen: boolean; - FdoOPENSSL_LOAD_CONF: boolean; - FisSafeToFreeRSA: boolean; - FPassword: utf8string; - FCachedSize: integer; - - FOpenSSLproc_BioSMem: function: PBIO_METHOD cdecl; - FOpenSSLproc_BioNew : function(_type: PBIO_METHOD): PBIO cdecl; - FOpenSSLproc_BioFree: function( bio: PBIO): longint cdecl; - FOpenSSLproc_BioRead: function( b: PBIO; data: Pointer; len: longint): longint cdecl; - //FOpenSSLProc_setup_engine: function( var err: BIO; sEngine: PChar; debug: longint): PEngine; cdecl; - FOpenSSLProc_RAND_seed: procedure( const buf: pointer; num: integer); cdecl; - FOpenSSLProc_RAND_status: function: integer; cdecl; - FOpenSSLProc_RSA_new: function: PRSA; - // FOpenSSLProc_RSA_new_method: function( Eng: PEngine): PRSA; - FOpenSSLProc_RSA_size: function( RSA: PRSA): longint; - FOpenSSLProc_RSA_free: procedure( R: PRSA); - FOpenSSLProc_BN_set_word: function( n: pBIGNUM; w: longword): longint; cdecl; - FOpenSSLProc_RSA_generate_key_ex: function( rsa : PRSA; bits: longint; e: PBIGNUM; cb: PBN_GENCB): integer; cdecl; - FOpenSSLProc_BN_free: procedure( n: PBIGNUM); cdecl; - FOpenSSLProc_BN_new: function: PBIGNUM; - FOpenSSLProc_ERR_get_err: function: longword; cdecl; - FOpenSSLProc_ERR_error_string_n: procedure( ErrorCode: longword; Buf: PAnsiChar; len: longword); cdecl; - FOpenSSLProc_BN_get_word: function ( a: PBIGNUM): longword; cdecl; - FOpenSSLProc_RSA_up_ref: function( rsa: PRSA): longint; cdecl; - FOpenSSLProc_PEM_write_bio_RSAPrivateKey: - function( bp: PBIO; x: PRSA; const enc: PEVP_CIPHER; kstr: PAnsiChar; - klen: longint; cb: pem_password_cb; u: pointer): longint; cdecl; - FOpenSSLProc_PEM_write_bio_RSAPublicKey: function( bp: PBIO; x: PRSA): longint; cdecl; - FOpenSSLProc_RSA_sign: function( type1: longint; m: pointer; m_len: longword; - sigret: PAnsichar; var siglen: longword; rsa: PRSA): longint; cdecl; - FOpenSSLProc_RSA_verify: function (type1: longint; m: pointer; m_len: longword; - sigbuf: PAnsichar; siglen: longword; rsa: PRSA): longint; cdecl; - FOpenSSLProc_RSA_print: function( bp: PBIO; x: PRSA; offset: longint): longint; cdecl; - FOpenSSLProc_PEM_read_bio_RSAPrivateKey: - function( bp: PBIO; x: PPRSA; cb: pem_password_cb; u: pointer): PRSA; cdecl; - FOpenSSLProc_BIO_new_mem_buf: function( buf: pointer; len: longint): PBIO; cdecl; - FOpenSSLProc_PEM_read_bio_RSAPublicKey: - function( bp: PBIO; x: PPRSA; cb: pem_password_cb; u: pointer): PRSA; cdecl; - - FOpenSSLProc_EVP_des_ede3_cbc : TOpenSLL_CipherFunc; // des3 - FOpenSSLProc_EVP_des_cbc : TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_idea_cbc : TOpenSLL_CipherFunc; // idea - FOpenSSLProc_EVP_seed_cbc : TOpenSLL_CipherFunc; // Encrypt PEM output with CBC seed - FOpenSSLProc_EVP_aes_128_cbc : TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_aes_192_cbc : TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_aes_256_cbc : TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_aes_256_ofb : TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_camellia_128_cbc: TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_camellia_192_cbc: TOpenSLL_CipherFunc; - FOpenSSLProc_EVP_camellia_256_cbc: TOpenSLL_CipherFunc; - - FOpenSSLProc_EVP_CIPHER_CTX_init: EVP_CIPHER_varProc; - FOpenSSLProc_EVP_CIPHER_CTX_cleanup: EVP_CIPHER_intFunc; - FOpenSSLProc_EVP_CipherInit_ex: function( var ctx: EVP_CIPHER_CTX; - const cipher: PEVP_CIPHER; impl: pointer {PENGINE}; - const key: PByte; const iv: PByte; enc: integer): integer; cdecl; - FOpenSSLProc_EVP_CIPHER_CTX_set_key_length: - function (var x: EVP_CIPHER_CTX; keylen: integer): integer; cdecl; - FOpenSSLProc_EVP_CipherUpdate: function( var ctx: EVP_CIPHER_CTX; - const outBytes: PByte; var outLen: integer; - const inBytes: PByte; inLen: integer): integer; cdecl; - FOpenSSLProc_EVP_CipherFinal_ex: function( var ctx: EVP_CIPHER_CTX; - const outBytes: PByte; var outLen: integer): integer; cdecl; - FOpenSSLProc_EVP_CIPHER_CTX_set_padding: function( var ctx: EVP_CIPHER_CTX; - pad: integer): integer; cdecl; - - function GetEVP( Cipher: TCipherToEncryptPrivateKeyWith): PEVP_CIPHER; - - function TryOpen( - const LibPath: string; // Empty or path to lib (no final backslash) - const LibName: string; // pathless library filename. - const DLLDir: string; // Empty or SetDLLDirectory directory. - RqrMajorV, RqrMinorV, RqrReleaseV, RqrBuildV: integer; - const RqrSignatureProc: string; // An exported procedure of this name - // MUST be in the library or it is not valid. - // Minimum requirements. - // If zero's then no requirements. - var Err: TOpenLibError; // Kind of error. - var Handle: HMODULE; // Returned library handle. - var WindowsError: DWORD; // windows GetLastError where appropriate. - var FileName: string; // Full file name of loaded library - var ErrMsg: string; // Error message, where available. - var MajorV, MinorV, ReleaseV, BuildV: integer // Actual version numbers. - - ): boolean; // True if and only if loaded ok. - - function GetIsLoaded: boolean; - procedure SetIsLoaded( Value: boolean); - - procedure SetLibPath( const Value: string); - procedure SetLibName( const Value: string); - procedure SetDLLDir( const Value: string); - function GetRequiredVersionStr: string; - procedure SetRequiredVersionStr( const Value: string); - procedure OpenLib; - procedure CloseLib; - procedure GetProcs; - procedure ClearProcs; - procedure SetMemoryManager; - procedure App_Start; - procedure App_Shutdown; - function isLibraryUniqueInstance: boolean; - procedure GetAndCallParameterless( const ProcName: string); - function OpenSSL_CallBack( p1, p2: integer): integer; - procedure GetError( var ErrorCode: integer; var ErrorMsg: string); - - protected - FStoragePassword: utf8string; - FOnProgress: TOnOpenSSLProgress; - procedure PreShutdown; virtual; - - public - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - procedure Clear; - - property isLoaded: boolean read GetIsLoaded write SetIsLoaded; - - property Handle: HMODULE read FHandle; - property FileName: string read FFileName; - property Err: TOpenLibError read FErr; - property WindowsError: DWORD read FWindowsError; - property ErrMsg: string read FErrMsg; - property MajorV: integer read FMajorV; - property MinorV: integer read FMinorV; - property ReleaseV: integer read FReleaseV; - property BuildV: integer read FBuildV; - property haveTriedToOpen: boolean read FhaveTriedToOpen; - - - published - property LibPath: string read FLibPath write SetLibPath; - property LibName: string read FLibName write SetLibName; // default LibEay32; - property SupportDLLDir: string read FDLLDir write SetDLLDir; - // ^ dir of needed DLL's. - property RequiredVersion: string read GetRequiredVersionStr write SetRequiredVersionStr; - // ^ Must be like '1.2.3.4' or '1.2.3' or '1.2' or '1' or empty. - property OnProgress: TOnOpenSSLProgress read FOnProgress write FOnProgress; - end; - - -{$IF CompilerVersion >= 23.0} - {$IFDEF OpenSSL_Win64_NotYetSupported} - [ComponentPlatformsAttribute( pidWin32)] // Just 32-bit for the moment. - {$ELSE} - [ComponentPlatformsAttribute( pidWin32, pidWin64)] - {$ENDIF} -{$IFEND} -TOpenSSL_Signatory = class( TOpenSSL_Base) - private - FRSA: PRSA; - FStorageCipher: TCipherToEncryptPrivateKeyWith; - FAsymetricKeySizeInBits: cardinal; - FKeyStorageParts: TKeyStoragePartSet; - - function PEM_Password_CallBack( buf: PAnsistring; size, rwflag: longint): longint; - procedure CloseRSA; - procedure GenRSA( KeySizeInBits: integer; var ErrorCode: integer; var ErrorMsg: string); - - - procedure LoadRSA_PrivateKey( - var ErrorMessage: string; - Cipher: TCipherToEncryptPrivateKeyWith; - const sPrivateKey: utf8string; - const Password: utf8string); - - procedure LoadRSA_PublicKey( - var ErrorMessage: string; - const sPublicKey: utf8string); - - function RSA_Size: integer; - - procedure RSA_Sign( - PreHash: TSigHashKind; - Message1: pointer; MessageLen: cardinal; - var Signature: utf8string; var ErrorMessage: string); - - function RSA_Verify( - PreHash: TSigHashKind; - Message1: pointer; MessageLen: cardinal; - const Signature: utf8string): boolean; // True for verified good. - - - function PrivateKey_AsPEM( Cipher: TCipherToEncryptPrivateKeyWith; const Password: utf8string): utf8string; - - function GetPrivateKey_AsPEM: utf8string; - procedure SetPrivateKey_AsPEM( const Value: utf8string); - function GetPublicKey_AsPEM: utf8string; - procedure SetPublicKey_AsPEM( const Value: utf8string); - - protected - procedure PreShutdown; override; - - public - constructor Create( AOwner: TComponent); override; - function Sign( PreHash: TSigHashKind; HashedDocument, Signature: TStream): boolean; - function Verify( PreHash: TSigHashKind; HashedDocument, Signature: TStream): TVerifyResult; - - function GenerateKeys: boolean; - procedure StoreKeysToStream( Store: TStream; Parts: TKeyStoragePartSet); - procedure LoadKeysFromStream( Store: TStream; Parts: TKeyStoragePartSet); - function HasParts: TKeyStoragePartSet; - procedure Randomize; - function SignVerify_SelfTest: boolean; - function Print: string; - - property PrivateKey: utf8string read GetPrivateKey_AsPEM write SetPrivateKey_AsPEM; - property PublicKey : utf8string read GetPublicKey_AsPEM write SetPublicKey_AsPEM; - - published - property AsymetricKeySizeInBits: cardinal read FAsymetricKeySizeInBits - write FAsymetricKeySizeInBits; - - property PrivateKeyStoragePassword: utf8string read FStoragePassword write FStoragePassword; - property PrivateKeyStorageCipher: TCipherToEncryptPrivateKeyWith read FStorageCipher write FStorageCipher; - property OnProgress: TOnOpenSSLProgress read FOnProgress write FOnProgress; - end; - -TOpenSSL_PaddingScheme = ( - padNone, - padPKCS); - -{$IF CompilerVersion >= 23.0} - {$IFDEF OpenSSL_Win64_NotYetSupported} - [ComponentPlatformsAttribute( pidWin32)] // Just 32-bit for the moment. - {$ELSE} - [ComponentPlatformsAttribute( pidWin32, pidWin64)] - {$ENDIF} -{$IFEND} -TOpenSSL_Codec = class( TOpenSSL_Base) - private - FCipher: TCipherToEncryptPrivateKeyWith; - FKey: TBytes; - FIV: TBytes; - FisInitialised: boolean; - Fctx: EVP_CIPHER_CTX; - FPad: TOpenSSL_PaddingScheme; - procedure BeginEncDec( doEncrypt: Boolean); - - public - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - - procedure SetKey( const key1: TBytes); - procedure SetIV ( const iv1 : TBytes); - procedure Encrypt( PlaintextInStream, CiphertextOutStream: TStream); - procedure Decrypt( PlaintextOutStream, CiphertextInStream: TStream); - - published - property Cipher: TCipherToEncryptPrivateKeyWith read FCipher write FCipher; - property PaddingScheme: TOpenSSL_PaddingScheme read FPad write FPad; - end; - -implementation - - - -{$WARNINGS OFF} -uses SyncObjs, {$IFDEF GENERICS}Generics.Collections{$ELSE}Contnrs{$ENDIF}, TPLB3.Random; - - -const - RSA_F4: longint = $10001; - -var - OpenSSL_LibGate: TCriticalSection = nil; - OpenSSL_Libs : TObjectList{$IFDEF GENERICS}{$ENDIF} = nil; // of TOpenSSL_Lib - -{$IFDEF HuntingMemoryLeaks} - Allocated: int64 = 0; -{$ENDIF} - -procedure InitUnit_OpenSSL_Lib; -begin -OpenSSL_LibGate := TCriticalSection.Create; -OpenSSL_Libs := nil; -{$IFDEF HuntingMemoryLeaks} -Allocated := 0 -{$ENDIF} -end; - -procedure DoneUnit_OpenSSL_Lib; -begin -FreeAndNil( OpenSSL_LibGate); -FreeAndNil( OpenSSL_Libs) -end; - - - - - - -function cb_2_SpringBoard( p1, p2 : longint; p3 : PBN_GENCB): longint; cdecl; -var - InvokerObj: TObject; -begin -InvokerObj := TObject( p3.arg); -if InvokerObj is TOpenSSL_Signatory then - result := TOpenSSL_Signatory( InvokerObj).OpenSSL_CallBack( p1, p2) - else - result := 0 -end; - - -function pem_password_cb_SpringBoard( - buf: PAnsistring; size, rwflag: longint; - userdata: pointer): longint; cdecl; -var - InvokerObj: TObject; -begin -InvokerObj := TObject( userdata); -if InvokerObj is TOpenSSL_Signatory then - result := TOpenSSL_Signatory( InvokerObj) - .PEM_Password_CallBack( buf, size, rwflag) - else - result := 0 -end; - - -{ TBIO } - -constructor TBIO.Create( Lib1: TOpenSSL_Signatory); -begin -FLib := Lib1; -FBIOobj := InitBIO_Object -end; - - -destructor TBIO.Destroy; -begin -if assigned( FBIOobj) and assigned( FLib) and (FLib.FHandle <> 0) then - begin - FLib.FOpenSSLproc_BioFree( FBIOobj); - FBIOobj := nil - end; -inherited -end; - -function TBIO.Readansistring: ansistring; -var - Buffer: ansistring; - Amount: longint; -begin -result := ''; -if (not assigned( FLib)) or (FLib.FHandle = 0) then exit; -SetLength( Buffer, 1024); -repeat - Amount := FLib.FOpenSSLproc_BioRead( FBIOobj, @Buffer[1], Length( Buffer)); - if Amount > 0 then - result := result + Copy( Buffer, 1, Amount) -until Amount = -1 -end; - - -{ TMemoryBIO } - -function TMemoryBIO.InitBIO_Object: pBIO; -begin -result := FLib.FOpenSSLproc_BioNew( FLib.FOpenSSLproc_BioSMem) -end; - -{ TReadOnlyBIO } - -constructor TReadOnlyBIO.Create( - Lib1: TOpenSSL_Signatory; Data: pointer; DataLen: integer); -begin -SetLength( FData, DataLen); -if DataLen > 0 then - Move( Data^, FData[0], DataLen); -inherited Create( Lib1) -end; - - -destructor TReadOnlyBIO.Destroy; -begin -inherited; -SetLength( FData, 0) -end; - -function TReadOnlyBIO.InitBIO_Object: pBIO; -begin -if Length( FData) > 0 then - result := FLib.FOpenSSLProc_BIO_new_mem_buf( @FData[0], Length( FData)) - else - result := FLib.FOpenSSLProc_BIO_new_mem_buf( nil, 0) -end; - -{ TOpenSSL_Signatory } - -procedure TOpenSSL_Base.App_Shutdown; - - procedure GetAndCallOneIntParam( const ProcName: string; Value: integer); - type - TProc_OneIntParam = procedure( P1: longint); cdecl; - var - Proc: TProc_OneIntParam; - begin - if (FHandle = 0) or (ProcName = '') then exit; - @Proc := GetProcAddress( FHandle, PChar( ProcName)); - if assigned( Proc) then - Proc( Value) - end; - - procedure GetAndCallOnePtrParam( const ProcName: string; Value: pointer); - type - TProc_OnePntrParam = procedure( P1: pointer); cdecl; - var - Proc: TProc_OnePntrParam; - begin - if (FHandle = 0) or (ProcName = '') then exit; - @Proc := GetProcAddress( FHandle, PChar( ProcName)); - if assigned( Proc) then - Proc( Value) - end; - -begin -GetAndCallOneIntParam ( 'CONF_modules_unload', 1); -GetAndCallParameterless( 'OBJ_cleanup'); -GetAndCallParameterless( 'EVP_cleanup'); -GetAndCallParameterless( 'ENGINE_cleanup'); -GetAndCallParameterless( 'CRYPTO_cleanup_all_ex_data'); -GetAndCallOnePtrParam ( 'ERR_remove_thread_state', nil); -GetAndCallParameterless( 'ERR_free_strings') -end; - -procedure TOpenSSL_Base.App_Start; -begin -GetAndCallParameterless( 'ERR_load_crypto_strings'); -if FdoOPENSSL_LOAD_CONF then - GetAndCallParameterless( 'OPENSSL_add_all_algorithms_conf') - else - GetAndCallParameterless( 'OPENSSL_add_all_algorithms_noconf'); -GetAndCallParameterless( 'ENGINE_load_builtin_engines'); -Randomize -end; - -procedure TOpenSSL_Base.Clear; -begin -SetIsLoaded( False); -FhaveTriedToOpen := False -end; - - -procedure TOpenSSL_Base.ClearProcs; -begin -@FOpenSSLproc_BioSMem := nil; -@FOpenSSLproc_BioNew := nil; -@FOpenSSLproc_BioFree := nil; -@FOpenSSLproc_BioRead := nil; -//@FOpenSSLProc_setup_engine := nil; -@FOpenSSLProc_RAND_seed := nil; -@FOpenSSLProc_RAND_status := nil; -@FOpenSSLProc_RSA_new := nil; -//@FOpenSSLProc_RSA_new_method := nil; -@FOpenSSLProc_RSA_size := nil; -@FOpenSSLProc_RSA_free := nil; -@FOpenSSLProc_BN_set_word := nil; -@FOpenSSLProc_RSA_generate_key_ex := nil; -@FOpenSSLProc_BN_free := nil; -@FOpenSSLProc_BN_new := nil; -@FOpenSSLProc_ERR_get_err := nil; -@FOpenSSLProc_ERR_error_string_n := nil; -@FOpenSSLProc_BN_get_word := nil; -@FOpenSSLProc_RSA_up_ref := nil; -@FOpenSSLProc_PEM_write_bio_RSAPrivateKey := nil; -@FOpenSSLProc_PEM_write_bio_RSAPublicKey := nil; -@FOpenSSLProc_RSA_sign := nil; -@FOpenSSLProc_RSA_verify := nil; - -@FOpenSSLProc_RSA_print := nil; -@FOpenSSLProc_PEM_read_bio_RSAPrivateKey := nil; -@FOpenSSLProc_BIO_new_mem_buf := nil; -@FOpenSSLProc_PEM_read_bio_RSAPublicKey := nil; - -@FOpenSSLProc_EVP_des_ede3_cbc := nil; -@FOpenSSLProc_EVP_des_cbc := nil; -@FOpenSSLProc_EVP_idea_cbc := nil; -@FOpenSSLProc_EVP_seed_cbc := nil; -@FOpenSSLProc_EVP_aes_128_cbc := nil; -@FOpenSSLProc_EVP_aes_192_cbc := nil; -@FOpenSSLProc_EVP_aes_256_cbc := nil; -@FOpenSSLProc_EVP_aes_256_ofb := nil; -@FOpenSSLProc_EVP_camellia_128_cbc := nil; -@FOpenSSLProc_EVP_camellia_192_cbc := nil; -@FOpenSSLProc_EVP_camellia_256_cbc := nil; - -@FOpenSSLProc_EVP_CIPHER_CTX_init := nil; -@FOpenSSLProc_EVP_CIPHER_CTX_cleanup := nil; -@FOpenSSLProc_EVP_CipherInit_ex := nil; -@FOpenSSLProc_EVP_CIPHER_CTX_set_key_length := nil; -@FOpenSSLProc_EVP_CipherUpdate := nil; -@FOpenSSLProc_EVP_CipherFinal_ex := nil; -@FOpenSSLProc_EVP_CIPHER_CTX_set_padding := nil; - -end; - -procedure TOpenSSL_Base.CloseLib; -begin -if FHandle <> 0 then - begin - FhaveTriedToOpen := False; // Only count failed attempts to open. - OpenSSL_LibGate.Enter; - try - PreShutdown; - if isLibraryUniqueInstance then - App_Shutdown; - FreeLibrary( FHandle); - FHandle := 0; - ClearProcs; - if assigned( OpenSSL_Libs) and (OpenSSL_Libs.IndexOf( self) <> -1) then - OpenSSL_Libs.Remove( self); - if assigned( OpenSSL_Libs) and (OpenSSL_Libs.Count = 0) then - FreeAndNil( OpenSSL_Libs) - finally - OpenSSL_LibGate.Leave - end - end; -FCachedSize := -1; -FFileName := ''; -FErr := erNull; -FWindowsError := 0; -FErrMsg := ''; -FMajorV := 0; -FMinorV := 0; -FReleaseV := 0; -FBuildV := 0 -end; - - - -procedure TOpenSSL_Signatory.CloseRSA; - - procedure ReleaseBigNumDataMember( var n: PBIGNUM); - begin - if assigned( n) and assigned( FOpenSSLProc_BN_free) then - begin - FOpenSSLProc_BN_free( n); - n := nil - end; - end; - -begin -FKeyStorageParts := []; -if assigned( FOpenSSLProc_RSA_free) and assigned( FRSA) then - begin - ReleaseBigNumDataMember( FRSA^.n); - ReleaseBigNumDataMember( FRSA^.e); - ReleaseBigNumDataMember( FRSA^.d); - ReleaseBigNumDataMember( FRSA^.p); - ReleaseBigNumDataMember( FRSA^.q); - ReleaseBigNumDataMember( FRSA^.dmp1); - ReleaseBigNumDataMember( FRSA^.dmq1); - ReleaseBigNumDataMember( FRSA^.iqmp); - if FisSafeToFreeRSA then - try - FOpenSSLProc_RSA_free( FRSA) - except - FisSafeToFreeRSA := False - end; - FRSA := nil - end -end; - -constructor TOpenSSL_Base.Create( AOwner: TComponent); -begin -inherited Create( AOwner); -FHandle := 0; -FLibPath := ''; -FLibName := LibEay; -FFileName := ''; -FDLLDir := ''; -FRqrMajorV := 1; -FRqrMinorV := 0; -FRqrReleaseV := 0; -FRqrBuildV := 0; -FErr := erNull; -FWindowsError := 0; -FErrMsg := ''; -FMajorV := 0; -FMinorV := 0; -FReleaseV := 0; -FBuildV := 0; -FhaveTriedToOpen := False; -FdoOPENSSL_LOAD_CONF := False; -FisSafeToFreeRSA := False; -FCachedSize := -1; -ClearProcs; -FPassword := ''; -FStoragePassword := ''; -end; - -destructor TOpenSSL_Base.Destroy; -begin -Clear; -inherited -end; - - - -constructor TOpenSSL_Signatory.Create( AOwner: TComponent); -begin -inherited Create( AOwner); -FAsymetricKeySizeInBits := Default_AsymetricKeySizeInBits; -FRSA := nil; -FStorageCipher := cipher_InTheClear; -FKeyStorageParts := [] -end; - -function TOpenSSL_Signatory.GenerateKeys: boolean; - var ErrorCode: integer; - var ErrorMsg: string; -begin -GenRSA( FAsymetricKeySizeInBits, ErrorCode, ErrorMsg); -result := ErrorMsg = ''; -if not result then - FErrMsg := ErrorMsg -end; - - -procedure TOpenSSL_Signatory.GenRSA( - KeySizeInBits: integer; - var ErrorCode: integer; var ErrorMsg: string); -var - bn: PBIGNUM; - Ok: boolean; - cb: BN_GENCB; -{$IFDEF HuntingMemoryLeaks} - StartMemory, Leakage: int64; -{$ENDIF} -// UserAborted: boolean; - -begin -{$IFDEF HuntingMemoryLeaks} -StartMemory := Allocated; -{$ENDIF} -try -ErrorCode := 0; -//UserAborted := False; -CloseRSA; -FisSafeToFreeRSA := True; -ErrorMsg := '(Error) TOpenSSL_Signatory not loaded.'; -if not assigned( FOpenSSLProc_RSA_new) then exit; -ErrorMsg := ''; -FRSA := FOpenSSLProc_RSA_new; -bn := FOpenSSLProc_BN_new; -try - Ok := FOpenSSLProc_BN_set_word( bn, RSA_F4) = 1; - cb.ver := 2; - cb.arg := pointer( self); - @cb.cb_2 := @cb_2_SpringBoard; - if Ok then - begin - Ok := FOpenSSLProc_RSA_generate_key_ex( FRSA, KeySizeInBits, bn, @cb) = 1; - if Ok then - begin - FCachedSize := KeySizeInBits; - FKeyStorageParts := [partPublic, partPrivate] - end - else - GetError( ErrorCode, ErrorMsg) - end; -finally - if assigned( bn) then - FOpenSSLProc_BN_free( bn); - end; -// UserAborted := ErrorCode = $04081003; // = 67637251 - -finally -FisSafeToFreeRSA := False -end; -{$IFDEF HuntingMemoryLeaks} -Leakage := Allocated - StartMemory; -{$ENDIF} -end; - - -procedure TOpenSSL_Base.GetAndCallParameterless( const ProcName: string); -type - TProc_NoParams = procedure; cdecl; -var - Proc: TProc_NoParams; -begin -if (FHandle = 0) or (ProcName = '') then exit; -@Proc := GetProcAddress( FHandle, PChar( ProcName)); -if assigned( Proc) then - Proc -end; - - - -procedure TOpenSSL_Base.GetError( - var ErrorCode: integer; var ErrorMsg: string); -var - aErrorMsg: ansistring; -begin -ErrorCode := 0; -if not assigned( FOpenSSLProc_ERR_get_err) then - begin - ErrorCode := -1; - ErrorMsg := 'TOpenSSL_Lib not loaded.' - end - else - begin - aErrorMsg := ''; - ErrorCode := FOpenSSLProc_ERR_get_err; - if ErrorCode <> 0 then - begin - SetLength( aErrorMsg, 500); - FOpenSSLProc_ERR_error_string_n( ErrorCode, PAnsiChar( aErrorMsg), Length( aErrorMsg)); - SetLength( aErrorMsg, StrLen( PAnsiChar( aErrorMsg))) - end; - ErrorMsg := aErrorMsg // Coerce system code page ansi into utf16 - end; -end; - - - -function TOpenSSL_Base.GetEVP( - Cipher: TCipherToEncryptPrivateKeyWith): PEVP_CIPHER; -var - Func: TOpenSLL_CipherFunc; - -begin -case Cipher of - cipher_InTheClear : begin - result := nil; - exit; - end; - cipher_des_ede3_cbc : @Func := @FOpenSSLProc_EVP_des_ede3_cbc; - cipher_des_cbc : @Func := @FOpenSSLProc_EVP_des_cbc; - cipher_idea_cbc : @Func := @FOpenSSLProc_EVP_idea_cbc; - cipher_seed_cbc : @Func := @FOpenSSLProc_EVP_seed_cbc; - cipher_aes_128_cbc : @Func := @FOpenSSLProc_EVP_aes_128_cbc; - cipher_aes_192_cbc : @Func := @FOpenSSLProc_EVP_aes_192_cbc; - cipher_aes_256_cbc : @Func := @FOpenSSLProc_EVP_aes_256_cbc; - cipher_aes_256_ofb : @Func := @FOpenSSLProc_EVP_aes_256_ofb; - cipher_camellia_128_cbc : @Func := @FOpenSSLProc_EVP_camellia_128_cbc; - cipher_camellia_192_cbc : @Func := @FOpenSSLProc_EVP_camellia_192_cbc; - cipher_camellia_256_cbc : @Func := @FOpenSSLProc_EVP_camellia_256_cbc; - end; -if assigned( Func) then - result := Func // This is a function call. - else - result := nil -end; - - - -function TOpenSSL_Base.GetIsLoaded: boolean; -begin -result := FHandle <> 0 -end; - - -procedure TOpenSSL_Base.GetProcs; - - function ProcAddress( const ProcName: string): pointer; - begin - result := GetProcAddress( FHandle, PChar( ProcName)) - end; - -begin -ClearProcs; -if FHandle = 0 then exit; -@FOpenSSLproc_BioSMem := ProcAddress( 'BIO_s_mem'); -@FOpenSSLproc_BioNew := ProcAddress( 'BIO_new'); -@FOpenSSLproc_BioFree := ProcAddress( 'BIO_free'); -@FOpenSSLproc_BioRead := ProcAddress( 'BIO_read'); -//@FOpenSSLProc_setup_engine := ProcAddress( 'setup_engine'); -@FOpenSSLProc_RAND_seed := ProcAddress( 'RAND_seed'); -@FOpenSSLProc_RAND_status := ProcAddress( 'RAND_status'); -@FOpenSSLProc_RSA_new := ProcAddress( 'RSA_new'); -//@FOpenSSLProc_RSA_new_method := ProcAddress( 'RSA_new_method'); -@FOpenSSLProc_RSA_size := ProcAddress( 'RSA_size'); -@FOpenSSLProc_RSA_free := ProcAddress( 'RSA_free'); -@FOpenSSLProc_BN_set_word := ProcAddress( 'BN_set_word'); -@FOpenSSLProc_RSA_generate_key_ex := ProcAddress( 'RSA_generate_key_ex'); -@FOpenSSLProc_BN_free := ProcAddress( 'BN_free'); -@FOpenSSLProc_BN_new := ProcAddress( 'BN_new'); -@FOpenSSLProc_ERR_get_err := ProcAddress( 'ERR_get_error'); -@FOpenSSLProc_ERR_error_string_n := ProcAddress( 'ERR_error_string_n'); -@FOpenSSLProc_BN_get_word := ProcAddress('BN_get_word'); -@FOpenSSLProc_RSA_up_ref := ProcAddress( 'RSA_up_ref'); -@FOpenSSLProc_PEM_write_bio_RSAPrivateKey := ProcAddress( 'PEM_write_bio_RSAPrivateKey'); -@FOpenSSLProc_PEM_write_bio_RSAPublicKey := ProcAddress( 'PEM_write_bio_RSAPublicKey'); -@FOpenSSLProc_RSA_sign := ProcAddress( 'RSA_sign'); -@FOpenSSLProc_RSA_verify := ProcAddress( 'RSA_verify'); - -@FOpenSSLProc_RSA_print := ProcAddress( 'RSA_print'); -@FOpenSSLProc_PEM_read_bio_RSAPrivateKey := ProcAddress( 'PEM_read_bio_RSAPrivateKey'); -@FOpenSSLProc_BIO_new_mem_buf := ProcAddress( 'BIO_new_mem_buf'); -@FOpenSSLProc_PEM_read_bio_RSAPublicKey := ProcAddress( 'PEM_read_bio_RSAPublicKey'); - -@FOpenSSLProc_EVP_des_ede3_cbc := ProcAddress( 'EVP_des_ede3_cbc'); -@FOpenSSLProc_EVP_des_cbc := ProcAddress( 'EVP_des_cbc'); -@FOpenSSLProc_EVP_idea_cbc := ProcAddress( 'EVP_idea_cbc'); -@FOpenSSLProc_EVP_seed_cbc := ProcAddress( 'EVP_seed_cbc'); -@FOpenSSLProc_EVP_aes_128_cbc := ProcAddress( 'EVP_aes_128_cbc'); -@FOpenSSLProc_EVP_aes_192_cbc := ProcAddress( 'EVP_aes_192_cbc'); -@FOpenSSLProc_EVP_aes_256_cbc := ProcAddress( 'EVP_aes_256_cbc'); -@FOpenSSLProc_EVP_aes_256_ofb := ProcAddress( 'EVP_aes_256_ofb'); -@FOpenSSLProc_EVP_camellia_128_cbc := ProcAddress( 'EVP_camellia_128_cbc'); -@FOpenSSLProc_EVP_camellia_192_cbc := ProcAddress( 'EVP_camellia_192_cbc'); -@FOpenSSLProc_EVP_camellia_256_cbc := ProcAddress( 'EVP_camellia_256_cbc'); - -@FOpenSSLProc_EVP_CIPHER_CTX_init := ProcAddress( 'EVP_CIPHER_CTX_init'); -@FOpenSSLProc_EVP_CIPHER_CTX_cleanup := ProcAddress( 'EVP_CIPHER_CTX_cleanup'); -@FOpenSSLProc_EVP_CipherInit_ex := ProcAddress( 'EVP_CipherInit_ex'); -@FOpenSSLProc_EVP_CIPHER_CTX_set_key_length := ProcAddress( 'EVP_CIPHER_CTX_set_key_length'); -@FOpenSSLProc_EVP_CipherUpdate := ProcAddress( 'EVP_CipherUpdate'); -@FOpenSSLProc_EVP_CipherFinal_ex := ProcAddress( 'EVP_CipherFinal_ex'); -@FOpenSSLProc_EVP_CIPHER_CTX_set_padding := ProcAddress( 'EVP_CIPHER_CTX_set_padding'); - -end; - -function TOpenSSL_Base.GetRequiredVersionStr: string; -begin -result := Format( '%d.%d.%d.%d', - [FRqrMajorV, FRqrMinorV, FRqrReleaseV, FRqrBuildV]) -end; - - - -function TOpenSSL_Base.isLibraryUniqueInstance: boolean; -var - j: integer; - OpenSSL_Lib: TOpenSSL_Base; - -begin -result := True; -if FHandle = 0 then exit; -OpenSSL_LibGate.Enter; -try - for j := 0 to OpenSSL_Libs.Count - 1 do - begin - OpenSSL_Lib := OpenSSL_Libs[j] as TOpenSSL_Base; - result := (OpenSSL_Lib = self) or - (OpenSSL_Lib.FHandle = 0) or - (OpenSSL_Lib.FHandle <> FHandle); - if not result then break - end -finally - OpenSSL_LibGate.Leave - end -end; - - - -function TOpenSSL_Signatory.HasParts: TKeyStoragePartSet; -begin -if assigned( FRSA) then - result := FKeyStorageParts - else - result := [] -end; - - -function ReadString( Source: TStream; const TerminatingPattern: utf8string): utf8string; -var - Ch: ansichar; - s: utf8string; - FoundMatch: boolean; - ReadCount: integer; - L: integer; -begin -Ch := #0; -s := ''; -ReadCount := 0; -FoundMatch := False; -L := Length( TerminatingPattern); -if L = 0 then exit; -while (not FoundMatch) and (Source.Read( Ch, 1) = 1) do - begin - Inc( ReadCount); - if Length( s) = L then - begin - Move( s[2], s[1], L - 1); - s[ L] := Ch - end - else - s := s + Ch; - FoundMatch := s = TerminatingPattern - end; -if FoundMatch then - begin - SetLength( result, ReadCount); - if ReadCount > 0 then - begin - Source.Seek( -ReadCount, soCurrent); - if Source.Read( result[1], ReadCount) <> ReadCount then - result := '(Error) Streaming error.' - end - end - else - result := '' -end; - - - -procedure TOpenSSL_Signatory.LoadRSA_PrivateKey( - var ErrorMessage: string; - Cipher: TCipherToEncryptPrivateKeyWith; const sPrivateKey, - Password: utf8string); -var - bp: TBIO; - cb: BN_GENCB; - Code: integer; - isException: boolean; -begin -ErrorMessage := ''; -CloseRSA; -if assigned( FOpenSSLProc_PEM_read_bio_RSAPrivateKey) and (sPrivateKey <> '') then - begin - FPassword := Password; - if (FPassword = '') and (Cipher <> cipher_InTheClear) then - ErrorMessage := 'A non-empty password is required.'; - if (FPassword <> '') and (Cipher = cipher_InTheClear) then - FPassword := ''; - - if ErrorMessage <> '' then exit; - - cb.ver := 2; - cb.arg := pointer( self); - @cb.cb_2 := @cb_2_SpringBoard; - isException := False; - bp := TReadOnlyBIO.Create( self, @sPrivateKey[1], Length( sPrivateKey)); - try - try - if FPassword <> '' then - // The below line was contributed to user Trupka of the LockBox website. - // Thanks Trupka. - FRSA := FOpenSSLProc_PEM_read_bio_RSAPrivateKey( bp.FBIOobj, nil, @pem_password_cb_SpringBoard, Pointer(Self)) - else - FRSA := FOpenSSLProc_PEM_read_bio_RSAPrivateKey( bp.FBIOobj, nil, nil, nil) - finally - bp.Free; - FPassword := '' - end - except on e: Exception do - begin - isException := True; - FRSA := nil; - ErrorMessage := e.Message - end; - end; - if (not assigned( FRSA)) and (not isException) then - GetError( Code, ErrorMessage); - if assigned( FRSA) and (ErrorMessage = '') and (not SignVerify_SelfTest) then - ErrorMessage := '(Error) TOpenSSL_Signatory.LoadRSA_PrivateKey failed self-test.' - end - else if assigned( FOpenSSLProc_PEM_read_bio_RSAPrivateKey) then - ErrorMessage := '(Error) Private key file corrupt, empty or the wrong type.' - else - ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.'; - -if ErrorMessage = '' then - FKeyStorageParts := [partPublic, partPrivate] -end; - - - -procedure TOpenSSL_Signatory.LoadRSA_PublicKey( - var ErrorMessage: string; const sPublicKey: utf8string); -var - bp: TBIO; - isException: boolean; - Code: integer; -begin -ErrorMessage := ''; -CloseRSA; - -if assigned( FOpenSSLProc_PEM_read_bio_RSAPublicKey) and (sPublicKey <> '') then - begin - isException := False; - bp := TReadOnlyBIO.Create( self, @sPublicKey[1], Length( sPublicKey)); - try - try - FRSA := FOpenSSLProc_PEM_read_bio_RSAPublicKey( bp.FBIOobj, nil, nil, nil) - finally - bp.Free; - end - except on e: Exception do - begin - isException := True; - FRSA := nil; - ErrorMessage := e.Message - end; - end; - if (not assigned( FRSA)) and (not isException) then - GetError( Code, ErrorMessage) - end - else if assigned( FOpenSSLProc_PEM_read_bio_RSAPublicKey) then - ErrorMessage := '(Error) Public key file corrupt, empty or the wrong type.' - else - ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.'; - -if ErrorMessage = '' then - FKeyStorageParts := [partPublic] -end; - - - -//function TOpenSSL_Signatory.NewMemoryBio: TMemoryBIO; -//begin -//if FHandle = 0 then -// result := nil -// else -// result := TMemoryBIO.Create( self) -//end; - - - -procedure TOpenSSL_Base.OpenLib; -begin -OpenSSL_LibGate.Enter; -try -CloseLib; -if TryOpen( - FLibPath, FLibName, FDLLDir, - FRqrMajorV, FRqrMinorV, FRqrReleaseV, FRqrBuildV, - 'RSA_generate_key_ex', - FErr, FHandle, FWindowsError, FFileName, FErrMsg, - FMajorV, FMinorV, FReleaseV, FBuildV) then - begin - GetProcs; - if not assigned( OpenSSL_Libs) then - OpenSSL_Libs := TObjectList{$IFDEF GENERICS}{$ENDIF}.Create( False); - if OpenSSL_Libs.IndexOf( self) = -1 then - OpenSSL_Libs.Add( self); - if isLibraryUniqueInstance then - begin - SetMemoryManager; - App_Start - end - end; -finally -OpenSSL_LibGate.Leave -end end; - - - - -function TOpenSSL_Base.OpenSSL_CallBack( p1, p2: integer): integer; -begin -if (not assigned( FOnProgress)) or FOnProgress( self, p1, p2) then - result := 1 - else - result := 0 -end; - - -procedure TOpenSSL_Base.PreShutdown; -begin -end; - -function TOpenSSL_Signatory.PEM_Password_CallBack( - buf: PAnsistring; size, rwflag: longint): longint; -begin -// rwflag is 0 when reading and 1 when writing. -result := Length( FPassword); -if result > size then - result := size; -if result > 0 then - Move( FPassword[1], buf^, result) -end; - - -function TOpenSSL_Signatory.GetPublicKey_AsPEM: utf8string; -var - PublicKeyBIO: TBIO; -begin -if assigned( FOpenSSLProc_PEM_write_bio_RSAPublicKey) and - assigned( FRSA) and (partPublic in FKeyStorageParts) then - begin - PublicKeyBIO := TMemoryBIO.Create( self); - try - FOpenSSLProc_PEM_write_bio_RSAPublicKey( PublicKeyBIO.FBIOobj, FRSA); - result := PublicKeyBIO.ReadAnsiString - finally - PublicKeyBIO.Free - end - end - else - result := '(Error)' -end; - - - -procedure TOpenSSL_Signatory.PreShutdown; -begin -inherited; -CloseRSA -end; - -function TOpenSSL_Signatory.Print: string; -var - BIO: TBIO; - ErrorCode: integer; -begin -if assigned( FOpenSSLProc_RSA_print) and assigned( FRSA) then - begin - BIO := TMemoryBIO.Create( self); - try - if FOpenSSLProc_RSA_print( BIO.FBIOobj, FRSA, 0) = 1 then - result := BIO.ReadAnsiString // Coerce system code page ansi into utf16 - else - GetError( ErrorCode, result) - finally - BIO.Free - end - end - else - result := '(Error) TOpenSSL_Signatory not loaded.' -end; - - - -function TOpenSSL_Signatory.PrivateKey_AsPEM( - Cipher: TCipherToEncryptPrivateKeyWith; - const Password: utf8string): utf8string; -var - Ok: boolean; - PrivateKeyBIO: TBIO; - enc: PEVP_CIPHER; - ErrorCode: integer; - sResult: string; -begin -result := ''; -if assigned( FOpenSSLProc_PEM_write_bio_RSAPrivateKey) and - assigned( FRSA) and assigned( FOpenSSLProc_EVP_des_ede3_cbc) then - begin - FPassword := Password; - if (FPassword = '') and (Cipher <> cipher_InTheClear) then - result := '(Error) A non-empty password is required.'; - if (FPassword <> '') and (Cipher = cipher_InTheClear) then - FPassword := ''; - enc := GetEVP( Cipher); - if (not assigned( enc)) and (Cipher <> cipher_InTheClear) then - result := '(Error) Encryption function not found in OpenSSL'; - if result <> '' then exit; - - PrivateKeyBIO := TMemoryBIO.Create( self); - if FPassword <> '' then - Ok := FOpenSSLProc_PEM_write_bio_RSAPrivateKey( - PrivateKeyBIO.FBIOobj, FRSA, - enc, nil, 0, pem_password_cb_SpringBoard, pointer( self)) = 1 - else - Ok := FOpenSSLProc_PEM_write_bio_RSAPrivateKey( - PrivateKeyBIO.FBIOobj, FRSA, - nil, nil, 0, nil, nil) = 1; - FPassword := ''; - if Ok then - result := PrivateKeyBIO.ReadAnsiString - else - begin - GetError( ErrorCode, sResult); - result := '(Error) ' + sResult - end; - PrivateKeyBIO.Free - end -else -result := '(Error) TOpenSSL_Signatory not loaded.'; -end; - - - - -procedure TOpenSSL_Signatory.Randomize; -var - Buffer: TBytes; - L, RandStatus, j: integer; -begin -if not assigned( FOpenSSLProc_RAND_seed) or - not assigned( FOpenSSLProc_RAND_status) then exit; -L := 1000; -SetLength( Buffer, L); -for j := 1 to 100 do - begin - TRandomStream.Instance.Read( Buffer[0], L); - FOpenSSLProc_RAND_seed( @Buffer[0], L); - RandStatus := FOpenSSLProc_RAND_status; - if RandStatus = 1 then break - end; -end; - - -//procedure TOpenSSL_Signatory.RSA_IncRef; -//begin -//if assigned( FRSA) and assigned( FOpenSSLProc_RSA_up_ref) then -// FOpenSSLProc_RSA_up_ref( FRSA) -//end; - -const TypeNumbers: array[ TSigHashKind] of longint = ( - { hshSHA1 ==> } 64, - { hshRipemd160 ==> } 117, - { hshMD5 ==> } 4); - -procedure TOpenSSL_Signatory.RSA_Sign( - PreHash: TSigHashKind; Message1: pointer; - MessageLen: cardinal; var Signature: utf8string; - var ErrorMessage: string); -var - SigLen: longword; - ErrorCode: integer; -begin -Signature := ''; -ErrorMessage := ''; -if assigned( FOpenSSLProc_RSA_sign) and assigned( FRSA) then - begin - if FCachedSize = -1 then - FCachedSize := RSA_Size; - SigLen := (FCachedSize + 7) div 8; - if SigLen < 2048 then - SigLen := 2048; - SetLength( Signature, SigLen); - if FOpenSSLProc_RSA_sign( TypeNumbers[PreHash], Message1, MessageLen, - PAnsiChar( Signature), SigLen, FRSA) = 1 then - SetLength( Signature, SigLen) - else - begin - Signature := ''; - GetError( ErrorCode, ErrorMessage) - end; - end - else - ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.' -end; - - - -function TOpenSSL_Signatory.RSA_Size: integer; -var - s, Prefix: string; - P, V, Code: integer; -begin -result := 0; -if not assigned( FRSA) then exit; - -result := FCachedSize; -if result <> -1 then exit; - -result := 0; -if not assigned( FRSA^.n) then - begin - if assigned( FRSA^.d) and assigned( FRSA^.e) then - begin - s := Print; - // 1st line of Print = 'Private-Key: (2048 bit)' - Prefix := 'Private-Key: ('; - P := Pos( Prefix, s); - if P > 0 then - Delete( s, 1, P + Length(Prefix) - 1); - P := Pos(' bit)',s); - if P > 0 then - SetLength( s, P - 1); - s := Trim( s); - Val( s, V, Code); - if (s <> '') and (Code = 0) and (V > 0) then - result := V - end - end - else - try - if assigned( FOpenSSLProc_RSA_size) then - result := FOpenSSLProc_RSA_size( FRSA) - except - result := 0 - end; - -if result <> 0 then - FCachedSize := result -end; - - - -function TOpenSSL_Signatory.RSA_Verify( - PreHash: TSigHashKind; Message1: pointer; - MessageLen: cardinal; const Signature: utf8string): boolean; -begin -if assigned( FOpenSSLProc_RSA_verify) and assigned( FRSA) then - result := FOpenSSLProc_RSA_verify( - TypeNumbers[PreHash], Message1, MessageLen, - PAnsiChar( Signature), Length( Signature), FRSA) = 1 - else - result := False -end; - - -procedure TOpenSSL_Base.SetDLLDir( const Value: string); -begin -if FDLLDir = Value then exit; -Assert( not GetIsLoaded, '(Error) Do not set SupportDLLDir while the library is loaded.'); -FDLLDir := Value -end; - - -procedure TOpenSSL_Base.SetIsLoaded( Value: boolean); -begin -if (FHandle <> 0) = Value then exit; -if Value then - begin - if not FhaveTriedToOpen then - begin - FhaveTriedToOpen := True; - OpenLib - end; - end - else - CloseLib -end; - - -procedure TOpenSSL_Base.SetLibName( const Value: string); -var - sCanonicalValue: string; -begin -sCanonicalValue := Value; -if sCanonicalValue = '' then - sCanonicalValue := LibEay; -if FLibName = sCanonicalValue then exit; -Assert( not GetIsLoaded, 'Do not set LibName while the library is loaded.'); -FLibName := sCanonicalValue -end; - -procedure TOpenSSL_Base.SetLibPath(const Value: string); -begin -if FLibName = Value then exit; -Assert( not GetIsLoaded, 'Do not set LibPath while the library is loaded.'); -FLibPath := Value -end; - - -type - TOpenSSLproc_Malloc = function( Size: longword) : Pointer; cdecl; - -function Delphi_Malloc( Size: longword): pointer cdecl; -begin -{$IFDEF HuntingMemoryLeaks} -result := AllocMem( Size + 4); -plongword( result)^ := Size; -result := pointer( cardinal( result) + 4); -Allocated := Allocated + Size -{$ELSE} -result := AllocMem( Size) -{$ENDIF} -end; - - -type - TOpenSSLproc_Realloc = function( Ptr: pointer; Size: longword): pointer; cdecl; - -function Delphi_Realloc( Ptr: pointer; Size: longword): pointer cdecl; -{$IFDEF HuntingMemoryLeaks} -var - OldSize: longword; -begin -result := pointer( cardinal( Ptr) - 4); -OldSize := plongword( result)^; -ReallocMem( result, Size); -plongword( result)^ := Size; -result := pointer( cardinal( result) + 4); -Allocated := Allocated - OldSize + Size -end; -{$ELSE} -begin -result := Ptr; -ReallocMem( result, Size); -end; -{$ENDIF} - -type - TOpenSSLproc_Free = procedure( Ptr: pointer); cdecl; - -procedure Delphi_Free( Ptr: pointer) cdecl; -{$IFDEF HuntingMemoryLeaks} -var - RealPtr: pointer; - OldSize: longword; -begin -RealPtr := pointer( cardinal( Ptr) - 4); -OldSize := plongword( RealPtr)^; -FreeMem( RealPtr); -Allocated := Allocated - OldSize -end; -{$ELSE} -begin -FreeMem( Ptr) -end; -{$ENDIF} - -procedure TOpenSSL_Base.SetMemoryManager; -var - openSSLproc_CRYPTO_set_mem_functions : function( - m: TOpenSSLproc_Malloc; - r: TOpenSSLproc_Realloc; - f: TOpenSSLproc_Free): longint cdecl; -begin -@openSSLproc_CRYPTO_set_mem_functions := GetProcAddress( FHandle, 'CRYPTO_set_mem_functions'); -if assigned( openSSLproc_CRYPTO_set_mem_functions) then - openSSLproc_CRYPTO_set_mem_functions( - @Delphi_Malloc, @Delphi_Realloc, @Delphi_Free) -end; - -procedure TOpenSSL_Base.SetRequiredVersionStr( const Value: string); -var - s: string; - isOk1: boolean; - isEmpty1: boolean; - RqrMajorV1, RqrMinorV1, RqrReleaseV1, RqrBuildV1: integer; - - procedure ExtractNumberBeforeDot( - var sDotSeparatedNumbers: string; - var FirstNumber: integer; - var isOk: boolean; - var isEmpty: boolean); - - var - P: integer; - sVal: string; - Code: integer; - begin - P := Pos( '.', sDotSeparatedNumbers); - if P > 0 then - begin - sVal := Copy( sDotSeparatedNumbers, 1, P - 1); - Delete( sDotSeparatedNumbers, 1, P) - end - else - begin - sVal := sDotSeparatedNumbers; - sDotSeparatedNumbers := '' - end; - isEmpty := sVal = ''; - if isEmpty then - begin - FirstNumber := 0; - isOk := True - end - else - begin - Val( sVal, FirstNumber, Code); - isOk := Code = 0; - if not isOk then - FirstNumber := 0 - end; - if isOk and (FirstNumber < 0) then - begin - isOk := False; - FirstNumber := 0 - end - end; - -begin -s := Trim( Value); -RqrMajorV1 := 0; -RqrMinorV1 := 0; -RqrReleaseV1 := 0; -RqrBuildV1 := 0; -ExtractNumberBeforeDot( s, RqrMajorV1, isOk1, isEmpty1); - -if isOk1 and (not isEmpty1) and (s <> '') then - ExtractNumberBeforeDot( s, RqrMinorV1, isOk1, isEmpty1); - -if isOk1 and (not isEmpty1) and (s <> '') then - ExtractNumberBeforeDot( s, RqrReleaseV1, isOk1, isEmpty1); - -if isOk1 and (not isEmpty1) and (s <> '') then - ExtractNumberBeforeDot( s, RqrBuildV1, isOk1, isEmpty1); - -if isOk1 and (s <> '') then - isOk1 := False; - -if not isOk1 then - raise Exception.CreateFmt('"%s" is invalid format for ' + - 'TOpenSSL_Lib.RequiredVersion',[Trim(Value)]); - -if (FRqrMajorV = RqrMajorV1 ) and - (FRqrMinorV = RqrMinorV1 ) and - (FRqrReleaseV = RqrReleaseV1) and - (FRqrBuildV = RqrBuildV1 ) then - exit; - -Assert( not GetIsLoaded, 'Do not set RequiredVersion while the library is loaded.'); - -FRqrMajorV := RqrMajorV1; -FRqrMinorV := RqrMinorV1; -FRqrReleaseV := RqrReleaseV1; -FRqrBuildV := RqrBuildV1 -end; - - - -function TOpenSSL_Signatory.SignVerify_SelfTest: boolean; -var - TestMessage, Signature: utf8string; - ErrorMsg: string; - Idx: TSigHashKind; -begin -TestMessage := 'Hello worldHello worldHello worldHello worldHello'; -SetLength( TestMessage, 20); -for Idx := Low( TSigHashKind) to High( TSigHashKind) do - begin - RSA_Sign( Idx, @TestMessage[1], Length( TestMessage), Signature, ErrorMsg); - result := (ErrorMsg = '') and - RSA_Verify( Idx, @TestMessage[1], Length( TestMessage), Signature); - if not result then break - end; -end; - -{$IF CompilerVersion < 21} - {$IFDEF UNICODE} - function SetDllDirectory( lpPathName: PWideChar): BOOL; - stdcall; external kernel32 name 'SetDllDirectoryW'; - {$ELSE} - function SetDllDirectory( lpPathName: PAnsiChar): BOOL; - stdcall; external kernel32 name 'SetDllDirectoryA'; - {$ENDIF} -{$IFEND} - -function TOpenSSL_Base.TryOpen( const LibPath, LibName, DLLDir: string; - RqrMajorV, RqrMinorV, RqrReleaseV, RqrBuildV: integer; - const RqrSignatureProc: string; var Err: TOpenLibError; var Handle: HMODULE; - var WindowsError: DWORD; var FileName, ErrMsg: string; var MajorV, MinorV, - ReleaseV, BuildV: integer): boolean; -{$IFDEF MSWINDOWS} -var - iLibSize, iValueSize: DWord; - Buf: ansiString; - Ok: boolean; - fvip: pointer; -{$ENDIF} -begin -Err := erNull; -Handle := 0; -WindowsError := 0; -FileName := LibName; -if LibPath <> '' then - FileName := IncludeTrailingPathDelimiter( LibPath) + FileName; -ErrMsg := ''; -MajorV := 0; -MinorV := 0; -ReleaseV := 0; -BuildV := 0; -{$IF Defined(WIN64)} - {$IF Defined(OpenSSL_Win64_NotYetSupported)} - result := False; - Err := erPlatformNotSupported; - ErrMsg := 'Win64 platform not yet supported by TOpenSSL_Signatory.'; - exit; - {$IFEND} -{$ELSEIF not Defined(WIN32)} - result := False; - Err := erPlatformNotSupported; - ErrMsg := 'This platform not supported by TOpenSSL_Signatory.'; - exit; -{$IFEND} - -{$IFDEF MSWINDOWS} -if (DLLDir <> '') and (not SetDllDirectory( PChar( DLLDir))) then - begin - Err := erSetDLLDirectory; - WindowsError := GetLastError; - end; -if Err = erNull then - try - Handle := SysUtils.safeloadlibrary( FileName, SEM_FAILCRITICALERRORS + - SEM_NOGPFAULTERRORBOX + - SEM_NOOPENFILEERRORBOX); - if Handle = 0 then - begin - Err := erLoadFailed; - WindowsError := GetLastError - end; - except on e: exception do - begin - Err := erException; - Handle := 0; - ErrMsg := Format( '%s: %s', [e.ClassName, e.Message]) - end; - end; -if (DLLDir <> '') and (Err <> erSetDLLDirectory) then - SetDllDirectory(nil); -if Handle <> 0 then - FileName := sysutils.GetModuleName( Handle); -if (Err in [erSetDLLDirectory, erLoadFailed]) and (WindowsError <> 0) then - ErrMsg := SysUtils.SysErrorMessage( WindowsError); -result := Err = erNull; - -if result then - begin - iLibSize := GetFileVersionInfoSize( PChar( FileName), iLibSize); - Ok := iLibSize > 0; - if Ok then - begin - SetLength( Buf, iLibSize); - Ok := GetFileVersionInfo( PChar( FileName), 0, iLibSize, PAnsiChar( Buf)) and - VerQueryValue( PAnsiChar( Buf), '\', fvip, iValueSize) and - (iValueSize >= SizeOf( TVSFixedFileInfo)) - end; - if Ok then - begin - MajorV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); - MinorV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); - ReleaseV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionLS); - BuildV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionLS) - end - end; -if result and ( - (MajorV < RqrMajorV) or - ((MajorV = RqrMajorV) and (MinorV < RqrMinorV)) or - ((MajorV = RqrMajorV) and (MinorV = RqrMinorV) and (ReleaseV < RqrReleaseV)) or - ((MajorV = RqrMajorV) and (MinorV = RqrMinorV) and (ReleaseV < RqrReleaseV) and (BuildV < RqrBuildV))) then - begin - Err := erVersionTooLow; - result := False - end; - -if result and (RqrSignatureProc <> '') and (not assigned( - windows.GetProcAddress( Handle, PChar( RqrSignatureProc)))) then - begin - Err := erSignatureAbsent; - result := False - end; - -if (Err in [erVersionTooLow, erSignatureAbsent]) and (Handle <> 0) then - begin - FreeLibrary( Handle); - Handle := 0 - end; -{$ENDIF} -end; - -procedure TOpenSSL_Signatory.StoreKeysToStream( - Store: TStream; Parts: TKeyStoragePartSet); -var - sPrivateKey, sPublicKey: utf8string; - -begin -if partPrivate in Parts then - begin - sPrivateKey := PrivateKey_AsPEM( FStorageCipher, FStoragePassword); - if Pos( '(Error) ', sPrivateKey) > 0 then - begin - FErrMsg := sPrivateKey; - raise Exception.Create( FErrMsg) - end; - if sPrivateKey <> '' then - Store.Write( sPrivateKey[1], Length( sPrivateKey)) - end - - else if partPublic in Parts then - begin - sPublicKey := PublicKey; - if Pos( '(Error) ', sPublicKey) > 0 then - begin - FErrMsg := sPublicKey; - raise Exception.Create( FErrMsg) - end; - if sPublicKey <> '' then - Store.Write( sPublicKey[1], Length( sPublicKey)) - end - - else begin end -end; - -procedure TOpenSSL_Signatory.LoadKeysFromStream( - Store: TStream; Parts: TKeyStoragePartSet); -var - ErrorMessage: string; -begin -if partPrivate in Parts then - begin - LoadRSA_PrivateKey( ErrorMessage, FStorageCipher, ReadString( Store, - '-----END RSA PRIVATE KEY-----'#10), FStoragePassword); - if ErrorMessage = '' then exit; - FErrMsg := ErrorMessage; - raise Exception.Create( FErrMsg) - end - - else if partPublic in Parts then - begin - LoadRSA_PublicKey( ErrorMessage, ReadString( Store, - '-----END RSA PUBLIC KEY-----'#10)); - if ErrorMessage = '' then exit; - FErrMsg := ErrorMessage; - raise Exception.Create( FErrMsg) - end - - else begin end -end; - -function TOpenSSL_Signatory.Sign( - PreHash: TSigHashKind; HashedDocument, Signature: TStream): boolean; -var - Message1: pointer; - MessageLen: cardinal; - sSignature: utf8string; - ErrorMessage: string; - MemStream: TMemoryStream; -begin -MessageLen := HashedDocument.Size - HashedDocument.Position; -if HashedDocument is TMemoryStream then - begin - Message1 := TMemoryStream( HashedDocument).Memory; - MemStream := nil - end - else - begin - MemStream := TMemoryStream.Create; - MemStream.Size := MessageLen; - MemStream.Position := 0; - MemStream.CopyFrom( HashedDocument, MessageLen); - Message1 := MemStream.Memory - end; -try - RSA_Sign( PreHash, Message1, MessageLen, sSignature, ErrorMessage); -finally - MemStream.Free - end; -result := (ErrorMessage = '') and (sSignature <> ''); -if result then - Signature.Write( sSignature[1], Length( sSignature)) - else if ErrorMessage <> '' then - FErrMsg := ErrorMessage - else - FErrMsg := '(Error) Unknown error' -end; - - -function TOpenSSL_Signatory.Verify( - PreHash: TSigHashKind; HashedDocument, Signature: TStream): TVerifyResult; -var - Message1: pointer; - MessageLen: cardinal; - sSignature: utf8string; - MemStream: TMemoryStream; - SigLen: integer; -begin -MessageLen := HashedDocument.Size - HashedDocument.Position; -if HashedDocument is TMemoryStream then - begin - Message1 := TMemoryStream( HashedDocument).Memory; - MemStream := nil - end - else - begin - MemStream := TMemoryStream.Create; - MemStream.Size := MessageLen; - MemStream.Position := 0; - MemStream.CopyFrom( HashedDocument, MessageLen); - Message1 := MemStream.Memory - end; -try - SigLen := Signature.Size - Signature.Position; - SetLength( sSignature, SigLen); - if SigLen > 0 then - Signature.Read( sSignature[1], SigLen); - if RSA_Verify( PreHash, Message1, MessageLen, sSignature) then - result := vPass - else - result := vFail -finally - MemStream.Free - end -end; - - -function TOpenSSL_Signatory.GetPrivateKey_AsPEM: utf8string; -begin -if partPrivate in FKeyStorageParts then - result := PrivateKey_AsPEM( FStorageCipher, FStoragePassword) - else - result := '(Error) No private key' -end; - - -procedure TOpenSSL_Signatory.SetPrivateKey_AsPEM( const Value: utf8string); -var - Err: string; -begin -LoadRSA_PrivateKey( Err, FStorageCipher, Value, FStoragePassword); -if Err <> '' then - begin - FErrMsg := Err; - raise Exception.Create( FErrMsg) - end -end; - - -procedure TOpenSSL_Signatory.SetPublicKey_AsPEM( const Value: utf8string); -var - Err: string; -begin -LoadRSA_PublicKey( Err, Value); -if Err <> '' then - begin - FErrMsg := Err; - raise Exception.Create( FErrMsg) - end -end; - - - -//procedure TOpenSSL_Signatory.OpenSSL_Encrypt( const key, iv: TBytes; Cipher: TCipherToEncryptPrivateKeyWith; InStream, OutStream: TStream); -//var -// Key: rawbytestring; -// IV : rawbytestring; -// ctx: EVP_CIPHER_CTX; -// ret: integer; -// s: string; -// j: integer; -// outbuf, inbuf: TBytes; -// inLen, outLen: Integer; -// Ok: boolean; -//begin -//Key := '1234567812345678'; -//IV := '1234567812345678'; -//SetLength( inbuf, Length( Key)); -//SetLength( outbuf, Length( Key)); - -// FOpenSSLProc_EVP_CipherInit_ex( ctx, GetEVP( cipher_aes_256_ofb), nil, nil, nil, 1); -// FOpenSSLProc_EVP_CIPHER_CTX_set_key_length( ctx, Length( Key)); -// FOpenSSLProc_EVP_CipherInit_ex( ctx, nil, nil, @Key[1], @IV[1], 1); -// for j := 1 to 10 do -// begin -// inLen := Length( inBuf); -// outLen := Length( outBuf); -// Ok := FOpenSSLProc_EVP_CipherUpdate( ctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; -// if not Ok then break; -// s := '1'; -// end; -// outLen := Length( outBuf); -// Ok := FOpenSSLProc_EVP_CipherFinal_ex( ctx, @outbuf[1], outLen) <> 0; - -//end; - -{ TOpenSSL_Codec } - -constructor TOpenSSL_Codec.Create( AOwner: TComponent); -begin -inherited Create( AOwner); -FCipher := cipher_aes_256_ofb; -SetLength( FKey, 0); -SetLength( FIV , 0); -FisInitialised := False; -FPad := padPKCS; -end; - -destructor TOpenSSL_Codec.Destroy; -begin -if isLoaded and FisInitialised then - begin - FisInitialised := False; - FOpenSSLProc_EVP_CIPHER_CTX_cleanup( Fctx); // Equivalent to a burn. - end; -inherited -end; - -procedure TOpenSSL_Codec.SetKey( const key1: TBytes); -begin -SetLength( FKey, Length( key1)); -if Length( key1) > 0 then - Move( key1[1], FKey[1], Length( key1)); -end; - -procedure TOpenSSL_Codec.SetIV( const iv1: TBytes); -begin -SetLength( FIV, Length( iv1)); -if Length( iv1) > 0 then - Move( iv1[1], FIV[1], Length( iv1)); -end; - -procedure TOpenSSL_Codec.BeginEncDec( doEncrypt: Boolean); -var - EncValue: integer; - iPadParm: integer; -begin -if not FisInitialised then - begin - FisInitialised := True; - FOpenSSLProc_EVP_CIPHER_CTX_init( Fctx); - end; -FOpenSSLProc_EVP_CipherInit_ex( Fctx, GetEVP( FCipher), nil, nil, nil, 1); -FOpenSSLProc_EVP_CIPHER_CTX_set_key_length( Fctx, Length( FKey)); -if doEncrypt then - EncValue := 1 - else - EncValue := 0; -FOpenSSLProc_EVP_CipherInit_ex( Fctx, nil, nil, @FKey[1], @FIV[1], EncValue); -iPadParm := Ord( FPad); -FOpenSSLProc_EVP_CIPHER_CTX_set_padding( Fctx, iPadParm); -end; - -procedure TOpenSSL_Codec.Encrypt( - PlaintextInStream, CiphertextOutStream: TStream); -var - InBuf, OutBuf: TBytes; - InLen, OutLen: Integer; - Ok: boolean; -begin -BeginEncDec( True); -SetLength( InBuf , Length( FIV)); -SetLength( OutBuf, Length( FIV) * 2); -Ok := True; -repeat - InLen := PlaintextInStream.Read( InBuf[1], Length( InBuf)); - OutLen := Length( OutBuf); - If InLen = 0 then break; - if InLen < Length( InBuf) then - begin - case FPad of - padNone: - begin - - end; - - padPKCS: - begin - - end; - - end; - end; - Ok := FOpenSSLProc_EVP_CipherUpdate( Fctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; - if Ok and (OutLen > 0) then - CiphertextOutStream.Write( OutBuf[1], OutLen) -until (InLen < Length( InBuf)) or (not Ok); -if Ok then - begin - OutLen := Length( outBuf); - Ok := FOpenSSLProc_EVP_CipherFinal_ex( Fctx, @Outbuf[1], OutLen) <> 0; - if Ok and (OutLen > 0) then - CiphertextOutStream.Write( OutBuf[1], OutLen) - end - else - raise Exception.Create( 'OpenSSL encryption error') -end; - -procedure TOpenSSL_Codec.Decrypt( - PlaintextOutStream, CiphertextInStream: TStream); -const - MaxTries = 2; -var - InBuf, OutBuf: TBytes; - InLen, OutLen: Integer; - Ok: boolean; - PlainPos, CipherPos, CipherSz: Int64; - Trial: integer; -begin -PlainPos := PlaintextOutStream.Position; -CipherPos := CiphertextInStream.Position; -CipherSz := CiphertextInStream.Size; -for Trial := 1 to MaxTries do - begin - BeginEncDec( False); - SetLength( InBuf , Length( FIV)); - SetLength( OutBuf, Length( FIV) * 2); - Ok := True; - repeat - InLen := CiphertextInStream.Read( InBuf[1], Length( InBuf)); - OutLen := Length( OutBuf); - If InLen = 0 then break; - Ok := FOpenSSLProc_EVP_CipherUpdate( Fctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; - if Ok and (OutLen > 0) then - PlaintextOutStream.Write( OutBuf[1], OutLen) - until (InLen < Length( InBuf)) or (not Ok); - if Ok then - begin - OutLen := Length( outBuf); - Ok := FOpenSSLProc_EVP_CipherFinal_ex( Fctx, @Outbuf[1], OutLen) <> 0; - if Ok and (OutLen > 0) then - PlaintextOutStream.Write( OutBuf[1], OutLen) - end; - if Ok then break; - if Trial < MaxTries then - begin - PlaintextOutStream.Position := PlainPos; - CiphertextInStream.Position := CipherPos; - CiphertextInStream.Size := CipherSz; - FisInitialised := False; - FOpenSSLProc_EVP_CIPHER_CTX_cleanup( Fctx) - end - else - raise Exception.Create( 'OpenSSL encryption error') - end -end; - -initialization -InitUnit_OpenSSL_Lib; - -finalization -DoneUnit_OpenSSL_Lib -end. +{* ***** BEGIN LICENSE BLOCK ***** +This file is a wrapper around the OpenSSL dynamic link library, using +its published API. As a consequence, there are some identifiers in this +file which are copied from or derived from the OpenSSL source code header files. + +Although the use here, of the OpenSSL headers are sufficiently limited, +that copying of this file in relation to the OpenSSL copyright is defended +by the doctrine of fair use, as a measure of respect, please note the following +license conditions for the redistribution of the OpenSSL project products. + + + +======================================================================== +======================================================================== +========== BEGINNING OF THE OPENSSL LICENSE DISCLOSURE =============== +======================================================================== +======================================================================== + + LICENSE ISSUES + ============== + + The OpenSSL toolkit stays under a dual license, i.e. both the conditions of + the OpenSSL License and the original SSLeay license apply to the toolkit. + See below for the actual license texts. Actually both licenses are BSD-style + Open Source licenses. In case of any license issues related to OpenSSL + please contact openssl-core@openssl.org. + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + LICENSE ISSUES + ============== + + The OpenSSL toolkit stays under a dual license, i.e. both the conditions of + the OpenSSL License and the original SSLeay license apply to the toolkit. + See below for the actual license texts. Actually both licenses are BSD-style + Open Source licenses. In case of any license issues related to OpenSSL + please contact openssl-core@openssl.org. + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +======================================================================== +======================================================================== +========== END OF THE OPENSSL LICENSE DISCLOSURE ====================== +======================================================================== +======================================================================== + + + + + + + +======================================================================== +======================================================================== +========== BEGINNING OF COPYRIGHT NOTICE AND ========================== +========== STATEMENT OF COPYING PERMISSION FOR THIS FILE =========== +======================================================================== +======================================================================== + +Copyright 2011 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + + +======================================================================== +======================================================================== +========== END OF COPYRIGHT NOTICE AND ================================ +========== STATEMENT OF COPYING PERMISSION FOR THIS FILE =========== +======================================================================== +======================================================================== + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.OpenSSL experimental; +// {$IFDEF VER150} +// unit uTPLb_OpenSSL; +// {$ENDIF} +// +// {$IF compilerversion > 16} +// unit TPLB3.OpenSSL experimental; +// {$IFEND} + +{$define OpenSSL_Win64_NotYetSupported} +// Undefine the above, when someone has tested the TOpenSSL_Signatory component +// for 64-bit platform. + + +interface +uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.Signatory, + TPLB3.Asymetric, SysUtils, {$IFDEF MSWINDOWS}Windows,{$ENDIF} Types, + TPLB3.Compatibility; + +const +{$IF Defined(WIN32)} + LibEay = 'libeay32.dll'; +{$ELSEIF Defined(WIN64)} + LibEay = 'libeay64.dll'; +{$ELSEIF not Defined(WIN32) and not Defined(WIN64)} + LibEay = ''; +{$IFEND} + Default_AsymetricKeySizeInBits = 2048; + +// OpenSSL is not supported on NEXTGEN platforms; these aliases are just to +// keep the compiler happy. +{$IFDEF NEXTGEN} +type + AnsiChar = Char; + AnsiString = string; + PAnsiChar = PWideChar; + PAnsiString = ^AnsiString; + UTF8String = string; +{$ENDIF} + +type +TOpenLibError = ( + erNull, + erSetDLLDirectory, + erLoadFailed, + erException, + erVersionTooLow, + erSignatureAbsent, + erPlatformNotSupported + ); + + +type + +TCipherToEncryptPrivateKeyWith = ( + cipher_InTheClear, + cipher_des_ede3_cbc, + cipher_des_cbc , + cipher_idea_cbc , + cipher_seed_cbc , + cipher_aes_128_cbc, + cipher_aes_192_cbc , + cipher_aes_256_cbc , + cipher_aes_256_ofb , + cipher_camellia_128_cbc, + cipher_camellia_192_cbc, + cipher_camellia_256_cbc); + + +const + EVP_MAX_MD_SIZE = 64; + EVP_MAX_KEY_LENGTH = 32; + EVP_MAX_IV_LENGTH = 16; + EVP_MAX_BLOCK_LENGTH = 32; + +type +EVP_CIPHER_CTX = packed record + cipher: pointer; // to EVP_CIPHER + engine: pointer; // to ENGINE *engine; Functional reference if 'cipher' is ENGINE-provided + encrypt: integer; // encrypt or decrypt + buf_len: integer; // number we have left + + oiv: array[0..EVP_MAX_IV_LENGTH-1] of byte; // original iv + iv : array[0..EVP_MAX_IV_LENGTH-1] of byte; // working iv + buf: array[0..EVP_MAX_BLOCK_LENGTH-1] of byte; // saved partial block + num: integer; // used by cfb/ofb mode + app_data: pointer; // application stuff + key_len: integer; // May change for variable length cipher + flags: longword; // Various flags + cipher_data: pointer; // per EVP data + final_used: integer; + block_mask: integer; + final1: array[0..EVP_MAX_BLOCK_LENGTH-1] of byte; // possible final block */ + xtra: array[0..100] of byte; + end; + +EVP_CIPHER_varProc = procedure( var a: EVP_CIPHER_CTX); cdecl; +EVP_CIPHER_intFunc = function ( var a: EVP_CIPHER_CTX): integer; cdecl; + +PBIO = pointer; // For the curious, you can find a more transparent + // definition of BIO/PBIO in unit IdSSLOpenSSLHeaders, + // or go directly to the OpenSSL header files. + +TOpenSSL_Signatory = class; + + +TBIO = class( TObject) + protected + FLib: TOpenSSL_Signatory; + FBIOobj: pBIO; + + function InitBIO_Object: pBIO; virtual; abstract; + + public + constructor Create( Lib1: TOpenSSL_Signatory); + function Readansistring: ansistring; + // Actually the character encoding must be determined by the context. + // It is not necessarily ansi. It could be a raw byte data. + destructor Destroy; override; + end; + +TMemoryBIO = class( TBIO) + protected + function InitBIO_Object: pBIO; override; + + public + end; + +TReadOnlyBIO = class( TBIO) + private + FData: TBytes; + + protected + function InitBIO_Object: pBIO; override; + + public + constructor Create( Lib1: TOpenSSL_Signatory; Data: pointer; DataLen: integer); + destructor Destroy; override; + end; + + +PBN_GENCB = ^BN_GENCB; +BN_GENCB = packed record + ver : longword; // WILL be 2. + arg : pointer; + cb_2: function( p1, p2 : longint; p3: PBN_GENCB): longint; cdecl; + end; + +pem_password_cb = function( buf: PAnsistring; size, rwflag: longint; + userdata: pointer): longint; cdecl; + +TSigHashKind = ( // How was the input message to sign/verify computed from the source document? + hshSHA1, // The document was hashed with SHA1 to produce the input message. NID_sha1 = 64 + hshRipemd160, // The hash algorithm was ripemd160. NID_ripemd160 = 117 + hshMD5); // The hash was MD5. NID_md5 = 4 + +BIGNUM = packed record + d : longword; + top : longint; + dmax : longint; + neg : longint; + flags: longint; + end; +PBIGNUM = ^BIGNUM; + +CRYPTO_EX_DATA = packed record + sk : pointer; + dummy: longint; + end; + +RSA = packed record + pad : longint; + version : longword; + engine : pointer; // PENGINE + n : PBIGNUM; + e : PBIGNUM; + d : PBIGNUM; + p : PBIGNUM; + q : PBIGNUM; + dmp1 : PBIGNUM; + dmq1 : PBIGNUM; + iqmp : PBIGNUM; + ex_data : CRYPTO_EX_DATA; + references: longint; + flags : longint; + _method_mod_n : pointer; + _method_mod_p : pointer; + _method_mod_q : pointer; + bignum_data : PAnsichar; + blinding : pointer; + mt_blinding : pointer; + end; +PRSA = ^RSA; +PPRSA = ^PRSA; + +Pbio_info_cb = procedure( _para1: PBIO; _para2: longint; + _para3: PAnsichar; _para4: longint; _para5, _para6: longword); cdecl; + +BIO_METHOD = packed record + _type: longint; + name : PAnsichar; + bwrite : function (_para1: PBIO; _para2 : PAnsichar; _para3 : longint): longint; cdecl; + bread : function (_para1: PBIO; _para2: PAnsiChar; _para3: longint): longint; cdecl; + bputs : function (_para1: PBIO; _para2 : PAnsichar): longint; cdecl; + bgets : function (_para1: PBIO; _para2 : PAnsichar; _para3: longint): longint; cdecl; + ctrl : function (_para1: PBIO; _para2 : longint; _para3: longword; _para4: pointer): longword; cdecl; + create : function (_para1: PBIO): longint; cdecl; + destroy : function (_para1: PBIO): longint; cdecl; + callback_ctrl: function (_para1: PBIO; _para2: longint; _para : pbio_info_cb): longword; cdecl; + end; +PBIO_METHOD = ^BIO_METHOD; + +PEVP_CIPHER = pointer; + +TOpenSLL_CipherFunc = function: PEVP_CIPHER; cdecl; + +TOnOpenSSLProgress = function( Sender: TObject; p1, p2: integer): boolean of object; + + +TOpenSSL_Base = class +{$IF CompilerVersion > 15} + abstract +{$IFEND} + ( TTPLb_BaseNonVisualComponent) + private + FHandle: HMODULE; + FLibPath: string; + FLibName: string; + FFileName: string; // LibPath + LibName + FDLLDir: string; // dir of needed DLL's. + FRqrMajorV: integer; + FRqrMinorV: integer; + FRqrReleaseV: integer; + FRqrBuildV: integer; + FErr: TOpenLibError; + FWindowsError: DWORD; + FErrMsg: string; + FMajorV, FMinorV, FReleaseV, FBuildV: integer; + FhaveTriedToOpen: boolean; + FdoOPENSSL_LOAD_CONF: boolean; + FisSafeToFreeRSA: boolean; + FPassword: utf8string; + FCachedSize: integer; + + FOpenSSLproc_BioSMem: function: PBIO_METHOD cdecl; + FOpenSSLproc_BioNew : function(_type: PBIO_METHOD): PBIO cdecl; + FOpenSSLproc_BioFree: function( bio: PBIO): longint cdecl; + FOpenSSLproc_BioRead: function( b: PBIO; data: Pointer; len: longint): longint cdecl; + //FOpenSSLProc_setup_engine: function( var err: BIO; sEngine: PChar; debug: longint): PEngine; cdecl; + FOpenSSLProc_RAND_seed: procedure( const buf: pointer; num: integer); cdecl; + FOpenSSLProc_RAND_status: function: integer; cdecl; + FOpenSSLProc_RSA_new: function: PRSA; + // FOpenSSLProc_RSA_new_method: function( Eng: PEngine): PRSA; + FOpenSSLProc_RSA_size: function( RSA: PRSA): longint; + FOpenSSLProc_RSA_free: procedure( R: PRSA); + FOpenSSLProc_BN_set_word: function( n: pBIGNUM; w: longword): longint; cdecl; + FOpenSSLProc_RSA_generate_key_ex: function( rsa : PRSA; bits: longint; e: PBIGNUM; cb: PBN_GENCB): integer; cdecl; + FOpenSSLProc_BN_free: procedure( n: PBIGNUM); cdecl; + FOpenSSLProc_BN_new: function: PBIGNUM; + FOpenSSLProc_ERR_get_err: function: longword; cdecl; + FOpenSSLProc_ERR_error_string_n: procedure( ErrorCode: longword; Buf: PAnsiChar; len: longword); cdecl; + FOpenSSLProc_BN_get_word: function ( a: PBIGNUM): longword; cdecl; + FOpenSSLProc_RSA_up_ref: function( rsa: PRSA): longint; cdecl; + FOpenSSLProc_PEM_write_bio_RSAPrivateKey: + function( bp: PBIO; x: PRSA; const enc: PEVP_CIPHER; kstr: PAnsiChar; + klen: longint; cb: pem_password_cb; u: pointer): longint; cdecl; + FOpenSSLProc_PEM_write_bio_RSAPublicKey: function( bp: PBIO; x: PRSA): longint; cdecl; + FOpenSSLProc_RSA_sign: function( type1: longint; m: pointer; m_len: longword; + sigret: PAnsichar; var siglen: longword; rsa: PRSA): longint; cdecl; + FOpenSSLProc_RSA_verify: function (type1: longint; m: pointer; m_len: longword; + sigbuf: PAnsichar; siglen: longword; rsa: PRSA): longint; cdecl; + FOpenSSLProc_RSA_print: function( bp: PBIO; x: PRSA; offset: longint): longint; cdecl; + FOpenSSLProc_PEM_read_bio_RSAPrivateKey: + function( bp: PBIO; x: PPRSA; cb: pem_password_cb; u: pointer): PRSA; cdecl; + FOpenSSLProc_BIO_new_mem_buf: function( buf: pointer; len: longint): PBIO; cdecl; + FOpenSSLProc_PEM_read_bio_RSAPublicKey: + function( bp: PBIO; x: PPRSA; cb: pem_password_cb; u: pointer): PRSA; cdecl; + + FOpenSSLProc_EVP_des_ede3_cbc : TOpenSLL_CipherFunc; // des3 + FOpenSSLProc_EVP_des_cbc : TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_idea_cbc : TOpenSLL_CipherFunc; // idea + FOpenSSLProc_EVP_seed_cbc : TOpenSLL_CipherFunc; // Encrypt PEM output with CBC seed + FOpenSSLProc_EVP_aes_128_cbc : TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_aes_192_cbc : TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_aes_256_cbc : TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_aes_256_ofb : TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_camellia_128_cbc: TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_camellia_192_cbc: TOpenSLL_CipherFunc; + FOpenSSLProc_EVP_camellia_256_cbc: TOpenSLL_CipherFunc; + + FOpenSSLProc_EVP_CIPHER_CTX_init: EVP_CIPHER_varProc; + FOpenSSLProc_EVP_CIPHER_CTX_cleanup: EVP_CIPHER_intFunc; + FOpenSSLProc_EVP_CipherInit_ex: function( var ctx: EVP_CIPHER_CTX; + const cipher: PEVP_CIPHER; impl: pointer {PENGINE}; + const key: PByte; const iv: PByte; enc: integer): integer; cdecl; + FOpenSSLProc_EVP_CIPHER_CTX_set_key_length: + function (var x: EVP_CIPHER_CTX; keylen: integer): integer; cdecl; + FOpenSSLProc_EVP_CipherUpdate: function( var ctx: EVP_CIPHER_CTX; + const outBytes: PByte; var outLen: integer; + const inBytes: PByte; inLen: integer): integer; cdecl; + FOpenSSLProc_EVP_CipherFinal_ex: function( var ctx: EVP_CIPHER_CTX; + const outBytes: PByte; var outLen: integer): integer; cdecl; + FOpenSSLProc_EVP_CIPHER_CTX_set_padding: function( var ctx: EVP_CIPHER_CTX; + pad: integer): integer; cdecl; + + function GetEVP( Cipher: TCipherToEncryptPrivateKeyWith): PEVP_CIPHER; + + function TryOpen( + const LibPath: string; // Empty or path to lib (no final backslash) + const LibName: string; // pathless library filename. + const DLLDir: string; // Empty or SetDLLDirectory directory. + RqrMajorV, RqrMinorV, RqrReleaseV, RqrBuildV: integer; + const RqrSignatureProc: string; // An exported procedure of this name + // MUST be in the library or it is not valid. + // Minimum requirements. + // If zero's then no requirements. + var Err: TOpenLibError; // Kind of error. + var Handle: HMODULE; // Returned library handle. + var WindowsError: DWORD; // windows GetLastError where appropriate. + var FileName: string; // Full file name of loaded library + var ErrMsg: string; // Error message, where available. + var MajorV, MinorV, ReleaseV, BuildV: integer // Actual version numbers. + + ): boolean; // True if and only if loaded ok. + + function GetIsLoaded: boolean; + procedure SetIsLoaded( Value: boolean); + + procedure SetLibPath( const Value: string); + procedure SetLibName( const Value: string); + procedure SetDLLDir( const Value: string); + function GetRequiredVersionStr: string; + procedure SetRequiredVersionStr( const Value: string); + procedure OpenLib; + procedure CloseLib; + procedure GetProcs; + procedure ClearProcs; + procedure SetMemoryManager; + procedure App_Start; + procedure App_Shutdown; + function isLibraryUniqueInstance: boolean; + procedure GetAndCallParameterless( const ProcName: string); + function OpenSSL_CallBack( p1, p2: integer): integer; + procedure GetError( var ErrorCode: integer; var ErrorMsg: string); + + protected + FStoragePassword: utf8string; + FOnProgress: TOnOpenSSLProgress; + procedure PreShutdown; virtual; + + public + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + procedure Clear; + + property isLoaded: boolean read GetIsLoaded write SetIsLoaded; + + property Handle: HMODULE read FHandle; + property FileName: string read FFileName; + property Err: TOpenLibError read FErr; + property WindowsError: DWORD read FWindowsError; + property ErrMsg: string read FErrMsg; + property MajorV: integer read FMajorV; + property MinorV: integer read FMinorV; + property ReleaseV: integer read FReleaseV; + property BuildV: integer read FBuildV; + property haveTriedToOpen: boolean read FhaveTriedToOpen; + + + published + property LibPath: string read FLibPath write SetLibPath; + property LibName: string read FLibName write SetLibName; // default LibEay32; + property SupportDLLDir: string read FDLLDir write SetDLLDir; + // ^ dir of needed DLL's. + property RequiredVersion: string read GetRequiredVersionStr write SetRequiredVersionStr; + // ^ Must be like '1.2.3.4' or '1.2.3' or '1.2' or '1' or empty. + property OnProgress: TOnOpenSSLProgress read FOnProgress write FOnProgress; + end; + + +{$IF CompilerVersion >= 23.0} + {$IFDEF OpenSSL_Win64_NotYetSupported} + [ComponentPlatformsAttribute( pidWin32)] // Just 32-bit for the moment. + {$ELSE} + [ComponentPlatformsAttribute( pidWin32, pidWin64)] + {$ENDIF} +{$IFEND} +TOpenSSL_Signatory = class( TOpenSSL_Base) + private + FRSA: PRSA; + FStorageCipher: TCipherToEncryptPrivateKeyWith; + FAsymetricKeySizeInBits: cardinal; + FKeyStorageParts: TKeyStoragePartSet; + + function PEM_Password_CallBack( buf: PAnsistring; size, rwflag: longint): longint; + procedure CloseRSA; + procedure GenRSA( KeySizeInBits: integer; var ErrorCode: integer; var ErrorMsg: string); + + + procedure LoadRSA_PrivateKey( + var ErrorMessage: string; + Cipher: TCipherToEncryptPrivateKeyWith; + const sPrivateKey: utf8string; + const Password: utf8string); + + procedure LoadRSA_PublicKey( + var ErrorMessage: string; + const sPublicKey: utf8string); + + function RSA_Size: integer; + + procedure RSA_Sign( + PreHash: TSigHashKind; + Message1: pointer; MessageLen: cardinal; + var Signature: utf8string; var ErrorMessage: string); + + function RSA_Verify( + PreHash: TSigHashKind; + Message1: pointer; MessageLen: cardinal; + const Signature: utf8string): boolean; // True for verified good. + + + function PrivateKey_AsPEM( Cipher: TCipherToEncryptPrivateKeyWith; const Password: utf8string): utf8string; + + function GetPrivateKey_AsPEM: utf8string; + procedure SetPrivateKey_AsPEM( const Value: utf8string); + function GetPublicKey_AsPEM: utf8string; + procedure SetPublicKey_AsPEM( const Value: utf8string); + + protected + procedure PreShutdown; override; + + public + constructor Create( AOwner: TComponent); override; + function Sign( PreHash: TSigHashKind; HashedDocument, Signature: TStream): boolean; + function Verify( PreHash: TSigHashKind; HashedDocument, Signature: TStream): TVerifyResult; + + function GenerateKeys: boolean; + procedure StoreKeysToStream( Store: TStream; Parts: TKeyStoragePartSet); + procedure LoadKeysFromStream( Store: TStream; Parts: TKeyStoragePartSet); + function HasParts: TKeyStoragePartSet; + procedure Randomize; + function SignVerify_SelfTest: boolean; + function Print: string; + + property PrivateKey: utf8string read GetPrivateKey_AsPEM write SetPrivateKey_AsPEM; + property PublicKey : utf8string read GetPublicKey_AsPEM write SetPublicKey_AsPEM; + + published + property AsymetricKeySizeInBits: cardinal read FAsymetricKeySizeInBits + write FAsymetricKeySizeInBits; + + property PrivateKeyStoragePassword: utf8string read FStoragePassword write FStoragePassword; + property PrivateKeyStorageCipher: TCipherToEncryptPrivateKeyWith read FStorageCipher write FStorageCipher; + property OnProgress: TOnOpenSSLProgress read FOnProgress write FOnProgress; + end; + +TOpenSSL_PaddingScheme = ( + padNone, + padPKCS); + +{$IF CompilerVersion >= 23.0} + {$IFDEF OpenSSL_Win64_NotYetSupported} + [ComponentPlatformsAttribute( pidWin32)] // Just 32-bit for the moment. + {$ELSE} + [ComponentPlatformsAttribute( pidWin32, pidWin64)] + {$ENDIF} +{$IFEND} +TOpenSSL_Codec = class( TOpenSSL_Base) + private + FCipher: TCipherToEncryptPrivateKeyWith; + FKey: TBytes; + FIV: TBytes; + FisInitialised: boolean; + Fctx: EVP_CIPHER_CTX; + FPad: TOpenSSL_PaddingScheme; + procedure BeginEncDec( doEncrypt: Boolean); + + public + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + + procedure SetKey( const key1: TBytes); + procedure SetIV ( const iv1 : TBytes); + procedure Encrypt( PlaintextInStream, CiphertextOutStream: TStream); + procedure Decrypt( PlaintextOutStream, CiphertextInStream: TStream); + + published + property Cipher: TCipherToEncryptPrivateKeyWith read FCipher write FCipher; + property PaddingScheme: TOpenSSL_PaddingScheme read FPad write FPad; + end; + +implementation + + + +{$WARNINGS OFF} +uses SyncObjs, {$IFDEF GENERICS}Generics.Collections{$ELSE}Contnrs{$ENDIF}, TPLB3.Random; + + +const + RSA_F4: longint = $10001; + +var + OpenSSL_LibGate: TCriticalSection = nil; + OpenSSL_Libs : TObjectList{$IFDEF GENERICS}{$ENDIF} = nil; // of TOpenSSL_Lib + +{$IFDEF HuntingMemoryLeaks} + Allocated: int64 = 0; +{$ENDIF} + +procedure InitUnit_OpenSSL_Lib; +begin +OpenSSL_LibGate := TCriticalSection.Create; +OpenSSL_Libs := nil; +{$IFDEF HuntingMemoryLeaks} +Allocated := 0 +{$ENDIF} +end; + +procedure DoneUnit_OpenSSL_Lib; +begin +FreeAndNil( OpenSSL_LibGate); +FreeAndNil( OpenSSL_Libs) +end; + + + + + + +function cb_2_SpringBoard( p1, p2 : longint; p3 : PBN_GENCB): longint; cdecl; +var + InvokerObj: TObject; +begin +InvokerObj := TObject( p3.arg); +if InvokerObj is TOpenSSL_Signatory then + result := TOpenSSL_Signatory( InvokerObj).OpenSSL_CallBack( p1, p2) + else + result := 0 +end; + + +function pem_password_cb_SpringBoard( + buf: PAnsistring; size, rwflag: longint; + userdata: pointer): longint; cdecl; +var + InvokerObj: TObject; +begin +InvokerObj := TObject( userdata); +if InvokerObj is TOpenSSL_Signatory then + result := TOpenSSL_Signatory( InvokerObj) + .PEM_Password_CallBack( buf, size, rwflag) + else + result := 0 +end; + + +{ TBIO } + +constructor TBIO.Create( Lib1: TOpenSSL_Signatory); +begin +FLib := Lib1; +FBIOobj := InitBIO_Object +end; + + +destructor TBIO.Destroy; +begin +if assigned( FBIOobj) and assigned( FLib) and (FLib.FHandle <> 0) then + begin + FLib.FOpenSSLproc_BioFree( FBIOobj); + FBIOobj := nil + end; +inherited +end; + +function TBIO.Readansistring: ansistring; +var + Buffer: ansistring; + Amount: longint; +begin +result := ''; +if (not assigned( FLib)) or (FLib.FHandle = 0) then exit; +SetLength( Buffer, 1024); +repeat + Amount := FLib.FOpenSSLproc_BioRead( FBIOobj, @Buffer[1], Length( Buffer)); + if Amount > 0 then + result := result + Copy( Buffer, 1, Amount) +until Amount = -1 +end; + + +{ TMemoryBIO } + +function TMemoryBIO.InitBIO_Object: pBIO; +begin +result := FLib.FOpenSSLproc_BioNew( FLib.FOpenSSLproc_BioSMem) +end; + +{ TReadOnlyBIO } + +constructor TReadOnlyBIO.Create( + Lib1: TOpenSSL_Signatory; Data: pointer; DataLen: integer); +begin +SetLength( FData, DataLen); +if DataLen > 0 then + Move( Data^, FData[0], DataLen); +inherited Create( Lib1) +end; + + +destructor TReadOnlyBIO.Destroy; +begin +inherited; +SetLength( FData, 0) +end; + +function TReadOnlyBIO.InitBIO_Object: pBIO; +begin +if Length( FData) > 0 then + result := FLib.FOpenSSLProc_BIO_new_mem_buf( @FData[0], Length( FData)) + else + result := FLib.FOpenSSLProc_BIO_new_mem_buf( nil, 0) +end; + +{ TOpenSSL_Signatory } + +procedure TOpenSSL_Base.App_Shutdown; + + procedure GetAndCallOneIntParam( const ProcName: string; Value: integer); + type + TProc_OneIntParam = procedure( P1: longint); cdecl; + var + Proc: TProc_OneIntParam; + begin + if (FHandle = 0) or (ProcName = '') then exit; + @Proc := GetProcAddress( FHandle, PChar( ProcName)); + if assigned( Proc) then + Proc( Value) + end; + + procedure GetAndCallOnePtrParam( const ProcName: string; Value: pointer); + type + TProc_OnePntrParam = procedure( P1: pointer); cdecl; + var + Proc: TProc_OnePntrParam; + begin + if (FHandle = 0) or (ProcName = '') then exit; + @Proc := GetProcAddress( FHandle, PChar( ProcName)); + if assigned( Proc) then + Proc( Value) + end; + +begin +GetAndCallOneIntParam ( 'CONF_modules_unload', 1); +GetAndCallParameterless( 'OBJ_cleanup'); +GetAndCallParameterless( 'EVP_cleanup'); +GetAndCallParameterless( 'ENGINE_cleanup'); +GetAndCallParameterless( 'CRYPTO_cleanup_all_ex_data'); +GetAndCallOnePtrParam ( 'ERR_remove_thread_state', nil); +GetAndCallParameterless( 'ERR_free_strings') +end; + +procedure TOpenSSL_Base.App_Start; +begin +GetAndCallParameterless( 'ERR_load_crypto_strings'); +if FdoOPENSSL_LOAD_CONF then + GetAndCallParameterless( 'OPENSSL_add_all_algorithms_conf') + else + GetAndCallParameterless( 'OPENSSL_add_all_algorithms_noconf'); +GetAndCallParameterless( 'ENGINE_load_builtin_engines'); +Randomize +end; + +procedure TOpenSSL_Base.Clear; +begin +SetIsLoaded( False); +FhaveTriedToOpen := False +end; + + +procedure TOpenSSL_Base.ClearProcs; +begin +@FOpenSSLproc_BioSMem := nil; +@FOpenSSLproc_BioNew := nil; +@FOpenSSLproc_BioFree := nil; +@FOpenSSLproc_BioRead := nil; +//@FOpenSSLProc_setup_engine := nil; +@FOpenSSLProc_RAND_seed := nil; +@FOpenSSLProc_RAND_status := nil; +@FOpenSSLProc_RSA_new := nil; +//@FOpenSSLProc_RSA_new_method := nil; +@FOpenSSLProc_RSA_size := nil; +@FOpenSSLProc_RSA_free := nil; +@FOpenSSLProc_BN_set_word := nil; +@FOpenSSLProc_RSA_generate_key_ex := nil; +@FOpenSSLProc_BN_free := nil; +@FOpenSSLProc_BN_new := nil; +@FOpenSSLProc_ERR_get_err := nil; +@FOpenSSLProc_ERR_error_string_n := nil; +@FOpenSSLProc_BN_get_word := nil; +@FOpenSSLProc_RSA_up_ref := nil; +@FOpenSSLProc_PEM_write_bio_RSAPrivateKey := nil; +@FOpenSSLProc_PEM_write_bio_RSAPublicKey := nil; +@FOpenSSLProc_RSA_sign := nil; +@FOpenSSLProc_RSA_verify := nil; + +@FOpenSSLProc_RSA_print := nil; +@FOpenSSLProc_PEM_read_bio_RSAPrivateKey := nil; +@FOpenSSLProc_BIO_new_mem_buf := nil; +@FOpenSSLProc_PEM_read_bio_RSAPublicKey := nil; + +@FOpenSSLProc_EVP_des_ede3_cbc := nil; +@FOpenSSLProc_EVP_des_cbc := nil; +@FOpenSSLProc_EVP_idea_cbc := nil; +@FOpenSSLProc_EVP_seed_cbc := nil; +@FOpenSSLProc_EVP_aes_128_cbc := nil; +@FOpenSSLProc_EVP_aes_192_cbc := nil; +@FOpenSSLProc_EVP_aes_256_cbc := nil; +@FOpenSSLProc_EVP_aes_256_ofb := nil; +@FOpenSSLProc_EVP_camellia_128_cbc := nil; +@FOpenSSLProc_EVP_camellia_192_cbc := nil; +@FOpenSSLProc_EVP_camellia_256_cbc := nil; + +@FOpenSSLProc_EVP_CIPHER_CTX_init := nil; +@FOpenSSLProc_EVP_CIPHER_CTX_cleanup := nil; +@FOpenSSLProc_EVP_CipherInit_ex := nil; +@FOpenSSLProc_EVP_CIPHER_CTX_set_key_length := nil; +@FOpenSSLProc_EVP_CipherUpdate := nil; +@FOpenSSLProc_EVP_CipherFinal_ex := nil; +@FOpenSSLProc_EVP_CIPHER_CTX_set_padding := nil; + +end; + +procedure TOpenSSL_Base.CloseLib; +begin +if FHandle <> 0 then + begin + FhaveTriedToOpen := False; // Only count failed attempts to open. + OpenSSL_LibGate.Enter; + try + PreShutdown; + if isLibraryUniqueInstance then + App_Shutdown; + FreeLibrary( FHandle); + FHandle := 0; + ClearProcs; + if assigned( OpenSSL_Libs) and (OpenSSL_Libs.IndexOf( self) <> -1) then + OpenSSL_Libs.Remove( self); + if assigned( OpenSSL_Libs) and (OpenSSL_Libs.Count = 0) then + FreeAndNil( OpenSSL_Libs) + finally + OpenSSL_LibGate.Leave + end + end; +FCachedSize := -1; +FFileName := ''; +FErr := erNull; +FWindowsError := 0; +FErrMsg := ''; +FMajorV := 0; +FMinorV := 0; +FReleaseV := 0; +FBuildV := 0 +end; + + + +procedure TOpenSSL_Signatory.CloseRSA; + + procedure ReleaseBigNumDataMember( var n: PBIGNUM); + begin + if assigned( n) and assigned( FOpenSSLProc_BN_free) then + begin + FOpenSSLProc_BN_free( n); + n := nil + end; + end; + +begin +FKeyStorageParts := []; +if assigned( FOpenSSLProc_RSA_free) and assigned( FRSA) then + begin + ReleaseBigNumDataMember( FRSA^.n); + ReleaseBigNumDataMember( FRSA^.e); + ReleaseBigNumDataMember( FRSA^.d); + ReleaseBigNumDataMember( FRSA^.p); + ReleaseBigNumDataMember( FRSA^.q); + ReleaseBigNumDataMember( FRSA^.dmp1); + ReleaseBigNumDataMember( FRSA^.dmq1); + ReleaseBigNumDataMember( FRSA^.iqmp); + if FisSafeToFreeRSA then + try + FOpenSSLProc_RSA_free( FRSA) + except + FisSafeToFreeRSA := False + end; + FRSA := nil + end +end; + +constructor TOpenSSL_Base.Create( AOwner: TComponent); +begin +inherited Create( AOwner); +FHandle := 0; +FLibPath := ''; +FLibName := LibEay; +FFileName := ''; +FDLLDir := ''; +FRqrMajorV := 1; +FRqrMinorV := 0; +FRqrReleaseV := 0; +FRqrBuildV := 0; +FErr := erNull; +FWindowsError := 0; +FErrMsg := ''; +FMajorV := 0; +FMinorV := 0; +FReleaseV := 0; +FBuildV := 0; +FhaveTriedToOpen := False; +FdoOPENSSL_LOAD_CONF := False; +FisSafeToFreeRSA := False; +FCachedSize := -1; +ClearProcs; +FPassword := ''; +FStoragePassword := ''; +end; + +destructor TOpenSSL_Base.Destroy; +begin +Clear; +inherited +end; + + + +constructor TOpenSSL_Signatory.Create( AOwner: TComponent); +begin +inherited Create( AOwner); +FAsymetricKeySizeInBits := Default_AsymetricKeySizeInBits; +FRSA := nil; +FStorageCipher := cipher_InTheClear; +FKeyStorageParts := [] +end; + +function TOpenSSL_Signatory.GenerateKeys: boolean; + var ErrorCode: integer; + var ErrorMsg: string; +begin +GenRSA( FAsymetricKeySizeInBits, ErrorCode, ErrorMsg); +result := ErrorMsg = ''; +if not result then + FErrMsg := ErrorMsg +end; + + +procedure TOpenSSL_Signatory.GenRSA( + KeySizeInBits: integer; + var ErrorCode: integer; var ErrorMsg: string); +var + bn: PBIGNUM; + Ok: boolean; + cb: BN_GENCB; +{$IFDEF HuntingMemoryLeaks} + StartMemory, Leakage: int64; +{$ENDIF} +// UserAborted: boolean; + +begin +{$IFDEF HuntingMemoryLeaks} +StartMemory := Allocated; +{$ENDIF} +try +ErrorCode := 0; +//UserAborted := False; +CloseRSA; +FisSafeToFreeRSA := True; +ErrorMsg := '(Error) TOpenSSL_Signatory not loaded.'; +if not assigned( FOpenSSLProc_RSA_new) then exit; +ErrorMsg := ''; +FRSA := FOpenSSLProc_RSA_new; +bn := FOpenSSLProc_BN_new; +try + Ok := FOpenSSLProc_BN_set_word( bn, RSA_F4) = 1; + cb.ver := 2; + cb.arg := pointer( self); + @cb.cb_2 := @cb_2_SpringBoard; + if Ok then + begin + Ok := FOpenSSLProc_RSA_generate_key_ex( FRSA, KeySizeInBits, bn, @cb) = 1; + if Ok then + begin + FCachedSize := KeySizeInBits; + FKeyStorageParts := [partPublic, partPrivate] + end + else + GetError( ErrorCode, ErrorMsg) + end; +finally + if assigned( bn) then + FOpenSSLProc_BN_free( bn); + end; +// UserAborted := ErrorCode = $04081003; // = 67637251 + +finally +FisSafeToFreeRSA := False +end; +{$IFDEF HuntingMemoryLeaks} +Leakage := Allocated - StartMemory; +{$ENDIF} +end; + + +procedure TOpenSSL_Base.GetAndCallParameterless( const ProcName: string); +type + TProc_NoParams = procedure; cdecl; +var + Proc: TProc_NoParams; +begin +if (FHandle = 0) or (ProcName = '') then exit; +@Proc := GetProcAddress( FHandle, PChar( ProcName)); +if assigned( Proc) then + Proc +end; + + + +procedure TOpenSSL_Base.GetError( + var ErrorCode: integer; var ErrorMsg: string); +var + aErrorMsg: ansistring; +begin +ErrorCode := 0; +if not assigned( FOpenSSLProc_ERR_get_err) then + begin + ErrorCode := -1; + ErrorMsg := 'TOpenSSL_Lib not loaded.' + end + else + begin + aErrorMsg := ''; + ErrorCode := FOpenSSLProc_ERR_get_err; + if ErrorCode <> 0 then + begin + SetLength( aErrorMsg, 500); + FOpenSSLProc_ERR_error_string_n( ErrorCode, PAnsiChar( aErrorMsg), Length( aErrorMsg)); + SetLength( aErrorMsg, StrLen( PAnsiChar( aErrorMsg))) + end; + ErrorMsg := aErrorMsg // Coerce system code page ansi into utf16 + end; +end; + + + +function TOpenSSL_Base.GetEVP( + Cipher: TCipherToEncryptPrivateKeyWith): PEVP_CIPHER; +var + Func: TOpenSLL_CipherFunc; + +begin +case Cipher of + cipher_InTheClear : begin + result := nil; + exit; + end; + cipher_des_ede3_cbc : @Func := @FOpenSSLProc_EVP_des_ede3_cbc; + cipher_des_cbc : @Func := @FOpenSSLProc_EVP_des_cbc; + cipher_idea_cbc : @Func := @FOpenSSLProc_EVP_idea_cbc; + cipher_seed_cbc : @Func := @FOpenSSLProc_EVP_seed_cbc; + cipher_aes_128_cbc : @Func := @FOpenSSLProc_EVP_aes_128_cbc; + cipher_aes_192_cbc : @Func := @FOpenSSLProc_EVP_aes_192_cbc; + cipher_aes_256_cbc : @Func := @FOpenSSLProc_EVP_aes_256_cbc; + cipher_aes_256_ofb : @Func := @FOpenSSLProc_EVP_aes_256_ofb; + cipher_camellia_128_cbc : @Func := @FOpenSSLProc_EVP_camellia_128_cbc; + cipher_camellia_192_cbc : @Func := @FOpenSSLProc_EVP_camellia_192_cbc; + cipher_camellia_256_cbc : @Func := @FOpenSSLProc_EVP_camellia_256_cbc; + end; +if assigned( Func) then + result := Func // This is a function call. + else + result := nil +end; + + + +function TOpenSSL_Base.GetIsLoaded: boolean; +begin +result := FHandle <> 0 +end; + + +procedure TOpenSSL_Base.GetProcs; + + function ProcAddress( const ProcName: string): pointer; + begin + result := GetProcAddress( FHandle, PChar( ProcName)) + end; + +begin +ClearProcs; +if FHandle = 0 then exit; +@FOpenSSLproc_BioSMem := ProcAddress( 'BIO_s_mem'); +@FOpenSSLproc_BioNew := ProcAddress( 'BIO_new'); +@FOpenSSLproc_BioFree := ProcAddress( 'BIO_free'); +@FOpenSSLproc_BioRead := ProcAddress( 'BIO_read'); +//@FOpenSSLProc_setup_engine := ProcAddress( 'setup_engine'); +@FOpenSSLProc_RAND_seed := ProcAddress( 'RAND_seed'); +@FOpenSSLProc_RAND_status := ProcAddress( 'RAND_status'); +@FOpenSSLProc_RSA_new := ProcAddress( 'RSA_new'); +//@FOpenSSLProc_RSA_new_method := ProcAddress( 'RSA_new_method'); +@FOpenSSLProc_RSA_size := ProcAddress( 'RSA_size'); +@FOpenSSLProc_RSA_free := ProcAddress( 'RSA_free'); +@FOpenSSLProc_BN_set_word := ProcAddress( 'BN_set_word'); +@FOpenSSLProc_RSA_generate_key_ex := ProcAddress( 'RSA_generate_key_ex'); +@FOpenSSLProc_BN_free := ProcAddress( 'BN_free'); +@FOpenSSLProc_BN_new := ProcAddress( 'BN_new'); +@FOpenSSLProc_ERR_get_err := ProcAddress( 'ERR_get_error'); +@FOpenSSLProc_ERR_error_string_n := ProcAddress( 'ERR_error_string_n'); +@FOpenSSLProc_BN_get_word := ProcAddress('BN_get_word'); +@FOpenSSLProc_RSA_up_ref := ProcAddress( 'RSA_up_ref'); +@FOpenSSLProc_PEM_write_bio_RSAPrivateKey := ProcAddress( 'PEM_write_bio_RSAPrivateKey'); +@FOpenSSLProc_PEM_write_bio_RSAPublicKey := ProcAddress( 'PEM_write_bio_RSAPublicKey'); +@FOpenSSLProc_RSA_sign := ProcAddress( 'RSA_sign'); +@FOpenSSLProc_RSA_verify := ProcAddress( 'RSA_verify'); + +@FOpenSSLProc_RSA_print := ProcAddress( 'RSA_print'); +@FOpenSSLProc_PEM_read_bio_RSAPrivateKey := ProcAddress( 'PEM_read_bio_RSAPrivateKey'); +@FOpenSSLProc_BIO_new_mem_buf := ProcAddress( 'BIO_new_mem_buf'); +@FOpenSSLProc_PEM_read_bio_RSAPublicKey := ProcAddress( 'PEM_read_bio_RSAPublicKey'); + +@FOpenSSLProc_EVP_des_ede3_cbc := ProcAddress( 'EVP_des_ede3_cbc'); +@FOpenSSLProc_EVP_des_cbc := ProcAddress( 'EVP_des_cbc'); +@FOpenSSLProc_EVP_idea_cbc := ProcAddress( 'EVP_idea_cbc'); +@FOpenSSLProc_EVP_seed_cbc := ProcAddress( 'EVP_seed_cbc'); +@FOpenSSLProc_EVP_aes_128_cbc := ProcAddress( 'EVP_aes_128_cbc'); +@FOpenSSLProc_EVP_aes_192_cbc := ProcAddress( 'EVP_aes_192_cbc'); +@FOpenSSLProc_EVP_aes_256_cbc := ProcAddress( 'EVP_aes_256_cbc'); +@FOpenSSLProc_EVP_aes_256_ofb := ProcAddress( 'EVP_aes_256_ofb'); +@FOpenSSLProc_EVP_camellia_128_cbc := ProcAddress( 'EVP_camellia_128_cbc'); +@FOpenSSLProc_EVP_camellia_192_cbc := ProcAddress( 'EVP_camellia_192_cbc'); +@FOpenSSLProc_EVP_camellia_256_cbc := ProcAddress( 'EVP_camellia_256_cbc'); + +@FOpenSSLProc_EVP_CIPHER_CTX_init := ProcAddress( 'EVP_CIPHER_CTX_init'); +@FOpenSSLProc_EVP_CIPHER_CTX_cleanup := ProcAddress( 'EVP_CIPHER_CTX_cleanup'); +@FOpenSSLProc_EVP_CipherInit_ex := ProcAddress( 'EVP_CipherInit_ex'); +@FOpenSSLProc_EVP_CIPHER_CTX_set_key_length := ProcAddress( 'EVP_CIPHER_CTX_set_key_length'); +@FOpenSSLProc_EVP_CipherUpdate := ProcAddress( 'EVP_CipherUpdate'); +@FOpenSSLProc_EVP_CipherFinal_ex := ProcAddress( 'EVP_CipherFinal_ex'); +@FOpenSSLProc_EVP_CIPHER_CTX_set_padding := ProcAddress( 'EVP_CIPHER_CTX_set_padding'); + +end; + +function TOpenSSL_Base.GetRequiredVersionStr: string; +begin +result := Format( '%d.%d.%d.%d', + [FRqrMajorV, FRqrMinorV, FRqrReleaseV, FRqrBuildV]) +end; + + + +function TOpenSSL_Base.isLibraryUniqueInstance: boolean; +var + j: integer; + OpenSSL_Lib: TOpenSSL_Base; + +begin +result := True; +if FHandle = 0 then exit; +OpenSSL_LibGate.Enter; +try + for j := 0 to OpenSSL_Libs.Count - 1 do + begin + OpenSSL_Lib := OpenSSL_Libs[j] as TOpenSSL_Base; + result := (OpenSSL_Lib = self) or + (OpenSSL_Lib.FHandle = 0) or + (OpenSSL_Lib.FHandle <> FHandle); + if not result then break + end +finally + OpenSSL_LibGate.Leave + end +end; + + + +function TOpenSSL_Signatory.HasParts: TKeyStoragePartSet; +begin +if assigned( FRSA) then + result := FKeyStorageParts + else + result := [] +end; + + +function ReadString( Source: TStream; const TerminatingPattern: utf8string): utf8string; +var + Ch: ansichar; + s: utf8string; + FoundMatch: boolean; + ReadCount: integer; + L: integer; +begin +Ch := #0; +s := ''; +ReadCount := 0; +FoundMatch := False; +L := Length( TerminatingPattern); +if L = 0 then exit; +while (not FoundMatch) and (Source.Read( Ch, 1) = 1) do + begin + Inc( ReadCount); + if Length( s) = L then + begin + Move( s[2], s[1], L - 1); + s[ L] := Ch + end + else + s := s + Ch; + FoundMatch := s = TerminatingPattern + end; +if FoundMatch then + begin + SetLength( result, ReadCount); + if ReadCount > 0 then + begin + Source.Seek( -ReadCount, soCurrent); + if Source.Read( result[1], ReadCount) <> ReadCount then + result := '(Error) Streaming error.' + end + end + else + result := '' +end; + + + +procedure TOpenSSL_Signatory.LoadRSA_PrivateKey( + var ErrorMessage: string; + Cipher: TCipherToEncryptPrivateKeyWith; const sPrivateKey, + Password: utf8string); +var + bp: TBIO; + cb: BN_GENCB; + Code: integer; + isException: boolean; +begin +ErrorMessage := ''; +CloseRSA; +if assigned( FOpenSSLProc_PEM_read_bio_RSAPrivateKey) and (sPrivateKey <> '') then + begin + FPassword := Password; + if (FPassword = '') and (Cipher <> cipher_InTheClear) then + ErrorMessage := 'A non-empty password is required.'; + if (FPassword <> '') and (Cipher = cipher_InTheClear) then + FPassword := ''; + + if ErrorMessage <> '' then exit; + + cb.ver := 2; + cb.arg := pointer( self); + @cb.cb_2 := @cb_2_SpringBoard; + isException := False; + bp := TReadOnlyBIO.Create( self, @sPrivateKey[1], Length( sPrivateKey)); + try + try + if FPassword <> '' then + // The below line was contributed to user Trupka of the LockBox website. + // Thanks Trupka. + FRSA := FOpenSSLProc_PEM_read_bio_RSAPrivateKey( bp.FBIOobj, nil, @pem_password_cb_SpringBoard, Pointer(Self)) + else + FRSA := FOpenSSLProc_PEM_read_bio_RSAPrivateKey( bp.FBIOobj, nil, nil, nil) + finally + bp.Free; + FPassword := '' + end + except on e: Exception do + begin + isException := True; + FRSA := nil; + ErrorMessage := e.Message + end; + end; + if (not assigned( FRSA)) and (not isException) then + GetError( Code, ErrorMessage); + if assigned( FRSA) and (ErrorMessage = '') and (not SignVerify_SelfTest) then + ErrorMessage := '(Error) TOpenSSL_Signatory.LoadRSA_PrivateKey failed self-test.' + end + else if assigned( FOpenSSLProc_PEM_read_bio_RSAPrivateKey) then + ErrorMessage := '(Error) Private key file corrupt, empty or the wrong type.' + else + ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.'; + +if ErrorMessage = '' then + FKeyStorageParts := [partPublic, partPrivate] +end; + + + +procedure TOpenSSL_Signatory.LoadRSA_PublicKey( + var ErrorMessage: string; const sPublicKey: utf8string); +var + bp: TBIO; + isException: boolean; + Code: integer; +begin +ErrorMessage := ''; +CloseRSA; + +if assigned( FOpenSSLProc_PEM_read_bio_RSAPublicKey) and (sPublicKey <> '') then + begin + isException := False; + bp := TReadOnlyBIO.Create( self, @sPublicKey[1], Length( sPublicKey)); + try + try + FRSA := FOpenSSLProc_PEM_read_bio_RSAPublicKey( bp.FBIOobj, nil, nil, nil) + finally + bp.Free; + end + except on e: Exception do + begin + isException := True; + FRSA := nil; + ErrorMessage := e.Message + end; + end; + if (not assigned( FRSA)) and (not isException) then + GetError( Code, ErrorMessage) + end + else if assigned( FOpenSSLProc_PEM_read_bio_RSAPublicKey) then + ErrorMessage := '(Error) Public key file corrupt, empty or the wrong type.' + else + ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.'; + +if ErrorMessage = '' then + FKeyStorageParts := [partPublic] +end; + + + +//function TOpenSSL_Signatory.NewMemoryBio: TMemoryBIO; +//begin +//if FHandle = 0 then +// result := nil +// else +// result := TMemoryBIO.Create( self) +//end; + + + +procedure TOpenSSL_Base.OpenLib; +begin +OpenSSL_LibGate.Enter; +try +CloseLib; +if TryOpen( + FLibPath, FLibName, FDLLDir, + FRqrMajorV, FRqrMinorV, FRqrReleaseV, FRqrBuildV, + 'RSA_generate_key_ex', + FErr, FHandle, FWindowsError, FFileName, FErrMsg, + FMajorV, FMinorV, FReleaseV, FBuildV) then + begin + GetProcs; + if not assigned( OpenSSL_Libs) then + OpenSSL_Libs := TObjectList{$IFDEF GENERICS}{$ENDIF}.Create( False); + if OpenSSL_Libs.IndexOf( self) = -1 then + OpenSSL_Libs.Add( self); + if isLibraryUniqueInstance then + begin + SetMemoryManager; + App_Start + end + end; +finally +OpenSSL_LibGate.Leave +end end; + + + + +function TOpenSSL_Base.OpenSSL_CallBack( p1, p2: integer): integer; +begin +if (not assigned( FOnProgress)) or FOnProgress( self, p1, p2) then + result := 1 + else + result := 0 +end; + + +procedure TOpenSSL_Base.PreShutdown; +begin +end; + +function TOpenSSL_Signatory.PEM_Password_CallBack( + buf: PAnsistring; size, rwflag: longint): longint; +begin +// rwflag is 0 when reading and 1 when writing. +result := Length( FPassword); +if result > size then + result := size; +if result > 0 then + Move( FPassword[1], buf^, result) +end; + + +function TOpenSSL_Signatory.GetPublicKey_AsPEM: utf8string; +var + PublicKeyBIO: TBIO; +begin +if assigned( FOpenSSLProc_PEM_write_bio_RSAPublicKey) and + assigned( FRSA) and (partPublic in FKeyStorageParts) then + begin + PublicKeyBIO := TMemoryBIO.Create( self); + try + FOpenSSLProc_PEM_write_bio_RSAPublicKey( PublicKeyBIO.FBIOobj, FRSA); + result := PublicKeyBIO.ReadAnsiString + finally + PublicKeyBIO.Free + end + end + else + result := '(Error)' +end; + + + +procedure TOpenSSL_Signatory.PreShutdown; +begin +inherited; +CloseRSA +end; + +function TOpenSSL_Signatory.Print: string; +var + BIO: TBIO; + ErrorCode: integer; +begin +if assigned( FOpenSSLProc_RSA_print) and assigned( FRSA) then + begin + BIO := TMemoryBIO.Create( self); + try + if FOpenSSLProc_RSA_print( BIO.FBIOobj, FRSA, 0) = 1 then + result := BIO.ReadAnsiString // Coerce system code page ansi into utf16 + else + GetError( ErrorCode, result) + finally + BIO.Free + end + end + else + result := '(Error) TOpenSSL_Signatory not loaded.' +end; + + + +function TOpenSSL_Signatory.PrivateKey_AsPEM( + Cipher: TCipherToEncryptPrivateKeyWith; + const Password: utf8string): utf8string; +var + Ok: boolean; + PrivateKeyBIO: TBIO; + enc: PEVP_CIPHER; + ErrorCode: integer; + sResult: string; +begin +result := ''; +if assigned( FOpenSSLProc_PEM_write_bio_RSAPrivateKey) and + assigned( FRSA) and assigned( FOpenSSLProc_EVP_des_ede3_cbc) then + begin + FPassword := Password; + if (FPassword = '') and (Cipher <> cipher_InTheClear) then + result := '(Error) A non-empty password is required.'; + if (FPassword <> '') and (Cipher = cipher_InTheClear) then + FPassword := ''; + enc := GetEVP( Cipher); + if (not assigned( enc)) and (Cipher <> cipher_InTheClear) then + result := '(Error) Encryption function not found in OpenSSL'; + if result <> '' then exit; + + PrivateKeyBIO := TMemoryBIO.Create( self); + if FPassword <> '' then + Ok := FOpenSSLProc_PEM_write_bio_RSAPrivateKey( + PrivateKeyBIO.FBIOobj, FRSA, + enc, nil, 0, pem_password_cb_SpringBoard, pointer( self)) = 1 + else + Ok := FOpenSSLProc_PEM_write_bio_RSAPrivateKey( + PrivateKeyBIO.FBIOobj, FRSA, + nil, nil, 0, nil, nil) = 1; + FPassword := ''; + if Ok then + result := PrivateKeyBIO.ReadAnsiString + else + begin + GetError( ErrorCode, sResult); + result := '(Error) ' + sResult + end; + PrivateKeyBIO.Free + end +else +result := '(Error) TOpenSSL_Signatory not loaded.'; +end; + + + + +procedure TOpenSSL_Signatory.Randomize; +var + Buffer: TBytes; + L, RandStatus, j: integer; +begin +if not assigned( FOpenSSLProc_RAND_seed) or + not assigned( FOpenSSLProc_RAND_status) then exit; +L := 1000; +SetLength( Buffer, L); +for j := 1 to 100 do + begin + TRandomStream.Instance.Read( Buffer[0], L); + FOpenSSLProc_RAND_seed( @Buffer[0], L); + RandStatus := FOpenSSLProc_RAND_status; + if RandStatus = 1 then break + end; +end; + + +//procedure TOpenSSL_Signatory.RSA_IncRef; +//begin +//if assigned( FRSA) and assigned( FOpenSSLProc_RSA_up_ref) then +// FOpenSSLProc_RSA_up_ref( FRSA) +//end; + +const TypeNumbers: array[ TSigHashKind] of longint = ( + { hshSHA1 ==> } 64, + { hshRipemd160 ==> } 117, + { hshMD5 ==> } 4); + +procedure TOpenSSL_Signatory.RSA_Sign( + PreHash: TSigHashKind; Message1: pointer; + MessageLen: cardinal; var Signature: utf8string; + var ErrorMessage: string); +var + SigLen: longword; + ErrorCode: integer; +begin +Signature := ''; +ErrorMessage := ''; +if assigned( FOpenSSLProc_RSA_sign) and assigned( FRSA) then + begin + if FCachedSize = -1 then + FCachedSize := RSA_Size; + SigLen := (FCachedSize + 7) div 8; + if SigLen < 2048 then + SigLen := 2048; + SetLength( Signature, SigLen); + if FOpenSSLProc_RSA_sign( TypeNumbers[PreHash], Message1, MessageLen, + PAnsiChar( Signature), SigLen, FRSA) = 1 then + SetLength( Signature, SigLen) + else + begin + Signature := ''; + GetError( ErrorCode, ErrorMessage) + end; + end + else + ErrorMessage := '(Error) TOpenSSL_Signatory not loaded.' +end; + + + +function TOpenSSL_Signatory.RSA_Size: integer; +var + s, Prefix: string; + P, V, Code: integer; +begin +result := 0; +if not assigned( FRSA) then exit; + +result := FCachedSize; +if result <> -1 then exit; + +result := 0; +if not assigned( FRSA^.n) then + begin + if assigned( FRSA^.d) and assigned( FRSA^.e) then + begin + s := Print; + // 1st line of Print = 'Private-Key: (2048 bit)' + Prefix := 'Private-Key: ('; + P := Pos( Prefix, s); + if P > 0 then + Delete( s, 1, P + Length(Prefix) - 1); + P := Pos(' bit)',s); + if P > 0 then + SetLength( s, P - 1); + s := Trim( s); + Val( s, V, Code); + if (s <> '') and (Code = 0) and (V > 0) then + result := V + end + end + else + try + if assigned( FOpenSSLProc_RSA_size) then + result := FOpenSSLProc_RSA_size( FRSA) + except + result := 0 + end; + +if result <> 0 then + FCachedSize := result +end; + + + +function TOpenSSL_Signatory.RSA_Verify( + PreHash: TSigHashKind; Message1: pointer; + MessageLen: cardinal; const Signature: utf8string): boolean; +begin +if assigned( FOpenSSLProc_RSA_verify) and assigned( FRSA) then + result := FOpenSSLProc_RSA_verify( + TypeNumbers[PreHash], Message1, MessageLen, + PAnsiChar( Signature), Length( Signature), FRSA) = 1 + else + result := False +end; + + +procedure TOpenSSL_Base.SetDLLDir( const Value: string); +begin +if FDLLDir = Value then exit; +Assert( not GetIsLoaded, '(Error) Do not set SupportDLLDir while the library is loaded.'); +FDLLDir := Value +end; + + +procedure TOpenSSL_Base.SetIsLoaded( Value: boolean); +begin +if (FHandle <> 0) = Value then exit; +if Value then + begin + if not FhaveTriedToOpen then + begin + FhaveTriedToOpen := True; + OpenLib + end; + end + else + CloseLib +end; + + +procedure TOpenSSL_Base.SetLibName( const Value: string); +var + sCanonicalValue: string; +begin +sCanonicalValue := Value; +if sCanonicalValue = '' then + sCanonicalValue := LibEay; +if FLibName = sCanonicalValue then exit; +Assert( not GetIsLoaded, 'Do not set LibName while the library is loaded.'); +FLibName := sCanonicalValue +end; + +procedure TOpenSSL_Base.SetLibPath(const Value: string); +begin +if FLibName = Value then exit; +Assert( not GetIsLoaded, 'Do not set LibPath while the library is loaded.'); +FLibPath := Value +end; + + +type + TOpenSSLproc_Malloc = function( Size: longword) : Pointer; cdecl; + +function Delphi_Malloc( Size: longword): pointer cdecl; +begin +{$IFDEF HuntingMemoryLeaks} +result := AllocMem( Size + 4); +plongword( result)^ := Size; +result := pointer( cardinal( result) + 4); +Allocated := Allocated + Size +{$ELSE} +result := AllocMem( Size) +{$ENDIF} +end; + + +type + TOpenSSLproc_Realloc = function( Ptr: pointer; Size: longword): pointer; cdecl; + +function Delphi_Realloc( Ptr: pointer; Size: longword): pointer cdecl; +{$IFDEF HuntingMemoryLeaks} +var + OldSize: longword; +begin +result := pointer( cardinal( Ptr) - 4); +OldSize := plongword( result)^; +ReallocMem( result, Size); +plongword( result)^ := Size; +result := pointer( cardinal( result) + 4); +Allocated := Allocated - OldSize + Size +end; +{$ELSE} +begin +result := Ptr; +ReallocMem( result, Size); +end; +{$ENDIF} + +type + TOpenSSLproc_Free = procedure( Ptr: pointer); cdecl; + +procedure Delphi_Free( Ptr: pointer) cdecl; +{$IFDEF HuntingMemoryLeaks} +var + RealPtr: pointer; + OldSize: longword; +begin +RealPtr := pointer( cardinal( Ptr) - 4); +OldSize := plongword( RealPtr)^; +FreeMem( RealPtr); +Allocated := Allocated - OldSize +end; +{$ELSE} +begin +FreeMem( Ptr) +end; +{$ENDIF} + +procedure TOpenSSL_Base.SetMemoryManager; +var + openSSLproc_CRYPTO_set_mem_functions : function( + m: TOpenSSLproc_Malloc; + r: TOpenSSLproc_Realloc; + f: TOpenSSLproc_Free): longint cdecl; +begin +@openSSLproc_CRYPTO_set_mem_functions := GetProcAddress( FHandle, 'CRYPTO_set_mem_functions'); +if assigned( openSSLproc_CRYPTO_set_mem_functions) then + openSSLproc_CRYPTO_set_mem_functions( + @Delphi_Malloc, @Delphi_Realloc, @Delphi_Free) +end; + +procedure TOpenSSL_Base.SetRequiredVersionStr( const Value: string); +var + s: string; + isOk1: boolean; + isEmpty1: boolean; + RqrMajorV1, RqrMinorV1, RqrReleaseV1, RqrBuildV1: integer; + + procedure ExtractNumberBeforeDot( + var sDotSeparatedNumbers: string; + var FirstNumber: integer; + var isOk: boolean; + var isEmpty: boolean); + + var + P: integer; + sVal: string; + Code: integer; + begin + P := Pos( '.', sDotSeparatedNumbers); + if P > 0 then + begin + sVal := Copy( sDotSeparatedNumbers, 1, P - 1); + Delete( sDotSeparatedNumbers, 1, P) + end + else + begin + sVal := sDotSeparatedNumbers; + sDotSeparatedNumbers := '' + end; + isEmpty := sVal = ''; + if isEmpty then + begin + FirstNumber := 0; + isOk := True + end + else + begin + Val( sVal, FirstNumber, Code); + isOk := Code = 0; + if not isOk then + FirstNumber := 0 + end; + if isOk and (FirstNumber < 0) then + begin + isOk := False; + FirstNumber := 0 + end + end; + +begin +s := Trim( Value); +RqrMajorV1 := 0; +RqrMinorV1 := 0; +RqrReleaseV1 := 0; +RqrBuildV1 := 0; +ExtractNumberBeforeDot( s, RqrMajorV1, isOk1, isEmpty1); + +if isOk1 and (not isEmpty1) and (s <> '') then + ExtractNumberBeforeDot( s, RqrMinorV1, isOk1, isEmpty1); + +if isOk1 and (not isEmpty1) and (s <> '') then + ExtractNumberBeforeDot( s, RqrReleaseV1, isOk1, isEmpty1); + +if isOk1 and (not isEmpty1) and (s <> '') then + ExtractNumberBeforeDot( s, RqrBuildV1, isOk1, isEmpty1); + +if isOk1 and (s <> '') then + isOk1 := False; + +if not isOk1 then + raise Exception.CreateFmt('"%s" is invalid format for ' + + 'TOpenSSL_Lib.RequiredVersion',[Trim(Value)]); + +if (FRqrMajorV = RqrMajorV1 ) and + (FRqrMinorV = RqrMinorV1 ) and + (FRqrReleaseV = RqrReleaseV1) and + (FRqrBuildV = RqrBuildV1 ) then + exit; + +Assert( not GetIsLoaded, 'Do not set RequiredVersion while the library is loaded.'); + +FRqrMajorV := RqrMajorV1; +FRqrMinorV := RqrMinorV1; +FRqrReleaseV := RqrReleaseV1; +FRqrBuildV := RqrBuildV1 +end; + + + +function TOpenSSL_Signatory.SignVerify_SelfTest: boolean; +var + TestMessage, Signature: utf8string; + ErrorMsg: string; + Idx: TSigHashKind; +begin +TestMessage := 'Hello worldHello worldHello worldHello worldHello'; +SetLength( TestMessage, 20); +for Idx := Low( TSigHashKind) to High( TSigHashKind) do + begin + RSA_Sign( Idx, @TestMessage[1], Length( TestMessage), Signature, ErrorMsg); + result := (ErrorMsg = '') and + RSA_Verify( Idx, @TestMessage[1], Length( TestMessage), Signature); + if not result then break + end; +end; + +{$IF CompilerVersion < 21} + {$IFDEF UNICODE} + function SetDllDirectory( lpPathName: PWideChar): BOOL; + stdcall; external kernel32 name 'SetDllDirectoryW'; + {$ELSE} + function SetDllDirectory( lpPathName: PAnsiChar): BOOL; + stdcall; external kernel32 name 'SetDllDirectoryA'; + {$ENDIF} +{$IFEND} + +function TOpenSSL_Base.TryOpen( const LibPath, LibName, DLLDir: string; + RqrMajorV, RqrMinorV, RqrReleaseV, RqrBuildV: integer; + const RqrSignatureProc: string; var Err: TOpenLibError; var Handle: HMODULE; + var WindowsError: DWORD; var FileName, ErrMsg: string; var MajorV, MinorV, + ReleaseV, BuildV: integer): boolean; +{$IFDEF MSWINDOWS} +var + iLibSize, iValueSize: DWord; + Buf: ansiString; + Ok: boolean; + fvip: pointer; +{$ENDIF} +begin +Err := erNull; +Handle := 0; +WindowsError := 0; +FileName := LibName; +if LibPath <> '' then + FileName := IncludeTrailingPathDelimiter( LibPath) + FileName; +ErrMsg := ''; +MajorV := 0; +MinorV := 0; +ReleaseV := 0; +BuildV := 0; +{$IF Defined(WIN64)} + {$IF Defined(OpenSSL_Win64_NotYetSupported)} + result := False; + Err := erPlatformNotSupported; + ErrMsg := 'Win64 platform not yet supported by TOpenSSL_Signatory.'; + exit; + {$IFEND} +{$ELSEIF not Defined(WIN32)} + result := False; + Err := erPlatformNotSupported; + ErrMsg := 'This platform not supported by TOpenSSL_Signatory.'; + exit; +{$IFEND} + +{$IFDEF MSWINDOWS} +if (DLLDir <> '') and (not SetDllDirectory( PChar( DLLDir))) then + begin + Err := erSetDLLDirectory; + WindowsError := GetLastError; + end; +if Err = erNull then + try + Handle := SysUtils.safeloadlibrary( FileName, SEM_FAILCRITICALERRORS + + SEM_NOGPFAULTERRORBOX + + SEM_NOOPENFILEERRORBOX); + if Handle = 0 then + begin + Err := erLoadFailed; + WindowsError := GetLastError + end; + except on e: exception do + begin + Err := erException; + Handle := 0; + ErrMsg := Format( '%s: %s', [e.ClassName, e.Message]) + end; + end; +if (DLLDir <> '') and (Err <> erSetDLLDirectory) then + SetDllDirectory(nil); +if Handle <> 0 then + FileName := sysutils.GetModuleName( Handle); +if (Err in [erSetDLLDirectory, erLoadFailed]) and (WindowsError <> 0) then + ErrMsg := SysUtils.SysErrorMessage( WindowsError); +result := Err = erNull; + +if result then + begin + iLibSize := GetFileVersionInfoSize( PChar( FileName), iLibSize); + Ok := iLibSize > 0; + if Ok then + begin + SetLength( Buf, iLibSize); + Ok := GetFileVersionInfo( PChar( FileName), 0, iLibSize, PAnsiChar( Buf)) and + VerQueryValue( PAnsiChar( Buf), '\', fvip, iValueSize) and + (iValueSize >= SizeOf( TVSFixedFileInfo)) + end; + if Ok then + begin + MajorV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); + MinorV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionMS); + ReleaseV := HiWord( TVSFixedFileInfo( fvip^).dwFileVersionLS); + BuildV := LoWord( TVSFixedFileInfo( fvip^).dwFileVersionLS) + end + end; +if result and ( + (MajorV < RqrMajorV) or + ((MajorV = RqrMajorV) and (MinorV < RqrMinorV)) or + ((MajorV = RqrMajorV) and (MinorV = RqrMinorV) and (ReleaseV < RqrReleaseV)) or + ((MajorV = RqrMajorV) and (MinorV = RqrMinorV) and (ReleaseV < RqrReleaseV) and (BuildV < RqrBuildV))) then + begin + Err := erVersionTooLow; + result := False + end; + +if result and (RqrSignatureProc <> '') and (not assigned( + windows.GetProcAddress( Handle, PChar( RqrSignatureProc)))) then + begin + Err := erSignatureAbsent; + result := False + end; + +if (Err in [erVersionTooLow, erSignatureAbsent]) and (Handle <> 0) then + begin + FreeLibrary( Handle); + Handle := 0 + end; +{$ENDIF} +end; + +procedure TOpenSSL_Signatory.StoreKeysToStream( + Store: TStream; Parts: TKeyStoragePartSet); +var + sPrivateKey, sPublicKey: utf8string; + +begin +if partPrivate in Parts then + begin + sPrivateKey := PrivateKey_AsPEM( FStorageCipher, FStoragePassword); + if Pos( '(Error) ', sPrivateKey) > 0 then + begin + FErrMsg := sPrivateKey; + raise Exception.Create( FErrMsg) + end; + if sPrivateKey <> '' then + Store.Write( sPrivateKey[1], Length( sPrivateKey)) + end + + else if partPublic in Parts then + begin + sPublicKey := PublicKey; + if Pos( '(Error) ', sPublicKey) > 0 then + begin + FErrMsg := sPublicKey; + raise Exception.Create( FErrMsg) + end; + if sPublicKey <> '' then + Store.Write( sPublicKey[1], Length( sPublicKey)) + end + + else begin end +end; + +procedure TOpenSSL_Signatory.LoadKeysFromStream( + Store: TStream; Parts: TKeyStoragePartSet); +var + ErrorMessage: string; +begin +if partPrivate in Parts then + begin + LoadRSA_PrivateKey( ErrorMessage, FStorageCipher, ReadString( Store, + '-----END RSA PRIVATE KEY-----'#10), FStoragePassword); + if ErrorMessage = '' then exit; + FErrMsg := ErrorMessage; + raise Exception.Create( FErrMsg) + end + + else if partPublic in Parts then + begin + LoadRSA_PublicKey( ErrorMessage, ReadString( Store, + '-----END RSA PUBLIC KEY-----'#10)); + if ErrorMessage = '' then exit; + FErrMsg := ErrorMessage; + raise Exception.Create( FErrMsg) + end + + else begin end +end; + +function TOpenSSL_Signatory.Sign( + PreHash: TSigHashKind; HashedDocument, Signature: TStream): boolean; +var + Message1: pointer; + MessageLen: cardinal; + sSignature: utf8string; + ErrorMessage: string; + MemStream: TMemoryStream; +begin +MessageLen := HashedDocument.Size - HashedDocument.Position; +if HashedDocument is TMemoryStream then + begin + Message1 := TMemoryStream( HashedDocument).Memory; + MemStream := nil + end + else + begin + MemStream := TMemoryStream.Create; + MemStream.Size := MessageLen; + MemStream.Position := 0; + MemStream.CopyFrom( HashedDocument, MessageLen); + Message1 := MemStream.Memory + end; +try + RSA_Sign( PreHash, Message1, MessageLen, sSignature, ErrorMessage); +finally + MemStream.Free + end; +result := (ErrorMessage = '') and (sSignature <> ''); +if result then + Signature.Write( sSignature[1], Length( sSignature)) + else if ErrorMessage <> '' then + FErrMsg := ErrorMessage + else + FErrMsg := '(Error) Unknown error' +end; + + +function TOpenSSL_Signatory.Verify( + PreHash: TSigHashKind; HashedDocument, Signature: TStream): TVerifyResult; +var + Message1: pointer; + MessageLen: cardinal; + sSignature: utf8string; + MemStream: TMemoryStream; + SigLen: integer; +begin +MessageLen := HashedDocument.Size - HashedDocument.Position; +if HashedDocument is TMemoryStream then + begin + Message1 := TMemoryStream( HashedDocument).Memory; + MemStream := nil + end + else + begin + MemStream := TMemoryStream.Create; + MemStream.Size := MessageLen; + MemStream.Position := 0; + MemStream.CopyFrom( HashedDocument, MessageLen); + Message1 := MemStream.Memory + end; +try + SigLen := Signature.Size - Signature.Position; + SetLength( sSignature, SigLen); + if SigLen > 0 then + Signature.Read( sSignature[1], SigLen); + if RSA_Verify( PreHash, Message1, MessageLen, sSignature) then + result := vPass + else + result := vFail +finally + MemStream.Free + end +end; + + +function TOpenSSL_Signatory.GetPrivateKey_AsPEM: utf8string; +begin +if partPrivate in FKeyStorageParts then + result := PrivateKey_AsPEM( FStorageCipher, FStoragePassword) + else + result := '(Error) No private key' +end; + + +procedure TOpenSSL_Signatory.SetPrivateKey_AsPEM( const Value: utf8string); +var + Err: string; +begin +LoadRSA_PrivateKey( Err, FStorageCipher, Value, FStoragePassword); +if Err <> '' then + begin + FErrMsg := Err; + raise Exception.Create( FErrMsg) + end +end; + + +procedure TOpenSSL_Signatory.SetPublicKey_AsPEM( const Value: utf8string); +var + Err: string; +begin +LoadRSA_PublicKey( Err, Value); +if Err <> '' then + begin + FErrMsg := Err; + raise Exception.Create( FErrMsg) + end +end; + + + +//procedure TOpenSSL_Signatory.OpenSSL_Encrypt( const key, iv: TBytes; Cipher: TCipherToEncryptPrivateKeyWith; InStream, OutStream: TStream); +//var +// Key: rawbytestring; +// IV : rawbytestring; +// ctx: EVP_CIPHER_CTX; +// ret: integer; +// s: string; +// j: integer; +// outbuf, inbuf: TBytes; +// inLen, outLen: Integer; +// Ok: boolean; +//begin +//Key := '1234567812345678'; +//IV := '1234567812345678'; +//SetLength( inbuf, Length( Key)); +//SetLength( outbuf, Length( Key)); + +// FOpenSSLProc_EVP_CipherInit_ex( ctx, GetEVP( cipher_aes_256_ofb), nil, nil, nil, 1); +// FOpenSSLProc_EVP_CIPHER_CTX_set_key_length( ctx, Length( Key)); +// FOpenSSLProc_EVP_CipherInit_ex( ctx, nil, nil, @Key[1], @IV[1], 1); +// for j := 1 to 10 do +// begin +// inLen := Length( inBuf); +// outLen := Length( outBuf); +// Ok := FOpenSSLProc_EVP_CipherUpdate( ctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; +// if not Ok then break; +// s := '1'; +// end; +// outLen := Length( outBuf); +// Ok := FOpenSSLProc_EVP_CipherFinal_ex( ctx, @outbuf[1], outLen) <> 0; + +//end; + +{ TOpenSSL_Codec } + +constructor TOpenSSL_Codec.Create( AOwner: TComponent); +begin +inherited Create( AOwner); +FCipher := cipher_aes_256_ofb; +SetLength( FKey, 0); +SetLength( FIV , 0); +FisInitialised := False; +FPad := padPKCS; +end; + +destructor TOpenSSL_Codec.Destroy; +begin +if isLoaded and FisInitialised then + begin + FisInitialised := False; + FOpenSSLProc_EVP_CIPHER_CTX_cleanup( Fctx); // Equivalent to a burn. + end; +inherited +end; + +procedure TOpenSSL_Codec.SetKey( const key1: TBytes); +begin +SetLength( FKey, Length( key1)); +if Length( key1) > 0 then + Move( key1[1], FKey[1], Length( key1)); +end; + +procedure TOpenSSL_Codec.SetIV( const iv1: TBytes); +begin +SetLength( FIV, Length( iv1)); +if Length( iv1) > 0 then + Move( iv1[1], FIV[1], Length( iv1)); +end; + +procedure TOpenSSL_Codec.BeginEncDec( doEncrypt: Boolean); +var + EncValue: integer; + iPadParm: integer; +begin +if not FisInitialised then + begin + FisInitialised := True; + FOpenSSLProc_EVP_CIPHER_CTX_init( Fctx); + end; +FOpenSSLProc_EVP_CipherInit_ex( Fctx, GetEVP( FCipher), nil, nil, nil, 1); +FOpenSSLProc_EVP_CIPHER_CTX_set_key_length( Fctx, Length( FKey)); +if doEncrypt then + EncValue := 1 + else + EncValue := 0; +FOpenSSLProc_EVP_CipherInit_ex( Fctx, nil, nil, @FKey[1], @FIV[1], EncValue); +iPadParm := Ord( FPad); +FOpenSSLProc_EVP_CIPHER_CTX_set_padding( Fctx, iPadParm); +end; + +procedure TOpenSSL_Codec.Encrypt( + PlaintextInStream, CiphertextOutStream: TStream); +var + InBuf, OutBuf: TBytes; + InLen, OutLen: Integer; + Ok: boolean; +begin +BeginEncDec( True); +SetLength( InBuf , Length( FIV)); +SetLength( OutBuf, Length( FIV) * 2); +Ok := True; +repeat + InLen := PlaintextInStream.Read( InBuf[1], Length( InBuf)); + OutLen := Length( OutBuf); + If InLen = 0 then break; + if InLen < Length( InBuf) then + begin + case FPad of + padNone: + begin + + end; + + padPKCS: + begin + + end; + + end; + end; + Ok := FOpenSSLProc_EVP_CipherUpdate( Fctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; + if Ok and (OutLen > 0) then + CiphertextOutStream.Write( OutBuf[1], OutLen) +until (InLen < Length( InBuf)) or (not Ok); +if Ok then + begin + OutLen := Length( outBuf); + Ok := FOpenSSLProc_EVP_CipherFinal_ex( Fctx, @Outbuf[1], OutLen) <> 0; + if Ok and (OutLen > 0) then + CiphertextOutStream.Write( OutBuf[1], OutLen) + end + else + raise Exception.Create( 'OpenSSL encryption error') +end; + +procedure TOpenSSL_Codec.Decrypt( + PlaintextOutStream, CiphertextInStream: TStream); +const + MaxTries = 2; +var + InBuf, OutBuf: TBytes; + InLen, OutLen: Integer; + Ok: boolean; + PlainPos, CipherPos, CipherSz: Int64; + Trial: integer; +begin +PlainPos := PlaintextOutStream.Position; +CipherPos := CiphertextInStream.Position; +CipherSz := CiphertextInStream.Size; +for Trial := 1 to MaxTries do + begin + BeginEncDec( False); + SetLength( InBuf , Length( FIV)); + SetLength( OutBuf, Length( FIV) * 2); + Ok := True; + repeat + InLen := CiphertextInStream.Read( InBuf[1], Length( InBuf)); + OutLen := Length( OutBuf); + If InLen = 0 then break; + Ok := FOpenSSLProc_EVP_CipherUpdate( Fctx, @outbuf[1], outlen, @inBuf[1], inlen) <> 0; + if Ok and (OutLen > 0) then + PlaintextOutStream.Write( OutBuf[1], OutLen) + until (InLen < Length( InBuf)) or (not Ok); + if Ok then + begin + OutLen := Length( outBuf); + Ok := FOpenSSLProc_EVP_CipherFinal_ex( Fctx, @Outbuf[1], OutLen) <> 0; + if Ok and (OutLen > 0) then + PlaintextOutStream.Write( OutBuf[1], OutLen) + end; + if Ok then break; + if Trial < MaxTries then + begin + PlaintextOutStream.Position := PlainPos; + CiphertextInStream.Position := CipherPos; + CiphertextInStream.Size := CipherSz; + FisInitialised := False; + FOpenSSLProc_EVP_CIPHER_CTX_cleanup( Fctx) + end + else + raise Exception.Create( 'OpenSSL encryption error') + end +end; + +initialization +InitUnit_OpenSSL_Lib; + +finalization +DoneUnit_OpenSSL_Lib +end. diff --git a/run/TPLB3.PCBC.pas b/LockBox3/run/TPLB3.PCBC.pas similarity index 96% rename from run/TPLB3.PCBC.pas rename to LockBox3/run/TPLB3.PCBC.pas index b4bb832..430fc8e 100644 --- a/run/TPLB3.PCBC.pas +++ b/LockBox3/run/TPLB3.PCBC.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,188 +12,188 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.PCBC; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; - -type - -TPCBC = class( TInterfacedObject, IBlockChainingModel) - protected - function Chain_EncryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function Chain_DecryptBlock( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec): TBlockChainLink; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function ChainingFeatures: TChainingFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - -TPCBCLink = class( TBlockChainLink) - private - FSourceCopy: TMemoryStream; - - constructor Create( Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec); - - public - function Clone: TBlockChainLink; override; - procedure Burn; override; - destructor Destroy; override; - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -implementation - - - - - - -uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; - -{ TPCBC } - -function TPCBC.ChainingFeatures: TChainingFeatureSet; -begin -result := [] -end; - - -function TPCBC.Chain_DecryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TPCBCLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TPCBC.Chain_EncryptBlock( Key: TSymetricKey; - InitializationVector: TMemoryStream; const Cipher: IBlockCodec - ): TBlockChainLink; -begin -result := TPCBCLink.Create( Key, InitializationVector, Cipher) -end; - - - -function TPCBC.DefinitionURL: string; -begin -result := '' // No definition available. -end; - - - -function TPCBC.DisplayName: string; -begin -result := 'PCBC' -end; - - - -function TPCBC.Features: TAlgorithmicFeatureSet; -begin -result := [afCryptographicallyWeak, afOpenSourceSoftware] -end; - - -function TPCBC.ProgId: string; -begin -result := PCBC_ProgId -end; - - - - - -function TPCBC.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} - 'Block_cipher_modes_of_operation#Propagating_cipher-block_chaining_.28PCBC.29' -end; - -{ TPCBCLink } - -constructor TPCBCLink.Create( - Key: TSymetricKey; InitializationVector: TMemoryStream; - const Cipher: IBlockCodec); -begin -BaseCreate( Key, InitializationVector, Cipher); -FSourceCopy := TMemoryStream.Create; -FSourceCopy.Size := FCV.Size -end; - - -function TPCBCLink.Clone: TBlockChainLink; -begin -result := inherited Clone; -TPCBCLink(result).FSourceCopy := TMemoryStream.Create; -TPCBCLink(result).FSourceCopy.Size := FCV.Size -end; - - -procedure TPCBCLink.Burn; -begin -inherited; -BurnMemoryStream( FSourceCopy) -end; - - -destructor TPCBCLink.Destroy; -begin -inherited; -FSourceCopy.Free -end; - - -procedure TPCBCLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -CopyMemoryStream( Plaintext, FSourceCopy); -XOR_Streams2( FCV, Plaintext); // FCV := FCV xor plaintext -FCipher.Encrypt_Block( FCV, Ciphertext); -XOR_Streams3( FCV, FSourceCopy, Ciphertext) // FCV := FSourceCopy xor Ciphertext -end; - - -procedure TPCBCLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -CopyMemoryStream( Ciphertext, FSourceCopy); -FCipher.Decrypt_Block( Plaintext, Ciphertext); -XOR_Streams2( Plaintext, FCV); // plaintext := plaintext xor FCV -XOR_Streams3( FCV, FSourceCopy, Plaintext) // FCV := FSourceCopy xor Plaintext -end; - - - - - -end. - + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.PCBC; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher; + +type + +TPCBC = class( TInterfacedObject, IBlockChainingModel) + protected + function Chain_EncryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function Chain_DecryptBlock( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec): TBlockChainLink; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function ChainingFeatures: TChainingFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + +TPCBCLink = class( TBlockChainLink) + private + FSourceCopy: TMemoryStream; + + constructor Create( Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec); + + public + function Clone: TBlockChainLink; override; + procedure Burn; override; + destructor Destroy; override; + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +implementation + + + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.I18n; + +{ TPCBC } + +function TPCBC.ChainingFeatures: TChainingFeatureSet; +begin +result := [] +end; + + +function TPCBC.Chain_DecryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TPCBCLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TPCBC.Chain_EncryptBlock( Key: TSymetricKey; + InitializationVector: TMemoryStream; const Cipher: IBlockCodec + ): TBlockChainLink; +begin +result := TPCBCLink.Create( Key, InitializationVector, Cipher) +end; + + + +function TPCBC.DefinitionURL: string; +begin +result := '' // No definition available. +end; + + + +function TPCBC.DisplayName: string; +begin +result := 'PCBC' +end; + + + +function TPCBC.Features: TAlgorithmicFeatureSet; +begin +result := [afCryptographicallyWeak, afOpenSourceSoftware] +end; + + +function TPCBC.ProgId: string; +begin +result := PCBC_ProgId +end; + + + + + +function TPCBC.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} + 'Block_cipher_modes_of_operation#Propagating_cipher-block_chaining_.28PCBC.29' +end; + +{ TPCBCLink } + +constructor TPCBCLink.Create( + Key: TSymetricKey; InitializationVector: TMemoryStream; + const Cipher: IBlockCodec); +begin +BaseCreate( Key, InitializationVector, Cipher); +FSourceCopy := TMemoryStream.Create; +FSourceCopy.Size := FCV.Size +end; + + +function TPCBCLink.Clone: TBlockChainLink; +begin +result := inherited Clone; +TPCBCLink(result).FSourceCopy := TMemoryStream.Create; +TPCBCLink(result).FSourceCopy.Size := FCV.Size +end; + + +procedure TPCBCLink.Burn; +begin +inherited; +BurnMemoryStream( FSourceCopy) +end; + + +destructor TPCBCLink.Destroy; +begin +inherited; +FSourceCopy.Free +end; + + +procedure TPCBCLink.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +CopyMemoryStream( Plaintext, FSourceCopy); +XOR_Streams2( FCV, Plaintext); // FCV := FCV xor plaintext +FCipher.Encrypt_Block( FCV, Ciphertext); +XOR_Streams3( FCV, FSourceCopy, Ciphertext) // FCV := FSourceCopy xor Ciphertext +end; + + +procedure TPCBCLink.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +CopyMemoryStream( Ciphertext, FSourceCopy); +FCipher.Decrypt_Block( Plaintext, Ciphertext); +XOR_Streams2( Plaintext, FCV); // plaintext := plaintext xor FCV +XOR_Streams3( FCV, FSourceCopy, Plaintext) // FCV := FSourceCopy xor Plaintext +end; + + + + + +end. + diff --git a/run/TPLB3.PointerArithmetic.pas b/LockBox3/run/TPLB3.PointerArithmetic.pas similarity index 97% rename from run/TPLB3.PointerArithmetic.pas rename to LockBox3/run/TPLB3.PointerArithmetic.pas index 9ab66cc..9f832c4 100644 --- a/run/TPLB3.PointerArithmetic.pas +++ b/LockBox3/run/TPLB3.PointerArithmetic.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,139 +12,139 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.PointerArithmetic; -interface -uses Classes; - -{$if CompilerVersion >= 17.00}{$REGION 'Notes on NativeInt/NativeUInt'}{$ifend} -// Size on Win32 | Size on Win64 | Size on OS X | Size on iOS -//--------------------------------------------------------+------------------+---------------+-------------- -// pointer | 4 | 8 (XE2+) | tba | tba -// integer | 4 | 4 | tba | tba -// NativeInt (CompilerVersion = 18.50) | 8 | n/a | n/a | n/a -// NativeInt (CompilerVersion < 20.00) and -// (CompilerVersion <> 18.50) | 4 | n/a | n/a | n/a -// NativeInt (CompilerVersion >= 20.00) | 4 | 8 (XE2+) | tba | tba -// TrueNativeInt | 4 | 8 (XE2+) | tba | tba -//--------------------------------------------------------+------------------+---------------+-------------- -{$if CompilerVersion >= 17.00}{$ENDREGION}{$ifend} -type -{$if CompilerVersion < 20.00} - TrueNativeInt = integer; - TrueNativeUInt = cardinal; -{$else} - TrueNativeInt = NativeInt; - TrueNativeUInt = NativeUInt; -{$ifend} - -// An effort needs to be made to maintain the compiler independance of -// the functional output of this unit. - -function Offset( Pntr: pointer; Value: integer): pointer; -function MemStrmOffset( Stream: TMemoryStream; Value: integer): pointer; - -procedure ClearMemory( Stream: TMemoryStream; Offset, CountBytes: integer); - -function ReadMem( Source: TStream; Destin: TMemoryStream; DestinOffset, CountBytes: integer): integer; -// The above reads CountBytes bytes from Source from its current position, -// and puts it to the destination memory stream as offset by DestinOffset. -// Assume that Destin is already large enough. - - -function WriteMem( Source: TMemoryStream; SourceOffset: integer; - Destin: TStream; CountBytes: integer): integer; -// The above reads CountBytes bytes from Source offset by SourceOffset, -// and puts it to the destination stream (writing to its current position). -// Assume that Source is already large enough. - - -function isAligned32( P: pointer): boolean; -// Above returns True if the pointer is aligned to a 32-bit boundary. - -implementation - - - - - - - - - -function Offset( Pntr: pointer; Value: integer): pointer; -begin -{$if CompilerVersion >= 21.00} -result := PByte( Pntr) + Value -{$else} -result := pointer( TrueNativeInt( Pntr) + Value) -{$ifend} -end; - - - - - -function MemStrmOffset( Stream: TMemoryStream; Value: integer): pointer; -begin -{$if CompilerVersion >= 21.00} -result := PByte( Stream.Memory) + Value -{$else} -result := pointer( TrueNativeInt( Stream.Memory) + Value) -{$ifend} -end; - - - - -function ReadMem( Source: TStream; Destin: TMemoryStream; DestinOffset, CountBytes: integer): integer; -// This function reads CountBytes bytes from Source from its current position, -// and puts it to the destination memory stream as offset by DestinOffset. -// Assume that Destin is already large enough. -begin -result := Source.Read( MemStrmOffset( Destin, DestinOffset)^, CountBytes) -end; - - - -function WriteMem( Source: TMemoryStream; SourceOffset: integer; - Destin: TStream; CountBytes: integer): integer; -// This function reads CountBytes bytes from Source offset by SourceOffset, -// and puts it to the destination stream (writing to its current position). -// Assume that Source is already large enough. -begin -result := Destin.Write( MemStrmOffset( Source, SourceOffset)^, CountBytes) -end; - - -function isAligned32( P: pointer): boolean; -begin -result := (TrueNativeUInt( P) mod 4) = 0 -end; - - -procedure ClearMemory( Stream: TMemoryStream; Offset, CountBytes: integer); -begin -if CountBytes > 0 then - FillChar( MemStrmOffset( Stream, Offset)^, CountBytes, 0) -end; - - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.PointerArithmetic; +interface +uses Classes; + +{$if CompilerVersion >= 17.00}{$REGION 'Notes on NativeInt/NativeUInt'}{$ifend} +// Size on Win32 | Size on Win64 | Size on OS X | Size on iOS +//--------------------------------------------------------+------------------+---------------+-------------- +// pointer | 4 | 8 (XE2+) | tba | tba +// integer | 4 | 4 | tba | tba +// NativeInt (CompilerVersion = 18.50) | 8 | n/a | n/a | n/a +// NativeInt (CompilerVersion < 20.00) and +// (CompilerVersion <> 18.50) | 4 | n/a | n/a | n/a +// NativeInt (CompilerVersion >= 20.00) | 4 | 8 (XE2+) | tba | tba +// TrueNativeInt | 4 | 8 (XE2+) | tba | tba +//--------------------------------------------------------+------------------+---------------+-------------- +{$if CompilerVersion >= 17.00}{$ENDREGION}{$ifend} +type +{$if CompilerVersion < 20.00} + TrueNativeInt = integer; + TrueNativeUInt = cardinal; +{$else} + TrueNativeInt = NativeInt; + TrueNativeUInt = NativeUInt; +{$ifend} + +// An effort needs to be made to maintain the compiler independance of +// the functional output of this unit. + +function Offset( Pntr: pointer; Value: integer): pointer; +function MemStrmOffset( Stream: TMemoryStream; Value: integer): pointer; + +procedure ClearMemory( Stream: TMemoryStream; Offset, CountBytes: integer); + +function ReadMem( Source: TStream; Destin: TMemoryStream; DestinOffset, CountBytes: integer): integer; +// The above reads CountBytes bytes from Source from its current position, +// and puts it to the destination memory stream as offset by DestinOffset. +// Assume that Destin is already large enough. + + +function WriteMem( Source: TMemoryStream; SourceOffset: integer; + Destin: TStream; CountBytes: integer): integer; +// The above reads CountBytes bytes from Source offset by SourceOffset, +// and puts it to the destination stream (writing to its current position). +// Assume that Source is already large enough. + + +function isAligned32( P: pointer): boolean; +// Above returns True if the pointer is aligned to a 32-bit boundary. + +implementation + + + + + + + + + +function Offset( Pntr: pointer; Value: integer): pointer; +begin +{$if CompilerVersion >= 21.00} +result := PByte( Pntr) + Value +{$else} +result := pointer( TrueNativeInt( Pntr) + Value) +{$ifend} +end; + + + + + +function MemStrmOffset( Stream: TMemoryStream; Value: integer): pointer; +begin +{$if CompilerVersion >= 21.00} +result := PByte( Stream.Memory) + Value +{$else} +result := pointer( TrueNativeInt( Stream.Memory) + Value) +{$ifend} +end; + + + + +function ReadMem( Source: TStream; Destin: TMemoryStream; DestinOffset, CountBytes: integer): integer; +// This function reads CountBytes bytes from Source from its current position, +// and puts it to the destination memory stream as offset by DestinOffset. +// Assume that Destin is already large enough. +begin +result := Source.Read( MemStrmOffset( Destin, DestinOffset)^, CountBytes) +end; + + + +function WriteMem( Source: TMemoryStream; SourceOffset: integer; + Destin: TStream; CountBytes: integer): integer; +// This function reads CountBytes bytes from Source offset by SourceOffset, +// and puts it to the destination stream (writing to its current position). +// Assume that Source is already large enough. +begin +result := Destin.Write( MemStrmOffset( Source, SourceOffset)^, CountBytes) +end; + + +function isAligned32( P: pointer): boolean; +begin +result := (TrueNativeUInt( P) mod 4) = 0 +end; + + +procedure ClearMemory( Stream: TMemoryStream; Offset, CountBytes: integer); +begin +if CountBytes > 0 then + FillChar( MemStrmOffset( Stream, Offset)^, CountBytes, 0) +end; + + +end. diff --git a/run/TPLB3.RSA_Engine.pas b/LockBox3/run/TPLB3.RSA_Engine.pas similarity index 96% rename from run/TPLB3.RSA_Engine.pas rename to LockBox3/run/TPLB3.RSA_Engine.pas index afd5df1..40ce139 100644 --- a/run/TPLB3.RSA_Engine.pas +++ b/LockBox3/run/TPLB3.RSA_Engine.pas @@ -1,1077 +1,1077 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.RSA_Engine; -interface -uses Classes, TPLB3.StreamCipher, TPLB3.Asymetric, TPLB3.Codec, TPLB3.CodecIntf, - TPLB3.HugeCardinal, TPLB3.MemoryStreamPool, TPLB3.Compatibility; - -type -TRSA_Engine = class( TAsymetric_Engine) - protected - // ICryptoGraphicAlgorithm - function DisplayName: string; override; - function ProgId: string; override; - function Features: TAlgorithmicFeatureSet; override; - function DefinitionURL: string; override; - function WikipediaReference: string; override; - - // IStreamCipher = interface( ) - function LoadKeyFromStream( Store: TStream): TSymetricKey; override; - - function AsymetricKeyPairClass: TAsymetricKeyPairClass; override; - function EncClass: TAsymetricEncryptorClass; override; - function DecClass: TAsymetricDecryptorClass; override; - - public - procedure GenerateAsymetricKeyPair( - KeySizeInBits: cardinal; - ProgressSender: TObject; - ProgressEvent: TGenerateAsymetricKeyPairProgress; - var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); - override; - - function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): - TAsymetricKeyPair; override; - end; - - const - RSAKeySig: packed array[0..9] of Byte = (78, 10, 76, 111, 99, 107, 66, 111, 120, 51); // #78#10'LockBox3'; - RSAKeyStoreVersion = 1; - - type - RSAKeyStorePart = (PartN, PartE, PartD, PartCRT); - RSAKeyStorePartSet = set of RSAKeyStorePart; - -IHugeCardinalWrap = interface - ['{27B8620A-903B-4695-80DD-20DA9D24BCC4}'] - function Value: THugeCardinal; - procedure Burn; - function IsZero: boolean; - end; - -TRSAKeyPair = class; -TRSAKeyPart = class( TAsymtricKeyPart) - protected - F_RSA_n: IHugeCardinalWrap; - FOwner: TRSAKeyPair; - function NominalKeyBitLength: cardinal; override; - procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); virtual; abstract; - procedure StoreE( Store: TStream); virtual; abstract; - procedure StoreD( Store: TStream); virtual; abstract; - procedure StoreCRT( Store: TStream); virtual; abstract; - procedure StoreSmallPartsToStream( const Parts: RSAKeyStorePartSet; Store: TStream); - procedure LoadE( Store: TStream); virtual; abstract; - procedure LoadD( Store: TStream); virtual; abstract; - procedure LoadCRT( Store: TStream); virtual; abstract; - procedure LoadSmallPartsFromStream( const Parts: RSAKeyStorePartSet; Store: TStream); - procedure SenseVersion( doReadPastHeader: boolean; Store: TStream; - var Version: integer; var AvailableParts: RSAKeyStorePartSet); - - public - procedure SaveToStream ( Store: TStream); override; - procedure LoadFromStream( Store: TStream); override; - procedure Burn; override; - end; - -TRSA_PublicKeyPart = class( TRSAKeyPart) - protected - procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); override; - procedure StoreE( Store: TStream); override; - procedure StoreD( Store: TStream); override; - procedure StoreCRT( Store: TStream); override; - procedure LoadE( Store: TStream); override; - procedure LoadD( Store: TStream); override; - procedure LoadCRT( Store: TStream); override; - public - F_RSA_e: IHugeCardinalWrap; - procedure Burn; override; - function isEmpty: boolean; override; - end; - -TRSA_PrivateKeyPart = class( TRSAKeyPart) - protected - procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); override; - procedure StoreE( Store: TStream); override; - procedure StoreD( Store: TStream); override; - procedure StoreCRT( Store: TStream); override; - procedure LoadE( Store: TStream); override; - procedure LoadD( Store: TStream); override; - procedure LoadCRT( Store: TStream); override; - public - F_RSA_d: IHugeCardinalWrap; - F_RSA_p, F_RSA_q, F_RSA_dp, F_RSA_dq, F_RSA_qinv: IHugeCardinalWrap; - procedure Burn; override; - function isEmpty: boolean; override; - end; - -TRSAKeyPair = class( TAsymetricKeyPair) - private - procedure LinkParts; - procedure CheckLinkages; - - protected - FPool: IMemoryStreamPool; - function StoreHugeCardinal( - Number: THugeCardinal; StoreStream: TStream): boolean; virtual; - function LoadHugeCardinal_IfNotAlready( - StoreStream: TStream; var Number: IHugeCardinalWrap): boolean; virtual; - - public - F_RSA_n, F_RSA_d, F_RSA_e: IHugeCardinalWrap; - F_RSA_p, F_RSA_q, F_RSA_dp, F_RSA_dq, F_RSA_qinv: IHugeCardinalWrap; - - constructor CreateEmpty; override; - destructor Destroy; override; - procedure LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); override; - procedure StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); override; - procedure Burn; override; - end; - -TRSA_Encryptor = class( TAsymetricEncryptor) - public - function GenerateSymetricKey: TSymetricKey; override; - function VerifySignature( - Document: TStream; // FCipherText is the signature to be verified. - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean): boolean; override; - end; - -TRSA_Decryptor = class( TAsymetricDecryptor) - public - function LoadSymetricKey( Ciphertext: TStream): TSymetricKey; override; - procedure Sign( // FPlaintext is the document to be signed. - Signature: TStream; - ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; - var wasAborted: boolean); override; - end; - -implementation - - - - - - - - - - - - - - - - - - -uses TPLB3.RSA_Primitives, SysUtils, Math, TPLB3.HugeCardinalUtils, - TPLB3.Constants, TPLB3.I18n; - -{ TRSA_Engine } - -function TRSA_Engine.AsymetricKeyPairClass: TAsymetricKeyPairClass; -begin -result := TRSAKeyPair -end; - -function TRSA_Engine.DecClass: TAsymetricDecryptorClass; -begin -result := TRSA_Decryptor -end; - -function TRSA_Engine.DefinitionURL: string; -begin -result := 'http://www.ietf.org/rfc/rfc3447.txt' -end; - - -function TRSA_Engine.DisplayName: string; -begin -result := RSA_DisplayName -end; - - - - - - -function TRSA_Engine.EncClass: TAsymetricEncryptorClass; -begin -result := TRSA_Encryptor -end; - - - -function TRSA_Engine.Features: TAlgorithmicFeatureSet; -begin -result := (inherited Features); -Include( result, afStar) -end; - - - -type TRSA_Gen_Key_Helper = class - private - FPool: IMemoryStreamPool; - FdoOwn: boolean; - FNumbersTested: integer; - FClient_ProgressEvent: TGenerateAsymetricKeyPairProgress; - - procedure Progress_Event( Sender: TObject; BitsProcessed, - TotalBits: int64; var doAbort: boolean); - procedure PrimalityTest_Event( CountPrimalityTests: integer); - - public - constructor Create( - Client_ProgressEvent1: TGenerateAsymetricKeyPairProgress; - const Pool1: IMemoryStreamPool); - destructor Destroy; override; - end; - - -THugeCardinalWrap = class( TInterfacedObject, IHugeCardinalWrap) - private - FValue: THugeCardinal; - function Value: THugeCardinal; - procedure Burn; - function IsZero: boolean; - public - constructor Create( Value1: THugeCardinal); - destructor Destroy; override; - end; - -function NewWrap( Value1: THugeCardinal): IHugeCardinalWrap; -begin -result := THugeCardinalWrap.Create( Value1) -end; - -procedure TRSA_Engine.GenerateAsymetricKeyPair( - KeySizeInBits: cardinal; ProgressSender: TObject; - ProgressEvent: TGenerateAsymetricKeyPairProgress; - var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); -var - RSAKeyPair: TRSAKeyPair; - N, e, d, Totient: THugeCardinal; - p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. - GeneratePrimePassCount: integer; // 1 .. 20; - Helper: TRSA_Gen_Key_Helper; -begin -RSAKeyPair := AsymetricKeyPairClass.CreateEmpty as TRSAKeyPair; - -GeneratePrimePassCount := 5; -Helper := TRSA_Gen_Key_Helper.Create( ProgressEvent, RSAKeyPair.FPool); -Totient := nil; - -try -TPLB3.HugeCardinalUtils.Compute_RSA_Fundamentals_2Factors( - KeySizeInBits, StandardExponent, N, e, d, Totient, - p, q, dp, dq, qinv, - Helper.Progress_Event, Helper.PrimalityTest_Event, - GeneratePrimePassCount, RSAKeyPair.FPool, Helper.FNumbersTested, wasAborted); - -if not wasAborted then - begin - RSAKeyPair.F_RSA_n := NewWrap( N); - RSAKeyPair.F_RSA_d := NewWrap( d); - RSAKeyPair.F_RSA_e := NewWrap( e); - RSAKeyPair.F_RSA_p := NewWrap( p); - RSAKeyPair.F_RSA_q := NewWrap( q); - RSAKeyPair.F_RSA_dp := NewWrap( dp); - RSAKeyPair.F_RSA_dq := NewWrap( dq); - RSAKeyPair.F_RSA_qinv := NewWrap( qinv); - RSAKeyPair.LinkParts - end - else - begin - N.Free; d.Free; e.Free; - p.Free; q.Free; dp.Free; dq.Free; qinv.Free; - end -finally - Totient.Free; - Helper.Free - end; -KeyPair := RSAKeyPair -end; - - - -function TRSA_Engine.CreateFromStream( - Store: TStream; Parts: TKeyStoragePartSet): TAsymetricKeyPair; -begin -result := TRSAKeyPair.CreateEmpty; -result.LoadFromStream( Store, Parts) -end; - - -function TRSA_Engine.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := CreateFromStream( Store, [partPublic, partPrivate]) -end; - - -function TRSA_Engine.ProgId: string; -begin -result := RSA_ProgId -end; - - -function TRSA_Engine.WikipediaReference: string; -begin -result := 'RSA' -end; - - - -{ TRSAKeyPart } - -procedure TRSAKeyPart.Burn; -begin -F_RSA_n.Burn -end; - - -function TRSAKeyPart.NominalKeyBitLength: cardinal; -var - Xtra: cardinal; -begin -result := F_RSA_n.Value.BitLength; -Xtra := result mod 8; -if Xtra > 0 then - Inc( result, 8 - Xtra) -end; - - -procedure TRSAKeyPart.StoreSmallPartsToStream( const Parts: RSAKeyStorePartSet; Store: TStream); -var - Version: integer; -begin -Store.WriteBuffer( RSAKeySig[0], Length( RSAKeySig)); -Version := RSAKeyStoreVersion; -Store.WriteBuffer( Version, SizeOf( Version)); -Store.WriteBuffer( Parts, SizeOf( Parts)); -if (PartN in Parts) and assigned( FOwner) then - FOwner.StoreHugeCardinal( F_RSA_n.Value, Store); -if (PartE in Parts) and assigned( FOwner) then - StoreE( Store); -if (PartD in Parts) and assigned( FOwner) then - StoreD( Store); -if (PartCRT in Parts) and assigned( FOwner) then - StoreCRT( Store); -end; - - -procedure TRSAKeyPart.SaveToStream( Store: TStream); -var - PartsToStore: RSAKeyStorePartSet; -begin -PartsToStore := [PartN]; -MarkPartsToStoreLoad( PartsToStore); -StoreSmallPartsToStream( PartsToSTore, Store) -//FOwner.StoreHugeCardinal( F_RSA_n, Store) -end; - -procedure TRSAKeyPart.SenseVersion( - doReadPastHeader: boolean; Store: TStream; - var Version: integer; - var AvailableParts: RSAKeyStorePartSet); -var - Sig: packed array[0..9] of Byte; - ReadCount, Count: integer; - Ok: boolean; -begin -ReadCount := Store.Read( Sig[0], Length( Sig)); -Ok := (ReadCount = Length( Sig)) and CompareMem( @Sig[0], @RSAKeySig[0], Length( Sig)); -if Ok then - begin - Count := Store.Read( Version, SizeOf( Version)); - Inc( ReadCount, Count); - Ok := (Count = SizeOf( Version)) and (Version >= 1) - end; -if Ok then - begin - Count := Store.Read( AvailableParts, SizeOf( AvailableParts)); - Inc( ReadCount, Count); - Ok := Count = SizeOf( AvailableParts) - end; -if (not Ok) or (not doReadPastHeader) then - Store.Seek( -ReadCount, soCurrent); -if not Ok then - begin - Version := 0; - AvailableParts := [] - end -end; - -procedure TRSAKeyPart.LoadSmallPartsFromStream( const Parts: RSAKeyStorePartSet; Store: TStream); -var - Version: integer; - // Sig: utf8string; - AvailableParts, PartsToLoad: RSAKeyStorePartSet; -begin -SenseVersion( True, Store, Version, AvailableParts); -if Version > RSAKeyStoreVersion then - raise Exception.Create('Invalid or unrecognised format for RSA key'); -if Version >= 1 then - begin - if (Parts - AvailableParts - [PartCRT]) <> [] then - raise Exception.Create('Error Message'); - PartsToLoad := Parts - [PartCRT]; - if ((Parts * [PartD, PartCRT]) <> []) and - (PartCRT in AvailableParts) then - Include( PartsToLoad, PartCRT); - end - else - PartsToLoad := []; -if assigned( FOwner) then - FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_n); -if PartE in PartsToLoad then - LoadE( Store); -if PartD in PartsToLoad then - LoadD( Store); -if PartCRT in PartsToLoad then - LoadCRT( Store) -end; - - -procedure TRSAKeyPart.LoadFromStream( Store: TStream); -var - PartsToLoad: RSAKeyStorePartSet; -begin -PartsToLoad := [PartN]; -MarkPartsToStoreLoad( PartsToLoad); -LoadSmallPartsFromStream( PartsToLoad, Store) -// FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_n) -end; - - - - -{ TRSA_Encryptor } - -function TRSA_Encryptor.GenerateSymetricKey: TSymetricKey; -var - Key: TRSA_PublicKeyPart; -begin -Key := FPublicKey as TRSA_PublicKeyPart; -result := Generate_RSA_SymetricKey( - Key.F_RSA_n.Value, Key.F_RSA_e.Value, FCipherText, FSymetricCodec.BlockCipher) -end; - - -type -TMonitor = class - private - FSender: TObject; - FEvent: TOnEncDecProgress; - function OnProgress( Sender: TObject; CountBytesProcessed: int64): boolean; - public - constructor Create( Event: TOnEncDecProgress; Sender: TObject); - end; - - -function TRSA_Encryptor.VerifySignature( - Document: TStream; ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; var wasAborted: boolean): boolean; -var - Key: TRSA_PublicKeyPart; - Monitor: TMonitor; - OpRes: TLongOpResult; -begin -Key := FPublicKey as TRSA_PublicKeyPart; -wasAborted := False; -result := assigned( Key) and - assigned( Key.F_RSA_n) and (not Key.F_RSA_n.isZero) and - assigned( Key.F_RSA_e) and (not Key.F_RSA_e.isZero); -if result then - begin - Monitor := TMonitor.Create( ProgressEvent, ProgressSender); - try - OpRes := RSASSA_PSS_VERIFY( Key.F_RSA_n.Value, Key.F_RSA_e.Value, Document, FCipherText, - Monitor.OnProgress) - finally - Monitor.Free; - end; - result := OpRes = opPass; - wasAborted := OpRes = opAbort - end -end; - - - -function UnWrap( const Wrap: IHugeCardinalWrap): THugeCardinal; -begin -if assigned( Wrap) then - result := Wrap.Value - else - result := nil -end; - -{ TRSA_Decryptor } - -function TRSA_Decryptor.LoadSymetricKey( Ciphertext: TStream): TSymetricKey; -var - Key: TRSA_PrivateKeyPart; -begin -Key := FPrivateKey as TRSA_PrivateKeyPart; -result := Extract_RSA_SymetricKey( - UnWrap( Key.F_RSA_d), UnWrap( Key.F_RSA_n), - UnWrap( Key.F_RSA_p), UnWrap( Key.F_RSA_q), UnWrap( Key.F_RSA_dp), UnWrap( Key.F_RSA_dq), UnWrap( Key.F_RSA_qinv), - Ciphertext, FSymetricCodec.BlockCipher) -end; - - - - -procedure TRSA_Decryptor.Sign( - Signature: TStream; ProgressSender: TObject; - ProgressEvent: TOnEncDecProgress; var wasAborted: boolean); -var - Succeeded: boolean; - Key: TRSA_PrivateKeyPart; - OpRes: TLongOpResult; - Monitor: TMonitor; -begin -wasAborted := False; -Key := FPrivateKey as TRSA_PrivateKeyPart; -Succeeded := assigned( Key) and - assigned( Key.F_RSA_d) and (not Key.F_RSA_d.isZero) and - assigned( Key.F_RSA_n) and (not Key.F_RSA_n.isZero); -if Succeeded then - begin - Monitor := TMonitor.Create( ProgressEvent, ProgressSender); - try - OpRes := TPLB3.RSA_Primitives.RSASSA_PSS_SIGN( - UnWrap( Key.F_RSA_d), UnWrap( Key.F_RSA_n), FPlainText, Signature, Monitor.OnProgress, - UnWrap( Key.F_RSA_p), UnWrap( Key.F_RSA_q), UnWrap( Key.F_RSA_dp), UnWrap( Key.F_RSA_dq), UnWrap( Key.F_RSA_qinv)) - finally - Monitor.Free - end; -// Succeeded := OpRes = opPass; - wasAborted := opRes = opAbort - // Discard Succeeded. It should be impossible to fail. - end -end; - - - - -function StoreHugeCardinal_Primitive( - Number: THugeCardinal; StoreStream: TStream): boolean; -// Stores the number in the stream using the cannonical format. -// Returns True if the Number was assigned. -var - L: cardinal; -begin -result := assigned( Number); -if result then - L := (Number.BitLength + 7) div 8 - else - L := 0; -if not assigned( StoreStream) then exit; -StoreStream.WriteBuffer( L, SizeOf( L)); -if L > 0 then - Number.StreamOut( LittleEndien, StoreStream, L) -end; - - -function LoadHugeCardinal_Primitive( - StoreStream: TStream; const Pool1: IMemoryStreamPool): THugeCardinal; -// Loads the number from the stream using the cannonical format. -var - L: cardinal; - ValueStream: TMemoryStream; -begin -StoreStream.Read( L, SizeOf( L)); -ValueStream := TMemoryStream.Create; -try -StoreStream.ReadBuffer( ValueStream.Memory^, L); -ValueStream.Position := 0; -result := THugeCardinal.CreateFromStreamIn( - L*8, LittleEndien, ValueStream, Pool1) -finally -ValueStream.Free -end end; - - - -function TRSAKeyPair.StoreHugeCardinal( - Number: THugeCardinal; StoreStream: TStream): boolean; - // virtual method. -begin -result := StoreHugeCardinal_Primitive( Number, StoreStream) -end; - - -procedure TRSAKeyPair.StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); -var - SmallParts: RSAKeyStorePartSet; -begin -if Parts = [] then - SmallParts := [] - else - SmallParts := [PartN]; -if partPublic in Parts then - (FPublicPart as TRSAKeyPart).MarkPartsToStoreLoad( SmallParts); -if partPrivate in Parts then - (FPrivatePart as TRSAKeyPart).MarkPartsToStoreLoad( SmallParts); -if FPublicPart is TRSAKeyPart then - TRSAKeyPart( FPublicPart).StoreSmallPartsToStream( SmallParts, Store) - else - (FPrivatePart as TRSAKeyPart).StoreSmallPartsToStream( SmallParts, Store) -//if Parts <> [] then -// StoreHugeCardinal( F_RSA_n, Store); -//if partPublic in Parts then -// StoreHugeCardinal( F_RSA_e, Store); -//if partPrivate in Parts then -// StoreHugeCardinal( F_RSA_d, Store) -end; - - -function TRSAKeyPair.LoadHugeCardinal_IfNotAlready( - StoreStream: TStream; var Number: IHugeCardinalWrap): boolean; - // virtual method. -var - L: cardinal; - ValueStream: TMemoryStream; -begin -result := not assigned( Number); -if not result then exit; // Only load if we are not already loaded. -StoreStream.ReadBuffer( L, SizeOf( L)); -ValueStream := TMemoryStream.Create; -try -ValueStream.Size := L; -if L > 0 then - StoreStream.ReadBuffer( ValueStream.Memory^, L); -ValueStream.Position := 0; -Number := NewWrap( THugeCardinal.CreateFromStreamIn( - L*8, LittleEndien, ValueStream, FPool)) -finally -ValueStream.Free -end; -if Number.isZero then - Number := nil -end; - - -{ TRSA_PublicKeyPart } - -procedure TRSA_PublicKeyPart.Burn; -begin -inherited; -F_RSA_e.Burn -end; - -function TRSA_PublicKeyPart.isEmpty: boolean; -begin -result := (not assigned( F_RSA_e)) or F_RSA_e.isZero -end; - - -procedure TRSA_PublicKeyPart.LoadCRT( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPrivatePart).LoadCRT( Store) -end; - -procedure TRSA_PublicKeyPart.LoadD( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPrivatePart).LoadD( Store) -end; - -procedure TRSA_PublicKeyPart.LoadE( Store: TStream); -begin -if assigned( FOwner) then - FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_e) -end; - - - -procedure TRSA_PublicKeyPart.MarkPartsToStoreLoad( - var Parts: RSAKeyStorePartSet); -begin -Include( Parts, PartE) -end; - - - -procedure TRSA_PublicKeyPart.StoreCRT( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPrivatePart).StoreCRT( Store) -end; - -procedure TRSA_PublicKeyPart.StoreD( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPrivatePart).StoreD( Store) -end; - -procedure TRSA_PublicKeyPart.StoreE( Store: TStream); -begin -if assigned( FOwner) then - FOwner.StoreHugeCardinal( F_RSA_e.Value, Store) -end; - -{ TRSA_PrivateKeyPart } - -procedure TRSA_PrivateKeyPart.Burn; -begin -inherited; -F_RSA_d.Burn -end; - - -function TRSA_PrivateKeyPart.isEmpty: boolean; -begin -result := (not assigned( F_RSA_d)) or F_RSA_d.isZero -end; - -procedure TRSA_PrivateKeyPart.LoadCRT( Store: TStream); -begin -if not assigned( FOwner) then exit; -FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_p); -FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_q); -FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_dp); -FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_dq); -FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_qinv) -end; - -procedure TRSA_PrivateKeyPart.LoadD( Store: TStream); -begin -if assigned( FOwner) then - FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_d) -end; - -procedure TRSA_PrivateKeyPart.LoadE( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPublicPart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPublicPart).LoadE( Store) -end; - - - -procedure TRSA_PrivateKeyPart.MarkPartsToStoreLoad( - var Parts: RSAKeyStorePartSet); -begin -Include( Parts, PartD); -if assigned( F_RSA_qinv) then - Include( Parts, PartCRT) -end; - - - -procedure TRSA_PrivateKeyPart.StoreCRT( Store: TStream); -begin -if not assigned( FOwner) then exit; -FOwner.StoreHugeCardinal( F_RSA_p.Value, Store); -FOwner.StoreHugeCardinal( F_RSA_q.Value, Store); -FOwner.StoreHugeCardinal( F_RSA_dp.Value, Store); -FOwner.StoreHugeCardinal( F_RSA_dq.Value, Store); -FOwner.StoreHugeCardinal( F_RSA_qinv.Value, Store) -end; - -procedure TRSA_PrivateKeyPart.StoreD( Store: TStream); -begin -if assigned( FOwner) then - FOwner.StoreHugeCardinal( F_RSA_d.Value, Store) -end; - -procedure TRSA_PrivateKeyPart.StoreE( Store: TStream); -begin -if assigned( FOwner) and (FOwner.FPublicPart is TRSAKeyPart) then - TRSAKeyPart( FOwner.FPublicPart).StoreE( Store) -end; - -{ TRSAKeyPair } - -procedure TRSAKeyPair.Burn; -begin -if assigned( F_RSA_n) then - F_RSA_n.Burn; -if assigned( F_RSA_e) then - F_RSA_e.Burn; -if assigned( F_RSA_d) then - F_RSA_d.Burn; -if assigned( F_RSA_p) then - F_RSA_p.Burn; -if assigned( F_RSA_q) then - F_RSA_q.Burn; -if assigned( F_RSA_dp) then - F_RSA_dp.Burn; -if assigned( F_RSA_dq) then - F_RSA_dq.Burn; -if assigned( F_RSA_qinv) then - F_RSA_qinv.Burn; -F_RSA_n := nil; -F_RSA_d := nil; -F_RSA_e := nil; -F_RSA_p := nil; -F_RSA_q := nil; -F_RSA_dp := nil; -F_RSA_dq := nil; -F_RSA_qinv := nil; -LinkParts -end; - - - -constructor TRSAKeyPair.CreateEmpty; -begin -FPool := NewPool; -F_RSA_n := nil; -F_RSA_d := nil; -F_RSA_e := nil; -F_RSA_p := nil; -F_RSA_q := nil; -F_RSA_dp := nil; -F_RSA_dq := nil; -F_RSA_qinv := nil; -FPublicPart := TRSA_PublicKeyPart.Create; -FPrivatePart := TRSA_PrivateKeyPart.Create; -LinkParts; -end; - - - -procedure TRSAKeyPair.LinkParts; -begin -(FPublicPart as TRSA_PublicKeyPart).FOwner := self; -(FPublicPart as TRSA_PublicKeyPart).F_RSA_n := F_RSA_n; -(FPublicPart as TRSA_PublicKeyPart).F_RSA_e := F_RSA_e; - -(FPrivatePart as TRSA_PrivateKeyPart).FOwner := self; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_n := F_RSA_n; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d := F_RSA_d; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_p := F_RSA_p; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_q := F_RSA_q; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_dp := F_RSA_dp; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_dq := F_RSA_dq; -(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_qinv := F_RSA_qinv; -end; - - -procedure TRSAKeyPair.CheckLinkages; -begin -if not ( - (FPublicPart is TRSA_PublicKeyPart ) and - (FPrivatePart is TRSA_PrivateKeyPart) and - (TRSA_PublicKeyPart( FPublicPart).FOwner = self) and - (TRSA_PublicKeyPart( FPublicPart).F_RSA_n = F_RSA_n) and - (TRSA_PublicKeyPart( FPublicPart).F_RSA_e = F_RSA_e) and - (TRSA_PrivateKeyPart( FPrivatePart).FOwner = self) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_n = F_RSA_n) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_d = F_RSA_d) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p = F_RSA_p) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q = F_RSA_q) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp = F_RSA_dp) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq = F_RSA_dq) and - (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv = F_RSA_qinv)) then - raise Exception.Create('TRSAKeyPair linkage error.'); -end; - - -destructor TRSAKeyPair.Destroy; -begin -F_RSA_n := nil; -F_RSA_d := nil; -F_RSA_e := nil; -F_RSA_p := nil; -F_RSA_q := nil; -F_RSA_dp := nil; -F_RSA_dq := nil; -F_RSA_qinv := nil; -FPool := nil; -inherited -end; - - - -procedure TRSAKeyPair.LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); -var - Version: integer; - AvailableParts, PartsToLoad: RSAKeyStorePartSet; -begin -(FPublicPart as TRSA_PublicKeyPart).SenseVersion( False, Store, Version, AvailableParts); -if Parts <> [] then - begin - F_RSA_n := nil; - (FPublicPart as TRSA_PublicKeyPart).F_RSA_n := nil; - TRSA_PublicKeyPart( FPublicPart).F_RSA_n := nil; - end; -if partPublic in Parts then - begin - F_RSA_e := nil; - TRSA_PublicKeyPart ( FPublicPart).F_RSA_e := nil; - end; -if partPrivate in Parts then - begin - F_RSA_d := nil; - F_RSA_p := nil; - F_RSA_q := nil; - F_RSA_dp := nil; - F_RSA_dq := nil; - F_RSA_qinv := nil; - (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d := nil; - TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p := nil; - TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q := nil; - TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp := nil; - TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq := nil; - TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv := nil; - end; -if Version = 0 then - begin - if Parts <> [] then - LoadHugeCardinal_IfNotAlready( Store, F_RSA_n); - if partPublic in Parts then - LoadHugeCardinal_IfNotAlready( Store, F_RSA_e); - if partPrivate in Parts then - LoadHugeCardinal_IfNotAlready( Store, F_RSA_d); - LinkParts - end - else - begin - PartsToLoad := []; - if Parts <> [] then - Include( PartsToLoad, PartN); - if partPublic in Parts then - Include( PartsToLoad, PartE); - if partPrivate in Parts then - begin - Include( PartsToLoad, PartD); - Include( PartsToLoad, PartCRT); - end; - (FPublicPart as TRSA_PublicKeyPart).LoadSmallPartsFromStream( PartsToLoad, Store); - // n and e are loaded into the public key. - // d, dp, dq, p, q & qinv are loaded into the private key. - F_RSA_n := (FPublicPart as TRSA_PublicKeyPart).F_RSA_n; - F_RSA_e := (FPublicPart as TRSA_PublicKeyPart).F_RSA_e; - (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_n := F_RSA_n; - F_RSA_d := (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d; - F_RSA_p := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p; - F_RSA_q := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q; - F_RSA_dp := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp; - F_RSA_dq := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq; - F_RSA_qinv := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv - end; -CheckLinkages -end; - - - - - -{ TRSA_Gen_Key_Helper } - -constructor TRSA_Gen_Key_Helper.Create( - Client_ProgressEvent1: TGenerateAsymetricKeyPairProgress; - const Pool1: IMemoryStreamPool); -begin -FPool := Pool1; -FdoOwn := not assigned( FPool); -if FdoOwn then - FPool := NewPool; -FNumbersTested := 0; -FClient_ProgressEvent := Client_ProgressEvent1 -end; - - -destructor TRSA_Gen_Key_Helper.Destroy; -begin -FPool := nil; -inherited -end; - - -procedure TRSA_Gen_Key_Helper.PrimalityTest_Event( CountPrimalityTests: integer); -begin -end; - - -procedure TRSA_Gen_Key_Helper.Progress_Event( - Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); -begin -if assigned( FClient_ProgressEvent) then - FClient_ProgressEvent( Sender, FNumbersTested, doAbort) -end; - -{ TMonitor } - -constructor TMonitor.Create(Event: TOnEncDecProgress; Sender: TObject); -begin -FEvent := Event; -FSender := Sender -end; - -function TMonitor.OnProgress( - Sender: TObject; CountBytesProcessed: int64): boolean; -begin -// Discard the low-level 'Sender' -if assigned( FEvent) then - result := FEvent( FSender, CountBytesProcessed) - else - result := True -end; - -{ THugeCardinalWrap } - -procedure THugeCardinalWrap.Burn; -begin -if assigned( FValue) then - FValue.Burn -end; - -constructor THugeCardinalWrap.Create( Value1: THugeCardinal); -begin -FValue := Value1 -end; - -destructor THugeCardinalWrap.Destroy; -begin -FValue.Free; -inherited -end; - -function THugeCardinalWrap.IsZero: boolean; -begin -result := (not assigned( FValue)) or FValue.isZero -end; - -function THugeCardinalWrap.Value: THugeCardinal; -begin -result := FValue -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.RSA_Engine; +interface +uses Classes, TPLB3.StreamCipher, TPLB3.Asymetric, TPLB3.Codec, TPLB3.CodecIntf, + TPLB3.HugeCardinal, TPLB3.MemoryStreamPool, TPLB3.Compatibility; + +type +TRSA_Engine = class( TAsymetric_Engine) + protected + // ICryptoGraphicAlgorithm + function DisplayName: string; override; + function ProgId: string; override; + function Features: TAlgorithmicFeatureSet; override; + function DefinitionURL: string; override; + function WikipediaReference: string; override; + + // IStreamCipher = interface( ) + function LoadKeyFromStream( Store: TStream): TSymetricKey; override; + + function AsymetricKeyPairClass: TAsymetricKeyPairClass; override; + function EncClass: TAsymetricEncryptorClass; override; + function DecClass: TAsymetricDecryptorClass; override; + + public + procedure GenerateAsymetricKeyPair( + KeySizeInBits: cardinal; + ProgressSender: TObject; + ProgressEvent: TGenerateAsymetricKeyPairProgress; + var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); + override; + + function CreateFromStream( Store: TStream; Parts: TKeyStoragePartSet): + TAsymetricKeyPair; override; + end; + + const + RSAKeySig: packed array[0..9] of Byte = (78, 10, 76, 111, 99, 107, 66, 111, 120, 51); // #78#10'LockBox3'; + RSAKeyStoreVersion = 1; + + type + RSAKeyStorePart = (PartN, PartE, PartD, PartCRT); + RSAKeyStorePartSet = set of RSAKeyStorePart; + +IHugeCardinalWrap = interface + ['{27B8620A-903B-4695-80DD-20DA9D24BCC4}'] + function Value: THugeCardinal; + procedure Burn; + function IsZero: boolean; + end; + +TRSAKeyPair = class; +TRSAKeyPart = class( TAsymtricKeyPart) + protected + F_RSA_n: IHugeCardinalWrap; + FOwner: TRSAKeyPair; + function NominalKeyBitLength: cardinal; override; + procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); virtual; abstract; + procedure StoreE( Store: TStream); virtual; abstract; + procedure StoreD( Store: TStream); virtual; abstract; + procedure StoreCRT( Store: TStream); virtual; abstract; + procedure StoreSmallPartsToStream( const Parts: RSAKeyStorePartSet; Store: TStream); + procedure LoadE( Store: TStream); virtual; abstract; + procedure LoadD( Store: TStream); virtual; abstract; + procedure LoadCRT( Store: TStream); virtual; abstract; + procedure LoadSmallPartsFromStream( const Parts: RSAKeyStorePartSet; Store: TStream); + procedure SenseVersion( doReadPastHeader: boolean; Store: TStream; + var Version: integer; var AvailableParts: RSAKeyStorePartSet); + + public + procedure SaveToStream ( Store: TStream); override; + procedure LoadFromStream( Store: TStream); override; + procedure Burn; override; + end; + +TRSA_PublicKeyPart = class( TRSAKeyPart) + protected + procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); override; + procedure StoreE( Store: TStream); override; + procedure StoreD( Store: TStream); override; + procedure StoreCRT( Store: TStream); override; + procedure LoadE( Store: TStream); override; + procedure LoadD( Store: TStream); override; + procedure LoadCRT( Store: TStream); override; + public + F_RSA_e: IHugeCardinalWrap; + procedure Burn; override; + function isEmpty: boolean; override; + end; + +TRSA_PrivateKeyPart = class( TRSAKeyPart) + protected + procedure MarkPartsToStoreLoad( var Parts: RSAKeyStorePartSet); override; + procedure StoreE( Store: TStream); override; + procedure StoreD( Store: TStream); override; + procedure StoreCRT( Store: TStream); override; + procedure LoadE( Store: TStream); override; + procedure LoadD( Store: TStream); override; + procedure LoadCRT( Store: TStream); override; + public + F_RSA_d: IHugeCardinalWrap; + F_RSA_p, F_RSA_q, F_RSA_dp, F_RSA_dq, F_RSA_qinv: IHugeCardinalWrap; + procedure Burn; override; + function isEmpty: boolean; override; + end; + +TRSAKeyPair = class( TAsymetricKeyPair) + private + procedure LinkParts; + procedure CheckLinkages; + + protected + FPool: IMemoryStreamPool; + function StoreHugeCardinal( + Number: THugeCardinal; StoreStream: TStream): boolean; virtual; + function LoadHugeCardinal_IfNotAlready( + StoreStream: TStream; var Number: IHugeCardinalWrap): boolean; virtual; + + public + F_RSA_n, F_RSA_d, F_RSA_e: IHugeCardinalWrap; + F_RSA_p, F_RSA_q, F_RSA_dp, F_RSA_dq, F_RSA_qinv: IHugeCardinalWrap; + + constructor CreateEmpty; override; + destructor Destroy; override; + procedure LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); override; + procedure StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); override; + procedure Burn; override; + end; + +TRSA_Encryptor = class( TAsymetricEncryptor) + public + function GenerateSymetricKey: TSymetricKey; override; + function VerifySignature( + Document: TStream; // FCipherText is the signature to be verified. + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean): boolean; override; + end; + +TRSA_Decryptor = class( TAsymetricDecryptor) + public + function LoadSymetricKey( Ciphertext: TStream): TSymetricKey; override; + procedure Sign( // FPlaintext is the document to be signed. + Signature: TStream; + ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; + var wasAborted: boolean); override; + end; + +implementation + + + + + + + + + + + + + + + + + + +uses TPLB3.RSA_Primitives, SysUtils, Math, TPLB3.HugeCardinalUtils, + TPLB3.Constants, TPLB3.I18n; + +{ TRSA_Engine } + +function TRSA_Engine.AsymetricKeyPairClass: TAsymetricKeyPairClass; +begin +result := TRSAKeyPair +end; + +function TRSA_Engine.DecClass: TAsymetricDecryptorClass; +begin +result := TRSA_Decryptor +end; + +function TRSA_Engine.DefinitionURL: string; +begin +result := 'http://www.ietf.org/rfc/rfc3447.txt' +end; + + +function TRSA_Engine.DisplayName: string; +begin +result := RSA_DisplayName +end; + + + + + + +function TRSA_Engine.EncClass: TAsymetricEncryptorClass; +begin +result := TRSA_Encryptor +end; + + + +function TRSA_Engine.Features: TAlgorithmicFeatureSet; +begin +result := (inherited Features); +Include( result, afStar) +end; + + + +type TRSA_Gen_Key_Helper = class + private + FPool: IMemoryStreamPool; + FdoOwn: boolean; + FNumbersTested: integer; + FClient_ProgressEvent: TGenerateAsymetricKeyPairProgress; + + procedure Progress_Event( Sender: TObject; BitsProcessed, + TotalBits: int64; var doAbort: boolean); + procedure PrimalityTest_Event( CountPrimalityTests: integer); + + public + constructor Create( + Client_ProgressEvent1: TGenerateAsymetricKeyPairProgress; + const Pool1: IMemoryStreamPool); + destructor Destroy; override; + end; + + +THugeCardinalWrap = class( TInterfacedObject, IHugeCardinalWrap) + private + FValue: THugeCardinal; + function Value: THugeCardinal; + procedure Burn; + function IsZero: boolean; + public + constructor Create( Value1: THugeCardinal); + destructor Destroy; override; + end; + +function NewWrap( Value1: THugeCardinal): IHugeCardinalWrap; +begin +result := THugeCardinalWrap.Create( Value1) +end; + +procedure TRSA_Engine.GenerateAsymetricKeyPair( + KeySizeInBits: cardinal; ProgressSender: TObject; + ProgressEvent: TGenerateAsymetricKeyPairProgress; + var KeyPair: TAsymetricKeyPair; var wasAborted: boolean); +var + RSAKeyPair: TRSAKeyPair; + N, e, d, Totient: THugeCardinal; + p, q, dp, dq, qinv: THugeCardinal; // For use with CRT. + GeneratePrimePassCount: integer; // 1 .. 20; + Helper: TRSA_Gen_Key_Helper; +begin +RSAKeyPair := AsymetricKeyPairClass.CreateEmpty as TRSAKeyPair; + +GeneratePrimePassCount := 5; +Helper := TRSA_Gen_Key_Helper.Create( ProgressEvent, RSAKeyPair.FPool); +Totient := nil; + +try +TPLB3.HugeCardinalUtils.Compute_RSA_Fundamentals_2Factors( + KeySizeInBits, StandardExponent, N, e, d, Totient, + p, q, dp, dq, qinv, + Helper.Progress_Event, Helper.PrimalityTest_Event, + GeneratePrimePassCount, RSAKeyPair.FPool, Helper.FNumbersTested, wasAborted); + +if not wasAborted then + begin + RSAKeyPair.F_RSA_n := NewWrap( N); + RSAKeyPair.F_RSA_d := NewWrap( d); + RSAKeyPair.F_RSA_e := NewWrap( e); + RSAKeyPair.F_RSA_p := NewWrap( p); + RSAKeyPair.F_RSA_q := NewWrap( q); + RSAKeyPair.F_RSA_dp := NewWrap( dp); + RSAKeyPair.F_RSA_dq := NewWrap( dq); + RSAKeyPair.F_RSA_qinv := NewWrap( qinv); + RSAKeyPair.LinkParts + end + else + begin + N.Free; d.Free; e.Free; + p.Free; q.Free; dp.Free; dq.Free; qinv.Free; + end +finally + Totient.Free; + Helper.Free + end; +KeyPair := RSAKeyPair +end; + + + +function TRSA_Engine.CreateFromStream( + Store: TStream; Parts: TKeyStoragePartSet): TAsymetricKeyPair; +begin +result := TRSAKeyPair.CreateEmpty; +result.LoadFromStream( Store, Parts) +end; + + +function TRSA_Engine.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := CreateFromStream( Store, [partPublic, partPrivate]) +end; + + +function TRSA_Engine.ProgId: string; +begin +result := RSA_ProgId +end; + + +function TRSA_Engine.WikipediaReference: string; +begin +result := 'RSA' +end; + + + +{ TRSAKeyPart } + +procedure TRSAKeyPart.Burn; +begin +F_RSA_n.Burn +end; + + +function TRSAKeyPart.NominalKeyBitLength: cardinal; +var + Xtra: cardinal; +begin +result := F_RSA_n.Value.BitLength; +Xtra := result mod 8; +if Xtra > 0 then + Inc( result, 8 - Xtra) +end; + + +procedure TRSAKeyPart.StoreSmallPartsToStream( const Parts: RSAKeyStorePartSet; Store: TStream); +var + Version: integer; +begin +Store.WriteBuffer( RSAKeySig[0], Length( RSAKeySig)); +Version := RSAKeyStoreVersion; +Store.WriteBuffer( Version, SizeOf( Version)); +Store.WriteBuffer( Parts, SizeOf( Parts)); +if (PartN in Parts) and assigned( FOwner) then + FOwner.StoreHugeCardinal( F_RSA_n.Value, Store); +if (PartE in Parts) and assigned( FOwner) then + StoreE( Store); +if (PartD in Parts) and assigned( FOwner) then + StoreD( Store); +if (PartCRT in Parts) and assigned( FOwner) then + StoreCRT( Store); +end; + + +procedure TRSAKeyPart.SaveToStream( Store: TStream); +var + PartsToStore: RSAKeyStorePartSet; +begin +PartsToStore := [PartN]; +MarkPartsToStoreLoad( PartsToStore); +StoreSmallPartsToStream( PartsToSTore, Store) +//FOwner.StoreHugeCardinal( F_RSA_n, Store) +end; + +procedure TRSAKeyPart.SenseVersion( + doReadPastHeader: boolean; Store: TStream; + var Version: integer; + var AvailableParts: RSAKeyStorePartSet); +var + Sig: packed array[0..9] of Byte; + ReadCount, Count: integer; + Ok: boolean; +begin +ReadCount := Store.Read( Sig[0], Length( Sig)); +Ok := (ReadCount = Length( Sig)) and CompareMem( @Sig[0], @RSAKeySig[0], Length( Sig)); +if Ok then + begin + Count := Store.Read( Version, SizeOf( Version)); + Inc( ReadCount, Count); + Ok := (Count = SizeOf( Version)) and (Version >= 1) + end; +if Ok then + begin + Count := Store.Read( AvailableParts, SizeOf( AvailableParts)); + Inc( ReadCount, Count); + Ok := Count = SizeOf( AvailableParts) + end; +if (not Ok) or (not doReadPastHeader) then + Store.Seek( -ReadCount, soCurrent); +if not Ok then + begin + Version := 0; + AvailableParts := [] + end +end; + +procedure TRSAKeyPart.LoadSmallPartsFromStream( const Parts: RSAKeyStorePartSet; Store: TStream); +var + Version: integer; + // Sig: utf8string; + AvailableParts, PartsToLoad: RSAKeyStorePartSet; +begin +SenseVersion( True, Store, Version, AvailableParts); +if Version > RSAKeyStoreVersion then + raise Exception.Create('Invalid or unrecognised format for RSA key'); +if Version >= 1 then + begin + if (Parts - AvailableParts - [PartCRT]) <> [] then + raise Exception.Create('Error Message'); + PartsToLoad := Parts - [PartCRT]; + if ((Parts * [PartD, PartCRT]) <> []) and + (PartCRT in AvailableParts) then + Include( PartsToLoad, PartCRT); + end + else + PartsToLoad := []; +if assigned( FOwner) then + FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_n); +if PartE in PartsToLoad then + LoadE( Store); +if PartD in PartsToLoad then + LoadD( Store); +if PartCRT in PartsToLoad then + LoadCRT( Store) +end; + + +procedure TRSAKeyPart.LoadFromStream( Store: TStream); +var + PartsToLoad: RSAKeyStorePartSet; +begin +PartsToLoad := [PartN]; +MarkPartsToStoreLoad( PartsToLoad); +LoadSmallPartsFromStream( PartsToLoad, Store) +// FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_n) +end; + + + + +{ TRSA_Encryptor } + +function TRSA_Encryptor.GenerateSymetricKey: TSymetricKey; +var + Key: TRSA_PublicKeyPart; +begin +Key := FPublicKey as TRSA_PublicKeyPart; +result := Generate_RSA_SymetricKey( + Key.F_RSA_n.Value, Key.F_RSA_e.Value, FCipherText, FSymetricCodec.BlockCipher) +end; + + +type +TMonitor = class + private + FSender: TObject; + FEvent: TOnEncDecProgress; + function OnProgress( Sender: TObject; CountBytesProcessed: int64): boolean; + public + constructor Create( Event: TOnEncDecProgress; Sender: TObject); + end; + + +function TRSA_Encryptor.VerifySignature( + Document: TStream; ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; var wasAborted: boolean): boolean; +var + Key: TRSA_PublicKeyPart; + Monitor: TMonitor; + OpRes: TLongOpResult; +begin +Key := FPublicKey as TRSA_PublicKeyPart; +wasAborted := False; +result := assigned( Key) and + assigned( Key.F_RSA_n) and (not Key.F_RSA_n.isZero) and + assigned( Key.F_RSA_e) and (not Key.F_RSA_e.isZero); +if result then + begin + Monitor := TMonitor.Create( ProgressEvent, ProgressSender); + try + OpRes := RSASSA_PSS_VERIFY( Key.F_RSA_n.Value, Key.F_RSA_e.Value, Document, FCipherText, + Monitor.OnProgress) + finally + Monitor.Free; + end; + result := OpRes = opPass; + wasAborted := OpRes = opAbort + end +end; + + + +function UnWrap( const Wrap: IHugeCardinalWrap): THugeCardinal; +begin +if assigned( Wrap) then + result := Wrap.Value + else + result := nil +end; + +{ TRSA_Decryptor } + +function TRSA_Decryptor.LoadSymetricKey( Ciphertext: TStream): TSymetricKey; +var + Key: TRSA_PrivateKeyPart; +begin +Key := FPrivateKey as TRSA_PrivateKeyPart; +result := Extract_RSA_SymetricKey( + UnWrap( Key.F_RSA_d), UnWrap( Key.F_RSA_n), + UnWrap( Key.F_RSA_p), UnWrap( Key.F_RSA_q), UnWrap( Key.F_RSA_dp), UnWrap( Key.F_RSA_dq), UnWrap( Key.F_RSA_qinv), + Ciphertext, FSymetricCodec.BlockCipher) +end; + + + + +procedure TRSA_Decryptor.Sign( + Signature: TStream; ProgressSender: TObject; + ProgressEvent: TOnEncDecProgress; var wasAborted: boolean); +var + Succeeded: boolean; + Key: TRSA_PrivateKeyPart; + OpRes: TLongOpResult; + Monitor: TMonitor; +begin +wasAborted := False; +Key := FPrivateKey as TRSA_PrivateKeyPart; +Succeeded := assigned( Key) and + assigned( Key.F_RSA_d) and (not Key.F_RSA_d.isZero) and + assigned( Key.F_RSA_n) and (not Key.F_RSA_n.isZero); +if Succeeded then + begin + Monitor := TMonitor.Create( ProgressEvent, ProgressSender); + try + OpRes := TPLB3.RSA_Primitives.RSASSA_PSS_SIGN( + UnWrap( Key.F_RSA_d), UnWrap( Key.F_RSA_n), FPlainText, Signature, Monitor.OnProgress, + UnWrap( Key.F_RSA_p), UnWrap( Key.F_RSA_q), UnWrap( Key.F_RSA_dp), UnWrap( Key.F_RSA_dq), UnWrap( Key.F_RSA_qinv)) + finally + Monitor.Free + end; +// Succeeded := OpRes = opPass; + wasAborted := opRes = opAbort + // Discard Succeeded. It should be impossible to fail. + end +end; + + + + +function StoreHugeCardinal_Primitive( + Number: THugeCardinal; StoreStream: TStream): boolean; +// Stores the number in the stream using the cannonical format. +// Returns True if the Number was assigned. +var + L: cardinal; +begin +result := assigned( Number); +if result then + L := (Number.BitLength + 7) div 8 + else + L := 0; +if not assigned( StoreStream) then exit; +StoreStream.WriteBuffer( L, SizeOf( L)); +if L > 0 then + Number.StreamOut( LittleEndien, StoreStream, L) +end; + + +function LoadHugeCardinal_Primitive( + StoreStream: TStream; const Pool1: IMemoryStreamPool): THugeCardinal; +// Loads the number from the stream using the cannonical format. +var + L: cardinal; + ValueStream: TMemoryStream; +begin +StoreStream.Read( L, SizeOf( L)); +ValueStream := TMemoryStream.Create; +try +StoreStream.ReadBuffer( ValueStream.Memory^, L); +ValueStream.Position := 0; +result := THugeCardinal.CreateFromStreamIn( + L*8, LittleEndien, ValueStream, Pool1) +finally +ValueStream.Free +end end; + + + +function TRSAKeyPair.StoreHugeCardinal( + Number: THugeCardinal; StoreStream: TStream): boolean; + // virtual method. +begin +result := StoreHugeCardinal_Primitive( Number, StoreStream) +end; + + +procedure TRSAKeyPair.StoreToStream( Store: TStream; Parts: TKeyStoragePartSet); +var + SmallParts: RSAKeyStorePartSet; +begin +if Parts = [] then + SmallParts := [] + else + SmallParts := [PartN]; +if partPublic in Parts then + (FPublicPart as TRSAKeyPart).MarkPartsToStoreLoad( SmallParts); +if partPrivate in Parts then + (FPrivatePart as TRSAKeyPart).MarkPartsToStoreLoad( SmallParts); +if FPublicPart is TRSAKeyPart then + TRSAKeyPart( FPublicPart).StoreSmallPartsToStream( SmallParts, Store) + else + (FPrivatePart as TRSAKeyPart).StoreSmallPartsToStream( SmallParts, Store) +//if Parts <> [] then +// StoreHugeCardinal( F_RSA_n, Store); +//if partPublic in Parts then +// StoreHugeCardinal( F_RSA_e, Store); +//if partPrivate in Parts then +// StoreHugeCardinal( F_RSA_d, Store) +end; + + +function TRSAKeyPair.LoadHugeCardinal_IfNotAlready( + StoreStream: TStream; var Number: IHugeCardinalWrap): boolean; + // virtual method. +var + L: cardinal; + ValueStream: TMemoryStream; +begin +result := not assigned( Number); +if not result then exit; // Only load if we are not already loaded. +StoreStream.ReadBuffer( L, SizeOf( L)); +ValueStream := TMemoryStream.Create; +try +ValueStream.Size := L; +if L > 0 then + StoreStream.ReadBuffer( ValueStream.Memory^, L); +ValueStream.Position := 0; +Number := NewWrap( THugeCardinal.CreateFromStreamIn( + L*8, LittleEndien, ValueStream, FPool)) +finally +ValueStream.Free +end; +if Number.isZero then + Number := nil +end; + + +{ TRSA_PublicKeyPart } + +procedure TRSA_PublicKeyPart.Burn; +begin +inherited; +F_RSA_e.Burn +end; + +function TRSA_PublicKeyPart.isEmpty: boolean; +begin +result := (not assigned( F_RSA_e)) or F_RSA_e.isZero +end; + + +procedure TRSA_PublicKeyPart.LoadCRT( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPrivatePart).LoadCRT( Store) +end; + +procedure TRSA_PublicKeyPart.LoadD( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPrivatePart).LoadD( Store) +end; + +procedure TRSA_PublicKeyPart.LoadE( Store: TStream); +begin +if assigned( FOwner) then + FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_e) +end; + + + +procedure TRSA_PublicKeyPart.MarkPartsToStoreLoad( + var Parts: RSAKeyStorePartSet); +begin +Include( Parts, PartE) +end; + + + +procedure TRSA_PublicKeyPart.StoreCRT( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPrivatePart).StoreCRT( Store) +end; + +procedure TRSA_PublicKeyPart.StoreD( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPrivatePart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPrivatePart).StoreD( Store) +end; + +procedure TRSA_PublicKeyPart.StoreE( Store: TStream); +begin +if assigned( FOwner) then + FOwner.StoreHugeCardinal( F_RSA_e.Value, Store) +end; + +{ TRSA_PrivateKeyPart } + +procedure TRSA_PrivateKeyPart.Burn; +begin +inherited; +F_RSA_d.Burn +end; + + +function TRSA_PrivateKeyPart.isEmpty: boolean; +begin +result := (not assigned( F_RSA_d)) or F_RSA_d.isZero +end; + +procedure TRSA_PrivateKeyPart.LoadCRT( Store: TStream); +begin +if not assigned( FOwner) then exit; +FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_p); +FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_q); +FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_dp); +FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_dq); +FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_qinv) +end; + +procedure TRSA_PrivateKeyPart.LoadD( Store: TStream); +begin +if assigned( FOwner) then + FOwner.LoadHugeCardinal_IfNotAlready( Store, F_RSA_d) +end; + +procedure TRSA_PrivateKeyPart.LoadE( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPublicPart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPublicPart).LoadE( Store) +end; + + + +procedure TRSA_PrivateKeyPart.MarkPartsToStoreLoad( + var Parts: RSAKeyStorePartSet); +begin +Include( Parts, PartD); +if assigned( F_RSA_qinv) then + Include( Parts, PartCRT) +end; + + + +procedure TRSA_PrivateKeyPart.StoreCRT( Store: TStream); +begin +if not assigned( FOwner) then exit; +FOwner.StoreHugeCardinal( F_RSA_p.Value, Store); +FOwner.StoreHugeCardinal( F_RSA_q.Value, Store); +FOwner.StoreHugeCardinal( F_RSA_dp.Value, Store); +FOwner.StoreHugeCardinal( F_RSA_dq.Value, Store); +FOwner.StoreHugeCardinal( F_RSA_qinv.Value, Store) +end; + +procedure TRSA_PrivateKeyPart.StoreD( Store: TStream); +begin +if assigned( FOwner) then + FOwner.StoreHugeCardinal( F_RSA_d.Value, Store) +end; + +procedure TRSA_PrivateKeyPart.StoreE( Store: TStream); +begin +if assigned( FOwner) and (FOwner.FPublicPart is TRSAKeyPart) then + TRSAKeyPart( FOwner.FPublicPart).StoreE( Store) +end; + +{ TRSAKeyPair } + +procedure TRSAKeyPair.Burn; +begin +if assigned( F_RSA_n) then + F_RSA_n.Burn; +if assigned( F_RSA_e) then + F_RSA_e.Burn; +if assigned( F_RSA_d) then + F_RSA_d.Burn; +if assigned( F_RSA_p) then + F_RSA_p.Burn; +if assigned( F_RSA_q) then + F_RSA_q.Burn; +if assigned( F_RSA_dp) then + F_RSA_dp.Burn; +if assigned( F_RSA_dq) then + F_RSA_dq.Burn; +if assigned( F_RSA_qinv) then + F_RSA_qinv.Burn; +F_RSA_n := nil; +F_RSA_d := nil; +F_RSA_e := nil; +F_RSA_p := nil; +F_RSA_q := nil; +F_RSA_dp := nil; +F_RSA_dq := nil; +F_RSA_qinv := nil; +LinkParts +end; + + + +constructor TRSAKeyPair.CreateEmpty; +begin +FPool := NewPool; +F_RSA_n := nil; +F_RSA_d := nil; +F_RSA_e := nil; +F_RSA_p := nil; +F_RSA_q := nil; +F_RSA_dp := nil; +F_RSA_dq := nil; +F_RSA_qinv := nil; +FPublicPart := TRSA_PublicKeyPart.Create; +FPrivatePart := TRSA_PrivateKeyPart.Create; +LinkParts; +end; + + + +procedure TRSAKeyPair.LinkParts; +begin +(FPublicPart as TRSA_PublicKeyPart).FOwner := self; +(FPublicPart as TRSA_PublicKeyPart).F_RSA_n := F_RSA_n; +(FPublicPart as TRSA_PublicKeyPart).F_RSA_e := F_RSA_e; + +(FPrivatePart as TRSA_PrivateKeyPart).FOwner := self; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_n := F_RSA_n; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d := F_RSA_d; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_p := F_RSA_p; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_q := F_RSA_q; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_dp := F_RSA_dp; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_dq := F_RSA_dq; +(FPrivatePart as TRSA_PrivateKeyPart).F_RSA_qinv := F_RSA_qinv; +end; + + +procedure TRSAKeyPair.CheckLinkages; +begin +if not ( + (FPublicPart is TRSA_PublicKeyPart ) and + (FPrivatePart is TRSA_PrivateKeyPart) and + (TRSA_PublicKeyPart( FPublicPart).FOwner = self) and + (TRSA_PublicKeyPart( FPublicPart).F_RSA_n = F_RSA_n) and + (TRSA_PublicKeyPart( FPublicPart).F_RSA_e = F_RSA_e) and + (TRSA_PrivateKeyPart( FPrivatePart).FOwner = self) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_n = F_RSA_n) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_d = F_RSA_d) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p = F_RSA_p) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q = F_RSA_q) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp = F_RSA_dp) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq = F_RSA_dq) and + (TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv = F_RSA_qinv)) then + raise Exception.Create('TRSAKeyPair linkage error.'); +end; + + +destructor TRSAKeyPair.Destroy; +begin +F_RSA_n := nil; +F_RSA_d := nil; +F_RSA_e := nil; +F_RSA_p := nil; +F_RSA_q := nil; +F_RSA_dp := nil; +F_RSA_dq := nil; +F_RSA_qinv := nil; +FPool := nil; +inherited +end; + + + +procedure TRSAKeyPair.LoadFromStream( Store: TStream; Parts: TKeyStoragePartSet); +var + Version: integer; + AvailableParts, PartsToLoad: RSAKeyStorePartSet; +begin +(FPublicPart as TRSA_PublicKeyPart).SenseVersion( False, Store, Version, AvailableParts); +if Parts <> [] then + begin + F_RSA_n := nil; + (FPublicPart as TRSA_PublicKeyPart).F_RSA_n := nil; + TRSA_PublicKeyPart( FPublicPart).F_RSA_n := nil; + end; +if partPublic in Parts then + begin + F_RSA_e := nil; + TRSA_PublicKeyPart ( FPublicPart).F_RSA_e := nil; + end; +if partPrivate in Parts then + begin + F_RSA_d := nil; + F_RSA_p := nil; + F_RSA_q := nil; + F_RSA_dp := nil; + F_RSA_dq := nil; + F_RSA_qinv := nil; + (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d := nil; + TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p := nil; + TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q := nil; + TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp := nil; + TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq := nil; + TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv := nil; + end; +if Version = 0 then + begin + if Parts <> [] then + LoadHugeCardinal_IfNotAlready( Store, F_RSA_n); + if partPublic in Parts then + LoadHugeCardinal_IfNotAlready( Store, F_RSA_e); + if partPrivate in Parts then + LoadHugeCardinal_IfNotAlready( Store, F_RSA_d); + LinkParts + end + else + begin + PartsToLoad := []; + if Parts <> [] then + Include( PartsToLoad, PartN); + if partPublic in Parts then + Include( PartsToLoad, PartE); + if partPrivate in Parts then + begin + Include( PartsToLoad, PartD); + Include( PartsToLoad, PartCRT); + end; + (FPublicPart as TRSA_PublicKeyPart).LoadSmallPartsFromStream( PartsToLoad, Store); + // n and e are loaded into the public key. + // d, dp, dq, p, q & qinv are loaded into the private key. + F_RSA_n := (FPublicPart as TRSA_PublicKeyPart).F_RSA_n; + F_RSA_e := (FPublicPart as TRSA_PublicKeyPart).F_RSA_e; + (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_n := F_RSA_n; + F_RSA_d := (FPrivatePart as TRSA_PrivateKeyPart).F_RSA_d; + F_RSA_p := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_p; + F_RSA_q := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_q; + F_RSA_dp := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dp; + F_RSA_dq := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_dq; + F_RSA_qinv := TRSA_PrivateKeyPart( FPrivatePart).F_RSA_qinv + end; +CheckLinkages +end; + + + + + +{ TRSA_Gen_Key_Helper } + +constructor TRSA_Gen_Key_Helper.Create( + Client_ProgressEvent1: TGenerateAsymetricKeyPairProgress; + const Pool1: IMemoryStreamPool); +begin +FPool := Pool1; +FdoOwn := not assigned( FPool); +if FdoOwn then + FPool := NewPool; +FNumbersTested := 0; +FClient_ProgressEvent := Client_ProgressEvent1 +end; + + +destructor TRSA_Gen_Key_Helper.Destroy; +begin +FPool := nil; +inherited +end; + + +procedure TRSA_Gen_Key_Helper.PrimalityTest_Event( CountPrimalityTests: integer); +begin +end; + + +procedure TRSA_Gen_Key_Helper.Progress_Event( + Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); +begin +if assigned( FClient_ProgressEvent) then + FClient_ProgressEvent( Sender, FNumbersTested, doAbort) +end; + +{ TMonitor } + +constructor TMonitor.Create(Event: TOnEncDecProgress; Sender: TObject); +begin +FEvent := Event; +FSender := Sender +end; + +function TMonitor.OnProgress( + Sender: TObject; CountBytesProcessed: int64): boolean; +begin +// Discard the low-level 'Sender' +if assigned( FEvent) then + result := FEvent( FSender, CountBytesProcessed) + else + result := True +end; + +{ THugeCardinalWrap } + +procedure THugeCardinalWrap.Burn; +begin +if assigned( FValue) then + FValue.Burn +end; + +constructor THugeCardinalWrap.Create( Value1: THugeCardinal); +begin +FValue := Value1 +end; + +destructor THugeCardinalWrap.Destroy; +begin +FValue.Free; +inherited +end; + +function THugeCardinalWrap.IsZero: boolean; +begin +result := (not assigned( FValue)) or FValue.isZero +end; + +function THugeCardinalWrap.Value: THugeCardinal; +begin +result := FValue +end; + +end. diff --git a/run/TPLB3.RSA_Primitives.pas b/LockBox3/run/TPLB3.RSA_Primitives.pas similarity index 96% rename from run/TPLB3.RSA_Primitives.pas rename to LockBox3/run/TPLB3.RSA_Primitives.pas index 4b71739..5e70412 100644 --- a/run/TPLB3.RSA_Primitives.pas +++ b/LockBox3/run/TPLB3.RSA_Primitives.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,1304 +12,1304 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.RSA_Primitives; -// This unit implements the primitives specified in RFC-3447 -// http://www.ietf.org/rfc/rfc3447.txt & -// http://www.rfc-editor.org/errata_search.php?rfc=3447 - -interface -uses - TPLB3.HugeCardinal, Classes, TPLB3.MemoryStreamPool, TPLB3.StreamCipher, - TPLB3.BlockCipher, TPLB3.Hash; - -function I2OSP( x: THugeCardinal; xLen: integer; - XStream: TStream; const Pool: IMemoryStreamPool): boolean; -// Integer-to-Octet-String primitive -// I2OSP converts a huge cardinal to a byte stream of the specified length. -// Inputs: -// x The number to be converted. -// xLen The intended length in bytes of the output octet stream. -// Pool Optional memory stream pool for re-cycling memory. -// Outputs: -// XStream The corresponding octet stream is written to this TStream -// at the input position. The stream is not resized or repositioned -// before output. -// result Returns True if the operation was successful; -// False if xLen was too small for x. - - -function OS2IP( XStream: TStream; xLen: integer; - var x: THugeCardinal; - const Pool: IMemoryStreamPool; MaxBits: integer): boolean; -// Octet-String-to-Integer primitive -// OS2IP converts byte stream of the specified length to a new huge cardinal. -// Inputs: -// XStream The octet stream to be converted. -// The stream is not resized or repositioned -// before reading, but is read from its current (input) position. -// xLen The length in bytes of the octet stream to be read. The -// stream must have this many bytes readable or an exception -// will be raised. (units are bytes) -// Pool Construction parameter for huge cardinal. -// MaxBits Construction parameter for huge cardinal. (units are bits) -// Outputs: -// x The number converted to. On input this is nil or dangling. -// On output, a new THugeCardinal is created. -// result Returns True if the operation was successful; -// False if xLen was too large for MaxBits. - - -procedure MGF1( mgfSeed: TStream; maskLen: cardinal; mask: TStream); -// MGF1 is a Mask Generation Function based on SHA-1. -// Inputs: -// mgfSeed The octet stream which seeds deterministically the output. -// The seed is the whole stream. -// maskLen The intented length in bytes of the output mask. -// Outputs: -// mask The mask or output stream created. Must not be nil on input. - - -type -TLongOpResult = (opPass, opFail, opAbort); - - -function RSAES_OAEP_ENCRYPT( n, e: THugeCardinal; M, C: TMemoryStream): boolean; -// RSAES-OAEP-ENCRYPT is the RSA encryption primitive. -// Inputs: -// n The RSA encryption public key modulus. -// e The RSA encryption public key exponent. -// M The plaintext to be encrypted. -// Outputs: -// C The encrypted ciphertext. This stream is cleared on input. -// The byte length of C, mlen must not more the byte length of -// the modulus (k), less twice the hash length (hLen), less 2. -// mLen <= k - 2 * hLen - 2 -// The hash used is SHA-1, so hLen = 20. -// result True if successful; False if failed. - - -function RSAES_OAEP_ENCRYPT_MaxByteLen( n: THugeCardinal): integer; -// Computes the maximum byte length for M in the RSAES_OAEP_ENCRYPT function. -// Inputs: -// n The RSA encryption public key modulus. -// Outputs: -// result The maximum byte length for M. See comments about the -// RSAES_OAEP_ENCRYPT function. -// result := k - 2 * hLen - 2 - - -function RSAES_OAEP_DECRYPT( d, n: THugeCardinal; C, M: TStream; - p, q, dp, dq, qinv: THugeCardinal): boolean; -// RSAES-OAEP-DECRYPT is the RSA decryption primitive. -// Inputs: -// n The RSA encryption public key modulus. -// d The RSA encryption private key exponent. -// C The ciphertext to be decrypted. Length = length of n in bytes. -// p, q, dp, dq, qinv: Optional break-down of d for use in CRT. -// Outputs: -// M The decrypted plaintext. This stream is cleared on input. -// The hash used is SHA-1, so hLen = 20. -// result True if successful; False if failed. - - -function EMSA_PSS_ENCODE( M: TStream; emBits, sLen: integer; EM: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -// EMSA-PSS-ENCODE is the RSA message encoding primitive used by Sign & Verify. -// Inputs: -// M message to be encoded, an octet string. -// emBits maximal bit length of the integer OS2IP (EM), -// at least 8hLen + 8sLen + 9 -// sLen Intended length in octets of the salt -// Outputs: -// EM encoded message, an octet string of length emLen = \ceil -// (emBits/8) -// result True if successful; False if failed (due to emBits being too small.) -// Using: -// Hash hash function (hLen denotes the length in octets of the hash -// function output) used is SHA-1. -// MGF mask generation function uses is MGF1. - - -function RSASSA_PSS_SIGN( d, n: THugeCardinal; M, S: TStream; - CheckAbortFunc: TOnHashProgress; - p, q, dp, dq, qinv: THugeCardinal): TLongOpResult; -// RSASSA-PSS-SIGN is the RSA signature generation primitive. -// Inputs: -// d The signer's RSA private key exponent. -// n The signer's RSA public key modulus. -// M The message to be signed. -// Outputs: -// S The signature. -// result = opPass The operation was successful. -// = opFail The operation failed for some reason other than user abort. -// = opAbort The operation was aborted by the user before it could be completed. - - -function EMSA_PSS_VERIFY( M: TStream; emBits, sLen: integer; EM: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -// EMSA-PSS-VERIFY -// It is the inverse of EMSA-PSS-ENCODE - - -function RSASSA_PSS_VERIFY( n, e: THugeCardinal; M, S: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -// RSASSA-PSS-VERIFY -// Inputs: -// n The signer's RSA public key modulus. -// e The signer's RSA private key exponent. -// M The message whose signature is to be verified. -// S The signature to be verified. -// Outputs: -// result = opPass The verification passed. -// = opFail The verification failed for some reason other than user abort. -// = opAbort The verification was aborted by the user before it could be completed. - - -function Generate_RSA_SymetricKey( - n, e: THugeCardinal; CipherStream: TStream; - const SymetricCipher: IBlockCipher): TSymetricKey; - -function Extract_RSA_SymetricKey( - d, n, p, q, dp, dq, qinv: THugeCardinal; CipherStream: TStream; - const SymetricCipher: IBlockCipher): TSymetricKey; - -{$IF compilerversion > 15} -{$REGION 'Algorithm archive'} -{$IFEND} -var - // Set the following variable to a non-zero value access older behaviour. - // Or leave as zero for default. - RSA_Primitives_AlgorithmVersion: integer = 0; - -const - V3_0_0_BaseIdx = 1; - RSA_Primitives_Algorithm: array[ 0..V3_0_0_BaseIdx {Insert RSA_Primitives_AlgorithmVersion here}] of record - TPLB3_Version_Low, TPLB3_Version_High: string; - end = ( - {0, The current version ==> } ( TPLB3_Version_Low: '3.4.1'; TPLB3_Version_High: ''), - {1, An older version ==> } ( TPLB3_Version_Low: '3.0.0'; TPLB3_Version_High: '3.4.0')); -{$IF compilerversion > 15} -{$ENDREGION} -{$IFEND} - -var - UseCRT: boolean = True; - -implementation - - - - - - - - -uses TPLB3.PointerArithmetic, SysUtils, Math, TPLB3.SHA1, - TPLB3.HashDsc, TPLB3.StreamUtils, SyncObjs, TPLB3.Random, TPLB3.I18n; - - -var - hLen1: integer = -1; - HashOfNil: TMemoryStream = nil; - GlobalsGate: TCriticalSection; - -function CreateHashDscObject( var Obj: TObject): IHashDsc; -begin -result := nil; -Obj := TSHA1.Create; -Supports( Obj, IHashDsc, result) -end; - - -function AcquireHash( var Obj: TObject): IHash; -var - HashObj: TSimpleHash; - Dsc: TObject; -begin -result := nil; -HashObj := TSimpleHash.Create; -Obj := HashObj; -Supports( Obj, IHash, result); -result.Hash := CreateHashDscObject( Dsc) -end; - - -procedure ReleaseHash( Obj: TObject; var H: IHash); -begin -H := nil; -Obj.Free -end; - - -function hLen: integer; -var - H: TObject; - HI: IHashDsc; -begin -if hLen1 = -1 then - begin - HI := CreateHashDscObject( H); - hLen1 := HI.DigestSize div 8; - HI := nil; - end; -result := hLen1 -end; - - -procedure ReleaseHashSharedObjects; -begin -hLen1 := -1 -end; - -procedure InitUnit_RSA_Primitives; -begin -hLen1 := -1; -HashOfNil := nil; -GlobalsGate := TCriticalSection.Create -{$IFDEF RELEASE}; -// Release configuration build. -{$ENDIF} -{$IFDEF DEBUG}; -// Debug configuration build. -{$ENDIF} -{$IFDEF SI}; -Si.Enabled := True; -SiMain.ClearLog; -{$ENDIF} -end; - - -procedure DoneUnit_RSA_Primitives; -begin -FreeAndNil( GlobalsGate); -FreeAndNil( HashOfNil) -end; - - - - -function I2OSP( x: THugeCardinal; xLen: integer; XStream: TStream; - const Pool: IMemoryStreamPool): boolean; -begin -result := xLen >= ((x.BitLength + 7) div 8); -if result then - x.StreamOut( BigEndien, XStream, xLen) -end; - - - -function OS2IP( XStream: TStream; xLen: integer; - var x: THugeCardinal; - const Pool: IMemoryStreamPool; MaxBits: integer): boolean; -begin -if (RSA_Primitives_AlgorithmVersion <> V3_0_0_BaseIdx) and - ((XStream.Size - XStream.Position) <> xLen) then - raise Exception.Create('OS2IP wrong parameter'); -try - x := THugeCardinal.CreateFromStreamIn( MaxBits, BigEndien, XStream, Pool); - result := Assigned( x) -except - x := nil; - result := False -end end; - - - - -procedure MGF1( mgfSeed: TStream; maskLen: cardinal; mask: TStream); -var - Counter: longword; - HashObj: TObject; - Hash: IHash; - xfer: integer; - Buffer: array[0..99] of byte; - // Assume SizeOf( Buffer) >= (TSHA1.DigestSize div 8) -begin -mask.Size := 0; -if maskLen <= 0 then exit; -Hash := AcquireHash( HashObj); -try -Counter := 0; -repeat - Hash.Begin_Hash; - Hash.UpdateMemory( Counter, SizeOf(Counter)); - mgfSeed.Position := 0; - repeat - xfer := mgfSeed.Read( Buffer, SizeOf( Buffer)); - if xfer > 0 then - Hash.UpdateMemory( Buffer, xfer); - until xfer < SizeOf( Buffer); - Hash.End_Hash; - xfer := Min( maskLen, Hash.Hash.DigestSize div 8); // = 20 bytes for SHA-1 - Hash.HashOutputValue.ReadBuffer( Buffer, xfer); - mask.WriteBuffer( Buffer, xfer); - Dec( maskLen, xfer); - Inc( Counter) -until maskLen <= 0; -finally - ReleaseHash( HashObj, Hash) -end end; - - - -function RSAES_OAEP_ENCRYPT_MaxByteLen( n: THugeCardinal): integer; -begin -if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then - result := ((n.BitLength - 1) div 8) - (2 * hLen) - 2 -else - result := ((n.BitLength + 7) div 8) - (2 * hLen) - 2; -if result < 0 then - result := 0 -end; - - -procedure CheckHashOfNil; -var - HI: IHash; - H: TObject; -begin -GlobalsGate.Enter; -try -if assigned( HashOfNil) then exit; -HashOfNil := TMemoryStream.Create; -HI := AcquireHash( H); -HI.Begin_Hash; -HI.End_Hash; -HashOfNil.CopyFrom( HI.HashOutputValue, 0); -ReleaseHash( H, HI) -finally -GlobalsGate.Leave -end end; - - -function RSAES_OAEP_ENCRYPT( n, e: THugeCardinal; M, C: TMemoryStream): boolean; -var - mLen: integer; - k: integer; // Largest number of bytes that guarentees a number from those bytes is less than n - j: integer; - DB, Seed, dbMask, maskedDB, seedMask, maskedSeed, EM: TMemoryStream; - m1: THugeCardinal; -{$IFDEF SI} - Ok: boolean; -{$ENDIF} - - function NewMemoryStream: TMemoryStream; - begin - if assigned( n.FPool) then - result := n.FPool.NewMemoryStream( 0) - else - result := TMemoryStream.Create - end; - - procedure PutByte( S: TStream; byte1: byte); - begin - S.Write( byte1, 1) - end; - -begin -{$IFDEF SI} -SiMain.EnterMethod( 'RSAES_OAEP_ENCRYPT'); -SiMain.LogStream( 'n', n.FValue); -SiMain.LogInteger( 'n.BitLen', n.BitLength); -SiMain.LogInteger( 'n.MaxBits', n.MaxBits); -SiMain.LogStream( 'M', M); -{$ENDIF} -DB := nil; Seed := nil; dbMask := nil; maskedDB := nil; seedMask := nil; -maskedSeed := nil; EM := nil; m1 := nil; -try -C.Size := 0; -mLen := M.Size; -{$IFDEF SI} -SiMain.LogInteger( 'mLen', mLen); -{$ENDIF} - -// Step 1.b -// We require Require 0 < mLen <= (k - (2 * hLen) - 2) -// where k = (n.BitLength - 1) div 8 -result := mLen <= RSAES_OAEP_ENCRYPT_MaxByteLen( n); -if not result then exit; - -// Step 2.a -CheckHashOfNil; // HashOfNil has hLen = 20 bytes. -if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then - k := (n.BitLength - 1) div 8 -else - k := (n.BitLength + 7) div 8; -{$IFDEF SI} -SiMain.LogInteger( 'k', k); -{$ENDIF} - -// DB = lHash || PS || 0x01 || M. Len = k - hLen - 1 -DB := NewMemoryStream; -DB.Write( HashOfNil.Memory^, HashOfNil.Size); // Dont use CopyFrom on a global. -// Step 2.b and 2.c -for j := 0 to k - mLen - (2 * hLen) - 3 do - PutByte( DB, 0); // PS = stream of zeros. Len = k - mLen - (2 * hLen) - 2 -PutByte( DB, 1); -DB.CopyFrom( M, 0); -{$IFDEF SI} -SiMain.LogStream( 'DB', DB); -{$ENDIF} - -// Step 2.d -// seed = random. len = hLen -Seed := NewMemoryStream; -Seed.Size := hLen; -RandomFillStream( Seed); -{$IFDEF SI} -SiMain.LogStream( 'Seed', Seed); -{$ENDIF} - -// Step 2.e -// dbMask = MGF1( seed, k - hLen - 1). Len = k - hLen - 1 -dbMask := NewMemoryStream; -MGF1( Seed, k - hLen - 1, dbMask); -{$IFDEF SI} -SiMain.LogStream( 'dbMask', dbMask); -{$ENDIF} - -// Step 2.f -//maskedDB = DB xor dbMask. Len = k - hLen - 1 -maskedDB := NewMemoryStream; -maskedDB.Size := k - hLen - 1; -XOR_Streams3( maskedDB, DB, dbMask); -{$IFDEF SI} -SiMain.LogStream( 'maskedDB', maskedDB); -{$ENDIF} - -// Step 2.g -// seedMask = MGF1( maskedDB, hLen). Len = hLen -seedMask := NewMemoryStream; -MGF1( maskedDB, hLen, seedMask); -{$IFDEF SI} -SiMain.LogStream( 'seedMask', seedMask); -{$ENDIF} - -// Step 2.h -// maskedSeed = seed xor seedMask. Len = hLen -maskedSeed := NewMemoryStream; -maskedSeed.Size := hLen; -XOR_Streams3( maskedSeed, Seed, SeedMask); -{$IFDEF SI} -SiMain.LogStream( 'maskedSeed', maskedSeed); -{$ENDIF} - -// Step 2.i -// EM = 0x00 || maskedSeed || maskedDB. Len = k -EM := NewMemoryStream; -PutByte( EM, 0); -EM.CopyFrom( maskedSeed, 0); -EM.CopyFrom( maskedDB, 0); -{$IFDEF SI} -SiMain.LogStream( 'EM', EM); -{$ENDIF} - -// Step 3.a -// m = OS2IP (EM). m:THugeInteger. m.BitLength = k*8 -EM.Position := 0; -{$IFDEF SI} -Ok := OS2IP( EM, k, m1, n.FPool, n.bitlength); -SiMain.LogBoolean( 'm = OS2IP( EM) Ok', Ok); -if Ok then - begin - Ok := not (m1.Compare( n) in [rGreaterThan, rEqualTo]); - SiMain.LogStream( 'm', m1.FValue); - SiMain.LogInteger( 'm.BitLen', m1.BitLength); - SiMain.LogInteger( 'm.MaxBits', m1.MaxBits); - SiMain.LogBoolean( 'm < n', Ok); - end; -if not Ok then - raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix); -{$ELSE} -if (not OS2IP( EM, k, m1, n.FPool, n.bitlength)) or - (m1.Compare( n) in [rGreaterThan, rEqualTo]) then - raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix); -{$ENDIF} - -// Step 3.b -// c = m ** e mod n; // RSAEP -m1.PowerMod( e, n, nil); // 0 <= m1 < n -{$IFDEF SI} -SiMain.LogStream( 'c', m1.FValue); -{$ENDIF} - -// Step 3.c -// C = I2OSP (c, (n.BitLength + 7) div 8). // len (n.BitLength + 7) div 8 -if not I2OSP( m1, (n.BitLength + 7) div 8, C, n.FPool) then - raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix) -{$IFDEF SI} -;SiMain.LogStream( 'C', C); -{$ENDIF} - -finally -DB.Free; Seed.Free; dbMask.Free; maskedDB.Free; seedMask.Free; -maskedSeed.Free; EM.Free; m1.Free -{$IFDEF SI} -;SiMain.LeaveMethod( 'RSAES_OAEP_ENCRYPT'); -{$ENDIF} -end end; - - - - - - -function RSAES_OAEP_DECRYPT( d, n: THugeCardinal; C, M: TStream; - p, q, dp, dq, qinv: THugeCardinal): boolean; -// RSAES-OAEP-DECRYPT is the RSA decryption primitive. -// Inputs: -// n The RSA encryption public key modulus. -// d The RSA encryption private key exponent. -// C The ciphertext to be decrypted. Length = length of n in bytes. -// Outputs: -// M The decrypted plaintext. This stream is cleared on input. -// The hash used is SHA-1, so hLen = 20. -// result True if successful; False if failed. -var - mLen: integer; - k: integer; // Largest number of bytes that guarentees a number from those bytes is less than n - bytesRead: cardinal; - DB, Seed, dbMask, maskedDB, seedMask, maskedSeed, EM, reconHash: TMemoryStream; - m1: THugeCardinal; - Y: byte; - - function NewMemoryStream: TMemoryStream; - begin - if assigned( n.FPool) then - result := n.FPool.NewMemoryStream( 0) - else - result := TMemoryStream.Create - end; - -begin -{$IFDEF SI} -;SiMain.EnterMethod( 'RSAES_OAEP_DECRYPT'); -SiMain.LogStream( 'C', C); -SiMain.LogInteger( 'C.Size', C.Size); -SiMain.LogInteger( 'n.BitLength', n.BitLength); -{$ENDIF} -DB := nil; Seed := nil; dbMask := nil; maskedDB := nil; seedMask := nil; -maskedSeed := nil; EM := nil; m1 := nil; reconHash := nil; - -try -M.Size := 0; - -// Step 1.b -result := C.Size = (n.BitLength + 7) div 8; -if not result then exit; - -// Step 2.a -// c2 = I2OSP (C, (n.BitLength + 7) div 8). // len (n.BitLength + 7) div 8 -C.Position := 0; -if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then - begin - k := (n.BitLength - 1) div 8; - result := OS2IP( C, (n.BitLength + 7) div 8, m1, n.FPool, n.bitlength) - end -else - begin - k := (n.BitLength + 7) div 8; - result := OS2IP( C, k, m1, n.FPool, n.bitlength); - end; -if not result then exit; -{$IFDEF SI} -SiMain.LogStream( 'c', m1.FValue); -{$ENDIF} - -// Step 2.b m = RSADP (K, c). -if UseCRT then - m1.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil) - else - m1.PowerMod( d, n, nil); // 0 <= m1 < n -{$IFDEF SI} -SiMain.LogStream( 'm', m1.FValue); -{$ENDIF} - -// Step 2.c EM = I2OSP (m, k). -EM := NewMemoryStream; -result := I2OSP( m1, k, EM, n.FPool); // EM len = k -if not result then exit; -{$IFDEF SI} -SiMain.LogInteger( 'k', k); -SiMain.LogStream( 'EM', EM); -{$ENDIF} - -// Step 3.a -CheckHashOfNil; // HashOfNil has hLen = 20 bytes. - -// Step 3.b EM = Y || maskedSeed || maskedDB. -EM.Position := 0; -EM.Read( Y, 1); -maskedSeed := NewMemoryStream; -maskedSeed.CopyFrom( EM, hLen); -maskedDB := NewMemoryStream; -maskedDB.CopyFrom( EM, k - hLen - 1); -result := Y = 0; -if not result then exit; - -// Step 3.c -// seedMask = MGF(maskedDB, hLen). Len = hLen -seedMask := NewMemoryStream; -MGF1( maskedDB, hLen, seedMask); - -// Step 3.d -// Seed = seed = maskedSeed xor seedMask. Len = hLen -Seed := NewMemoryStream; -Seed.Size := hLen; -XOR_Streams3( Seed, maskedSeed, SeedMask); - -// Step 3.e -// dbMask = MGF1( seed, k - hLen - 1). Len = k - hLen - 1 -dbMask := NewMemoryStream; -MGF1( Seed, k - hLen - 1, dbMask); - -// Step 3.f -// DB = maskedDB xor dbMask. Len = k - hLen - 1 -DB := NewMemoryStream; -DB.Size := k - hLen - 1; -XOR_Streams3( DB, maskedDB, dbMask); - -// Step 3.g -// DB = lHash' || PS || 0x01 || M. -DB.Position := 0; -reconHash := NewMemoryStream; -reconHash.CopyFrom( DB, hLen); -repeat - bytesRead := DB.Read( Y, 1) -until (Y <> 0) or (bytesRead = 0); -mLen := DB.Size - DB.Position; -result := CompareMemoryStreams( reconHash, HashOfNil) and - (Y = 1) and (bytesRead = 1) and (mLen > 0); -if not result then exit; - -// Step 4: Output the message M -M.CopyFrom( DB, mLen) - -finally -DB.Free; Seed.Free; dbMask.Free; maskedDB.Free; seedMask.Free; -maskedSeed.Free; EM.Free; m1.Free; reconHash.Free -{$IFDEF SI} -;SiMain.LeaveMethod( 'RSAES_OAEP_DECRYPT'); -{$ENDIF} -end end; - - - - -function Generate_RSA_SymetricKey( - n, e: THugeCardinal; CipherStream: TStream; - const SymetricCipher: IBlockCipher): TSymetricKey; -// 1. Make a random Seed stream of size IBlockCipher.SeedByteSize -// 2. Create the key with IBlockCipher.GenerateKey( Seed) -// 3. Create a mememto of the key with TSymetricKey.SaveToStream -// 4. Measure the size of this stream. It needs to be transmitted. -// 6. Prefix the cipherstream with the count of chunks. -// 5. Process this stream RSAES_OAEP_ENCRYPT_MaxByteLen bytes at a time. -// Each RSAES_OAEP_ENCRYPT_MaxByteLen or part-thereof is a key chunk. -// In most cases, we will probably only get one key chunk. -// 6. On each key chunk, call function RSAES_OAEP_ENCRYPT( n, e, M=chunk, C=output); -// 7. Append each C to the cipherstream. -var - SeedStream, M, C: TMemoryStream; - PayloadSize: integer; - MaxChunk, Chunk: integer; - Ok: boolean; - - function NewMemoryStream( Sz: integer): TMemoryStream; - begin - if assigned( n.FPool) then - result := n.FPool.NewMemoryStream( Sz) - else - begin - result := TMemoryStream.Create; - result.Size := Sz - end - end; - -begin -result := nil; -SeedStream := NewMemoryStream( SymetricCipher.SeedByteSize); -try -RandomFillStream( SeedStream); -result := SymetricCipher.GenerateKey( SeedStream); -SeedStream.Position := 0; -result.SaveToStream( SeedStream); -PayloadSize := SeedStream.Position; -SeedStream.Size := PayloadSize; -SeedStream.Position := 0; -CipherStream.Write( PayloadSize, 4); -MaxChunk := RSAES_OAEP_ENCRYPT_MaxByteLen( n); -Ok := False; -M := NewMemoryStream( MaxChunk); -C := NewMemoryStream( (n.BitLength + 7) div 8); -try -while (PayloadSize > 0) and (MaxChunk > 0) do - begin - Chunk := Min( PayloadSize, MaxChunk); - M.Size := Chunk; - SeedStream.Read( M.Memory^, Chunk); - Ok := RSAES_OAEP_ENCRYPT( n, e, M, C); - if not Ok then break; - CipherStream.Write( C.Memory^, C.Size); - Dec( PayloadSize, Chunk) - end; -finally -FreeAndNil( M); -FreeAndNil( C); -end -finally -FreeAndNil( SeedStream) -end; -if not Ok then - FreeAndNil( result) -end; - - - - -function Extract_RSA_SymetricKey( - d, n, p, q, dp, dq, qinv: THugeCardinal; CipherStream: TStream; - const SymetricCipher: IBlockCipher): TSymetricKey; -var - KeyStream, M, C: TMemoryStream; - PayloadSize: integer; - MaxChunk, Chunk, CipherChunkSize: integer; - Ok: boolean; - - function NewMemoryStream( Sz: integer): TMemoryStream; - begin - if assigned( n.FPool) then - result := n.FPool.NewMemoryStream( Sz) - else - begin - result := TMemoryStream.Create; - result.Size := Sz - end - end; - -begin -result := nil; -CipherStream.Read( PayloadSize, 4); -MaxChunk := RSAES_OAEP_ENCRYPT_MaxByteLen( n); -Ok := False; -CipherChunkSize := (n.BitLength + 7) div 8; -KeyStream := NewMemoryStream( 0); -try -M := NewMemoryStream( MaxChunk); -C := NewMemoryStream( CipherChunkSize); -try -while (PayloadSize > 0) and (MaxChunk > 0) do - begin - Chunk := Min( PayloadSize, MaxChunk); - C.Size := CipherChunkSize; - Ok := (CipherStream.Read( C.Memory^, CipherChunkSize) = CipherChunkSize) and - RSAES_OAEP_DECRYPT( d, n, C, M, p, q, dp, dq, qinv) and (M.Size = Chunk); - if not Ok then break; - KeyStream.Write( M.Memory^, Chunk); - Dec( PayloadSize, Chunk) - end; -finally -FreeAndNil( M); -FreeAndNil( C); -end; -KeyStream.Position := 0; -if Ok then - result := SymetricCipher.LoadKeyFromStream( KeyStream) -finally -FreeAndNil( KeyStream) -end end; - - - -procedure ClearLeftMostBits( Stream: TStream; BitsToClear: integer); -var - aByte, ClearFlags: byte; - j: integer; -begin -// BitsToClear == (8 * emLen) - emBits -if BitsToClear <= 0 then exit; -Assert( BitsToClear <= 8, ''); -Stream.Position := 0; -Stream.Read( aByte, 1); -// For RFC 3447, "left--most" will be read as Most Signficant. -ClearFlags := $80; -for j := 2 to BitsToClear do - ClearFlags := (ClearFlags shr 1) + $80; -aByte := aByte and (not ClearFlags); -Stream.Position := 0; -Stream.Write( aByte, 1) -end; - - - -type -TDocumentProgressMonitor = class - private - FDelegate: TOnHashProgress; - - function OnHashProgress( - Sender: TObject; CountBytesProcessed: int64): boolean; - public - constructor Create( Delegate1: TOnHashProgress); - end; - -function EMSA_PSS_ENCODE( M: TStream; emBits, sLen: integer; EM: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -// EMSA-PSS-ENCODE is the RSA message encoding primitive used by Sign & Verify. -// Inputs: -// M message to be encoded, an octet string. -// emBits maximal bit length of the integer OS2IP (EM), -// at least 8hLen + 8sLen + 9 -// sLen Intended length in octets of the salt -// Outputs: -// EM encoded message, an octet string of length emLen = \ceil -// (emBits/8) -// result True if successful; False if failed (due to emBits being too small.) -// Using: -// Hash hash function (hLen denotes the length in octets of the hash -// function output) used is SHA-1. -// MGF mask generation function uses is MGF1. -var - HashObj: TObject; - Hash: IHash; - mHash: TStream; - hLen1, emLen: integer; - M_Dash: TStream; // M' - Zero_8Bytes: uint64; - aByte: byte; - SaltP: int64; - H, DB, maskedDB, dbMask: TMemoryStream; - j: integer; - Monitor: TDocumentProgressMonitor; - Ok: boolean; - -begin -result := opFail; -// 1. [Step 1 of the standard unecessary]. -// 2. Let mHash = Hash(M), an octet string of length hLen. -Zero_8Bytes := 0; -emLen := (emBits + 7) div 8; - -M_Dash := TMemoryStream.Create; -mHash := TMemoryStream.Create; -H := TMemoryStream.Create; -DB := TMemoryStream.Create; -maskedDB := TMemoryStream.Create; -dbMask := TMemoryStream.Create; -try - -M_Dash.Write( Zero_8Bytes, 8); -Hash := AcquireHash( HashObj); -Monitor := TDocumentProgressMonitor.Create( CheckAbortFunc); -try - Hash.OnProgress := Monitor.OnHashProgress; - Hash.HashStream( M); - Hash.OnProgress := nil; - if Hash.isUserAborted then - begin - result := opAbort; - exit - end; - hLen1 := Hash.HashOutputValue.Size; - Hash.WriteHashOutputToStream( M_Dash); - -// 3. If emLen < hLen + sLen + 2, output "encoding error" and stop. - Ok := emLen >= (hLen1 + sLen + 2); - if not Ok then exit; - -// 4. Generate a random octet string salt of length sLen; if sLen = 0, -// then salt is the empty string. -// 5. Let -// M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt; -// M' is an octet string of length 8 + hLen + sLen with eight -// initial zero octets. - SaltP := M_Dash.Position; - M_Dash.CopyFrom( TRandomStream.Instance, sLen); - -// 6. Let H = Hash(M'), an octet string of length hLen. - Hash.HashStream( M_Dash); - Hash.WriteHashOutputToStream( H); - -// 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2 -// zero octets. The length of PS may be 0. - aByte := 0; - for j := 1 to emLen - sLen - hLen1 - 2 do - DB.Write( aByte, 1); - -// 8. Let DB = PS || 0x01 || salt; DB is an octet string of length -// emLen - hLen - 1. - aByte := $01; - DB.Write( aByte, 1); - M_Dash.Position := SaltP; - DB.CopyFrom( M_Dash, sLen); - -// 9. Let dbMask = MGF(H, emLen - hLen - 1). - MGF1( H, emLen - hLen -1, dbMask) -finally - ReleaseHash( HashObj, Hash); - Monitor.Free -end; - -// 10. Let maskedDB = DB \xor dbMask. -maskedDB.Size := DB.Size; -XOR_Streams3( maskedDB, DB, dbMask); - -// 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in -// maskedDB to zero. -ClearLeftMostBits( maskedDB, (8 * emLen) - emBits); - -// 12. Let EM = maskedDB || H || 0xbc. -// 13. Output EM. -EM.CopyFrom( maskedDB, 0); -EM.CopyFrom( H, 0); -aByte := $BC; -EM.Write( aByte, 1) - -finally -M_Dash.Free; -mHash.Free; -H.Free; -DB.Free; -maskedDB.Free; -dbMask.Free -end; -if Ok then - result := opPass -end; - - -function EMSA_PSS_VERIFY( M: TStream; emBits, sLen: integer; EM: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -var - HashObj: TObject; - Hash: IHash; - mHash: TStream; - hLen1, emLen: integer; - M_Dash: TStream; // M' - Zero_8Bytes: uint64; - aByte, ClearFlags: byte; -// SaltP: int64; - H, DB, maskedDB, dbMask, reconH: TMemoryStream; - j: integer; - Monitor: TDocumentProgressMonitor; - Ok: boolean; -begin -Monitor := nil; -result := opFail; -Zero_8Bytes := 0; -emLen := (emBits + 7) div 8; - -M_Dash := TMemoryStream.Create; -mHash := TMemoryStream.Create; -reconH := TMemoryStream.Create; -H := TMemoryStream.Create; -DB := TMemoryStream.Create; -maskedDB := TMemoryStream.Create; -dbMask := TMemoryStream.Create; -try - -M_Dash.Write( Zero_8Bytes, 8); -Hash := AcquireHash( HashObj); -try - Monitor := TDocumentProgressMonitor.Create( CheckAbortFunc); - Hash.OnProgress := Monitor.OnHashProgress; - Hash.HashStream( M); - Hash.OnProgress := nil; - if Hash.isUserAborted then - begin - result := opAbort; - exit - end; - hLen1 := Hash.HashOutputValue.Size; - Hash.WriteHashOutputToStream( M_Dash); - - // mHash := Hash( M) - // M' = 00 00 00 00 00 00 00 00 || mHash - Ok := emLen >= (hLen1 + sLen + 2); - if not Ok then exit; - - // Recover maskedDB from ( EM == (maskedDB || H || $BC)) - EM.Position := 0; - maskedDB.Size := emLen - hLen1 - 1; - Ok := EM.Read( maskedDB.Memory^, maskedDB.Size) = maskedDB.Size; - - // Recover H from ( EM == (maskedDB || H || $BC)) - H.Size := hLen1; - Ok := Ok and (EM.Read( H.Memory^, hLen1) = hLen1) and - (EM.Read( aByte, 1) = 1) and - (aByte = $BC); // checks $BC byte. - if not Ok then exit; - - // check maskedDB[leftmost 8emLen - emBits bits] == 0 - if (8 * emLen) > emBits then - begin - maskedDB.Position := 0; - MaskedDB.Read( aByte, 1); - // For RFC 3447, "left--most" will be read as Most Signficant. - ClearFlags := $80; - for j := emBits to 8 * emLen - 2 do - ClearFlags := (ClearFlags shr 1) + $80; - Ok := (aByte and ClearFlags) = 0; - maskedDB.Position := 0 - end; - - // dbMask := MGF( H, emLen - hLen - 1) - MGF1( H, emLen - hLen -1, dbMask); - - // DB := maskedDB xor dbMask - DB.Size := dbMask.Size; - XOR_Streams3( DB, maskedDB, dbMask); - - // DB[ 8emLen - emBits bits] := 0 - ClearLeftMostBits( DB, (8 * emLen) - emBits); - - // Extract PS from DB = PS || $01 || salt - // and then check PS = 0 - DB.Position := 0; - for j := 0 to emLen - sLen - hLen - 3 do - begin - Ok := (DB.Read( aByte, 1) = 1) and (aByte = 0); - if not Ok then break - end; - if not Ok then exit; - - // Extract $01 from DB = PS || $01 || salt - // and check it - Ok := (DB.Read( aByte, 1) = 1) and (aByte = $01); - if not Ok then exit; - - // M' = 00 00 00 00 00 00 00 00 || mHash || salt; - M_Dash.CopyFrom( DB, sLen); - M_Dash.Position := 0; - - // H' = Hash(M') - Hash.HashStream( M_Dash); - reconH.Size := hLen1; - reconH.Position := 0; - Hash.WriteHashOutputToStream( reconH); - -finally - ReleaseHash( HashObj, Hash); - Monitor.Free -end; - -// check H == H' -Ok := CompareMemoryStreams( reconH, H) -finally -M_Dash.Free; -mHash.Free; -H.Free; -DB.Free; -maskedDB.Free; -dbMask.Free; -reconH.Free -end; -if Ok then - result := opPass -end; - - - - - - -const - MaxSaltLength = 20; - -function RSASSA_PSS_SIGN ( d, n: THugeCardinal; M, S: TStream; - CheckAbortFunc: TOnHashProgress; - p, q, dp, dq, qinv: THugeCardinal): TLongOpResult; -// TO DO: Check for user abort. - -// RSASSA-PSS-SIGN is the RSA signature generation primitive. -// Inputs: -// d The signer's RSA private key exponent. -// n The signer's RSA public key modulus. -// M The message to be signed. -// Outputs: -// S The signature. An octet string of length k, where k is the -// length in octets of the RSA modulus n -// result = opPass The operation was successful. -// = opFail The operation failed for some reason other than user abort. -// = opAbort The operation was aborted by the user before it could be completed. -var - modBits: integer; - hLen1: integer; - EM: TStream; - Ok: boolean; - SaltLength, k: integer; - Little_m: THugeCardinal; - EMLen: integer; -begin -// 1. EMSA-PSS encoding: Apply the EMSA-PSS encoding operation (Section -// 9.1.1) to the message M to produce an encoded message EM of length -// \ceil ((modBits - 1)/8) octets such that the bit length of the -// integer OS2IP (EM) (see Section 4.2) is at most modBits - 1, where -// modBits is the length in bits of the RSA modulus n: -// EM = EMSA-PSS-ENCODE (M, modBits - 1). -modBits := n.BitLength; -k := (modBits + 7) div 8; -EMLen := (modBits + 6) div 8; -hLen1 := hLen; -SaltLength := Max( Min( EMLen - hLen1 - 2, MaxSaltLength), 0); -Little_m := nil; -EM := TMemoryStream.Create; -try -result := EMSA_PSS_ENCODE( M, modBits - 1, SaltLength, EM, CheckAbortFunc); -if result = opAbort then exit; -Ok := result = opPass; - -// EM.Size == EMLen == (modBits + 6) div 8 - -// 2. RSA signature: -// a. Convert the encoded message EM to an integer message -// representative m (see Section 4.2): -// m = OS2IP (EM). -EM.Position := 0; -Ok := Ok and OS2IP( EM, EMLen, Little_m, n.FPool, n.MaxBits); - -// b. Apply the RSASP1 signature primitive (Section 5.2.1) to the RSA -// private key K and the message representative m to produce an -// integer signature representative s: -// s = RSASP1 (K, m). -if Ok then - begin - if UseCRT then - Little_m.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil) - else - Little_m.PowerMod( d, n, nil); // 0 <= m1 < n - end; - -// c. Convert the signature representative s to a signature S of -// length k octets (see Section 4.1): -// S = I2OSP (s, k). -Ok := Ok and I2OSP( Little_m, k, S, n.FPool) -finally - EM.Free; - Little_m.Free - end; -if Ok then - result := opPass - else - result := opFail -end; - - -function RSASSA_PSS_VERIFY( n, e: THugeCardinal; M, S: TStream; - CheckAbortFunc: TOnHashProgress): TLongOpResult; -// RSASSA-PSS-VERIFY -// Inputs: -// n The signer's RSA public key modulus. -// e The signer's RSA private key exponent. -// M The message whose signature is to be verified. -// S The signature to be verified. -// Outputs: -// result = opPass The verification passed. -// = opFail The verification failed for some reason other than user abort. -// = opAbort The verification was aborted by the user before it could be completed. -var - Little_s: THugeCardinal; - Ok: boolean; - modBits, k, EMLen, SaltLength: integer; - EM: TStream; - -begin -// 1. Length checking: If the length of the signature S is not k octets, -// output "invalid signature" and stop. -// 2.a. Convert the signature S to an integer signature representative -// s (see Section 4.2): -// s = OS2IP (S). -modBits := n.BitLength; -k := (modBits + 7) div 8; -EMLen := (modBits + 6) div 8; -SaltLength := Max( Min( EMLen - hLen1 - 2, MaxSaltLength), 0); -Little_s := nil; -try -Ok := OS2IP( S, k, Little_s, n.FPool, n.bitlength); - -// 2.b. Apply the RSAVP1 verification primitive (Section 5.2.2) to the -// RSA public key (n, e) and the signature representative s to -// produce an integer message representative m: -// m = RSAVP1 ((n, e), s). -Ok := Ok and (Little_s.Compare( n) = rLessThan); -if Ok then - Little_s.PowerMod( e, n, nil); - -// c. Convert the message representative m to an encoded message EM -// of length emLen = \ceil ((modBits - 1)/8) octets, where modBits -// is the length in bits of the RSA modulus n (see Section 4.1): -// EM = I2OSP (m, emLen). -EM := TMemoryStream.Create; -try -Ok := Ok and I2OSP( Little_s, EMLen, EM, n.FPool); - -// 3. EMSA-PSS verification: Apply the EMSA-PSS verification operation -// (Section 9.1.2) to the message M and the encoded message EM to -// determine whether they are consistent: -// Result = EMSA-PSS-VERIFY (M, EM, modBits - 1). -if Ok then - begin - result := EMSA_PSS_VERIFY( M, modBits - 1, SaltLength, EM, CheckAbortFunc); - if result = opAbort then exit; - Ok := result = opPass - end -finally - EM.Free -end; -finally - Little_s.Free -end; -if Ok then - result := opPass - else - result := opFail -end; - - - - - - -{ TDocumentProgressMonitor } - -constructor TDocumentProgressMonitor.Create( Delegate1: TOnHashProgress); -begin -FDelegate := Delegate1 -end; - - -function TDocumentProgressMonitor.OnHashProgress( - Sender: TObject; CountBytesProcessed: int64): boolean; -begin -if assigned( FDelegate) then - result := FDelegate( Sender, CountBytesProcessed) - else - result := True -end; - - -initialization -InitUnit_RSA_Primitives; - -finalization -DoneUnit_RSA_Primitives; - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.RSA_Primitives; +// This unit implements the primitives specified in RFC-3447 +// http://www.ietf.org/rfc/rfc3447.txt & +// http://www.rfc-editor.org/errata_search.php?rfc=3447 + +interface +uses + TPLB3.HugeCardinal, Classes, TPLB3.MemoryStreamPool, TPLB3.StreamCipher, + TPLB3.BlockCipher, TPLB3.Hash; + +function I2OSP( x: THugeCardinal; xLen: integer; + XStream: TStream; const Pool: IMemoryStreamPool): boolean; +// Integer-to-Octet-String primitive +// I2OSP converts a huge cardinal to a byte stream of the specified length. +// Inputs: +// x The number to be converted. +// xLen The intended length in bytes of the output octet stream. +// Pool Optional memory stream pool for re-cycling memory. +// Outputs: +// XStream The corresponding octet stream is written to this TStream +// at the input position. The stream is not resized or repositioned +// before output. +// result Returns True if the operation was successful; +// False if xLen was too small for x. + + +function OS2IP( XStream: TStream; xLen: integer; + var x: THugeCardinal; + const Pool: IMemoryStreamPool; MaxBits: integer): boolean; +// Octet-String-to-Integer primitive +// OS2IP converts byte stream of the specified length to a new huge cardinal. +// Inputs: +// XStream The octet stream to be converted. +// The stream is not resized or repositioned +// before reading, but is read from its current (input) position. +// xLen The length in bytes of the octet stream to be read. The +// stream must have this many bytes readable or an exception +// will be raised. (units are bytes) +// Pool Construction parameter for huge cardinal. +// MaxBits Construction parameter for huge cardinal. (units are bits) +// Outputs: +// x The number converted to. On input this is nil or dangling. +// On output, a new THugeCardinal is created. +// result Returns True if the operation was successful; +// False if xLen was too large for MaxBits. + + +procedure MGF1( mgfSeed: TStream; maskLen: cardinal; mask: TStream); +// MGF1 is a Mask Generation Function based on SHA-1. +// Inputs: +// mgfSeed The octet stream which seeds deterministically the output. +// The seed is the whole stream. +// maskLen The intented length in bytes of the output mask. +// Outputs: +// mask The mask or output stream created. Must not be nil on input. + + +type +TLongOpResult = (opPass, opFail, opAbort); + + +function RSAES_OAEP_ENCRYPT( n, e: THugeCardinal; M, C: TMemoryStream): boolean; +// RSAES-OAEP-ENCRYPT is the RSA encryption primitive. +// Inputs: +// n The RSA encryption public key modulus. +// e The RSA encryption public key exponent. +// M The plaintext to be encrypted. +// Outputs: +// C The encrypted ciphertext. This stream is cleared on input. +// The byte length of C, mlen must not more the byte length of +// the modulus (k), less twice the hash length (hLen), less 2. +// mLen <= k - 2 * hLen - 2 +// The hash used is SHA-1, so hLen = 20. +// result True if successful; False if failed. + + +function RSAES_OAEP_ENCRYPT_MaxByteLen( n: THugeCardinal): integer; +// Computes the maximum byte length for M in the RSAES_OAEP_ENCRYPT function. +// Inputs: +// n The RSA encryption public key modulus. +// Outputs: +// result The maximum byte length for M. See comments about the +// RSAES_OAEP_ENCRYPT function. +// result := k - 2 * hLen - 2 + + +function RSAES_OAEP_DECRYPT( d, n: THugeCardinal; C, M: TStream; + p, q, dp, dq, qinv: THugeCardinal): boolean; +// RSAES-OAEP-DECRYPT is the RSA decryption primitive. +// Inputs: +// n The RSA encryption public key modulus. +// d The RSA encryption private key exponent. +// C The ciphertext to be decrypted. Length = length of n in bytes. +// p, q, dp, dq, qinv: Optional break-down of d for use in CRT. +// Outputs: +// M The decrypted plaintext. This stream is cleared on input. +// The hash used is SHA-1, so hLen = 20. +// result True if successful; False if failed. + + +function EMSA_PSS_ENCODE( M: TStream; emBits, sLen: integer; EM: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +// EMSA-PSS-ENCODE is the RSA message encoding primitive used by Sign & Verify. +// Inputs: +// M message to be encoded, an octet string. +// emBits maximal bit length of the integer OS2IP (EM), +// at least 8hLen + 8sLen + 9 +// sLen Intended length in octets of the salt +// Outputs: +// EM encoded message, an octet string of length emLen = \ceil +// (emBits/8) +// result True if successful; False if failed (due to emBits being too small.) +// Using: +// Hash hash function (hLen denotes the length in octets of the hash +// function output) used is SHA-1. +// MGF mask generation function uses is MGF1. + + +function RSASSA_PSS_SIGN( d, n: THugeCardinal; M, S: TStream; + CheckAbortFunc: TOnHashProgress; + p, q, dp, dq, qinv: THugeCardinal): TLongOpResult; +// RSASSA-PSS-SIGN is the RSA signature generation primitive. +// Inputs: +// d The signer's RSA private key exponent. +// n The signer's RSA public key modulus. +// M The message to be signed. +// Outputs: +// S The signature. +// result = opPass The operation was successful. +// = opFail The operation failed for some reason other than user abort. +// = opAbort The operation was aborted by the user before it could be completed. + + +function EMSA_PSS_VERIFY( M: TStream; emBits, sLen: integer; EM: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +// EMSA-PSS-VERIFY +// It is the inverse of EMSA-PSS-ENCODE + + +function RSASSA_PSS_VERIFY( n, e: THugeCardinal; M, S: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +// RSASSA-PSS-VERIFY +// Inputs: +// n The signer's RSA public key modulus. +// e The signer's RSA private key exponent. +// M The message whose signature is to be verified. +// S The signature to be verified. +// Outputs: +// result = opPass The verification passed. +// = opFail The verification failed for some reason other than user abort. +// = opAbort The verification was aborted by the user before it could be completed. + + +function Generate_RSA_SymetricKey( + n, e: THugeCardinal; CipherStream: TStream; + const SymetricCipher: IBlockCipher): TSymetricKey; + +function Extract_RSA_SymetricKey( + d, n, p, q, dp, dq, qinv: THugeCardinal; CipherStream: TStream; + const SymetricCipher: IBlockCipher): TSymetricKey; + +{$IF compilerversion > 15} +{$REGION 'Algorithm archive'} +{$IFEND} +var + // Set the following variable to a non-zero value access older behaviour. + // Or leave as zero for default. + RSA_Primitives_AlgorithmVersion: integer = 0; + +const + V3_0_0_BaseIdx = 1; + RSA_Primitives_Algorithm: array[ 0..V3_0_0_BaseIdx {Insert RSA_Primitives_AlgorithmVersion here}] of record + TPLB3_Version_Low, TPLB3_Version_High: string; + end = ( + {0, The current version ==> } ( TPLB3_Version_Low: '3.4.1'; TPLB3_Version_High: ''), + {1, An older version ==> } ( TPLB3_Version_Low: '3.0.0'; TPLB3_Version_High: '3.4.0')); +{$IF compilerversion > 15} +{$ENDREGION} +{$IFEND} + +var + UseCRT: boolean = True; + +implementation + + + + + + + + +uses TPLB3.PointerArithmetic, SysUtils, Math, TPLB3.SHA1, + TPLB3.HashDsc, TPLB3.StreamUtils, SyncObjs, TPLB3.Random, TPLB3.I18n; + + +var + hLen1: integer = -1; + HashOfNil: TMemoryStream = nil; + GlobalsGate: TCriticalSection; + +function CreateHashDscObject( var Obj: TObject): IHashDsc; +begin +result := nil; +Obj := TSHA1.Create; +Supports( Obj, IHashDsc, result) +end; + + +function AcquireHash( var Obj: TObject): IHash; +var + HashObj: TSimpleHash; + Dsc: TObject; +begin +result := nil; +HashObj := TSimpleHash.Create; +Obj := HashObj; +Supports( Obj, IHash, result); +result.Hash := CreateHashDscObject( Dsc) +end; + + +procedure ReleaseHash( Obj: TObject; var H: IHash); +begin +H := nil; +Obj.Free +end; + + +function hLen: integer; +var + H: TObject; + HI: IHashDsc; +begin +if hLen1 = -1 then + begin + HI := CreateHashDscObject( H); + hLen1 := HI.DigestSize div 8; + HI := nil; + end; +result := hLen1 +end; + + +procedure ReleaseHashSharedObjects; +begin +hLen1 := -1 +end; + +procedure InitUnit_RSA_Primitives; +begin +hLen1 := -1; +HashOfNil := nil; +GlobalsGate := TCriticalSection.Create +{$IFDEF RELEASE}; +// Release configuration build. +{$ENDIF} +{$IFDEF DEBUG}; +// Debug configuration build. +{$ENDIF} +{$IFDEF SI}; +Si.Enabled := True; +SiMain.ClearLog; +{$ENDIF} +end; + + +procedure DoneUnit_RSA_Primitives; +begin +FreeAndNil( GlobalsGate); +FreeAndNil( HashOfNil) +end; + + + + +function I2OSP( x: THugeCardinal; xLen: integer; XStream: TStream; + const Pool: IMemoryStreamPool): boolean; +begin +result := xLen >= ((x.BitLength + 7) div 8); +if result then + x.StreamOut( BigEndien, XStream, xLen) +end; + + + +function OS2IP( XStream: TStream; xLen: integer; + var x: THugeCardinal; + const Pool: IMemoryStreamPool; MaxBits: integer): boolean; +begin +if (RSA_Primitives_AlgorithmVersion <> V3_0_0_BaseIdx) and + ((XStream.Size - XStream.Position) <> xLen) then + raise Exception.Create('OS2IP wrong parameter'); +try + x := THugeCardinal.CreateFromStreamIn( MaxBits, BigEndien, XStream, Pool); + result := Assigned( x) +except + x := nil; + result := False +end end; + + + + +procedure MGF1( mgfSeed: TStream; maskLen: cardinal; mask: TStream); +var + Counter: longword; + HashObj: TObject; + Hash: IHash; + xfer: integer; + Buffer: array[0..99] of byte; + // Assume SizeOf( Buffer) >= (TSHA1.DigestSize div 8) +begin +mask.Size := 0; +if maskLen <= 0 then exit; +Hash := AcquireHash( HashObj); +try +Counter := 0; +repeat + Hash.Begin_Hash; + Hash.UpdateMemory( Counter, SizeOf(Counter)); + mgfSeed.Position := 0; + repeat + xfer := mgfSeed.Read( Buffer, SizeOf( Buffer)); + if xfer > 0 then + Hash.UpdateMemory( Buffer, xfer); + until xfer < SizeOf( Buffer); + Hash.End_Hash; + xfer := Min( maskLen, Hash.Hash.DigestSize div 8); // = 20 bytes for SHA-1 + Hash.HashOutputValue.ReadBuffer( Buffer, xfer); + mask.WriteBuffer( Buffer, xfer); + Dec( maskLen, xfer); + Inc( Counter) +until maskLen <= 0; +finally + ReleaseHash( HashObj, Hash) +end end; + + + +function RSAES_OAEP_ENCRYPT_MaxByteLen( n: THugeCardinal): integer; +begin +if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then + result := ((n.BitLength - 1) div 8) - (2 * hLen) - 2 +else + result := ((n.BitLength + 7) div 8) - (2 * hLen) - 2; +if result < 0 then + result := 0 +end; + + +procedure CheckHashOfNil; +var + HI: IHash; + H: TObject; +begin +GlobalsGate.Enter; +try +if assigned( HashOfNil) then exit; +HashOfNil := TMemoryStream.Create; +HI := AcquireHash( H); +HI.Begin_Hash; +HI.End_Hash; +HashOfNil.CopyFrom( HI.HashOutputValue, 0); +ReleaseHash( H, HI) +finally +GlobalsGate.Leave +end end; + + +function RSAES_OAEP_ENCRYPT( n, e: THugeCardinal; M, C: TMemoryStream): boolean; +var + mLen: integer; + k: integer; // Largest number of bytes that guarentees a number from those bytes is less than n + j: integer; + DB, Seed, dbMask, maskedDB, seedMask, maskedSeed, EM: TMemoryStream; + m1: THugeCardinal; +{$IFDEF SI} + Ok: boolean; +{$ENDIF} + + function NewMemoryStream: TMemoryStream; + begin + if assigned( n.FPool) then + result := n.FPool.NewMemoryStream( 0) + else + result := TMemoryStream.Create + end; + + procedure PutByte( S: TStream; byte1: byte); + begin + S.Write( byte1, 1) + end; + +begin +{$IFDEF SI} +SiMain.EnterMethod( 'RSAES_OAEP_ENCRYPT'); +SiMain.LogStream( 'n', n.FValue); +SiMain.LogInteger( 'n.BitLen', n.BitLength); +SiMain.LogInteger( 'n.MaxBits', n.MaxBits); +SiMain.LogStream( 'M', M); +{$ENDIF} +DB := nil; Seed := nil; dbMask := nil; maskedDB := nil; seedMask := nil; +maskedSeed := nil; EM := nil; m1 := nil; +try +C.Size := 0; +mLen := M.Size; +{$IFDEF SI} +SiMain.LogInteger( 'mLen', mLen); +{$ENDIF} + +// Step 1.b +// We require Require 0 < mLen <= (k - (2 * hLen) - 2) +// where k = (n.BitLength - 1) div 8 +result := mLen <= RSAES_OAEP_ENCRYPT_MaxByteLen( n); +if not result then exit; + +// Step 2.a +CheckHashOfNil; // HashOfNil has hLen = 20 bytes. +if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then + k := (n.BitLength - 1) div 8 +else + k := (n.BitLength + 7) div 8; +{$IFDEF SI} +SiMain.LogInteger( 'k', k); +{$ENDIF} + +// DB = lHash || PS || 0x01 || M. Len = k - hLen - 1 +DB := NewMemoryStream; +DB.Write( HashOfNil.Memory^, HashOfNil.Size); // Dont use CopyFrom on a global. +// Step 2.b and 2.c +for j := 0 to k - mLen - (2 * hLen) - 3 do + PutByte( DB, 0); // PS = stream of zeros. Len = k - mLen - (2 * hLen) - 2 +PutByte( DB, 1); +DB.CopyFrom( M, 0); +{$IFDEF SI} +SiMain.LogStream( 'DB', DB); +{$ENDIF} + +// Step 2.d +// seed = random. len = hLen +Seed := NewMemoryStream; +Seed.Size := hLen; +RandomFillStream( Seed); +{$IFDEF SI} +SiMain.LogStream( 'Seed', Seed); +{$ENDIF} + +// Step 2.e +// dbMask = MGF1( seed, k - hLen - 1). Len = k - hLen - 1 +dbMask := NewMemoryStream; +MGF1( Seed, k - hLen - 1, dbMask); +{$IFDEF SI} +SiMain.LogStream( 'dbMask', dbMask); +{$ENDIF} + +// Step 2.f +//maskedDB = DB xor dbMask. Len = k - hLen - 1 +maskedDB := NewMemoryStream; +maskedDB.Size := k - hLen - 1; +XOR_Streams3( maskedDB, DB, dbMask); +{$IFDEF SI} +SiMain.LogStream( 'maskedDB', maskedDB); +{$ENDIF} + +// Step 2.g +// seedMask = MGF1( maskedDB, hLen). Len = hLen +seedMask := NewMemoryStream; +MGF1( maskedDB, hLen, seedMask); +{$IFDEF SI} +SiMain.LogStream( 'seedMask', seedMask); +{$ENDIF} + +// Step 2.h +// maskedSeed = seed xor seedMask. Len = hLen +maskedSeed := NewMemoryStream; +maskedSeed.Size := hLen; +XOR_Streams3( maskedSeed, Seed, SeedMask); +{$IFDEF SI} +SiMain.LogStream( 'maskedSeed', maskedSeed); +{$ENDIF} + +// Step 2.i +// EM = 0x00 || maskedSeed || maskedDB. Len = k +EM := NewMemoryStream; +PutByte( EM, 0); +EM.CopyFrom( maskedSeed, 0); +EM.CopyFrom( maskedDB, 0); +{$IFDEF SI} +SiMain.LogStream( 'EM', EM); +{$ENDIF} + +// Step 3.a +// m = OS2IP (EM). m:THugeInteger. m.BitLength = k*8 +EM.Position := 0; +{$IFDEF SI} +Ok := OS2IP( EM, k, m1, n.FPool, n.bitlength); +SiMain.LogBoolean( 'm = OS2IP( EM) Ok', Ok); +if Ok then + begin + Ok := not (m1.Compare( n) in [rGreaterThan, rEqualTo]); + SiMain.LogStream( 'm', m1.FValue); + SiMain.LogInteger( 'm.BitLen', m1.BitLength); + SiMain.LogInteger( 'm.MaxBits', m1.MaxBits); + SiMain.LogBoolean( 'm < n', Ok); + end; +if not Ok then + raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix); +{$ELSE} +if (not OS2IP( EM, k, m1, n.FPool, n.bitlength)) or + (m1.Compare( n) in [rGreaterThan, rEqualTo]) then + raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix); +{$ENDIF} + +// Step 3.b +// c = m ** e mod n; // RSAEP +m1.PowerMod( e, n, nil); // 0 <= m1 < n +{$IFDEF SI} +SiMain.LogStream( 'c', m1.FValue); +{$ENDIF} + +// Step 3.c +// C = I2OSP (c, (n.BitLength + 7) div 8). // len (n.BitLength + 7) div 8 +if not I2OSP( m1, (n.BitLength + 7) div 8, C, n.FPool) then + raise Exception.Create('RSAES_OAEP_ENCRYPT ' + ES_InternalError_Suffix) +{$IFDEF SI} +;SiMain.LogStream( 'C', C); +{$ENDIF} + +finally +DB.Free; Seed.Free; dbMask.Free; maskedDB.Free; seedMask.Free; +maskedSeed.Free; EM.Free; m1.Free +{$IFDEF SI} +;SiMain.LeaveMethod( 'RSAES_OAEP_ENCRYPT'); +{$ENDIF} +end end; + + + + + + +function RSAES_OAEP_DECRYPT( d, n: THugeCardinal; C, M: TStream; + p, q, dp, dq, qinv: THugeCardinal): boolean; +// RSAES-OAEP-DECRYPT is the RSA decryption primitive. +// Inputs: +// n The RSA encryption public key modulus. +// d The RSA encryption private key exponent. +// C The ciphertext to be decrypted. Length = length of n in bytes. +// Outputs: +// M The decrypted plaintext. This stream is cleared on input. +// The hash used is SHA-1, so hLen = 20. +// result True if successful; False if failed. +var + mLen: integer; + k: integer; // Largest number of bytes that guarentees a number from those bytes is less than n + bytesRead: cardinal; + DB, Seed, dbMask, maskedDB, seedMask, maskedSeed, EM, reconHash: TMemoryStream; + m1: THugeCardinal; + Y: byte; + + function NewMemoryStream: TMemoryStream; + begin + if assigned( n.FPool) then + result := n.FPool.NewMemoryStream( 0) + else + result := TMemoryStream.Create + end; + +begin +{$IFDEF SI} +;SiMain.EnterMethod( 'RSAES_OAEP_DECRYPT'); +SiMain.LogStream( 'C', C); +SiMain.LogInteger( 'C.Size', C.Size); +SiMain.LogInteger( 'n.BitLength', n.BitLength); +{$ENDIF} +DB := nil; Seed := nil; dbMask := nil; maskedDB := nil; seedMask := nil; +maskedSeed := nil; EM := nil; m1 := nil; reconHash := nil; + +try +M.Size := 0; + +// Step 1.b +result := C.Size = (n.BitLength + 7) div 8; +if not result then exit; + +// Step 2.a +// c2 = I2OSP (C, (n.BitLength + 7) div 8). // len (n.BitLength + 7) div 8 +C.Position := 0; +if RSA_Primitives_AlgorithmVersion = V3_0_0_BaseIdx then + begin + k := (n.BitLength - 1) div 8; + result := OS2IP( C, (n.BitLength + 7) div 8, m1, n.FPool, n.bitlength) + end +else + begin + k := (n.BitLength + 7) div 8; + result := OS2IP( C, k, m1, n.FPool, n.bitlength); + end; +if not result then exit; +{$IFDEF SI} +SiMain.LogStream( 'c', m1.FValue); +{$ENDIF} + +// Step 2.b m = RSADP (K, c). +if UseCRT then + m1.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil) + else + m1.PowerMod( d, n, nil); // 0 <= m1 < n +{$IFDEF SI} +SiMain.LogStream( 'm', m1.FValue); +{$ENDIF} + +// Step 2.c EM = I2OSP (m, k). +EM := NewMemoryStream; +result := I2OSP( m1, k, EM, n.FPool); // EM len = k +if not result then exit; +{$IFDEF SI} +SiMain.LogInteger( 'k', k); +SiMain.LogStream( 'EM', EM); +{$ENDIF} + +// Step 3.a +CheckHashOfNil; // HashOfNil has hLen = 20 bytes. + +// Step 3.b EM = Y || maskedSeed || maskedDB. +EM.Position := 0; +EM.Read( Y, 1); +maskedSeed := NewMemoryStream; +maskedSeed.CopyFrom( EM, hLen); +maskedDB := NewMemoryStream; +maskedDB.CopyFrom( EM, k - hLen - 1); +result := Y = 0; +if not result then exit; + +// Step 3.c +// seedMask = MGF(maskedDB, hLen). Len = hLen +seedMask := NewMemoryStream; +MGF1( maskedDB, hLen, seedMask); + +// Step 3.d +// Seed = seed = maskedSeed xor seedMask. Len = hLen +Seed := NewMemoryStream; +Seed.Size := hLen; +XOR_Streams3( Seed, maskedSeed, SeedMask); + +// Step 3.e +// dbMask = MGF1( seed, k - hLen - 1). Len = k - hLen - 1 +dbMask := NewMemoryStream; +MGF1( Seed, k - hLen - 1, dbMask); + +// Step 3.f +// DB = maskedDB xor dbMask. Len = k - hLen - 1 +DB := NewMemoryStream; +DB.Size := k - hLen - 1; +XOR_Streams3( DB, maskedDB, dbMask); + +// Step 3.g +// DB = lHash' || PS || 0x01 || M. +DB.Position := 0; +reconHash := NewMemoryStream; +reconHash.CopyFrom( DB, hLen); +repeat + bytesRead := DB.Read( Y, 1) +until (Y <> 0) or (bytesRead = 0); +mLen := DB.Size - DB.Position; +result := CompareMemoryStreams( reconHash, HashOfNil) and + (Y = 1) and (bytesRead = 1) and (mLen > 0); +if not result then exit; + +// Step 4: Output the message M +M.CopyFrom( DB, mLen) + +finally +DB.Free; Seed.Free; dbMask.Free; maskedDB.Free; seedMask.Free; +maskedSeed.Free; EM.Free; m1.Free; reconHash.Free +{$IFDEF SI} +;SiMain.LeaveMethod( 'RSAES_OAEP_DECRYPT'); +{$ENDIF} +end end; + + + + +function Generate_RSA_SymetricKey( + n, e: THugeCardinal; CipherStream: TStream; + const SymetricCipher: IBlockCipher): TSymetricKey; +// 1. Make a random Seed stream of size IBlockCipher.SeedByteSize +// 2. Create the key with IBlockCipher.GenerateKey( Seed) +// 3. Create a mememto of the key with TSymetricKey.SaveToStream +// 4. Measure the size of this stream. It needs to be transmitted. +// 6. Prefix the cipherstream with the count of chunks. +// 5. Process this stream RSAES_OAEP_ENCRYPT_MaxByteLen bytes at a time. +// Each RSAES_OAEP_ENCRYPT_MaxByteLen or part-thereof is a key chunk. +// In most cases, we will probably only get one key chunk. +// 6. On each key chunk, call function RSAES_OAEP_ENCRYPT( n, e, M=chunk, C=output); +// 7. Append each C to the cipherstream. +var + SeedStream, M, C: TMemoryStream; + PayloadSize: integer; + MaxChunk, Chunk: integer; + Ok: boolean; + + function NewMemoryStream( Sz: integer): TMemoryStream; + begin + if assigned( n.FPool) then + result := n.FPool.NewMemoryStream( Sz) + else + begin + result := TMemoryStream.Create; + result.Size := Sz + end + end; + +begin +result := nil; +SeedStream := NewMemoryStream( SymetricCipher.SeedByteSize); +try +RandomFillStream( SeedStream); +result := SymetricCipher.GenerateKey( SeedStream); +SeedStream.Position := 0; +result.SaveToStream( SeedStream); +PayloadSize := SeedStream.Position; +SeedStream.Size := PayloadSize; +SeedStream.Position := 0; +CipherStream.Write( PayloadSize, 4); +MaxChunk := RSAES_OAEP_ENCRYPT_MaxByteLen( n); +Ok := False; +M := NewMemoryStream( MaxChunk); +C := NewMemoryStream( (n.BitLength + 7) div 8); +try +while (PayloadSize > 0) and (MaxChunk > 0) do + begin + Chunk := Min( PayloadSize, MaxChunk); + M.Size := Chunk; + SeedStream.Read( M.Memory^, Chunk); + Ok := RSAES_OAEP_ENCRYPT( n, e, M, C); + if not Ok then break; + CipherStream.Write( C.Memory^, C.Size); + Dec( PayloadSize, Chunk) + end; +finally +FreeAndNil( M); +FreeAndNil( C); +end +finally +FreeAndNil( SeedStream) +end; +if not Ok then + FreeAndNil( result) +end; + + + + +function Extract_RSA_SymetricKey( + d, n, p, q, dp, dq, qinv: THugeCardinal; CipherStream: TStream; + const SymetricCipher: IBlockCipher): TSymetricKey; +var + KeyStream, M, C: TMemoryStream; + PayloadSize: integer; + MaxChunk, Chunk, CipherChunkSize: integer; + Ok: boolean; + + function NewMemoryStream( Sz: integer): TMemoryStream; + begin + if assigned( n.FPool) then + result := n.FPool.NewMemoryStream( Sz) + else + begin + result := TMemoryStream.Create; + result.Size := Sz + end + end; + +begin +result := nil; +CipherStream.Read( PayloadSize, 4); +MaxChunk := RSAES_OAEP_ENCRYPT_MaxByteLen( n); +Ok := False; +CipherChunkSize := (n.BitLength + 7) div 8; +KeyStream := NewMemoryStream( 0); +try +M := NewMemoryStream( MaxChunk); +C := NewMemoryStream( CipherChunkSize); +try +while (PayloadSize > 0) and (MaxChunk > 0) do + begin + Chunk := Min( PayloadSize, MaxChunk); + C.Size := CipherChunkSize; + Ok := (CipherStream.Read( C.Memory^, CipherChunkSize) = CipherChunkSize) and + RSAES_OAEP_DECRYPT( d, n, C, M, p, q, dp, dq, qinv) and (M.Size = Chunk); + if not Ok then break; + KeyStream.Write( M.Memory^, Chunk); + Dec( PayloadSize, Chunk) + end; +finally +FreeAndNil( M); +FreeAndNil( C); +end; +KeyStream.Position := 0; +if Ok then + result := SymetricCipher.LoadKeyFromStream( KeyStream) +finally +FreeAndNil( KeyStream) +end end; + + + +procedure ClearLeftMostBits( Stream: TStream; BitsToClear: integer); +var + aByte, ClearFlags: byte; + j: integer; +begin +// BitsToClear == (8 * emLen) - emBits +if BitsToClear <= 0 then exit; +Assert( BitsToClear <= 8, ''); +Stream.Position := 0; +Stream.Read( aByte, 1); +// For RFC 3447, "left--most" will be read as Most Signficant. +ClearFlags := $80; +for j := 2 to BitsToClear do + ClearFlags := (ClearFlags shr 1) + $80; +aByte := aByte and (not ClearFlags); +Stream.Position := 0; +Stream.Write( aByte, 1) +end; + + + +type +TDocumentProgressMonitor = class + private + FDelegate: TOnHashProgress; + + function OnHashProgress( + Sender: TObject; CountBytesProcessed: int64): boolean; + public + constructor Create( Delegate1: TOnHashProgress); + end; + +function EMSA_PSS_ENCODE( M: TStream; emBits, sLen: integer; EM: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +// EMSA-PSS-ENCODE is the RSA message encoding primitive used by Sign & Verify. +// Inputs: +// M message to be encoded, an octet string. +// emBits maximal bit length of the integer OS2IP (EM), +// at least 8hLen + 8sLen + 9 +// sLen Intended length in octets of the salt +// Outputs: +// EM encoded message, an octet string of length emLen = \ceil +// (emBits/8) +// result True if successful; False if failed (due to emBits being too small.) +// Using: +// Hash hash function (hLen denotes the length in octets of the hash +// function output) used is SHA-1. +// MGF mask generation function uses is MGF1. +var + HashObj: TObject; + Hash: IHash; + mHash: TStream; + hLen1, emLen: integer; + M_Dash: TStream; // M' + Zero_8Bytes: uint64; + aByte: byte; + SaltP: int64; + H, DB, maskedDB, dbMask: TMemoryStream; + j: integer; + Monitor: TDocumentProgressMonitor; + Ok: boolean; + +begin +result := opFail; +// 1. [Step 1 of the standard unecessary]. +// 2. Let mHash = Hash(M), an octet string of length hLen. +Zero_8Bytes := 0; +emLen := (emBits + 7) div 8; + +M_Dash := TMemoryStream.Create; +mHash := TMemoryStream.Create; +H := TMemoryStream.Create; +DB := TMemoryStream.Create; +maskedDB := TMemoryStream.Create; +dbMask := TMemoryStream.Create; +try + +M_Dash.Write( Zero_8Bytes, 8); +Hash := AcquireHash( HashObj); +Monitor := TDocumentProgressMonitor.Create( CheckAbortFunc); +try + Hash.OnProgress := Monitor.OnHashProgress; + Hash.HashStream( M); + Hash.OnProgress := nil; + if Hash.isUserAborted then + begin + result := opAbort; + exit + end; + hLen1 := Hash.HashOutputValue.Size; + Hash.WriteHashOutputToStream( M_Dash); + +// 3. If emLen < hLen + sLen + 2, output "encoding error" and stop. + Ok := emLen >= (hLen1 + sLen + 2); + if not Ok then exit; + +// 4. Generate a random octet string salt of length sLen; if sLen = 0, +// then salt is the empty string. +// 5. Let +// M' = (0x)00 00 00 00 00 00 00 00 || mHash || salt; +// M' is an octet string of length 8 + hLen + sLen with eight +// initial zero octets. + SaltP := M_Dash.Position; + M_Dash.CopyFrom( TRandomStream.Instance, sLen); + +// 6. Let H = Hash(M'), an octet string of length hLen. + Hash.HashStream( M_Dash); + Hash.WriteHashOutputToStream( H); + +// 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2 +// zero octets. The length of PS may be 0. + aByte := 0; + for j := 1 to emLen - sLen - hLen1 - 2 do + DB.Write( aByte, 1); + +// 8. Let DB = PS || 0x01 || salt; DB is an octet string of length +// emLen - hLen - 1. + aByte := $01; + DB.Write( aByte, 1); + M_Dash.Position := SaltP; + DB.CopyFrom( M_Dash, sLen); + +// 9. Let dbMask = MGF(H, emLen - hLen - 1). + MGF1( H, emLen - hLen -1, dbMask) +finally + ReleaseHash( HashObj, Hash); + Monitor.Free +end; + +// 10. Let maskedDB = DB \xor dbMask. +maskedDB.Size := DB.Size; +XOR_Streams3( maskedDB, DB, dbMask); + +// 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in +// maskedDB to zero. +ClearLeftMostBits( maskedDB, (8 * emLen) - emBits); + +// 12. Let EM = maskedDB || H || 0xbc. +// 13. Output EM. +EM.CopyFrom( maskedDB, 0); +EM.CopyFrom( H, 0); +aByte := $BC; +EM.Write( aByte, 1) + +finally +M_Dash.Free; +mHash.Free; +H.Free; +DB.Free; +maskedDB.Free; +dbMask.Free +end; +if Ok then + result := opPass +end; + + +function EMSA_PSS_VERIFY( M: TStream; emBits, sLen: integer; EM: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +var + HashObj: TObject; + Hash: IHash; + mHash: TStream; + hLen1, emLen: integer; + M_Dash: TStream; // M' + Zero_8Bytes: uint64; + aByte, ClearFlags: byte; +// SaltP: int64; + H, DB, maskedDB, dbMask, reconH: TMemoryStream; + j: integer; + Monitor: TDocumentProgressMonitor; + Ok: boolean; +begin +Monitor := nil; +result := opFail; +Zero_8Bytes := 0; +emLen := (emBits + 7) div 8; + +M_Dash := TMemoryStream.Create; +mHash := TMemoryStream.Create; +reconH := TMemoryStream.Create; +H := TMemoryStream.Create; +DB := TMemoryStream.Create; +maskedDB := TMemoryStream.Create; +dbMask := TMemoryStream.Create; +try + +M_Dash.Write( Zero_8Bytes, 8); +Hash := AcquireHash( HashObj); +try + Monitor := TDocumentProgressMonitor.Create( CheckAbortFunc); + Hash.OnProgress := Monitor.OnHashProgress; + Hash.HashStream( M); + Hash.OnProgress := nil; + if Hash.isUserAborted then + begin + result := opAbort; + exit + end; + hLen1 := Hash.HashOutputValue.Size; + Hash.WriteHashOutputToStream( M_Dash); + + // mHash := Hash( M) + // M' = 00 00 00 00 00 00 00 00 || mHash + Ok := emLen >= (hLen1 + sLen + 2); + if not Ok then exit; + + // Recover maskedDB from ( EM == (maskedDB || H || $BC)) + EM.Position := 0; + maskedDB.Size := emLen - hLen1 - 1; + Ok := EM.Read( maskedDB.Memory^, maskedDB.Size) = maskedDB.Size; + + // Recover H from ( EM == (maskedDB || H || $BC)) + H.Size := hLen1; + Ok := Ok and (EM.Read( H.Memory^, hLen1) = hLen1) and + (EM.Read( aByte, 1) = 1) and + (aByte = $BC); // checks $BC byte. + if not Ok then exit; + + // check maskedDB[leftmost 8emLen - emBits bits] == 0 + if (8 * emLen) > emBits then + begin + maskedDB.Position := 0; + MaskedDB.Read( aByte, 1); + // For RFC 3447, "left--most" will be read as Most Signficant. + ClearFlags := $80; + for j := emBits to 8 * emLen - 2 do + ClearFlags := (ClearFlags shr 1) + $80; + Ok := (aByte and ClearFlags) = 0; + maskedDB.Position := 0 + end; + + // dbMask := MGF( H, emLen - hLen - 1) + MGF1( H, emLen - hLen -1, dbMask); + + // DB := maskedDB xor dbMask + DB.Size := dbMask.Size; + XOR_Streams3( DB, maskedDB, dbMask); + + // DB[ 8emLen - emBits bits] := 0 + ClearLeftMostBits( DB, (8 * emLen) - emBits); + + // Extract PS from DB = PS || $01 || salt + // and then check PS = 0 + DB.Position := 0; + for j := 0 to emLen - sLen - hLen - 3 do + begin + Ok := (DB.Read( aByte, 1) = 1) and (aByte = 0); + if not Ok then break + end; + if not Ok then exit; + + // Extract $01 from DB = PS || $01 || salt + // and check it + Ok := (DB.Read( aByte, 1) = 1) and (aByte = $01); + if not Ok then exit; + + // M' = 00 00 00 00 00 00 00 00 || mHash || salt; + M_Dash.CopyFrom( DB, sLen); + M_Dash.Position := 0; + + // H' = Hash(M') + Hash.HashStream( M_Dash); + reconH.Size := hLen1; + reconH.Position := 0; + Hash.WriteHashOutputToStream( reconH); + +finally + ReleaseHash( HashObj, Hash); + Monitor.Free +end; + +// check H == H' +Ok := CompareMemoryStreams( reconH, H) +finally +M_Dash.Free; +mHash.Free; +H.Free; +DB.Free; +maskedDB.Free; +dbMask.Free; +reconH.Free +end; +if Ok then + result := opPass +end; + + + + + + +const + MaxSaltLength = 20; + +function RSASSA_PSS_SIGN ( d, n: THugeCardinal; M, S: TStream; + CheckAbortFunc: TOnHashProgress; + p, q, dp, dq, qinv: THugeCardinal): TLongOpResult; +// TO DO: Check for user abort. + +// RSASSA-PSS-SIGN is the RSA signature generation primitive. +// Inputs: +// d The signer's RSA private key exponent. +// n The signer's RSA public key modulus. +// M The message to be signed. +// Outputs: +// S The signature. An octet string of length k, where k is the +// length in octets of the RSA modulus n +// result = opPass The operation was successful. +// = opFail The operation failed for some reason other than user abort. +// = opAbort The operation was aborted by the user before it could be completed. +var + modBits: integer; + hLen1: integer; + EM: TStream; + Ok: boolean; + SaltLength, k: integer; + Little_m: THugeCardinal; + EMLen: integer; +begin +// 1. EMSA-PSS encoding: Apply the EMSA-PSS encoding operation (Section +// 9.1.1) to the message M to produce an encoded message EM of length +// \ceil ((modBits - 1)/8) octets such that the bit length of the +// integer OS2IP (EM) (see Section 4.2) is at most modBits - 1, where +// modBits is the length in bits of the RSA modulus n: +// EM = EMSA-PSS-ENCODE (M, modBits - 1). +modBits := n.BitLength; +k := (modBits + 7) div 8; +EMLen := (modBits + 6) div 8; +hLen1 := hLen; +SaltLength := Max( Min( EMLen - hLen1 - 2, MaxSaltLength), 0); +Little_m := nil; +EM := TMemoryStream.Create; +try +result := EMSA_PSS_ENCODE( M, modBits - 1, SaltLength, EM, CheckAbortFunc); +if result = opAbort then exit; +Ok := result = opPass; + +// EM.Size == EMLen == (modBits + 6) div 8 + +// 2. RSA signature: +// a. Convert the encoded message EM to an integer message +// representative m (see Section 4.2): +// m = OS2IP (EM). +EM.Position := 0; +Ok := Ok and OS2IP( EM, EMLen, Little_m, n.FPool, n.MaxBits); + +// b. Apply the RSASP1 signature primitive (Section 5.2.1) to the RSA +// private key K and the message representative m to produce an +// integer signature representative s: +// s = RSASP1 (K, m). +if Ok then + begin + if UseCRT then + Little_m.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil) + else + Little_m.PowerMod( d, n, nil); // 0 <= m1 < n + end; + +// c. Convert the signature representative s to a signature S of +// length k octets (see Section 4.1): +// S = I2OSP (s, k). +Ok := Ok and I2OSP( Little_m, k, S, n.FPool) +finally + EM.Free; + Little_m.Free + end; +if Ok then + result := opPass + else + result := opFail +end; + + +function RSASSA_PSS_VERIFY( n, e: THugeCardinal; M, S: TStream; + CheckAbortFunc: TOnHashProgress): TLongOpResult; +// RSASSA-PSS-VERIFY +// Inputs: +// n The signer's RSA public key modulus. +// e The signer's RSA private key exponent. +// M The message whose signature is to be verified. +// S The signature to be verified. +// Outputs: +// result = opPass The verification passed. +// = opFail The verification failed for some reason other than user abort. +// = opAbort The verification was aborted by the user before it could be completed. +var + Little_s: THugeCardinal; + Ok: boolean; + modBits, k, EMLen, SaltLength: integer; + EM: TStream; + +begin +// 1. Length checking: If the length of the signature S is not k octets, +// output "invalid signature" and stop. +// 2.a. Convert the signature S to an integer signature representative +// s (see Section 4.2): +// s = OS2IP (S). +modBits := n.BitLength; +k := (modBits + 7) div 8; +EMLen := (modBits + 6) div 8; +SaltLength := Max( Min( EMLen - hLen1 - 2, MaxSaltLength), 0); +Little_s := nil; +try +Ok := OS2IP( S, k, Little_s, n.FPool, n.bitlength); + +// 2.b. Apply the RSAVP1 verification primitive (Section 5.2.2) to the +// RSA public key (n, e) and the signature representative s to +// produce an integer message representative m: +// m = RSAVP1 ((n, e), s). +Ok := Ok and (Little_s.Compare( n) = rLessThan); +if Ok then + Little_s.PowerMod( e, n, nil); + +// c. Convert the message representative m to an encoded message EM +// of length emLen = \ceil ((modBits - 1)/8) octets, where modBits +// is the length in bits of the RSA modulus n (see Section 4.1): +// EM = I2OSP (m, emLen). +EM := TMemoryStream.Create; +try +Ok := Ok and I2OSP( Little_s, EMLen, EM, n.FPool); + +// 3. EMSA-PSS verification: Apply the EMSA-PSS verification operation +// (Section 9.1.2) to the message M and the encoded message EM to +// determine whether they are consistent: +// Result = EMSA-PSS-VERIFY (M, EM, modBits - 1). +if Ok then + begin + result := EMSA_PSS_VERIFY( M, modBits - 1, SaltLength, EM, CheckAbortFunc); + if result = opAbort then exit; + Ok := result = opPass + end +finally + EM.Free +end; +finally + Little_s.Free +end; +if Ok then + result := opPass + else + result := opFail +end; + + + + + + +{ TDocumentProgressMonitor } + +constructor TDocumentProgressMonitor.Create( Delegate1: TOnHashProgress); +begin +FDelegate := Delegate1 +end; + + +function TDocumentProgressMonitor.OnHashProgress( + Sender: TObject; CountBytesProcessed: int64): boolean; +begin +if assigned( FDelegate) then + result := FDelegate( Sender, CountBytesProcessed) + else + result := True +end; + + +initialization +InitUnit_RSA_Primitives; + +finalization +DoneUnit_RSA_Primitives; + +end. diff --git a/run/TPLB3.Random.pas b/LockBox3/run/TPLB3.Random.pas similarity index 95% rename from run/TPLB3.Random.pas rename to LockBox3/run/TPLB3.Random.pas index 5798448..8fe4f9d 100644 --- a/run/TPLB3.Random.pas +++ b/LockBox3/run/TPLB3.Random.pas @@ -1,291 +1,291 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Random; -interface -uses Classes; - -type - -TRandomStream = class( TStream) - private - FValue: int64; - FBuffer: int64; - FAvail: integer; - - procedure Crunch; - procedure SetSeed( Value: int64); - - protected - function GetSize: Int64; override; - procedure SetSize( const NewSize: Int64); override; - - public - constructor Create; - destructor Destroy; override; - class function Instance: TRandomStream; - - function Read ( var Buffer; Count: Longint): Longint; override; - function Write( const Buffer; Count: Longint): Longint; override; - function Seek ( const Offset: Int64; Origin: TSeekOrigin): Int64; override; - - procedure Randomize; - - property Seed: int64 read FValue write SetSeed; - end; - - -implementation - - - - - - -uses Math, {$IFDEF MSWINDOWS}Windows,{$ENDIF} SysUtils, TPLB3.IntegerUtils, TPLB3.Compatibility; -var - Inst: TRandomStream = nil; - - - - - - -function TimeStampClock: int64; -{$IFDEF ASSEMBLER} -asm - RDTSC -end; -{$ELSE} -var - SystemTimes: TThread.TSystemTimes; -begin - TThread.GetSystemTimes( SystemTimes); - result := SystemTimes.KernelTime -end; -{$ENDIF} - - -procedure InitUnit_Random; -begin -end; - - -procedure DoneUnit_Random; -begin -Inst.Free -end; - - -{$IFDEF MSWINDOWS} -function CryptAcquireContext( - var phProv: THandle; - pszContainer, pszProvider: PChar; - dwProvType, dwFlags: DWORD): bool; - stdcall; external advapi32 - {$IFDEF UNICODE} - name 'CryptAcquireContextW'; - {$ELSE} - name 'CryptAcquireContextA'; - {$ENDIF} - -function CryptReleaseContext( - hProv: THandle; - dwFlags: DWORD): bool; - stdcall; external advapi32 name 'CryptReleaseContext'; - -function CryptGenRandom( - hProv: THandle; - dwLen: DWORD; - pbBuffer: pointer): bool; - stdcall; external advapi32 name 'CryptGenRandom'; - -const - PROV_RSA_FULL = 1; - CRYPT_SILENT = 64; - Provider = 'Microsoft Base Cryptographic Provider v1.0'; -{$ENDIF} - - - - - -{ TRandomStream } - -constructor TRandomStream.Create; -begin -if not assigned( Inst) then - Inst := self; -Randomize -end; - - -{$OVERFLOWCHECKS OFF} {$RANGECHECKS OFF} -procedure TRandomStream.Crunch; -// Refer http://www.merlyn.demon.co.uk/pas-rand.htm -const - Factor: int64 = 6364136223846793005; -begin -FValue := FValue * Factor + 1 ; -FBuffer := FValue; -FAvail := SizeOf( FValue) -end; -{$RANGECHECKS ON} {$OVERFLOWCHECKS ON} - - -destructor TRandomStream.Destroy; -begin -if Inst = self then - Inst := nil; -inherited -end; - - -function TRandomStream.GetSize: Int64; -begin -result := 0 -end; - - -class function TRandomStream.Instance: TRandomStream; -begin -if not assigned( Inst) then - TRandomStream.Create; -result := Inst -end; - - -procedure TRandomStream.Randomize; -{$IFDEF MSWINDOWS} -var - hProv: THandle; - dwProvType, dwFlags: DWORD; - Provider1: string; - hasOpenHandle: boolean; -{$ENDIF} -begin -{$IFDEF MSWINDOWS} -Provider1 := Provider; -dwProvType := PROV_RSA_FULL; -dwFlags := CRYPT_SILENT; -hasOpenHandle := CryptAcquireContext( hProv, nil, PChar( Provider), dwProvType, dwFlags); -try - if (not hasOpenHandle) or (not CryptGenRandom( hProv, SizeOf( FValue), @FValue)) then - FValue := TimeStampClock -finally - if hasOpenHandle then - CryptReleaseContext( hProv, 0) - end; -{$ELSE} - FValue := TimeStampClock; -{$ENDIF} -Crunch -end; - - - - -function TRandomStream.Read( var Buffer; Count: Integer): Longint; -var - P: PByte; - Amnt, AmntBits, C: integer; - Harv: int64; - Carry: uint32; -begin -result := Max( Count, 0); -if result <= 0 then exit; -P := @Buffer; -C := result; -repeat - Amnt := Min( FAvail, C); - Move( FBuffer, P^, Amnt); - Dec( FAvail, Amnt); - Dec( C, Amnt); - Inc( P, Amnt); - if FAvail <= 0 then - Crunch - else - begin - Harv := FBuffer; - if Amnt >= 4 then - begin - Int64Rec( Harv).Lo := Int64Rec( Harv).Hi; - Int64Rec( Harv).Hi := 0; - Dec( Amnt, 4) - end; - if Amnt > 0 then - begin - AmntBits := Amnt * 8; - Carry := Int64Rec( Harv).Hi shl (32 - (AmntBits)); - Int64Rec( Harv).Hi := Int64Rec( Harv).Hi shr AmntBits; - Int64Rec( Harv).Lo := (Int64Rec( Harv).Lo shr AmntBits) or Carry; - end; - FBuffer := Harv - end -until C <= 0 -end; - - -function TRandomStream.Seek( const Offset: Int64; Origin: TSeekOrigin): Int64; -begin -result := 0 -end; - - -procedure TRandomStream.SetSeed( Value: int64); -begin -FValue := Value; -FBuffer := FValue; -FAvail := SizeOf( FBuffer) -end; - - -procedure TRandomStream.SetSize( const NewSize: Int64); -begin -end; - - -function TRandomStream.Write( const Buffer; Count: Integer): Longint; -begin -result := Count -end; - - - -initialization -InitUnit_Random; - -finalization -DoneUnit_Random; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Random; +interface +uses Classes; + +type + +TRandomStream = class( TStream) + private + FValue: int64; + FBuffer: int64; + FAvail: integer; + + procedure Crunch; + procedure SetSeed( Value: int64); + + protected + function GetSize: Int64; override; + procedure SetSize( const NewSize: Int64); override; + + public + constructor Create; + destructor Destroy; override; + class function Instance: TRandomStream; + + function Read ( var Buffer; Count: Longint): Longint; override; + function Write( const Buffer; Count: Longint): Longint; override; + function Seek ( const Offset: Int64; Origin: TSeekOrigin): Int64; override; + + procedure Randomize; + + property Seed: int64 read FValue write SetSeed; + end; + + +implementation + + + + + + +uses Math, {$IFDEF MSWINDOWS}Windows,{$ENDIF} SysUtils, TPLB3.IntegerUtils, TPLB3.Compatibility; +var + Inst: TRandomStream = nil; + + + + + + +function TimeStampClock: int64; +{$IFDEF ASSEMBLER} +asm + RDTSC +end; +{$ELSE} +var + SystemTimes: TThread.TSystemTimes; +begin + TThread.GetSystemTimes( SystemTimes); + result := SystemTimes.KernelTime +end; +{$ENDIF} + + +procedure InitUnit_Random; +begin +end; + + +procedure DoneUnit_Random; +begin +Inst.Free +end; + + +{$IFDEF MSWINDOWS} +function CryptAcquireContext( + var phProv: THandle; + pszContainer, pszProvider: PChar; + dwProvType, dwFlags: DWORD): bool; + stdcall; external advapi32 + {$IFDEF UNICODE} + name 'CryptAcquireContextW'; + {$ELSE} + name 'CryptAcquireContextA'; + {$ENDIF} + +function CryptReleaseContext( + hProv: THandle; + dwFlags: DWORD): bool; + stdcall; external advapi32 name 'CryptReleaseContext'; + +function CryptGenRandom( + hProv: THandle; + dwLen: DWORD; + pbBuffer: pointer): bool; + stdcall; external advapi32 name 'CryptGenRandom'; + +const + PROV_RSA_FULL = 1; + CRYPT_SILENT = 64; + Provider = 'Microsoft Base Cryptographic Provider v1.0'; +{$ENDIF} + + + + + +{ TRandomStream } + +constructor TRandomStream.Create; +begin +if not assigned( Inst) then + Inst := self; +Randomize +end; + + +{$OVERFLOWCHECKS OFF} {$RANGECHECKS OFF} +procedure TRandomStream.Crunch; +// Refer http://www.merlyn.demon.co.uk/pas-rand.htm +const + Factor: int64 = 6364136223846793005; +begin +FValue := FValue * Factor + 1 ; +FBuffer := FValue; +FAvail := SizeOf( FValue) +end; +{$RANGECHECKS ON} {$OVERFLOWCHECKS ON} + + +destructor TRandomStream.Destroy; +begin +if Inst = self then + Inst := nil; +inherited +end; + + +function TRandomStream.GetSize: Int64; +begin +result := 0 +end; + + +class function TRandomStream.Instance: TRandomStream; +begin +if not assigned( Inst) then + TRandomStream.Create; +result := Inst +end; + + +procedure TRandomStream.Randomize; +{$IFDEF MSWINDOWS} +var + hProv: THandle; + dwProvType, dwFlags: DWORD; + Provider1: string; + hasOpenHandle: boolean; +{$ENDIF} +begin +{$IFDEF MSWINDOWS} +Provider1 := Provider; +dwProvType := PROV_RSA_FULL; +dwFlags := CRYPT_SILENT; +hasOpenHandle := CryptAcquireContext( hProv, nil, PChar( Provider), dwProvType, dwFlags); +try + if (not hasOpenHandle) or (not CryptGenRandom( hProv, SizeOf( FValue), @FValue)) then + FValue := TimeStampClock +finally + if hasOpenHandle then + CryptReleaseContext( hProv, 0) + end; +{$ELSE} + FValue := TimeStampClock; +{$ENDIF} +Crunch +end; + + + + +function TRandomStream.Read( var Buffer; Count: Integer): Longint; +var + P: PByte; + Amnt, AmntBits, C: integer; + Harv: int64; + Carry: uint32; +begin +result := Max( Count, 0); +if result <= 0 then exit; +P := @Buffer; +C := result; +repeat + Amnt := Min( FAvail, C); + Move( FBuffer, P^, Amnt); + Dec( FAvail, Amnt); + Dec( C, Amnt); + Inc( P, Amnt); + if FAvail <= 0 then + Crunch + else + begin + Harv := FBuffer; + if Amnt >= 4 then + begin + Int64Rec( Harv).Lo := Int64Rec( Harv).Hi; + Int64Rec( Harv).Hi := 0; + Dec( Amnt, 4) + end; + if Amnt > 0 then + begin + AmntBits := Amnt * 8; + Carry := Int64Rec( Harv).Hi shl (32 - (AmntBits)); + Int64Rec( Harv).Hi := Int64Rec( Harv).Hi shr AmntBits; + Int64Rec( Harv).Lo := (Int64Rec( Harv).Lo shr AmntBits) or Carry; + end; + FBuffer := Harv + end +until C <= 0 +end; + + +function TRandomStream.Seek( const Offset: Int64; Origin: TSeekOrigin): Int64; +begin +result := 0 +end; + + +procedure TRandomStream.SetSeed( Value: int64); +begin +FValue := Value; +FBuffer := FValue; +FAvail := SizeOf( FBuffer) +end; + + +procedure TRandomStream.SetSize( const NewSize: Int64); +begin +end; + + +function TRandomStream.Write( const Buffer; Count: Integer): Longint; +begin +result := Count +end; + + + +initialization +InitUnit_Random; + +finalization +DoneUnit_Random; + + +end. diff --git a/run/TPLB3.SHA1.pas b/LockBox3/run/TPLB3.SHA1.pas similarity index 95% rename from run/TPLB3.SHA1.pas rename to LockBox3/run/TPLB3.SHA1.pas index 82b687e..21f2f96 100644 --- a/run/TPLB3.SHA1.pas +++ b/LockBox3/run/TPLB3.SHA1.pas @@ -1,312 +1,313 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.SHA1; -interface -uses classes, TPLB3.HashDsc, TPLB3.StreamCipher; - -type - -TSHA1 = class( TInterfacedObject, IHashDsc, ICryptoGraphicAlgorithm) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DigestSize: integer; // in units of bits. Must be a multiple of 8. - function UpdateSize: integer; // Size that the input to the Update must be. - function MakeHasher( const Params: IInterface): IHasher; - function DefinitionURL: string; - function WikipediaReference: string; - end; - - - - - -implementation - - - - - - - - - -// References -// 1. http://www.itl.nist.gov/fipspubs/fip180-1.htm - - - - -uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, - TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; - -type -TSHA1_Hasher = class( TInterfacedObject, IHasher) - private - H: array[ 0.. 5 ] of uint32; - FCount: int64; - - constructor Create; - procedure Update( Source{in}: TMemoryStream); - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); - procedure Burn; - function SelfTest_Source: string; - function SelfTest_ReferenceHashValue: string; - end; - - - - - - - - -{ TSHA1 } - -function TSHA1.DisplayName: string; -begin -result := 'SHA-1' -end; - -function TSHA1.ProgId: string; -begin -result := SHA1_ProgId -end; - -function TSHA1.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware, afCryptographicallyWeak] -end; - -function TSHA1.DefinitionURL: string; -begin -result := 'http://www.itl.nist.gov/fipspubs/fip180-1.htm' -end; - -function TSHA1.DigestSize: integer; -begin -result := 160 -end; - -function TSHA1.UpdateSize: integer; -begin -result := 512 -end; - - - -function TSHA1.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} 'SHA1' -end; - - - -function TSHA1.MakeHasher( const Params: IInterface): IHasher; -begin -result := TSHA1_Hasher.Create -end; - - -{ TSHA1_Hasher } - -procedure TSHA1_Hasher.Burn; -begin -BurnMemory( H, SizeOf( H)); -FCount := 0 -end; - - - -constructor TSHA1_Hasher.Create; -begin -H[0] := $67452301; -H[1] := $EFCDAB89; -H[2] := $98BADCFE; -H[3] := $10325476; -H[4] := $C3D2E1F0; -FCount := 0 -end; - -const Pad: packed array [ 0.. 64] of byte = ( - $80, - $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, - $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, - $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, - $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00); - -procedure TSHA1_Hasher.End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); -var - L, j: integer; - PadLen: integer; - Injection, Block: TMemoryStream; - Count: int64; - lwDigest: uint32; -begin -L := PartBlock.Position; -Assert( L <= 64, 'TSHA1_Hasher.End_Hash - Wrong block size.'); -Inc( FCount, L * 8); -PadLen := 64 - ((L + 8) mod 64); -Injection := TMemoryStream.Create; -Block := TMemoryStream.Create; -try -if L > 0 then - Injection.Write( PartBlock.Memory^, L); -Injection.Write( Pad, PadLen); -Count := SwapEndien_s64( FCount); -Injection.Write( Count, 8); -Block.Size := 64; -Inc( L, PadLen + 8); -repeat - Move( Injection.Memory^, Block.Memory^, 64); - if L > 64 then - Move( MemStrmOffset( Injection, 64)^, Injection.Memory^, L - 64); - Dec( L, 64); - Injection.Size := L; - Update( Block) -until L <= 0 -finally -BurnMemoryStream( Injection); -Injection.Free; -BurnMemoryStream( Block); -Block.Free; -end; -Digest.Position := 0; -for j := 0 to 4 do - begin - lwDigest := SwapEndien_u32( H[j]); - Digest.WriteBuffer( lwDigest, 4) - end; -Digest.Position := 0; -// Burning -Count := 0; -lwDigest := 0 -end; - - - -function TSHA1_Hasher.SelfTest_Source: string; -// From sample 2 of Appendix B of reference 1. -begin -result := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' -end; - - - - -function TSHA1_Hasher.SelfTest_ReferenceHashValue: string; -// From sample 2 of Appendix B of reference 1. -begin -result := '84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1' -end; - - - - - - -procedure TSHA1_Hasher.Update( Source: TMemoryStream); -var - t: integer; - TEMP: uint32; - Arotl5: uint32; - W: array[ 0 .. 79 ] of uint32; - A, B, C, D, E: uint32; -begin -Assert( Source.Size = 64, 'TSHA1_Hasher.Update - Wrong block size.'); -Inc( FCount, 512); -Move( Source.Memory^, W, 64); -for t := 0 to 15 do - W[t] := SwapEndien_u32( W[t]); -for t := 16 to 79 do - W[t]:= RotateLeft1Bit_u32( - W[t-3] xor W[t-8] xor W[t-14] xor W[t-16]); -A := H[0]; -B := H[1]; -C := H[2]; -D := H[3]; -E := H[4]; - -for t := 0 to 19 do - begin - Arotl5 := (A shl 5) or (A shr 27); - TEMP := Arotl5 + ((B and C) or ((not B) and D)) + E + W[t] + $5A827999; - E := D; - D := C; - C := (B shl 30) or (B shr 2); - B := A; - A := TEMP - end; - -for t := 20 to 39 do - begin - Arotl5 := (A shl 5) or (A shr 27); - TEMP := Arotl5 + (B xor C xor D) + E + W[t] + $6ED9EBA1; - E := D; - D := C; - C := (B shl 30) or (B shr 2); - B := A; - A := TEMP - end; - -for t := 40 to 59 do - begin - Arotl5 := (A shl 5) or (A shr 27); - TEMP := Arotl5 + ((B and C) or (B and D) or (C and D)) + E + W[t] + $8F1BBCDC; - E := D; - D := C; - C := (B shl 30) or (B shr 2); - B := A; - A := TEMP - end; - -for t := 60 to 79 do - begin - Arotl5 := (A shl 5) or (A shr 27); - TEMP := Arotl5 + (B xor C xor D) + E + W[t] + $CA62C1D6; - E := D; - D := C; - C := (B shl 30) or (B shr 2); - B := A; - A := TEMP - end; - -H[0] := H[0] + A; -H[1] := H[1] + B; -H[2] := H[2] + C; -H[3] := H[3] + D; -H[4] := H[4] + E -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.SHA1; +{$OVERFLOWCHECKS OFF} +interface +uses classes, TPLB3.HashDsc, TPLB3.StreamCipher; + +type + +TSHA1 = class( TInterfacedObject, IHashDsc, ICryptoGraphicAlgorithm) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DigestSize: integer; // in units of bits. Must be a multiple of 8. + function UpdateSize: integer; // Size that the input to the Update must be. + function MakeHasher( const Params: IInterface): IHasher; + function DefinitionURL: string; + function WikipediaReference: string; + end; + + + + + +implementation + + + + + + + + + +// References +// 1. http://www.itl.nist.gov/fipspubs/fip180-1.htm + + + + +uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, + TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; + +type +TSHA1_Hasher = class( TInterfacedObject, IHasher) + private + H: array[ 0.. 5 ] of uint32; + FCount: int64; + + constructor Create; + procedure Update( Source{in}: TMemoryStream); + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); + procedure Burn; + function SelfTest_Source: string; + function SelfTest_ReferenceHashValue: string; + end; + + + + + + + + +{ TSHA1 } + +function TSHA1.DisplayName: string; +begin +result := 'SHA-1' +end; + +function TSHA1.ProgId: string; +begin +result := SHA1_ProgId +end; + +function TSHA1.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware, afCryptographicallyWeak] +end; + +function TSHA1.DefinitionURL: string; +begin +result := 'http://www.itl.nist.gov/fipspubs/fip180-1.htm' +end; + +function TSHA1.DigestSize: integer; +begin +result := 160 +end; + +function TSHA1.UpdateSize: integer; +begin +result := 512 +end; + + + +function TSHA1.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} 'SHA1' +end; + + + +function TSHA1.MakeHasher( const Params: IInterface): IHasher; +begin +result := TSHA1_Hasher.Create +end; + + +{ TSHA1_Hasher } + +procedure TSHA1_Hasher.Burn; +begin +BurnMemory( H, SizeOf( H)); +FCount := 0 +end; + + + +constructor TSHA1_Hasher.Create; +begin +H[0] := $67452301; +H[1] := $EFCDAB89; +H[2] := $98BADCFE; +H[3] := $10325476; +H[4] := $C3D2E1F0; +FCount := 0 +end; + +const Pad: packed array [ 0.. 64] of byte = ( + $80, + $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, + $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, + $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, + $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00); + +procedure TSHA1_Hasher.End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); +var + L, j: integer; + PadLen: integer; + Injection, Block: TMemoryStream; + Count: int64; + lwDigest: uint32; +begin +L := PartBlock.Position; +Assert( L <= 64, 'TSHA1_Hasher.End_Hash - Wrong block size.'); +Inc( FCount, L * 8); +PadLen := 64 - ((L + 8) mod 64); +Injection := TMemoryStream.Create; +Block := TMemoryStream.Create; +try +if L > 0 then + Injection.Write( PartBlock.Memory^, L); +Injection.Write( Pad, PadLen); +Count := SwapEndien_s64( FCount); +Injection.Write( Count, 8); +Block.Size := 64; +Inc( L, PadLen + 8); +repeat + Move( Injection.Memory^, Block.Memory^, 64); + if L > 64 then + Move( MemStrmOffset( Injection, 64)^, Injection.Memory^, L - 64); + Dec( L, 64); + Injection.Size := L; + Update( Block) +until L <= 0 +finally +BurnMemoryStream( Injection); +Injection.Free; +BurnMemoryStream( Block); +Block.Free; +end; +Digest.Position := 0; +for j := 0 to 4 do + begin + lwDigest := SwapEndien_u32( H[j]); + Digest.WriteBuffer( lwDigest, 4) + end; +Digest.Position := 0; +// Burning +Count := 0; +lwDigest := 0 +end; + + + +function TSHA1_Hasher.SelfTest_Source: string; +// From sample 2 of Appendix B of reference 1. +begin +result := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' +end; + + + + +function TSHA1_Hasher.SelfTest_ReferenceHashValue: string; +// From sample 2 of Appendix B of reference 1. +begin +result := '84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1' +end; + + + + + + +procedure TSHA1_Hasher.Update( Source: TMemoryStream); +var + t: integer; + TEMP: uint32; + Arotl5: uint32; + W: array[ 0 .. 79 ] of uint32; + A, B, C, D, E: uint32; +begin +Assert( Source.Size = 64, 'TSHA1_Hasher.Update - Wrong block size.'); +Inc( FCount, 512); +Move( Source.Memory^, W, 64); +for t := 0 to 15 do + W[t] := SwapEndien_u32( W[t]); +for t := 16 to 79 do + W[t]:= RotateLeft1Bit_u32( + W[t-3] xor W[t-8] xor W[t-14] xor W[t-16]); +A := H[0]; +B := H[1]; +C := H[2]; +D := H[3]; +E := H[4]; + +for t := 0 to 19 do + begin + Arotl5 := (A shl 5) or (A shr 27); + TEMP := Arotl5 + ((B and C) or ((not B) and D)) + E + W[t] + $5A827999; + E := D; + D := C; + C := (B shl 30) or (B shr 2); + B := A; + A := TEMP + end; + +for t := 20 to 39 do + begin + Arotl5 := (A shl 5) or (A shr 27); + TEMP := Arotl5 + (B xor C xor D) + E + W[t] + $6ED9EBA1; + E := D; + D := C; + C := (B shl 30) or (B shr 2); + B := A; + A := TEMP + end; + +for t := 40 to 59 do + begin + Arotl5 := (A shl 5) or (A shr 27); + TEMP := Arotl5 + ((B and C) or (B and D) or (C and D)) + E + W[t] + $8F1BBCDC; + E := D; + D := C; + C := (B shl 30) or (B shr 2); + B := A; + A := TEMP + end; + +for t := 60 to 79 do + begin + Arotl5 := (A shl 5) or (A shr 27); + TEMP := Arotl5 + (B xor C xor D) + E + W[t] + $CA62C1D6; + E := D; + D := C; + C := (B shl 30) or (B shr 2); + B := A; + A := TEMP + end; + +H[0] := H[0] + A; +H[1] := H[1] + B; +H[2] := H[2] + C; +H[3] := H[3] + D; +H[4] := H[4] + E +end; + +end. diff --git a/run/TPLB3.SHA2.pas b/LockBox3/run/TPLB3.SHA2.pas similarity index 96% rename from run/TPLB3.SHA2.pas rename to LockBox3/run/TPLB3.SHA2.pas index fe7297b..1f34686 100644 --- a/run/TPLB3.SHA2.pas +++ b/LockBox3/run/TPLB3.SHA2.pas @@ -1,1349 +1,1349 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2011 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.SHA2; - -// Note to the curious: -// These options settings will soon be migrated to an include file. -// Why are they here? A few units in the project are sensitive to some -// compiler options such as range-check and overflow-check. Normally this -// isnt an issue because units should be compiled into a run-time library -// with options as provided. However, a few users are employing the units -// holistically (not in a library), and in thier applications settings using -// incompatible project options. By explicity setting compiler options here -// and in other sensitive units, we can ensure that the units are compiled -// with options as designed, irrespective of how the developer-user incorporates -// the units (holistic or library). - -// Delphi 7 Options - {$A8,B-,C-,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} - {$MINSTACKSIZE $00004000} - {$MAXSTACKSIZE $00100000} - {$IFDEF MSWINDOWS} - {$IMAGEBASE $00400000} - {$ENDIF} - {$APPTYPE GUI} - {$WARN SYMBOL_DEPRECATED ON} - {$WARN SYMBOL_LIBRARY ON} - {$WARN SYMBOL_PLATFORM ON} - {$WARN UNIT_LIBRARY ON} - {$WARN UNIT_PLATFORM ON} - {$WARN UNIT_DEPRECATED ON} - {$WARN HRESULT_COMPAT ON} - {$WARN HIDING_MEMBER ON} - {$WARN HIDDEN_VIRTUAL ON} - {$WARN GARBAGE ON} - {$WARN BOUNDS_ERROR ON} - {$WARN ZERO_NIL_COMPAT ON} - {$WARN STRING_CONST_TRUNCED ON} - {$WARN FOR_LOOP_VAR_VARPAR ON} - {$WARN TYPED_CONST_VARPAR ON} - {$WARN ASG_TO_TYPED_CONST ON} - {$WARN CASE_LABEL_RANGE ON} - {$WARN FOR_VARIABLE ON} - {$WARN CONSTRUCTING_ABSTRACT ON} - {$WARN COMPARISON_FALSE ON} - {$WARN COMPARISON_TRUE ON} - {$WARN COMPARING_SIGNED_UNSIGNED ON} - {$WARN COMBINING_SIGNED_UNSIGNED ON} - {$WARN UNSUPPORTED_CONSTRUCT ON} - {$WARN FILE_OPEN ON} - {$WARN FILE_OPEN_UNITSRC ON} - {$WARN BAD_GLOBAL_SYMBOL ON} - {$WARN DUPLICATE_CTOR_DTOR ON} - {$WARN INVALID_DIRECTIVE ON} - {$WARN PACKAGE_NO_LINK ON} - {$WARN PACKAGED_THREADVAR ON} - {$WARN IMPLICIT_IMPORT ON} - {$WARN HPPEMIT_IGNORED ON} - {$WARN NO_RETVAL ON} - {$WARN USE_BEFORE_DEF ON} - {$WARN FOR_LOOP_VAR_UNDEF ON} - {$WARN UNIT_NAME_MISMATCH ON} - {$WARN NO_CFG_FILE_FOUND ON} - {$WARN MESSAGE_DIRECTIVE ON} - {$WARN IMPLICIT_VARIANTS ON} - {$WARN UNICODE_TO_LOCALE ON} - {$WARN LOCALE_TO_UNICODE ON} - {$WARN IMAGEBASE_MULTIPLE ON} - {$WARN SUSPICIOUS_TYPECAST ON} - {$WARN PRIVATE_PROPACCESSOR ON} - {$WARN UNSAFE_TYPE OFF} - {$WARN UNSAFE_CODE OFF} - {$WARN UNSAFE_CAST OFF} -// End Delphi 7 Options - -// Delphi 2005 Options -{$IF CompilerVersion >= 17.00} - {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} - {$MINSTACKSIZE $00004000} - {$MAXSTACKSIZE $00100000} - {$IFDEF MSWINDOWS} - {$IMAGEBASE $00400000} - {$ENDIF} - {$APPTYPE GUI} - {$WARN SYMBOL_DEPRECATED ON} - {$WARN SYMBOL_LIBRARY ON} - {$WARN SYMBOL_PLATFORM ON} - {$WARN SYMBOL_EXPERIMENTAL ON} - {$WARN UNIT_LIBRARY ON} - {$WARN UNIT_PLATFORM ON} - {$WARN UNIT_DEPRECATED ON} - {$WARN UNIT_EXPERIMENTAL ON} - {$WARN HRESULT_COMPAT ON} - {$WARN HIDING_MEMBER ON} - {$WARN HIDDEN_VIRTUAL ON} - {$WARN GARBAGE ON} - {$WARN BOUNDS_ERROR ON} - {$WARN ZERO_NIL_COMPAT ON} - {$WARN STRING_CONST_TRUNCED ON} - {$WARN FOR_LOOP_VAR_VARPAR ON} - {$WARN TYPED_CONST_VARPAR ON} - {$WARN ASG_TO_TYPED_CONST ON} - {$WARN CASE_LABEL_RANGE ON} - {$WARN FOR_VARIABLE ON} - {$WARN CONSTRUCTING_ABSTRACT ON} - {$WARN COMPARISON_FALSE ON} - {$WARN COMPARISON_TRUE ON} - {$WARN COMPARING_SIGNED_UNSIGNED ON} - {$WARN COMBINING_SIGNED_UNSIGNED ON} - {$WARN UNSUPPORTED_CONSTRUCT ON} - {$WARN FILE_OPEN ON} - {$WARN FILE_OPEN_UNITSRC ON} - {$WARN BAD_GLOBAL_SYMBOL ON} - {$WARN DUPLICATE_CTOR_DTOR ON} - {$WARN INVALID_DIRECTIVE ON} - {$WARN PACKAGE_NO_LINK ON} - {$WARN PACKAGED_THREADVAR ON} - {$WARN IMPLICIT_IMPORT ON} - {$WARN HPPEMIT_IGNORED ON} - {$WARN NO_RETVAL ON} - {$WARN USE_BEFORE_DEF ON} - {$WARN FOR_LOOP_VAR_UNDEF ON} - {$WARN UNIT_NAME_MISMATCH ON} - {$WARN NO_CFG_FILE_FOUND ON} - {$WARN MESSAGE_DIRECTIVE ON} - {$WARN IMPLICIT_VARIANTS ON} - {$WARN UNICODE_TO_LOCALE ON} - {$WARN LOCALE_TO_UNICODE ON} - {$WARN IMAGEBASE_MULTIPLE ON} - {$WARN SUSPICIOUS_TYPECAST ON} - {$WARN PRIVATE_PROPACCESSOR ON} - {$WARN UNSAFE_TYPE OFF} - {$WARN UNSAFE_CODE OFF} - {$WARN UNSAFE_CAST OFF} - {$WARN OPTION_TRUNCATED ON} - {$WARN WIDECHAR_REDUCED ON} - {$WARN DUPLICATES_IGNORED ON} -{$IFEND} -// End Delphi 2005 Options - -// Delphi 2007 Options -{$IF CompilerVersion >= 18.50} - {$A8,B-,C-,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} - {$MINSTACKSIZE $00004000} - {$MAXSTACKSIZE $00100000} - {$IFDEF MSWINDOWS} - {$IMAGEBASE $00400000} - {$ENDIF} - {$APPTYPE GUI} - {$WARN SYMBOL_DEPRECATED ON} - {$WARN SYMBOL_LIBRARY ON} - {$WARN SYMBOL_PLATFORM ON} - {$WARN SYMBOL_EXPERIMENTAL ON} - {$WARN UNIT_LIBRARY ON} - {$WARN UNIT_PLATFORM ON} - {$WARN UNIT_DEPRECATED ON} - {$WARN UNIT_EXPERIMENTAL ON} - {$WARN HRESULT_COMPAT ON} - {$WARN HIDING_MEMBER ON} - {$WARN HIDDEN_VIRTUAL ON} - {$WARN GARBAGE ON} - {$WARN BOUNDS_ERROR ON} - {$WARN ZERO_NIL_COMPAT ON} - {$WARN STRING_CONST_TRUNCED ON} - {$WARN FOR_LOOP_VAR_VARPAR ON} - {$WARN TYPED_CONST_VARPAR ON} - {$WARN ASG_TO_TYPED_CONST ON} - {$WARN CASE_LABEL_RANGE ON} - {$WARN FOR_VARIABLE ON} - {$WARN CONSTRUCTING_ABSTRACT ON} - {$WARN COMPARISON_FALSE ON} - {$WARN COMPARISON_TRUE ON} - {$WARN COMPARING_SIGNED_UNSIGNED ON} - {$WARN COMBINING_SIGNED_UNSIGNED ON} - {$WARN UNSUPPORTED_CONSTRUCT ON} - {$WARN FILE_OPEN ON} - {$WARN FILE_OPEN_UNITSRC ON} - {$WARN BAD_GLOBAL_SYMBOL ON} - {$WARN DUPLICATE_CTOR_DTOR ON} - {$WARN INVALID_DIRECTIVE ON} - {$WARN PACKAGE_NO_LINK ON} - {$WARN PACKAGED_THREADVAR ON} - {$WARN IMPLICIT_IMPORT ON} - {$WARN HPPEMIT_IGNORED ON} - {$WARN NO_RETVAL ON} - {$WARN USE_BEFORE_DEF ON} - {$WARN FOR_LOOP_VAR_UNDEF ON} - {$WARN UNIT_NAME_MISMATCH ON} - {$WARN NO_CFG_FILE_FOUND ON} - {$WARN IMPLICIT_VARIANTS ON} - {$WARN UNICODE_TO_LOCALE ON} - {$WARN LOCALE_TO_UNICODE ON} - {$WARN IMAGEBASE_MULTIPLE ON} - {$WARN SUSPICIOUS_TYPECAST ON} - {$WARN PRIVATE_PROPACCESSOR ON} - {$WARN UNSAFE_TYPE OFF} - {$WARN UNSAFE_CODE OFF} - {$WARN UNSAFE_CAST OFF} - {$WARN OPTION_TRUNCATED ON} - {$WARN WIDECHAR_REDUCED ON} - {$WARN DUPLICATES_IGNORED ON} - {$WARN UNIT_INIT_SEQ ON} - {$WARN LOCAL_PINVOKE ON} - {$WARN MESSAGE_DIRECTIVE ON} - {$WARN TYPEINFO_IMPLICITLY_ADDED ON} - {$WARN XML_WHITESPACE_NOT_ALLOWED ON} - {$WARN XML_UNKNOWN_ENTITY ON} - {$WARN XML_INVALID_NAME_START ON} - {$WARN XML_INVALID_NAME ON} - {$WARN XML_EXPECTED_CHARACTER ON} - {$WARN XML_CREF_NO_RESOLVE ON} - {$WARN XML_NO_PARM ON} - {$WARN XML_NO_MATCHING_PARM ON} -{$IFEND} -// End Delphi 2007 Options - -// Delphi 2010 Options -{$IF CompilerVersion >= 21.00} - {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N-,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} - {$MINSTACKSIZE $00004000} - {$MAXSTACKSIZE $00100000} - {$IFDEF MSWINDOWS} - {$IMAGEBASE $00400000} - {$ENDIF} - {$APPTYPE GUI} - {$WARN SYMBOL_DEPRECATED ON} - {$WARN SYMBOL_LIBRARY ON} - {$WARN SYMBOL_PLATFORM ON} - {$WARN SYMBOL_EXPERIMENTAL ON} - {$WARN UNIT_LIBRARY ON} - {$WARN UNIT_PLATFORM ON} - {$WARN UNIT_DEPRECATED ON} - {$WARN UNIT_EXPERIMENTAL ON} - {$WARN HRESULT_COMPAT ON} - {$WARN HIDING_MEMBER ON} - {$WARN HIDDEN_VIRTUAL ON} - {$WARN GARBAGE ON} - {$WARN BOUNDS_ERROR ON} - {$WARN ZERO_NIL_COMPAT ON} - {$WARN STRING_CONST_TRUNCED ON} - {$WARN FOR_LOOP_VAR_VARPAR ON} - {$WARN TYPED_CONST_VARPAR ON} - {$WARN ASG_TO_TYPED_CONST ON} - {$WARN CASE_LABEL_RANGE ON} - {$WARN FOR_VARIABLE ON} - {$WARN CONSTRUCTING_ABSTRACT ON} - {$WARN COMPARISON_FALSE ON} - {$WARN COMPARISON_TRUE ON} - {$WARN COMPARING_SIGNED_UNSIGNED ON} - {$WARN COMBINING_SIGNED_UNSIGNED ON} - {$WARN UNSUPPORTED_CONSTRUCT ON} - {$WARN FILE_OPEN ON} - {$WARN FILE_OPEN_UNITSRC ON} - {$WARN BAD_GLOBAL_SYMBOL ON} - {$WARN DUPLICATE_CTOR_DTOR ON} - {$WARN INVALID_DIRECTIVE ON} - {$WARN PACKAGE_NO_LINK ON} - {$WARN PACKAGED_THREADVAR ON} - {$WARN IMPLICIT_IMPORT ON} - {$WARN HPPEMIT_IGNORED ON} - {$WARN NO_RETVAL ON} - {$WARN USE_BEFORE_DEF ON} - {$WARN FOR_LOOP_VAR_UNDEF ON} - {$WARN UNIT_NAME_MISMATCH ON} - {$WARN NO_CFG_FILE_FOUND ON} - {$WARN IMPLICIT_VARIANTS ON} - {$WARN UNICODE_TO_LOCALE ON} - {$WARN LOCALE_TO_UNICODE ON} - {$WARN IMAGEBASE_MULTIPLE ON} - {$WARN SUSPICIOUS_TYPECAST ON} - {$WARN PRIVATE_PROPACCESSOR ON} - {$WARN UNSAFE_TYPE OFF} - {$WARN UNSAFE_CODE OFF} - {$WARN UNSAFE_CAST OFF} - {$WARN OPTION_TRUNCATED ON} - {$WARN WIDECHAR_REDUCED ON} - {$WARN DUPLICATES_IGNORED ON} - {$WARN UNIT_INIT_SEQ ON} - {$WARN LOCAL_PINVOKE ON} - {$WARN MESSAGE_DIRECTIVE ON} - {$WARN TYPEINFO_IMPLICITLY_ADDED ON} - {$WARN RLINK_WARNING ON} - {$WARN IMPLICIT_STRING_CAST ON} - {$WARN IMPLICIT_STRING_CAST_LOSS ON} - {$WARN EXPLICIT_STRING_CAST OFF} - {$WARN EXPLICIT_STRING_CAST_LOSS OFF} - {$WARN CVT_WCHAR_TO_ACHAR ON} - {$WARN CVT_NARROWING_STRING_LOST ON} - {$WARN CVT_ACHAR_TO_WCHAR OFF} - {$WARN CVT_WIDENING_STRING_LOST OFF} - {$WARN XML_WHITESPACE_NOT_ALLOWED ON} - {$WARN XML_UNKNOWN_ENTITY ON} - {$WARN XML_INVALID_NAME_START ON} - {$WARN XML_INVALID_NAME ON} - {$WARN XML_EXPECTED_CHARACTER ON} - {$WARN XML_CREF_NO_RESOLVE ON} - {$WARN XML_NO_PARM ON} - {$WARN XML_NO_MATCHING_PARM ON} -{$IFEND} -// End Delphi 2010 Options - -interface -uses classes, TPLB3.HashDsc, TPLB3.StreamCipher, TPLB3.Decorators; - -type - -TSHA2FamilyMember = (SHA_224, SHA_256, SHA_348, SHA_512, SHA_512_224, SHA_512_256); - -{$IF compilerversion >= 21} [DesignDescription( -'SHA-2 is a family of hashes designed to supersede SHA-1. As of the date ' + -'of this writing, there are no discovered collisions for any SHA-2 member.' -)] {$IFEND} -TSHA2 = class( TInterfacedObject, - IHashDsc, ICryptoGraphicAlgorithm, IControlObject) - private - FAlgorithm: TSHA2FamilyMember; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DigestSize: integer; // in units of bits. Must be a multiple of 8. - function UpdateSize: integer; // Size that the input to the Update must be. - function MakeHasher( const Params: IInterface): IHasher; - function DefinitionURL: string; - function WikipediaReference: string; - function ControlObject: TObject; - - public - constructor Create( Algorithm1: TSHA2FamilyMember); - end; - - - - - -implementation - - - - - - -uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, - TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; - -type - TaToh = (a, b, c, d, e, f, g, h); - TSHA256_M_Array = array[0..15] of uint32; - TSHA512_M_Array = array[0..15] of uint64; - TSHA256_W_Array = array[0..63] of uint32; - TSHA512_W_Array = array[0..79] of uint64; - TaToh_Array32 = array[ TaToh ] of uint32; - TaToh_Array64 = array[ TaToh ] of uint64; - -TSHA2_BaseHasher = class( TInterfacedObject, IHasher) - private - constructor Create( Algorithm1: TSHA2FamilyMember); - - protected - FAlgorithm: TSHA2FamilyMember; - FCount: uint64; - FisEnding: boolean; - - protected - procedure InitHashVectors; virtual; abstract; - procedure Update( Source{in}: TMemoryStream); virtual; abstract; - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); virtual; abstract; - procedure Burn; virtual; abstract; - function SelfTest_Source: string; virtual; abstract; - function SelfTest_ReferenceHashValue: string; virtual; abstract; - end; - - -TSHA256 = class( TSHA2_BaseHasher) - protected - FH: TaToh_Array32; - - procedure InitHashVectors; override; - procedure Update( Source{in}: TMemoryStream); override; - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); override; - procedure Burn; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - -TSHA224 = class( TSHA256) - protected - procedure InitHashVectors; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - -TSHA512 = class( TSHA2_BaseHasher) - protected - FH: TaToh_Array64; - - procedure InitHashVectors; override; - procedure Update( Source{in}: TMemoryStream); override; - procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); override; - procedure Burn; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - -TSHA384 = class( TSHA512) - protected - procedure InitHashVectors; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - -TSHA512_224 = class( TSHA512) - protected - procedure InitHashVectors; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - -TSHA512_256 = class( TSHA512) - protected - procedure InitHashVectors; override; - function SelfTest_Source: string; override; - function SelfTest_ReferenceHashValue: string; override; - end; - - - -/////////////////////////////////////// -// SHA-2 Primitives - -{ 4.2.2 SHA-224 and SHA-256 Constants - SHA-224 and SHA-256 use the same sequence of sixty-four constant 32-bit words, - These words represent the first thirty-two bits of the fractional parts of - the cube roots of the first sixty-four prime numbers. In hex, these constant - words are (from left to right). } - -const K_Values_32: array[ 0..63 ] of uint32 = ( - $428a2f98, $71374491, $b5c0fbcf, $e9b5dba5, $3956c25b, $59f111f1, $923f82a4, $ab1c5ed5, - $d807aa98, $12835b01, $243185be, $550c7dc3, $72be5d74, $80deb1fe, $9bdc06a7, $c19bf174, - $e49b69c1, $efbe4786, $0fc19dc6, $240ca1cc, $2de92c6f, $4a7484aa, $5cb0a9dc, $76f988da, - $983e5152, $a831c66d, $b00327c8, $bf597fc7, $c6e00bf3, $d5a79147, $06ca6351, $14292967, - $27b70a85, $2e1b2138, $4d2c6dfc, $53380d13, $650a7354, $766a0abb, $81c2c92e, $92722c85, - $a2bfe8a1, $a81a664b, $c24b8b70, $c76c51a3, $d192e819, $d6990624, $f40e3585, $106aa070, - $19a4c116, $1e376c08, $2748774c, $34b0bcb5, $391c0cb3, $4ed8aa4a, $5b9cca4f, $682e6ff3, - $748f82ee, $78a5636f, $84c87814, $8cc70208, $90befffa, $a4506ceb, $bef9a3f7, $c67178f2); - -{ 4.2.3 SHA-384, SHA-512, SHA-512/224 and SHA-512/256 Constants - SHA-384, SHA-512, SHA-512/224 and SHA-512/256 use the same sequence of eighty - constant 64-bit words, . These words represent the first sixty-four bits of - the fractional parts of the cube roots of the first eighty prime numbers. - In hex, these constant words are (from left to right) } - -{$IF compilerversion > 15} -const K_Values_64: array[ 0..79 ] of uint64 = ( - $428a2f98d728ae22, $7137449123ef65cd, $b5c0fbcfec4d3b2f, $e9b5dba58189dbbc, - $3956c25bf348b538, $59f111f1b605d019, $923f82a4af194f9b, $ab1c5ed5da6d8118, - $d807aa98a3030242, $12835b0145706fbe, $243185be4ee4b28c, $550c7dc3d5ffb4e2, - $72be5d74f27b896f, $80deb1fe3b1696b1, $9bdc06a725c71235, $c19bf174cf692694, - $e49b69c19ef14ad2, $efbe4786384f25e3, $0fc19dc68b8cd5b5, $240ca1cc77ac9c65, - $2de92c6f592b0275, $4a7484aa6ea6e483, $5cb0a9dcbd41fbd4, $76f988da831153b5, - $983e5152ee66dfab, $a831c66d2db43210, $b00327c898fb213f, $bf597fc7beef0ee4, - $c6e00bf33da88fc2, $d5a79147930aa725, $06ca6351e003826f, $142929670a0e6e70, - $27b70a8546d22ffc, $2e1b21385c26c926, $4d2c6dfc5ac42aed, $53380d139d95b3df, - $650a73548baf63de, $766a0abb3c77b2a8, $81c2c92e47edaee6, $92722c851482353b, - $a2bfe8a14cf10364, $a81a664bbc423001, $c24b8b70d0f89791, $c76c51a30654be30, - $d192e819d6ef5218, $d69906245565a910, $f40e35855771202a, $106aa07032bbd1b8, - $19a4c116b8d2d0c8, $1e376c085141ab53, $2748774cdf8eeb99, $34b0bcb5e19b48a8, - $391c0cb3c5c95a63, $4ed8aa4ae3418acb, $5b9cca4f7763e373, $682e6ff3d6b2b8a3, - $748f82ee5defb2fc, $78a5636f43172f60, $84c87814a1f0ab72, $8cc702081a6439ec, - $90befffa23631e28, $a4506cebde82bde9, $bef9a3f7b2c67915, $c67178f2e372532b, - $ca273eceea26619c, $d186b8c721c0c207, $eada7dd6cde0eb1e, $f57d4f7fee6ed178, - $06f067aa72176fba, $0a637dc5a2c898a6, $113f9804bef90dae, $1b710b35131c471b, - $28db77f523047d84, $32caab7b40c72493, $3c9ebe0a15c9bebc, $431d67c49c100d4c, - $4cc5d4becb3e42b6, $597f299cfc657e2a, $5fcb6fab3ad6faec, $6c44198c4a475817); - -{$ELSE} // Delphi 7 -const K_Values_64: array[ 0..79 ] of uint64 = ( - {}uint64( $428A2F98D728AE22){}, {}uint64( $7137449123EF65CD){}, {}uint64( -$4A3F043013B2C4D1){}, {}uint64( -$164A245A7E762444){}, - {}uint64( $3956C25BF348B538){}, {}uint64( $59F111F1B605D019){}, {}uint64( -$6DC07D5B50E6B065){}, {}uint64( -$54E3A12A25927EE8){}, - {}uint64( -$27F855675CFCFDBE){}, {}uint64( $12835B0145706FBE){}, {}uint64( $243185BE4EE4B28C){}, {}uint64( $550C7DC3D5FFB4E2){}, - {}uint64( $72BE5D74F27B896F){}, {}uint64( -$7F214E01C4E9694F){}, {}uint64( -$6423F958DA38EDCB){}, {}uint64( -$3E640E8B3096D96C){}, - {}uint64( -$1B64963E610EB52E){}, {}uint64( -$1041B879C7B0DA1D){}, {}uint64( $0FC19DC68B8CD5B5){}, {}uint64( $240CA1CC77AC9C65){}, - {}uint64( $2DE92C6F592B0275){}, {}uint64( $4A7484AA6EA6E483){}, {}uint64( $5CB0A9DCBD41FBD4){}, {}uint64( $76F988DA831153B5){}, - {}uint64( -$67C1AEAD11992055){}, {}uint64( -$57CE3992D24BCDF0){}, {}uint64( -$4FFCD8376704DEC1){}, {}uint64( -$40A680384110F11C){}, - {}uint64( -$391FF40CC257703E){}, {}uint64( -$2A586EB86CF558DB){}, {}uint64( $06CA6351E003826F){}, {}uint64( $142929670A0E6E70){}, - {}uint64( $27B70A8546D22FFC){}, {}uint64( $2E1B21385C26C926){}, {}uint64( $4D2C6DFC5AC42AED){}, {}uint64( $53380D139D95B3DF){}, - {}uint64( $650A73548BAF63DE){}, {}uint64( $766A0ABB3C77B2A8){}, {}uint64( -$7E3D36D1B812511A){}, {}uint64( -$6D8DD37AEB7DCAC5){}, - {}uint64( -$5D40175EB30EFC9C){}, {}uint64( -$57E599B443BDCFFF){}, {}uint64( -$3DB4748F2F07686F){}, {}uint64( -$3893AE5CF9AB41D0){}, - {}uint64( -$2E6D17E62910ADE8){}, {}uint64( -$2966F9DBAA9A56F0){}, {}uint64( -$0BF1CA7AA88EDFD6){}, {}uint64( $106AA07032BBD1B8){}, - {}uint64( $19A4C116B8D2D0C8){}, {}uint64( $1E376C085141AB53){}, {}uint64( $2748774CDF8EEB99){}, {}uint64( $34B0BCB5E19B48A8){}, - {}uint64( $391C0CB3C5C95A63){}, {}uint64( $4ED8AA4AE3418ACB){}, {}uint64( $5B9CCA4F7763E373){}, {}uint64( $682E6FF3D6B2B8A3){}, - {}uint64( $748F82EE5DEFB2FC){}, {}uint64( $78A5636F43172F60){}, {}uint64( -$7B3787EB5E0F548E){}, {}uint64( -$7338FDF7E59BC614){}, - {}uint64( -$6F410005DC9CE1D8){}, {}uint64( -$5BAF9314217D4217){}, {}uint64( -$41065C084D3986EB){}, {}uint64( -$398E870D1C8DACD5){}, - {}uint64( -$35D8C13115D99E64){}, {}uint64( -$2E794738DE3F3DF9){}, {}uint64( -$15258229321F14E2){}, {}uint64( -$0A82B08011912E88){}, - {}uint64( $06F067AA72176FBA){}, {}uint64( $0A637DC5A2C898A6){}, {}uint64( $113F9804BEF90DAE){}, {}uint64( $1B710B35131C471B){}, - {}uint64( $28DB77F523047D84){}, {}uint64( $32CAAB7B40C72493){}, {}uint64( $3C9EBE0A15C9BEBC){}, {}uint64( $431D67C49C100D4C){}, - {}uint64( $4CC5D4BECB3E42B6){}, {}uint64( $597F299CFC657E2A){}, {}uint64( $5FCB6FAB3AD6FAEC){}, {}uint64( $6C44198C4A475817){}); -{$IFEND} - - - // FIPS PUB 180-4 | 4.1.2 | Ch() function -function Ch32( x, y, z: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// Ch(x,y,z) = (x ^ y) xor (not x ^ z) -result := (x and y) xor ((not x) and z) -end; - - - // FIPS PUB 180-4 | 4.1.3 | Ch() function -function Ch64( x, y, z: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// Ch(x,y,z) = (x ^ y) xor (not x ^ z) -result := (x and y) xor ((not x) and z) -end; - - - // FIPS PUB 180-4 | 4.1.2 | Maj() function -function Maj32( x, y, z: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// Ch(x,y,z) = (x ^ y) xor (x ^ z) xor (y ^ z) -result := (x and y) xor (x and z) xor (y and z) -end; - - - // FIPS PUB 180-4 | 4.1.3 | Maj() function -function Maj64( x, y, z: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// Ch(x,y,z) = (x ^ y) xor (x ^ z) xor (y ^ z) -result := (x and y) xor (x and z) xor (y and z) -end; - - - // FIPS PUB 180-4 | 4.2.4 | ROTR operation -function Rotr32( Shift: integer; x: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -result := (x shr Shift) or (x shl (32 - Shift)) -end; - - -function Rotr64( Shift: integer; x: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -result := (x shr Shift) or (x shl (64 - Shift)) -end; - - - - // FIPS PUB 180-4 | 4.1.2 | SIGMA[0,256]() function -function BigSigma0_256_32( x: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// SIGMA[0,256](x) = ROTR[2](x) xor ROTR[13](x) xor ROTR[22](x) -result := Rotr32( 2, x) xor Rotr32( 13, x) xor Rotr32( 22, x) -end; - - - - // FIPS PUB 180-4 | 4.1.2 | SIGMA[1,256]() function -function BigSigma1_256_32( x: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// SIGMA[1,256](x) = ROTR[6](x) xor ROTR[11](x) xor ROTR[25](x) -result := Rotr32( 6, x) xor Rotr32( 11, x) xor Rotr32( 25, x) -end; - - - - // FIPS PUB 180-4 | 4.1.3 | SIGMA[0,512]() function -function BigSigma0_512_64( x: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// SIGMA[0,512](x) = ROTR[28](x) xor ROTR[34](x) xor ROTR[39](x) -result := Rotr64( 28, x) xor Rotr64( 34, x) xor Rotr64( 39, x) -end; - - - - // FIPS PUB 180-4 | 4.1.3 | SIGMA[1,512]() function -function BigSigma1_512_64( x: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// SIGMA[1,512](x) = ROTR[14](x) xor ROTR[18](x) xor ROTR[41](x) -result := Rotr64( 14, x) xor Rotr64( 18, x) xor Rotr64( 41, x) -end; - - - - // FIPS PUB 180-4 | 4.1.2 | sigma[0,256]() function -function LittleSigma0_256_32( x: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// sigma[0,256](x) = ROTR[7](x) xor ROTR[18](x) xor SHR[3](x) -result := Rotr32( 7, x) xor Rotr32( 18, x) xor (x shr 3) -end; - - - - // FIPS PUB 180-4 | 4.1.2 | sigma[1,256]() function -function LittleSigma1_256_32( x: uint32): uint32; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// sigma[1,256](x) = ROTR[17](x) xor ROTR[19](x) xor SHR[10](x) -result := Rotr32( 17, x) xor Rotr32( 19, x) xor (x shr 10) -end; - - - - // FIPS PUB 180-4 | 4.1.3 | sigma[0,512]() function -function LittleSigma0_512_64( x: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// sigma[0,512](x) = ROTR[1](x) xor ROTR[8](x) xor SHR[7](x) -result := Rotr64( 1, x) xor Rotr64( 8, x) xor (x shr 7) -end; - - - - // FIPS PUB 180-4 | 4.1.3 | sigma[1,512]() function -function LittleSigma1_512_64( x: uint64): uint64; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -// sigma[1,512](x) = ROTR[19](x) xor ROTR[61](x) xor SHR[6](x) -result := Rotr64( 19, x) xor Rotr64( 61, x) xor (x shr 6) -end; - - -function SHA_StylePadding_64_in_512( MessageLengthInBits: uint64; var Pad): integer; -// The padded message will be 512 bits or 64 bytes. -// Assume Pad is at least that long. -// Return number of bytes of padding. -var - PadByte: PByte; - BigEndienLenInBits: uint64; - Excess, Zeros: integer; -begin -PadByte := @Pad; -PadByte^ := $80; -Inc( PadByte); -Excess := ((MessageLengthInBits + 7) div 8) mod 64; -Zeros := 55 - Excess; -if Zeros < 0 then - Inc( Zeros, 64); -if Zeros > 0 then - begin - FillChar( PadByte^, Zeros, $00); - Inc( PadByte, Zeros) - end; -BigEndienLenInBits := SwapEndien_u64( MessageLengthInBits); -Move( BigEndienLenInBits, PadByte^, 8); -result := Zeros + 9 -end; - - -function SHA_StylePadding_128_in_1024( - Lo64MessageLengthInBits, Hi64MessageLengthInBits: uint64; var Pad): integer; -// The padded message will be 1024 bits or 128 bytes. -// Assume Pad is at least that long. -// Return number of bytes of padding. -var - PadByte: PByte; - BigEndienLenInBits: uint64; - Excess, Zeros: integer; -begin -PadByte := @Pad; -PadByte^ := $80; -Inc( PadByte); -Excess := ((Lo64MessageLengthInBits + 7) div 8) mod 128; -Zeros := 111 - Excess; -if Zeros < 0 then - Inc( Zeros, 128); -if Zeros > 0 then - begin - FillChar( PadByte^, Zeros, $00); - Inc( PadByte, Zeros) - end; -BigEndienLenInBits := SwapEndien_s64( Hi64MessageLengthInBits); -Move( BigEndienLenInBits, PadByte^, 8); -Inc( PadByte, 8); -BigEndienLenInBits := SwapEndien_s64( Lo64MessageLengthInBits); -Move( BigEndienLenInBits, PadByte^, 8); -result := Zeros + 17 -end; - -procedure SHA256_Step1( - const M: TSHA256_M_Array; - var W: TSHA256_W_Array); -var - t: integer; - Temp32: uint32; -begin -for t := 0 to 15 do - W[t] := M[t]; -for t := 16 to 63 do - begin - Temp32 := LittleSigma1_256_32( W[t-2]) + - W[t-7] + - LittleSigma0_256_32( W[t-15]) + - W[t-16]; - W[t] := Temp32 - end -end; - -procedure SHA512_Step1( - const M: TSHA512_M_Array; - var W: TSHA512_W_Array); -var - t: integer; - Temp64: uint64; -begin -for t := 0 to 15 do - W[t] := M[t]; -for t := 16 to 79 do - begin - Temp64 := LittleSigma1_512_64( W[t-2]) + - W[t-7] + - LittleSigma0_512_64( W[t-15]) + - W[t-16]; - W[t] := Temp64 - end -end; - - -procedure SHA256_Step3( - var aa: TaToh_Array32; - const W: TSHA256_W_Array); -var - T1, T2: uint32; - t: integer; -begin -for t := 0 to 63 do - begin - T1 := aa[h] + BigSigma1_256_32( aa[e]) + Ch32( aa[e], aa[f], aa[g]) + K_Values_32[t] + W[t]; - T2 := BigSigma0_256_32( aa[a]) + Maj32( aa[a], aa[b], aa[c]); - aa[h] := aa[g]; - aa[g] := aa[f]; - aa[f] := aa[e]; - aa[e] := aa[d] + T1; - aa[d] := aa[c]; - aa[c] := aa[b]; - aa[b] := aa[a]; - aa[a] := T1 + T2 - end -end; - - -procedure SHA512_Step3( - var aa: TaToh_Array64; - const W: TSHA512_W_Array); -var - T1, T2: uint64; - t: integer; -begin -for t := 0 to 79 do - begin - T1 := aa[h] + BigSigma1_512_64( aa[e]) + Ch64( aa[e], aa[f], aa[g]) + K_Values_64[t] + W[t]; - T2 := BigSigma0_512_64( aa[a]) + Maj64( aa[a], aa[b], aa[c]); - aa[h] := aa[g]; - aa[g] := aa[f]; - aa[f] := aa[e]; - aa[e] := aa[d] + T1; - aa[d] := aa[c]; - aa[c] := aa[b]; - aa[b] := aa[a]; - aa[a] := T1 + T2 - end -end; - - -procedure SHA256_Step4( - var HH: TaToh_Array32; - const aa: TaToh_Array32); -var - Letter: TaToh; -begin -for Letter := a to h do - HH[ Letter] := HH[ Letter] + aa[ Letter] -end; - - -procedure SHA512_Step4( - var HH: TaToh_Array64; - const aa: TaToh_Array64); -var - Letter: TaToh; -begin -for Letter := a to h do - HH[ Letter] := HH[ Letter] + aa[ Letter] -end; - - -procedure SHA256_Step2( - var aa: TaToh_Array32; - const HH: TaToh_Array32); -var - Letter: TaToh; -begin -for Letter := a to h do - aa[ Letter] := HH[ Letter] -end; - - -procedure SHA512_Step2( - var aa: TaToh_Array64; - const HH: TaToh_Array64); -var - Letter: TaToh; -begin -for Letter := a to h do - aa[ Letter] := HH[ Letter] -end; - - -/////////////////////////////////////// -// TSHA-2 Class - -function TSHA2.ControlObject: TObject; -begin -result := self -end; - - -constructor TSHA2.Create( Algorithm1: TSHA2FamilyMember); -begin -FAlgorithm := Algorithm1 -end; - - - -function TSHA2.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/drafts/' + - 'fips180-4/Draft-FIPS180-4_Feb2011.pdf' -end; - -const DigestSizes: array[ TSHA2FamilyMember] of integer = ( -// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 - 224, 256, 384, 512, 224, 256); -function TSHA2.DigestSize: integer; -begin -result := DigestSizes[ FAlgorithm] -end; - - -function TSHA2.DisplayName: string; -const Names: array[ TSHA2FamilyMember] of string = ( -// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 - '224', '256', '384', '512', '512/224', '512/256'); -begin -result := 'SHA-' + Names[ FAlgorithm] -end; - - -function TSHA2.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware]; -if FAlgorithm in [SHA_512_224, SHA_512_256] then - Include( result, afStar) -end; - - - -function TSHA2.MakeHasher( const Params: IInterface): IHasher; -type - TSHA2_BaseHasherClass = class of TSHA2_BaseHasher; -const - Classes: array[ TSHA2FamilyMember] of TSHA2_BaseHasherClass = ( - TSHA224, TSHA256, TSHA384, TSHA512, TSHA512_224, TSHA512_256); -begin -result := Classes[ Falgorithm].Create( FAlgorithm) -end; - - -function TSHA2.ProgId: string; -const Names: array[ TSHA2FamilyMember] of string = ( -// SHA_224, SHA_256, SHA_348, SHA_512, SHA_512_224, SHA_512_256 - SHA224_ProgId, SHA256_ProgId, - SHA384_ProgId, SHA512_ProgId, SHA512_224_ProgId, SHA512_256_ProgId); -begin -result := Names[ FAlgorithm] -end; - -function TSHA2.UpdateSize: integer; -const Sizes: array[ TSHA2FamilyMember] of integer = ( -// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 - 512, 512, 1024, 1024, 1024, 1024); -begin -result := Sizes[ FAlgorithm] -end; - - -function TSHA2.WikipediaReference: string; -begin -result := {'http://en.wikipedia.org/wiki/' +} 'Sha-2' -end; - - -{ TSHA2_BaseHasher } - -constructor TSHA2_BaseHasher.Create( Algorithm1: TSHA2FamilyMember); -begin -FAlgorithm := Algorithm1; -FCount := 0; -FisEnding := False; -InitHashVectors -end; - -{ TSHA256 } - -procedure TSHA256.InitHashVectors; -begin -FH[a] := $6a09e667; -FH[b] := $bb67ae85; -FH[c] := $3c6ef372; -FH[d] := $a54ff53a; -FH[e] := $510e527f; -FH[f] := $9b05688c; -FH[g] := $1f83d9ab; -FH[h] := $5be0cd19 -end; - - - -procedure TSHA256.Update( Source: TMemoryStream); -var - M: TSHA256_M_Array; - W: TSHA256_W_Array; - aa: TaToh_Array32; - t: integer; - Temp32: uint32; -begin -Assert( Source.Size = 64, 'TSHA256.Update - Wrong block size.'); -if not FisEnding then - Inc( FCount, 512); -Source.Position := 0; -for t := 0 to 15 do - begin - Source.Read( Temp32, 4); - M[t] := SwapEndien_u32( Temp32) - end; -SHA256_Step1( M, W); -SHA256_Step2( aa, FH); -SHA256_Step3( aa, W); -SHA256_Step4( FH, aa) -end; - - -procedure TSHA256.End_Hash( PartBlock: TMemoryStream; Digest: TStream); -var - MessageLengthInBits, L: uint64; - Pad: packed array[ 0..71 ] of byte; - PaddingCountInBytes: integer; - PadOrigin, Xfer: integer; - jj: TaToh; - lwDigest: uint32; -begin -L := PartBlock.Position; -Assert( L <= 64, 'TSHA256.End_Hash - Wrong block size.'); -FisEnding := True; -Inc( FCount, L * 8); -MessageLengthInBits := FCount; -PaddingCountInBytes := SHA_StylePadding_64_in_512( MessageLengthInBits, Pad); -PadOrigin := 0; -Xfer := 64 - L; -if Xfer < 0 then - Xfer := 0; -if Xfer > PaddingCountInBytes then - Xfer := PaddingCountInBytes; -if Xfer > 0 then - begin - PartBlock.Write( Pad, Xfer); - Inc( PadOrigin, Xfer); - Dec( PaddingCountInBytes, Xfer) - end; -Update( PartBlock); -Xfer := PaddingCountInBytes; -if Xfer > 0 then - begin - PartBlock.Position := 0; - PartBlock.Write( Pad[ PadOrigin], Xfer); - Assert( Xfer = 64, 'TSHA256.End_Hash - Wrong block size.'); - Update( PartBlock) - end; -PartBlock.Position := L; -L := DigestSizes[ FAlgorithm] div 8; // digest size in bytes. -Digest.Position := 0; -for jj := a to h do - begin - if L <= 0 then break; - lwDigest := SwapEndien_u32( FH[jj]); - Xfer := 4; - if Xfer > L then - Xfer := L; - if Xfer <= 0 then break; - Digest.WriteBuffer( lwDigest, Xfer); - Dec( L, Xfer) - end; -Digest.Position := 0; -FillChar( FH, SizeOf( FH), 0) -end; - - -procedure TSHA256.Burn; -begin -FCount := 0; -FillChar( FH, SizeOf( FH), 0); -FisEnding := False -end; - -function TSHA256.SelfTest_Source: string; -begin -result := 'abc' -end; - - -function TSHA256.SelfTest_ReferenceHashValue: string; -begin -result := 'BA7816BF 8F01CFEA ' + - '414140DE 5DAE2223 B00361A3 96177A9C B410FF61 F20015AD' -end; - - -{ TSHA224 } - -procedure TSHA224.InitHashVectors; -begin -FH[a] := $c1059ed8; -FH[b] := $367cd507; -FH[c] := $3070dd17; -FH[d] := $f70e5939; -FH[e] := $ffc00b31; -FH[f] := $68581511; -FH[g] := $64f98fa7; -FH[h] := $befa4fa4 -end; - - -function TSHA224.SelfTest_Source: string; -begin -result := 'abc' -// Two block alternative: -// result := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' -end; - - -function TSHA224.SelfTest_ReferenceHashValue: string; -begin -result := '23097D22 3405D822 8642A477 BDA255B3 2AADBCE4 BDA0B3F7 E36C9DA7' -// Two block alternative: -// result := '75388B16 512776CC 5DBA5DA1 FD890150 B0C6455C B4F58B19 52522525' -end; - - - - -{ TSHA512 } - -procedure TSHA512.InitHashVectors; -begin -{$IF compilerversion > 15} -FH[a] := $6a09e667f3bcc908; -FH[b] := $bb67ae8584caa73b; -FH[c] := $3c6ef372fe94f82b; -FH[d] := $a54ff53a5f1d36f1; -FH[e] := $510e527fade682d1; -FH[f] := $9b05688c2b3e6c1f; -FH[g] := $1f83d9abfb41bd6b; -FH[h] := $5be0cd19137e2179 - -{$ELSE} // Delphi 7 -FH[a] := {}uint64( $6A09E667F3BCC908){}; -FH[b] := {}uint64( -$4498517A7B3558C5){}; -FH[c] := {}uint64( $3C6EF372FE94F82B){}; -FH[d] := {}uint64( -$5AB00AC5A0E2C90F){}; -FH[e] := {}uint64( $510E527FADE682D1){}; -FH[f] := {}uint64( -$64FA9773D4C193E1){}; -FH[g] := {}uint64( $1F83D9ABFB41BD6B){}; -FH[h] := {}uint64( $5BE0CD19137E2179){} -{$IFEND} -end; - - - -procedure TSHA512.Update( Source: TMemoryStream); -var - M: TSHA512_M_Array; - W: TSHA512_W_Array; - aa: TaToh_Array64; - t: integer; - Temp64: uint64; -begin -Assert( Source.Size = 128, 'TSHA512.Update - Wrong block size.'); -if not FisEnding then - Inc( FCount, 1024); -Source.Position := 0; -for t := 0 to 15 do - begin - Source.Read( Temp64, 8); - M[t] := SwapEndien_u64( Temp64) - end; -SHA512_Step1( M, W); -SHA512_Step2( aa, FH); -SHA512_Step3( aa, W); -SHA512_Step4( FH, aa) -end; - - -procedure TSHA512.End_Hash( PartBlock: TMemoryStream; Digest: TStream); -var - Lo64MessageLengthInBits, Hi64MessageLengthInBits, L: uint64; - Pad: packed array[ 0..255 ] of byte; - PaddingCountInBytes: integer; - PadOrigin, Xfer: integer; - jj: TaToh; - lwDigest: uint64; -begin -L := PartBlock.Position; -Assert( L <= 128, 'TSHA512.End_Hash - Wrong block size.'); -FisEnding := True; -Inc( FCount, L * 8); -Lo64MessageLengthInBits := FCount; -Hi64MessageLengthInBits := 0; -PaddingCountInBytes := SHA_StylePadding_128_in_1024( - Lo64MessageLengthInBits, Hi64MessageLengthInBits, Pad); -PadOrigin := 0; -Xfer := 128 - L; -if Xfer < 0 then - Xfer := 0; -if Xfer > PaddingCountInBytes then - Xfer := PaddingCountInBytes; -if Xfer > 0 then - begin - PartBlock.Write( Pad, Xfer); - Inc( PadOrigin, Xfer); - Dec( PaddingCountInBytes, Xfer) - end; -Update( PartBlock); -Xfer := PaddingCountInBytes; -if Xfer > 0 then - begin - PartBlock.Position := 0; - PartBlock.Write( Pad[ PadOrigin], Xfer); - Assert( Xfer = 128, 'TSHA512.End_Hash - Wrong block size.'); - Update( PartBlock) - end; -PartBlock.Position := L; -L := DigestSizes[ FAlgorithm] div 8; // digest size in bytes. -Digest.Position := 0; -for jj := a to h do - begin - if L <= 0 then break; - lwDigest := SwapEndien_u64( FH[jj]); - Xfer := 8; - if Xfer > L then - Xfer := L; - if Xfer <= 0 then break; - Digest.WriteBuffer( lwDigest, Xfer); - Dec( L, Xfer) - end; -Digest.Position := 0; -FillChar( FH, SizeOf( FH), 0) -end; - - -procedure TSHA512.Burn; -begin -FCount := 0; -FillChar( FH, SizeOf( FH), 0); -FisEnding := False -end; - -function TSHA512.SelfTest_Source: string; -begin -result := 'abc' -end; - - -function TSHA512.SelfTest_ReferenceHashValue: string; -begin -result := 'DDAF35A1 93617ABA CC417349 AE204131 ' + - '12E6FA4E 89A97EA2 0A9EEEE6 4B55D39A 2192992A 274FC1A8 ' + - '36BA3C23 A3FEEBBD 454D4423 643CE80E 2A9AC94F A54CA49F' -end; - - - -{ TSHA348 } - -procedure TSHA384.InitHashVectors; -begin -{$IF compilerversion > 15} -FH[a] := $cbbb9d5dc1059ed8; -FH[b] := $629a292a367cd507; -FH[c] := $9159015a3070dd17; -FH[d] := $152fecd8f70e5939; -FH[e] := $67332667ffc00b31; -FH[f] := $8eb44a8768581511; -FH[g] := $db0c2e0d64f98fa7; -FH[h] := $47b5481dbefa4fa4 - -{$ELSE} // Delphi 7 -FH[a] := {}uint64( -$344462A23EFA6128){}; -FH[b] := {}uint64( $629A292A367CD507){}; -FH[c] := {}uint64( -$6EA6FEA5CF8F22E9){}; -FH[d] := {}uint64( $152FECD8F70E5939){}; -FH[e] := {}uint64( $67332667FFC00B31){}; -FH[f] := {}uint64( -$714BB57897A7EAEF){}; -FH[g] := {}uint64( -$24F3D1F29B067059){}; -FH[h] := {}uint64( $47B5481DBEFA4FA4){} -{$IFEND} -end; - - -function TSHA384.SelfTest_Source: string; -begin -result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijk' + - 'lmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' - -end; - - -function TSHA384.SelfTest_ReferenceHashValue: string; -begin -result := '09330C33 F71147E8 3D192FC7 82CD1B47 53111B17 3B3B05D2 ' + - '2FA08086 E3B0F712 FCC7C71A 557E2DB9 66C3E9FA 91746039' -end; - - -{ TSHA512_224 } - -procedure TSHA512_224.InitHashVectors; -begin -{$IF compilerversion > 15} -FH[a] := $8C3D37C819544DA2; -FH[b] := $73E1996689DCD4D6; -FH[c] := $1DFAB7AE32FF9C82; -FH[d] := $679DD514582F9FCF; -FH[e] := $0F6D2B697BD44DA8; -FH[f] := $77E36F7304C48942; -FH[g] := $3F9D85A86A1D36C8; -FH[h] := $1112E6AD91D692A1 - -{$ELSE} // Delphi 7 -FH[a] := {}uint64( -$73C2C837E6ABB25E){}; -FH[b] := {}uint64( $73E1996689DCD4D6){}; -FH[c] := {}uint64( $1DFAB7AE32FF9C82){}; -FH[d] := {}uint64( $679DD514582F9FCF){}; -FH[e] := {}uint64( $0F6D2B697BD44DA8){}; -FH[f] := {}uint64( $77E36F7304C48942){}; -FH[g] := {}uint64( $3F9D85A86A1D36C8){}; -FH[h] := {}uint64( $1112E6AD91D692A1){} -{$IFEND} -end; - - - -function TSHA512_224.SelfTest_Source: string; -begin -result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi' + - 'jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' -end; - -function TSHA512_224.SelfTest_ReferenceHashValue: string; -begin -result := '23FEC5BB 94D60B23 30819264 0B0C4533 35D66473 4FE40E72 68674AF9' -end; - - - -{ TSHA512_256 } - -procedure TSHA512_256.InitHashVectors; -begin -{$IF compilerversion > 15} -FH[a] := $22312194FC2BF72C; -FH[b] := $9F555FA3C84C64C2; -FH[c] := $2393B86B6F53B151; -FH[d] := $963877195940EABD; -FH[e] := $96283EE2A88EFFE3; -FH[f] := $BE5E1E2553863992; -FH[g] := $2B0199FC2C85B8AA; -FH[h] := $0EB72DDC81C52CA2 - -{$ELSE} // Delphi 7 -FH[a] := {}uint64( $22312194FC2BF72C){}; -FH[b] := {}uint64( -$60AAA05C37B39B3E){}; -FH[c] := {}uint64( $2393B86B6F53B151){}; -FH[d] := {}uint64( -$69C788E6A6BF1543){}; -FH[e] := {}uint64( -$69D7C11D5771001D){}; -FH[f] := {}uint64( -$41A1E1DAAC79C66E){}; -FH[g] := {}uint64( $2B0199FC2C85B8AA){}; -FH[h] := {}uint64( $0EB72DDC81C52CA2){} -{$IFEND} -end; - - - -function TSHA512_256.SelfTest_Source: string; -begin -result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijkl' + - 'mnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' -end; - -function TSHA512_256.SelfTest_ReferenceHashValue: string; -begin -result := '3928E184 FB8690F8 40DA3988 121D31BE 65CB9D3E F83EE614 ' + - '6FEAC861 E19B563A' -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2011 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.SHA2; + +// Note to the curious: +// These options settings will soon be migrated to an include file. +// Why are they here? A few units in the project are sensitive to some +// compiler options such as range-check and overflow-check. Normally this +// isnt an issue because units should be compiled into a run-time library +// with options as provided. However, a few users are employing the units +// holistically (not in a library), and in thier applications settings using +// incompatible project options. By explicity setting compiler options here +// and in other sensitive units, we can ensure that the units are compiled +// with options as designed, irrespective of how the developer-user incorporates +// the units (holistic or library). + +// Delphi 7 Options + {$A8,B-,C-,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} + {$MINSTACKSIZE $00004000} + {$MAXSTACKSIZE $00100000} + {$IFDEF MSWINDOWS} + {$IMAGEBASE $00400000} + {$ENDIF} + {$APPTYPE GUI} + {$WARN SYMBOL_DEPRECATED ON} + {$WARN SYMBOL_LIBRARY ON} + {$WARN SYMBOL_PLATFORM ON} + {$WARN UNIT_LIBRARY ON} + {$WARN UNIT_PLATFORM ON} + {$WARN UNIT_DEPRECATED ON} + {$WARN HRESULT_COMPAT ON} + {$WARN HIDING_MEMBER ON} + {$WARN HIDDEN_VIRTUAL ON} + {$WARN GARBAGE ON} + {$WARN BOUNDS_ERROR ON} + {$WARN ZERO_NIL_COMPAT ON} + {$WARN STRING_CONST_TRUNCED ON} + {$WARN FOR_LOOP_VAR_VARPAR ON} + {$WARN TYPED_CONST_VARPAR ON} + {$WARN ASG_TO_TYPED_CONST ON} + {$WARN CASE_LABEL_RANGE ON} + {$WARN FOR_VARIABLE ON} + {$WARN CONSTRUCTING_ABSTRACT ON} + {$WARN COMPARISON_FALSE ON} + {$WARN COMPARISON_TRUE ON} + {$WARN COMPARING_SIGNED_UNSIGNED ON} + {$WARN COMBINING_SIGNED_UNSIGNED ON} + {$WARN UNSUPPORTED_CONSTRUCT ON} + {$WARN FILE_OPEN ON} + {$WARN FILE_OPEN_UNITSRC ON} + {$WARN BAD_GLOBAL_SYMBOL ON} + {$WARN DUPLICATE_CTOR_DTOR ON} + {$WARN INVALID_DIRECTIVE ON} + {$WARN PACKAGE_NO_LINK ON} + {$WARN PACKAGED_THREADVAR ON} + {$WARN IMPLICIT_IMPORT ON} + {$WARN HPPEMIT_IGNORED ON} + {$WARN NO_RETVAL ON} + {$WARN USE_BEFORE_DEF ON} + {$WARN FOR_LOOP_VAR_UNDEF ON} + {$WARN UNIT_NAME_MISMATCH ON} + {$WARN NO_CFG_FILE_FOUND ON} + {$WARN MESSAGE_DIRECTIVE ON} + {$WARN IMPLICIT_VARIANTS ON} + {$WARN UNICODE_TO_LOCALE ON} + {$WARN LOCALE_TO_UNICODE ON} + {$WARN IMAGEBASE_MULTIPLE ON} + {$WARN SUSPICIOUS_TYPECAST ON} + {$WARN PRIVATE_PROPACCESSOR ON} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_CAST OFF} +// End Delphi 7 Options + +// Delphi 2005 Options +{$IF CompilerVersion >= 17.00} + {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} + {$MINSTACKSIZE $00004000} + {$MAXSTACKSIZE $00100000} + {$IFDEF MSWINDOWS} + {$IMAGEBASE $00400000} + {$ENDIF} + {$APPTYPE GUI} + {$WARN SYMBOL_DEPRECATED ON} + {$WARN SYMBOL_LIBRARY ON} + {$WARN SYMBOL_PLATFORM ON} + {$WARN SYMBOL_EXPERIMENTAL ON} + {$WARN UNIT_LIBRARY ON} + {$WARN UNIT_PLATFORM ON} + {$WARN UNIT_DEPRECATED ON} + {$WARN UNIT_EXPERIMENTAL ON} + {$WARN HRESULT_COMPAT ON} + {$WARN HIDING_MEMBER ON} + {$WARN HIDDEN_VIRTUAL ON} + {$WARN GARBAGE ON} + {$WARN BOUNDS_ERROR ON} + {$WARN ZERO_NIL_COMPAT ON} + {$WARN STRING_CONST_TRUNCED ON} + {$WARN FOR_LOOP_VAR_VARPAR ON} + {$WARN TYPED_CONST_VARPAR ON} + {$WARN ASG_TO_TYPED_CONST ON} + {$WARN CASE_LABEL_RANGE ON} + {$WARN FOR_VARIABLE ON} + {$WARN CONSTRUCTING_ABSTRACT ON} + {$WARN COMPARISON_FALSE ON} + {$WARN COMPARISON_TRUE ON} + {$WARN COMPARING_SIGNED_UNSIGNED ON} + {$WARN COMBINING_SIGNED_UNSIGNED ON} + {$WARN UNSUPPORTED_CONSTRUCT ON} + {$WARN FILE_OPEN ON} + {$WARN FILE_OPEN_UNITSRC ON} + {$WARN BAD_GLOBAL_SYMBOL ON} + {$WARN DUPLICATE_CTOR_DTOR ON} + {$WARN INVALID_DIRECTIVE ON} + {$WARN PACKAGE_NO_LINK ON} + {$WARN PACKAGED_THREADVAR ON} + {$WARN IMPLICIT_IMPORT ON} + {$WARN HPPEMIT_IGNORED ON} + {$WARN NO_RETVAL ON} + {$WARN USE_BEFORE_DEF ON} + {$WARN FOR_LOOP_VAR_UNDEF ON} + {$WARN UNIT_NAME_MISMATCH ON} + {$WARN NO_CFG_FILE_FOUND ON} + {$WARN MESSAGE_DIRECTIVE ON} + {$WARN IMPLICIT_VARIANTS ON} + {$WARN UNICODE_TO_LOCALE ON} + {$WARN LOCALE_TO_UNICODE ON} + {$WARN IMAGEBASE_MULTIPLE ON} + {$WARN SUSPICIOUS_TYPECAST ON} + {$WARN PRIVATE_PROPACCESSOR ON} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN OPTION_TRUNCATED ON} + {$WARN WIDECHAR_REDUCED ON} + {$WARN DUPLICATES_IGNORED ON} +{$IFEND} +// End Delphi 2005 Options + +// Delphi 2007 Options +{$IF CompilerVersion >= 18.50} + {$A8,B-,C-,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} + {$MINSTACKSIZE $00004000} + {$MAXSTACKSIZE $00100000} + {$IFDEF MSWINDOWS} + {$IMAGEBASE $00400000} + {$ENDIF} + {$APPTYPE GUI} + {$WARN SYMBOL_DEPRECATED ON} + {$WARN SYMBOL_LIBRARY ON} + {$WARN SYMBOL_PLATFORM ON} + {$WARN SYMBOL_EXPERIMENTAL ON} + {$WARN UNIT_LIBRARY ON} + {$WARN UNIT_PLATFORM ON} + {$WARN UNIT_DEPRECATED ON} + {$WARN UNIT_EXPERIMENTAL ON} + {$WARN HRESULT_COMPAT ON} + {$WARN HIDING_MEMBER ON} + {$WARN HIDDEN_VIRTUAL ON} + {$WARN GARBAGE ON} + {$WARN BOUNDS_ERROR ON} + {$WARN ZERO_NIL_COMPAT ON} + {$WARN STRING_CONST_TRUNCED ON} + {$WARN FOR_LOOP_VAR_VARPAR ON} + {$WARN TYPED_CONST_VARPAR ON} + {$WARN ASG_TO_TYPED_CONST ON} + {$WARN CASE_LABEL_RANGE ON} + {$WARN FOR_VARIABLE ON} + {$WARN CONSTRUCTING_ABSTRACT ON} + {$WARN COMPARISON_FALSE ON} + {$WARN COMPARISON_TRUE ON} + {$WARN COMPARING_SIGNED_UNSIGNED ON} + {$WARN COMBINING_SIGNED_UNSIGNED ON} + {$WARN UNSUPPORTED_CONSTRUCT ON} + {$WARN FILE_OPEN ON} + {$WARN FILE_OPEN_UNITSRC ON} + {$WARN BAD_GLOBAL_SYMBOL ON} + {$WARN DUPLICATE_CTOR_DTOR ON} + {$WARN INVALID_DIRECTIVE ON} + {$WARN PACKAGE_NO_LINK ON} + {$WARN PACKAGED_THREADVAR ON} + {$WARN IMPLICIT_IMPORT ON} + {$WARN HPPEMIT_IGNORED ON} + {$WARN NO_RETVAL ON} + {$WARN USE_BEFORE_DEF ON} + {$WARN FOR_LOOP_VAR_UNDEF ON} + {$WARN UNIT_NAME_MISMATCH ON} + {$WARN NO_CFG_FILE_FOUND ON} + {$WARN IMPLICIT_VARIANTS ON} + {$WARN UNICODE_TO_LOCALE ON} + {$WARN LOCALE_TO_UNICODE ON} + {$WARN IMAGEBASE_MULTIPLE ON} + {$WARN SUSPICIOUS_TYPECAST ON} + {$WARN PRIVATE_PROPACCESSOR ON} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN OPTION_TRUNCATED ON} + {$WARN WIDECHAR_REDUCED ON} + {$WARN DUPLICATES_IGNORED ON} + {$WARN UNIT_INIT_SEQ ON} + {$WARN LOCAL_PINVOKE ON} + {$WARN MESSAGE_DIRECTIVE ON} + {$WARN TYPEINFO_IMPLICITLY_ADDED ON} + {$WARN XML_WHITESPACE_NOT_ALLOWED ON} + {$WARN XML_UNKNOWN_ENTITY ON} + {$WARN XML_INVALID_NAME_START ON} + {$WARN XML_INVALID_NAME ON} + {$WARN XML_EXPECTED_CHARACTER ON} + {$WARN XML_CREF_NO_RESOLVE ON} + {$WARN XML_NO_PARM ON} + {$WARN XML_NO_MATCHING_PARM ON} +{$IFEND} +// End Delphi 2007 Options + +// Delphi 2010 Options +{$IF CompilerVersion >= 21.00} + {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N-,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} + {$MINSTACKSIZE $00004000} + {$MAXSTACKSIZE $00100000} + {$IFDEF MSWINDOWS} + {$IMAGEBASE $00400000} + {$ENDIF} + {$APPTYPE GUI} + {$WARN SYMBOL_DEPRECATED ON} + {$WARN SYMBOL_LIBRARY ON} + {$WARN SYMBOL_PLATFORM ON} + {$WARN SYMBOL_EXPERIMENTAL ON} + {$WARN UNIT_LIBRARY ON} + {$WARN UNIT_PLATFORM ON} + {$WARN UNIT_DEPRECATED ON} + {$WARN UNIT_EXPERIMENTAL ON} + {$WARN HRESULT_COMPAT ON} + {$WARN HIDING_MEMBER ON} + {$WARN HIDDEN_VIRTUAL ON} + {$WARN GARBAGE ON} + {$WARN BOUNDS_ERROR ON} + {$WARN ZERO_NIL_COMPAT ON} + {$WARN STRING_CONST_TRUNCED ON} + {$WARN FOR_LOOP_VAR_VARPAR ON} + {$WARN TYPED_CONST_VARPAR ON} + {$WARN ASG_TO_TYPED_CONST ON} + {$WARN CASE_LABEL_RANGE ON} + {$WARN FOR_VARIABLE ON} + {$WARN CONSTRUCTING_ABSTRACT ON} + {$WARN COMPARISON_FALSE ON} + {$WARN COMPARISON_TRUE ON} + {$WARN COMPARING_SIGNED_UNSIGNED ON} + {$WARN COMBINING_SIGNED_UNSIGNED ON} + {$WARN UNSUPPORTED_CONSTRUCT ON} + {$WARN FILE_OPEN ON} + {$WARN FILE_OPEN_UNITSRC ON} + {$WARN BAD_GLOBAL_SYMBOL ON} + {$WARN DUPLICATE_CTOR_DTOR ON} + {$WARN INVALID_DIRECTIVE ON} + {$WARN PACKAGE_NO_LINK ON} + {$WARN PACKAGED_THREADVAR ON} + {$WARN IMPLICIT_IMPORT ON} + {$WARN HPPEMIT_IGNORED ON} + {$WARN NO_RETVAL ON} + {$WARN USE_BEFORE_DEF ON} + {$WARN FOR_LOOP_VAR_UNDEF ON} + {$WARN UNIT_NAME_MISMATCH ON} + {$WARN NO_CFG_FILE_FOUND ON} + {$WARN IMPLICIT_VARIANTS ON} + {$WARN UNICODE_TO_LOCALE ON} + {$WARN LOCALE_TO_UNICODE ON} + {$WARN IMAGEBASE_MULTIPLE ON} + {$WARN SUSPICIOUS_TYPECAST ON} + {$WARN PRIVATE_PROPACCESSOR ON} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN OPTION_TRUNCATED ON} + {$WARN WIDECHAR_REDUCED ON} + {$WARN DUPLICATES_IGNORED ON} + {$WARN UNIT_INIT_SEQ ON} + {$WARN LOCAL_PINVOKE ON} + {$WARN MESSAGE_DIRECTIVE ON} + {$WARN TYPEINFO_IMPLICITLY_ADDED ON} + {$WARN RLINK_WARNING ON} + {$WARN IMPLICIT_STRING_CAST ON} + {$WARN IMPLICIT_STRING_CAST_LOSS ON} + {$WARN EXPLICIT_STRING_CAST OFF} + {$WARN EXPLICIT_STRING_CAST_LOSS OFF} + {$WARN CVT_WCHAR_TO_ACHAR ON} + {$WARN CVT_NARROWING_STRING_LOST ON} + {$WARN CVT_ACHAR_TO_WCHAR OFF} + {$WARN CVT_WIDENING_STRING_LOST OFF} + {$WARN XML_WHITESPACE_NOT_ALLOWED ON} + {$WARN XML_UNKNOWN_ENTITY ON} + {$WARN XML_INVALID_NAME_START ON} + {$WARN XML_INVALID_NAME ON} + {$WARN XML_EXPECTED_CHARACTER ON} + {$WARN XML_CREF_NO_RESOLVE ON} + {$WARN XML_NO_PARM ON} + {$WARN XML_NO_MATCHING_PARM ON} +{$IFEND} +// End Delphi 2010 Options + +interface +uses classes, TPLB3.HashDsc, TPLB3.StreamCipher, TPLB3.Decorators; + +type + +TSHA2FamilyMember = (SHA_224, SHA_256, SHA_348, SHA_512, SHA_512_224, SHA_512_256); + +{$IF compilerversion >= 21} [DesignDescription( +'SHA-2 is a family of hashes designed to supersede SHA-1. As of the date ' + +'of this writing, there are no discovered collisions for any SHA-2 member.' +)] {$IFEND} +TSHA2 = class( TInterfacedObject, + IHashDsc, ICryptoGraphicAlgorithm, IControlObject) + private + FAlgorithm: TSHA2FamilyMember; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DigestSize: integer; // in units of bits. Must be a multiple of 8. + function UpdateSize: integer; // Size that the input to the Update must be. + function MakeHasher( const Params: IInterface): IHasher; + function DefinitionURL: string; + function WikipediaReference: string; + function ControlObject: TObject; + + public + constructor Create( Algorithm1: TSHA2FamilyMember); + end; + + + + + +implementation + + + + + + +uses TPLB3.BinaryUtils, TPLB3.StreamUtils, TPLB3.PointerArithmetic, + TPLB3.IntegerUtils, TPLB3.Constants, TPLB3.I18n; + +type + TaToh = (a, b, c, d, e, f, g, h); + TSHA256_M_Array = array[0..15] of uint32; + TSHA512_M_Array = array[0..15] of uint64; + TSHA256_W_Array = array[0..63] of uint32; + TSHA512_W_Array = array[0..79] of uint64; + TaToh_Array32 = array[ TaToh ] of uint32; + TaToh_Array64 = array[ TaToh ] of uint64; + +TSHA2_BaseHasher = class( TInterfacedObject, IHasher) + private + constructor Create( Algorithm1: TSHA2FamilyMember); + + protected + FAlgorithm: TSHA2FamilyMember; + FCount: uint64; + FisEnding: boolean; + + protected + procedure InitHashVectors; virtual; abstract; + procedure Update( Source{in}: TMemoryStream); virtual; abstract; + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); virtual; abstract; + procedure Burn; virtual; abstract; + function SelfTest_Source: string; virtual; abstract; + function SelfTest_ReferenceHashValue: string; virtual; abstract; + end; + + +TSHA256 = class( TSHA2_BaseHasher) + protected + FH: TaToh_Array32; + + procedure InitHashVectors; override; + procedure Update( Source{in}: TMemoryStream); override; + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); override; + procedure Burn; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + +TSHA224 = class( TSHA256) + protected + procedure InitHashVectors; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + +TSHA512 = class( TSHA2_BaseHasher) + protected + FH: TaToh_Array64; + + procedure InitHashVectors; override; + procedure Update( Source{in}: TMemoryStream); override; + procedure End_Hash( PartBlock{in}: TMemoryStream; Digest: TStream); override; + procedure Burn; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + +TSHA384 = class( TSHA512) + protected + procedure InitHashVectors; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + +TSHA512_224 = class( TSHA512) + protected + procedure InitHashVectors; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + +TSHA512_256 = class( TSHA512) + protected + procedure InitHashVectors; override; + function SelfTest_Source: string; override; + function SelfTest_ReferenceHashValue: string; override; + end; + + + +/////////////////////////////////////// +// SHA-2 Primitives + +{ 4.2.2 SHA-224 and SHA-256 Constants + SHA-224 and SHA-256 use the same sequence of sixty-four constant 32-bit words, + These words represent the first thirty-two bits of the fractional parts of + the cube roots of the first sixty-four prime numbers. In hex, these constant + words are (from left to right). } + +const K_Values_32: array[ 0..63 ] of uint32 = ( + $428a2f98, $71374491, $b5c0fbcf, $e9b5dba5, $3956c25b, $59f111f1, $923f82a4, $ab1c5ed5, + $d807aa98, $12835b01, $243185be, $550c7dc3, $72be5d74, $80deb1fe, $9bdc06a7, $c19bf174, + $e49b69c1, $efbe4786, $0fc19dc6, $240ca1cc, $2de92c6f, $4a7484aa, $5cb0a9dc, $76f988da, + $983e5152, $a831c66d, $b00327c8, $bf597fc7, $c6e00bf3, $d5a79147, $06ca6351, $14292967, + $27b70a85, $2e1b2138, $4d2c6dfc, $53380d13, $650a7354, $766a0abb, $81c2c92e, $92722c85, + $a2bfe8a1, $a81a664b, $c24b8b70, $c76c51a3, $d192e819, $d6990624, $f40e3585, $106aa070, + $19a4c116, $1e376c08, $2748774c, $34b0bcb5, $391c0cb3, $4ed8aa4a, $5b9cca4f, $682e6ff3, + $748f82ee, $78a5636f, $84c87814, $8cc70208, $90befffa, $a4506ceb, $bef9a3f7, $c67178f2); + +{ 4.2.3 SHA-384, SHA-512, SHA-512/224 and SHA-512/256 Constants + SHA-384, SHA-512, SHA-512/224 and SHA-512/256 use the same sequence of eighty + constant 64-bit words, . These words represent the first sixty-four bits of + the fractional parts of the cube roots of the first eighty prime numbers. + In hex, these constant words are (from left to right) } + +{$IF compilerversion > 15} +const K_Values_64: array[ 0..79 ] of uint64 = ( + $428a2f98d728ae22, $7137449123ef65cd, $b5c0fbcfec4d3b2f, $e9b5dba58189dbbc, + $3956c25bf348b538, $59f111f1b605d019, $923f82a4af194f9b, $ab1c5ed5da6d8118, + $d807aa98a3030242, $12835b0145706fbe, $243185be4ee4b28c, $550c7dc3d5ffb4e2, + $72be5d74f27b896f, $80deb1fe3b1696b1, $9bdc06a725c71235, $c19bf174cf692694, + $e49b69c19ef14ad2, $efbe4786384f25e3, $0fc19dc68b8cd5b5, $240ca1cc77ac9c65, + $2de92c6f592b0275, $4a7484aa6ea6e483, $5cb0a9dcbd41fbd4, $76f988da831153b5, + $983e5152ee66dfab, $a831c66d2db43210, $b00327c898fb213f, $bf597fc7beef0ee4, + $c6e00bf33da88fc2, $d5a79147930aa725, $06ca6351e003826f, $142929670a0e6e70, + $27b70a8546d22ffc, $2e1b21385c26c926, $4d2c6dfc5ac42aed, $53380d139d95b3df, + $650a73548baf63de, $766a0abb3c77b2a8, $81c2c92e47edaee6, $92722c851482353b, + $a2bfe8a14cf10364, $a81a664bbc423001, $c24b8b70d0f89791, $c76c51a30654be30, + $d192e819d6ef5218, $d69906245565a910, $f40e35855771202a, $106aa07032bbd1b8, + $19a4c116b8d2d0c8, $1e376c085141ab53, $2748774cdf8eeb99, $34b0bcb5e19b48a8, + $391c0cb3c5c95a63, $4ed8aa4ae3418acb, $5b9cca4f7763e373, $682e6ff3d6b2b8a3, + $748f82ee5defb2fc, $78a5636f43172f60, $84c87814a1f0ab72, $8cc702081a6439ec, + $90befffa23631e28, $a4506cebde82bde9, $bef9a3f7b2c67915, $c67178f2e372532b, + $ca273eceea26619c, $d186b8c721c0c207, $eada7dd6cde0eb1e, $f57d4f7fee6ed178, + $06f067aa72176fba, $0a637dc5a2c898a6, $113f9804bef90dae, $1b710b35131c471b, + $28db77f523047d84, $32caab7b40c72493, $3c9ebe0a15c9bebc, $431d67c49c100d4c, + $4cc5d4becb3e42b6, $597f299cfc657e2a, $5fcb6fab3ad6faec, $6c44198c4a475817); + +{$ELSE} // Delphi 7 +const K_Values_64: array[ 0..79 ] of uint64 = ( + {}uint64( $428A2F98D728AE22){}, {}uint64( $7137449123EF65CD){}, {}uint64( -$4A3F043013B2C4D1){}, {}uint64( -$164A245A7E762444){}, + {}uint64( $3956C25BF348B538){}, {}uint64( $59F111F1B605D019){}, {}uint64( -$6DC07D5B50E6B065){}, {}uint64( -$54E3A12A25927EE8){}, + {}uint64( -$27F855675CFCFDBE){}, {}uint64( $12835B0145706FBE){}, {}uint64( $243185BE4EE4B28C){}, {}uint64( $550C7DC3D5FFB4E2){}, + {}uint64( $72BE5D74F27B896F){}, {}uint64( -$7F214E01C4E9694F){}, {}uint64( -$6423F958DA38EDCB){}, {}uint64( -$3E640E8B3096D96C){}, + {}uint64( -$1B64963E610EB52E){}, {}uint64( -$1041B879C7B0DA1D){}, {}uint64( $0FC19DC68B8CD5B5){}, {}uint64( $240CA1CC77AC9C65){}, + {}uint64( $2DE92C6F592B0275){}, {}uint64( $4A7484AA6EA6E483){}, {}uint64( $5CB0A9DCBD41FBD4){}, {}uint64( $76F988DA831153B5){}, + {}uint64( -$67C1AEAD11992055){}, {}uint64( -$57CE3992D24BCDF0){}, {}uint64( -$4FFCD8376704DEC1){}, {}uint64( -$40A680384110F11C){}, + {}uint64( -$391FF40CC257703E){}, {}uint64( -$2A586EB86CF558DB){}, {}uint64( $06CA6351E003826F){}, {}uint64( $142929670A0E6E70){}, + {}uint64( $27B70A8546D22FFC){}, {}uint64( $2E1B21385C26C926){}, {}uint64( $4D2C6DFC5AC42AED){}, {}uint64( $53380D139D95B3DF){}, + {}uint64( $650A73548BAF63DE){}, {}uint64( $766A0ABB3C77B2A8){}, {}uint64( -$7E3D36D1B812511A){}, {}uint64( -$6D8DD37AEB7DCAC5){}, + {}uint64( -$5D40175EB30EFC9C){}, {}uint64( -$57E599B443BDCFFF){}, {}uint64( -$3DB4748F2F07686F){}, {}uint64( -$3893AE5CF9AB41D0){}, + {}uint64( -$2E6D17E62910ADE8){}, {}uint64( -$2966F9DBAA9A56F0){}, {}uint64( -$0BF1CA7AA88EDFD6){}, {}uint64( $106AA07032BBD1B8){}, + {}uint64( $19A4C116B8D2D0C8){}, {}uint64( $1E376C085141AB53){}, {}uint64( $2748774CDF8EEB99){}, {}uint64( $34B0BCB5E19B48A8){}, + {}uint64( $391C0CB3C5C95A63){}, {}uint64( $4ED8AA4AE3418ACB){}, {}uint64( $5B9CCA4F7763E373){}, {}uint64( $682E6FF3D6B2B8A3){}, + {}uint64( $748F82EE5DEFB2FC){}, {}uint64( $78A5636F43172F60){}, {}uint64( -$7B3787EB5E0F548E){}, {}uint64( -$7338FDF7E59BC614){}, + {}uint64( -$6F410005DC9CE1D8){}, {}uint64( -$5BAF9314217D4217){}, {}uint64( -$41065C084D3986EB){}, {}uint64( -$398E870D1C8DACD5){}, + {}uint64( -$35D8C13115D99E64){}, {}uint64( -$2E794738DE3F3DF9){}, {}uint64( -$15258229321F14E2){}, {}uint64( -$0A82B08011912E88){}, + {}uint64( $06F067AA72176FBA){}, {}uint64( $0A637DC5A2C898A6){}, {}uint64( $113F9804BEF90DAE){}, {}uint64( $1B710B35131C471B){}, + {}uint64( $28DB77F523047D84){}, {}uint64( $32CAAB7B40C72493){}, {}uint64( $3C9EBE0A15C9BEBC){}, {}uint64( $431D67C49C100D4C){}, + {}uint64( $4CC5D4BECB3E42B6){}, {}uint64( $597F299CFC657E2A){}, {}uint64( $5FCB6FAB3AD6FAEC){}, {}uint64( $6C44198C4A475817){}); +{$IFEND} + + + // FIPS PUB 180-4 | 4.1.2 | Ch() function +function Ch32( x, y, z: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// Ch(x,y,z) = (x ^ y) xor (not x ^ z) +result := (x and y) xor ((not x) and z) +end; + + + // FIPS PUB 180-4 | 4.1.3 | Ch() function +function Ch64( x, y, z: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// Ch(x,y,z) = (x ^ y) xor (not x ^ z) +result := (x and y) xor ((not x) and z) +end; + + + // FIPS PUB 180-4 | 4.1.2 | Maj() function +function Maj32( x, y, z: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// Ch(x,y,z) = (x ^ y) xor (x ^ z) xor (y ^ z) +result := (x and y) xor (x and z) xor (y and z) +end; + + + // FIPS PUB 180-4 | 4.1.3 | Maj() function +function Maj64( x, y, z: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// Ch(x,y,z) = (x ^ y) xor (x ^ z) xor (y ^ z) +result := (x and y) xor (x and z) xor (y and z) +end; + + + // FIPS PUB 180-4 | 4.2.4 | ROTR operation +function Rotr32( Shift: integer; x: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +result := (x shr Shift) or (x shl (32 - Shift)) +end; + + +function Rotr64( Shift: integer; x: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +result := (x shr Shift) or (x shl (64 - Shift)) +end; + + + + // FIPS PUB 180-4 | 4.1.2 | SIGMA[0,256]() function +function BigSigma0_256_32( x: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// SIGMA[0,256](x) = ROTR[2](x) xor ROTR[13](x) xor ROTR[22](x) +result := Rotr32( 2, x) xor Rotr32( 13, x) xor Rotr32( 22, x) +end; + + + + // FIPS PUB 180-4 | 4.1.2 | SIGMA[1,256]() function +function BigSigma1_256_32( x: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// SIGMA[1,256](x) = ROTR[6](x) xor ROTR[11](x) xor ROTR[25](x) +result := Rotr32( 6, x) xor Rotr32( 11, x) xor Rotr32( 25, x) +end; + + + + // FIPS PUB 180-4 | 4.1.3 | SIGMA[0,512]() function +function BigSigma0_512_64( x: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// SIGMA[0,512](x) = ROTR[28](x) xor ROTR[34](x) xor ROTR[39](x) +result := Rotr64( 28, x) xor Rotr64( 34, x) xor Rotr64( 39, x) +end; + + + + // FIPS PUB 180-4 | 4.1.3 | SIGMA[1,512]() function +function BigSigma1_512_64( x: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// SIGMA[1,512](x) = ROTR[14](x) xor ROTR[18](x) xor ROTR[41](x) +result := Rotr64( 14, x) xor Rotr64( 18, x) xor Rotr64( 41, x) +end; + + + + // FIPS PUB 180-4 | 4.1.2 | sigma[0,256]() function +function LittleSigma0_256_32( x: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// sigma[0,256](x) = ROTR[7](x) xor ROTR[18](x) xor SHR[3](x) +result := Rotr32( 7, x) xor Rotr32( 18, x) xor (x shr 3) +end; + + + + // FIPS PUB 180-4 | 4.1.2 | sigma[1,256]() function +function LittleSigma1_256_32( x: uint32): uint32; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// sigma[1,256](x) = ROTR[17](x) xor ROTR[19](x) xor SHR[10](x) +result := Rotr32( 17, x) xor Rotr32( 19, x) xor (x shr 10) +end; + + + + // FIPS PUB 180-4 | 4.1.3 | sigma[0,512]() function +function LittleSigma0_512_64( x: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// sigma[0,512](x) = ROTR[1](x) xor ROTR[8](x) xor SHR[7](x) +result := Rotr64( 1, x) xor Rotr64( 8, x) xor (x shr 7) +end; + + + + // FIPS PUB 180-4 | 4.1.3 | sigma[1,512]() function +function LittleSigma1_512_64( x: uint64): uint64; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +// sigma[1,512](x) = ROTR[19](x) xor ROTR[61](x) xor SHR[6](x) +result := Rotr64( 19, x) xor Rotr64( 61, x) xor (x shr 6) +end; + + +function SHA_StylePadding_64_in_512( MessageLengthInBits: uint64; var Pad): integer; +// The padded message will be 512 bits or 64 bytes. +// Assume Pad is at least that long. +// Return number of bytes of padding. +var + PadByte: PByte; + BigEndienLenInBits: uint64; + Excess, Zeros: integer; +begin +PadByte := @Pad; +PadByte^ := $80; +Inc( PadByte); +Excess := ((MessageLengthInBits + 7) div 8) mod 64; +Zeros := 55 - Excess; +if Zeros < 0 then + Inc( Zeros, 64); +if Zeros > 0 then + begin + FillChar( PadByte^, Zeros, $00); + Inc( PadByte, Zeros) + end; +BigEndienLenInBits := SwapEndien_u64( MessageLengthInBits); +Move( BigEndienLenInBits, PadByte^, 8); +result := Zeros + 9 +end; + + +function SHA_StylePadding_128_in_1024( + Lo64MessageLengthInBits, Hi64MessageLengthInBits: uint64; var Pad): integer; +// The padded message will be 1024 bits or 128 bytes. +// Assume Pad is at least that long. +// Return number of bytes of padding. +var + PadByte: PByte; + BigEndienLenInBits: uint64; + Excess, Zeros: integer; +begin +PadByte := @Pad; +PadByte^ := $80; +Inc( PadByte); +Excess := ((Lo64MessageLengthInBits + 7) div 8) mod 128; +Zeros := 111 - Excess; +if Zeros < 0 then + Inc( Zeros, 128); +if Zeros > 0 then + begin + FillChar( PadByte^, Zeros, $00); + Inc( PadByte, Zeros) + end; +BigEndienLenInBits := SwapEndien_s64( Hi64MessageLengthInBits); +Move( BigEndienLenInBits, PadByte^, 8); +Inc( PadByte, 8); +BigEndienLenInBits := SwapEndien_s64( Lo64MessageLengthInBits); +Move( BigEndienLenInBits, PadByte^, 8); +result := Zeros + 17 +end; + +procedure SHA256_Step1( + const M: TSHA256_M_Array; + var W: TSHA256_W_Array); +var + t: integer; + Temp32: uint32; +begin +for t := 0 to 15 do + W[t] := M[t]; +for t := 16 to 63 do + begin + Temp32 := LittleSigma1_256_32( W[t-2]) + + W[t-7] + + LittleSigma0_256_32( W[t-15]) + + W[t-16]; + W[t] := Temp32 + end +end; + +procedure SHA512_Step1( + const M: TSHA512_M_Array; + var W: TSHA512_W_Array); +var + t: integer; + Temp64: uint64; +begin +for t := 0 to 15 do + W[t] := M[t]; +for t := 16 to 79 do + begin + Temp64 := LittleSigma1_512_64( W[t-2]) + + W[t-7] + + LittleSigma0_512_64( W[t-15]) + + W[t-16]; + W[t] := Temp64 + end +end; + + +procedure SHA256_Step3( + var aa: TaToh_Array32; + const W: TSHA256_W_Array); +var + T1, T2: uint32; + t: integer; +begin +for t := 0 to 63 do + begin + T1 := aa[h] + BigSigma1_256_32( aa[e]) + Ch32( aa[e], aa[f], aa[g]) + K_Values_32[t] + W[t]; + T2 := BigSigma0_256_32( aa[a]) + Maj32( aa[a], aa[b], aa[c]); + aa[h] := aa[g]; + aa[g] := aa[f]; + aa[f] := aa[e]; + aa[e] := aa[d] + T1; + aa[d] := aa[c]; + aa[c] := aa[b]; + aa[b] := aa[a]; + aa[a] := T1 + T2 + end +end; + + +procedure SHA512_Step3( + var aa: TaToh_Array64; + const W: TSHA512_W_Array); +var + T1, T2: uint64; + t: integer; +begin +for t := 0 to 79 do + begin + T1 := aa[h] + BigSigma1_512_64( aa[e]) + Ch64( aa[e], aa[f], aa[g]) + K_Values_64[t] + W[t]; + T2 := BigSigma0_512_64( aa[a]) + Maj64( aa[a], aa[b], aa[c]); + aa[h] := aa[g]; + aa[g] := aa[f]; + aa[f] := aa[e]; + aa[e] := aa[d] + T1; + aa[d] := aa[c]; + aa[c] := aa[b]; + aa[b] := aa[a]; + aa[a] := T1 + T2 + end +end; + + +procedure SHA256_Step4( + var HH: TaToh_Array32; + const aa: TaToh_Array32); +var + Letter: TaToh; +begin +for Letter := a to h do + HH[ Letter] := HH[ Letter] + aa[ Letter] +end; + + +procedure SHA512_Step4( + var HH: TaToh_Array64; + const aa: TaToh_Array64); +var + Letter: TaToh; +begin +for Letter := a to h do + HH[ Letter] := HH[ Letter] + aa[ Letter] +end; + + +procedure SHA256_Step2( + var aa: TaToh_Array32; + const HH: TaToh_Array32); +var + Letter: TaToh; +begin +for Letter := a to h do + aa[ Letter] := HH[ Letter] +end; + + +procedure SHA512_Step2( + var aa: TaToh_Array64; + const HH: TaToh_Array64); +var + Letter: TaToh; +begin +for Letter := a to h do + aa[ Letter] := HH[ Letter] +end; + + +/////////////////////////////////////// +// TSHA-2 Class + +function TSHA2.ControlObject: TObject; +begin +result := self +end; + + +constructor TSHA2.Create( Algorithm1: TSHA2FamilyMember); +begin +FAlgorithm := Algorithm1 +end; + + + +function TSHA2.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/drafts/' + + 'fips180-4/Draft-FIPS180-4_Feb2011.pdf' +end; + +const DigestSizes: array[ TSHA2FamilyMember] of integer = ( +// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 + 224, 256, 384, 512, 224, 256); +function TSHA2.DigestSize: integer; +begin +result := DigestSizes[ FAlgorithm] +end; + + +function TSHA2.DisplayName: string; +const Names: array[ TSHA2FamilyMember] of string = ( +// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 + '224', '256', '384', '512', '512/224', '512/256'); +begin +result := 'SHA-' + Names[ FAlgorithm] +end; + + +function TSHA2.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware]; +if FAlgorithm in [SHA_512_224, SHA_512_256] then + Include( result, afStar) +end; + + + +function TSHA2.MakeHasher( const Params: IInterface): IHasher; +type + TSHA2_BaseHasherClass = class of TSHA2_BaseHasher; +const + Classes: array[ TSHA2FamilyMember] of TSHA2_BaseHasherClass = ( + TSHA224, TSHA256, TSHA384, TSHA512, TSHA512_224, TSHA512_256); +begin +result := Classes[ Falgorithm].Create( FAlgorithm) +end; + + +function TSHA2.ProgId: string; +const Names: array[ TSHA2FamilyMember] of string = ( +// SHA_224, SHA_256, SHA_348, SHA_512, SHA_512_224, SHA_512_256 + SHA224_ProgId, SHA256_ProgId, + SHA384_ProgId, SHA512_ProgId, SHA512_224_ProgId, SHA512_256_ProgId); +begin +result := Names[ FAlgorithm] +end; + +function TSHA2.UpdateSize: integer; +const Sizes: array[ TSHA2FamilyMember] of integer = ( +// SHA_224, SHA_256, SHA_384, SHA_512, SHA_512_224, SHA_512_256 + 512, 512, 1024, 1024, 1024, 1024); +begin +result := Sizes[ FAlgorithm] +end; + + +function TSHA2.WikipediaReference: string; +begin +result := {'http://en.wikipedia.org/wiki/' +} 'Sha-2' +end; + + +{ TSHA2_BaseHasher } + +constructor TSHA2_BaseHasher.Create( Algorithm1: TSHA2FamilyMember); +begin +FAlgorithm := Algorithm1; +FCount := 0; +FisEnding := False; +InitHashVectors +end; + +{ TSHA256 } + +procedure TSHA256.InitHashVectors; +begin +FH[a] := $6a09e667; +FH[b] := $bb67ae85; +FH[c] := $3c6ef372; +FH[d] := $a54ff53a; +FH[e] := $510e527f; +FH[f] := $9b05688c; +FH[g] := $1f83d9ab; +FH[h] := $5be0cd19 +end; + + + +procedure TSHA256.Update( Source: TMemoryStream); +var + M: TSHA256_M_Array; + W: TSHA256_W_Array; + aa: TaToh_Array32; + t: integer; + Temp32: uint32; +begin +Assert( Source.Size = 64, 'TSHA256.Update - Wrong block size.'); +if not FisEnding then + Inc( FCount, 512); +Source.Position := 0; +for t := 0 to 15 do + begin + Source.Read( Temp32, 4); + M[t] := SwapEndien_u32( Temp32) + end; +SHA256_Step1( M, W); +SHA256_Step2( aa, FH); +SHA256_Step3( aa, W); +SHA256_Step4( FH, aa) +end; + + +procedure TSHA256.End_Hash( PartBlock: TMemoryStream; Digest: TStream); +var + MessageLengthInBits, L: uint64; + Pad: packed array[ 0..71 ] of byte; + PaddingCountInBytes: integer; + PadOrigin, Xfer: integer; + jj: TaToh; + lwDigest: uint32; +begin +L := PartBlock.Position; +Assert( L <= 64, 'TSHA256.End_Hash - Wrong block size.'); +FisEnding := True; +Inc( FCount, L * 8); +MessageLengthInBits := FCount; +PaddingCountInBytes := SHA_StylePadding_64_in_512( MessageLengthInBits, Pad); +PadOrigin := 0; +Xfer := 64 - L; +if Xfer < 0 then + Xfer := 0; +if Xfer > PaddingCountInBytes then + Xfer := PaddingCountInBytes; +if Xfer > 0 then + begin + PartBlock.Write( Pad, Xfer); + Inc( PadOrigin, Xfer); + Dec( PaddingCountInBytes, Xfer) + end; +Update( PartBlock); +Xfer := PaddingCountInBytes; +if Xfer > 0 then + begin + PartBlock.Position := 0; + PartBlock.Write( Pad[ PadOrigin], Xfer); + Assert( Xfer = 64, 'TSHA256.End_Hash - Wrong block size.'); + Update( PartBlock) + end; +PartBlock.Position := L; +L := DigestSizes[ FAlgorithm] div 8; // digest size in bytes. +Digest.Position := 0; +for jj := a to h do + begin + if L <= 0 then break; + lwDigest := SwapEndien_u32( FH[jj]); + Xfer := 4; + if Xfer > L then + Xfer := L; + if Xfer <= 0 then break; + Digest.WriteBuffer( lwDigest, Xfer); + Dec( L, Xfer) + end; +Digest.Position := 0; +FillChar( FH, SizeOf( FH), 0) +end; + + +procedure TSHA256.Burn; +begin +FCount := 0; +FillChar( FH, SizeOf( FH), 0); +FisEnding := False +end; + +function TSHA256.SelfTest_Source: string; +begin +result := 'abc' +end; + + +function TSHA256.SelfTest_ReferenceHashValue: string; +begin +result := 'BA7816BF 8F01CFEA ' + + '414140DE 5DAE2223 B00361A3 96177A9C B410FF61 F20015AD' +end; + + +{ TSHA224 } + +procedure TSHA224.InitHashVectors; +begin +FH[a] := $c1059ed8; +FH[b] := $367cd507; +FH[c] := $3070dd17; +FH[d] := $f70e5939; +FH[e] := $ffc00b31; +FH[f] := $68581511; +FH[g] := $64f98fa7; +FH[h] := $befa4fa4 +end; + + +function TSHA224.SelfTest_Source: string; +begin +result := 'abc' +// Two block alternative: +// result := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' +end; + + +function TSHA224.SelfTest_ReferenceHashValue: string; +begin +result := '23097D22 3405D822 8642A477 BDA255B3 2AADBCE4 BDA0B3F7 E36C9DA7' +// Two block alternative: +// result := '75388B16 512776CC 5DBA5DA1 FD890150 B0C6455C B4F58B19 52522525' +end; + + + + +{ TSHA512 } + +procedure TSHA512.InitHashVectors; +begin +{$IF compilerversion > 15} +FH[a] := $6a09e667f3bcc908; +FH[b] := $bb67ae8584caa73b; +FH[c] := $3c6ef372fe94f82b; +FH[d] := $a54ff53a5f1d36f1; +FH[e] := $510e527fade682d1; +FH[f] := $9b05688c2b3e6c1f; +FH[g] := $1f83d9abfb41bd6b; +FH[h] := $5be0cd19137e2179 + +{$ELSE} // Delphi 7 +FH[a] := {}uint64( $6A09E667F3BCC908){}; +FH[b] := {}uint64( -$4498517A7B3558C5){}; +FH[c] := {}uint64( $3C6EF372FE94F82B){}; +FH[d] := {}uint64( -$5AB00AC5A0E2C90F){}; +FH[e] := {}uint64( $510E527FADE682D1){}; +FH[f] := {}uint64( -$64FA9773D4C193E1){}; +FH[g] := {}uint64( $1F83D9ABFB41BD6B){}; +FH[h] := {}uint64( $5BE0CD19137E2179){} +{$IFEND} +end; + + + +procedure TSHA512.Update( Source: TMemoryStream); +var + M: TSHA512_M_Array; + W: TSHA512_W_Array; + aa: TaToh_Array64; + t: integer; + Temp64: uint64; +begin +Assert( Source.Size = 128, 'TSHA512.Update - Wrong block size.'); +if not FisEnding then + Inc( FCount, 1024); +Source.Position := 0; +for t := 0 to 15 do + begin + Source.Read( Temp64, 8); + M[t] := SwapEndien_u64( Temp64) + end; +SHA512_Step1( M, W); +SHA512_Step2( aa, FH); +SHA512_Step3( aa, W); +SHA512_Step4( FH, aa) +end; + + +procedure TSHA512.End_Hash( PartBlock: TMemoryStream; Digest: TStream); +var + Lo64MessageLengthInBits, Hi64MessageLengthInBits, L: uint64; + Pad: packed array[ 0..255 ] of byte; + PaddingCountInBytes: integer; + PadOrigin, Xfer: integer; + jj: TaToh; + lwDigest: uint64; +begin +L := PartBlock.Position; +Assert( L <= 128, 'TSHA512.End_Hash - Wrong block size.'); +FisEnding := True; +Inc( FCount, L * 8); +Lo64MessageLengthInBits := FCount; +Hi64MessageLengthInBits := 0; +PaddingCountInBytes := SHA_StylePadding_128_in_1024( + Lo64MessageLengthInBits, Hi64MessageLengthInBits, Pad); +PadOrigin := 0; +Xfer := 128 - L; +if Xfer < 0 then + Xfer := 0; +if Xfer > PaddingCountInBytes then + Xfer := PaddingCountInBytes; +if Xfer > 0 then + begin + PartBlock.Write( Pad, Xfer); + Inc( PadOrigin, Xfer); + Dec( PaddingCountInBytes, Xfer) + end; +Update( PartBlock); +Xfer := PaddingCountInBytes; +if Xfer > 0 then + begin + PartBlock.Position := 0; + PartBlock.Write( Pad[ PadOrigin], Xfer); + Assert( Xfer = 128, 'TSHA512.End_Hash - Wrong block size.'); + Update( PartBlock) + end; +PartBlock.Position := L; +L := DigestSizes[ FAlgorithm] div 8; // digest size in bytes. +Digest.Position := 0; +for jj := a to h do + begin + if L <= 0 then break; + lwDigest := SwapEndien_u64( FH[jj]); + Xfer := 8; + if Xfer > L then + Xfer := L; + if Xfer <= 0 then break; + Digest.WriteBuffer( lwDigest, Xfer); + Dec( L, Xfer) + end; +Digest.Position := 0; +FillChar( FH, SizeOf( FH), 0) +end; + + +procedure TSHA512.Burn; +begin +FCount := 0; +FillChar( FH, SizeOf( FH), 0); +FisEnding := False +end; + +function TSHA512.SelfTest_Source: string; +begin +result := 'abc' +end; + + +function TSHA512.SelfTest_ReferenceHashValue: string; +begin +result := 'DDAF35A1 93617ABA CC417349 AE204131 ' + + '12E6FA4E 89A97EA2 0A9EEEE6 4B55D39A 2192992A 274FC1A8 ' + + '36BA3C23 A3FEEBBD 454D4423 643CE80E 2A9AC94F A54CA49F' +end; + + + +{ TSHA348 } + +procedure TSHA384.InitHashVectors; +begin +{$IF compilerversion > 15} +FH[a] := $cbbb9d5dc1059ed8; +FH[b] := $629a292a367cd507; +FH[c] := $9159015a3070dd17; +FH[d] := $152fecd8f70e5939; +FH[e] := $67332667ffc00b31; +FH[f] := $8eb44a8768581511; +FH[g] := $db0c2e0d64f98fa7; +FH[h] := $47b5481dbefa4fa4 + +{$ELSE} // Delphi 7 +FH[a] := {}uint64( -$344462A23EFA6128){}; +FH[b] := {}uint64( $629A292A367CD507){}; +FH[c] := {}uint64( -$6EA6FEA5CF8F22E9){}; +FH[d] := {}uint64( $152FECD8F70E5939){}; +FH[e] := {}uint64( $67332667FFC00B31){}; +FH[f] := {}uint64( -$714BB57897A7EAEF){}; +FH[g] := {}uint64( -$24F3D1F29B067059){}; +FH[h] := {}uint64( $47B5481DBEFA4FA4){} +{$IFEND} +end; + + +function TSHA384.SelfTest_Source: string; +begin +result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijk' + + 'lmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' + +end; + + +function TSHA384.SelfTest_ReferenceHashValue: string; +begin +result := '09330C33 F71147E8 3D192FC7 82CD1B47 53111B17 3B3B05D2 ' + + '2FA08086 E3B0F712 FCC7C71A 557E2DB9 66C3E9FA 91746039' +end; + + +{ TSHA512_224 } + +procedure TSHA512_224.InitHashVectors; +begin +{$IF compilerversion > 15} +FH[a] := $8C3D37C819544DA2; +FH[b] := $73E1996689DCD4D6; +FH[c] := $1DFAB7AE32FF9C82; +FH[d] := $679DD514582F9FCF; +FH[e] := $0F6D2B697BD44DA8; +FH[f] := $77E36F7304C48942; +FH[g] := $3F9D85A86A1D36C8; +FH[h] := $1112E6AD91D692A1 + +{$ELSE} // Delphi 7 +FH[a] := {}uint64( -$73C2C837E6ABB25E){}; +FH[b] := {}uint64( $73E1996689DCD4D6){}; +FH[c] := {}uint64( $1DFAB7AE32FF9C82){}; +FH[d] := {}uint64( $679DD514582F9FCF){}; +FH[e] := {}uint64( $0F6D2B697BD44DA8){}; +FH[f] := {}uint64( $77E36F7304C48942){}; +FH[g] := {}uint64( $3F9D85A86A1D36C8){}; +FH[h] := {}uint64( $1112E6AD91D692A1){} +{$IFEND} +end; + + + +function TSHA512_224.SelfTest_Source: string; +begin +result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi' + + 'jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' +end; + +function TSHA512_224.SelfTest_ReferenceHashValue: string; +begin +result := '23FEC5BB 94D60B23 30819264 0B0C4533 35D66473 4FE40E72 68674AF9' +end; + + + +{ TSHA512_256 } + +procedure TSHA512_256.InitHashVectors; +begin +{$IF compilerversion > 15} +FH[a] := $22312194FC2BF72C; +FH[b] := $9F555FA3C84C64C2; +FH[c] := $2393B86B6F53B151; +FH[d] := $963877195940EABD; +FH[e] := $96283EE2A88EFFE3; +FH[f] := $BE5E1E2553863992; +FH[g] := $2B0199FC2C85B8AA; +FH[h] := $0EB72DDC81C52CA2 + +{$ELSE} // Delphi 7 +FH[a] := {}uint64( $22312194FC2BF72C){}; +FH[b] := {}uint64( -$60AAA05C37B39B3E){}; +FH[c] := {}uint64( $2393B86B6F53B151){}; +FH[d] := {}uint64( -$69C788E6A6BF1543){}; +FH[e] := {}uint64( -$69D7C11D5771001D){}; +FH[f] := {}uint64( -$41A1E1DAAC79C66E){}; +FH[g] := {}uint64( $2B0199FC2C85B8AA){}; +FH[h] := {}uint64( $0EB72DDC81C52CA2){} +{$IFEND} +end; + + + +function TSHA512_256.SelfTest_Source: string; +begin +result := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijkl' + + 'mnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu' +end; + +function TSHA512_256.SelfTest_ReferenceHashValue: string; +begin +result := '3928E184 FB8690F8 40DA3988 121D31BE 65CB9D3E F83EE614 ' + + '6FEAC861 E19B563A' +end; + + +end. diff --git a/run/TPLB3.SVN_Keywords.pas b/LockBox3/run/TPLB3.SVN_Keywords.pas similarity index 95% rename from run/TPLB3.SVN_Keywords.pas rename to LockBox3/run/TPLB3.SVN_Keywords.pas index 35b21c5..a377e26 100644 --- a/run/TPLB3.SVN_Keywords.pas +++ b/LockBox3/run/TPLB3.SVN_Keywords.pas @@ -1,42 +1,42 @@ -{$I TPLB3.Common.inc} - -unit TPLB3.SVN_Keywords; -interface -const - TPLB3Runtime_SVN_Keyword_Date : string = '$Date: ? $'; - TPLB3Runtime_SVN_Keyword_Revision: string = '$Revision: ? $'; - TPLB3Runtime_SVN_Keyword_Author : string = '$Author: ? $'; - TPLB3Runtime_SVN_Keyword_HeadURL : string = '$HeadURL: ? $'; - TPLB3Runtime_SVN_Keyword_Id : string = '$Id: TPLB3.SVN_Keywords.pas ? ? ? $'; - - -function TPLB3Runtime_SVN_Revision: integer; - - -implementation - -{$WARNINGS OFF} -function TPLB3Runtime_SVN_Revision: integer; -var - s, Pattern: string; - P, Code: integer; -begin -s := TPLB3Runtime_SVN_Keyword_Revision; -Pattern := '$Revision: '; -P := Pos( Pattern, s); -if P > 0 then - Delete( s, P, Length( Pattern)); -Pattern := ' '; -P := Pos( Pattern, s); -if P > 0 then - SetLength( s, P-1); -Val( s, result, Code); -if (s = '') or (Code <> 0) then - result := -1 // Signifying unknown version -end; -{$WARNINGS ON} - -{ Here is a scratch pad area for forcing changes to file in SVN. - -} -end. +{$I TPLB3.Common.inc} + +unit TPLB3.SVN_Keywords; +interface +const + TPLB3Runtime_SVN_Keyword_Date : string = '$Date: ? $'; + TPLB3Runtime_SVN_Keyword_Revision: string = '$Revision: ? $'; + TPLB3Runtime_SVN_Keyword_Author : string = '$Author: ? $'; + TPLB3Runtime_SVN_Keyword_HeadURL : string = '$HeadURL: ? $'; + TPLB3Runtime_SVN_Keyword_Id : string = '$Id: TPLB3.SVN_Keywords.pas ? ? ? $'; + + +function TPLB3Runtime_SVN_Revision: integer; + + +implementation + +{$WARNINGS OFF} +function TPLB3Runtime_SVN_Revision: integer; +var + s, Pattern: string; + P, Code: integer; +begin +s := TPLB3Runtime_SVN_Keyword_Revision; +Pattern := '$Revision: '; +P := Pos( Pattern, s); +if P > 0 then + Delete( s, P, Length( Pattern)); +Pattern := ' '; +P := Pos( Pattern, s); +if P > 0 then + SetLength( s, P-1); +Val( s, result, Code); +if (s = '') or (Code <> 0) then + result := -1 // Signifying unknown version +end; +{$WARNINGS ON} + +{ Here is a scratch pad area for forcing changes to file in SVN. + +} +end. diff --git a/run/TPLB3.Signatory.pas b/LockBox3/run/TPLB3.Signatory.pas similarity index 96% rename from run/TPLB3.Signatory.pas rename to LockBox3/run/TPLB3.Signatory.pas index 98873ec..f5771a7 100644 --- a/run/TPLB3.Signatory.pas +++ b/LockBox3/run/TPLB3.Signatory.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,234 +12,234 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.Signatory; -interface -uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.Codec, TPLB3.Asymetric; - -type -TGenerateKeysPhase = (gkNeutral, gkGenSigningKeys, gkGenCryptoKeys, gkDone); -TVerifyResult = (vPass, vFail, vUserAbort); - - -TSignatory = class( TTPLb_BaseNonVisualComponent) - private - FCodec: TCodec; - - procedure SetCodec( Value: TCodec); - - protected - procedure Notification( - AComponent: TComponent; Operation: TOperation); override; - - public - FGenPhase: TGenerateKeysPhase; - FCryptoKeys : TAsymetricKeyPair; - FSigningKeys: TAsymetricKeyPair; - - constructor Create( AOwner: TComponent); override; - destructor Destroy; override; - function Sign( Document, Signature: TStream): boolean; - function Verify( Document, Signature: TStream): TVerifyResult; - - function GenerateKeys: boolean; - procedure StoreKeysToStream( Store: TStream; Parts: TKeyStoragePartSet); - procedure LoadKeysFromStream( Store: TStream; Parts: TKeyStoragePartSet); - function Can_SaveKeys( Parts: TKeyStoragePartSet): boolean; - function HasParts: TKeyStoragePartSet; - - procedure Burn; - - published - property Codec: TCodec read FCodec write SetCodec; - end; - -implementation - - - - - - - - - - -uses SysUtils; -{ TSignatory } - -procedure TSignatory.Notification( - AComponent: TComponent; Operation: TOperation); -begin -inherited; -if (Operation = opRemove) and (AComponent = FCodec) then - SetCodec( nil) -end; - - - -procedure TSignatory.SetCodec( Value: TCodec); -begin -if FCodec = Value then exit; -if assigned( FCodec) then - FCodec.RemoveFreeNotification( self); -FCodec := Value; -if assigned( FCodec) then - FCodec.FreeNotification( self) -end; - - - - - - -constructor TSignatory.Create( AOwner: TComponent); -begin -FGenPhase := gkNeutral; -inherited -end; - - -destructor TSignatory.Destroy; -begin -Burn; -SetCodec( nil); -inherited -end; - - -procedure TSignatory.Burn; -begin -if assigned( FSigningKeys) then - FSigningKeys.Burn; -if assigned( FCryptoKeys) then - FCryptoKeys.Burn; -FreeAndNil( FSigningKeys); FreeAndNil( FCryptoKeys) -end; - - -function TSignatory.GenerateKeys: boolean; -begin -FGenPhase := gkGenSigningKeys; -FreeAndNil( FSigningKeys); FreeAndNil( FCryptoKeys); -FCodec.InitFromGeneratedAsymetricKeyPair; -result := not FCodec.isUserAborted; -if not result then exit; -FSigningKeys := (FCodec.Key as TAsymetricKeyPair).Clone; -FGenPhase := gkGenCryptoKeys; -FCodec.InitFromGeneratedAsymetricKeyPair; -result := not FCodec.isUserAborted; -if not result then exit; -FCryptoKeys := (FCodec.Key as TAsymetricKeyPair).Clone; -FGenPhase := gkDone -end; - - -function TSignatory.HasParts: TKeyStoragePartSet; -begin -if assigned( FCryptoKeys) and assigned( FSigningKeys) then - result := FCryptoKeys.HasParts * FSigningKeys.HasParts - else - result := [] -end; - -function TSignatory.Sign( Document, Signature: TStream): boolean; -var - Engine: IASymetric_Engine; - wasAborted: boolean; -begin -wasAborted := False; -Engine := FCodec.Asymetric_Engine; -FCodec.EstimatedWorkLoad := Document.Size; -Engine.Sign( Document, Signature, - FSigningKeys.FPrivatePart, self, - FCodec.OnProgress, wasAborted); -FCodec.isUserAborted := wasAborted; -result := not wasAborted -end; - - -function TSignatory.Verify( Document, Signature: TStream): TVerifyResult; -var - Engine: IASymetric_Engine; - wasAborted, Ok: boolean; -begin -wasAborted := False; -Engine := FCodec.Asymetric_Engine; -FCodec.EstimatedWorkLoad := Document.Size; -Ok := Engine.VerifySignature( Document, Signature, - FSigningKeys.FPublicPart, self, - FCodec.OnProgress, wasAborted); -FCodec.isUserAborted := wasAborted; -if wasAborted then - result := vUserAbort - else if Ok then - result := vPass - else - result := vFail -end; - - - -procedure TSignatory.StoreKeysToStream( - Store: TStream; Parts: TKeyStoragePartSet); -begin -if assigned( FCryptoKeys) then - FCryptoKeys.StoreToStream( Store, Parts); -if assigned( FSigningKeys) then -FSigningKeys.StoreToStream( Store, Parts); -end; - - - -procedure TSignatory.LoadKeysFromStream( - Store: TStream; Parts: TKeyStoragePartSet); -var - Engine: IASymetric_Engine; -begin -Engine := FCodec.Asymetric_Engine; -if assigned( FCryptoKeys) then - FCryptoKeys.LoadFromStream( Store, Parts) - - else if assigned( Engine) then - FCryptoKeys := Engine.CreateFromStream( Store, Parts); - -if assigned( FSigningKeys) then - FSigningKeys.LoadFromStream( Store, Parts) - - else if assigned( Engine) then - FSigningKeys := Engine.CreateFromStream( Store, Parts); - -if assigned( FCryptoKeys) and assigned( FCodec) then - FCodec.InitFromKey( FCryptoKeys.Clone) -end; - - - -function TSignatory.Can_SaveKeys( Parts: TKeyStoragePartSet): boolean; -begin -result := assigned( FSigningKeys) and assigned( FCryptoKeys) and - FCryptoKeys .Can_StoreToStream( Parts) and - FSigningKeys.Can_StoreToStream( Parts) -end; - - - -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.Signatory; +interface +uses Classes, TPLB3.BaseNonVisualComponent, TPLB3.Codec, TPLB3.Asymetric; + +type +TGenerateKeysPhase = (gkNeutral, gkGenSigningKeys, gkGenCryptoKeys, gkDone); +TVerifyResult = (vPass, vFail, vUserAbort); + + +TSignatory = class( TTPLb_BaseNonVisualComponent) + private + FCodec: TCodec; + + procedure SetCodec( Value: TCodec); + + protected + procedure Notification( + AComponent: TComponent; Operation: TOperation); override; + + public + FGenPhase: TGenerateKeysPhase; + FCryptoKeys : TAsymetricKeyPair; + FSigningKeys: TAsymetricKeyPair; + + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + function Sign( Document, Signature: TStream): boolean; + function Verify( Document, Signature: TStream): TVerifyResult; + + function GenerateKeys: boolean; + procedure StoreKeysToStream( Store: TStream; Parts: TKeyStoragePartSet); + procedure LoadKeysFromStream( Store: TStream; Parts: TKeyStoragePartSet); + function Can_SaveKeys( Parts: TKeyStoragePartSet): boolean; + function HasParts: TKeyStoragePartSet; + + procedure Burn; + + published + property Codec: TCodec read FCodec write SetCodec; + end; + +implementation + + + + + + + + + + +uses SysUtils; +{ TSignatory } + +procedure TSignatory.Notification( + AComponent: TComponent; Operation: TOperation); +begin +inherited; +if (Operation = opRemove) and (AComponent = FCodec) then + SetCodec( nil) +end; + + + +procedure TSignatory.SetCodec( Value: TCodec); +begin +if FCodec = Value then exit; +if assigned( FCodec) then + FCodec.RemoveFreeNotification( self); +FCodec := Value; +if assigned( FCodec) then + FCodec.FreeNotification( self) +end; + + + + + + +constructor TSignatory.Create( AOwner: TComponent); +begin +FGenPhase := gkNeutral; +inherited +end; + + +destructor TSignatory.Destroy; +begin +Burn; +SetCodec( nil); +inherited +end; + + +procedure TSignatory.Burn; +begin +if assigned( FSigningKeys) then + FSigningKeys.Burn; +if assigned( FCryptoKeys) then + FCryptoKeys.Burn; +FreeAndNil( FSigningKeys); FreeAndNil( FCryptoKeys) +end; + + +function TSignatory.GenerateKeys: boolean; +begin +FGenPhase := gkGenSigningKeys; +FreeAndNil( FSigningKeys); FreeAndNil( FCryptoKeys); +FCodec.InitFromGeneratedAsymetricKeyPair; +result := not FCodec.isUserAborted; +if not result then exit; +FSigningKeys := (FCodec.Key as TAsymetricKeyPair).Clone; +FGenPhase := gkGenCryptoKeys; +FCodec.InitFromGeneratedAsymetricKeyPair; +result := not FCodec.isUserAborted; +if not result then exit; +FCryptoKeys := (FCodec.Key as TAsymetricKeyPair).Clone; +FGenPhase := gkDone +end; + + +function TSignatory.HasParts: TKeyStoragePartSet; +begin +if assigned( FCryptoKeys) and assigned( FSigningKeys) then + result := FCryptoKeys.HasParts * FSigningKeys.HasParts + else + result := [] +end; + +function TSignatory.Sign( Document, Signature: TStream): boolean; +var + Engine: IASymetric_Engine; + wasAborted: boolean; +begin +wasAborted := False; +Engine := FCodec.Asymetric_Engine; +FCodec.EstimatedWorkLoad := Document.Size; +Engine.Sign( Document, Signature, + FSigningKeys.FPrivatePart, self, + FCodec.OnProgress, wasAborted); +FCodec.isUserAborted := wasAborted; +result := not wasAborted +end; + + +function TSignatory.Verify( Document, Signature: TStream): TVerifyResult; +var + Engine: IASymetric_Engine; + wasAborted, Ok: boolean; +begin +wasAborted := False; +Engine := FCodec.Asymetric_Engine; +FCodec.EstimatedWorkLoad := Document.Size; +Ok := Engine.VerifySignature( Document, Signature, + FSigningKeys.FPublicPart, self, + FCodec.OnProgress, wasAborted); +FCodec.isUserAborted := wasAborted; +if wasAborted then + result := vUserAbort + else if Ok then + result := vPass + else + result := vFail +end; + + + +procedure TSignatory.StoreKeysToStream( + Store: TStream; Parts: TKeyStoragePartSet); +begin +if assigned( FCryptoKeys) then + FCryptoKeys.StoreToStream( Store, Parts); +if assigned( FSigningKeys) then +FSigningKeys.StoreToStream( Store, Parts); +end; + + + +procedure TSignatory.LoadKeysFromStream( + Store: TStream; Parts: TKeyStoragePartSet); +var + Engine: IASymetric_Engine; +begin +Engine := FCodec.Asymetric_Engine; +if assigned( FCryptoKeys) then + FCryptoKeys.LoadFromStream( Store, Parts) + + else if assigned( Engine) then + FCryptoKeys := Engine.CreateFromStream( Store, Parts); + +if assigned( FSigningKeys) then + FSigningKeys.LoadFromStream( Store, Parts) + + else if assigned( Engine) then + FSigningKeys := Engine.CreateFromStream( Store, Parts); + +if assigned( FCryptoKeys) and assigned( FCodec) then + FCodec.InitFromKey( FCryptoKeys.Clone) +end; + + + +function TSignatory.Can_SaveKeys( Parts: TKeyStoragePartSet): boolean; +begin +result := assigned( FSigningKeys) and assigned( FCryptoKeys) and + FCryptoKeys .Can_StoreToStream( Parts) and + FSigningKeys.Can_StoreToStream( Parts) +end; + + + +end. diff --git a/run/TPLB3.SimpleBlockCipher.pas b/LockBox3/run/TPLB3.SimpleBlockCipher.pas similarity index 95% rename from run/TPLB3.SimpleBlockCipher.pas rename to LockBox3/run/TPLB3.SimpleBlockCipher.pas index d044fc2..5025e98 100644 --- a/run/TPLB3.SimpleBlockCipher.pas +++ b/LockBox3/run/TPLB3.SimpleBlockCipher.pas @@ -1,275 +1,275 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.SimpleBlockCipher; -interface -uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, TPLB3.Compatibility; - -type -TSimpleBlockCipherKey = class; - -TSimpleBlockCipher = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; - function KeySize: integer; - function SeedByteSize: integer; - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - - protected - function Encrypt( - const Buffer: TBytes; - Key: TSimpleBlockCipherKey; - doEncrypt: boolean): TBytes; virtual; abstract; - - public - FProgId: string; - FDisplayName: string; - FFeatures: TAlgorithmicFeatureSet; - FBlockSizeInBytes: integer; - - constructor Create( - const ProgId1: string; - const DisplayName1: string; - Features1: TAlgorithmicFeatureSet; - BlockSizeInBytes1: integer); - end; -TSimpleBlockCipherClass = class of TSimpleBlockCipher; - - -TSimpleBlockCipherKey = class( TSymetricKey) - public - FKeyData: TBytes; - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - -TSimpleBlockCipherCodec = class( TInterfacedObject, IBlockCodec) - protected - FKey: TSimpleBlockCipherKey; - FBuffer: TBytes; - FCipher: TSimpleBlockCipher; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - end; - - -implementation - - - - - - - - -{ TSimpleBlockCipher } - -function TSimpleBlockCipher.BlockSize: integer; -begin -result := FBlockSizeInBytes * 8 -end; - - - -constructor TSimpleBlockCipher.Create( - const ProgId1, DisplayName1: string; - Features1: TAlgorithmicFeatureSet; BlockSizeInBytes1: integer); -begin -FProgId := ProgId1; -FDisplayName := DisplayName1; -FFeatures := Features1; -FBlockSizeInBytes := BlockSizeInBytes1 -end; - - - -function TSimpleBlockCipher.DefinitionURL: string; -begin -result := '' -end; - -function TSimpleBlockCipher.DisplayName: string; -begin -result := FDisplayName -end; - - -function TSimpleBlockCipher.Features: TAlgorithmicFeatureSet; -begin -result := FFeatures -end; - - -function TSimpleBlockCipher.GenerateKey( Seed: TStream): TSymetricKey; -var - Res: TSimpleBlockCipherKey; -begin -Res := TSimpleBlockCipherKey.Create; -SetLength( Res.FKeyData, FBlockSizeInBytes); -result := Res; -Seed.Read( Res.FKeyData[0], SizeOf( Res.FKeyData)) -end; - - -function TSimpleBlockCipher.KeySize: integer; -begin -result := FBlockSizeInBytes * 8 -end; - - -function TSimpleBlockCipher.LoadKeyFromStream( Store: TStream): TSymetricKey; -var - Res: TSimpleBlockCipherKey; -begin -Res := TSimpleBlockCipherKey.Create; -result := Res; -Store.Read( Res.FKeyData[0], SizeOf( Res.FKeyData)) -end; - - -function TSimpleBlockCipher.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -var - Res: TSimpleBlockCipherCodec; - j: integer; -begin -Res := TSimpleBlockCipherCodec.Create; -result := Res; -Res.FKey := Key as TSimpleBlockCipherKey; -SetLength( Res.FBuffer, FBlockSizeInBytes); -for j := 0 to Length( Res.FBuffer) - 1 do - Res.FBuffer[ j] := 0; -Res.FCipher := self -end; - - - -function TSimpleBlockCipher.ProgId: string; -begin -result := FProgId -end; - - - -function TSimpleBlockCipher.SeedByteSize: integer; -begin -result := FBlockSizeInBytes -end; - - -function TSimpleBlockCipher.SelfTest_Ciphertext: string; -begin -result := '' -end; - -function TSimpleBlockCipher.SelfTest_Key: string; -begin -result := '' -end; - -function TSimpleBlockCipher.SelfTest_Plaintext: string; -begin -result := '' -end; - -function TSimpleBlockCipher.WikipediaReference: string; -begin -result := '' -end; - -{ TSimpleBlockCipherCodec } - -procedure TSimpleBlockCipherCodec.Burn; -var - j: integer; -begin -for j := 0 to Length( FBuffer) - 1 do - FBuffer[ j] := 0 -end; - - - -procedure TSimpleBlockCipherCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -Ciphertext.Position := 0; -Plaintext.Position := 0; -Ciphertext.Read( FBuffer[0], Length( FBuffer)); -FBuffer := FCipher.Encrypt( FBuffer, FKey, False); -Plaintext.Write( FBuffer[0], Length( FBuffer)) -end; - - - -procedure TSimpleBlockCipherCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -Plaintext.Position := 0; -Ciphertext.Position := 0; -Plaintext.Read( FBuffer[0], Length( FBuffer)); -FBuffer := FCipher.Encrypt( FBuffer, FKey, True); -Ciphertext.Write( FBuffer[0], Length( FBuffer)) -end; - -procedure TSimpleBlockCipherCodec.Reset; -begin -end; - -{ TDemoSymetricKey } - -procedure TSimpleBlockCipherKey.Burn; -var - j: integer; -begin -for j := 0 to Length( FKeyData) - 1 do - FKeyData[ j] := 0 -end; - - -procedure TSimpleBlockCipherKey.SaveToStream( Stream: TStream); -begin -Stream.Write( FKeyData[0], Length( FKeyData)) -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.SimpleBlockCipher; +interface +uses Classes, SysUtils, TPLB3.StreamCipher, TPLB3.BlockCipher, TPLB3.Compatibility; + +type +TSimpleBlockCipherKey = class; + +TSimpleBlockCipher = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; + function KeySize: integer; + function SeedByteSize: integer; + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + + protected + function Encrypt( + const Buffer: TBytes; + Key: TSimpleBlockCipherKey; + doEncrypt: boolean): TBytes; virtual; abstract; + + public + FProgId: string; + FDisplayName: string; + FFeatures: TAlgorithmicFeatureSet; + FBlockSizeInBytes: integer; + + constructor Create( + const ProgId1: string; + const DisplayName1: string; + Features1: TAlgorithmicFeatureSet; + BlockSizeInBytes1: integer); + end; +TSimpleBlockCipherClass = class of TSimpleBlockCipher; + + +TSimpleBlockCipherKey = class( TSymetricKey) + public + FKeyData: TBytes; + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + +TSimpleBlockCipherCodec = class( TInterfacedObject, IBlockCodec) + protected + FKey: TSimpleBlockCipherKey; + FBuffer: TBytes; + FCipher: TSimpleBlockCipher; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + end; + + +implementation + + + + + + + + +{ TSimpleBlockCipher } + +function TSimpleBlockCipher.BlockSize: integer; +begin +result := FBlockSizeInBytes * 8 +end; + + + +constructor TSimpleBlockCipher.Create( + const ProgId1, DisplayName1: string; + Features1: TAlgorithmicFeatureSet; BlockSizeInBytes1: integer); +begin +FProgId := ProgId1; +FDisplayName := DisplayName1; +FFeatures := Features1; +FBlockSizeInBytes := BlockSizeInBytes1 +end; + + + +function TSimpleBlockCipher.DefinitionURL: string; +begin +result := '' +end; + +function TSimpleBlockCipher.DisplayName: string; +begin +result := FDisplayName +end; + + +function TSimpleBlockCipher.Features: TAlgorithmicFeatureSet; +begin +result := FFeatures +end; + + +function TSimpleBlockCipher.GenerateKey( Seed: TStream): TSymetricKey; +var + Res: TSimpleBlockCipherKey; +begin +Res := TSimpleBlockCipherKey.Create; +SetLength( Res.FKeyData, FBlockSizeInBytes); +result := Res; +Seed.Read( Res.FKeyData[0], SizeOf( Res.FKeyData)) +end; + + +function TSimpleBlockCipher.KeySize: integer; +begin +result := FBlockSizeInBytes * 8 +end; + + +function TSimpleBlockCipher.LoadKeyFromStream( Store: TStream): TSymetricKey; +var + Res: TSimpleBlockCipherKey; +begin +Res := TSimpleBlockCipherKey.Create; +result := Res; +Store.Read( Res.FKeyData[0], SizeOf( Res.FKeyData)) +end; + + +function TSimpleBlockCipher.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +var + Res: TSimpleBlockCipherCodec; + j: integer; +begin +Res := TSimpleBlockCipherCodec.Create; +result := Res; +Res.FKey := Key as TSimpleBlockCipherKey; +SetLength( Res.FBuffer, FBlockSizeInBytes); +for j := 0 to Length( Res.FBuffer) - 1 do + Res.FBuffer[ j] := 0; +Res.FCipher := self +end; + + + +function TSimpleBlockCipher.ProgId: string; +begin +result := FProgId +end; + + + +function TSimpleBlockCipher.SeedByteSize: integer; +begin +result := FBlockSizeInBytes +end; + + +function TSimpleBlockCipher.SelfTest_Ciphertext: string; +begin +result := '' +end; + +function TSimpleBlockCipher.SelfTest_Key: string; +begin +result := '' +end; + +function TSimpleBlockCipher.SelfTest_Plaintext: string; +begin +result := '' +end; + +function TSimpleBlockCipher.WikipediaReference: string; +begin +result := '' +end; + +{ TSimpleBlockCipherCodec } + +procedure TSimpleBlockCipherCodec.Burn; +var + j: integer; +begin +for j := 0 to Length( FBuffer) - 1 do + FBuffer[ j] := 0 +end; + + + +procedure TSimpleBlockCipherCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +Ciphertext.Position := 0; +Plaintext.Position := 0; +Ciphertext.Read( FBuffer[0], Length( FBuffer)); +FBuffer := FCipher.Encrypt( FBuffer, FKey, False); +Plaintext.Write( FBuffer[0], Length( FBuffer)) +end; + + + +procedure TSimpleBlockCipherCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +Plaintext.Position := 0; +Ciphertext.Position := 0; +Plaintext.Read( FBuffer[0], Length( FBuffer)); +FBuffer := FCipher.Encrypt( FBuffer, FKey, True); +Ciphertext.Write( FBuffer[0], Length( FBuffer)) +end; + +procedure TSimpleBlockCipherCodec.Reset; +begin +end; + +{ TDemoSymetricKey } + +procedure TSimpleBlockCipherKey.Burn; +var + j: integer; +begin +for j := 0 to Length( FKeyData) - 1 do + FKeyData[ j] := 0 +end; + + +procedure TSimpleBlockCipherKey.SaveToStream( Stream: TStream); +begin +Stream.Write( FKeyData[0], Length( FKeyData)) +end; + +end. diff --git a/run/TPLB3.StreamCipher.pas b/LockBox3/run/TPLB3.StreamCipher.pas similarity index 97% rename from run/TPLB3.StreamCipher.pas rename to LockBox3/run/TPLB3.StreamCipher.pas index 051bc45..87a50cd 100644 --- a/run/TPLB3.StreamCipher.pas +++ b/LockBox3/run/TPLB3.StreamCipher.pas @@ -1,9 +1,9 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ @@ -12,165 +12,165 @@ the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.StreamCipher; -interface -uses Classes; -type - -TAlgorithmicFeature = ( // Flags which describe hashes, ciphers and chain modes. - afStar, // A preferred system. Displayed with a star next to the name in the designer. - afCryptographicallyWeak, // The system is not known to be cryptographically strong. - // This flag is mutually exclusive with afStar. Not applicable to compressors and converters. - afNotImplementedYet, // The algorithm has not yet been implemented, - // but it will be displayed as an option in the object inspector - // as an indication of future direction. - afForTestOnly, // For test purposes only. Do not use in a production system. - afForRunTimeOnly, // The selection will not be displayed as an option in the object inspector. - afEncumberedByPatent, // Indicates that deployment of a binary using this - // algorithm may be constrained or encumbered by a Patent. - afEncumberedByCopyRight, // Indicates that the deployment of the source code - // or a bundled library binary may be constrained or encumbered by Copyright issues, - // other than the copyright being a form of Open Source Software (OSS). - // This flag is mutually exclusive with afOpenSourceSoftware. - afOpenSourceSoftware, // Indicates that the source code for this algorithm - // is covered by an OSS license. This flag does not descript the algorithm itself. - afCommercial, // Indicates that the deployment of either the source code - // or the compiled binary is covered by a commercial licence. - // For this flag to be set, afEncumberedByCopyRight must also be set. - // Mutually exclusive with afOpenSourceSoftware. - afCompressor, // Only applies to Stream Ciphers. It means the intention - // of the cipher is to compress or to expand data. - afConverter, // Only applies to Stream Ciphers. It means the intention - // of the cipher convert from one format to another, without - // encryption nor the the main intention of compression. - afBlockAdapter, // Only applies to Stream Ciphers. It means that the - // stream cipher is an adapter for any applied block cipher. - afDisplayNameOnKeySize, // Normally if the display name includes %d - // this is replaced by the block size in bits. However if the block - // cipher has the afDisplayNameOnKeySize, it is instead replaced - // by the key size in bits. - afDoesNotNeedSalt, // Only applicable to IStreamCiphers which are true - // crytographic codecs, that is to say they do not have the - // afCompressor or afConverter feature. Normally, stream ciphers will - // be used by injecting a 64 bit salt of random data at the start - // of the plaintext stream. However, if the cipher has this feature - // (afDoesNotNeedSalt) it means it is already salting its own - // tranform, or it cannot benefit from salt. In this case, users of - // IStreamCipher, such as TCodec will not salt the plaintext. - afAsymetric // Uses Asymetric key generation - ); - -TAlgorithmicFeatureSet = set of TAlgorithmicFeature; - -ICryptoGraphicAlgorithm = interface - ['{0562074A-4D94-4721-BC4A-65E48372A7E7}'] - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - end; - - -TSymetricKey = class - public - procedure SaveToStream( Stream: TStream); virtual; abstract; - procedure Burn; virtual; abstract; - end; - - -IStreamEncryptor = interface - ['{4DC93CFC-AD4C-4D2D-9087-296CCC591995}'] - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - procedure Reset; - end; - -IStreamDecryptor = interface - ['{481C71F0-BBB2-4021-93F3-48A5C21F8184}'] - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - procedure Reset; - end; - -IStreamCipher = interface( ICryptoGraphicAlgorithm) - ['{E2F61BDB-42A3-4A9B-A02C-FA710B23F660}'] - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function Parameterize( const Params: IInterface): IStreamCipher; - - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; - - // StreamCiphers should also implement IisBase64Converter if they - // are base64 converters. - // StreamCiphers should also implement IStreamCipherEx2. - end; - -IStreamCipherEx2 = interface( IStreamCipher) - ['{6D9B5040-980C-42E4-9FD3-CB8926D26C0B}'] - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream; IV: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream; IV: TStream): IStreamDecryptor; - end; - -IisBase64Converter = interface - ['{63929D9C-9416-4352-BBF6-B2FBCF6C7E86}'] - // Optional interface for IStreamCipher - end; - -implementation - - - -{ -Empty (any mode) ==> empty. - -NoChaining modes (eg. ECB) -1. Pad: Add one byte $80 and then pad out with zeros. -2. Encrypt blocks without nonce. - -Other mode -1. Make a nonce. The size of the nonce is 128 bits (16 bytes). -The nonce is to be a random number. -2. If the block size is greater or equal to 128 bits, then -set the lower 128 bits of the IV to be equal to the nounce, -and the higher bits zero. -3. If the block size is less than 128 bits, then set the -IV to be the lower (block size) bits of the nounce. -4. Emit in the clear the part of the nonce used to make the IV. -5. If nonce was bigger than block size, prepend the plaintext -with the balance of the nonce, before encryption. - -If not a keystream (eg. CBC), and the prepended plaintext is less than -one block, then switch to OFB. - -If not a keystream, but prepended plaintext is greater or equal -to one block then apply ciphertext srealing. - -If keystream, then just clip the last partial ciphertext block. - - -Attributes: - - NoChaining - - isKeyStream -} -end. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.StreamCipher; +interface +uses Classes; +type + +TAlgorithmicFeature = ( // Flags which describe hashes, ciphers and chain modes. + afStar, // A preferred system. Displayed with a star next to the name in the designer. + afCryptographicallyWeak, // The system is not known to be cryptographically strong. + // This flag is mutually exclusive with afStar. Not applicable to compressors and converters. + afNotImplementedYet, // The algorithm has not yet been implemented, + // but it will be displayed as an option in the object inspector + // as an indication of future direction. + afForTestOnly, // For test purposes only. Do not use in a production system. + afForRunTimeOnly, // The selection will not be displayed as an option in the object inspector. + afEncumberedByPatent, // Indicates that deployment of a binary using this + // algorithm may be constrained or encumbered by a Patent. + afEncumberedByCopyRight, // Indicates that the deployment of the source code + // or a bundled library binary may be constrained or encumbered by Copyright issues, + // other than the copyright being a form of Open Source Software (OSS). + // This flag is mutually exclusive with afOpenSourceSoftware. + afOpenSourceSoftware, // Indicates that the source code for this algorithm + // is covered by an OSS license. This flag does not descript the algorithm itself. + afCommercial, // Indicates that the deployment of either the source code + // or the compiled binary is covered by a commercial licence. + // For this flag to be set, afEncumberedByCopyRight must also be set. + // Mutually exclusive with afOpenSourceSoftware. + afCompressor, // Only applies to Stream Ciphers. It means the intention + // of the cipher is to compress or to expand data. + afConverter, // Only applies to Stream Ciphers. It means the intention + // of the cipher convert from one format to another, without + // encryption nor the the main intention of compression. + afBlockAdapter, // Only applies to Stream Ciphers. It means that the + // stream cipher is an adapter for any applied block cipher. + afDisplayNameOnKeySize, // Normally if the display name includes %d + // this is replaced by the block size in bits. However if the block + // cipher has the afDisplayNameOnKeySize, it is instead replaced + // by the key size in bits. + afDoesNotNeedSalt, // Only applicable to IStreamCiphers which are true + // crytographic codecs, that is to say they do not have the + // afCompressor or afConverter feature. Normally, stream ciphers will + // be used by injecting a 64 bit salt of random data at the start + // of the plaintext stream. However, if the cipher has this feature + // (afDoesNotNeedSalt) it means it is already salting its own + // tranform, or it cannot benefit from salt. In this case, users of + // IStreamCipher, such as TCodec will not salt the plaintext. + afAsymetric // Uses Asymetric key generation + ); + +TAlgorithmicFeatureSet = set of TAlgorithmicFeature; + +ICryptoGraphicAlgorithm = interface + ['{0562074A-4D94-4721-BC4A-65E48372A7E7}'] + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + end; + + +TSymetricKey = class + public + procedure SaveToStream( Stream: TStream); virtual; abstract; + procedure Burn; virtual; abstract; + end; + + +IStreamEncryptor = interface + ['{4DC93CFC-AD4C-4D2D-9087-296CCC591995}'] + procedure Encrypt( const Plaintext: TStream); + procedure End_Encrypt; + procedure Reset; + end; + +IStreamDecryptor = interface + ['{481C71F0-BBB2-4021-93F3-48A5C21F8184}'] + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + procedure Reset; + end; + +IStreamCipher = interface( ICryptoGraphicAlgorithm) + ['{E2F61BDB-42A3-4A9B-A02C-FA710B23F660}'] + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function Parameterize( const Params: IInterface): IStreamCipher; + + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; + + // StreamCiphers should also implement IisBase64Converter if they + // are base64 converters. + // StreamCiphers should also implement IStreamCipherEx2. + end; + +IStreamCipherEx2 = interface( IStreamCipher) + ['{6D9B5040-980C-42E4-9FD3-CB8926D26C0B}'] + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream; IV: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream; IV: TStream): IStreamDecryptor; + end; + +IisBase64Converter = interface + ['{63929D9C-9416-4352-BBF6-B2FBCF6C7E86}'] + // Optional interface for IStreamCipher + end; + +implementation + + + +{ +Empty (any mode) ==> empty. + +NoChaining modes (eg. ECB) +1. Pad: Add one byte $80 and then pad out with zeros. +2. Encrypt blocks without nonce. + +Other mode +1. Make a nonce. The size of the nonce is 128 bits (16 bytes). +The nonce is to be a random number. +2. If the block size is greater or equal to 128 bits, then +set the lower 128 bits of the IV to be equal to the nounce, +and the higher bits zero. +3. If the block size is less than 128 bits, then set the +IV to be the lower (block size) bits of the nounce. +4. Emit in the clear the part of the nonce used to make the IV. +5. If nonce was bigger than block size, prepend the plaintext +with the balance of the nonce, before encryption. + +If not a keystream (eg. CBC), and the prepended plaintext is less than +one block, then switch to OFB. + +If not a keystream, but prepended plaintext is greater or equal +to one block then apply ciphertext srealing. + +If keystream, then just clip the last partial ciphertext block. + + +Attributes: + - NoChaining + - isKeyStream +} +end. diff --git a/run/TPLB3.StreamToBlock.pas b/LockBox3/run/TPLB3.StreamToBlock.pas similarity index 81% rename from run/TPLB3.StreamToBlock.pas rename to LockBox3/run/TPLB3.StreamToBlock.pas index 3135679..de1ddd0 100644 --- a/run/TPLB3.StreamToBlock.pas +++ b/LockBox3/run/TPLB3.StreamToBlock.pas @@ -1,1913 +1,1787 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.StreamToBlock; -interface -uses TPLB3.StreamCipher, TPLB3.BlockCipher, Classes, TPLB3.Decorators; - -type - -TStreamToBlock_Adapter = class( TInterfacedObject, - IStreamCipher, ICryptoGraphicAlgorithm, IControlObject, - IStreamCipherEx2) - private - FBlockCipher: IBlockCipher; - FChaining: IBlockChainingModel; - FAdvancedOptions: TSymetricEncryptionOptionSet; - FOnSetIV: TSetMemStreamProc; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; overload; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; overload; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream; IV: TStream): IStreamEncryptor; overload; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream; IV: TStream): IStreamDecryptor; overload; - - // IControlObject = interface - function ControlObject: TObject; - - public - constructor Create; - end; - - -function StreamToBlock_Adapter_CSharpVariant: IStreamCipher; -// CSharp variant: -// 1. Only decrypt is implemented. -// 2. Not automatically registered with the library. You have to explicitly register. -// 3. Full IV is prepended in the ciphertext stream. -// 4. Straight zero padding. - -implementation - - - - - - - - - - - - - -uses SysUtils, Math, TPLB3.StreamUtils, TPLB3.CFB_Block, TPLB3.Constants, - TPLB3.CFB_8Bit, TPLB3.PointerArithmetic, TPLB3.I18n; - - -{ HOW THE STREAM TO BLOCK ADAPTER WORKS (Encryption direction) - ================================================================= - -We have a plaintext message (msg), which we which to encrypt and transmit -over an insecure channel using a block mode cipher. - - Let the length of the plaintext message in bits be m. - Len( msg) = m - m >= 0 - - Let the block size in bits be B. - B >= 2 - - Because of our fileing system constraints, we must have - m mod 8 = 0 - B mod 8 = 0 - B >= 16 (B=8 would make block-mode pointless). - -CASE ONE: The Trivial Case. ---------------------------- -In this case the message is empty, that is to say m = 0. -we handle this with an empty emission. This is so, regardless of the -chaining mode and its features. - -In all other cases ... ----------------------- -In all other cases that follow, in general we will emit the following -data in the said order. - 1. The IV Seed. This is emitted in the clear. This will not always be present. - 2. The encryption of the following stream: - 2.1 A prefix. This will not always be present. - 2.2 The payload message, msg - 2.3 Padding at the end. Whether this is present or not, depends on the mode. - The last ciphertext block of (2.) may be truncated according to mode. - -Let the length of the IV seed in bits be s. -Let the length of the prefix in bits be pre. -Let the length of the end padding be pd. -Let the length of the input to to codec, before padding, be x. - x = pre + m - -Let N be the number of blocks. - N = roof( x / B) = (x + B - 1) div B - -Let xl be the length of the last ciphertext block, before padding. - if (x mod B) = 0 ==> xl = B - if (x mod B) <> 0 ==> xl = x mod B - 8 <= xl <= B - -Necessarily, we have ... - pd = (B - xl) + (k * B) - where k is some non-negative integer, which is going to depend on - our mode and padding scheme. - -How we proceed next, depends on the chaining features. -Here is the definition again. - -IBlockCipher.ChainingFeatures: TChainingFeature = ( - cfNoNounce, // The chaining mode does not require any nounce nor - // does it require an IV. Ex: ECB - cfKeyStream, // A key-stream is at the heart of the chaining mode - // The final partial block can be padded arbitarily, - // encrypted as usual, and then truncated to the same - // length as the corresponding plaintext input. - // Examples: CFB, 8-bit CFB, OFB and CTR. - // Counter-examples: ECB and CBC - cf8bit); // Plaintext and cipher text are processed one byte at a time. - // Example: 8-bit CFB. - -CASE TWO: cfNoNounce and cfKeyStream ------------------------------------- -There are no stock modes which are an example of this. I don't expect -that there will even be any custom modes worth their salt (pun intended), -which has this combination of features. Never-the-less, this algorithm -deals with this case, just in case a custom cipher is so. - -1. There is no IV seed. - s = 0 -2. There is no prefix. - pre = 0 -3. The IV is set to all zeros. -4. If the plaintext is not congruent to the block size (xl < B), then - pad out the last plaintext block with zeros. We will call this - type of padding, "short zero extend". - pd = B - xl -5. Encrypt the blocks in order -6. Truncate the last ciphertext block to xl. -7. Emit the ciphertext blocks. - -CASE THREE: cfNoNounce and NOT cfKeyStream -------------------------------------------- -An example of such a mode is ECB. -1. There is no IV seed. - s = 0 -2. There is no prefix. - pre = 0 -3. The IV is set to all zeros. -4. Pad out the last block like this .. - 4.1. Append a single '1' bit. ($80 in a byte) - 4.2. Append as many zeros as required to make the final block full. - We will call this type of padding "Simple dimple". - xl < B ==> pd = B - xl - xl = B ==> pd = B -5. Encrypt the blocks in order -6. Do NOT truncate the last ciphertext block. -7. Emit the ciphertext blocks. - -Otherwise ... ----------- -1. Generate a 64 bit nonce from a random number generator. -2.1 If B >= 64, set the lower 64 bits of the IV to be the nonce, - and the remaining bits zero. The IV seed is the nonce, and - there is no prefix. - s = 64 - pre = 0 -2.2 If B < 64, we need to compensate for the weakness of the chaining mode - against the repeat-message attack, by salting or pre-seeding the - input plaintext proportionally. Set the IV to be the lower B bits - of the nounce. The IV seed is the IV. The prefix is the remaining - bits of the nonce. - s = B - pre = 64 - B - -In either case: s + pre = 64 - -In what follows, use the following terminology. - If x < B then describe the message as a 'short message'. - If (x mod B) = 0 then describe the message as a 'round message'. - If (x > B) and ((x mod B) > 0) then describe the message as a 'sharp message'. - -CASE FOUR: NOT cfNoNounce and NOT cfKeyStream and short message ----------------------------------------------------------------- -CBC mode has NOT cfNoNounce and NOT cfKeyStream. -In this case, act as if the mode was CFB, which has feature set [cfKeyStream], - that is to say CFB has NOT cfNoNounce and cfKeyStream. -Refer to case 7 (NOT cfNoNounce, cfKeyStream) - -CASE FIVE: NOT cfNoNounce and round message --------------------------------------------- -1. No padding is required. - xl = B -2. Encrypt the blocks in order. -3. There is no truncation of the last ciphertext block. -4. Emit the ciphertext blocks in natural order. - -CASE SIX: NOT cfNoNounce and NOT cfKeyStream and sharp message ----------------------------------------------------------------- -1. Apply ciphertext stealing to the last two blocks. -2. The last two ciphertext blocks are emitted in reverse order. That is - to say, the second last cipherblock (which has length xl) is emitted - last, and the naturally last cipherblock (which has length B) is emitted - second last. - -CASE SEVEN: NOT cfNoNounce and cfKeyStream but not round message ----------------------------------------------------------------- -1. Our cipher effectively a stream-mode cipher. So short zero extend the - last block. -2. Encrypt the blocks in natural order. -3. Truncate the last block to xl. -4. Emit the blocks in natural order. - - - -} - - - - -type -TEncryptorDecryptor = class( TInterfacedObject) - protected - FChaining: IBlockChainingModel; - FEmitBuffer: TMemoryStream; - FBuffer: TMemoryStream; - FBlockLen: integer; - FCodec: IBlockCodec; - FBlockCipher: IBlockCipher; - FLenBuffer: integer; - FChainState: TBlockChainLink; - FIV: TMemoryStream; - FDataCount: int64; - FisAutoXOR: boolean; - Fis8bitMode: boolean; - FisEncrypting: boolean; - FEmissionStream: TStream; - - procedure Reset; virtual; - procedure Emit( SourceBuf: TMemoryStream; EmitLen: integer = -1); - // ^ Encrypt/Decrypt and then emit. - - procedure Emit_1stBuffer; - function ShortNonKeyStreamingChainMode: IBlockChainingModel; - procedure Chained_Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Chained_Decrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - - public - constructor Start_EncDec( - Key1: TSymetricKey; EmissionStream1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - isEncrypting1: boolean); - - destructor Destroy; override; - end; - - - - -TNoNonceEncryptor = class( TEncryptorDecryptor, IStreamEncryptor) - private - FCipherText: TStream; - FPad: TMemoryStream; - - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - - protected - procedure Reset; override; - - public - constructor Start_Encrypt( - Key1: TSymetricKey; CipherText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); - - destructor Destroy; override; - end; - - -TNoncibleEncryptor = class( TEncryptorDecryptor, IStreamEncryptor) - private - FKey: TSymetricKey; - FCipherText: TStream; - F2ndBuffer: TMemoryStream; - Fis2ndBufferFull: boolean; - FIVSeedLen: integer; - FSaltLen: integer; - FNonce: TMemoryStream; - FisShortMessage: boolean; - FisAddingSalt: boolean; - FOnSetIV: TSetMemStreamProc; - - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - - protected - procedure Reset; override; - - public - constructor Start_Encrypt( - Key1: TSymetricKey; CipherText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - OnSetIV1: TSetMemStreamProc); - - destructor Destroy; override; - end; - - -TOpenSSLCompatEncryptor = class( TEncryptorDecryptor, IStreamEncryptor) - private - FKey: TSymetricKey; - FCipherText: TStream; - - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - - protected - procedure Reset; override; - - public - constructor Start_Encrypt( - Key1: TSymetricKey; CipherText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); - - constructor Start_Encrypt_WithIV( - Key1: TSymetricKey; CipherText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - IV1: TStream); - - destructor Destroy; override; - end; - -TNoncibleDecryptor = class( TEncryptorDecryptor, IStreamDecryptor) - private - FKey: TSymetricKey; - FPlainText: TStream; - F2ndBuffer: TMemoryStream; - Fis2ndBufferFull: boolean; - FSaltAbsorber: TDesalinationWriteStream; - FDataCount: int64; - FIVSeedLen: integer; - FSaltLen: integer; - FisShortMessage: boolean; - FOnSetIV: TSetMemStreamProc; - - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - - protected - procedure Reset; override; - - public - constructor Start_Decrypt( - Key1: TSymetricKey; PlainText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - OnSetIV1: TSetMemStreamProc); - - destructor Destroy; override; - end; - -TOpenSSLCompatDecryptor = class( TEncryptorDecryptor, IStreamDecryptor) - private - //Fis2ndBufferFull: boolean; - //FSaltAbsorber: TDesalinationWriteStream; - //FDataCount: int64; - //FIVSeedLen: integer; - //FSaltLen: integer; - //FisShortMessage: boolean; - - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - - protected - procedure Reset; override; - - public - constructor Start_Decrypt( - Key1: TSymetricKey; PlainText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); - - constructor Start_Decrypt_WithIV( - Key1: TSymetricKey; PlainText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - IV1: TStream); - - destructor Destroy; override; - end; - - -TNoNonceDecryptor = class( TEncryptorDecryptor, IStreamDecryptor) - private - FPlaintext: TStream; - FisSecondBufferFull: boolean; - F2ndBuffer: TMemoryStream; - - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - - protected - procedure Reset; override; - - public - constructor Start_Decrypt( - Key1: TSymetricKey; PlainText1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); - - destructor Destroy; override; - end; - - - - - -{ TStreamToBlock_Adapter } - -function TStreamToBlock_Adapter.ControlObject: TObject; -var - ControlObject: IControlObject; -begin -if Supports( FBlockCipher, IControlObject, ControlObject) then - result := ControlObject.ControlObject - else - result := self -end; - - -constructor TStreamToBlock_Adapter.Create; -begin -FAdvancedOptions := [] -end; - -function TStreamToBlock_Adapter.DefinitionURL: string; -begin -result := '' -end; - - - -function TStreamToBlock_Adapter.DisplayName: string; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.DisplayName - else - result := BlockCipher_DisplayName -end; - - - -function TStreamToBlock_Adapter.Features: TAlgorithmicFeatureSet; -begin -result := [afStar, afOpenSourceSoftware, afBlockAdapter, afDoesNotNeedSalt] -end; - - -function TStreamToBlock_Adapter.GenerateKey( Seed: TStream): TSymetricKey; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.GenerateKey( Seed) - else - result := nil -end; - - -function TStreamToBlock_Adapter.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -if assigned( FBlockCipher) and assigned( Store) then - result := FBlockCipher.LoadKeyFromStream( Store) - else - result := nil -end; - - -function TStreamToBlock_Adapter.Parameterize( - const Params: IInterface): IStreamCipher; -var - BlockCipherSelector: IBlockCipherSelector; - BlockCipherSelectorEx2: IBlockCipherSelectorEx2; - BlockCipher: IBlockCipher; - Chaining: IBlockChainingModel; - Newbie: TStreamToBlock_Adapter; -begin -result := nil; -if assigned( FBlockCipher) and assigned( FChaining) then exit; -FAdvancedOptions := []; -if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then - begin - BlockCipher := BlockCipherSelector.GetBlockCipher; - Chaining := BlockCipherSelector.GetChainMode; - if Supports( BlockCipherSelector, IBlockCipherSelectorEx2, BlockCipherSelectorEx2) then - FAdvancedOptions := BlockCipherSelectorEx2.GetAdvancedOptions2 - end; -if not (assigned( BlockCipher) or assigned( Chaining)) then exit; -Newbie := TStreamToBlock_Adapter.Create; -Newbie.FBlockCipher := BlockCipher; -Newbie.FChaining := Chaining; -result := Newbie; -if (not assigned( BlockCipherSelectorEx2)) or - (not BlockCipherSelectorEx2.hasOnSetIVHandler( Newbie.FOnSetIV)) then - Newbie.FOnSetIV := nil -end; - - - - -function TStreamToBlock_Adapter.ProgId: string; -begin -result := BlockCipher_ProgId -end; - - - -function TStreamToBlock_Adapter.SeedByteSize: integer; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.SeedByteSize - else - result := -1 -end; - - - -function TStreamToBlock_Adapter.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin -if optOpenSSL_CompatibilityMode in FAdvancedOptions then - begin - if not (cfNoNounce in FChaining.ChainingFeatures) then - raise Exception.Create( ES_OpenSSLCompat_RequiresIV); - result := TOpenSSLCompatDecryptor.Start_Decrypt( - Key, PlainText, FBlockCipher, FChaining) - end - - else if cfNoNounce in FChaining.ChainingFeatures then - result := TNoNonceDecryptor.Start_Decrypt( - Key, PlainText, FBlockCipher, FChaining) - else - result := TNoncibleDecryptor.Start_Decrypt( - Key, PlainText, FBlockCipher, FChaining, FOnSetIV) -end; - - - -function TStreamToBlock_Adapter.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -if optOpenSSL_CompatibilityMode in FAdvancedOptions then - // Valid only for ECB. Other chain modes for OpenSSL compatibility - // require an explicit user-supplied IV. - begin - if not (cfNoNounce in FChaining.ChainingFeatures) then - raise Exception.Create( ES_OpenSSLCompat_RequiresIV); - result := TOpenSSLCompatEncryptor.Start_Encrypt( - Key, CipherText, FBlockCipher, FChaining) - end - - else if cfNoNounce in FChaining.ChainingFeatures then - result := TNoNonceEncryptor.Start_Encrypt( - Key, CipherText, FBlockCipher, FChaining) - else - result := TNoncibleEncryptor.Start_Encrypt( - Key, CipherText, FBlockCipher, FChaining, FOnSetIV) -end; - - - -function TStreamToBlock_Adapter.Start_Decrypt( - Key: TSymetricKey; PlainText, IV: TStream): IStreamDecryptor; -var - sName: string; -begin -if optOpenSSL_CompatibilityMode in FAdvancedOptions then - result := TOpenSSLCompatDecryptor.Start_Decrypt_WithIV( - Key, PlainText, FBlockCipher, FChaining, IV) - else - begin - if assigned( FBlockCipher) then - sName := FBlockCipher.DisplayName - else - sName := '(no block cipher)'; - raise Exception.CreateFmt( ES_NoOpenSSLCompat, [sName]) - end; -end; - -function TStreamToBlock_Adapter.Start_Encrypt( - Key: TSymetricKey; CipherText, IV: TStream): IStreamEncryptor; -var - sName: string; -begin -if optOpenSSL_CompatibilityMode in FAdvancedOptions then - result := TOpenSSLCompatEncryptor.Start_Encrypt_WithIV( - Key, CipherText, FBlockCipher, FChaining, IV) - else - begin - if assigned( FBlockCipher) then - sName := FBlockCipher.DisplayName - else - sName := '(no block cipher)'; - raise Exception.CreateFmt( ES_NoOpenSSLCompat, [sName]) - end; -end; - - - -function TStreamToBlock_Adapter.WikipediaReference: string; -begin -result := '' -end; - - - - - -{ TNoNonceEncryptor } - -constructor TNoNonceEncryptor.Start_Encrypt( Key1: TSymetricKey; - CipherText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); -begin -inherited Start_EncDec( Key1, CipherText1, BlockCipher1, Chaining1, True); -FCipherText := CipherText1; -FIV.Size := FBlockLen; -ZeroFillStream( FIV); -FChainState := FChaining.Chain_EncryptBlock( Key1, FIV, FCodec); -if cfKeyStream in FChaining.ChainingFeatures then - FPad := nil - else - FPad := TMemoryStream.Create -end; - - - -procedure TNoNonceEncryptor.Encrypt( const Plaintext: TStream); -var - X: int64; - Amnt: integer; -begin -Plaintext.Position := 0; -X := Plaintext.Size; -while X > 0 do - begin - Amnt := FBlockLen - FLenBuffer; - if X < FBlockLen then - Amnt := Min( Amnt, X); - if Amnt > 0 then - begin - ReadMem( Plaintext, FBuffer, FLenBuffer, Amnt); - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if FLenBuffer = FBlockLen then - Emit_1stBuffer - end -end; - - -const PadIntroducer: byte = $80; - -procedure TNoNonceEncryptor.End_Encrypt; -begin -if (FDataCount <> 0) and (not (cfKeyStream in FChaining.ChainingFeatures)) then - begin - FPad.Size := FBlockLen - FLenBuffer; - ZeroFillStream( FPad); - PByte( FPad.Memory)^ := PadIntroducer; - Encrypt( FPad) - end; -if cfKeyStream in FChaining.ChainingFeatures then - Emit_1stBuffer; -Reset -end; - - - -procedure TNoNonceEncryptor.Reset; -begin -inherited Reset; -FChainState.Reset( FIV); -if not (cfKeyStream in FChaining.ChainingFeatures) then - BurnMemoryStream( FPad) -end; - - - -destructor TNoNonceEncryptor.Destroy; -begin -BurnMemoryStream( FPad); FPad.Free; -inherited -end; - - - -{ TNoncibleEncryptor } - -constructor TNoncibleEncryptor.Start_Encrypt( - Key1: TSymetricKey; - CipherText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; OnSetIV1: TSetMemStreamProc); -begin -inherited Start_EncDec( Key1, Ciphertext1, BlockCipher1, Chaining1, True); -FKey := Key1; -FCipherText := CipherText1; -FChainState := nil; -F2ndBuffer := TMemoryStream.Create; -F2ndBuffer.Size := FBlockLen; -Fis2ndBufferFull := False; -FIV.Size := FBlockLen; -FIVSeedLen := Min( FBlockLen, 8); -FSaltLen := 8 - FIVSeedLen; -FNonce := TMemoryStream.Create; -FIV.Size := FBlockLen; -FisShortMessage := True; -FisAddingSalt := False; -FOnSetIV := OnSetIV1 -end; - - - - -procedure TNoncibleEncryptor.Encrypt( const Plaintext: TStream); -var - X: int64; - Amnt: integer; - Tmp: TMemoryStream; -begin -Plaintext.Position := 0; -X := Plaintext.Size; -if (X > 0) and (FDataCount = 0) and (not FisAddingSalt) then - begin - // 1. Acquire Nonce. - FNonce.Size := 8; - RandomFillStream( FNonce); - - // 2. Determine the IV. - Move( FNonce.Memory^, FIV.Memory^, FIVSeedLen); - if FBlockLen > FIVSeedLen then - FillChar( MemStrmOffset( FIV, FIVSeedLen)^, - FBlockLen - FIVSeedLen, 0); - if assigned( FOnSetIV) then - FOnSetIV( FIV); - - // 3. Emit IV seed in the clear. - if FIVSeedLen > 0 then - FCiphertext.WriteBuffer( FIV.Memory^, FIVSeedLen); - - // 4. Pre-pend salt. - if FSaltLen > 0 then - begin - FisAddingSalt := True; - try - Move( MemStrmOffset( FNonce, FIVSeedLen)^, - FNonce.Memory^, FSaltLen); - FNonce.Size := FSaltLen; - Encrypt( FNonce) - finally - FisAddingSalt := False - end - end; - - BurnMemoryStream( FNonce) - end; -while (X > 0) or (FLenBuffer = FBlockLen) do - begin - Amnt := FBlockLen - FLenBuffer; - if Amnt > X then - Amnt := X; - if Amnt > 0 then - begin - Amnt := ReadMem( Plaintext, FBuffer, FLenBuffer, Amnt); - if Amnt = 0 then - X := 0 - else - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if FLenBuffer >= FBlockLen then - FisShortMessage := False; - if (FLenBuffer = FBlockLen) and (not Fis2ndBufferFull) then - begin - Tmp := F2ndBuffer; - F2ndBuffer := FBuffer; - FBuffer := Tmp; - Fis2ndBufferFull := True; - FLenBuffer := 0 - end; - if (FLenBuffer = FBlockLen) and Fis2ndBufferFull then - begin - if not assigned( FChainState) then - FChainState := FChaining.Chain_EncryptBlock( FKey, FIV, FCodec); - Emit( F2ndBuffer); - Fis2ndBufferFull := False - end - end -end; - - -procedure TNoncibleEncryptor.End_Encrypt; -var - Actual: IBlockChainingModel; - ChainStateClone: TBlockChainLink; -begin -if FDataCount = 0 then - begin end - - else - begin - if FisShortMessage and (not (cfKeyStream in FChaining.ChainingFeatures)) then - begin - Actual := ShortNonKeyStreamingChainMode; - Fis8bitMode := (cf8bit in Actual.ChainingFeatures) and - (cfKeyStream in Actual.ChainingFeatures) - end - else - Actual := FChaining; - FisAutoXOR := ([cfKeyStream, cfAutoXOR] * Actual.ChainingFeatures) = - [cfKeyStream, cfAutoXOR]; - if not assigned( FChainState) then - FChainState := Actual.Chain_EncryptBlock( FKey, FIV, FCodec); - - if FLenBuffer = 0 then - begin // Round case - Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling); - Emit( F2ndBuffer); - end - - else if cfKeyStream in Actual.ChainingFeatures then - begin // KeyStream case - if Fis2ndBufferFull then - Emit( F2ndBuffer); - Emit_1stBuffer - end - - else - begin // Ciphertext stealing - Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling); - ChainStateClone := FChainState.Clone; - try - Chained_Encrypt_Block( F2ndBuffer, FEmitBuffer); - Move( MemStrmOffset( FEmitBuffer, FLenBuffer)^, - MemStrmOffset( FBuffer, FLenBuffer)^, - FBlockLen - FLenBuffer); // << The steal! - FBuffer.Position := 0; - F2ndBuffer.Position := 0; - ChainStateClone.Encrypt_Block( FBuffer, F2ndBuffer); - FCiphertext.WriteBuffer( F2ndBuffer .Memory^, FBlockLen); // Swap emission order. - FCiphertext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) - finally - ChainStateClone.Burn; - ChainStateClone.Free - end - end - end; -Reset -end; - - - - - -procedure TNoncibleEncryptor.Reset; -begin -inherited Reset; -BurnMemory( F2ndBuffer .Memory^, FBlockLen); -FreeAndNil( FChainState); -Fis2ndBufferFull := False; -FisShortMessage := True; -BurnMemory( FIV.Memory^, FBlockLen); -BurnMemoryStream( FNonce) -end; - - - -destructor TNoncibleEncryptor.Destroy; -begin -BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); -BurnMemoryStream( FIV); -BurnMemoryStream( FNonce); FreeAndNil( FNonce); -FDataCount := 0; -inherited -end; - - - - -{ TNoNonceDecryptor } - -constructor TNoNonceDecryptor.Start_Decrypt( - Key1: TSymetricKey; PlainText1: TStream; - const BlockCipher1: IBlockCipher; const Chaining1: IBlockChainingModel); -begin -inherited Start_EncDec( Key1, Plaintext1, BlockCipher1, Chaining1, False); -FPlainText := PlainText1; -FIV.Size := FBlockLen; -ZeroFillStream( FIV); -FChainState := FChaining.Chain_DecryptBlock( Key1, FIV, FCodec); -FisSecondBufferFull := False; -F2ndBuffer := TMemoryStream.Create; -F2ndBuffer.Size := FBlockLen -end; - - -procedure TNoNonceDecryptor.Decrypt( const Ciphertext: TStream); -var - X: int64; - Amnt: integer; - Tmp: TMemoryStream; -begin -Ciphertext.Position := 0; -X := Ciphertext.Size; -while (X > 0) or ((FLenBuffer = FBlockLen) and (not FisSecondBufferFull)) do - begin - Amnt := FBlockLen - FLenBuffer; - if X < FBlockLen then - Amnt := Min( Amnt, X); - if Amnt > 0 then - begin - ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if (FLenBuffer = FBlockLen) and (not FisSecondBufferFull) then - begin - Tmp := F2ndBuffer; - F2ndBuffer := FBuffer; - FBuffer := Tmp; - FisSecondBufferFull := True; - FLenBuffer := 0 - end; - if FisSecondBufferFull and (FLenBuffer > 0) then - begin - Emit( F2ndBuffer); - FisSecondBufferFull := False - end - end -end; - -procedure TNoNonceDecryptor.End_Decrypt; -var - Sentinal: PByte; - j: integer; -begin -if FDataCount = 0 then - begin end - - else if cfKeyStream in FChaining.ChainingFeatures then - begin - if FisSecondBufferFull then - begin - Emit( F2ndBuffer); - FisSecondBufferFull := False - end; - Emit_1stBuffer - end - - else - begin - Assert( FisSecondBufferFull and (FLenBuffer = 0), - AS_BlockPaddingCorrupt); - Chained_Decrypt_Block( FEmitBuffer, F2ndBuffer); - FLenBuffer := 0; - Sentinal := PByte( MemStrmOffset( FEmitBuffer, FBlockLen - 1)); - for j := FBlockLen - 1 downto 0 do - begin - if Sentinal^ = PadIntroducer then - begin - FLenBuffer := j; - break - end; - Dec( Sentinal) - end; - if FLenBuffer > 0 then - FPlaintext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) - end; - -Reset -end; - - -procedure TNoNonceDecryptor.Reset; -begin -inherited Reset; -BurnMemory( F2ndBuffer .Memory^, FBlockLen); -FChainState.Reset( FIV); -FisSecondBufferFull := False -end; - - - -destructor TNoNonceDecryptor.Destroy; -begin -BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); -inherited -end; - - -{ TNoncibleDecryptor } - -function TEncryptorDecryptor.ShortNonKeyStreamingChainMode: IBlockChainingModel; -begin -result := TCFB_8Bit.Create -// TCFB_Block is also a reasonable replacement. -end; - - - -constructor TNoncibleDecryptor.Start_Decrypt( - Key1: TSymetricKey; - PlainText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; - OnSetIV1: TSetMemStreamProc); -begin -inherited Start_EncDec( Key1, Plaintext1, BlockCipher1, Chaining1, False); -FKey := Key1; - -FPlainText := PlainText1; -FLenBuffer := 0; - -F2ndBuffer := TMemoryStream.Create; -F2ndBuffer.Size := FBlockLen; -Fis2ndBufferFull := False; - -FOnSetIV := OnSetIV1; -FIV.Size := 0; - -FIVSeedLen := Min( FBlockLen, 8); -FSaltLen := 8 - FIVSeedLen; -if FSaltLen > 0 then - begin - FSaltAbsorber := TDesalinationWriteStream.Create; - FSaltAbsorber.FreshwaterStream := FEmissionStream; - FEmissionStream := FSaltAbsorber; - FSaltAbsorber.SaltVolume := FSaltLen - end - else - FSaltAbsorber := nil; - -FisShortMessage := True -end; - - -procedure TNoncibleDecryptor.Decrypt( const Ciphertext: TStream); -var - X: int64; - Amnt: integer; - Tmp: TMemoryStream; - OldSize: integer; -begin -Ciphertext.Position := 0; -X := Ciphertext.Size; -while (X > 0) or (FLenBuffer = FBlockLen) do - begin - - // 1. Read the IV. - if FIVSeedLen > 0 then - begin - Amnt := FIVSeedLen; - if X < Amnt then - Amnt := X; - FIV.CopyFrom( Ciphertext, Amnt); - Dec( X, Amnt); - Dec( FIVSeedLen, Amnt); - OldSize := FIV.Size; - if (FIVSeedLen = 0) and (OldSize < FBlockLen) then - begin - FIV.Size := FBlockLen; - FillChar( MemStrmOffset( FIV, OldSize)^, FBlockLen - OldSize, 0) - end; - if Assigned( FOnSetIV) then - FOnSetIV( FIV); - continue - end; - - // 2. Now process the payload - Amnt := FBlockLen - FLenBuffer; - if X < Amnt then - Amnt := X; - if Amnt > 0 then - begin - ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if FLenBuffer >= FBlockLen then - FisShortMessage := False; - if (FLenBuffer = FBlockLen) and (not Fis2ndBufferFull) then - begin - Tmp := F2ndBuffer; - F2ndBuffer := FBuffer; - FBuffer := Tmp; - Fis2ndBufferFull := True; - FLenBuffer := 0 - end; - if (FLenBuffer = FBlockLen) and Fis2ndBufferFull then - begin - if not assigned( FChainState) then - FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); - Emit( F2ndBuffer); - Fis2ndBufferFull := False - end - end -end; - - - -procedure TNoncibleDecryptor.End_Decrypt; -var - Actual: IBlockChainingModel; - ChainStateClone: TBlockChainLink; -begin -if FDataCount = 0 then - begin end - - else - begin - if FisShortMessage and (not (cfKeyStream in FChaining.ChainingFeatures)) then - begin - Actual := ShortNonKeyStreamingChainMode; - Fis8bitMode := (cf8bit in Actual.ChainingFeatures) and - (cfKeyStream in Actual.ChainingFeatures) - end - else - Actual := FChaining; - FisAutoXOR := ([cfKeyStream, cfAutoXOR] * Actual.ChainingFeatures) = - [cfKeyStream, cfAutoXOR]; - if not assigned( FChainState) then - FChainState := Actual.Chain_DecryptBlock( FKey, FIV, FCodec); - - if FLenBuffer = 0 then - begin // Round case - Assert( Fis2ndBufferFull, AS_BlockToStream_EndDecrypt_InternalMarshalling); - Emit( F2ndBuffer) - end - - else if cfKeyStream in Actual.ChainingFeatures then - begin // KeyStream case - if Fis2ndBufferFull then - Emit( F2ndBuffer); - Emit_1stBuffer - end - - else - begin // Ciphertext stealing - Assert( Fis2ndBufferFull, AS_BlockToStream_EndDecrypt_InternalMarshalling); - ChainStateClone := FChainState.Clone; - try - Chained_Decrypt_Block( FEmitBuffer, F2ndBuffer); - Move( MemStrmOffset( FEmitBuffer, FLenBuffer)^, - MemStrmOffset( FBuffer, FLenBuffer)^, - FBlockLen - FLenBuffer); // << Reverse the steal! - F2ndBuffer.Position := 0; - FBuffer.Position := 0; - ChainStateClone.Decrypt_Block( F2ndBuffer, FBuffer); - FPlaintext.WriteBuffer( F2ndBuffer .Memory^, FBlockLen); - FPlaintext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) - finally - ChainStateClone.Burn; - ChainStateClone.Free - end - end - end; -Reset -end; - - - -procedure TNoncibleDecryptor.Reset; -begin -inherited Reset; -BurnMemory( F2ndBuffer .Memory^, FBlockLen); -Fis2ndBufferFull := False; -FisShortMessage := True; -BurnMemoryStream( FIV); -if assigned( FChainState) then - begin - FChainState.Burn; - FChainState.Free; - FChainState := nil - end; -FIVSeedLen := Min( FBlockLen, 8); -FSaltLen := 8 - FIVSeedLen; -if FSaltLen > 0 then - FSaltAbsorber.SaltVolume := FSaltLen -end; - - - -destructor TNoncibleDecryptor.Destroy; -begin -BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); -FreeAndNil( FSaltAbsorber); -FDataCount := 0; -inherited -end; - - -{ TEncryptorDecryptor } - -constructor TEncryptorDecryptor.Start_EncDec( - Key1: TSymetricKey; EmissionStream1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; isEncrypting1: boolean); -begin -FEmissionStream := EmissionStream1; -FBlockCipher := BlockCipher1; -FChaining := Chaining1; -FEmitBuffer := TMemoryStream.Create; -FBuffer := TMemoryStream.Create; -FBlockLen := FBlockCipher.BlockSize div 8; -FCodec := FBlockCipher.MakeBlockCodec( Key1); -FBuffer.Size := FBlockLen; -FLenBuffer := 0; -FEmitBuffer.Size := FBlockLen; -FIV := TMemoryStream.Create; -FChainState := nil; -FDataCount := 0; -FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = - [cfKeyStream, cfAutoXOR]; -Fis8bitMode := (cf8bit in FChaining.ChainingFeatures) and - (cfKeyStream in FChaining.ChainingFeatures) and - (not (cfNoNounce in FChaining.ChainingFeatures)); -// A chaining mode with cf8Bit MUST also have -// cfKeyStream and not cfNoNounce -FisEncrypting := isEncrypting1 -end; - - - -procedure TEncryptorDecryptor.Chained_Decrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -begin -Plaintext.Position := 0; -Ciphertext.Position := 0; -FChainState.Decrypt_Block( Plaintext, Ciphertext) -end; - - -procedure TEncryptorDecryptor.Chained_Encrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -begin -Plaintext.Position := 0; -Ciphertext.Position := 0; -FChainState.Encrypt_Block( Plaintext, Ciphertext) -end; - - - -destructor TEncryptorDecryptor.Destroy; -begin -BurnMemoryStream( FEmitBuffer); FEmitBuffer.Free; -BurnMemoryStream( FBuffer); FBuffer.Free; -FCodec.Burn; -FCodec := nil; -if assigned( FChainState) then - begin - FChainState.Burn; - FChainState.Free - end; -BurnMemoryStream( FIV); -FIV.Free; -inherited -end; - - - -procedure TEncryptorDecryptor.Emit( - SourceBuf: TMemoryStream; EmitLen: integer = -1); -var - PlaintextByte, CiphertextByte: byte; - P, Q: PByte; - j: integer; -begin -if EmitLen = -1 then - EmitLen := FBlockLen; -if FisEncrypting then - begin - if Fis8bitMode then - begin - P := SourceBuf.Memory; - Q := FEmitBuffer.Memory; - for j := 0 to EmitLen - 1 do - begin - PlaintextByte := P^; - FChainState.Encrypt_8bit( PlaintextByte, CiphertextByte); - Q^ := CiphertextByte; - Inc( P); Inc( Q) - end - end - else - Chained_Encrypt_Block( SourceBuf, FEmitBuffer) - end - else - begin - if Fis8bitMode then - begin - P := SourceBuf.Memory; - Q := FEmitBuffer.Memory; - for j := 0 to EmitLen - 1 do - begin - CiphertextByte := P^; - FChainState.Decrypt_8bit( PlaintextByte, CiphertextByte); - Q^ := PlaintextByte; - Inc( P); Inc( Q) - end - end - else - Chained_Decrypt_Block( FEmitBuffer, SourceBuf) - end; -if FisAutoXOR then - XOR_Streams2( FEmitBuffer, SourceBuf); -FEmissionStream.WriteBuffer( FEmitBuffer.Memory^, EmitLen) -end; - - - - -procedure TEncryptorDecryptor.Emit_1stBuffer; -begin -if FLenBuffer = 0 then exit; -Emit( FBuffer, FLenBuffer); -FLenBuffer := 0 -end; - - -procedure TEncryptorDecryptor.Reset; -begin -BurnMemory( FEmitBuffer.Memory^, FBlockLen); -BurnMemory( FBuffer .Memory^, FBlockLen); -FCodec.Reset; -FLenBuffer := 0; -FDataCount := 0 -end; - - - - -{ TOpenSSLCompatEncryptor } - -constructor TOpenSSLCompatEncryptor.Start_Encrypt( - Key1: TSymetricKey; CipherText1: TStream; - const BlockCipher1: IBlockCipher; const Chaining1: IBlockChainingModel); -begin -// Valid only for ECB. Other chain modes for OpenSSL compatibility -// require an explicit user-supplied IV. -inherited Start_EncDec( Key1, Ciphertext1, BlockCipher1, Chaining1, True); -FKey := Key1; -FCipherText := CipherText1; -FIV.Size := FBlockLen; -ZeroFillStream( FIV); -FChainState := FChaining.Chain_EncryptBlock( Key1, FIV, FCodec); -end; - -constructor TOpenSSLCompatEncryptor.Start_Encrypt_WithIV( - Key1: TSymetricKey; CipherText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; IV1: TStream); -begin -inherited Start_EncDec( Key1, Ciphertext1, BlockCipher1, Chaining1, True); -FKey := Key1; -FCipherText := CipherText1; -FIV.Size := 0; -FIV.CopyFrom( IV1, 0); -FChainState := FChaining.Chain_EncryptBlock( Key1, FIV, FCodec); -end; - -destructor TOpenSSLCompatEncryptor.Destroy; -begin - // TODO - inherited; -end; - -procedure TOpenSSLCompatEncryptor.Encrypt( const Plaintext: TStream); -var - X: int64; - Amnt: integer; -begin -Plaintext.Position := 0; -X := Plaintext.Size; -while (X > 0) or (FLenBuffer = FBlockLen) do - begin - Amnt := FBlockLen - FLenBuffer; - if Amnt > X then - Amnt := X; - if Amnt > 0 then - begin - Amnt := ReadMem( Plaintext, FBuffer, FLenBuffer, Amnt); - if Amnt = 0 then - X := 0 - else - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if FLenBuffer = FBlockLen then - begin - Emit( FBuffer); - FLenBuffer := 0 - end - end -end; - -procedure TOpenSSLCompatEncryptor.End_Encrypt; -var - PadByte: byte; -begin -if not (cfKeyStream in FChaining.ChainingFeatures) then - begin - if FLenBuffer = 0 then - PadByte := FBlockLen - else - PadByte := FBlockLen - FLenBuffer; - FillChar( Offset( FBuffer.Memory, FLenBuffer)^, PadByte, PadByte); - FLenBuffer := FBlockLen; - end; -if FLenBuffer > 0 then - Emit( FBuffer, FLenBuffer); -FLenBuffer := 0; -end; - -procedure TOpenSSLCompatEncryptor.Reset; -begin - inherited; - // TODO - -end; - -{ TOpenSSLCompatDecryptor } - -procedure TOpenSSLCompatDecryptor.Decrypt(const Ciphertext: TStream); -begin - // TODO - -end; - -destructor TOpenSSLCompatDecryptor.Destroy; -begin - // TODO - - inherited; -end; - -procedure TOpenSSLCompatDecryptor.End_Decrypt; -begin - // TODO - -end; - -procedure TOpenSSLCompatDecryptor.Reset; -begin - inherited; - // TODO - -end; - -constructor TOpenSSLCompatDecryptor.Start_Decrypt(Key1: TSymetricKey; - PlainText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); -begin - // TODO - -end; - -constructor TOpenSSLCompatDecryptor.Start_Decrypt_WithIV(Key1: TSymetricKey; - PlainText1: TStream; const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel; IV1: TStream); -begin - // TODO - -end; - - - -///////////////////////// - - - -type -TCSharpStreamToBlock_Adapter = class( TInterfacedObject, - IStreamCipher, ICryptoGraphicAlgorithm, IControlObject) - private - FBlockCipher: IBlockCipher; - FChaining: IBlockChainingModel; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; - - // IControlObject = interface - function ControlObject: TObject; - - public - constructor Create; - end; - -TCSharpDecryptor = class( TInterfacedObject, IStreamDecryptor) - private - FChaining: IBlockChainingModel; - FEmitBuffer: TMemoryStream; - FBuffer: TMemoryStream; - FBlockLen: integer; - FCodec: IBlockCodec; - FBlockCipher: IBlockCipher; - FLenBuffer: integer; - FChainState: TBlockChainLink; - FIV: TMemoryStream; - FDataCount: int64; - FisAutoXOR: boolean; - Fis8bitMode: boolean; - FEmissionStream: TStream; - FKey: TSymetricKey; - - procedure Reset; - procedure Emit( SourceBuf: TMemoryStream; EmitLen: integer = -1); - procedure Emit_1stBuffer; - procedure Chained_Decrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - - public - constructor Start_Decrypt( - Key1: TSymetricKey; EmissionStream1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); - - destructor Destroy; override; - end; - - -function TCSharpStreamToBlock_Adapter.ControlObject: TObject; -var - ControlObject: IControlObject; -begin -if Supports( FBlockCipher, IControlObject, ControlObject) then - result := ControlObject.ControlObject - else - result := self -end; - - -constructor TCSharpStreamToBlock_Adapter.Create; -begin -end; - -function TCSharpStreamToBlock_Adapter.DefinitionURL: string; -begin -result := '' -end; - - - -function TCSharpStreamToBlock_Adapter.DisplayName: string; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.DisplayName - else - result := BlockCipher_DisplayName + ' CSharp variant' -end; - - - -function TCSharpStreamToBlock_Adapter.Features: TAlgorithmicFeatureSet; -begin -result := [afBlockAdapter, afDoesNotNeedSalt] -end; - - -function TCSharpStreamToBlock_Adapter.GenerateKey( Seed: TStream): TSymetricKey; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.GenerateKey( Seed) - else - result := nil -end; - - -function TCSharpStreamToBlock_Adapter.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -if assigned( FBlockCipher) and assigned( Store) then - result := FBlockCipher.LoadKeyFromStream( Store) - else - result := nil -end; - - -function TCSharpStreamToBlock_Adapter.Parameterize( - const Params: IInterface): IStreamCipher; -var - BlockCipherSelector: IBlockCipherSelector; - //BlockCipherSelectorEx2: IBlockCipherSelectorEx2; - BlockCipher: IBlockCipher; - Chaining: IBlockChainingModel; - Newbie: TCSharpStreamToBlock_Adapter; -begin -result := nil; -if assigned( FBlockCipher) and assigned( FChaining) then exit; -if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then - begin - BlockCipher := BlockCipherSelector.GetBlockCipher; - Chaining := BlockCipherSelector.GetChainMode; - end; -if not (assigned( BlockCipher) or assigned( Chaining)) then exit; -Newbie := TCSharpStreamToBlock_Adapter.Create; -Newbie.FBlockCipher := BlockCipher; -Newbie.FChaining := Chaining; -result := Newbie -end; - - - - -function TCSharpStreamToBlock_Adapter.ProgId: string; -begin -result := 'CSharp.StreamToBlock' -end; - - - -function TCSharpStreamToBlock_Adapter.SeedByteSize: integer; -begin -if assigned( FBlockCipher) then - result := FBlockCipher.SeedByteSize - else - result := -1 -end; - - -procedure NotSupported; -begin -raise Exception.Create('Feature not supported.'); -end; - -function TCSharpStreamToBlock_Adapter.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin - if cfNoNounce in FChaining.ChainingFeatures then - NotSupported - else - result := TCSharpDecryptor.Start_Decrypt( - Key, PlainText, FBlockCipher, FChaining) -end; - - - -function TCSharpStreamToBlock_Adapter.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -NotSupported -end; - - - - - -function TCSharpStreamToBlock_Adapter.WikipediaReference: string; -begin -result := '' -end; - - -constructor TCSharpDecryptor.Start_Decrypt( - Key1: TSymetricKey; EmissionStream1: TStream; - const BlockCipher1: IBlockCipher; - const Chaining1: IBlockChainingModel); -begin -FEmissionStream := EmissionStream1; -FBlockCipher := BlockCipher1; -FChaining := Chaining1; -FEmitBuffer := TMemoryStream.Create; -FBuffer := TMemoryStream.Create; -FBlockLen := FBlockCipher.BlockSize div 8; -FCodec := FBlockCipher.MakeBlockCodec( Key1); -FBuffer.Size := FBlockLen; -FLenBuffer := 0; -FEmitBuffer.Size := FBlockLen; -FIV := TMemoryStream.Create; -FChainState := nil; -FDataCount := 0; -FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = - [cfKeyStream, cfAutoXOR]; -Fis8bitMode := (cf8bit in FChaining.ChainingFeatures) and - (cfKeyStream in FChaining.ChainingFeatures) and - (not (cfNoNounce in FChaining.ChainingFeatures)); -// A chaining mode with cf8Bit MUST also have -// cfKeyStream and not cfNoNounce -FKey := Key1; -FLenBuffer := 0; -FIV.Size := 0; -end; - - - -procedure TCSharpDecryptor.Chained_Decrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -begin -Plaintext.Position := 0; -Ciphertext.Position := 0; -FChainState.Decrypt_Block( Plaintext, Ciphertext) -end; - - -destructor TCSharpDecryptor.Destroy; -begin -FDataCount := 0; -BurnMemoryStream( FEmitBuffer); FEmitBuffer.Free; -BurnMemoryStream( FBuffer); FBuffer.Free; -FCodec.Burn; -FCodec := nil; -if assigned( FChainState) then - begin - FChainState.Burn; - FChainState.Free - end; -BurnMemoryStream( FIV); -FIV.Free; -inherited -end; - - - -procedure TCSharpDecryptor.Emit( - SourceBuf: TMemoryStream; EmitLen: integer = -1); -var - PlaintextByte, CiphertextByte: byte; - P, Q: PByte; - j: integer; -begin -if EmitLen = -1 then - EmitLen := FBlockLen; -if Fis8bitMode then - begin - P := SourceBuf.Memory; - Q := FEmitBuffer.Memory; - for j := 0 to EmitLen - 1 do - begin - CiphertextByte := P^; - FChainState.Decrypt_8bit( PlaintextByte, CiphertextByte); - Q^ := PlaintextByte; - Inc( P); Inc( Q) - end - end - else - Chained_Decrypt_Block( FEmitBuffer, SourceBuf); -if FisAutoXOR then - XOR_Streams2( FEmitBuffer, SourceBuf); -FEmissionStream.WriteBuffer( FEmitBuffer.Memory^, EmitLen) -end; - - - - -procedure TCSharpDecryptor.Emit_1stBuffer; -begin -if FLenBuffer = 0 then exit; -Emit( FBuffer, FLenBuffer); -FLenBuffer := 0 -end; - - -procedure TCSharpDecryptor.Reset; -begin -BurnMemory( FEmitBuffer.Memory^, FBlockLen); -BurnMemory( FBuffer .Memory^, FBlockLen); -FCodec.Reset; -FLenBuffer := 0; -FDataCount := 0; -BurnMemoryStream( FIV); -if assigned( FChainState) then - begin - FChainState.Burn; - FChainState.Free; - FChainState := nil - end -end; - - - - -procedure TCSharpDecryptor.Decrypt( const Ciphertext: TStream); -var - X: int64; - Amnt: integer; - //Tmp: TMemoryStream; - //OldSize: integer; -begin -Ciphertext.Position := 0; -X := Ciphertext.Size; -while (X > 0) or (FLenBuffer = FBlockLen) do - begin - - // 1. Read the IV. - if (FIV.Size < FBlockLen) and (X > 0) then - begin - Amnt := FBlockLen - FIV.Size; - if X < Amnt then - Amnt := X; - FIV.CopyFrom( Ciphertext, Amnt); - Dec( X, Amnt); - continue - end; - - // 2. Now process the payload - Amnt := FBlockLen - FLenBuffer; - if X < Amnt then - Amnt := X; - if Amnt > 0 then - begin - ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); - Dec( X, Amnt); - Inc( FLenBuffer, Amnt); - Inc( FDataCount, Amnt) - end; - if FLenBuffer = FBlockLen then - begin - if not assigned( FChainState) then - FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); - Emit_1stBuffer - end - end -end; - - - -procedure TCSharpDecryptor.End_Decrypt; -//var -// ChainStateClone: TBlockChainLink; -begin -if FDataCount = 0 then - begin end - else - begin - FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = - [cfKeyStream, cfAutoXOR]; - if not assigned( FChainState) then - FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); - if (FLenBuffer = 0) or (cfKeyStream in FChaining.ChainingFeatures) then - Emit_1stBuffer - else - begin - Reset; - raise Exception.Create('Ciphertext not zero padded'); - end - end; -Reset -end; - - - -function StreamToBlock_Adapter_CSharpVariant: IStreamCipher; -begin -result := TCSharpStreamToBlock_Adapter.Create -end; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.StreamToBlock; +interface +uses TPLB3.StreamCipher, TPLB3.BlockCipher, Classes, TPLB3.Decorators; + +type + +TStreamToBlock_Adapter = class( TInterfacedObject, + IStreamCipher, ICryptoGraphicAlgorithm, IControlObject + // IStreamCipherEx2 + ) + private + FBlockCipher: IBlockCipher; + FChaining: IBlockChainingModel; + FAdvancedOptions: TSymetricEncryptionOptionSet; + FOnSetIV: TSetMemStreamProc; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; overload; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; overload; +// function Start_Encrypt( Key: TSymetricKey; CipherText: TStream; IV: TStream): IStreamEncryptor; overload; +// function Start_Decrypt( Key: TSymetricKey; PlainText : TStream; IV: TStream): IStreamDecryptor; overload; + + // IControlObject = interface + function ControlObject: TObject; + + public + constructor Create; + end; + + +function StreamToBlock_Adapter_CSharpVariant: IStreamCipher; +// CSharp variant: +// 1. Only decrypt is implemented. +// 2. Not automatically registered with the library. You have to explicitly register. +// 3. Full IV is prepended in the ciphertext stream. +// 4. Straight zero padding. + +implementation + + + + + + + + + + + + + +uses SysUtils, Math, TPLB3.StreamUtils, TPLB3.CFB_Block, TPLB3.Constants, + TPLB3.CFB_8Bit, TPLB3.PointerArithmetic, TPLB3.I18n; + + +{ HOW THE STREAM TO BLOCK ADAPTER WORKS (Encryption direction) + ================================================================= + +We have a plaintext message (msg), which we which to encrypt and transmit +over an insecure channel using a block mode cipher. + + Let the length of the plaintext message in bits be m. + Len( msg) = m + m >= 0 + + Let the block size in bits be B. + B >= 2 + + Because of our fileing system constraints, we must have + m mod 8 = 0 + B mod 8 = 0 + B >= 16 (B=8 would make block-mode pointless). + +CASE ONE: The Trivial Case. +--------------------------- +In this case the message is empty, that is to say m = 0. +we handle this with an empty emission. This is so, regardless of the +chaining mode and its features. + +In all other cases ... +---------------------- +In all other cases that follow, in general we will emit the following +data in the said order. + 1. The IV Seed. This is emitted in the clear. This will not always be present. + 2. The encryption of the following stream: + 2.1 A prefix. This will not always be present. + 2.2 The payload message, msg + 2.3 Padding at the end. Whether this is present or not, depends on the mode. + The last ciphertext block of (2.) may be truncated according to mode. + +Let the length of the IV seed in bits be s. +Let the length of the prefix in bits be pre. +Let the length of the end padding be pd. +Let the length of the input to to codec, before padding, be x. + x = pre + m + +Let N be the number of blocks. + N = roof( x / B) = (x + B - 1) div B + +Let xl be the length of the last ciphertext block, before padding. + if (x mod B) = 0 ==> xl = B + if (x mod B) <> 0 ==> xl = x mod B + 8 <= xl <= B + +Necessarily, we have ... + pd = (B - xl) + (k * B) + where k is some non-negative integer, which is going to depend on + our mode and padding scheme. + +How we proceed next, depends on the chaining features. +Here is the definition again. + +IBlockCipher.ChainingFeatures: TChainingFeature = ( + cfNoNounce, // The chaining mode does not require any nounce nor + // does it require an IV. Ex: ECB + cfKeyStream, // A key-stream is at the heart of the chaining mode + // The final partial block can be padded arbitarily, + // encrypted as usual, and then truncated to the same + // length as the corresponding plaintext input. + // Examples: CFB, 8-bit CFB, OFB and CTR. + // Counter-examples: ECB and CBC + cf8bit); // Plaintext and cipher text are processed one byte at a time. + // Example: 8-bit CFB. + +CASE TWO: cfNoNounce and cfKeyStream +------------------------------------ +There are no stock modes which are an example of this. I don't expect +that there will even be any custom modes worth their salt (pun intended), +which has this combination of features. Never-the-less, this algorithm +deals with this case, just in case a custom cipher is so. + +1. There is no IV seed. + s = 0 +2. There is no prefix. + pre = 0 +3. The IV is set to all zeros. +4. If the plaintext is not congruent to the block size (xl < B), then + pad out the last plaintext block with zeros. We will call this + type of padding, "short zero extend". + pd = B - xl +5. Encrypt the blocks in order +6. Truncate the last ciphertext block to xl. +7. Emit the ciphertext blocks. + +CASE THREE: cfNoNounce and NOT cfKeyStream +------------------------------------------- +An example of such a mode is ECB. +1. There is no IV seed. + s = 0 +2. There is no prefix. + pre = 0 +3. The IV is set to all zeros. +4. Pad out the last block like this .. + 4.1. Append a single '1' bit. ($80 in a byte) + 4.2. Append as many zeros as required to make the final block full. + We will call this type of padding "Simple dimple". + xl < B ==> pd = B - xl + xl = B ==> pd = B +5. Encrypt the blocks in order +6. Do NOT truncate the last ciphertext block. +7. Emit the ciphertext blocks. + +Otherwise ... +---------- +1. Generate a 64 bit nonce from a random number generator. +2.1 If B >= 64, set the lower 64 bits of the IV to be the nonce, + and the remaining bits zero. The IV seed is the nonce, and + there is no prefix. + s = 64 + pre = 0 +2.2 If B < 64, we need to compensate for the weakness of the chaining mode + against the repeat-message attack, by salting or pre-seeding the + input plaintext proportionally. Set the IV to be the lower B bits + of the nounce. The IV seed is the IV. The prefix is the remaining + bits of the nonce. + s = B + pre = 64 - B + +In either case: s + pre = 64 + +In what follows, use the following terminology. + If x < B then describe the message as a 'short message'. + If (x mod B) = 0 then describe the message as a 'round message'. + If (x > B) and ((x mod B) > 0) then describe the message as a 'sharp message'. + +CASE FOUR: NOT cfNoNounce and NOT cfKeyStream and short message +---------------------------------------------------------------- +CBC mode has NOT cfNoNounce and NOT cfKeyStream. +In this case, act as if the mode was CFB, which has feature set [cfKeyStream], + that is to say CFB has NOT cfNoNounce and cfKeyStream. +Refer to case 7 (NOT cfNoNounce, cfKeyStream) + +CASE FIVE: NOT cfNoNounce and round message +-------------------------------------------- +1. No padding is required. + xl = B +2. Encrypt the blocks in order. +3. There is no truncation of the last ciphertext block. +4. Emit the ciphertext blocks in natural order. + +CASE SIX: NOT cfNoNounce and NOT cfKeyStream and sharp message +---------------------------------------------------------------- +1. Apply ciphertext stealing to the last two blocks. +2. The last two ciphertext blocks are emitted in reverse order. That is + to say, the second last cipherblock (which has length xl) is emitted + last, and the naturally last cipherblock (which has length B) is emitted + second last. + +CASE SEVEN: NOT cfNoNounce and cfKeyStream but not round message +---------------------------------------------------------------- +1. Our cipher effectively a stream-mode cipher. So short zero extend the + last block. +2. Encrypt the blocks in natural order. +3. Truncate the last block to xl. +4. Emit the blocks in natural order. + + + +} + + + + +type +TEncryptorDecryptor = class( TInterfacedObject) + protected + FChaining: IBlockChainingModel; + FEmitBuffer: TMemoryStream; + FBuffer: TMemoryStream; + FBlockLen: integer; + FCodec: IBlockCodec; + FBlockCipher: IBlockCipher; + FLenBuffer: integer; + FChainState: TBlockChainLink; + FIV: TMemoryStream; + FDataCount: int64; + FisAutoXOR: boolean; + Fis8bitMode: boolean; + FisEncrypting: boolean; + FEmissionStream: TStream; + FAdvancedOptions2: TSymetricEncryptionOptionSet; + + procedure Reset; virtual; + procedure Emit( SourceBuf: TMemoryStream; EmitLen: integer = -1); + // ^ Encrypt/Decrypt and then emit. + + procedure Emit_1stBuffer; + function ShortNonKeyStreamingChainMode: IBlockChainingModel; + procedure Chained_Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Chained_Decrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure GetIV; virtual; + + public + constructor Start_EncDec( + Key1: TSymetricKey; EmissionStream1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + isEncrypting1: boolean; + AdvancedOptions2: TSymetricEncryptionOptionSet); + + destructor Destroy; override; + end; + + + + +TNoNonceEncryptor = class( TEncryptorDecryptor, IStreamEncryptor) + private + FCipherText: TStream; + FPad: TMemoryStream; + + procedure Encrypt( const Plaintext: TStream); + procedure End_Encrypt; + + protected + procedure Reset; override; + + public + constructor Start_Encrypt( + Key1: TSymetricKey; CipherText1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + AdvancedOptions2: TSymetricEncryptionOptionSet); + + destructor Destroy; override; + end; + + +TNoncibleEncryptor = class( TEncryptorDecryptor, IStreamEncryptor) + private + FKey: TSymetricKey; + FCipherText: TStream; + F2ndBuffer: TMemoryStream; + Fis2ndBufferFull: boolean; + FIVSeedLen: integer; + FSaltLen: integer; + FNonce: TMemoryStream; + FisShortMessage: boolean; + FisAddingSalt: boolean; + FOnSetIV: TSetMemStreamProc; + + procedure Encrypt( const Plaintext: TStream); + procedure End_Encrypt; + + protected + procedure Reset; override; + procedure GetIV; override; + + public + constructor Start_Encrypt( + Key1: TSymetricKey; CipherText1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + OnSetIV1: TSetMemStreamProc; + AdvancedOptions2: TSymetricEncryptionOptionSet); + + destructor Destroy; override; + end; + + +TNoncibleDecryptor = class( TEncryptorDecryptor, IStreamDecryptor) + private + FKey: TSymetricKey; + FPlainText: TStream; + F2ndBuffer: TMemoryStream; + Fis2ndBufferFull: boolean; + FSaltAbsorber: TDesalinationWriteStream; + FDataCount: int64; + FIVSeedLen: integer; + FSaltLen: integer; + FisShortMessage: boolean; + FOnSetIV: TSetMemStreamProc; + FRemainingSeedLen: integer; + FhasCapturedIV : boolean; + + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + + protected + procedure Reset; override; + procedure GetIV; override; + + public + constructor Start_Decrypt( + Key1: TSymetricKey; PlainText1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + OnSetIV1: TSetMemStreamProc; + AdvancedOptions2: TSymetricEncryptionOptionSet); + + destructor Destroy; override; + end; + +TNoNonceDecryptor = class( TEncryptorDecryptor, IStreamDecryptor) + private + FPlaintext: TStream; + FisSecondBufferFull: boolean; + F2ndBuffer: TMemoryStream; + + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + + protected + procedure Reset; override; + + public + constructor Start_Decrypt( + Key1: TSymetricKey; PlainText1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + AdvancedOptions2: TSymetricEncryptionOptionSet); + + destructor Destroy; override; + end; + + + + + +{ TStreamToBlock_Adapter } + +function TStreamToBlock_Adapter.ControlObject: TObject; +var + ControlObject: IControlObject; +begin +if Supports( FBlockCipher, IControlObject, ControlObject) then + result := ControlObject.ControlObject + else + result := self +end; + + +constructor TStreamToBlock_Adapter.Create; +begin +FAdvancedOptions := [] +end; + +function TStreamToBlock_Adapter.DefinitionURL: string; +begin +result := '' +end; + + + +function TStreamToBlock_Adapter.DisplayName: string; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.DisplayName + else + result := BlockCipher_DisplayName +end; + + + +function TStreamToBlock_Adapter.Features: TAlgorithmicFeatureSet; +begin +result := [afStar, afOpenSourceSoftware, afBlockAdapter, afDoesNotNeedSalt] +end; + + +function TStreamToBlock_Adapter.GenerateKey( Seed: TStream): TSymetricKey; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.GenerateKey( Seed) + else + result := nil +end; + + +function TStreamToBlock_Adapter.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +if assigned( FBlockCipher) and assigned( Store) then + result := FBlockCipher.LoadKeyFromStream( Store) + else + result := nil +end; + + +function TStreamToBlock_Adapter.Parameterize( + const Params: IInterface): IStreamCipher; +var + BlockCipherSelector: IBlockCipherSelector; + BlockCipherSelectorEx2: IBlockCipherSelectorEx2; + BlockCipher: IBlockCipher; + Chaining: IBlockChainingModel; + Newbie: TStreamToBlock_Adapter; +begin +result := nil; +if assigned( FBlockCipher) and assigned( FChaining) then exit; +FAdvancedOptions := []; +if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then + begin + BlockCipher := BlockCipherSelector.GetBlockCipher; + Chaining := BlockCipherSelector.GetChainMode; + if Supports( BlockCipherSelector, IBlockCipherSelectorEx2, BlockCipherSelectorEx2) then + FAdvancedOptions := BlockCipherSelectorEx2.GetAdvancedOptions2 + end; +if not (assigned( BlockCipher) or assigned( Chaining)) then exit; +Newbie := TStreamToBlock_Adapter.Create; +Newbie.FBlockCipher := BlockCipher; +Newbie.FChaining := Chaining; +result := Newbie; +if (not assigned( BlockCipherSelectorEx2)) or + (not BlockCipherSelectorEx2.hasOnSetIVHandler( Newbie.FOnSetIV)) then + Newbie.FOnSetIV := nil +end; + + + + +function TStreamToBlock_Adapter.ProgId: string; +begin +result := BlockCipher_ProgId +end; + + + +function TStreamToBlock_Adapter.SeedByteSize: integer; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.SeedByteSize + else + result := -1 +end; + + + +function TStreamToBlock_Adapter.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin +//if optOpenSSL_CompatibilityMode in FAdvancedOptions then +// begin +// if not (cfNoNounce in FChaining.ChainingFeatures) then +// raise Exception.Create( ES_OpenSSLCompat_RequiresIV); +// result := TOpenSSLCompatDecryptor.Start_Decrypt( +// Key, PlainText, FBlockCipher, FChaining, FAdvancedOptions) +// end +// +// else + if cfNoNounce in FChaining.ChainingFeatures then + result := TNoNonceDecryptor.Start_Decrypt( + Key, PlainText, FBlockCipher, FChaining, FAdvancedOptions) + else + result := TNoncibleDecryptor.Start_Decrypt( + Key, PlainText, FBlockCipher, FChaining, FOnSetIV, FAdvancedOptions) +end; + + + +function TStreamToBlock_Adapter.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +//if optOpenSSL_CompatibilityMode in FAdvancedOptions then +// // Valid only for ECB. Other chain modes for OpenSSL compatibility +// // require an explicit user-supplied IV. +// begin +// if not (cfNoNounce in FChaining.ChainingFeatures) then +// raise Exception.Create( ES_OpenSSLCompat_RequiresIV); +// result := TOpenSSLCompatEncryptor.Start_Encrypt( +// Key, CipherText, FBlockCipher, FChaining, FAdvancedOptions) +// end +// +// else + if cfNoNounce in FChaining.ChainingFeatures then + result := TNoNonceEncryptor.Start_Encrypt( + Key, CipherText, FBlockCipher, FChaining, FAdvancedOptions) + else + result := TNoncibleEncryptor.Start_Encrypt( + Key, CipherText, FBlockCipher, FChaining, FOnSetIV, FAdvancedOptions) +end; + + + +//function TStreamToBlock_Adapter.Start_Decrypt( +// Key: TSymetricKey; PlainText, IV: TStream): IStreamDecryptor; +//var +// sName: string; +//begin +//if optOpenSSL_CompatibilityMode in FAdvancedOptions then +// result := TOpenSSLCompatDecryptor.Start_Decrypt_WithIV( +// Key, PlainText, FBlockCipher, FChaining, IV) +// else +// begin +// if assigned( FBlockCipher) then +// sName := FBlockCipher.DisplayName +// else +// sName := '(no block cipher)'; +// raise Exception.CreateFmt( ES_NoOpenSSLCompat, [sName]) +// end; +//end; + +//function TStreamToBlock_Adapter.Start_Encrypt( +// Key: TSymetricKey; CipherText, IV: TStream): IStreamEncryptor; +//var +// sName: string; +//begin +//if optOpenSSL_CompatibilityMode in FAdvancedOptions then +// result := TOpenSSLCompatEncryptor.Start_Encrypt_WithIV( +// Key, CipherText, FBlockCipher, FChaining, IV) +// else +// begin +// if assigned( FBlockCipher) then +// sName := FBlockCipher.DisplayName +// else +// sName := '(no block cipher)'; +// raise Exception.CreateFmt( ES_NoOpenSSLCompat, [sName]) +// end; +//end; + + + +function TStreamToBlock_Adapter.WikipediaReference: string; +begin +result := '' +end; + + + + + +{ TNoNonceEncryptor } + +constructor TNoNonceEncryptor.Start_Encrypt( Key1: TSymetricKey; + CipherText1: TStream; const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; AdvancedOptions2: TSymetricEncryptionOptionSet); +begin +inherited Start_EncDec( Key1, CipherText1, BlockCipher1, Chaining1, True, AdvancedOptions2); +FCipherText := CipherText1; +FIV.Size := FBlockLen; +ZeroFillStream( FIV); +FChainState := FChaining.Chain_EncryptBlock( Key1, FIV, FCodec); +if cfKeyStream in FChaining.ChainingFeatures then + FPad := nil + else + FPad := TMemoryStream.Create +end; + + + +procedure TNoNonceEncryptor.Encrypt( const Plaintext: TStream); +var + X: int64; + Amnt: integer; +begin +Plaintext.Position := 0; +X := Plaintext.Size; +while X > 0 do + begin + Amnt := FBlockLen - FLenBuffer; + if X < FBlockLen then + Amnt := Min( Amnt, X); + if Amnt > 0 then + begin + ReadMem( Plaintext, FBuffer, FLenBuffer, Amnt); + Dec( X, Amnt); + Inc( FLenBuffer, Amnt); + Inc( FDataCount, Amnt) + end; + if FLenBuffer = FBlockLen then + Emit_1stBuffer + end +end; + + +const PadIntroducer: byte = $80; + +procedure TNoNonceEncryptor.End_Encrypt; +begin +if (FDataCount <> 0) and (not (cfKeyStream in FChaining.ChainingFeatures)) then + begin + FPad.Size := FBlockLen - FLenBuffer; + ZeroFillStream( FPad); + PByte( FPad.Memory)^ := PadIntroducer; + Encrypt( FPad) + end; +if cfKeyStream in FChaining.ChainingFeatures then + Emit_1stBuffer; +Reset +end; + + + +procedure TNoNonceEncryptor.Reset; +begin +inherited Reset; +FChainState.Reset( FIV); +if not (cfKeyStream in FChaining.ChainingFeatures) then + BurnMemoryStream( FPad) +end; + + + +destructor TNoNonceEncryptor.Destroy; +begin +BurnMemoryStream( FPad); FPad.Free; +inherited +end; + + + +{ TNoncibleEncryptor } + +constructor TNoncibleEncryptor.Start_Encrypt( + Key1: TSymetricKey; + CipherText1: TStream; const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; OnSetIV1: TSetMemStreamProc; + AdvancedOptions2: TSymetricEncryptionOptionSet); +begin +inherited Start_EncDec( Key1, Ciphertext1, BlockCipher1, Chaining1, True, AdvancedOptions2); +FKey := Key1; +FCipherText := CipherText1; +FChainState := nil; +F2ndBuffer := TMemoryStream.Create; +F2ndBuffer.Size := FBlockLen; +Fis2ndBufferFull := False; +FIV.Size := FBlockLen; +FIVSeedLen := Min( FBlockLen, 8); +FSaltLen := 8 - FIVSeedLen; +FNonce := TMemoryStream.Create; +FisShortMessage := True; +FisAddingSalt := False; +FOnSetIV := OnSetIV1 +end; + + +procedure TNoncibleEncryptor.GetIV; +var + SizeDiff: integer; +begin + Move( FNonce.Memory^, FIV.Memory^, FIVSeedLen); + if FBlockLen > FIVSeedLen then + FillChar( MemStrmOffset( FIV, FIVSeedLen)^, FBlockLen - FIVSeedLen, 0); + if assigned( FOnSetIV) then + begin + FIV.Position := 0; + FOnSetIV( FIV); + SizeDiff := FIV.Size - FBlockLen; + if SizeDiff <> 0 then + FIV.Size := FBlockLen; + if SizeDiff < 0 then + FillChar( MemStrmOffset( FIV, FBlockLen + SizeDiff)^, -SizeDiff, 0); + FIV.Position := 0 + end +end; + + + +procedure TNoncibleEncryptor.Encrypt( const Plaintext: TStream); +var + X: int64; + Amnt: integer; + Tmp: TMemoryStream; +begin +Plaintext.Position := 0; +X := Plaintext.Size; +if (X > 0) and (FDataCount = 0) and (not FisAddingSalt) then + begin + // 1. Acquire Nonce. + FNonce.Size := 8; + RandomFillStream( FNonce); + + // 2. Determine the IV. + GetIV; + + // 3. Emit IV seed in the clear. + if (FIVSeedLen > 0) and (not (optSuppressIVSeedPrependage in FAdvancedOptions2)) then + FCiphertext.WriteBuffer( FIV.Memory^, FIVSeedLen); + + // 4. Pre-pend salt. + if FSaltLen > 0 then + begin + FisAddingSalt := True; + try + Move( MemStrmOffset( FNonce, FIVSeedLen)^, FNonce.Memory^, FSaltLen); + FNonce.Size := FSaltLen; + Encrypt( FNonce) + finally + FisAddingSalt := False + end + end; + + BurnMemoryStream( FNonce) + end; +while (X > 0) or (FLenBuffer = FBlockLen) do + begin + Amnt := FBlockLen - FLenBuffer; + if Amnt > X then + Amnt := X; + if Amnt > 0 then + begin + Amnt := ReadMem( Plaintext, FBuffer, FLenBuffer, Amnt); + if Amnt = 0 then + X := 0 + else + Dec( X, Amnt); + Inc( FLenBuffer, Amnt); + Inc( FDataCount, Amnt) + end; + if FLenBuffer >= FBlockLen then + FisShortMessage := False; + if (FLenBuffer = FBlockLen) and (not Fis2ndBufferFull) then + begin + Tmp := F2ndBuffer; + F2ndBuffer := FBuffer; + FBuffer := Tmp; + Fis2ndBufferFull := True; + FLenBuffer := 0 + end; + if (FLenBuffer = FBlockLen) and Fis2ndBufferFull then + begin + if not assigned( FChainState) then + FChainState := FChaining.Chain_EncryptBlock( FKey, FIV, FCodec); + Emit( F2ndBuffer); + Fis2ndBufferFull := False + end + end +end; + + +procedure TNoncibleEncryptor.End_Encrypt; +var + Actual: IBlockChainingModel; + ChainStateClone: TBlockChainLink; +begin +if FDataCount = 0 then + begin end + + else + begin + if FisShortMessage and (not (cfKeyStream in FChaining.ChainingFeatures)) then + begin + Actual := ShortNonKeyStreamingChainMode; + Fis8bitMode := (cf8bit in Actual.ChainingFeatures) and + (cfKeyStream in Actual.ChainingFeatures) + end + else + Actual := FChaining; + FisAutoXOR := ([cfKeyStream, cfAutoXOR] * Actual.ChainingFeatures) = + [cfKeyStream, cfAutoXOR]; + if not assigned( FChainState) then + FChainState := Actual.Chain_EncryptBlock( FKey, FIV, FCodec); + + if FLenBuffer = 0 then + begin // Round case + Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling); + Emit( F2ndBuffer); + end + + else if cfKeyStream in Actual.ChainingFeatures then + begin // KeyStream case + if Fis2ndBufferFull then + Emit( F2ndBuffer); + Emit_1stBuffer + end + + else + begin // Ciphertext stealing + Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling); + ChainStateClone := FChainState.Clone; + try + Chained_Encrypt_Block( F2ndBuffer, FEmitBuffer); + Move( MemStrmOffset( FEmitBuffer, FLenBuffer)^, + MemStrmOffset( FBuffer, FLenBuffer)^, + FBlockLen - FLenBuffer); // << The steal! + FBuffer.Position := 0; + F2ndBuffer.Position := 0; + ChainStateClone.Encrypt_Block( FBuffer, F2ndBuffer); + FCiphertext.WriteBuffer( F2ndBuffer .Memory^, FBlockLen); // Swap emission order. + FCiphertext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) + finally + ChainStateClone.Burn; + ChainStateClone.Free + end + end + end; +Reset +end; + + + + + +procedure TNoncibleEncryptor.Reset; +begin +inherited Reset; +BurnMemory( F2ndBuffer .Memory^, FBlockLen); +FreeAndNil( FChainState); +Fis2ndBufferFull := False; +FisShortMessage := True; +BurnMemory( FIV.Memory^, FBlockLen); +BurnMemoryStream( FNonce) +end; + + + +destructor TNoncibleEncryptor.Destroy; +begin +BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); +BurnMemoryStream( FIV); +BurnMemoryStream( FNonce); FreeAndNil( FNonce); +FDataCount := 0; +inherited +end; + + + + +{ TNoNonceDecryptor } + +constructor TNoNonceDecryptor.Start_Decrypt( + Key1: TSymetricKey; PlainText1: TStream; + const BlockCipher1: IBlockCipher; const Chaining1: IBlockChainingModel; AdvancedOptions2: TSymetricEncryptionOptionSet); +begin +inherited Start_EncDec( Key1, Plaintext1, BlockCipher1, Chaining1, False, AdvancedOptions2); +FPlainText := PlainText1; +FIV.Size := FBlockLen; +ZeroFillStream( FIV); +FChainState := FChaining.Chain_DecryptBlock( Key1, FIV, FCodec); +FisSecondBufferFull := False; +F2ndBuffer := TMemoryStream.Create; +F2ndBuffer.Size := FBlockLen +end; + + +procedure TNoNonceDecryptor.Decrypt( const Ciphertext: TStream); +var + X: int64; + Amnt: integer; + Tmp: TMemoryStream; +begin +Ciphertext.Position := 0; +X := Ciphertext.Size; +while (X > 0) or ((FLenBuffer = FBlockLen) and (not FisSecondBufferFull)) do + begin + Amnt := FBlockLen - FLenBuffer; + if X < FBlockLen then + Amnt := Min( Amnt, X); + if Amnt > 0 then + begin + ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); + Dec( X, Amnt); + Inc( FLenBuffer, Amnt); + Inc( FDataCount, Amnt) + end; + if (FLenBuffer = FBlockLen) and (not FisSecondBufferFull) then + begin + Tmp := F2ndBuffer; + F2ndBuffer := FBuffer; + FBuffer := Tmp; + FisSecondBufferFull := True; + FLenBuffer := 0 + end; + if FisSecondBufferFull and (FLenBuffer > 0) then + begin + Emit( F2ndBuffer); + FisSecondBufferFull := False + end + end +end; + +procedure TNoNonceDecryptor.End_Decrypt; +var + Sentinal: PByte; + j: integer; +begin +if FDataCount = 0 then + begin end + + else if cfKeyStream in FChaining.ChainingFeatures then + begin + if FisSecondBufferFull then + begin + Emit( F2ndBuffer); + FisSecondBufferFull := False + end; + Emit_1stBuffer + end + + else + begin + Assert( FisSecondBufferFull and (FLenBuffer = 0), + AS_BlockPaddingCorrupt); + Chained_Decrypt_Block( FEmitBuffer, F2ndBuffer); + FLenBuffer := 0; + Sentinal := PByte( MemStrmOffset( FEmitBuffer, FBlockLen - 1)); + for j := FBlockLen - 1 downto 0 do + begin + if Sentinal^ = PadIntroducer then + begin + FLenBuffer := j; + break + end; + Dec( Sentinal) + end; + if FLenBuffer > 0 then + FPlaintext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) + end; + +Reset +end; + + +procedure TNoNonceDecryptor.Reset; +begin +inherited Reset; +BurnMemory( F2ndBuffer .Memory^, FBlockLen); +FChainState.Reset( FIV); +FisSecondBufferFull := False +end; + + + +destructor TNoNonceDecryptor.Destroy; +begin +BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); +inherited +end; + + +{ TNoncibleDecryptor } + +function TEncryptorDecryptor.ShortNonKeyStreamingChainMode: IBlockChainingModel; +begin +result := TCFB_8Bit.Create +// TCFB_Block is also a reasonable replacement. +end; + + + +constructor TNoncibleDecryptor.Start_Decrypt( + Key1: TSymetricKey; + PlainText1: TStream; const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; + OnSetIV1: TSetMemStreamProc; + AdvancedOptions2: TSymetricEncryptionOptionSet); +begin +inherited Start_EncDec( Key1, Plaintext1, BlockCipher1, Chaining1, False, AdvancedOptions2); +FKey := Key1; + +FPlainText := PlainText1; +FLenBuffer := 0; + +F2ndBuffer := TMemoryStream.Create; +F2ndBuffer.Size := FBlockLen; +Fis2ndBufferFull := False; + +FOnSetIV := OnSetIV1; +FIV.Size := 0; + +FIVSeedLen := Min( FBlockLen, 8); +FSaltLen := 8 - FIVSeedLen; +if FSaltLen > 0 then + begin + FSaltAbsorber := TDesalinationWriteStream.Create; + FSaltAbsorber.FreshwaterStream := FEmissionStream; + FEmissionStream := FSaltAbsorber; + FSaltAbsorber.SaltVolume := FSaltLen + end + else + FSaltAbsorber := nil; +FRemainingSeedLen := FIVSeedLen; +if optSuppressIVSeedPrependage in FAdvancedOptions2 then + FRemainingSeedLen := 0; +FhasCapturedIV := False; + +FisShortMessage := True +end; + + +procedure TNoncibleDecryptor.Decrypt( const Ciphertext: TStream); +var + X: int64; + Amnt: integer; + Tmp: TMemoryStream; +begin +Ciphertext.Position := 0; +X := Ciphertext.Size; +while (X > 0) or (FLenBuffer = FBlockLen) do + begin + + // 1. Read the IV. + if FRemainingSeedLen > 0 then + begin + Amnt := FRemainingSeedLen; + if X < Amnt then + Amnt := X; + if Amnt > 0 then + FIV.CopyFrom( Ciphertext, Amnt); + Dec( X, Amnt); + Dec( FRemainingSeedLen, Amnt); + continue; + end; + + if (FRemainingSeedLen = 0) and (not FhasCapturedIV) then + begin + FhasCapturedIV := True; + GetIV; + continue + end; + + // 2. Now process the payload + Amnt := FBlockLen - FLenBuffer; + if X < Amnt then + Amnt := X; + if Amnt > 0 then + begin + ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); + Dec( X, Amnt); + Inc( FLenBuffer, Amnt); + Inc( FDataCount, Amnt) + end; + if FLenBuffer >= FBlockLen then + FisShortMessage := False; + if (FLenBuffer = FBlockLen) and (not Fis2ndBufferFull) then + begin + Tmp := F2ndBuffer; + F2ndBuffer := FBuffer; + FBuffer := Tmp; + Fis2ndBufferFull := True; + FLenBuffer := 0 + end; + if (FLenBuffer = FBlockLen) and Fis2ndBufferFull then + begin + if not assigned( FChainState) then + FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); + Emit( F2ndBuffer); + Fis2ndBufferFull := False + end + end +end; + + + +procedure TNoncibleDecryptor.End_Decrypt; +var + Actual: IBlockChainingModel; + ChainStateClone: TBlockChainLink; +begin +if FDataCount = 0 then + begin end + + else + begin + if FisShortMessage and (not (cfKeyStream in FChaining.ChainingFeatures)) then + begin + Actual := ShortNonKeyStreamingChainMode; + Fis8bitMode := (cf8bit in Actual.ChainingFeatures) and + (cfKeyStream in Actual.ChainingFeatures) + end + else + Actual := FChaining; + FisAutoXOR := ([cfKeyStream, cfAutoXOR] * Actual.ChainingFeatures) = + [cfKeyStream, cfAutoXOR]; + if not assigned( FChainState) then + FChainState := Actual.Chain_DecryptBlock( FKey, FIV, FCodec); + + if FLenBuffer = 0 then + begin // Round case + Assert( Fis2ndBufferFull, AS_BlockToStream_EndDecrypt_InternalMarshalling); + Emit( F2ndBuffer) + end + + else if cfKeyStream in Actual.ChainingFeatures then + begin // KeyStream case + if Fis2ndBufferFull then + Emit( F2ndBuffer); + Emit_1stBuffer + end + + else + begin // Ciphertext stealing + Assert( Fis2ndBufferFull, AS_BlockToStream_EndDecrypt_InternalMarshalling); + ChainStateClone := FChainState.Clone; + try + Chained_Decrypt_Block( FEmitBuffer, F2ndBuffer); + Move( MemStrmOffset( FEmitBuffer, FLenBuffer)^, + MemStrmOffset( FBuffer, FLenBuffer)^, + FBlockLen - FLenBuffer); // << Reverse the steal! + F2ndBuffer.Position := 0; + FBuffer.Position := 0; + ChainStateClone.Decrypt_Block( F2ndBuffer, FBuffer); + FPlaintext.WriteBuffer( F2ndBuffer .Memory^, FBlockLen); + FPlaintext.WriteBuffer( FEmitBuffer.Memory^, FLenBuffer) + finally + ChainStateClone.Burn; + ChainStateClone.Free + end + end + end; +Reset +end; + + + +procedure TNoncibleDecryptor.GetIV; +var + OldSize: integer; + SizeDiff: integer; +begin + OldSize := FIV.Size; + if OldSize < FBlockLen then + begin + FIV.Size := FBlockLen; + FillChar( MemStrmOffset( FIV, OldSize)^, FBlockLen - OldSize, 0) + end; + if assigned( FOnSetIV) then + begin + FIV.Position := 0; + FOnSetIV( FIV); + SizeDiff := FIV.Size - FBlockLen; + if SizeDiff <> 0 then + FIV.Size := FBlockLen; + if SizeDiff < 0 then + FillChar( MemStrmOffset( FIV, FBlockLen + SizeDiff)^, -SizeDiff, 0); + FIV.Position := 0 + end +end; + +procedure TNoncibleDecryptor.Reset; +begin +inherited Reset; +BurnMemory( F2ndBuffer .Memory^, FBlockLen); +Fis2ndBufferFull := False; +FisShortMessage := True; +BurnMemoryStream( FIV); +if assigned( FChainState) then + begin + FChainState.Burn; + FChainState.Free; + FChainState := nil + end; +FIVSeedLen := Min( FBlockLen, 8); +FSaltLen := 8 - FIVSeedLen; +if FSaltLen > 0 then + FSaltAbsorber.SaltVolume := FSaltLen; +FRemainingSeedLen := FIVSeedLen; +if optSuppressIVSeedPrependage in FAdvancedOptions2 then + FRemainingSeedLen := 0; +FhasCapturedIV := False +end; + + + +destructor TNoncibleDecryptor.Destroy; +begin +BurnMemoryStream( F2ndBuffer); FreeAndNil( F2ndBuffer); +FreeAndNil( FSaltAbsorber); +FDataCount := 0; +inherited +end; + + +{ TEncryptorDecryptor } + +constructor TEncryptorDecryptor.Start_EncDec( + Key1: TSymetricKey; EmissionStream1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel; isEncrypting1: boolean; + AdvancedOptions2: TSymetricEncryptionOptionSet); +begin +FAdvancedOptions2 := AdvancedOptions2; +FEmissionStream := EmissionStream1; +FBlockCipher := BlockCipher1; +FChaining := Chaining1; +FEmitBuffer := TMemoryStream.Create; +FBuffer := TMemoryStream.Create; +FBlockLen := FBlockCipher.BlockSize div 8; +FCodec := FBlockCipher.MakeBlockCodec( Key1); +FBuffer.Size := FBlockLen; +FLenBuffer := 0; +FEmitBuffer.Size := FBlockLen; +FIV := TMemoryStream.Create; +FChainState := nil; +FDataCount := 0; +FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = + [cfKeyStream, cfAutoXOR]; +Fis8bitMode := (cf8bit in FChaining.ChainingFeatures) and + (cfKeyStream in FChaining.ChainingFeatures) and + (not (cfNoNounce in FChaining.ChainingFeatures)); +// A chaining mode with cf8Bit MUST also have +// cfKeyStream and not cfNoNounce +FisEncrypting := isEncrypting1 +end; + + + +procedure TEncryptorDecryptor.Chained_Decrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +begin +Plaintext.Position := 0; +Ciphertext.Position := 0; +FChainState.Decrypt_Block( Plaintext, Ciphertext) +end; + + +procedure TEncryptorDecryptor.Chained_Encrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +begin +Plaintext.Position := 0; +Ciphertext.Position := 0; +FChainState.Encrypt_Block( Plaintext, Ciphertext) +end; + + + +destructor TEncryptorDecryptor.Destroy; +begin +BurnMemoryStream( FEmitBuffer); FEmitBuffer.Free; +BurnMemoryStream( FBuffer); FBuffer.Free; +FCodec.Burn; +FCodec := nil; +if assigned( FChainState) then + begin + FChainState.Burn; + FChainState.Free + end; +BurnMemoryStream( FIV); +FIV.Free; +inherited +end; + + + +procedure TEncryptorDecryptor.Emit( + SourceBuf: TMemoryStream; EmitLen: integer = -1); +var + PlaintextByte, CiphertextByte: byte; + P, Q: PByte; + j: integer; +begin +if EmitLen = -1 then + EmitLen := FBlockLen; +if FisEncrypting then + begin + if Fis8bitMode then + begin + P := SourceBuf.Memory; + Q := FEmitBuffer.Memory; + for j := 0 to EmitLen - 1 do + begin + PlaintextByte := P^; + FChainState.Encrypt_8bit( PlaintextByte, CiphertextByte); + Q^ := CiphertextByte; + Inc( P); Inc( Q) + end + end + else + Chained_Encrypt_Block( SourceBuf, FEmitBuffer) + end + else + begin + if Fis8bitMode then + begin + P := SourceBuf.Memory; + Q := FEmitBuffer.Memory; + for j := 0 to EmitLen - 1 do + begin + CiphertextByte := P^; + FChainState.Decrypt_8bit( PlaintextByte, CiphertextByte); + Q^ := PlaintextByte; + Inc( P); Inc( Q) + end + end + else + Chained_Decrypt_Block( FEmitBuffer, SourceBuf) + end; +if FisAutoXOR then + XOR_Streams2( FEmitBuffer, SourceBuf); +FEmissionStream.WriteBuffer( FEmitBuffer.Memory^, EmitLen) +end; + + + + +procedure TEncryptorDecryptor.Emit_1stBuffer; +begin +if FLenBuffer = 0 then exit; +Emit( FBuffer, FLenBuffer); +FLenBuffer := 0 +end; + + +procedure TEncryptorDecryptor.GetIV; +begin + // TODO +end; + +procedure TEncryptorDecryptor.Reset; +begin +BurnMemory( FEmitBuffer.Memory^, FBlockLen); +BurnMemory( FBuffer .Memory^, FBlockLen); +FCodec.Reset; +FLenBuffer := 0; +FDataCount := 0 +end; + + + + + + + +type +TCSharpStreamToBlock_Adapter = class( TInterfacedObject, + IStreamCipher, ICryptoGraphicAlgorithm, IControlObject) + private + FBlockCipher: IBlockCipher; + FChaining: IBlockChainingModel; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; + + // IControlObject = interface + function ControlObject: TObject; + + public + constructor Create; + end; + +TCSharpDecryptor = class( TInterfacedObject, IStreamDecryptor) + private + FChaining: IBlockChainingModel; + FEmitBuffer: TMemoryStream; + FBuffer: TMemoryStream; + FBlockLen: integer; + FCodec: IBlockCodec; + FBlockCipher: IBlockCipher; + FLenBuffer: integer; + FChainState: TBlockChainLink; + FIV: TMemoryStream; + FDataCount: int64; + FisAutoXOR: boolean; + Fis8bitMode: boolean; + FEmissionStream: TStream; + FKey: TSymetricKey; + + procedure Reset; + procedure Emit( SourceBuf: TMemoryStream; EmitLen: integer = -1); + procedure Emit_1stBuffer; + procedure Chained_Decrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + + public + constructor Start_Decrypt( + Key1: TSymetricKey; EmissionStream1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel); + + destructor Destroy; override; + end; + + +function TCSharpStreamToBlock_Adapter.ControlObject: TObject; +var + ControlObject: IControlObject; +begin +if Supports( FBlockCipher, IControlObject, ControlObject) then + result := ControlObject.ControlObject + else + result := self +end; + + +constructor TCSharpStreamToBlock_Adapter.Create; +begin +end; + +function TCSharpStreamToBlock_Adapter.DefinitionURL: string; +begin +result := '' +end; + + + +function TCSharpStreamToBlock_Adapter.DisplayName: string; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.DisplayName + else + result := BlockCipher_DisplayName + ' CSharp variant' +end; + + + +function TCSharpStreamToBlock_Adapter.Features: TAlgorithmicFeatureSet; +begin +result := [afBlockAdapter, afDoesNotNeedSalt] +end; + + +function TCSharpStreamToBlock_Adapter.GenerateKey( Seed: TStream): TSymetricKey; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.GenerateKey( Seed) + else + result := nil +end; + + +function TCSharpStreamToBlock_Adapter.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +if assigned( FBlockCipher) and assigned( Store) then + result := FBlockCipher.LoadKeyFromStream( Store) + else + result := nil +end; + + +function TCSharpStreamToBlock_Adapter.Parameterize( + const Params: IInterface): IStreamCipher; +var + BlockCipherSelector: IBlockCipherSelector; + //BlockCipherSelectorEx2: IBlockCipherSelectorEx2; + BlockCipher: IBlockCipher; + Chaining: IBlockChainingModel; + Newbie: TCSharpStreamToBlock_Adapter; +begin +result := nil; +if assigned( FBlockCipher) and assigned( FChaining) then exit; +if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then + begin + BlockCipher := BlockCipherSelector.GetBlockCipher; + Chaining := BlockCipherSelector.GetChainMode; + end; +if not (assigned( BlockCipher) or assigned( Chaining)) then exit; +Newbie := TCSharpStreamToBlock_Adapter.Create; +Newbie.FBlockCipher := BlockCipher; +Newbie.FChaining := Chaining; +result := Newbie +end; + + + + +function TCSharpStreamToBlock_Adapter.ProgId: string; +begin +result := 'CSharp.StreamToBlock' +end; + + + +function TCSharpStreamToBlock_Adapter.SeedByteSize: integer; +begin +if assigned( FBlockCipher) then + result := FBlockCipher.SeedByteSize + else + result := -1 +end; + + +procedure NotSupported; +begin +raise Exception.Create('Feature not supported.'); +end; + +function TCSharpStreamToBlock_Adapter.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin + if cfNoNounce in FChaining.ChainingFeatures then + NotSupported + else + result := TCSharpDecryptor.Start_Decrypt( + Key, PlainText, FBlockCipher, FChaining) +end; + + + +function TCSharpStreamToBlock_Adapter.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +NotSupported +end; + + + + + +function TCSharpStreamToBlock_Adapter.WikipediaReference: string; +begin +result := '' +end; + + +constructor TCSharpDecryptor.Start_Decrypt( + Key1: TSymetricKey; EmissionStream1: TStream; + const BlockCipher1: IBlockCipher; + const Chaining1: IBlockChainingModel); +begin +FEmissionStream := EmissionStream1; +FBlockCipher := BlockCipher1; +FChaining := Chaining1; +FEmitBuffer := TMemoryStream.Create; +FBuffer := TMemoryStream.Create; +FBlockLen := FBlockCipher.BlockSize div 8; +FCodec := FBlockCipher.MakeBlockCodec( Key1); +FBuffer.Size := FBlockLen; +FLenBuffer := 0; +FEmitBuffer.Size := FBlockLen; +FIV := TMemoryStream.Create; +FChainState := nil; +FDataCount := 0; +FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = + [cfKeyStream, cfAutoXOR]; +Fis8bitMode := (cf8bit in FChaining.ChainingFeatures) and + (cfKeyStream in FChaining.ChainingFeatures) and + (not (cfNoNounce in FChaining.ChainingFeatures)); +// A chaining mode with cf8Bit MUST also have +// cfKeyStream and not cfNoNounce +FKey := Key1; +FLenBuffer := 0; +FIV.Size := 0; +end; + + + +procedure TCSharpDecryptor.Chained_Decrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +begin +Plaintext.Position := 0; +Ciphertext.Position := 0; +FChainState.Decrypt_Block( Plaintext, Ciphertext) +end; + + +destructor TCSharpDecryptor.Destroy; +begin +FDataCount := 0; +BurnMemoryStream( FEmitBuffer); FEmitBuffer.Free; +BurnMemoryStream( FBuffer); FBuffer.Free; +FCodec.Burn; +FCodec := nil; +if assigned( FChainState) then + begin + FChainState.Burn; + FChainState.Free + end; +BurnMemoryStream( FIV); +FIV.Free; +inherited +end; + + + +procedure TCSharpDecryptor.Emit( + SourceBuf: TMemoryStream; EmitLen: integer = -1); +var + PlaintextByte, CiphertextByte: byte; + P, Q: PByte; + j: integer; +begin +if EmitLen = -1 then + EmitLen := FBlockLen; +if Fis8bitMode then + begin + P := SourceBuf.Memory; + Q := FEmitBuffer.Memory; + for j := 0 to EmitLen - 1 do + begin + CiphertextByte := P^; + FChainState.Decrypt_8bit( PlaintextByte, CiphertextByte); + Q^ := PlaintextByte; + Inc( P); Inc( Q) + end + end + else + Chained_Decrypt_Block( FEmitBuffer, SourceBuf); +if FisAutoXOR then + XOR_Streams2( FEmitBuffer, SourceBuf); +FEmissionStream.WriteBuffer( FEmitBuffer.Memory^, EmitLen) +end; + + + + +procedure TCSharpDecryptor.Emit_1stBuffer; +begin +if FLenBuffer = 0 then exit; +Emit( FBuffer, FLenBuffer); +FLenBuffer := 0 +end; + + +procedure TCSharpDecryptor.Reset; +begin +BurnMemory( FEmitBuffer.Memory^, FBlockLen); +BurnMemory( FBuffer .Memory^, FBlockLen); +FCodec.Reset; +FLenBuffer := 0; +FDataCount := 0; +BurnMemoryStream( FIV); +if assigned( FChainState) then + begin + FChainState.Burn; + FChainState.Free; + FChainState := nil + end +end; + + + + +procedure TCSharpDecryptor.Decrypt( const Ciphertext: TStream); +var + X: int64; + Amnt: integer; + //Tmp: TMemoryStream; + //OldSize: integer; +begin +Ciphertext.Position := 0; +X := Ciphertext.Size; +while (X > 0) or (FLenBuffer = FBlockLen) do + begin + + // 1. Read the IV. + if (FIV.Size < FBlockLen) and (X > 0) then + begin + Amnt := FBlockLen - FIV.Size; + if X < Amnt then + Amnt := X; + FIV.CopyFrom( Ciphertext, Amnt); + Dec( X, Amnt); + continue + end; + + // 2. Now process the payload + Amnt := FBlockLen - FLenBuffer; + if X < Amnt then + Amnt := X; + if Amnt > 0 then + begin + ReadMem( Ciphertext, FBuffer, FLenBuffer, Amnt); + Dec( X, Amnt); + Inc( FLenBuffer, Amnt); + Inc( FDataCount, Amnt) + end; + if FLenBuffer = FBlockLen then + begin + if not assigned( FChainState) then + FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); + Emit_1stBuffer + end + end +end; + + + +procedure TCSharpDecryptor.End_Decrypt; +//var +// ChainStateClone: TBlockChainLink; +begin +if FDataCount = 0 then + begin end + else + begin + FisAutoXOR := ([cfKeyStream, cfAutoXOR] * FChaining.ChainingFeatures) = + [cfKeyStream, cfAutoXOR]; + if not assigned( FChainState) then + FChainState := FChaining.Chain_DecryptBlock( FKey, FIV, FCodec); + if (FLenBuffer = 0) or (cfKeyStream in FChaining.ChainingFeatures) then + Emit_1stBuffer + else + begin + Reset; + raise Exception.Create('Ciphertext not zero padded'); + end + end; +Reset +end; + + + +function StreamToBlock_Adapter_CSharpVariant: IStreamCipher; +begin +result := TCSharpStreamToBlock_Adapter.Create +end; + +end. diff --git a/run/TPLB3.StreamUtils.pas b/LockBox3/run/TPLB3.StreamUtils.pas similarity index 96% rename from run/TPLB3.StreamUtils.pas rename to LockBox3/run/TPLB3.StreamUtils.pas index ae8d266..682c56a 100644 --- a/run/TPLB3.StreamUtils.pas +++ b/LockBox3/run/TPLB3.StreamUtils.pas @@ -1,610 +1,611 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2009 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.StreamUtils; -interface -uses Classes, SysUtils; - -const - Base64Chars: string = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - // You can implement non-standard variants to base64 transformation, - // by passing a string like the above one into the base64 transform functions - // below. -type - TInverseBaseTransform = array[ Byte] of byte; - -TDesalinationWriteStream = class( TStream) - private - FFreshwaterStream: TStream; - FSaltVolume: integer; - - protected - function GetSize: Int64; override; - procedure SetSize( const NewSize: Int64); override; - - public - function Read( var Buffer; Count: Longint): Longint; override; - function Write( const Buffer; Count: Longint): Longint; override; - function Seek( const Offset: Int64; Origin: TSeekOrigin): Int64; override; - - property FreshwaterStream: TStream read FFreshwaterStream write FFreshwaterStream; - property SaltVolume: integer read FSaltVolume write FSaltVolume; - end; - - - -function CloneMemoryStream( Original: TMemoryStream): TMemoryStream; -procedure CopyMemoryStream( Source, Destination: TMemoryStream); -procedure BurnMemoryStream( Destructo: TMemoryStream); -procedure BurnMemory( var Buff; BuffLen: integer); -procedure ZeroFillStream( Stream: TMemoryStream); -procedure RandomFillStream( Stream: TMemoryStream); - -procedure XOR_Streams2( Dest, Srce: TMemoryStream); // Dest := Dest xor Srce -procedure XOR_Streams3( Dest, SrceA, SrceB: TMemoryStream); // Dest := SrceB xor SrceB - -function CompareMemoryStreams( S1, S2: TMemoryStream): boolean; - -function Stream_to_Base64( Source: TStream; const Transform: string = ''): string; - -procedure Base64_to_stream( const Base64: string; Destin: TStream); - -procedure CustomBase64_to_stream( const Base64: string; Destin: TStream; - const InverseTransform: TInverseBaseTransform); - -/// -/// On entry, Source position is reset to zero. -/// -function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}): string; overload; -function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}; Count: Longint): string; overload; -/// -/// Destin is NOT repositioned. The write occurs at the point of the entry Destin.Position -/// -procedure String_to_stream( const Value: string; Destin: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); overload; -{$IFDEF UNICODE} -function Stream_to_utf8string( Source: TStream): string; deprecated; -procedure utf8string_to_stream( const Value: string; Destin: TStream); deprecated; -{$ENDIF} - - -function CompareFiles( const FN1, FN2: string; - Breathe: TNotifyEvent; BreathingSender: TObject): boolean; -function FileSize( const FileName: string): int64; - -// For debug purposes ONLY: -function Stream_to_decimalbytes( Source: TStream): string; -function DisplayStream( Stream: TStream): string; - -implementation - - - - - - - - - -uses Math, TPLB3.Random, TPLB3.IntegerUtils, TPLB3.Compatibility; - - - - -var - Inverse_Base64Chars: TInverseBaseTransform; - -procedure Invert_Base64Chars; forward; - -procedure InitUnit_StreamUtils; -begin -Invert_Base64Chars; -end; - -procedure DoneUnit_StreamUtils; -begin -end; - - -procedure BurnMemory( var Buff; BuffLen: integer); -begin -FillChar( Buff, BuffLen, 0) -end; - - -procedure ZeroFillStream( Stream: TMemoryStream); -var - L: integer; -begin -if assigned( Stream) then - L := Stream.Size - else - L := 0; -if L <= 0 then exit; -FillChar( Stream.Memory^, L, 0) -end; - - - -procedure RandomFillStream( Stream: TMemoryStream); -begin -if assigned( Stream) and (Stream.Size > 0) then - TRandomStream.Instance.Read( Stream.Memory^, Stream.Size) -end; - - -function CloneMemoryStream( Original: TMemoryStream): TMemoryStream; -var - L: integer; -begin -if assigned( Original) then - L := Original.Size - else - L := 0; -result := TMemoryStream.Create; -result.Size := L; -if L <= 0 then exit; -Move( Original.Memory^, result.Memory^, L); -result.Position := Original.Position -end; - - -procedure BurnMemoryStream( Destructo: TMemoryStream); -var - L: integer; -begin -if not assigned( Destructo) then exit; -L := Destructo.Size; -if L <= 0 then exit; -BurnMemory( Destructo.Memory^, L); -Destructo.Size := 0 -end; - - - -procedure XOR_Streams2( Dest, Srce: TMemoryStream); // Dest := Dest xor Srce -var - L: integer; - j: Integer; - DestP, SrceP: PByte; - DestP32, SrceP32: ^uint32; -begin -if assigned( Dest) and assigned( Srce) then - L := Min( Dest.Size, Srce.Size) - else - L := 0; -if L <= 0 then exit; -DestP32 := Dest.Memory; -SrceP32 := Srce.Memory; -for j := 0 to (L div 4) - 1 do - begin // Do as much as we can in 32 bit. It is faster. - DestP32^ := DestP32^ xor SrceP32^; - Inc( DestP32); - Inc( SrceP32) - end; -DestP := PByte( DestP32); -SrceP := PByte( SrceP32); -for j := 0 to (L mod 4) - 1 do - begin // And the remainder in 8 bit. - DestP^ := DestP^ xor SrceP^; - Inc( DestP); - Inc( SrceP) - end -end; - - - -procedure XOR_Streams3( Dest, SrceA, SrceB: TMemoryStream); // Dest := SrceB xor SrceB -var - L: integer; - j: Integer; - DestP, SrceAP, SrceBP: PByte; - DestP32, SrceAP32, SrceBP32: ^uint32; -begin -if assigned( Dest) and assigned( SrceA) and assigned( SrceB) then - L := Min( Min( Dest.Size, SrceA.Size), SrceB.Size) - else - L := 0; -if L <= 0 then exit; -DestP32 := Dest.Memory; -SrceAP32 := SrceA.Memory; -SrceBP32 := SrceB.Memory; -for j := 0 to (L div 4) - 1 do - begin // Do as much as we can in 32 bit. It is faster. - DestP32^ := SrceAP32^ xor SrceBP32^; - Inc( DestP32); - Inc( SrceAP32); - Inc( SrceBP32) - end; -DestP := PByte( DestP32); -SrceAP := PByte( SrceAP32); -SrceBP := PByte( SrceBP32); -for j := 0 to (L mod 4) - 1 do - begin - DestP^ := SrceAP^ xor SrceBP^; - Inc( DestP); - Inc( SrceAP); - Inc( SrceBP) - end -end; - - -function CompareMemoryStreams( S1, S2: TMemoryStream): boolean; -var - L: integer; -begin -L := S1.Size; -result := (L = S2.Size) and ((L = 0) or (CompareMem( S1.Memory, S2.Memory, L))) -end; - - - -procedure CopyMemoryStream( Source, Destination: TMemoryStream); -var - L: integer; -begin -L := Source.Size; -Destination.Size := L; -if L > 0 then - Move( Source.Memory^, Destination.Memory^, L) -end; - - - -function Stream_to_Base64( Source: TStream; const Transform: string = ''): string; -var - ThreeBytes: packed array[ 0..2 ] of byte; - BytesRead: integer; - P, j, i: integer; - Base64Transform: string; -begin -Base64Transform := Transform; -if Base64Transform = '' then - Base64Transform := Base64Chars; -SetLength( result, (Source.Size + 2) div 3 * 4); -Source.Position := 0; -P := {$IFDEF STRINGHELPER}Low( Result){$ELSE}1{$ENDIF}; -repeat - BytesRead := Source.Read( ThreeBytes, 3); - if BytesRead = 0 then break; - for j := BytesRead to 2 do - ThreeBytes[j] := 0; - for j := 0 to BytesRead do - begin - {$IFDEF STRINGHELPER} - result[ P ] := Base64Transform.Chars[ ThreeBytes[0] shr 2]; - {$ELSE} - result[ P ] := Base64Transform[ ( ThreeBytes[0] shr 2) + 1]; - {$ENDIF} - Inc( P); - for i := 0 to 1 do - ThreeBytes[i] := (ThreeBytes[i] shl 6) + (ThreeBytes[i+1] shr 2); - ThreeBytes[ 2] := ThreeBytes[ 2] shl 6 - end -until BytesRead < 3; -if BytesRead > 0 then - for j := BytesRead to 2 do - begin - result[ P] := '='; - Inc( P) - end -end; - - -procedure Base64_to_stream( const Base64: string; Destin: TStream); -begin -CustomBase64_to_stream( Base64, Destin, Inverse_Base64Chars) -end; - - -procedure CustomBase64_to_stream( const Base64: string; Destin: TStream; - const InverseTransform: TInverseBaseTransform); -var - P, j, i: integer; - Ch: Char; - Bits6: byte; - ThreeBytes: packed array[ 0..2 ] of byte; - ByteIdx, BitIdx: integer; -// ShrN: integer; - Addend: byte; -begin -// Assume Destin is already at the desired postion and size. -for P := 0 to (Length( Base64) div 4) - 1 do - begin - for i := 0 to 2 do ThreeBytes[i] := 0; - ByteIdx := 0; - BitIdx := 0; - for j := 1 to 4 do - begin - {$IFDEF STRINGHELPER} - Ch := Base64.Chars[ P * 4 + j - 1]; - {$ELSE} - Ch := Base64[ P * 4 + j]; - {$ENDIF} - if Ch = '=' then break; - Bits6 := InverseTransform[ Ord( Ch)]; -// ShrN := BitIdx - 2; - if BitIdx > 2 then - Addend := Bits6 shr (BitIdx - 2) - else if BitIdx = 2 then - Addend := Bits6 - else - Addend := Bits6 shl (2 - BitIdx); - ThreeBytes[ ByteIdx ] := ThreeBytes[ ByteIdx ] + Addend; - Inc( BitIdx, 6); - if BitIdx >= 8 then - begin - Dec( BitIdx, 8); - Inc( ByteIdx); - if BitIdx > 0 then - ThreeBytes[ByteIdx] := ThreeBytes[ByteIdx] + (Bits6 shl (8 - BitIdx)); - end - end; - Destin.WriteBuffer( ThreeBytes, ByteIdx) - end -end; - - -procedure Invert_Base64Chars; -var - j: integer; - ch: Byte; -begin -for ch := Low( Inverse_Base64Chars) to High( Inverse_Base64Chars) do - Inverse_Base64Chars[ ch] := 255; -for j := 1 to Length( Base64Chars) do - begin - {$IFDEF STRINGHELPER} - ch := Ord( Base64Chars.Chars[ j - 1]); - {$ELSE} - ch := Ord( Base64Chars[ j]); - {$ENDIF} - Inverse_Base64Chars[ ch] := j - 1 - end -end; - - -function Stream_to_string( Source: TStream; {$IFDEF UNICODE}Encoding: TEncoding;{$ENDIF} Count: Longint): string; -{$IFDEF UNICODE} -var - SourceBytes: TBytes; -{$ENDIF} -begin -if Count <> 0 then - begin - Source.Position := 0; - {$IFDEF UNICODE} - SetLength( SourceBytes, Count); - Source.ReadBuffer( SourceBytes[0], Count); - result := Encoding.GetString( SourceBytes); - {$ELSE} - SetLength( Result, Count); - Source.ReadBuffer( result[1], Count); - {$ENDIF} - end -end; - - -function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}): string; -begin - Result := Stream_to_string( Source{$IFDEF UNICODE}, Encoding{$ENDIF}, Source.Size); -end; - - -{$IFDEF UNICODE} -function Stream_to_utf8string( Source: TStream): string; -begin - Result := Stream_to_string( Source, TEncoding.UTF8); -end; -{$ENDIF} - - -procedure String_to_stream( const Value: string; Destin: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); -{$IFDEF UNICODE} -var - ValueBytes: TBytes; -{$ENDIF} -begin -if Value <> '' then - begin - {$IFDEF UNICODE} - ValueBytes := Encoding.GetBytes( Value); - Destin.WriteBuffer( ValueBytes[0], Length( ValueBytes)) - {$ELSE} - Destin.WriteBuffer( Value[1], Length( Value)) - {$ENDIF} - end -end; - - -{$IFDEF UNICODE} -procedure utf8string_to_stream( const Value: string; Destin: TStream); -begin - String_to_stream( Value, Destin, TEncoding.UTF8); -end; -{$ENDIF} - - -{ TDesalinationWriteStream } - -function TDesalinationWriteStream.GetSize: Int64; -begin -result := 0 -end; - -function TDesalinationWriteStream.Read( var Buffer; Count: Integer): Longint; -begin -result := 0 -end; - - - -function TDesalinationWriteStream.Seek( - const Offset: Int64; Origin: TSeekOrigin): Int64; -begin -if assigned( FFreshwaterStream) then - result := FFreshwaterStream.Seek( Offset, Origin) - else - result := 0 -end; - - - -procedure TDesalinationWriteStream.SetSize( const NewSize: Int64); -begin -end; - - -function TDesalinationWriteStream.Write( const Buffer; Count: Integer): Longint; -var - P: PByte; - C: integer; - SaltConsumption: integer; -begin -result := 0; -P := @Buffer; -C := Count; -if C <= 0 then exit; -SaltConsumption := Min( FSaltVolume, C); -if SaltConsumption > 0 then - begin - Dec( FSaltVolume, SaltConsumption); - Inc( P, SaltConsumption); - Dec( C, SaltConsumption); - result := SaltConsumption - end; -if (C > 0) and assigned( FFreshwaterStream) then - Inc( result, FFreshwaterStream.Write( P^, C)) -end; - - -function Stream_to_decimalbytes( Source: TStream): string; -var - b: byte; -begin -Source.Position := 0; -result := ''; -while Source.Read( b, 1) > 0 do - begin - if result <> '' then - result := result + ', '; - result := result + Format( '%d', [b]) - end -end; - - -function CompareFiles( const FN1, FN2: string; - Breathe: TNotifyEvent; BreathingSender: TObject): boolean; -const - BufferSizeInBytes = 1024; -var - Stream1, Stream2: TStream; - Buffer1, Buffer2: TBytes; - Count1, Count2, L: integer; -begin -Stream1 := TFileStream.Create( FN1, fmOpenRead); -Stream2 := TFileStream.Create( FN2, fmOpenRead); -try - result := Stream1.Size = Stream2.Size; - L := BufferSizeInBytes; - SetLength( Buffer1, L); - SetLength( Buffer2, L); - if result then - repeat - Count1 := Stream1.Read( Buffer1[0], L); - Count2 := Stream2.Read( Buffer2[0], L); - result := (Count1 = Count2) and CompareMem( - Buffer1, Buffer2, Count1); - if assigned( Breathe) then - Breathe( BreathingSender) - // Breathe should do something like Application.ProcessMessages(); - until (not result) or (Count1 < L) -finally - Stream1.Free; - Stream2.Free - end -end; - - -function FileSize( const FileName: string): int64; -var - FileStream: TStream; -begin -if not FileExists( FileName) then - result := 0 - else - try - FileStream := TFileStream.Create( FileName, fmOpenRead); - try - result := FileStream.Size - finally - FileStream.Free - end - except - result := 0 - end; -end; - - -function DisplayStream( Stream: TStream): string; -var - P, Sz: integer; - aByte: byte; - s: string; -begin -if not assigned( Stream) then - result := 'nil' - else - begin - P := Stream.Position; - Sz := Stream.Size; - Stream.Position := 0; - result := Format( 'stream[%d]=', [Sz]); - while Stream.Read( aByte, 1) = 1 do - begin - s := Format( '%2x', [aByte]); - if s[1]=' ' then - s[1] := '0'; - result := result + ' ' + s - end; - Stream.Position := P - end -end; - - -initialization -InitUnit_StreamUtils; - -finalization -DoneUnit_StreamUtils; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2009 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.StreamUtils; +{$R-} +interface +uses Classes, SysUtils; + +const + Base64Chars: string = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + // You can implement non-standard variants to base64 transformation, + // by passing a string like the above one into the base64 transform functions + // below. +type + TInverseBaseTransform = array[ Byte] of byte; + +TDesalinationWriteStream = class( TStream) + private + FFreshwaterStream: TStream; + FSaltVolume: integer; + + protected + function GetSize: Int64; override; + procedure SetSize( const NewSize: Int64); override; + + public + function Read( var Buffer; Count: Longint): Longint; override; + function Write( const Buffer; Count: Longint): Longint; override; + function Seek( const Offset: Int64; Origin: TSeekOrigin): Int64; override; + + property FreshwaterStream: TStream read FFreshwaterStream write FFreshwaterStream; + property SaltVolume: integer read FSaltVolume write FSaltVolume; + end; + + + +function CloneMemoryStream( Original: TMemoryStream): TMemoryStream; +procedure CopyMemoryStream( Source, Destination: TMemoryStream); +procedure BurnMemoryStream( Destructo: TMemoryStream); +procedure BurnMemory( var Buff; BuffLen: integer); +procedure ZeroFillStream( Stream: TMemoryStream); +procedure RandomFillStream( Stream: TMemoryStream); + +procedure XOR_Streams2( Dest, Srce: TMemoryStream); // Dest := Dest xor Srce +procedure XOR_Streams3( Dest, SrceA, SrceB: TMemoryStream); // Dest := SrceB xor SrceB + +function CompareMemoryStreams( S1, S2: TMemoryStream): boolean; + +function Stream_to_Base64( Source: TStream; const Transform: string = ''): string; + +procedure Base64_to_stream( const Base64: string; Destin: TStream); + +procedure CustomBase64_to_stream( const Base64: string; Destin: TStream; + const InverseTransform: TInverseBaseTransform); + +/// +/// On entry, Source position is reset to zero. +/// +function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}): string; overload; +function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}; Count: Longint): string; overload; +/// +/// Destin is NOT repositioned. The write occurs at the point of the entry Destin.Position +/// +procedure String_to_stream( const Value: string; Destin: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); overload; +{$IFDEF UNICODE} +function Stream_to_utf8string( Source: TStream): string; deprecated; +procedure utf8string_to_stream( const Value: string; Destin: TStream); deprecated; +{$ENDIF} + + +function CompareFiles( const FN1, FN2: string; + Breathe: TNotifyEvent; BreathingSender: TObject): boolean; +function FileSize( const FileName: string): int64; + +// For debug purposes ONLY: +function Stream_to_decimalbytes( Source: TStream): string; +function DisplayStream( Stream: TStream): string; + +implementation + + + + + + + + + +uses Math, TPLB3.Random, TPLB3.IntegerUtils, TPLB3.Compatibility; + + + + +var + Inverse_Base64Chars: TInverseBaseTransform; + +procedure Invert_Base64Chars; forward; + +procedure InitUnit_StreamUtils; +begin +Invert_Base64Chars; +end; + +procedure DoneUnit_StreamUtils; +begin +end; + + +procedure BurnMemory( var Buff; BuffLen: integer); +begin +FillChar( Buff, BuffLen, 0) +end; + + +procedure ZeroFillStream( Stream: TMemoryStream); +var + L: integer; +begin +if assigned( Stream) then + L := Stream.Size + else + L := 0; +if L <= 0 then exit; +FillChar( Stream.Memory^, L, 0) +end; + + + +procedure RandomFillStream( Stream: TMemoryStream); +begin +if assigned( Stream) and (Stream.Size > 0) then + TRandomStream.Instance.Read( Stream.Memory^, Stream.Size) +end; + + +function CloneMemoryStream( Original: TMemoryStream): TMemoryStream; +var + L: integer; +begin +if assigned( Original) then + L := Original.Size + else + L := 0; +result := TMemoryStream.Create; +result.Size := L; +if L <= 0 then exit; +Move( Original.Memory^, result.Memory^, L); +result.Position := Original.Position +end; + + +procedure BurnMemoryStream( Destructo: TMemoryStream); +var + L: integer; +begin +if not assigned( Destructo) then exit; +L := Destructo.Size; +if L <= 0 then exit; +BurnMemory( Destructo.Memory^, L); +Destructo.Size := 0 +end; + + + +procedure XOR_Streams2( Dest, Srce: TMemoryStream); // Dest := Dest xor Srce +var + L: integer; + j: Integer; + DestP, SrceP: PByte; + DestP32, SrceP32: ^uint32; +begin +if assigned( Dest) and assigned( Srce) then + L := Min( Dest.Size, Srce.Size) + else + L := 0; +if L <= 0 then exit; +DestP32 := Dest.Memory; +SrceP32 := Srce.Memory; +for j := 0 to (L div 4) - 1 do + begin // Do as much as we can in 32 bit. It is faster. + DestP32^ := DestP32^ xor SrceP32^; + Inc( DestP32); + Inc( SrceP32) + end; +DestP := PByte( DestP32); +SrceP := PByte( SrceP32); +for j := 0 to (L mod 4) - 1 do + begin // And the remainder in 8 bit. + DestP^ := DestP^ xor SrceP^; + Inc( DestP); + Inc( SrceP) + end +end; + + + +procedure XOR_Streams3( Dest, SrceA, SrceB: TMemoryStream); // Dest := SrceB xor SrceB +var + L: integer; + j: Integer; + DestP, SrceAP, SrceBP: PByte; + DestP32, SrceAP32, SrceBP32: ^uint32; +begin +if assigned( Dest) and assigned( SrceA) and assigned( SrceB) then + L := Min( Min( Dest.Size, SrceA.Size), SrceB.Size) + else + L := 0; +if L <= 0 then exit; +DestP32 := Dest.Memory; +SrceAP32 := SrceA.Memory; +SrceBP32 := SrceB.Memory; +for j := 0 to (L div 4) - 1 do + begin // Do as much as we can in 32 bit. It is faster. + DestP32^ := SrceAP32^ xor SrceBP32^; + Inc( DestP32); + Inc( SrceAP32); + Inc( SrceBP32) + end; +DestP := PByte( DestP32); +SrceAP := PByte( SrceAP32); +SrceBP := PByte( SrceBP32); +for j := 0 to (L mod 4) - 1 do + begin + DestP^ := SrceAP^ xor SrceBP^; + Inc( DestP); + Inc( SrceAP); + Inc( SrceBP) + end +end; + + +function CompareMemoryStreams( S1, S2: TMemoryStream): boolean; +var + L: integer; +begin +L := S1.Size; +result := (L = S2.Size) and ((L = 0) or (CompareMem( S1.Memory, S2.Memory, L))) +end; + + + +procedure CopyMemoryStream( Source, Destination: TMemoryStream); +var + L: integer; +begin +L := Source.Size; +Destination.Size := L; +if L > 0 then + Move( Source.Memory^, Destination.Memory^, L) +end; + + + +function Stream_to_Base64( Source: TStream; const Transform: string = ''): string; +var + ThreeBytes: packed array[ 0..2 ] of byte; + BytesRead: integer; + P, j, i: integer; + Base64Transform: string; +begin +Base64Transform := Transform; +if Base64Transform = '' then + Base64Transform := Base64Chars; +SetLength( result, (Source.Size + 2) div 3 * 4); +Source.Position := 0; +P := {$IFDEF STRINGHELPER}Low( Result){$ELSE}1{$ENDIF}; +repeat + BytesRead := Source.Read( ThreeBytes, 3); + if BytesRead = 0 then break; + for j := BytesRead to 2 do + ThreeBytes[j] := 0; + for j := 0 to BytesRead do + begin + {$IFDEF STRINGHELPER} + result[ P ] := Base64Transform.Chars[ ThreeBytes[0] shr 2]; + {$ELSE} + result[ P ] := Base64Transform[ ( ThreeBytes[0] shr 2) + 1]; + {$ENDIF} + Inc( P); + for i := 0 to 1 do + ThreeBytes[i] := (ThreeBytes[i] shl 6) + (ThreeBytes[i+1] shr 2); + ThreeBytes[ 2] := ThreeBytes[ 2] shl 6 + end +until BytesRead < 3; +if BytesRead > 0 then + for j := BytesRead to 2 do + begin + result[ P] := '='; + Inc( P) + end +end; + + +procedure Base64_to_stream( const Base64: string; Destin: TStream); +begin +CustomBase64_to_stream( Base64, Destin, Inverse_Base64Chars) +end; + + +procedure CustomBase64_to_stream( const Base64: string; Destin: TStream; + const InverseTransform: TInverseBaseTransform); +var + P, j, i: integer; + Ch: Char; + Bits6: byte; + ThreeBytes: packed array[ 0..2 ] of byte; + ByteIdx, BitIdx: integer; +// ShrN: integer; + Addend: byte; +begin +// Assume Destin is already at the desired postion and size. +for P := 0 to (Length( Base64) div 4) - 1 do + begin + for i := 0 to 2 do ThreeBytes[i] := 0; + ByteIdx := 0; + BitIdx := 0; + for j := 1 to 4 do + begin + {$IFDEF STRINGHELPER} + Ch := Base64.Chars[ P * 4 + j - 1]; + {$ELSE} + Ch := Base64[ P * 4 + j]; + {$ENDIF} + if Ch = '=' then break; + Bits6 := InverseTransform[ Ord( Ch)]; +// ShrN := BitIdx - 2; + if BitIdx > 2 then + Addend := Bits6 shr (BitIdx - 2) + else if BitIdx = 2 then + Addend := Bits6 + else + Addend := Bits6 shl (2 - BitIdx); + ThreeBytes[ ByteIdx ] := ThreeBytes[ ByteIdx ] + Addend; + Inc( BitIdx, 6); + if BitIdx >= 8 then + begin + Dec( BitIdx, 8); + Inc( ByteIdx); + if BitIdx > 0 then + ThreeBytes[ByteIdx] := ThreeBytes[ByteIdx] + (Bits6 shl (8 - BitIdx)); + end + end; + Destin.WriteBuffer( ThreeBytes, ByteIdx) + end +end; + + +procedure Invert_Base64Chars; +var + j: integer; + ch: Byte; +begin +for ch := Low( Inverse_Base64Chars) to High( Inverse_Base64Chars) do + Inverse_Base64Chars[ ch] := 255; +for j := 1 to Length( Base64Chars) do + begin + {$IFDEF STRINGHELPER} + ch := Ord( Base64Chars.Chars[ j - 1]); + {$ELSE} + ch := Ord( Base64Chars[ j]); + {$ENDIF} + Inverse_Base64Chars[ ch] := j - 1 + end +end; + + +function Stream_to_string( Source: TStream; {$IFDEF UNICODE}Encoding: TEncoding;{$ENDIF} Count: Longint): string; +{$IFDEF UNICODE} +var + SourceBytes: TBytes; +{$ENDIF} +begin +if Count <> 0 then + begin + Source.Position := 0; + {$IFDEF UNICODE} + SetLength( SourceBytes, Count); + Source.ReadBuffer( SourceBytes[0], Count); + result := Encoding.GetString( SourceBytes); + {$ELSE} + SetLength( Result, Count); + Source.ReadBuffer( result[1], Count); + {$ENDIF} + end +end; + + +function Stream_to_string( Source: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}): string; +begin + Result := Stream_to_string( Source{$IFDEF UNICODE}, Encoding{$ENDIF}, Source.Size); +end; + + +{$IFDEF UNICODE} +function Stream_to_utf8string( Source: TStream): string; +begin + Result := Stream_to_string( Source, TEncoding.UTF8); +end; +{$ENDIF} + + +procedure String_to_stream( const Value: string; Destin: TStream{$IFDEF UNICODE}; Encoding: TEncoding{$ENDIF}); +{$IFDEF UNICODE} +var + ValueBytes: TBytes; +{$ENDIF} +begin +if Value <> '' then + begin + {$IFDEF UNICODE} + ValueBytes := Encoding.GetBytes( Value); + Destin.WriteBuffer( ValueBytes[0], Length( ValueBytes)) + {$ELSE} + Destin.WriteBuffer( Value[1], Length( Value)) + {$ENDIF} + end +end; + + +{$IFDEF UNICODE} +procedure utf8string_to_stream( const Value: string; Destin: TStream); +begin + String_to_stream( Value, Destin, TEncoding.UTF8); +end; +{$ENDIF} + + +{ TDesalinationWriteStream } + +function TDesalinationWriteStream.GetSize: Int64; +begin +result := 0 +end; + +function TDesalinationWriteStream.Read( var Buffer; Count: Integer): Longint; +begin +result := 0 +end; + + + +function TDesalinationWriteStream.Seek( + const Offset: Int64; Origin: TSeekOrigin): Int64; +begin +if assigned( FFreshwaterStream) then + result := FFreshwaterStream.Seek( Offset, Origin) + else + result := 0 +end; + + + +procedure TDesalinationWriteStream.SetSize( const NewSize: Int64); +begin +end; + + +function TDesalinationWriteStream.Write( const Buffer; Count: Integer): Longint; +var + P: PByte; + C: integer; + SaltConsumption: integer; +begin +result := 0; +P := @Buffer; +C := Count; +if C <= 0 then exit; +SaltConsumption := Min( FSaltVolume, C); +if SaltConsumption > 0 then + begin + Dec( FSaltVolume, SaltConsumption); + Inc( P, SaltConsumption); + Dec( C, SaltConsumption); + result := SaltConsumption + end; +if (C > 0) and assigned( FFreshwaterStream) then + Inc( result, FFreshwaterStream.Write( P^, C)) +end; + + +function Stream_to_decimalbytes( Source: TStream): string; +var + b: byte; +begin +Source.Position := 0; +result := ''; +while Source.Read( b, 1) > 0 do + begin + if result <> '' then + result := result + ', '; + result := result + Format( '%d', [b]) + end +end; + + +function CompareFiles( const FN1, FN2: string; + Breathe: TNotifyEvent; BreathingSender: TObject): boolean; +const + BufferSizeInBytes = 1024; +var + Stream1, Stream2: TStream; + Buffer1, Buffer2: TBytes; + Count1, Count2, L: integer; +begin +Stream1 := TFileStream.Create( FN1, fmOpenRead); +Stream2 := TFileStream.Create( FN2, fmOpenRead); +try + result := Stream1.Size = Stream2.Size; + L := BufferSizeInBytes; + SetLength( Buffer1, L); + SetLength( Buffer2, L); + if result then + repeat + Count1 := Stream1.Read( Buffer1[0], L); + Count2 := Stream2.Read( Buffer2[0], L); + result := (Count1 = Count2) and CompareMem( + Buffer1, Buffer2, Count1); + if assigned( Breathe) then + Breathe( BreathingSender) + // Breathe should do something like Application.ProcessMessages(); + until (not result) or (Count1 < L) +finally + Stream1.Free; + Stream2.Free + end +end; + + +function FileSize( const FileName: string): int64; +var + FileStream: TStream; +begin +if not FileExists( FileName) then + result := 0 + else + try + FileStream := TFileStream.Create( FileName, fmOpenRead); + try + result := FileStream.Size + finally + FileStream.Free + end + except + result := 0 + end; +end; + + +function DisplayStream( Stream: TStream): string; +var + P, Sz: integer; + aByte: byte; + s: string; +begin +if not assigned( Stream) then + result := 'nil' + else + begin + P := Stream.Position; + Sz := Stream.Size; + Stream.Position := 0; + result := Format( 'stream[%d]=', [Sz]); + while Stream.Read( aByte, 1) = 1 do + begin + s := Format( '%2x', [aByte]); + if s[1]=' ' then + s[1] := '0'; + result := result + ' ' + s + end; + Stream.Position := P + end +end; + + +initialization +InitUnit_StreamUtils; + +finalization +DoneUnit_StreamUtils; + +end. diff --git a/run/TPLB3.TDES.pas b/LockBox3/run/TPLB3.TDES.pas similarity index 96% rename from run/TPLB3.TDES.pas rename to LockBox3/run/TPLB3.TDES.pas index 901244e..995ad44 100644 --- a/run/TPLB3.TDES.pas +++ b/LockBox3/run/TPLB3.TDES.pas @@ -1,442 +1,442 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.TDES; -interface -uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher; - -type - -T3DES = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm) - private - function DisplayName: string; virtual; - function ProgId: string; virtual; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; virtual; - function LoadKeyFromStream( Store: TStream): TSymetricKey; virtual; - function BlockSize: integer; virtual; // in units of bits. Must be a multiple of 8. - function KeySize: integer; virtual; - function SeedByteSize: integer; virtual; // Size that the input of the GenerateKey must be. - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; virtual; - function SelfTest_Key: string; virtual; - function SelfTest_Plaintext: string; virtual; - function SelfTest_Ciphertext: string; virtual; - - public - constructor Create; virtual; - end; - - -T3DES_KO1 = class( T3DES) - private - function DisplayName: string; override; - function ProgId: string; override; - function GenerateKey( Seed: TStream): TSymetricKey; override; - function LoadKeyFromStream( Store: TStream): TSymetricKey; override; - function KeySize: integer; override; - function SeedByteSize: integer; override; - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; override; - function SelfTest_Key: string; override; - function SelfTest_Plaintext: string; override; - function SelfTest_Ciphertext: string; override; - end; - - -implementation - - - - -uses TPLB3.Constants, TPLB3.DES, SysUtils, TPLB3.I18n; -{ TDES } - - -type -T3DESKey = class( TSymetricKey) - protected - FNativeKey1, FNativeKey2: uint64; - FExpandedKey1, FExpandedKey2: TExpandedKey; - - public - constructor Create( NativeKey1, NativeKey2: uint64); - constructor CreateFromStream( Store: TStream); virtual; - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -T3DESKey_KO1 = class( T3DESKey) - private - FNativeKey3: uint64; - FExpandedKey3: TExpandedKey; - - public - constructor Create( NativeKey1, NativeKey2, NativeKey3: uint64); - constructor CreateFromStream( Store: TStream); override; - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - - -T3DESCodec = class( TInterfacedObject, IBlockCodec) - protected - FLockBoxKey: T3DESKey; - - constructor Create( LockBoxKey1: T3DESKey); - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); virtual; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); virtual; - procedure Reset; virtual; - procedure Burn; virtual; - end; - -T3DESCodec_KO1 = class( T3DESCodec) - private - FLockBoxKey_KO1: T3DESKey_KO1; - - constructor Create( LockBoxKey1: T3DESKey_KO1); - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; - end; - - -function T3DES.BlockSize: integer; -begin -result := 64 -end; - -constructor T3DES.Create; -begin -end; - -function T3DES.DefinitionURL: string; -begin -result := 'http://csrc.nist.gov/publications/drafts/800-67-rev1/SP-800-67-rev1-2_July-2011.pdf' -end; - -function T3DES.DisplayName: string; -begin -result := '3DES (Keying option 2)' -end; - -function T3DES.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - - -function T3DES.GenerateKey( Seed: TStream): TSymetricKey; -var - SeedKey1, SeedKey2: uint64; -begin -Seed.ReadBuffer( SeedKey1, 8); -Seed.ReadBuffer( SeedKey2, 8); -result := T3DESKey.Create( SeedKey1, SeedKey2) -end; - -function T3DES.KeySize: integer; -begin -result := 80 -// Quote from wikipedia: -// Keying option 2 reduces the key size to 112 bits. However, this option -// is susceptible to certain chosen-plaintext or known-plaintext attacks -// and thus it is designated by NIST to have only 80 bits of security. -end; - -function T3DES.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := T3DESKey.CreateFromStream( Store) -end; - - -function T3DES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := T3DESCodec.Create( Key as T3DESKey) -end; - -function T3DES.ProgId: string; -begin -result := TripleDES_ProgId -end; - -function T3DES.SeedByteSize: integer; -begin -result := 16 -end; - - -//From the first line of the KAT table at: http://crypto.stackexchange.com/questions/926/does-anyone-have-a-kat-for-3des-ko-2/927#927 -//<------------- key -------------> <-- plaintext -> <- ciphertext -> -//E62CABB93D1F3BDC 524FDF91A279C297 DD16B3D004069AB3 8ADDBD2290E565CE - -function T3DES.SelfTest_Ciphertext: string; -begin -result := '8ADDBD2290E565CE' -end; - -function T3DES.SelfTest_Key: string; -begin -result := 'E62CABB93D1F3BDC 524FDF91A279C297' -end; - -function T3DES.SelfTest_Plaintext: string; -begin -result := 'DD16B3D004069AB3' -end; - -function T3DES.WikipediaReference: string; -begin -result := 'Triple_DES' -end; - -{ T3DESKey } - -constructor T3DESKey.Create( NativeKey1, NativeKey2: uint64); -begin -FNativeKey1 := NativeKey1; -FNativeKey2 := NativeKey2; -SetParityBitsOnKey( FNativeKey1); -SetParityBitsOnKey( FNativeKey2); -ExpandKey( FNativeKey1, FExpandedKey1); -ExpandKey( FNativeKey2, FExpandedKey2) -end; - - -constructor T3DESKey.CreateFromStream( Store: TStream); -begin -Store.ReadBuffer( FNativeKey1, 8); -Store.ReadBuffer( FNativeKey2, 8); -if (not hasCorrectParity( FNativeKey1)) or - (not hasCorrectParity( FNativeKey2)) then - raise Exception.Create( ES_InvalidKey); -ExpandKey( FNativeKey1, FExpandedKey1); -ExpandKey( FNativeKey2, FExpandedKey2) -end; - - - -procedure T3DESKey.SaveToStream( Stream: TStream); -begin -Stream.Write( FNativeKey1, 8); -Stream.Write( FNativeKey2, 8) -end; - -procedure T3DESKey.Burn; -begin -FNativeKey1 := 0; -FillChar( FExpandedKey1, SizeOf( FExpandedKey1), 0); -FNativeKey2 := 0; -FillChar( FExpandedKey2, SizeOf( FExpandedKey2), 0) -end; - - -{ T3DESCodec } - -constructor T3DESCodec.Create( LockBoxKey1: T3DESKey); -begin -FLockBoxKey := LockBoxKey1 -end; - - - -procedure T3DESCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Plaintext.Memory^, PlaintextBlock, 8); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey1); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey2); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey1); -Move( CiphertextBlock, Ciphertext.Memory^, 8) -end; - - - -procedure T3DESCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Ciphertext.Memory^, CiphertextBlock, 8); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey1); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey2); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey1); -Move( PlaintextBlock, Plaintext.Memory^, 8) -end; - - -procedure T3DESCodec.Reset; -begin -end; - - -procedure T3DESCodec.Burn; -begin -end; - - -{ T3DES_KO1 } - -function T3DES_KO1.DisplayName: string; -begin -result := '3DES (Keying option 1)' -end; - -function T3DES_KO1.GenerateKey( Seed: TStream): TSymetricKey; -var - SeedKey1, SeedKey2, SeedKey3: uint64; -begin -Seed.ReadBuffer( SeedKey1, 8); -Seed.ReadBuffer( SeedKey2, 8); -Seed.ReadBuffer( SeedKey3, 8); -result := T3DESKey_KO1.Create( SeedKey1, SeedKey2, SeedKey3) -end; - - -function T3DES_KO1.KeySize: integer; -begin -result := 112 -end; - -function T3DES_KO1.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := T3DESKey_KO1.CreateFromStream( Store) -end; - - -function T3DES_KO1.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := T3DESCodec_KO1.Create( Key as T3DESKey_KO1) -end; - - -function T3DES_KO1.ProgId: string; -begin -result := TripleDES_KO1_ProgId -end; - -function T3DES_KO1.SeedByteSize: integer; -begin -result := 24 -end; - - -// This test vector from section B1 of -// http://csrc.nist.gov/publications/drafts/800-67-rev1/SP-800-67-rev1-2_July-2011.pdf -function T3DES_KO1.SelfTest_Key: string; -begin -result := '0123456789ABCDEF 23456789ABCDEF01 456789ABCDEF0123' -end; - -function T3DES_KO1.SelfTest_Plaintext: string; -begin -result := '5468652071756663' -end; - -function T3DES_KO1.SelfTest_Ciphertext: string; -begin -result := 'A826FD8CE53B855F' -end; - - -{ T3DESKey_KO1 } - -procedure T3DESKey_KO1.Burn; -begin -inherited; -FNativeKey3 := 0; -FillChar( FExpandedKey3, SizeOf( FExpandedKey3), 0); -end; - - -constructor T3DESKey_KO1.Create( NativeKey1, NativeKey2, NativeKey3: uint64); -begin -inherited Create( NativeKey1, NativeKey2); -FNativeKey3 := NativeKey3; -SetParityBitsOnKey( FNativeKey3); -ExpandKey( FNativeKey3, FExpandedKey3) -end; - - - -constructor T3DESKey_KO1.CreateFromStream( Store: TStream); -begin -inherited CreateFromStream( Store); -Store.ReadBuffer( FNativeKey3, 8); -if not hasCorrectParity( FNativeKey3) then - raise Exception.Create( ES_InvalidKey); -ExpandKey( FNativeKey3, FExpandedKey3) -end; - - -procedure T3DESKey_KO1.SaveToStream( Stream: TStream); -begin -inherited SaveToStream( Stream); -Stream.Write( FNativeKey3, 8) -end; - -{ T3DESCodec_KO1 } - -constructor T3DESCodec_KO1.Create( LockBoxKey1: T3DESKey_KO1); -begin -inherited Create( LockBoxKey1); -FLockBoxKey_KO1 := LockBoxKey1 -end; - -procedure T3DESCodec_KO1.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Plaintext.Memory^, PlaintextBlock, 8); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey1); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey2); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey3); -Move( CiphertextBlock, Ciphertext.Memory^, 8) -end; - -procedure T3DESCodec_KO1.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -var - PlaintextBlock, CiphertextBlock: uint64; -begin -Move( Ciphertext.Memory^, CiphertextBlock, 8); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey3); -DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey2); -DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey1); -Move( PlaintextBlock, Plaintext.Memory^, 8) -end; - - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.TDES; +interface +uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher; + +type + +T3DES = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm) + private + function DisplayName: string; virtual; + function ProgId: string; virtual; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; virtual; + function LoadKeyFromStream( Store: TStream): TSymetricKey; virtual; + function BlockSize: integer; virtual; // in units of bits. Must be a multiple of 8. + function KeySize: integer; virtual; + function SeedByteSize: integer; virtual; // Size that the input of the GenerateKey must be. + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; virtual; + function SelfTest_Key: string; virtual; + function SelfTest_Plaintext: string; virtual; + function SelfTest_Ciphertext: string; virtual; + + public + constructor Create; virtual; + end; + + +T3DES_KO1 = class( T3DES) + private + function DisplayName: string; override; + function ProgId: string; override; + function GenerateKey( Seed: TStream): TSymetricKey; override; + function LoadKeyFromStream( Store: TStream): TSymetricKey; override; + function KeySize: integer; override; + function SeedByteSize: integer; override; + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; override; + function SelfTest_Key: string; override; + function SelfTest_Plaintext: string; override; + function SelfTest_Ciphertext: string; override; + end; + + +implementation + + + + +uses TPLB3.Constants, TPLB3.DES, SysUtils, TPLB3.I18n; +{ TDES } + + +type +T3DESKey = class( TSymetricKey) + protected + FNativeKey1, FNativeKey2: uint64; + FExpandedKey1, FExpandedKey2: TExpandedKey; + + public + constructor Create( NativeKey1, NativeKey2: uint64); + constructor CreateFromStream( Store: TStream); virtual; + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +T3DESKey_KO1 = class( T3DESKey) + private + FNativeKey3: uint64; + FExpandedKey3: TExpandedKey; + + public + constructor Create( NativeKey1, NativeKey2, NativeKey3: uint64); + constructor CreateFromStream( Store: TStream); override; + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + + +T3DESCodec = class( TInterfacedObject, IBlockCodec) + protected + FLockBoxKey: T3DESKey; + + constructor Create( LockBoxKey1: T3DESKey); + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); virtual; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); virtual; + procedure Reset; virtual; + procedure Burn; virtual; + end; + +T3DESCodec_KO1 = class( T3DESCodec) + private + FLockBoxKey_KO1: T3DESKey_KO1; + + constructor Create( LockBoxKey1: T3DESKey_KO1); + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); override; + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); override; + end; + + +function T3DES.BlockSize: integer; +begin +result := 64 +end; + +constructor T3DES.Create; +begin +end; + +function T3DES.DefinitionURL: string; +begin +result := 'http://csrc.nist.gov/publications/drafts/800-67-rev1/SP-800-67-rev1-2_July-2011.pdf' +end; + +function T3DES.DisplayName: string; +begin +result := '3DES (Keying option 2)' +end; + +function T3DES.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + + +function T3DES.GenerateKey( Seed: TStream): TSymetricKey; +var + SeedKey1, SeedKey2: uint64; +begin +Seed.ReadBuffer( SeedKey1, 8); +Seed.ReadBuffer( SeedKey2, 8); +result := T3DESKey.Create( SeedKey1, SeedKey2) +end; + +function T3DES.KeySize: integer; +begin +result := 80 +// Quote from wikipedia: +// Keying option 2 reduces the key size to 112 bits. However, this option +// is susceptible to certain chosen-plaintext or known-plaintext attacks +// and thus it is designated by NIST to have only 80 bits of security. +end; + +function T3DES.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := T3DESKey.CreateFromStream( Store) +end; + + +function T3DES.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := T3DESCodec.Create( Key as T3DESKey) +end; + +function T3DES.ProgId: string; +begin +result := TripleDES_ProgId +end; + +function T3DES.SeedByteSize: integer; +begin +result := 16 +end; + + +//From the first line of the KAT table at: http://crypto.stackexchange.com/questions/926/does-anyone-have-a-kat-for-3des-ko-2/927#927 +//<------------- key -------------> <-- plaintext -> <- ciphertext -> +//E62CABB93D1F3BDC 524FDF91A279C297 DD16B3D004069AB3 8ADDBD2290E565CE + +function T3DES.SelfTest_Ciphertext: string; +begin +result := '8ADDBD2290E565CE' +end; + +function T3DES.SelfTest_Key: string; +begin +result := 'E62CABB93D1F3BDC 524FDF91A279C297' +end; + +function T3DES.SelfTest_Plaintext: string; +begin +result := 'DD16B3D004069AB3' +end; + +function T3DES.WikipediaReference: string; +begin +result := 'Triple_DES' +end; + +{ T3DESKey } + +constructor T3DESKey.Create( NativeKey1, NativeKey2: uint64); +begin +FNativeKey1 := NativeKey1; +FNativeKey2 := NativeKey2; +SetParityBitsOnKey( FNativeKey1); +SetParityBitsOnKey( FNativeKey2); +ExpandKey( FNativeKey1, FExpandedKey1); +ExpandKey( FNativeKey2, FExpandedKey2) +end; + + +constructor T3DESKey.CreateFromStream( Store: TStream); +begin +Store.ReadBuffer( FNativeKey1, 8); +Store.ReadBuffer( FNativeKey2, 8); +if (not hasCorrectParity( FNativeKey1)) or + (not hasCorrectParity( FNativeKey2)) then + raise Exception.Create( ES_InvalidKey); +ExpandKey( FNativeKey1, FExpandedKey1); +ExpandKey( FNativeKey2, FExpandedKey2) +end; + + + +procedure T3DESKey.SaveToStream( Stream: TStream); +begin +Stream.Write( FNativeKey1, 8); +Stream.Write( FNativeKey2, 8) +end; + +procedure T3DESKey.Burn; +begin +FNativeKey1 := 0; +FillChar( FExpandedKey1, SizeOf( FExpandedKey1), 0); +FNativeKey2 := 0; +FillChar( FExpandedKey2, SizeOf( FExpandedKey2), 0) +end; + + +{ T3DESCodec } + +constructor T3DESCodec.Create( LockBoxKey1: T3DESKey); +begin +FLockBoxKey := LockBoxKey1 +end; + + + +procedure T3DESCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Plaintext.Memory^, PlaintextBlock, 8); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey1); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey2); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey1); +Move( CiphertextBlock, Ciphertext.Memory^, 8) +end; + + + +procedure T3DESCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Ciphertext.Memory^, CiphertextBlock, 8); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey1); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey.FExpandedKey2); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey.FExpandedKey1); +Move( PlaintextBlock, Plaintext.Memory^, 8) +end; + + +procedure T3DESCodec.Reset; +begin +end; + + +procedure T3DESCodec.Burn; +begin +end; + + +{ T3DES_KO1 } + +function T3DES_KO1.DisplayName: string; +begin +result := '3DES (Keying option 1)' +end; + +function T3DES_KO1.GenerateKey( Seed: TStream): TSymetricKey; +var + SeedKey1, SeedKey2, SeedKey3: uint64; +begin +Seed.ReadBuffer( SeedKey1, 8); +Seed.ReadBuffer( SeedKey2, 8); +Seed.ReadBuffer( SeedKey3, 8); +result := T3DESKey_KO1.Create( SeedKey1, SeedKey2, SeedKey3) +end; + + +function T3DES_KO1.KeySize: integer; +begin +result := 112 +end; + +function T3DES_KO1.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := T3DESKey_KO1.CreateFromStream( Store) +end; + + +function T3DES_KO1.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := T3DESCodec_KO1.Create( Key as T3DESKey_KO1) +end; + + +function T3DES_KO1.ProgId: string; +begin +result := TripleDES_KO1_ProgId +end; + +function T3DES_KO1.SeedByteSize: integer; +begin +result := 24 +end; + + +// This test vector from section B1 of +// http://csrc.nist.gov/publications/drafts/800-67-rev1/SP-800-67-rev1-2_July-2011.pdf +function T3DES_KO1.SelfTest_Key: string; +begin +result := '0123456789ABCDEF 23456789ABCDEF01 456789ABCDEF0123' +end; + +function T3DES_KO1.SelfTest_Plaintext: string; +begin +result := '5468652071756663' +end; + +function T3DES_KO1.SelfTest_Ciphertext: string; +begin +result := 'A826FD8CE53B855F' +end; + + +{ T3DESKey_KO1 } + +procedure T3DESKey_KO1.Burn; +begin +inherited; +FNativeKey3 := 0; +FillChar( FExpandedKey3, SizeOf( FExpandedKey3), 0); +end; + + +constructor T3DESKey_KO1.Create( NativeKey1, NativeKey2, NativeKey3: uint64); +begin +inherited Create( NativeKey1, NativeKey2); +FNativeKey3 := NativeKey3; +SetParityBitsOnKey( FNativeKey3); +ExpandKey( FNativeKey3, FExpandedKey3) +end; + + + +constructor T3DESKey_KO1.CreateFromStream( Store: TStream); +begin +inherited CreateFromStream( Store); +Store.ReadBuffer( FNativeKey3, 8); +if not hasCorrectParity( FNativeKey3) then + raise Exception.Create( ES_InvalidKey); +ExpandKey( FNativeKey3, FExpandedKey3) +end; + + +procedure T3DESKey_KO1.SaveToStream( Stream: TStream); +begin +inherited SaveToStream( Stream); +Stream.Write( FNativeKey3, 8) +end; + +{ T3DESCodec_KO1 } + +constructor T3DESCodec_KO1.Create( LockBoxKey1: T3DESKey_KO1); +begin +inherited Create( LockBoxKey1); +FLockBoxKey_KO1 := LockBoxKey1 +end; + +procedure T3DESCodec_KO1.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Plaintext.Memory^, PlaintextBlock, 8); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey1); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey2); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey3); +Move( CiphertextBlock, Ciphertext.Memory^, 8) +end; + +procedure T3DESCodec_KO1.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +var + PlaintextBlock, CiphertextBlock: uint64; +begin +Move( Ciphertext.Memory^, CiphertextBlock, 8); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey3); +DES_EncryptBlock( PlaintextBlock, CiphertextBlock, FLockBoxKey_KO1.FExpandedKey2); +DES_DecryptBlock( CiphertextBlock, PlaintextBlock, FLockBoxKey_KO1.FExpandedKey1); +Move( PlaintextBlock, Plaintext.Memory^, 8) +end; + + +end. diff --git a/run/TPLB3.TwoFish.pas b/LockBox3/run/TPLB3.TwoFish.pas similarity index 95% rename from run/TPLB3.TwoFish.pas rename to LockBox3/run/TPLB3.TwoFish.pas index 06abcd0..9fafed5 100644 --- a/run/TPLB3.TwoFish.pas +++ b/LockBox3/run/TPLB3.TwoFish.pas @@ -1,393 +1,393 @@ -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - -{$I TPLB3.Common.inc} - -unit TPLB3.TwoFish; -interface -uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; - -type -{$IF compilerversion >= 21} -{$RTTI EXPLICIT METHODS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublished])} -// Exposes the attribute on the SeedByteSize method. -{$IFEND} - -{$IF compilerversion >= 21} [DesignDescription( -'From Wikipedia: QUOTE:'#13#10 + -'Twofish is a symmetric key block cipher with a block size of 128 bits and '#13#10 + -'key sizes up to 256 bits. It was one of the five finalists of the Advanced '#13#10 + -'Encryption Standard contest, but was not selected for standardisation. '#13#10 + -'Twofish is related to the earlier block cipher Blowfish.'#13#10 + -'END QUOTE' -)] {$IFEND} -TTwoFish = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm, IControlObject -{$IF compilerversion < 21} - ,IVariableSeedSize -{$IFEND} - ) - private - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; - -{$IF compilerversion >= 21} - [IntegerRange( 192, 256)] -{$IFEND} - function KeySize: integer; - - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - function ControlObject: TObject; - -{$IF compilerversion >= 21} - [IntegerRange( 1, 32)] - function SeedByteSize: integer; -{$ELSE} - function SeedByteSize: integer; - function MinSeedByteSize: integer; - function MaxSeedByteSize: integer; -{$IFEND} - - public - constructor Create; - end; - - -implementation - - - - -uses TPLB3.Constants, SysUtils, TPLB3.DCP.twofish_Modified, Math, - TPLB3.Compatibility; - - - - - -type -TTwofishKey = class( TSymetricKey) - public - FKeySeed: TBytes; - FKeySize: integer; - FSubKeys: TSubKeys; - FSBox: TSBox; - - constructor GenerateFromSeed( Seed: TStream); - constructor LoadFromStream( Store: TStream); - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -TTwofishBlockCodec = class( TInterfacedObject, IBlockCodec) - private - FOwner: TTwoFish; - FKey: TTwofishKey; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - - public - constructor Create( Owner1: TTwoFish; Key1: TTwofishKey); - end; - - -var - hasPreComp: boolean = False; - - -procedure InitUnit_TwoFish; -begin -hasPreComp := False -end; - - -procedure DoneUnit_TwoFish; -begin -end; - - -procedure CheckPreComp; -begin -if hasPreComp then exit; -hasPreComp := True; -DCP_towfish_Precomp -end; - - - -function TTwoFish.BlockSize: integer; -begin -result := 128 -end; - - -function TTwoFish.ControlObject: TObject; -begin -result := self -end; - - -constructor TTwoFish.Create; -begin -end; - - -function TTwoFish.DefinitionURL: string; -begin -result := 'http://www.schneier.com/paper-twofish-paper.pdf' -end; - - -function TTwoFish.DisplayName: string; -begin -result := 'Twofish' -end; - - - -function TTwoFish.Features: TAlgorithmicFeatureSet; -begin -result := [afOpenSourceSoftware] -end; - - -function TTwoFish.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := TTwofishKey.GenerateFromSeed( Seed) -end; - - -function TTwoFish.KeySize: integer; -begin -result := 256 -// This is a nominal value only. The actual key size will only -// be known at key generation time. It will deemed either be 128, 192 or 256. -end; - - -function TTwoFish.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TTwofishKey.LoadFromStream( Store) -end; - - -function TTwoFish.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := TTwofishBlockCodec.Create( self, Key as TTwofishKey) -end; - - -function TTwoFish.ProgId: string; -begin -result := Twofish_ProgId -end; - - -function TTwoFish.SeedByteSize: integer; -// Variable. Up to 256 bits. In whole number of 8 bits. At least 8. -begin -result := 32 -end; - -{$IF compilerversion < 21} -// Equivalent to [IntegerRange( 1, 32)] -function TTwoFish.MinSeedByteSize: integer; -begin -result := 1 -end; - -function TTwoFish.MaxSeedByteSize: integer; -begin -result := 32 -end; -{$IFEND} - -//from http://www.schneier.com/code/ecb_ival.txt -//KEYSIZE=192 -//I=10 -//KEY=AE8109BFDA85C1F2C5038B34ED691BFF3AF6F7CE5BD35EF1 -//PT=893FD67B98C550073571BD631263FC78 -//CT=16434FC9C8841A63D58700B5578E8F67 - - -function TTwoFish.SelfTest_Ciphertext: string; -begin -result := '16434FC9C8841A63D58700B5578E8F67' -end; - - - - -function TTwoFish.SelfTest_Key: string; -begin -result := 'AE8109BFDA85C1F2C5038B34ED691BFF3AF6F7CE5BD35EF1' -end; - - - -function TTwoFish.SelfTest_Plaintext: string; -begin -result := '893FD67B98C550073571BD631263FC78' -end; - - - -function TTwoFish.WikipediaReference: string; -begin -result := 'Twofish' -end; - - - -{ TTwofishKey } - -constructor TTwofishKey.GenerateFromSeed( Seed: TStream); -var - L: integer; -begin -L := Seed.Size; -SetLength( FKeySeed, L); -if L > 0 then - begin - Seed.Position := 0; - Seed.Read( FKeySeed[0], L) - end; - -if L < 16 then - FKeySize := 128 - - else if L <= 24 then - FKeySize := 192 - - else - FKeySize := 256; - -CheckPreComp; -DCP_twofish_InitKey( FKeySeed[0], Min( L*8, 256), FSubKeys, FSBox) -end; - - - -constructor TTwofishKey.LoadFromStream( Store: TStream); -begin -CheckPreComp; -GenerateFromSeed( Store) -end; - - - -procedure TTwofishKey.SaveToStream( Stream: TStream); -begin -Stream.Write( FKeySeed[0], Length( FKeySeed)) -end; - - -procedure TTwofishKey.Burn; -var - L: integer; -begin -L := Length( FKeySeed); -if L > 0 then - begin - FillChar( FKeySeed[0], L, 0); - SetLength( FKeySeed, 0) - end; -FKeySize := 0; -FillChar( FSubKeys, SizeOf( FSubKeys), 0); -FillChar( FSBox, SizeOf( FSBox), 0) -end; - - -{ TTwofishBlockCodec } - -constructor TTwofishBlockCodec.Create( Owner1: TTwoFish; Key1: TTwofishKey); -begin -CheckPreComp; -FOwner := Owner1; -FKey := Key1 -end; - - -procedure TTwofishBlockCodec.Encrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -var - InData, OutData: T128; -begin -Move( Plaintext.Memory^, InData, SizeOf( T128)); -DCP_twofish_EncryptECB( FKey.FSubKeys, FKey.FSBox, InData, OutData); -Move( OutData, Ciphertext.Memory^, SizeOf( T128)) -end; - - - -procedure TTwofishBlockCodec.Decrypt_Block( - Plaintext, Ciphertext: TMemoryStream); -var - InData, OutData: T128; -begin -Move( Ciphertext.Memory^, InData, SizeOf( T128)); -DCP_twofish_DecryptECB( FKey.FSubKeys, FKey.FSBox, InData, OutData); -Move( OutData, Plaintext.Memory^, SizeOf( T128)) -end; - - - -procedure TTwofishBlockCodec.Reset; -begin -end; - - -procedure TTwofishBlockCodec.Burn; -begin -end; - - - -initialization -InitUnit_TwoFish; - -finalization -DoneUnit_TwoFish; - -end. +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + +{$I TPLB3.Common.inc} + +unit TPLB3.TwoFish; +interface +uses Classes, TPLB3.BlockCipher, TPLB3.StreamCipher, TPLB3.Decorators; + +type +{$IF compilerversion >= 21} +{$RTTI EXPLICIT METHODS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublished])} +// Exposes the attribute on the SeedByteSize method. +{$IFEND} + +{$IF compilerversion >= 21} [DesignDescription( +'From Wikipedia: QUOTE:'#13#10 + +'Twofish is a symmetric key block cipher with a block size of 128 bits and '#13#10 + +'key sizes up to 256 bits. It was one of the five finalists of the Advanced '#13#10 + +'Encryption Standard contest, but was not selected for standardisation. '#13#10 + +'Twofish is related to the earlier block cipher Blowfish.'#13#10 + +'END QUOTE' +)] {$IFEND} +TTwoFish = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm, IControlObject +{$IF compilerversion < 21} + ,IVariableSeedSize +{$IFEND} + ) + private + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; + +{$IF compilerversion >= 21} + [IntegerRange( 192, 256)] +{$IFEND} + function KeySize: integer; + + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + function ControlObject: TObject; + +{$IF compilerversion >= 21} + [IntegerRange( 1, 32)] + function SeedByteSize: integer; +{$ELSE} + function SeedByteSize: integer; + function MinSeedByteSize: integer; + function MaxSeedByteSize: integer; +{$IFEND} + + public + constructor Create; + end; + + +implementation + + + + +uses TPLB3.Constants, SysUtils, TPLB3.DCP.twofish_Modified, Math, + TPLB3.Compatibility; + + + + + +type +TTwofishKey = class( TSymetricKey) + public + FKeySeed: TBytes; + FKeySize: integer; + FSubKeys: TSubKeys; + FSBox: TSBox; + + constructor GenerateFromSeed( Seed: TStream); + constructor LoadFromStream( Store: TStream); + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +TTwofishBlockCodec = class( TInterfacedObject, IBlockCodec) + private + FOwner: TTwoFish; + FKey: TTwofishKey; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + + public + constructor Create( Owner1: TTwoFish; Key1: TTwofishKey); + end; + + +var + hasPreComp: boolean = False; + + +procedure InitUnit_TwoFish; +begin +hasPreComp := False +end; + + +procedure DoneUnit_TwoFish; +begin +end; + + +procedure CheckPreComp; +begin +if hasPreComp then exit; +hasPreComp := True; +DCP_towfish_Precomp +end; + + + +function TTwoFish.BlockSize: integer; +begin +result := 128 +end; + + +function TTwoFish.ControlObject: TObject; +begin +result := self +end; + + +constructor TTwoFish.Create; +begin +end; + + +function TTwoFish.DefinitionURL: string; +begin +result := 'http://www.schneier.com/paper-twofish-paper.pdf' +end; + + +function TTwoFish.DisplayName: string; +begin +result := 'Twofish' +end; + + + +function TTwoFish.Features: TAlgorithmicFeatureSet; +begin +result := [afOpenSourceSoftware] +end; + + +function TTwoFish.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := TTwofishKey.GenerateFromSeed( Seed) +end; + + +function TTwoFish.KeySize: integer; +begin +result := 256 +// This is a nominal value only. The actual key size will only +// be known at key generation time. It will deemed either be 128, 192 or 256. +end; + + +function TTwoFish.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TTwofishKey.LoadFromStream( Store) +end; + + +function TTwoFish.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := TTwofishBlockCodec.Create( self, Key as TTwofishKey) +end; + + +function TTwoFish.ProgId: string; +begin +result := Twofish_ProgId +end; + + +function TTwoFish.SeedByteSize: integer; +// Variable. Up to 256 bits. In whole number of 8 bits. At least 8. +begin +result := 32 +end; + +{$IF compilerversion < 21} +// Equivalent to [IntegerRange( 1, 32)] +function TTwoFish.MinSeedByteSize: integer; +begin +result := 1 +end; + +function TTwoFish.MaxSeedByteSize: integer; +begin +result := 32 +end; +{$IFEND} + +//from http://www.schneier.com/code/ecb_ival.txt +//KEYSIZE=192 +//I=10 +//KEY=AE8109BFDA85C1F2C5038B34ED691BFF3AF6F7CE5BD35EF1 +//PT=893FD67B98C550073571BD631263FC78 +//CT=16434FC9C8841A63D58700B5578E8F67 + + +function TTwoFish.SelfTest_Ciphertext: string; +begin +result := '16434FC9C8841A63D58700B5578E8F67' +end; + + + + +function TTwoFish.SelfTest_Key: string; +begin +result := 'AE8109BFDA85C1F2C5038B34ED691BFF3AF6F7CE5BD35EF1' +end; + + + +function TTwoFish.SelfTest_Plaintext: string; +begin +result := '893FD67B98C550073571BD631263FC78' +end; + + + +function TTwoFish.WikipediaReference: string; +begin +result := 'Twofish' +end; + + + +{ TTwofishKey } + +constructor TTwofishKey.GenerateFromSeed( Seed: TStream); +var + L: integer; +begin +L := Seed.Size; +SetLength( FKeySeed, L); +if L > 0 then + begin + Seed.Position := 0; + Seed.Read( FKeySeed[0], L) + end; + +if L < 16 then + FKeySize := 128 + + else if L <= 24 then + FKeySize := 192 + + else + FKeySize := 256; + +CheckPreComp; +DCP_twofish_InitKey( FKeySeed[0], Min( L*8, 256), FSubKeys, FSBox) +end; + + + +constructor TTwofishKey.LoadFromStream( Store: TStream); +begin +CheckPreComp; +GenerateFromSeed( Store) +end; + + + +procedure TTwofishKey.SaveToStream( Stream: TStream); +begin +Stream.Write( FKeySeed[0], Length( FKeySeed)) +end; + + +procedure TTwofishKey.Burn; +var + L: integer; +begin +L := Length( FKeySeed); +if L > 0 then + begin + FillChar( FKeySeed[0], L, 0); + SetLength( FKeySeed, 0) + end; +FKeySize := 0; +FillChar( FSubKeys, SizeOf( FSubKeys), 0); +FillChar( FSBox, SizeOf( FSBox), 0) +end; + + +{ TTwofishBlockCodec } + +constructor TTwofishBlockCodec.Create( Owner1: TTwoFish; Key1: TTwofishKey); +begin +CheckPreComp; +FOwner := Owner1; +FKey := Key1 +end; + + +procedure TTwofishBlockCodec.Encrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +var + InData, OutData: T128; +begin +Move( Plaintext.Memory^, InData, SizeOf( T128)); +DCP_twofish_EncryptECB( FKey.FSubKeys, FKey.FSBox, InData, OutData); +Move( OutData, Ciphertext.Memory^, SizeOf( T128)) +end; + + + +procedure TTwofishBlockCodec.Decrypt_Block( + Plaintext, Ciphertext: TMemoryStream); +var + InData, OutData: T128; +begin +Move( Ciphertext.Memory^, InData, SizeOf( T128)); +DCP_twofish_DecryptECB( FKey.FSubKeys, FKey.FSBox, InData, OutData); +Move( OutData, Plaintext.Memory^, SizeOf( T128)) +end; + + + +procedure TTwofishBlockCodec.Reset; +begin +end; + + +procedure TTwofishBlockCodec.Burn; +begin +end; + + + +initialization +InitUnit_TwoFish; + +finalization +DoneUnit_TwoFish; + +end. diff --git a/run/TPLB3.XXTEA.pas b/LockBox3/run/TPLB3.XXTEA.pas similarity index 96% rename from run/TPLB3.XXTEA.pas rename to LockBox3/run/TPLB3.XXTEA.pas index d7476db..4f83e70 100644 --- a/run/TPLB3.XXTEA.pas +++ b/LockBox3/run/TPLB3.XXTEA.pas @@ -1,1063 +1,1063 @@ -{$I TPLB3.Common.inc} - -unit TPLB3.XXTEA; -{* ***** BEGIN LICENSE BLOCK ***** -Copyright 2010 Sean B. Durkin -This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free -software being offered under a dual licensing scheme: LGPL3 or MPL1.1. - -The contents of this file are subject to the Mozilla Public License (MPL) -Version 1.1 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Alternatively, you may redistribute it and/or modify it under the terms of -the GNU Lesser General Public License (LGPL) as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -You should have received a copy of the Lesser GNU General Public License -along with TurboPower LockBox 3. If not, see . - -TurboPower LockBox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, -see the GNU Lesser General Public License for more details. In relation to MPL, -see the MPL License for the specific language governing rights and limitations -under the License. - -The Initial Developer of the Original Code for TurboPower LockBox version 2 -and earlier was TurboPower Software. - - * ***** END LICENSE BLOCK ***** *} - - -interface -uses TPLB3.StreamCipher, TPLB3.BlockCipher, Classes, Types, TPLB3.Decorators; - -type - -{$IF compilerversion >= 21} [DesignDescription( -'XXTEA is implemented here with the following options set so:'#13#10 + -'(*) The encoding of longwords is little-endien.'#13#10 + -'(*) Empty plaintext message maps to empty ciphertext message.'#13#10 + -'(*) For plaintext messages less than or equal to 199 bytes:'#13#10 + -'(**) The end of the plaintext is padded out PKCS7 style (RFC 3852) to 4-byte alignment;'#13#10 + -'(**) 8 bytes of salt is appended to the plaintext;'#13#10 + -'(**) The resultant extended plaintext is encrypted in XXTEA long block mode -'#13#10 + -' That is to say, the block size is set to be the message size.'#13#10 + -'(*) For plaintext messages more than or equal to 200 bytes:'#13#10 + -'(**) 12 random bytes are appended to the plaintext;'#13#10 + -'(**) The block size is fixed to 212 bytes;'#13#10 + -'(**) Normal block-cipher encryption applies according to your selected'#13#10 + -' chaining mode. As usual, this includes 64 bits of automatic salting,'#13#10 + -' and smart block quantisation (Ciphertext stealing or key-streaming,'#13#10 + -' as appropriate to the chaining mode).' -)] {$IFEND} -TXXTEA_LargeBlock = class( TInterfacedObject, - IStreamCipher, ICryptoGraphicAlgorithm, IControlObject) - private - FChaining: IBlockChainingModel; - - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function SeedByteSize: integer; - function Parameterize( const Params: IInterface): IStreamCipher; - function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; - function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; - function ControlObject: TObject; - - public - constructor Create; - end; - - - - TTEA_Key = packed array[ 0.. 3 ] of longword; - -procedure XXTEA_Encrypt( // Corrected Block TEA encryption primitive. - const Key: TTEA_Key; - const Plaintext: TLongWordDynArray; // At least 2 - var Ciphertext: TLongWordDynArray); // Same length as Plaintext - -procedure XXTEA_Decrypt( // Corrected Block TEA encryption primitive. - const Key: TTEA_Key; - const Ciphertext: TLongWordDynArray; // At least 2 - var Plaintext : TLongWordDynArray); // Same length as Ciphertext - - -implementation - - - - - - - - - - - - - -uses SysUtils, Math, TPLB3.StreamUtils, TPLB3.Constants, TPLB3.StreamToBlock, - TPLB3.PointerArithmetic, TPLB3.I18n, TPLB3.CBC, TPLB3.Random, - TPLB3.Compatibility; - - - -type -TXXTEA_LE_Key = class( TSymetricKey) - public - FNativeKey: TTEA_Key; - constructor Create( Seed: TStream; isStore: boolean); - {Above: False=from password or random seed; True=from SaveToStream} - - procedure SaveToStream( Stream: TStream); override; - procedure Burn; override; - end; - - -TXXTEA_LargeBlock_LE_Encryptor = class( TInterfacedObject, - IStreamEncryptor, IBlockCipherSelector) - public - constructor Create( Owner1: TXXTEA_LargeBlock; Key: TXXTEA_LE_Key; CipherText: TStream); - destructor Destroy; override; - - private - FOwner: TXXTEA_LargeBlock; - FKey: TXXTEA_LE_Key; - FCipherText: TStream; - FBuffer: TBytes; - FBufLen: integer; - FisBuffering: boolean; - FFixedCipher: IStreamCipher; - FFixedEnc: IStreamEncryptor; - - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - procedure Encrypt( const Plaintext: TStream); - procedure End_Encrypt; - procedure Reset; - end; - - -TAbbrieviatingStream = class( TStream) - private - FOutputStream: TStream; - FClipAmount: integer; - FBuffer: TBytes; - FBufLen: integer; - - protected - function GetSize: int64; override; - procedure SetSize( const NewSize: int64); override; - - public - constructor Create( OutputStream1: TStream; ClipAmount1: integer); - function Read ( var Buffer; Count: Longint): Longint; override; - function Write( const Buffer; Count: Longint): Longint; override; - function Seek ( const Offset: Int64; Origin: TSeekOrigin): int64; override; - - procedure EndStreaming; - end; - - - -TXXTEA_LargeBlock_LE_Decryptor = class( TInterfacedObject, - IStreamDecryptor, IBlockCipherSelector) - public - constructor Create( Owner1: TXXTEA_LargeBlock; Key: TXXTEA_LE_Key; PlainText: TStream); - destructor Destroy; override; - - private - FOwner: TXXTEA_LargeBlock; - FKey: TXXTEA_LE_Key; - FPlainText: TStream; - FBuffer: TBytes; - FBufLen: integer; - FisBuffering: boolean; - FFixedCipher: IStreamCipher; - FFixedDec: IStreamDecryptor; - FOutputBuffer: TAbbrieviatingStream; - - function GetBlockCipher : IBlockCipher; - function GetChainMode : IBlockChainingModel; - procedure Decrypt( const Ciphertext: TStream); - procedure End_Decrypt; - procedure Reset; - end; - - -TXXTEA_Block = class( TInterfacedObject, - IBlockCipher, ICryptoGraphicAlgorithm) - private - FBlockSize: integer; - function DisplayName: string; - function ProgId: string; - function Features: TAlgorithmicFeatureSet; - function DefinitionURL: string; - function WikipediaReference: string; - function GenerateKey( Seed: TStream): TSymetricKey; - function LoadKeyFromStream( Store: TStream): TSymetricKey; - function BlockSize: integer; // in units of bits. Must be a multiple of 8. - function KeySize: integer; // in units of bits. - function SeedByteSize: integer; // Size that the input of the GenerateKey must be. - function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; - function SelfTest_Key: string; - function SelfTest_Plaintext: string; - function SelfTest_Ciphertext: string; - - public - constructor Create( BlockSize1: integer); - end; - - -TXXTEA_BlockCodec = class( TInterfacedObject, IBlockCodec) - private - FBlockSize_InBytes: integer; - FKey: TXXTEA_LE_Key; - FPlaintext_Longs: TLongWordDynArray; - FCiphertext_Longs: TLongWordDynArray; - - procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); - procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); - procedure Reset; - procedure Burn; - - public - constructor Create( Key1: TXXTEA_LE_Key; BlockSize1: integer); - end; - -//type -// TTEA_Key = array[ 0.. 3 ] of longword; -// TLongs = array of longword; - -// XXTEA primitives -// In the following comment section, read ")-" as "}". -{ The original formulation of the Corrected Block TEA algorithm, published by - David Wheeler and Roger Needham, is as follows: - - #define MX (z>>5^y<<2) + (y>>3^z<<4)^(sum^y) + (k[p&3^e]^z); - long btea(long* v, long n, long* k) { - unsigned long z=v[n-1], y=v[0], sum=0, e, DELTA=0x9e3779b9; - long p, q ; - if (n > 1) { /* Coding Part */ - q = 6 + 52/n; - while (q-- > 0) { - sum += DELTA; - e = (sum >> 2) & 3; - for (p=0; p> 2) & 3; - for (p=n-1; p>0; p--) z = v[p-1], y = v[p] -= MX; - z = v[n-1]; - y = v[0] -= MX; - sum -= DELTA; - )- - return 0; - )- - return 1; - )- - -According to Needham and Wheeler: - BTEA will encode or decode n words as a single block where n > 1 - * v is the n word data vector - * k is the 4 word key - * n is negative for decoding - * if n is zero result is 1 and no coding or decoding takes place, otherwise the result is zero - * assumes 32 bit 'long' and same endian coding and decoding -} - - - -const DELTA = $9e3779b9; // For Little-endien implementations only. - -function Mx( - const z, y, sum: longword; - const k: TTEA_Key; const p, e: longword): longword; -{$IF CompilerVersion >= 17.0} inline; {$IFEND} -begin -result := (((z shr 5) xor (y shl 2)) + - ((y shr 3) xor (z shl 4))) xor ((sum xor y) + - (k[(p and 3) xor e] xor z)) -end; - - -procedure XXTEA_Encrypt( // Corrected Block TEA encryption primitive. - const Key: TTEA_Key; - const Plaintext : TLongWordDynArray; // At least 2 - var Ciphertext: TLongWordDynArray); // Same length as Plaintext -var - n: integer; - z, sum: longword; - e, q, p: LongWord; -begin -n := Length( Plaintext); -Assert( n >= 2, 'Plaintext too short'); -z := Plaintext[ n-1]; -if Length( Ciphertext) <> n then - SetLength( Ciphertext, n); -Move( Plaintext[0], Ciphertext[0], n * SizeOf( longword)); -sum := 0; -for q := 5 + (52 div n) downto 0 do - begin - Inc( sum, DELTA); - e := (sum shr 2) and 3; - for p := 0 to n - 2 do - begin - z := Ciphertext[ p] + MX( z, Ciphertext[ p + 1], sum, Key, p, e); // z = v[p] += MX - Ciphertext[ p] := z - end; - z := Ciphertext[ n-1] + MX( z, Ciphertext[ 0], sum, Key, n - 1, e); - Ciphertext[ n-1] := z - end -end; - - - -procedure XXTEA_Decrypt( // Corrected Block TEA decryption primitive. - const Key: TTEA_Key; - const Ciphertext: TLongWordDynArray; // At least 2 - var Plaintext : TLongWordDynArray); // Same length as Ciphertext -var - n: integer; - y: LongWord; - sum: LongWord; - e: LongWord; - p: LongWord; -begin -n := Length( Ciphertext); -Assert( n >= 2, 'Ciphertext too short'); -if Length( Plaintext) <> n then - SetLength( Plaintext, n); -Move( Ciphertext[0], Plaintext[0], n * SizeOf( longword)); -sum := (6 + (52 div Cardinal(n))) * DELTA; -y := Plaintext[0]; -while sum <> 0 do - begin - e := (sum shr 2) and 3; - for p := n - 1 downto 1 do - begin - y := Plaintext[p] - Mx( Plaintext[p - 1], y, sum, Key, p, e); - Plaintext[p] := y - end; - y := Plaintext[0] - Mx( Plaintext[n-1], y, sum, Key, 0, e); - Plaintext[0] := y; - Dec( sum, DELTA) - end -end; - - - -{ TXXTEA_LargeBlock } - -function TXXTEA_LargeBlock.ControlObject: TObject; -begin -result := self -end; - -constructor TXXTEA_LargeBlock.Create; -begin -end; - - -function TXXTEA_LargeBlock.DefinitionURL: string; -begin -result := 'http://www.movable-type.co.uk/scripts/xxtea.pdf' -end; - - -function TXXTEA_LargeBlock.DisplayName: string; -begin -result := 'XXTEA (large block; little-endien)' -end; - - - -function TXXTEA_LargeBlock.Features: TAlgorithmicFeatureSet; -begin -result := [afCryptographicallyWeak, afDoesNotNeedSalt, afOpenSourceSoftware] -end; - - - -function TXXTEA_LargeBlock.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := TXXTEA_LE_Key.Create( Seed, False) -end; - - -function TXXTEA_LargeBlock.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := TXXTEA_LE_Key.Create( Store, True) -end; - - -function TXXTEA_LargeBlock.Parameterize( - const Params: IInterface): IStreamCipher; -var - BlockCipherSelector: IBlockCipherSelector; - Chaining: IBlockChainingModel; - Newbie: TXXTEA_LargeBlock; -begin -result := nil; -if assigned( FChaining) then exit; -if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then - Chaining := BlockCipherSelector.GetChainMode; -if not assigned( Chaining) then exit; -Newbie := TXXTEA_LargeBlock.Create; -Newbie.FChaining := Chaining; -result := Newbie -end; - - - -function TXXTEA_LargeBlock.ProgId: string; -begin -result := XXTEA_Large_ProgId -end; - - -function TXXTEA_LargeBlock.SeedByteSize: integer; -begin -result := 128 -end; - - -function TXXTEA_LargeBlock.Start_Encrypt( - Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; -begin -result := TXXTEA_LargeBlock_LE_Encryptor - .Create( self, Key as TXXTEA_LE_Key, Ciphertext) -end; - - -function TXXTEA_LargeBlock.Start_Decrypt( - Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; -begin -result := TXXTEA_LargeBlock_LE_Decryptor - .Create( self, Key as TXXTEA_LE_Key, Plaintext) -end; - - -function TXXTEA_LargeBlock.WikipediaReference: string; -begin -result := 'XXTEA' -end; - - -{ TXXTEA_LE_Key } - -procedure TXXTEA_LE_Key.Burn; -begin -FillChar( FNativeKey, SizeOf( FNativeKey), 0) -end; - - -constructor TXXTEA_LE_Key.Create( Seed: TStream; isStore: boolean); -begin -Seed.ReadBuffer( FNativeKey, SizeOf( FNativeKey)) -end; - - -procedure TXXTEA_LE_Key.SaveToStream( Stream: TStream); -begin -Stream.WriteBuffer( FNativeKey, SizeOf( FNativeKey)) -end; - -const - EncryptionBufferSize = 200; - LargeMessageSaltTailLength = 12; - DecryptionBufferSize = EncryptionBufferSize + LargeMessageSaltTailLength; - - BlockSize_InBytes = 212; // 212 bytes or 53 longwords. - // This does not have to be 53 longwords. It is fairly arbitary. - // Lower values would be valid, and perhaps more appropriate for - // 8-bit chaining modes. - BlockSize_InBits = BlockSize_InBytes * 8; - -{ TXXTEA_LargeBlock_LE_Encryptor } - -constructor TXXTEA_LargeBlock_LE_Encryptor.Create( - Owner1: TXXTEA_LargeBlock; - Key: TXXTEA_LE_Key; CipherText: TStream); -begin -FOwner := Owner1; -FKey := Key; -FCiphertext := CipherText; -SetLength( FBuffer, EncryptionBufferSize); -FBufLen := 0; -FisBuffering := True -end; - -destructor TXXTEA_LargeBlock_LE_Encryptor.Destroy; -begin -SetLength( FBuffer, 0); -inherited -end; - -{ -XXTEA is a variable block length cipher. So how does that fit into -our model of block ciphers being of fixed block length? Apply the -following strategy. - -Let - n = Size of the plaintext payload (before salting, padding etc) in bytes. - c = Size of the ciphertext message in bytes. - B = Size of the XXTEA block in bytes. - -1. ENCRYPTION -============= -Upon encryption buffer up to 200 bytes. - -1.1 Case One: - An empty plaintext maps to an empty ciphertext. - n = 0 ==> c := 0 - -1.2 Small message case: - For a small message, just encrypt the whole thing directly in one block. - Salt and pad as required. - n <= 199 ==> - 1.2.1 Pad the message out at the tail to make it align to quad-byte. - The last pad byte value should be equal to the count of pad bytes, - in esse 1 to 4. There must be at least 1 pad byte. - 1.2.2 Salt the plaintext. That is to say inject 8 random bytes at the - tail of the plaintext. Due to the cyclic nature of XXTEA, the - salt does not need to be at the head. - 1.2.3 Encrypt the salted padded message as one XXTEA block. - c in [n+9 .. n+12] - c <= 211 - B = c - -1.3 Large message case: - For a large message, to be practical we must set reasonable block sizes. - Append 12 bytes of salt at the tail; and use normal block-to-stream adaption - with a block size of 212 bytes or 53 longwords. - n >= 200 ==> - 1.3.1 Append 12 random bytes to the end. - 1.3.2 Set block size to fixed 212 bytes. - 1.3.3 Encrypt using StreamToBlock adapter with XXTEA and the user's - requested chaining mode. This will intrinsically include - 8 bytes of salt (unless the mode is ECB), and block quantisation - most appropriate to the selected chaining mode. - c >= n + 12 - c >= 212 - B = 212 - -2. DECRYPTION -============= -Upon decryption buffer up to 212 bytes. - -2.1 Case One: - An empty ciphertext maps to an empty plaintext. - c = 0 ==> n := 0 - -2.2 Small message case: - For a small message, just decrypt the whole thing directly in one block. - Remove salt and de-pad as required. - c <= 211 ==> - 2.2.1 Decrypt the message as one XXTEA block. - 2.2.2 De-salt the decrypted plaintext. That is to say discard the last - 8 bytes at the head of the decrypted plaintext. - 2.2.3 De-pad the message out at the tail. The number of pad bytes to - remove is the value of the last byte. - B := c - n in [c - 12 .. c - 9] - n <= 199 - -2.3 Large message case: - For a large message, decrypt with a normal block-to-stream adaption. - Strip 12 bytes off from the tail; and use a block size of 212 bytes. - c >= 212 - ==> - 3.3.1 Set block size to fixed 212 bytes. - 3.3.2 Decrypt using StreamToBlock adapter with XXTEA and the user's - requested chaining mode. This will intrinsically include - 8 bytes of salt (unless the mode is ECB), and block quantisation - most appropriate to the selected chaining mode. - 3.3.3 Discard 12 bytes at the end. - c >= n + 12 - n >= 200 - B := 212 - - -} - - -procedure TXXTEA_LargeBlock_LE_Encryptor.Encrypt( const Plaintext: TStream); -var - Amnt: integer; - Tmp: IStreamCipher; - PTCopy: TStream; -begin -Amnt := -1; -if FisBuffering then - begin - // At this point we are not sure if it going to be large message - // or short message case. - Amnt := EncryptionBufferSize - FBufLen; - Amnt := Plaintext.Read( FBuffer[FBufLen], Amnt); - Inc( FBufLen, Amnt); - if FBufLen >= EncryptionBufferSize then - begin // Large message case, switch to adapter. - FFixedCipher := TStreamToBlock_Adapter.Create; - Tmp := FFixedCipher.Parameterize( self); - // The above line casts this to IBlockCipherSelector then calls: - // GetBlockCipher; and - // GetChainMode - if assigned( Tmp) then - FFixedCipher := Tmp; - FFixedEnc := FFixedCipher.Start_Encrypt( FKey, FCipherText); - PTCopy := TMemoryStream.Create; - try - PTCopy.Write( FBuffer[0], FBufLen); - PTCopy.Position := 0; - FFixedEnc.Encrypt( PTCopy) - finally - PTCopy.Free - end ; - FBufLen := 0; - FisBuffering := False - end - end; -if (not FisBuffering) and (Amnt <> 0) then - FFixedEnc.Encrypt( Plaintext) -end; - - - -procedure TXXTEA_LargeBlock_LE_Encryptor.End_Encrypt; -var - RequiredSizeIncrease, RequiredSize: integer; - j, L: integer; - PlaintextArray, CiphertextArray: TLongWordDynArray; - PTCopy: TMemoryStream; -begin -if FisBuffering then - begin - if FBufLen = 0 then exit; -// n <= 199 ==> -// 1.2.1 Pad the message out at the tail to make it align to quad-byte. -// The last pad byte value should be equal to the count of pad bytes, -// in esse 1 to 4. There must be at least 1 pad byte. -// 1.2.2 Salt the plaintext. That is to say inject 8 random bytes at the -// tail of the plaintext. Due to the cyclic nature of XXTEA, the -// salt does not need to be at the head. -// 1.2.3 Encrypt the salted padded message as one XXTEA block. - RequiredSizeIncrease := 4 - (FBufLen mod 4); - RequiredSize := FBufLen + RequiredSizeIncrease; // How much padding is needed? - for j := FBufLen to FBufLen + RequiredSizeIncrease - 1 do - FBuffer[j] := RequiredSizeIncrease; // Pad it out. - L := (RequiredSize div 4) + 2; - SetLength( PlaintextArray, L); // Setup longword array. - Move( FBuffer[0], PlaintextArray[0], RequiredSize); // Convert padded payload to longwords. - TRandomStream.Instance.Read( PlaintextArray[L-2], 8); // Salting. - SetLength( CiphertextArray, L); - XXTEA_Encrypt( FKey.FNativeKey, PlaintextArray, CiphertextArray); // One-block encryption. - FCipherText.Write( CiphertextArray[0], L * 4) - end - else - begin - PTCopy := TMemoryStream.Create; - try - PTCopy.Size := LargeMessageSaltTailLength; - TRandomStream.Instance.Read( PTCopy.Memory^, LargeMessageSaltTailLength); // 12 random bytes - PTCopy.Position := 0; - FFixedEnc.Encrypt( PTCopy) - finally - PTCopy.Free - end ; - FFixedEnc.End_Encrypt - end; -FFixedEnc := nil; -FFixedCipher := nil -end; - - - - -function TXXTEA_LargeBlock_LE_Encryptor.GetBlockCipher: IBlockCipher; -begin -result := TXXTEA_Block.Create( BlockSize_InBits) -end; - -function TXXTEA_LargeBlock_LE_Encryptor.GetChainMode: IBlockChainingModel; -begin -// Called by Parameterize. -result := FOwner.FChaining; -if not assigned( result) then - result := TCBC.Create -end; - -procedure TXXTEA_LargeBlock_LE_Encryptor.Reset; -begin -FBufLen := 0; -FisBuffering := True; -FFixedCipher := nil; -FFixedEnc := nil -end; - - -{ TXXTEA_LargeBlock_LE_Decryptor } - -constructor TXXTEA_LargeBlock_LE_Decryptor.Create( - Owner1: TXXTEA_LargeBlock; - Key: TXXTEA_LE_Key; PlainText: TStream); -begin -FOwner := Owner1; -FKey := Key; -FPlaintext := PlainText; -SetLength( FBuffer, DecryptionBufferSize); -FBufLen := 0; -FisBuffering := True -end; - - -procedure TXXTEA_LargeBlock_LE_Decryptor.Decrypt( const Ciphertext: TStream); -var - Amnt: integer; - Tmp: IStreamCipher; - PTCopy: TStream; -begin -Amnt := -1; -if FisBuffering then - begin - // At this point we are not sure if it going to be large message - // or short message case. - Amnt := DecryptionBufferSize - FBufLen; - Amnt := Ciphertext.Read( FBuffer[FBufLen], Amnt); - Inc( FBufLen, Amnt); - if FBufLen >= DecryptionBufferSize then - begin // Large message case, switch to adapter. - FFixedCipher := TStreamToBlock_Adapter.Create; - Tmp := FFixedCipher.Parameterize( self); - // The above line casts this to IBlockCipherSelector then calls: - // GetBlockCipher; and - // GetChainMode - if assigned( Tmp) then - FFixedCipher := Tmp; - FreeAndNil( FOutputBuffer); - FOutputBuffer := TAbbrieviatingStream - .Create( FPlainText, LargeMessageSaltTailLength); - FFixedDec := FFixedCipher.Start_Decrypt( FKey, FOutputBuffer); - PTCopy := TMemoryStream.Create; - try - PTCopy.Write( FBuffer[0], FBufLen); - PTCopy.Position := 0; - FFixedDec.Decrypt( PTCopy) - finally - PTCopy.Free - end ; - FBufLen := 0; - FisBuffering := False - end - end; -if (not FisBuffering) and (Amnt <> 0) then - FFixedDec.Decrypt( Ciphertext) -end; - - - -destructor TXXTEA_LargeBlock_LE_Decryptor.Destroy; -begin -FFixedDec := nil; -FFixedCipher := nil; -FreeAndNil( FOutputBuffer); -inherited -end; - -procedure TXXTEA_LargeBlock_LE_Decryptor.End_Decrypt; -var - RequiredSizeDecrease: integer; - L: integer; - PlaintextArray, CiphertextArray: TLongWordDynArray; -begin -if FisBuffering then - begin - if FBufLen = 0 then exit; -// c <= 211 ==> -// 2.2.1 Decrypt the message as one XXTEA block. -// 2.2.2 De-salt the decrypted plaintext. That is to say discard the last -// 8 bytes at the head of the decrypted plaintext. -// 2.2.3 De-pad the message out at the tail. The number of pad bytes to -// remove is the value of the last byte. - L := FBufLen div 4; - SetLength( CiphertextArray, L); // Setup longword array. - SetLength( PlaintextArray , L); - if L >= 2 then - begin - // XXTEA only valid if blocksize is at least 2 longwords. - // With the padding, this should ALWAYS be the case. - // Otherwise the ciphertext message is invalid. - Move( FBuffer[0], CiphertextArray[0], FBufLen); // Convert padded message to longwords. - XXTEA_Decrypt( FKey.FNativeKey, CiphertextArray, PlaintextArray); // One-block encryption. - end; - if FBufLen >= 8 then - Dec( FBufLen, 8) // de-salt - else - FBufLen := 0; - if FBufLen > 0 then // Calculate pad. - RequiredSizeDecrease := FBuffer[FBufLen-1] - else - RequiredSizeDecrease := 0; - if FBufLen >= RequiredSizeDecrease then - Dec( FBufLen, RequiredSizeDecrease) // de-pad - else - FBufLen := 0; - if L > 0 then - FPlainText.Write( CiphertextArray[0], L * 4) - end - else - begin - FFixedDec.End_Decrypt; - FOutputBuffer.EndStreaming; // Discard last 12 bytes - FreeAndNil( FOutputBuffer) - end; -FFixedDec := nil; -FFixedCipher := nil -end; - - - -function TXXTEA_LargeBlock_LE_Decryptor.GetBlockCipher: IBlockCipher; -begin -result := TXXTEA_Block.Create( BlockSize_InBits) -end; - -function TXXTEA_LargeBlock_LE_Decryptor.GetChainMode: IBlockChainingModel; -begin -result := FOwner.FChaining; -if not assigned( result) then - result := TCBC.Create -end; - -procedure TXXTEA_LargeBlock_LE_Decryptor.Reset; -begin -FBufLen := 0; -FisBuffering := True; -FFixedCipher := nil; -FFixedDec := nil; -FreeAndNil( FOutputBuffer) -end; - - -{ TXXTEA_Block } - -function TXXTEA_Block.BlockSize: integer; -begin -result := FBlockSize -end; - -constructor TXXTEA_Block.Create( BlockSize1: integer); -begin -FBlockSize := BlockSize1 -end; - -function TXXTEA_Block.DefinitionURL: string; -begin -result := '' // Not used. -end; - -function TXXTEA_Block.DisplayName: string; -begin -result := '' // Not used. -end; - - - -function TXXTEA_Block.Features: TAlgorithmicFeatureSet; -begin -result := [afCryptographicallyWeak, afForRunTimeOnly, afOpenSourceSoftware] -end; - - - -function TXXTEA_Block.GenerateKey( Seed: TStream): TSymetricKey; -begin -result := nil // Not used. -end; - -function TXXTEA_Block.KeySize: integer; -begin // Not used -result := SizeOf( TTEA_Key) * 8 -end; - -function TXXTEA_Block.LoadKeyFromStream( Store: TStream): TSymetricKey; -begin -result := nil // Not used. -end; - -function TXXTEA_Block.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; -begin -result := TXXTEA_BlockCodec.Create( Key as TXXTEA_LE_Key, FBlockSize) -end; - - -function TXXTEA_Block.ProgId: string; -begin -result := '' // Not used -end; - - -function TXXTEA_Block.SeedByteSize: integer; -begin -result := -1 // Not used -end; - -function TXXTEA_Block.SelfTest_Ciphertext: string; -begin -result := '' // Not used -end; - -function TXXTEA_Block.SelfTest_Key: string; -begin -result := '' // Not used -end; - -function TXXTEA_Block.SelfTest_Plaintext: string; -begin -result := '' // Not used -end; - -function TXXTEA_Block.WikipediaReference: string; -begin -result := '' // Not used -end; - - -{ TXXTEA_BlockCodec } - -procedure TXXTEA_BlockCodec.Burn; -begin // Not used -end; - - - -constructor TXXTEA_BlockCodec.Create( Key1: TXXTEA_LE_Key; BlockSize1: integer); -begin -FKey := Key1; -FBlockSize_InBytes := BlockSize1 div 8; -SetLength( FPlaintext_Longs, FBlockSize_InBytes div 4); // At least 2 longwords -SetLength( FCiphertext_Longs, Length( FPlaintext_Longs)) -end; - - - -procedure TXXTEA_BlockCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -Move( Ciphertext.Memory^, FCiphertext_Longs[0], FBlockSize_InBytes); -XXTEA_Decrypt( FKey.FNativeKey, FCiphertext_Longs, FPlaintext_Longs); -Move( FPlaintext_Longs[0], Plaintext.Memory^, FBlockSize_InBytes) -end; - - - -procedure TXXTEA_BlockCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); -begin -Move( Plaintext.Memory^, FPlaintext_Longs[0], FBlockSize_InBytes); -XXTEA_Encrypt( FKey.FNativeKey, FPlaintext_Longs, FCiphertext_Longs); -Move( FCiphertext_Longs[0], Ciphertext.Memory^, FBlockSize_InBytes) -end; - - -procedure TXXTEA_BlockCodec.Reset; -begin // Not used -BurnMemory( FPlaintext_Longs [0], FBlockSize_InBytes); -BurnMemory( FCiphertext_Longs[0], FBlockSize_InBytes) -end; - - -{ TAbbrieviatingStream } - -constructor TAbbrieviatingStream.Create( - OutputStream1: TStream; ClipAmount1: integer); -begin -FOutputStream := OutputStream1; -FClipAmount := ClipAmount1; -SetLength( FBuffer, FClipAmount + 1024); -FBufLen := 0 -end; - -procedure TAbbrieviatingStream.EndStreaming; -begin -SetLength( FBuffer, 0) -end; - -function TAbbrieviatingStream.GetSize: int64; -begin -result := 0 // Not used -end; - -function TAbbrieviatingStream.Read( var Buffer; Count: Integer): Longint; -begin -result := 0 // Not used -end; - -function TAbbrieviatingStream.Seek( - const Offset: Int64; Origin: TSeekOrigin): int64; -begin -result := 0 // Not used -end; - -procedure TAbbrieviatingStream.SetSize( const NewSize: int64); -begin // Not used -end; - - - -function TAbbrieviatingStream.Write( const Buffer; Count: Integer): Longint; -var - Amnt, Succeeded: integer; - P: PByte; -begin -P := @Buffer; -result := 0; -while Count > 0 do - begin - // 1. Buffer in as much as we can. - Amnt := FClipAmount - Length( FBuffer); - if Amnt < Count then - Amnt := Count; - if Amnt > 0 then - begin - Move( P^, FBuffer[FBufLen], Amnt); - Inc( P, Amnt); - Inc( FBufLen, Amnt); - Dec( Count, Amnt); - Inc( result, Amnt) - end; - - // 2. Pass-out our excess above the clip amount. - Amnt := FBufLen - FClipAmount; - if Amnt > 0 then - begin - if assigned( FOutputStream) then - Succeeded := FOutputStream.Write( FBuffer, Amnt) - else - Succeeded := 0; - if Succeeded > 0 then - begin - Dec( FBufLen, Succeeded); - if FBufLen > 0 then - Move( FBuffer[Succeeded], FBuffer[0], FBufLen) - end; - if Succeeded <> Amnt then break // Fail. Don't go further. - end - end -end; - -end. +{$I TPLB3.Common.inc} + +unit TPLB3.XXTEA; +{* ***** BEGIN LICENSE BLOCK ***** +Copyright 2010 Sean B. Durkin +This file is part of TurboPower LockBox 3. TurboPower LockBox 3 is free +software being offered under a dual licensing scheme: LGPL3 or MPL1.1. + +The contents of this file are subject to the Mozilla Public License (MPL) +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Alternatively, you may redistribute it and/or modify it under the terms of +the GNU Lesser General Public License (LGPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +You should have received a copy of the Lesser GNU General Public License +along with TurboPower LockBox 3. If not, see . + +TurboPower LockBox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. In relation to LGPL, +see the GNU Lesser General Public License for more details. In relation to MPL, +see the MPL License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code for TurboPower LockBox version 2 +and earlier was TurboPower Software. + + * ***** END LICENSE BLOCK ***** *} + + +interface +uses TPLB3.StreamCipher, TPLB3.BlockCipher, Classes, Types, TPLB3.Decorators; + +type + +{$IF compilerversion >= 21} [DesignDescription( +'XXTEA is implemented here with the following options set so:'#13#10 + +'(*) The encoding of longwords is little-endien.'#13#10 + +'(*) Empty plaintext message maps to empty ciphertext message.'#13#10 + +'(*) For plaintext messages less than or equal to 199 bytes:'#13#10 + +'(**) The end of the plaintext is padded out PKCS7 style (RFC 3852) to 4-byte alignment;'#13#10 + +'(**) 8 bytes of salt is appended to the plaintext;'#13#10 + +'(**) The resultant extended plaintext is encrypted in XXTEA long block mode -'#13#10 + +' That is to say, the block size is set to be the message size.'#13#10 + +'(*) For plaintext messages more than or equal to 200 bytes:'#13#10 + +'(**) 12 random bytes are appended to the plaintext;'#13#10 + +'(**) The block size is fixed to 212 bytes;'#13#10 + +'(**) Normal block-cipher encryption applies according to your selected'#13#10 + +' chaining mode. As usual, this includes 64 bits of automatic salting,'#13#10 + +' and smart block quantisation (Ciphertext stealing or key-streaming,'#13#10 + +' as appropriate to the chaining mode).' +)] {$IFEND} +TXXTEA_LargeBlock = class( TInterfacedObject, + IStreamCipher, ICryptoGraphicAlgorithm, IControlObject) + private + FChaining: IBlockChainingModel; + + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function SeedByteSize: integer; + function Parameterize( const Params: IInterface): IStreamCipher; + function Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; + function Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor; + function ControlObject: TObject; + + public + constructor Create; + end; + + + + TTEA_Key = packed array[ 0.. 3 ] of longword; + +procedure XXTEA_Encrypt( // Corrected Block TEA encryption primitive. + const Key: TTEA_Key; + const Plaintext: TLongWordDynArray; // At least 2 + var Ciphertext: TLongWordDynArray); // Same length as Plaintext + +procedure XXTEA_Decrypt( // Corrected Block TEA encryption primitive. + const Key: TTEA_Key; + const Ciphertext: TLongWordDynArray; // At least 2 + var Plaintext : TLongWordDynArray); // Same length as Ciphertext + + +implementation + + + + + + + + + + + + + +uses SysUtils, Math, TPLB3.StreamUtils, TPLB3.Constants, TPLB3.StreamToBlock, + TPLB3.PointerArithmetic, TPLB3.I18n, TPLB3.CBC, TPLB3.Random, + TPLB3.Compatibility; + + + +type +TXXTEA_LE_Key = class( TSymetricKey) + public + FNativeKey: TTEA_Key; + constructor Create( Seed: TStream; isStore: boolean); + {Above: False=from password or random seed; True=from SaveToStream} + + procedure SaveToStream( Stream: TStream); override; + procedure Burn; override; + end; + + +TXXTEA_LargeBlock_LE_Encryptor = class( TInterfacedObject, + IStreamEncryptor, IBlockCipherSelector) + public + constructor Create( Owner1: TXXTEA_LargeBlock; Key: TXXTEA_LE_Key; CipherText: TStream); + destructor Destroy; override; + + private + FOwner: TXXTEA_LargeBlock; + FKey: TXXTEA_LE_Key; + FCipherText: TStream; + FBuffer: TBytes; + FBufLen: integer; + FisBuffering: boolean; + FFixedCipher: IStreamCipher; + FFixedEnc: IStreamEncryptor; + + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + procedure Encrypt( const Plaintext: TStream); + procedure End_Encrypt; + procedure Reset; + end; + + +TAbbrieviatingStream = class( TStream) + private + FOutputStream: TStream; + FClipAmount: integer; + FBuffer: TBytes; + FBufLen: integer; + + protected + function GetSize: int64; override; + procedure SetSize( const NewSize: int64); override; + + public + constructor Create( OutputStream1: TStream; ClipAmount1: integer); + function Read ( var Buffer; Count: Longint): Longint; override; + function Write( const Buffer; Count: Longint): Longint; override; + function Seek ( const Offset: Int64; Origin: TSeekOrigin): int64; override; + + procedure EndStreaming; + end; + + + +TXXTEA_LargeBlock_LE_Decryptor = class( TInterfacedObject, + IStreamDecryptor, IBlockCipherSelector) + public + constructor Create( Owner1: TXXTEA_LargeBlock; Key: TXXTEA_LE_Key; PlainText: TStream); + destructor Destroy; override; + + private + FOwner: TXXTEA_LargeBlock; + FKey: TXXTEA_LE_Key; + FPlainText: TStream; + FBuffer: TBytes; + FBufLen: integer; + FisBuffering: boolean; + FFixedCipher: IStreamCipher; + FFixedDec: IStreamDecryptor; + FOutputBuffer: TAbbrieviatingStream; + + function GetBlockCipher : IBlockCipher; + function GetChainMode : IBlockChainingModel; + procedure Decrypt( const Ciphertext: TStream); + procedure End_Decrypt; + procedure Reset; + end; + + +TXXTEA_Block = class( TInterfacedObject, + IBlockCipher, ICryptoGraphicAlgorithm) + private + FBlockSize: integer; + function DisplayName: string; + function ProgId: string; + function Features: TAlgorithmicFeatureSet; + function DefinitionURL: string; + function WikipediaReference: string; + function GenerateKey( Seed: TStream): TSymetricKey; + function LoadKeyFromStream( Store: TStream): TSymetricKey; + function BlockSize: integer; // in units of bits. Must be a multiple of 8. + function KeySize: integer; // in units of bits. + function SeedByteSize: integer; // Size that the input of the GenerateKey must be. + function MakeBlockCodec( Key: TSymetricKey): IBlockCodec; + function SelfTest_Key: string; + function SelfTest_Plaintext: string; + function SelfTest_Ciphertext: string; + + public + constructor Create( BlockSize1: integer); + end; + + +TXXTEA_BlockCodec = class( TInterfacedObject, IBlockCodec) + private + FBlockSize_InBytes: integer; + FKey: TXXTEA_LE_Key; + FPlaintext_Longs: TLongWordDynArray; + FCiphertext_Longs: TLongWordDynArray; + + procedure Encrypt_Block( Plaintext{in}, Ciphertext{out}: TMemoryStream); + procedure Decrypt_Block( Plaintext{out}, Ciphertext{in}: TMemoryStream); + procedure Reset; + procedure Burn; + + public + constructor Create( Key1: TXXTEA_LE_Key; BlockSize1: integer); + end; + +//type +// TTEA_Key = array[ 0.. 3 ] of longword; +// TLongs = array of longword; + +// XXTEA primitives +// In the following comment section, read ")-" as "}". +{ The original formulation of the Corrected Block TEA algorithm, published by + David Wheeler and Roger Needham, is as follows: + + #define MX (z>>5^y<<2) + (y>>3^z<<4)^(sum^y) + (k[p&3^e]^z); + long btea(long* v, long n, long* k) { + unsigned long z=v[n-1], y=v[0], sum=0, e, DELTA=0x9e3779b9; + long p, q ; + if (n > 1) { /* Coding Part */ + q = 6 + 52/n; + while (q-- > 0) { + sum += DELTA; + e = (sum >> 2) & 3; + for (p=0; p> 2) & 3; + for (p=n-1; p>0; p--) z = v[p-1], y = v[p] -= MX; + z = v[n-1]; + y = v[0] -= MX; + sum -= DELTA; + )- + return 0; + )- + return 1; + )- + +According to Needham and Wheeler: + BTEA will encode or decode n words as a single block where n > 1 + * v is the n word data vector + * k is the 4 word key + * n is negative for decoding + * if n is zero result is 1 and no coding or decoding takes place, otherwise the result is zero + * assumes 32 bit 'long' and same endian coding and decoding +} + + + +const DELTA = $9e3779b9; // For Little-endien implementations only. + +function Mx( + const z, y, sum: longword; + const k: TTEA_Key; const p, e: longword): longword; +{$IF CompilerVersion >= 17.0} inline; {$IFEND} +begin +result := (((z shr 5) xor (y shl 2)) + + ((y shr 3) xor (z shl 4))) xor ((sum xor y) + + (k[(p and 3) xor e] xor z)) +end; + + +procedure XXTEA_Encrypt( // Corrected Block TEA encryption primitive. + const Key: TTEA_Key; + const Plaintext : TLongWordDynArray; // At least 2 + var Ciphertext: TLongWordDynArray); // Same length as Plaintext +var + n: integer; + z, sum: longword; + e, q, p: LongWord; +begin +n := Length( Plaintext); +Assert( n >= 2, 'Plaintext too short'); +z := Plaintext[ n-1]; +if Length( Ciphertext) <> n then + SetLength( Ciphertext, n); +Move( Plaintext[0], Ciphertext[0], n * SizeOf( longword)); +sum := 0; +for q := 5 + (52 div n) downto 0 do + begin + Inc( sum, DELTA); + e := (sum shr 2) and 3; + for p := 0 to n - 2 do + begin + z := Ciphertext[ p] + MX( z, Ciphertext[ p + 1], sum, Key, p, e); // z = v[p] += MX + Ciphertext[ p] := z + end; + z := Ciphertext[ n-1] + MX( z, Ciphertext[ 0], sum, Key, n - 1, e); + Ciphertext[ n-1] := z + end +end; + + + +procedure XXTEA_Decrypt( // Corrected Block TEA decryption primitive. + const Key: TTEA_Key; + const Ciphertext: TLongWordDynArray; // At least 2 + var Plaintext : TLongWordDynArray); // Same length as Ciphertext +var + n: integer; + y: LongWord; + sum: LongWord; + e: LongWord; + p: LongWord; +begin +n := Length( Ciphertext); +Assert( n >= 2, 'Ciphertext too short'); +if Length( Plaintext) <> n then + SetLength( Plaintext, n); +Move( Ciphertext[0], Plaintext[0], n * SizeOf( longword)); +sum := (6 + (52 div Cardinal(n))) * DELTA; +y := Plaintext[0]; +while sum <> 0 do + begin + e := (sum shr 2) and 3; + for p := n - 1 downto 1 do + begin + y := Plaintext[p] - Mx( Plaintext[p - 1], y, sum, Key, p, e); + Plaintext[p] := y + end; + y := Plaintext[0] - Mx( Plaintext[n-1], y, sum, Key, 0, e); + Plaintext[0] := y; + Dec( sum, DELTA) + end +end; + + + +{ TXXTEA_LargeBlock } + +function TXXTEA_LargeBlock.ControlObject: TObject; +begin +result := self +end; + +constructor TXXTEA_LargeBlock.Create; +begin +end; + + +function TXXTEA_LargeBlock.DefinitionURL: string; +begin +result := 'http://www.movable-type.co.uk/scripts/xxtea.pdf' +end; + + +function TXXTEA_LargeBlock.DisplayName: string; +begin +result := 'XXTEA (large block; little-endien)' +end; + + + +function TXXTEA_LargeBlock.Features: TAlgorithmicFeatureSet; +begin +result := [afCryptographicallyWeak, afDoesNotNeedSalt, afOpenSourceSoftware] +end; + + + +function TXXTEA_LargeBlock.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := TXXTEA_LE_Key.Create( Seed, False) +end; + + +function TXXTEA_LargeBlock.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := TXXTEA_LE_Key.Create( Store, True) +end; + + +function TXXTEA_LargeBlock.Parameterize( + const Params: IInterface): IStreamCipher; +var + BlockCipherSelector: IBlockCipherSelector; + Chaining: IBlockChainingModel; + Newbie: TXXTEA_LargeBlock; +begin +result := nil; +if assigned( FChaining) then exit; +if Supports( Params, IBlockCipherSelector, BlockCipherSelector) then + Chaining := BlockCipherSelector.GetChainMode; +if not assigned( Chaining) then exit; +Newbie := TXXTEA_LargeBlock.Create; +Newbie.FChaining := Chaining; +result := Newbie +end; + + + +function TXXTEA_LargeBlock.ProgId: string; +begin +result := XXTEA_Large_ProgId +end; + + +function TXXTEA_LargeBlock.SeedByteSize: integer; +begin +result := 128 +end; + + +function TXXTEA_LargeBlock.Start_Encrypt( + Key: TSymetricKey; CipherText: TStream): IStreamEncryptor; +begin +result := TXXTEA_LargeBlock_LE_Encryptor + .Create( self, Key as TXXTEA_LE_Key, Ciphertext) +end; + + +function TXXTEA_LargeBlock.Start_Decrypt( + Key: TSymetricKey; PlainText: TStream): IStreamDecryptor; +begin +result := TXXTEA_LargeBlock_LE_Decryptor + .Create( self, Key as TXXTEA_LE_Key, Plaintext) +end; + + +function TXXTEA_LargeBlock.WikipediaReference: string; +begin +result := 'XXTEA' +end; + + +{ TXXTEA_LE_Key } + +procedure TXXTEA_LE_Key.Burn; +begin +FillChar( FNativeKey, SizeOf( FNativeKey), 0) +end; + + +constructor TXXTEA_LE_Key.Create( Seed: TStream; isStore: boolean); +begin +Seed.ReadBuffer( FNativeKey, SizeOf( FNativeKey)) +end; + + +procedure TXXTEA_LE_Key.SaveToStream( Stream: TStream); +begin +Stream.WriteBuffer( FNativeKey, SizeOf( FNativeKey)) +end; + +const + EncryptionBufferSize = 200; + LargeMessageSaltTailLength = 12; + DecryptionBufferSize = EncryptionBufferSize + LargeMessageSaltTailLength; + + BlockSize_InBytes = 212; // 212 bytes or 53 longwords. + // This does not have to be 53 longwords. It is fairly arbitary. + // Lower values would be valid, and perhaps more appropriate for + // 8-bit chaining modes. + BlockSize_InBits = BlockSize_InBytes * 8; + +{ TXXTEA_LargeBlock_LE_Encryptor } + +constructor TXXTEA_LargeBlock_LE_Encryptor.Create( + Owner1: TXXTEA_LargeBlock; + Key: TXXTEA_LE_Key; CipherText: TStream); +begin +FOwner := Owner1; +FKey := Key; +FCiphertext := CipherText; +SetLength( FBuffer, EncryptionBufferSize); +FBufLen := 0; +FisBuffering := True +end; + +destructor TXXTEA_LargeBlock_LE_Encryptor.Destroy; +begin +SetLength( FBuffer, 0); +inherited +end; + +{ +XXTEA is a variable block length cipher. So how does that fit into +our model of block ciphers being of fixed block length? Apply the +following strategy. + +Let + n = Size of the plaintext payload (before salting, padding etc) in bytes. + c = Size of the ciphertext message in bytes. + B = Size of the XXTEA block in bytes. + +1. ENCRYPTION +============= +Upon encryption buffer up to 200 bytes. + +1.1 Case One: + An empty plaintext maps to an empty ciphertext. + n = 0 ==> c := 0 + +1.2 Small message case: + For a small message, just encrypt the whole thing directly in one block. + Salt and pad as required. + n <= 199 ==> + 1.2.1 Pad the message out at the tail to make it align to quad-byte. + The last pad byte value should be equal to the count of pad bytes, + in esse 1 to 4. There must be at least 1 pad byte. + 1.2.2 Salt the plaintext. That is to say inject 8 random bytes at the + tail of the plaintext. Due to the cyclic nature of XXTEA, the + salt does not need to be at the head. + 1.2.3 Encrypt the salted padded message as one XXTEA block. + c in [n+9 .. n+12] + c <= 211 + B = c + +1.3 Large message case: + For a large message, to be practical we must set reasonable block sizes. + Append 12 bytes of salt at the tail; and use normal block-to-stream adaption + with a block size of 212 bytes or 53 longwords. + n >= 200 ==> + 1.3.1 Append 12 random bytes to the end. + 1.3.2 Set block size to fixed 212 bytes. + 1.3.3 Encrypt using StreamToBlock adapter with XXTEA and the user's + requested chaining mode. This will intrinsically include + 8 bytes of salt (unless the mode is ECB), and block quantisation + most appropriate to the selected chaining mode. + c >= n + 12 + c >= 212 + B = 212 + +2. DECRYPTION +============= +Upon decryption buffer up to 212 bytes. + +2.1 Case One: + An empty ciphertext maps to an empty plaintext. + c = 0 ==> n := 0 + +2.2 Small message case: + For a small message, just decrypt the whole thing directly in one block. + Remove salt and de-pad as required. + c <= 211 ==> + 2.2.1 Decrypt the message as one XXTEA block. + 2.2.2 De-salt the decrypted plaintext. That is to say discard the last + 8 bytes at the head of the decrypted plaintext. + 2.2.3 De-pad the message out at the tail. The number of pad bytes to + remove is the value of the last byte. + B := c + n in [c - 12 .. c - 9] + n <= 199 + +2.3 Large message case: + For a large message, decrypt with a normal block-to-stream adaption. + Strip 12 bytes off from the tail; and use a block size of 212 bytes. + c >= 212 + ==> + 3.3.1 Set block size to fixed 212 bytes. + 3.3.2 Decrypt using StreamToBlock adapter with XXTEA and the user's + requested chaining mode. This will intrinsically include + 8 bytes of salt (unless the mode is ECB), and block quantisation + most appropriate to the selected chaining mode. + 3.3.3 Discard 12 bytes at the end. + c >= n + 12 + n >= 200 + B := 212 + + +} + + +procedure TXXTEA_LargeBlock_LE_Encryptor.Encrypt( const Plaintext: TStream); +var + Amnt: integer; + Tmp: IStreamCipher; + PTCopy: TStream; +begin +Amnt := -1; +if FisBuffering then + begin + // At this point we are not sure if it going to be large message + // or short message case. + Amnt := EncryptionBufferSize - FBufLen; + Amnt := Plaintext.Read( FBuffer[FBufLen], Amnt); + Inc( FBufLen, Amnt); + if FBufLen >= EncryptionBufferSize then + begin // Large message case, switch to adapter. + FFixedCipher := TStreamToBlock_Adapter.Create; + Tmp := FFixedCipher.Parameterize( self); + // The above line casts this to IBlockCipherSelector then calls: + // GetBlockCipher; and + // GetChainMode + if assigned( Tmp) then + FFixedCipher := Tmp; + FFixedEnc := FFixedCipher.Start_Encrypt( FKey, FCipherText); + PTCopy := TMemoryStream.Create; + try + PTCopy.Write( FBuffer[0], FBufLen); + PTCopy.Position := 0; + FFixedEnc.Encrypt( PTCopy) + finally + PTCopy.Free + end ; + FBufLen := 0; + FisBuffering := False + end + end; +if (not FisBuffering) and (Amnt <> 0) then + FFixedEnc.Encrypt( Plaintext) +end; + + + +procedure TXXTEA_LargeBlock_LE_Encryptor.End_Encrypt; +var + RequiredSizeIncrease, RequiredSize: integer; + j, L: integer; + PlaintextArray, CiphertextArray: TLongWordDynArray; + PTCopy: TMemoryStream; +begin +if FisBuffering then + begin + if FBufLen = 0 then exit; +// n <= 199 ==> +// 1.2.1 Pad the message out at the tail to make it align to quad-byte. +// The last pad byte value should be equal to the count of pad bytes, +// in esse 1 to 4. There must be at least 1 pad byte. +// 1.2.2 Salt the plaintext. That is to say inject 8 random bytes at the +// tail of the plaintext. Due to the cyclic nature of XXTEA, the +// salt does not need to be at the head. +// 1.2.3 Encrypt the salted padded message as one XXTEA block. + RequiredSizeIncrease := 4 - (FBufLen mod 4); + RequiredSize := FBufLen + RequiredSizeIncrease; // How much padding is needed? + for j := FBufLen to FBufLen + RequiredSizeIncrease - 1 do + FBuffer[j] := RequiredSizeIncrease; // Pad it out. + L := (RequiredSize div 4) + 2; + SetLength( PlaintextArray, L); // Setup longword array. + Move( FBuffer[0], PlaintextArray[0], RequiredSize); // Convert padded payload to longwords. + TRandomStream.Instance.Read( PlaintextArray[L-2], 8); // Salting. + SetLength( CiphertextArray, L); + XXTEA_Encrypt( FKey.FNativeKey, PlaintextArray, CiphertextArray); // One-block encryption. + FCipherText.Write( CiphertextArray[0], L * 4) + end + else + begin + PTCopy := TMemoryStream.Create; + try + PTCopy.Size := LargeMessageSaltTailLength; + TRandomStream.Instance.Read( PTCopy.Memory^, LargeMessageSaltTailLength); // 12 random bytes + PTCopy.Position := 0; + FFixedEnc.Encrypt( PTCopy) + finally + PTCopy.Free + end ; + FFixedEnc.End_Encrypt + end; +FFixedEnc := nil; +FFixedCipher := nil +end; + + + + +function TXXTEA_LargeBlock_LE_Encryptor.GetBlockCipher: IBlockCipher; +begin +result := TXXTEA_Block.Create( BlockSize_InBits) +end; + +function TXXTEA_LargeBlock_LE_Encryptor.GetChainMode: IBlockChainingModel; +begin +// Called by Parameterize. +result := FOwner.FChaining; +if not assigned( result) then + result := TCBC.Create +end; + +procedure TXXTEA_LargeBlock_LE_Encryptor.Reset; +begin +FBufLen := 0; +FisBuffering := True; +FFixedCipher := nil; +FFixedEnc := nil +end; + + +{ TXXTEA_LargeBlock_LE_Decryptor } + +constructor TXXTEA_LargeBlock_LE_Decryptor.Create( + Owner1: TXXTEA_LargeBlock; + Key: TXXTEA_LE_Key; PlainText: TStream); +begin +FOwner := Owner1; +FKey := Key; +FPlaintext := PlainText; +SetLength( FBuffer, DecryptionBufferSize); +FBufLen := 0; +FisBuffering := True +end; + + +procedure TXXTEA_LargeBlock_LE_Decryptor.Decrypt( const Ciphertext: TStream); +var + Amnt: integer; + Tmp: IStreamCipher; + PTCopy: TStream; +begin +Amnt := -1; +if FisBuffering then + begin + // At this point we are not sure if it going to be large message + // or short message case. + Amnt := DecryptionBufferSize - FBufLen; + Amnt := Ciphertext.Read( FBuffer[FBufLen], Amnt); + Inc( FBufLen, Amnt); + if FBufLen >= DecryptionBufferSize then + begin // Large message case, switch to adapter. + FFixedCipher := TStreamToBlock_Adapter.Create; + Tmp := FFixedCipher.Parameterize( self); + // The above line casts this to IBlockCipherSelector then calls: + // GetBlockCipher; and + // GetChainMode + if assigned( Tmp) then + FFixedCipher := Tmp; + FreeAndNil( FOutputBuffer); + FOutputBuffer := TAbbrieviatingStream + .Create( FPlainText, LargeMessageSaltTailLength); + FFixedDec := FFixedCipher.Start_Decrypt( FKey, FOutputBuffer); + PTCopy := TMemoryStream.Create; + try + PTCopy.Write( FBuffer[0], FBufLen); + PTCopy.Position := 0; + FFixedDec.Decrypt( PTCopy) + finally + PTCopy.Free + end ; + FBufLen := 0; + FisBuffering := False + end + end; +if (not FisBuffering) and (Amnt <> 0) then + FFixedDec.Decrypt( Ciphertext) +end; + + + +destructor TXXTEA_LargeBlock_LE_Decryptor.Destroy; +begin +FFixedDec := nil; +FFixedCipher := nil; +FreeAndNil( FOutputBuffer); +inherited +end; + +procedure TXXTEA_LargeBlock_LE_Decryptor.End_Decrypt; +var + RequiredSizeDecrease: integer; + L: integer; + PlaintextArray, CiphertextArray: TLongWordDynArray; +begin +if FisBuffering then + begin + if FBufLen = 0 then exit; +// c <= 211 ==> +// 2.2.1 Decrypt the message as one XXTEA block. +// 2.2.2 De-salt the decrypted plaintext. That is to say discard the last +// 8 bytes at the head of the decrypted plaintext. +// 2.2.3 De-pad the message out at the tail. The number of pad bytes to +// remove is the value of the last byte. + L := FBufLen div 4; + SetLength( CiphertextArray, L); // Setup longword array. + SetLength( PlaintextArray , L); + if L >= 2 then + begin + // XXTEA only valid if blocksize is at least 2 longwords. + // With the padding, this should ALWAYS be the case. + // Otherwise the ciphertext message is invalid. + Move( FBuffer[0], CiphertextArray[0], FBufLen); // Convert padded message to longwords. + XXTEA_Decrypt( FKey.FNativeKey, CiphertextArray, PlaintextArray); // One-block encryption. + end; + if FBufLen >= 8 then + Dec( FBufLen, 8) // de-salt + else + FBufLen := 0; + if FBufLen > 0 then // Calculate pad. + RequiredSizeDecrease := FBuffer[FBufLen-1] + else + RequiredSizeDecrease := 0; + if FBufLen >= RequiredSizeDecrease then + Dec( FBufLen, RequiredSizeDecrease) // de-pad + else + FBufLen := 0; + if L > 0 then + FPlainText.Write( CiphertextArray[0], L * 4) + end + else + begin + FFixedDec.End_Decrypt; + FOutputBuffer.EndStreaming; // Discard last 12 bytes + FreeAndNil( FOutputBuffer) + end; +FFixedDec := nil; +FFixedCipher := nil +end; + + + +function TXXTEA_LargeBlock_LE_Decryptor.GetBlockCipher: IBlockCipher; +begin +result := TXXTEA_Block.Create( BlockSize_InBits) +end; + +function TXXTEA_LargeBlock_LE_Decryptor.GetChainMode: IBlockChainingModel; +begin +result := FOwner.FChaining; +if not assigned( result) then + result := TCBC.Create +end; + +procedure TXXTEA_LargeBlock_LE_Decryptor.Reset; +begin +FBufLen := 0; +FisBuffering := True; +FFixedCipher := nil; +FFixedDec := nil; +FreeAndNil( FOutputBuffer) +end; + + +{ TXXTEA_Block } + +function TXXTEA_Block.BlockSize: integer; +begin +result := FBlockSize +end; + +constructor TXXTEA_Block.Create( BlockSize1: integer); +begin +FBlockSize := BlockSize1 +end; + +function TXXTEA_Block.DefinitionURL: string; +begin +result := '' // Not used. +end; + +function TXXTEA_Block.DisplayName: string; +begin +result := '' // Not used. +end; + + + +function TXXTEA_Block.Features: TAlgorithmicFeatureSet; +begin +result := [afCryptographicallyWeak, afForRunTimeOnly, afOpenSourceSoftware] +end; + + + +function TXXTEA_Block.GenerateKey( Seed: TStream): TSymetricKey; +begin +result := nil // Not used. +end; + +function TXXTEA_Block.KeySize: integer; +begin // Not used +result := SizeOf( TTEA_Key) * 8 +end; + +function TXXTEA_Block.LoadKeyFromStream( Store: TStream): TSymetricKey; +begin +result := nil // Not used. +end; + +function TXXTEA_Block.MakeBlockCodec( Key: TSymetricKey): IBlockCodec; +begin +result := TXXTEA_BlockCodec.Create( Key as TXXTEA_LE_Key, FBlockSize) +end; + + +function TXXTEA_Block.ProgId: string; +begin +result := '' // Not used +end; + + +function TXXTEA_Block.SeedByteSize: integer; +begin +result := -1 // Not used +end; + +function TXXTEA_Block.SelfTest_Ciphertext: string; +begin +result := '' // Not used +end; + +function TXXTEA_Block.SelfTest_Key: string; +begin +result := '' // Not used +end; + +function TXXTEA_Block.SelfTest_Plaintext: string; +begin +result := '' // Not used +end; + +function TXXTEA_Block.WikipediaReference: string; +begin +result := '' // Not used +end; + + +{ TXXTEA_BlockCodec } + +procedure TXXTEA_BlockCodec.Burn; +begin // Not used +end; + + + +constructor TXXTEA_BlockCodec.Create( Key1: TXXTEA_LE_Key; BlockSize1: integer); +begin +FKey := Key1; +FBlockSize_InBytes := BlockSize1 div 8; +SetLength( FPlaintext_Longs, FBlockSize_InBytes div 4); // At least 2 longwords +SetLength( FCiphertext_Longs, Length( FPlaintext_Longs)) +end; + + + +procedure TXXTEA_BlockCodec.Decrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +Move( Ciphertext.Memory^, FCiphertext_Longs[0], FBlockSize_InBytes); +XXTEA_Decrypt( FKey.FNativeKey, FCiphertext_Longs, FPlaintext_Longs); +Move( FPlaintext_Longs[0], Plaintext.Memory^, FBlockSize_InBytes) +end; + + + +procedure TXXTEA_BlockCodec.Encrypt_Block( Plaintext, Ciphertext: TMemoryStream); +begin +Move( Plaintext.Memory^, FPlaintext_Longs[0], FBlockSize_InBytes); +XXTEA_Encrypt( FKey.FNativeKey, FPlaintext_Longs, FCiphertext_Longs); +Move( FCiphertext_Longs[0], Ciphertext.Memory^, FBlockSize_InBytes) +end; + + +procedure TXXTEA_BlockCodec.Reset; +begin // Not used +BurnMemory( FPlaintext_Longs [0], FBlockSize_InBytes); +BurnMemory( FCiphertext_Longs[0], FBlockSize_InBytes) +end; + + +{ TAbbrieviatingStream } + +constructor TAbbrieviatingStream.Create( + OutputStream1: TStream; ClipAmount1: integer); +begin +FOutputStream := OutputStream1; +FClipAmount := ClipAmount1; +SetLength( FBuffer, FClipAmount + 1024); +FBufLen := 0 +end; + +procedure TAbbrieviatingStream.EndStreaming; +begin +SetLength( FBuffer, 0) +end; + +function TAbbrieviatingStream.GetSize: int64; +begin +result := 0 // Not used +end; + +function TAbbrieviatingStream.Read( var Buffer; Count: Integer): Longint; +begin +result := 0 // Not used +end; + +function TAbbrieviatingStream.Seek( + const Offset: Int64; Origin: TSeekOrigin): int64; +begin +result := 0 // Not used +end; + +procedure TAbbrieviatingStream.SetSize( const NewSize: int64); +begin // Not used +end; + + + +function TAbbrieviatingStream.Write( const Buffer; Count: Integer): Longint; +var + Amnt, Succeeded: integer; + P: PByte; +begin +P := @Buffer; +result := 0; +while Count > 0 do + begin + // 1. Buffer in as much as we can. + Amnt := FClipAmount - Length( FBuffer); + if Amnt < Count then + Amnt := Count; + if Amnt > 0 then + begin + Move( P^, FBuffer[FBufLen], Amnt); + Inc( P, Amnt); + Inc( FBufLen, Amnt); + Dec( Count, Amnt); + Inc( result, Amnt) + end; + + // 2. Pass-out our excess above the clip amount. + Amnt := FBufLen - FClipAmount; + if Amnt > 0 then + begin + if assigned( FOutputStream) then + Succeeded := FOutputStream.Write( FBuffer, Amnt) + else + Succeeded := 0; + if Succeeded > 0 then + begin + Dec( FBufLen, Succeeded); + if FBufLen > 0 then + Move( FBuffer[Succeeded], FBuffer[0], FBufLen) + end; + if Succeeded <> Amnt then break // Fail. Don't go further. + end + end +end; + +end. diff --git a/run/uTPLb_D7Compatibility.pas b/LockBox3/run/uTPLb_D7Compatibility.pas similarity index 92% rename from run/uTPLb_D7Compatibility.pas rename to LockBox3/run/uTPLb_D7Compatibility.pas index 6398f5c..06b8339 100644 --- a/run/uTPLb_D7Compatibility.pas +++ b/LockBox3/run/uTPLb_D7Compatibility.pas @@ -1,11 +1,11 @@ -unit uTPLb_D7Compatibility; -interface - -{$IF compilerversion <= 17} -type -TBytes = packed array of byte; -{$IFEND} - -implementation - -end. +unit uTPLb_D7Compatibility; +interface + +{$IF compilerversion <= 17} +type +TBytes = packed array of byte; +{$IFEND} + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/LICENSE.txt b/LockBox3/unit-tests/dunit-m/LICENSE.txt new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Compilers.inc b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Compilers.inc new file mode 100644 index 0000000..7d320eb --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Compilers.inc @@ -0,0 +1,665 @@ +//---------------------------------------------------------------------------------------------------------------------- +// Include file to determine which compiler is currently being used to build the project/component. +// This file uses ideas from Brad Stowers DFS.inc file. +// +// Portions created by Mike Lischke are +// Copyright (C) 1999, 2008 Mike Lischke. All Rights Reserved. +// Portions created by Jim Kueneman are +// Copyright (C) 2005, 2008 Jim Kueneman. All Rights Reserved. +// +//---------------------------------------------------------------------------------------------------------------------- +// +// This unit is released under the MIT license: +// Copyright (c) 1999, 2008 Mike Lischke (support@soft-gems.net, www.soft-gems.net). +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +// Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// You are asked to give the author(s) the due credit. This means that you acknowledge the work of the author(s) +// in the product documentation, about box, help or wherever a prominent place is. +// +//---------------------------------------------------------------------------------------------------------------------- +// +// The following symbols are defined: +// +// - COMPILER_1 : Kylix/Delphi/BCB 1.x is the compiler. +// - COMPILER_1_UP : Kylix/Delphi/BCB 1.x or higher is the compiler. +// - COMPILER_2 : Kylix/Delphi 2.x or BCB 1.x is the compiler. +// - COMPILER_2_UP : Kylix/Delphi 2.x or higher, or BCB 1.x or higher is the compiler. +// - COMPILER_3 : Kylix/Delphi/BCB 3.x is the compiler. +// - COMPILER_3_UP : Kylix/Delphi/BCB 3.x or higher is the compiler. +// - COMPILER_4 : Kylix/Delphi/BCB 4.x is the compiler. +// - COMPILER_4_UP : Kylix/Delphi/BCB 4.x or higher is the compiler. +// - COMPILER_5 : Kylix/Delphi/BCB 5.x is the compiler. +// - COMPILER_5_UP : Kylix/Delphi/BCB 5.x or higher is the compiler. +// - COMPILER_6 : Kylix/Delphi/BCB 6.x is the compiler. +// - COMPILER_6_UP : Kylix/Delphi/BCB 6.x or higher is the compiler. +// - COMPILER_7 : Kylix/Delphi/BCB 7.x is the compiler. +// - COMPILER_7_UP : Kylix/Delphi/BCB 7.x or higher is the compiler. +// - COMPILER_8 : Kylix/Delphi/BCB 8.x is the compiler. +// - COMPILER_8_UP : Kylix/Delphi/BCB 8.x or higher is the compiler. +// - COMPILER_9 : Kylix/Delphi/BCB 9.x is the compiler. +// - COMPILER_9_UP : Kylix/Delphi/BCB 9.x or higher is the compiler. +// - COMPILER_10 : Kylix/Delphi/BCB 10.x is the compiler. +// - COMPILER_10_UP : Kylix/Delphi/BCB 10.x or higher is the compiler. +// - COMPILER_11 : Kylix/Delphi/BCB 11.x is the compiler. +// - COMPILER_11_UP : Kylix/Delphi/BCB 11.x or higher is the compiler. +// - COMPILER_12 : Kylix/Delphi/BCB 12.x is the compiler. +// - COMPILER_12_UP : Kylix/Delphi/BCB 12.x or higher is the compiler. +// - COMPILER_14 : Kylix/Delphi/BCB 14.x is the compiler. +// - COMPILER_14_UP : Kylix/Delphi/BCB 14.x or higher is the compiler. +// - COMPILER_15 : Kylix/Delphi/BCB 15.x is the compiler. +// - COMPILER_15_UP : Kylix/Delphi/BCB 15.x or higher is the compiler. +// +// Only defined if Windows is the target: +// - CPPB : Any version of BCB is being used. +// - CPPB_1 : BCB v1.x is being used. +// - CPPB_3 : BCB v3.x is being used. +// - CPPB_3_UP : BCB v3.x or higher is being used. +// - CPPB_4 : BCB v4.x is being used. +// - CPPB_4_UP : BCB v4.x or higher is being used. +// - CPPB_5 : BCB v5.x is being used. +// - CPPB_5_UP : BCB v5.x or higher is being used. +// - CPPB_6 : BCB v6.x is being used. +// - CPPB_6_UP : BCB v6.x or higher is being used. +// - CPPB_XXX is not used any more, use the COMPILER_XXX defines +// +// Only defined if Windows is the target: +// - DELPHI : Any version of Delphi is being used. +// - DELPHI_1 : Delphi v1.x is being used. +// - DELPHI_2 : Delphi v2.x is being used. +// - DELPHI_2_UP : Delphi v2.x or higher is being used. +// - DELPHI_3 : Delphi v3.x is being used. +// - DELPHI_3_UP : Delphi v3.x or higher is being used. +// - DELPHI_4 : Delphi v4.x is being used. +// - DELPHI_4_UP : Delphi v4.x or higher is being used. +// - DELPHI_5 : Delphi v5.x is being used. +// - DELPHI_5_UP : Delphi v5.x or higher is being used. +// - DELPHI_6 : Delphi v6.x is being used. +// - DELPHI_6_UP : Delphi v6.x or higher is being used. +// - DELPHI_7 : Delphi v7.x is being used. +// - DELPHI_7_UP : Delphi v7.x or higher is being used. +// - DELPHI_8 : Delphi v8.x is being used. +// - DELPHI_8_UP : Delphi v8.x or higher is being used. +// - DELPHI_9 : Delphi v9.x is being used. +// - DELPHI_9_UP : Delphi v9.x or higher is being used. +// - DELPHI_XXX is not used any more, use the COMPILER_XXX defines +// +// Only defined if Linux is the target: +// - KYLIX : Any version of Kylix is being used. +// - KYLIX_1 : Kylix 1.x is being used. +// - KYLIX_1_UP : Kylix 1.x or higher is being used. +// - KYLIX_2 : Kylix 2.x is being used. +// - KYLIX_2_UP : Kylix 2.x or higher is being used. +// - KYLIX_3 : Kylix 3.x is being used. +// - KYLIX_3_UP : Kylix 3.x or higher is being used. +// +// Only defined if Linux is the target: +// - QT_CLX : Trolltech's QT library is being used. +// +// Only defined if Delphi.NET is the target: +// - DELPHI.NET : Any version of Delphi.NET is being used. +// - DELPHI.NET_1 : Delphi.NET version 1.x is being used. +// - DELPHI.NET_1_UP : Delphi.NET version 1.x is being used. +//---------------------------------------------------------------------------------------------------------------------- + +{$ifdef CLR} // The common language runtime symbol is only defined for the .NET platform. + {$define DELPHI.NET} + {$ifdef VER160} + {$define DELPHI.NET_1} + {$endif VER160} + + // Compiler defines common to all .NET versions. + {$ifdef DELPHI.NET_1} + {$define DELHI.NET_1_UP} + {$endif DELPHI.NET_1} +{$endif CLR} + +{$ifdef Win32} + +// Compiler defines not specific to a particlular platform. + + // RAD Studio XE (BDS 8.0) DELPHI and BCB are no longer defined, only COMPILER + {$ifdef VER220} + {$define COMPILER_15} + {$endif VER220} + + // RAD Studio 2010 (BDS 7.0) DELPHI and BCB are no longer defined, only COMPILER + {$ifdef VER210} + {$define COMPILER_14} + {$endif VER210} + + // RAD Studio 2009 (BDS 6.0) DELPHI and BCB are no longer defined, only COMPILER + {$ifdef VER200} + {$define COMPILER_12} + {$endif VER200} + + // RAD Studio 2007 (BDS 5.0) DELPHI and BCB are no longer defined, only COMPILER + {$ifdef VER190} + {$define COMPILER_11} + {$endif VER190} + + // DELPHI and BCB are no longer defined, only COMPILER + {$ifdef VER180} + {$define COMPILER_10} + {$endif VER180} + + {$ifdef VER170} + {$define COMPILER_9} + {$define DELPHI} + {$define DELPHI_9} + {$endif VER170} + + {$ifdef VER160} + {$define COMPILER_8} + {$define DELPHI} + {$define DELPHI_8} + {$endif VER160} + + {$ifdef VER150} + {$define COMPILER_7} + {$define DELPHI} + {$define DELPHI_7} + {$endif} + + {$ifdef VER140} + {$define COMPILER_6} + {$ifdef BCB} + {$define CPPB} + {$define CPPB_6} + {$else} + {$define DELPHI} + {$define DELPHI_6} + {$endif} + {$endif} + + {$ifdef VER130} + {$define COMPILER_5} + {$ifdef BCB} + {$define CPPB} + {$define CPPB_5} + {$else} + {$define DELPHI} + {$define DELPHI_5} + {$endif} + {$endif} + + {$ifdef VER125} + {$define COMPILER_4} + {$define CPPB} + {$define CPPB_4} + {$endif} + + {$ifdef VER120} + {$define COMPILER_4} + {$define DELPHI} + {$define DELPHI_4} + {$endif} + + {$ifdef VER110} + {$define COMPILER_3} + {$define CPPB} + {$define CPPB_3} + {$endif} + + {$ifdef VER100} + {$define COMPILER_3} + {$define DELPHI} + {$define DELPHI_3} + {$endif} + + {$ifdef VER93} + {$define COMPILER_2} // C++ Builder v1 compiler is really v2 + {$define CPPB} + {$define CPPB_1} + {$endif} + + {$ifdef VER90} + {$define COMPILER_2} + {$define DELPHI} + {$define DELPHI_2} + {$endif} + + {$ifdef VER80} + {$define COMPILER_1} + {$define DELPHI} + {$define DELPHI_1} + {$endif} + + {$ifdef DELPHI_2} + {$define DELPHI_2_UP} + {$endif} + + {$ifdef DELPHI_3} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$endif} + + {$ifdef DELPHI_4} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$endif} + + {$ifdef DELPHI_5} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$endif} + + {$ifdef DELPHI_6} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$endif} + + {$ifdef DELPHI_7} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$endif} + + {$ifdef DELPHI_8} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$endif} + + {$ifdef DELPHI_9} + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$endif} + + {$ifdef CPPB_3} + {$define CPPB_3_UP} + {$endif} + + {$ifdef CPPB_4} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$endif} + + {$ifdef CPPB_5} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$endif} + + {$ifdef CPPB_6} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + {$endif} + + {$ifdef CPPB_3_UP} + // C++ Builder requires this if you use Delphi components in run-time packages. + {$ObjExportAll On} + {$endif} + +{$else (not Windows)} + // Linux is the target + {$define QT_CLX} + + {$define KYLIX} + + {$ifdef VER140} + {$define COMPILER_6} + {$ifdef conditionalexpressions} + {$if Declared(RTLVersion) and (RTLVersion = 14)} + {$define KYLIX_1} + {$ifend} + + {$if Declared(RTLVersion) and (RTLVersion = 14.2)} + {$define KYLIX_2} + {$ifend} + + {$if Declared(RTLVersion) and (RTLVersion = 14.5)} + {$define KYLIX_3} + {$ifend} + {$endif} + {$endif} + + {$ifdef VER150} + {$define COMPILER_7} + {$define KYLIX_3} + {$endif} + + {$ifdef VER140} + {$define COMPILER_6} + {$define KYLIX_2} + {$endif} + + {$ifdef KYLIX_1} + {$define KYLIX_1_UP} + {$endif} + + {$ifdef KYLIX_2} + {$define KYLIX_2_UP} + {$endif} + + {$ifdef KYLIX_3} + {$define KYLIX_2_UP} + {$define KYLIX_3_UP} + {$endif} + +{$endif Win32} + + +{$ifdef COMPILER_1} + {$define COMPILER_1_UP} +{$endif} + +{$ifdef COMPILER_2} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} +{$endif} + +{$ifdef COMPILER_3} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} +{$endif} + +{$ifdef COMPILER_4} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} +{$endif} + +{$ifdef COMPILER_5} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} +{$endif} + +{$ifdef COMPILER_6} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} +{$endif} + +{$ifdef COMPILER_7} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} +{$endif} + +{$ifdef COMPILER_8} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} +{$endif} + +{$ifdef COMPILER_9} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} +{$endif} + +{$ifdef COMPILER_10} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + +{$endif} + +{$ifdef COMPILER_11} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + {$define COMPILER_11_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + +{$endif} + + +{$ifdef COMPILER_12} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + {$define COMPILER_11_UP} + {$define COMPILER_12_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + +{$endif} + + +{$ifdef COMPILER_13} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + {$define COMPILER_11_UP} + {$define COMPILER_12_UP} + {$define COMPILER_13_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + +{$endif} + +{$ifdef COMPILER_14} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + {$define COMPILER_11_UP} + {$define COMPILER_12_UP} + {$define COMPILER_13_UP} + {$define COMPILER_14_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + +{$endif} + + +// RAD Studio XE +{$ifdef conditionalexpressions} + {$if CompilerVersion >= 22} + {$define COMPILER_1_UP} + {$define COMPILER_2_UP} + {$define COMPILER_3_UP} + {$define COMPILER_4_UP} + {$define COMPILER_5_UP} + {$define COMPILER_6_UP} + {$define COMPILER_7_UP} + {$define COMPILER_8_UP} + {$define COMPILER_9_UP} + {$define COMPILER_10_UP} + {$define COMPILER_11_UP} + {$define COMPILER_12_UP} + {$define COMPILER_13_UP} + {$define COMPILER_14_UP} + {$define COMPILER_15_UP} + // Backwards compatibility + {$define DELPHI_2_UP} + {$define DELPHI_3_UP} + {$define DELPHI_4_UP} + {$define DELPHI_5_UP} + {$define DELPHI_6_UP} + {$define DELPHI_7_UP} + {$define DELPHI_8_UP} + {$define DELPHI_9_UP} + {$define CPPB_3_UP} + {$define CPPB_4_UP} + {$define CPPB_5_UP} + {$define CPPB_6_UP} + + {$ifdef BCB} + {$define CPPB} + {$else} + {$define DELPHI} + {$endif} + {$ifend} +{$endif} + +//---------------------------------------------------------------------------------------------------------------------- diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Readme.txt b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Readme.txt new file mode 100644 index 0000000..940c031 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Common/Readme.txt @@ -0,0 +1,3 @@ +This folder contains files which are used by Virtual Treeview but are of general interest, not only for Virtual Treeview. + +Mike, June 2009 \ No newline at end of file diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Read me.txt b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Read me.txt new file mode 100644 index 0000000..3870852 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Read me.txt @@ -0,0 +1 @@ +ml Jun 19, 2010: The Delphi subfolder, which contains all the package files having their version in the name (and hence aren't flexible enough when using the same package names in different Delphi/CBuilder versions) are now marked as deprecated and will sooner or later be removed. Use the packages subfolder instead. \ No newline at end of file diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibility.pas b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibility.pas new file mode 100644 index 0000000..0b95082 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibility.pas @@ -0,0 +1,774 @@ +unit DUnitM.VTAccessibility; + +//---------------------------------------------------------------------------------------------------------------------- +// +// Version 4.7.0 +// + +// This unit implements iAccessible interfaces for the VirtualTree visual components +// and the currently focused node. +// +// Written by Marco Zehe. (c) 2007 + +{$I '..\Common\Compilers.inc'} + +interface + +uses + Windows, Classes, ActiveX, + {$ifndef COMPILER_10_UP} + MSAAIntf, // MSAA support for Delphi up to 2005 + {$else} + Types, + oleacc, // MSAA support in Delphi 2006 or higher + {$endif COMPILER_10_UP} + DUnitM.VirtualTrees, DUnitM.VTAccessibilityFactory, Controls; + +type + TVirtualTreeAccessibility = class(TInterfacedObject, IDispatch, IAccessible) + private + FVirtualTree: TVirtualStringTree; + public + constructor Create(AVirtualTree: TVirtualStringTree); + + { IAccessibility } + function Get_accParent(out ppdispParent: IDispatch): HResult; stdcall; + function Get_accChildCount(out pcountChildren: Integer): HResult; stdcall; + function Get_accChild(varChild: OleVariant; out ppdispChild: IDispatch): HResult; stdcall; + function Get_accName(varChild: OleVariant; out pszName: WideString): HResult; stdcall; + function Get_accValue(varChild: OleVariant; out pszValue: WideString): HResult; stdcall; + function Get_accDescription(varChild: OleVariant; out pszDescription: WideString): HResult; stdcall; + function Get_accRole(varChild: OleVariant; out pvarRole: OleVariant): HResult; stdcall; + function Get_accState(varChild: OleVariant; out pvarState: OleVariant): HResult; stdcall; + function Get_accHelp(varChild: OleVariant; out pszHelp: WideString): HResult; stdcall; + function Get_accHelpTopic(out pszHelpFile: WideString; varChild: OleVariant; + out pidTopic: Integer): HResult; stdcall; + function Get_accKeyboardShortcut(varChild: OleVariant; out pszKeyboardShortcut: WideString): HResult; stdcall; + function Get_accFocus(out pvarChild: OleVariant): HResult; stdcall; + function Get_accSelection(out pvarChildren: OleVariant): HResult; stdcall; + function Get_accDefaultAction(varChild: OleVariant; out pszDefaultAction: WideString): HResult; stdcall; + function accSelect(flagsSelect: Integer; varChild: OleVariant): HResult; stdcall; + function accLocation(out pxLeft: Integer; out pyTop: Integer; out pcxWidth: Integer; + out pcyHeight: Integer; varChild: OleVariant): HResult; stdcall; + function accNavigate(navDir: Integer; varStart: OleVariant; out pvarEndUpAt: OleVariant): HResult; stdcall; + function accHitTest(xLeft: Integer; yTop: Integer; out pvarChild: OleVariant): HResult; stdcall; + function accDoDefaultAction(varChild: OleVariant): HResult; stdcall; + function Set_accName(varChild: OleVariant; const pszName: WideString): HResult; stdcall; + function Set_accValue(varChild: OleVariant; const pszValue: WideString): HResult; stdcall; + {IDispatch} + function GetIDsOfNames(const IID: TGUID; Names: Pointer; + NameCount: Integer; LocaleID: Integer; DispIDs: Pointer): HRESULT; stdcall; + function GetTypeInfo(Index: Integer; LocaleID: Integer; + out TypeInfo): HRESULT; stdcall; + function GetTypeInfoCount(out Count: Integer): HRESULT; stdcall; + function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer; + Flags: Word; var Params; VarResult: Pointer; ExcepInfo: Pointer; + ArgErr: Pointer): HRESULT; stdcall; + end; + + TVirtualTreeItemAccessibility = class(TVirtualTreeAccessibility, IAccessible) + public + { IAccessibility } + function Get_accParent(out ppdispParent: IDispatch): HResult; stdcall; + function Get_accChildCount(out pcountChildren: Integer): HResult; stdcall; + function Get_accChild(varChild: OleVariant; out ppdispChild: IDispatch): HResult; stdcall; + function Get_accName(varChild: OleVariant; out pszName: WideString): HResult; stdcall; + function Get_accValue(varChild: OleVariant; out pszValue: WideString): HResult; stdcall; + function Get_accDescription(varChild: OleVariant; out pszDescription: WideString): HResult; stdcall; + function Get_accRole(varChild: OleVariant; out pvarRole: OleVariant): HResult; stdcall; + function Get_accState(varChild: OleVariant; out pvarState: OleVariant): HResult; stdcall; + function accLocation(out pxLeft: Integer; + out pyTop: Integer; out pcxWidth: Integer; + out pcyHeight: Integer; varChild: OleVariant): HResult; stdcall; + function Get_accFocus(out pvarChild: OleVariant): HRESULT; stdcall; + end; + + TVTMultiColumnItemAccessibility = class(TVirtualTreeItemAccessibility, IAccessible) + private + function GetItemDescription(varChild: OleVariant; out pszDescription: WideString; IncludeMainColumn: boolean): HResult; stdcall; + public + { IAccessibility } + function Get_accName(varChild: OleVariant; out pszName: WideString): HResult; stdcall; + function Get_accDescription(varChild: OleVariant; out pszDescription: WideString): HResult; stdcall; + end; + + TVTDefaultAccessibleProvider = class(TInterfacedObject, IVTAccessibleProvider) + public + function CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; + end; + + TVTDefaultAccessibleItemProvider = class(TInterfacedObject, IVTAccessibleProvider) + public + function CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; + end; + + TVTMultiColumnAccessibleItemProvider = class(TInterfacedObject, IVTAccessibleProvider) + public + function CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; + end; + +implementation + +uses + SysUtils, Forms, Variants, Math; + + +{ TVirtualTreeAccessibility } +//---------------------------------------------------------------------------------------------------------------------- +constructor TVirtualTreeAccessibility.Create(AVirtualTree: TVirtualStringTree); +// assigns the parent and current fields, and lets the control's IAccessible object know its address. +begin + inherited Create; + FVirtualTree := AVirtualTree; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeAccessibility.accDoDefaultAction(varChild: OleVariant): HResult; +// a default action is not supported. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeAccessibility.accHitTest(xLeft: Integer; yTop: Integer; out pvarChild: OleVariant): HResult; +// returns the iAccessible object at the given point, if applicable. +var + Pt: TPoint; + HitInfo: THitInfo; +begin + Result := S_FALSE; + if FVirtualTree <> nil then + begin +// VariantInit(pvarChild); +// TVarData(pvarChild).VType := VT_I4; + Pt := fVirtualTree.ScreenToClient(Point(xLeft, yTop)); + if fVirtualTree.FocusedNode <> nil then + begin + fVirtualTree.GetHitTestInfoAt(xLeft, yTop, false, HitInfo); + if FVirtualTree.FocusedNode = HitInfo.HitNode then + begin + pvarChild := FVirtualTree.AccessibleItem; + Result := S_OK; + exit; + end; + end; + if PtInRect(FVirtualTree.BoundsRect, Pt) then + begin + pvarChild := CHILDID_SELF; + Result := S_OK; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.accLocation(out pxLeft: Integer; + out pyTop: Integer; out pcxWidth: Integer; + out pcyHeight: Integer; varChild: OleVariant): HResult; +// returns the location of the VirtualStringTree object. +var + P: TPoint; +begin + Result := S_FALSE; + if varChild = CHILDID_SELF then + begin + if FVirtualTree <> nil then + begin + P := FVirtualTree.ClientToScreen(FVirtualTree.ClientRect.TopLeft); + pxLeft := P.X; + pyTop := P.Y; + pcxWidth := FVirtualTree.Width; + pcyHeight := FVirtualTree.Height; + Result := S_OK; + end; + end + else if VarType(varchild) = VT_I4 then + begin + // return the location of the focused node + if (FVirtualTree <> nil) and (FVirtualTree.AccessibleItem <> nil) then + begin + Result := FVirtualTree.AccessibleItem.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, CHILDID_SELF); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.accNavigate(navDir: Integer; varStart: OleVariant; + out pvarEndUpAt: OleVariant): HResult; +// This is not supported. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accSelection(out pvarChildren: OleVariant): HResult; +// returns the selected child ID, if any. +begin + Result := s_false; + if FVirtualTree <> nil then + if fVirtualTree.FocusedNode <> nil then + begin + pvarChildren := 1; + result := s_OK; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.GetIDsOfNames(const IID: TGUID; + Names: Pointer; NameCount, LocaleID: Integer; DispIDs: Pointer): HRESULT; +// Not supported. +begin + Result := E_NOTIMPL; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.GetTypeInfo(Index, LocaleID: Integer; + out TypeInfo): HRESULT; +// not supported. +begin + Result := E_NOTIMPL; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.GetTypeInfoCount( + out Count: Integer): HRESULT; +// not supported. +begin + Result := E_NOTIMPL; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accChild(varChild: OleVariant; out ppdispChild: IDispatch): HResult; +// returns the iAccessible child, whicfh represents the focused item. +begin + if varChild = CHILDID_SELF then + begin + ppdispChild := FVirtualTree.AccessibleItem; + Result := S_OK; + end + else + Result := E_INVALIDARG +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accChildCount(out pcountChildren: Integer): HResult; +// Returns the number 1 for the one child: The focused item. +begin + pcountChildren := 1; + Result := S_OK; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accDefaultAction(varChild: OleVariant; out pszDefaultAction: WideString): HResult; +// Not supported. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accDescription(varChild: OleVariant; out pszDescription: WideString): HResult; +// returns the hint of the control, if assigned. +begin + pszDescription := ''; + Result := S_FALSE; + if varChild = CHILDID_SELF then + begin + if FVirtualTree <> nil then + pszDescription := GetLongHint(fVirtualTree.Hint); + end; + if Length(pszDescription) > 0 then + Result := S_OK; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accFocus(out pvarChild: OleVariant): HResult; +// returns the child ID of 1, if assigned. +begin + Result := s_false; + if fVirtualTree <> nil then + begin + if FVirtualTree.FocusedNode <> nil then + pvarChild := FVirtualTree.AccessibleItem + else + pvarChild := childid_self; + result := S_OK; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accHelp(varChild: OleVariant; out pszHelp: WideString): HResult; +// Not supported. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accHelpTopic(out pszHelpFile: WideString; varChild: OleVariant; + out pidTopic: Integer): HResult; +// Returns the HelpContext ID, if present. +begin + pszHelpFile := ''; + pidTopic := 0; + Result := S_OK; + if varChild = CHILDID_SELF then + if FVirtualTree <> nil then + begin + pszHelpFile := Application.HelpFile; + pidTopic := FVirtualTree.HelpContext; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accKeyboardShortcut(varChild: OleVariant; out pszKeyboardShortcut: WideString): HResult; +// Not supported. +begin + pszKeyboardShortcut := ''; + Result := S_FALSE; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accName(varChild: OleVariant; out pszName: WideString): HResult; +// if set, returns the new published AccessibleName property. +// if not set, tries the name and class name properties. +// otherwise, returns the default text. +begin + pszName := ''; + Result := S_FALSE; + if varChild = CHILDID_SELF then + begin + if FVirtualTree <> nil then + begin + if FVirtualTree.AccessibleName <> '' then + pszName := FVirtualTree.AccessibleName + else if FVirtualTree.Name <> '' then + pszName := FVirtualTree.Name + else if FVirtualTree.ClassName <> '' then + pszName := FVirtualTree.ClassName + else + PSZName := FVirtualTree.DefaultText; + result := S_OK; + end; + end + else if varType(varChild) = VT_I4 then + begin + // return the name for the inner accessible item + if (FVirtualTree <> nil) and (FVirtualTree.AccessibleItem <> nil) then + begin + Result := FVirtualTree.AccessibleItem.Get_accName(CHILDID_SELF, pszName); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accParent(out ppdispParent: IDispatch): HResult; +// Returns false, the tree itself does not have a parent. +var + hParent: HWND; +begin + Result := E_INVALIDARG; + ppdispParent := nil; + + // Addition - Simon Moscrop 7/5/2009 + if (FVirtualTree.HandleAllocated) then + begin + (* return the accesible object from the 'parent' which is the window of the + tree itself! (This doesn't initially appear correct but it seems to + be exactly what all the other controls do! To verfify try pointing the + ms accessibility explorer at a simple button control which has been dropped + onto a form. + *) + hParent := FVirtualTree.Handle; + RESULT := AccessibleObjectFromWindow(hParent,CHILDID_SELF,IID_IAccessible,pointeR(ppDispParent)); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accRole(varChild: OleVariant; out pvarRole: OleVariant): HResult; +// tells MSAA that it is a TreeView. +begin + Result := S_OK; +// VariantInit(pvarRole); +// TVarData(pvarRole).VType := VT_I4; + if varChild = CHILDID_SELF then + begin + if FVirtualTree <> nil then + pvarRole := ROLE_SYSTEM_OUTLINE; + end + else if VarType(varChild) = VT_I4 then + begin + // return the role of the inner accessible object + if (FVirtualTree <> nil) and (FVirtualTree.FocusedNode <> nil) then + pvarRole := ROLE_SYSTEM_OUTLINEITEM + else + RESULT := S_FALSE; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.accSelect(flagsSelect: Integer; varChild: OleVariant): HResult; +// since we're not supporting more than one item, this is not supported currently. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accState(varChild: OleVariant; out pvarState: OleVariant): HResult; +// returns the state of the control. +const + IsEnabled: array[Boolean] of Integer = (STATE_SYSTEM_UNAVAILABLE, 0); + HasPopup: array[Boolean] of Integer = (0, STATE_SYSTEM_HASPOPUP); + IsVisible: array[Boolean] of Integer = (STATE_SYSTEM_INVISIBLE, 0); +begin + Result := S_OK; +// VariantInit(pvarState); +// TVarData(pvarState).VType := VT_I4; + if varChild = CHILDID_SELF then + begin + if FVirtualTree <> nil then + begin + pvarState := STATE_SYSTEM_FOCUSED or STATE_SYSTEM_FOCUSABLE or STATE_SYSTEM_HOTTRACKED; + pvarState := pvarState or IsVisible[FVirtualTree.Visible]; + pvarState := pvarState or IsEnabled[FVirtualTree.Enabled]; + end + else + Result := E_INVALIDARG; + end + else if VarType(VarChild) = VT_I4 then + begin + // return the state of the inner accessible item + if (FVirtualTree <> nil) and (FVirtualTree.AccessibleItem <> nil) then + begin + Result := FVirtualTree.AccessibleItem.Get_accState(CHILDID_SELF, pVarState); + end + else + RESULT := E_INVALIDARG; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Get_accValue(varChild: OleVariant; out pszValue: WideString): HResult; +// the TreeView control itself does not have a value, returning false here. +begin + RESULT := S_FALSE; + + pszValue := ''; + if VarType(varChild) = VT_I4 then + if varChild = CHILDID_SELF then + Result := S_FALSE + else if (FVirtualTree <> nil) and (FVirtualTree.AccessibleItem <> nil) then + RESULT := FVirtualTree.AccessibleItem.Get_accValue(CHILDID_SELF,pszValue); +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Invoke(DispID: Integer; const IID: TGUID; + LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo, + ArgErr: Pointer): HRESULT; +// not supported. +begin + Result := E_NOTIMPL; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Set_accName(varChild: OleVariant; const pszName: WideString): HResult; stdcall; +// not supported. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeAccessibility.Set_accValue(varChild: OleVariant; const pszValue: WideString): HResult; +// not supported. +begin + Result := DISP_E_MEMBERNOTFOUND +end; + +{ TVirtualTreeItemAccessibility } + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.accLocation(out pxLeft, pyTop, pcxWidth, + pcyHeight: Integer; varChild: OleVariant): HResult; +// returns the location of the current accessible item. +var + P: TPoint; + DisplayRect: TRect; +begin + Result := S_FALSE; + if varChild = CHILDID_SELF then + begin + if FVirtualTree.FocusedNode <> nil then + begin + DisplayRect := FVirtualTree.GetDisplayRect(FVirtualTree.FocusedNode, FVirtualTree.Header.Columns.GetFirstVisibleColumn, True, False);//Use first visible column instead of -1 + P := FVirtualTree.ClientToScreen(DisplayRect.TopLeft); + pxLeft := P.X; + pyTop := P.Y; + pcxWidth := DisplayRect.Right - DisplayRect.Left; + pcyHeight := DisplayRect.Bottom - DisplayRect.Top; + Result := S_OK; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accChild(varChild: OleVariant; out ppdispChild: IDispatch): HResult; +// the item does not have children. Returning false. +begin + ppdispChild := nil; + Result := S_FALSE; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accChildCount(out pcountChildren: Integer): HResult; +// the item itself does not have children, returning 0. +begin + pcountChildren := 0; + Result := S_OK; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accDescription(varChild: OleVariant; out pszDescription: WideString): HResult; +// not supported for an item. +begin + Result := DISP_E_MEMBERNOTFOUND; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accFocus(out pvarChild: OleVariant): HResult; +begin + // must override this or we get an infinite loop when using MS narrator + // when navigating using the arrow keys. + RESULT := S_FALSE; + if FVirtualTree.FocusedNode <> nil then + begin + pvarChild := CHILDID_SELF; + RESULT := S_OK; + end; +end; + +function TVirtualTreeItemAccessibility.Get_accName(varChild: OleVariant; out pszName: WideString): HResult; +// the name is the node's caption. +var + kind: TVTImageKind; + ImgText: WideString; +begin + pszName := ''; + Result := S_FALSE; + if varChild = childid_self then + begin + if FVirtualTree <> nil then + if FVirtualTree.FocusedNode <> nil then + begin + for kind := ikNormal to ikOverlay do + begin + ImgText := FVirtualTree.ImageText[FVirtualTree.FocusedNode, Kind, FVirtualTree.Header.MainColumn]; + if ImgText <> '' then + pszName := pszName + ImgText + ' '; + end; + pszName := pszName + FVirtualTree.Text[FVirtualTree.FocusedNode, FVirtualTree.Header.MainColumn]; + result := S_OK; + end + else begin + PSZName := FVirtualTree.DefaultText; + result := S_OK; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accParent(out ppdispParent: IDispatch): HResult; +// tells MSAA that the VritualStringTree is its parent. +begin + result := S_FALSE; + if FVirtualTree <> nil then + begin + ppdispParent := FVirtualTree.Accessible; + Result := S_OK; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accRole(varChild: OleVariant; out pvarRole: OleVariant): HResult; +// tells MSAA that it is a TreeView item as opposed to the TreeView itself. +begin + Result := S_OK; +// VariantInit(pvarRole); +// TVarData(pvarRole).VType := VT_I4; + if varChild = childid_self then + begin + if FVirtualTree <> nil then + pvarRole := ROLE_SYSTEM_OUTLINEITEM; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accState(varChild: OleVariant; out pvarState: OleVariant): HResult; +// Tells MSAA the state the item is in. +const + IsEnabled: array[Boolean] of Integer = (STATE_SYSTEM_UNAVAILABLE, 0); + HasPopup: array[Boolean] of Integer = (0, STATE_SYSTEM_HASPOPUP); + IsVisible: array[Boolean] of Integer = (STATE_SYSTEM_INVISIBLE, 0); + IsChecked: array[Boolean] of Integer = (0, STATE_SYSTEM_CHECKED); + IsExpanded: array[Boolean] of Integer = (0, STATE_SYSTEM_EXPANDED); + IsCollapsed: array[Boolean] of Integer = (0, STATE_SYSTEM_COLLAPSED); +begin + Result := S_OK; +// VariantInit(pvarState); +// TVarData(pvarState).VType := VT_I4; + if varChild = childid_self then + begin + if FVirtualTree <> nil then + begin + pvarState := STATE_SYSTEM_FOCUSED or STATE_SYSTEM_FOCUSABLE or STATE_SYSTEM_HOTTRACKED; + pvarState := pvarState or IsVisible[FVirtualTree.Visible]; + pvarState := pvarState or IsEnabled[FVirtualTree.Enabled]; + if fVirtualTree.FocusedNode <> nil then + begin + pvarState := pvarState or IsChecked[csCheckedNormal = FVirtualTree.FocusedNode.CheckState]; + pvarState := pvarState or IsExpanded[VSExpanded in FVirtualTree.FocusedNode.States]; + if not (vsExpanded in FVirtualTree.FocusedNode.States) then + pvarState:= PvarState or IsCollapsed[vsHasChildren in FVirtualTree.FocusedNode.States]; + end; + end + else + Result := E_INVALIDARG; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +function TVirtualTreeItemAccessibility.Get_accValue(varChild: OleVariant; out pszValue: WideString): HResult; +// for a TreeView item, the value is the nesting level number, 0-based. +begin + pszValue := ''; + Result := S_FALSE; + if varChild = childid_self then + if FVirtualTree <> nil then + if FVirtualTree.FocusedNode <> nil then + begin + PSZValue := IntToStr(FVirtualTree.GetNodeLevel(FVirtualTree.FocusedNode)); + result := S_OK; + end; +end; + +{ TVTMultiColumnItemAccessibility } + +function TVTMultiColumnItemAccessibility.GetItemDescription( + varChild: OleVariant; out pszDescription: WideString; + IncludeMainColumn: boolean): HResult; +var + I: Integer; + ImgText: WideString; + kind: TVTImageKind; +begin + pszDescription := ''; + Result := S_FALSE; + if varChild = childid_self then + begin + if FVirtualTree <> nil then + if FVirtualTree.FocusedNode <> nil then + begin + if IncludeMainColumn then + begin + for kind := ikNormal to ikOverlay do + begin + ImgText := FVirtualTree.ImageText[FVirtualTree.FocusedNode, Kind, FVirtualTree.Header.MainColumn]; + if ImgText <> '' then + ImgText := ImgText + ' '; + end; + pszDescription := ImgText + FVirtualTree.Text[FVirtualTree.FocusedNode, FVirtualTree.Header.MainColumn] + '; '; + end; + for I := 0 to FVirtualTree.Header.Columns.Count - 1 do + if (FVirtualTree.Header.MainColumn <> I) and (coVisible in FVirtualTree.Header.Columns[I].Options) then + begin + for kind := ikNormal to ikOverlay do + begin + ImgText := FVirtualTree.ImageText[FVirtualTree.FocusedNode, Kind, I]; + if ImgText <> '' then + ImgText := ImgText + ' '; + end; + ImgText := ImgText + FVirtualTree.Text[FVirtualTree.FocusedNode, I]; + if ImgText <> '' then + pszDescription := pszDescription + +FVirtualTree.Header.Columns[I].Text + +': ' + + ImgText + +'; '; + end; + if pszDescription <> '' then + if pszDescription[Length(pszDescription)-1] = ';' then + Delete(pszDescription, length(pszDescription)-1, 2); + result := S_OK; + end + else begin + PSZDescription := FVirtualTree.DefaultText; + result := S_OK; + end; + end; +end; + +function TVTMultiColumnItemAccessibility.Get_accDescription( + varChild: OleVariant; out pszDescription: WideString): HResult; +begin + result := GetItemDescription(varChild, pszDescription, false) +end; + +function TVTMultiColumnItemAccessibility.Get_accName(varChild: OleVariant; + out pszName: WideString): HResult; +begin + result := GetItemDescription(varChild, pszName, true) +end; + +{ TVTDefaultAccessibleProvider } + +function TVTDefaultAccessibleProvider.CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; +begin + result := TVirtualTreeAccessibility.Create(TVirtualStringTree(ATree)); +end; + +{ TVTDefaultAccessibleItemProvider } + +function TVTDefaultAccessibleItemProvider.CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; +begin + result := TVirtualTreeItemAccessibility.Create(TVirtualStringTree(ATree)); +end; + +{ TVTMultiColumnAccessibleItemProvider } + +function TVTMultiColumnAccessibleItemProvider.CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; +begin + result := nil; + if TVirtualStringTree(ATree).Header.UseColumns then + result := TVTMultiColumnItemAccessibility.Create(TVirtualStringTree(ATree)); +end; + +var + DefaultAccessibleProvider: TVTDefaultAccessibleProvider; + DefaultAccessibleItemProvider: TVTDefaultAccessibleItemProvider; + MultiColumnAccessibleProvider: TVTMultiColumnAccessibleItemProvider; + +initialization + if DefaultAccessibleProvider = nil then + begin + DefaultAccessibleProvider := TVTDefaultAccessibleProvider.Create; + GetAccessibilityFactory.RegisterAccessibleProvider(DefaultAccessibleProvider); + end; + if DefaultAccessibleItemProvider = nil then + begin + DefaultAccessibleItemProvider := TVTDefaultAccessibleItemProvider.Create; + GetAccessibilityFactory.RegisterAccessibleProvider(DefaultAccessibleItemProvider); + end; + if MultiColumnAccessibleProvider = nil then + begin + MultiColumnAccessibleProvider := TVTMultiColumnAccessibleItemProvider.Create; + GetAccessibilityFactory.RegisterAccessibleProvider(MultiColumnAccessibleProvider); + end; +finalization + GetAccessibilityFactory.UnRegisterAccessibleProvider(MultiColumnAccessibleProvider); + MultiColumnAccessibleProvider := nil; + GetAccessibilityFactory.UnRegisterAccessibleProvider(DefaultAccessibleItemProvider); + DefaultAccessibleItemProvider := nil; + GetAccessibilityFactory.UnRegisterAccessibleProvider(DefaultAccessibleProvider); + DefaultAccessibleProvider := nil; + +end. + + + diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibilityFactory.pas b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibilityFactory.pas new file mode 100644 index 0000000..e4bd616 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VTAccessibilityFactory.pas @@ -0,0 +1,169 @@ +unit DUnitM.VTAccessibilityFactory; + +//---------------------------------------------------------------------------------------------------------------------- +// +// Version 4.7.0 +// + +// class to create IAccessibles for the tree passed into it. +// If not already assigned, creates IAccessibles for the tree itself +// and the focused item +// the tree accessible is returned when the tree receives an WM_GETOBJECT message +// the AccessibleItem is returned when the Accessible is being asked for the first child +// To create your own IAccessibles, use the VTStandardAccessible unit as a reference, +// and assign your Accessibles to the variables in the unit's initialization. +// You only need to add the unit to your project, and voilá, you have an accessible string tree! +// +// Written by Marco Zehe. (c) 2007 + +{$I '..\Common\Compilers.inc'} + +interface + +uses + {$ifndef COMPILER_10_UP} + MSAAIntf, // MSAA support for Delphi up to 2005 + {$else} + oleacc, // MSAA support in Delphi 2006 or higher + {$endif COMPILER_10_UP} + Classes, DUnitM.VirtualTrees; + +type + IVTAccessibleProvider = interface + function CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; + end; + + TVTAccessibilityFactory = class(TObject) + private + FAccessibleProviders: TInterfaceList; + public + constructor Create; + destructor Destroy; override; + function CreateIAccessible(ATree: TBaseVirtualTree): IAccessible; + procedure RegisterAccessibleProvider(AProvider: IVTAccessibleProvider); + procedure UnRegisterAccessibleProvider(AProvider: IVTAccessibleProvider); + end; + +function GetAccessibilityFactory: TVTAccessibilityFactory; + +implementation + +var + VTAccessibleFactory: TVTAccessibilityFactory = nil; + AccessibilityAvailable: Boolean = False; + +{ TVTAccessibilityFactory } + +constructor TVTAccessibilityFactory.Create; +begin + inherited Create; + FAccessibleProviders := TInterfaceList.Create; + FAccessibleProviders.Clear; +end; + +function TVTAccessibilityFactory.CreateIAccessible( + ATree: TBaseVirtualTree): IAccessible; +var + I: Integer; + TmpIAccessible: IAccessible; +// returns an IAccessible. +// 1. If the Accessible property of the passed-in tree is nil, +// the first registered element will be returned. +// Usually, this is the IAccessible that provides information about the tree itself. +// If it is not nil, we'll check whether the AccessibleItem is nil. +// If it is, we'll look in the registered IAccessibles for the appropriate one. +// Each IAccessibleProvider will check the tree for properties to determine whether it is responsible. +// We'll work top to bottom, from the most complicated to the most simple. +// The index for these should all be greater than 0, e g the IAccessible for the tree itself should always be registered first, then any IAccessible items. +begin + Result := nil; + if ATree <> nil then + begin + if ATree.Accessible = nil then + begin + if FAccessibleProviders.Count > 0 then + begin + Result := IVTAccessibleProvider(FAccessibleProviders.Items[0]).CreateIAccessible(ATree); + Exit; + end; + end; + if ATree.AccessibleItem = nil then + begin + if FAccessibleProviders.Count > 0 then + begin + for I := FAccessibleProviders.Count - 1 downto 1 do + begin + TmpIAccessible := IVTAccessibleProvider(FAccessibleProviders.Items[I]).CreateIAccessible(ATree); + if TmpIAccessible <> nil then + begin + Result := TmpIAccessible; + Break; + end; + end; + if TmpIAccessible = nil then + begin + Result := IVTAccessibleProvider(FAccessibleProviders.Items[0]).CreateIAccessible(ATree); + end; + end; + end + else + Result := ATree.AccessibleItem; + end; +end; + +destructor TVTAccessibilityFactory.Destroy; +begin + FAccessibleProviders.Free; + FAccessibleProviders := nil; + {$ifndef COMPILER_10_UP} + FreeAccLibrary; + {$endif COMPILER_10_UP} + inherited Destroy; +end; + +procedure TVTAccessibilityFactory.RegisterAccessibleProvider( + AProvider: IVTAccessibleProvider); +// Ads a provider if it is not already registered +begin + if FAccessibleProviders.IndexOf(AProvider) < 0 then + FAccessibleProviders.Add(AProvider) +end; + +procedure TVTAccessibilityFactory.UnRegisterAccessibleProvider( + AProvider: IVTAccessibleProvider); +// Unregisters/removes an IAccessible provider if it is present +begin + if FAccessibleProviders.IndexOf(AProvider) >= 0 then + FAccessibleProviders.Remove(AProvider); +end; + +function GetAccessibilityFactory: TVTAccessibilityFactory; + +// Accessibility helper function to create a singleton class that will create or return +// the IAccessible interface for the tree and the focused node. + +begin + // first, check if we've loaded the library already + if not AccessibilityAvailable then + {$ifndef COMPILER_10_UP} + AccessibilityAvailable := InitAccLibrary; + {$else} + AccessibilityAvailable := True; + {$endif COMPILER_10_UP} + if AccessibilityAvailable then + begin + // Check to see if the class has already been created. + if VTAccessibleFactory = nil then + VTAccessibleFactory := TVTAccessibilityFactory.Create; + Result := VTAccessibleFactory; + end + else + Result := nil; +end; + +initialization + +finalization + VTAccessibleFactory.Free; + +end. diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VirtualTrees.pas b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VirtualTrees.pas new file mode 100644 index 0000000..631bcc8 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/DUnitM.VirtualTrees.pas @@ -0,0 +1,36294 @@ +unit DUnitM.VirtualTrees; + +// Version 5.0.0 +// +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ +// +// Alternatively, you may redistribute this library, use and/or modify it under the terms of the +// GNU Lesser General Public License as published by the Free Software Foundation; +// either version 2.1 of the License, or (at your option) any later version. +// You may obtain a copy of the LGPL at http://www.gnu.org/copyleft/. +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +// specific language governing rights and limitations under the License. +// +// The original code is VirtualTrees.pas, released September 30, 2000. +// +// The initial developer of the original code is digital publishing AG (Munich, Germany, www.digitalpublishing.de), +// written by Mike Lischke (public@soft-gems.net, www.soft-gems.net). +// +// Portions created by digital publishing AG are Copyright +// (C) 1999-2001 digital publishing AG. All Rights Reserved. +//---------------------------------------------------------------------------------------------------------------------- +// +// For a list of recent changes please see file CHANGES.TXT +// +// Credits for their valuable assistance and code donations go to: +// Freddy Ertl, Marian Aldenhövel, Thomas Bogenrieder, Jim Kuenemann, Werner Lehmann, Jens Treichler, +// Paul Gallagher (IBO tree), Ondrej Kelle, Ronaldo Melo Ferraz, Heri Bender, Roland Bedürftig (BCB) +// Anthony Mills, Alexander Egorushkin (BCB), Mathias Torell (BCB), Frank van den Bergh, Vadim Sedulin, Peter Evans, +// Milan Vandrovec (BCB), Steve Moss, Joe White, David Clark, Anders Thomsen, Igor Afanasyev, Eugene Programmer, +// Corbin Dunn, Richard Pringle, Uli Gerhardt, Azza, Igor Savkic, Daniel Bauten, Timo Tegtmeier, Dmitry Zegebart, +// Andreas Hausladen, Joachim Marder +// Beta testers: +// Freddy Ertl, Hans-Jürgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein, +// Wim van der Vegt, Franc v/d Westelaken +// Indirect contribution (via publicly accessible work of those persons): +// Alex Denissov, Hiroyuki Hori (MMXAsm expert) +// Documentation: +// Markus Spoettl and toolsfactory GbR (http://www.doc-o-matic.com/, sponsoring Soft Gems development +// with a free copy of the Doc-O-Matic help authoring system), Sven H. (Step by step tutorial) +// CLX: +// Dmitri Dmitrienko (initial developer) +// Source repository: +// Subversion (server), TortoiseSVN (client tools), Fisheye (Web interface) +// Accessability implementation: +// Marco Zehe (with help from Sebastian Modersohn) +//---------------------------------------------------------------------------------------------------------------------- + +interface + +{$booleval off} // Use fastest possible boolean evaluation. + +{$I '..\Common\Compilers.inc'} +{$I VTConfig.inc} + +// For some things to work we need code, which is classified as being unsafe for .NET. +{$WARN UNSAFE_TYPE OFF} +{$WARN UNSAFE_CAST OFF} +{$WARN UNSAFE_CODE OFF} + +{$ifdef COMPILER_12_UP} + {$WARN IMPLICIT_STRING_CAST OFF} + {$WARN IMPLICIT_STRING_CAST_LOSS OFF} +{$endif COMPILER_12_UP} + +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} // Necessary for BCB 6 SP 2. +{$HPPEMIT '#include '} +{$HPPEMIT '#include '} + +uses + Windows, + {$ifndef COMPILER_10_UP} + MSAAIntf, // MSAA support for Delphi up to 2005 + {$else} + oleacc, // MSAA support in Delphi 2006 or higher + {$endif COMPILER_10_UP} + Messages, SysUtils, Classes, Graphics, Controls, Forms, ImgList, ActiveX, StdCtrls, Menus, Printers, + CommCtrl, // image lists, common controls tree structures + Themes, UxTheme + {$ifdef TntSupport} + , TntStdCtrls // Unicode aware inplace editor. + {$endif TntSupport} + ; + +{$ifndef COMPILER_12_UP} +type + UnicodeString = WideString; + PByte = PAnsiChar; +{$endif COMPILER_12_UP} + +const + VTVersion = '5.0.0'; + VTTreeStreamVersion = 2; + VTHeaderStreamVersion = 6; // The header needs an own stream version to indicate changes only relevant to the header. + + CacheThreshold = 2000; // Number of nodes a tree must at least have to start caching and at the same + // time the maximum number of nodes between two cache entries. + FadeAnimationStepCount = 255; // Number of animation steps for hint fading (0..255). + ShadowSize = 5; // Size in pixels of the hint shadow. This value has no influence on Win2K and XP systems + // as those OSes have native shadow support. + + // Special identifiers for columns. + NoColumn = -1; + InvalidColumn = -2; + + // Indices for check state images used for checking. + ckEmpty = 0; // an empty image used as place holder + // radio buttons + ckRadioUncheckedNormal = 1; + ckRadioUncheckedHot = 2; + ckRadioUncheckedPressed = 3; + ckRadioUncheckedDisabled = 4; + ckRadioCheckedNormal = 5; + ckRadioCheckedHot = 6; + ckRadioCheckedPressed = 7; + ckRadioCheckedDisabled = 8; + // check boxes + ckCheckUncheckedNormal = 9; + ckCheckUncheckedHot = 10; + ckCheckUncheckedPressed = 11; + ckCheckUncheckedDisabled = 12; + ckCheckCheckedNormal = 13; + ckCheckCheckedHot = 14; + ckCheckCheckedPressed = 15; + ckCheckCheckedDisabled = 16; + ckCheckMixedNormal = 17; + ckCheckMixedHot = 18; + ckCheckMixedPressed = 19; + ckCheckMixedDisabled = 20; + // simple button + ckButtonNormal = 21; + ckButtonHot = 22; + ckButtonPressed = 23; + ckButtonDisabled = 24; + + // Instead using a TTimer class for each of the various events I use Windows timers with messages + // as this is more economical. + ExpandTimer = 1; + EditTimer = 2; + HeaderTimer = 3; + ScrollTimer = 4; + ChangeTimer = 5; + StructureChangeTimer = 6; + SearchTimer = 7; + + // Need to use this message to release the edit link interface asynchronously. + WM_CHANGESTATE = WM_APP + 32; + + // Virtual Treeview does not need to be subclassed by an eventual Theme Manager instance as it handles + // Windows XP theme painting itself. Hence the special message is used to prevent subclassing. + CM_DENYSUBCLASSING = CM_BASE + 2000; + + // Decoupling message for auto-adjusting the internal edit window. + CM_AUTOADJUST = CM_BASE + 2005; + + // VT's own clipboard formats, + // Note: The reference format is used internally to allow to link to a tree reference + // to implement optimized moves and other back references. + CFSTR_VIRTUALTREE = 'Virtual Tree Data'; + CFSTR_VTREFERENCE = 'Virtual Tree Reference'; + CFSTR_HTML = 'HTML Format'; + CFSTR_RTF = 'Rich Text Format'; + CFSTR_RTFNOOBJS = 'Rich Text Format Without Objects'; + CFSTR_CSV = 'CSV'; + + // Drag image helpers for Windows 2000 and up. + IID_IDropTargetHelper: TGUID = (D1: $4657278B; D2: $411B; D3: $11D2; D4: ($83, $9A, $00, $C0, $4F, $D9, $18, $D0)); + IID_IDragSourceHelper: TGUID = (D1: $DE5BF786; D2: $477A; D3: $11D2; D4: ($83, $9D, $00, $C0, $4F, $D9, $18, $D0)); + IID_IDropTarget: TGUID = (D1: $00000122; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00, $46)); + CLSID_DragDropHelper: TGUID = (D1: $4657278A; D2: $411B; D3: $11D2; D4: ($83, $9A, $00, $C0, $4F, $D9, $18, $D0)); + + SID_IDropTargetHelper = '{4657278B-411B-11D2-839A-00C04FD918D0}'; + SID_IDragSourceHelper = '{DE5BF786-477A-11D2-839D-00C04FD918D0}'; + SID_IDropTarget = '{00000122-0000-0000-C000-000000000046}'; + + // Help identifiers for exceptions. Application developers are responsible to link them with actual help topics. + hcTFEditLinkIsNil = 2000; + hcTFWrongMoveError = 2001; + hcTFWrongStreamFormat = 2002; + hcTFWrongStreamVersion = 2003; + hcTFStreamTooSmall = 2004; + hcTFCorruptStream1 = 2005; + hcTFCorruptStream2 = 2006; + hcTFClipboardFailed = 2007; + hcTFCannotSetUserData = 2008; + + // Header standard split cursor. + crHeaderSplit = TCursor(63); + + // Height changing cursor. + crVertSplit = TCursor(62); + + UtilityImageSize = 16; // Needed by descendants for hittests. + +var // Clipboard format IDs used in OLE drag'n drop and clipboard transfers. + CF_VIRTUALTREE, + CF_VTREFERENCE, + CF_VRTF, + CF_VRTFNOOBJS, // Unfortunately CF_RTF* is already defined as being + // registration strings so I have to use different identifiers. + CF_HTML, + CF_CSV: Word; + + MMXAvailable: Boolean; // necessary to know because the blend code uses MMX instructions + IsWinVistaOrAbove: Boolean; + + {$MinEnumSize 1, make enumerations as small as possible} + +type + // The exception used by the trees. + EVirtualTreeError = class(Exception); + + PCardinal = ^Cardinal; + + // Limits the speed interval which can be used for auto scrolling (milliseconds). + TAutoScrollInterval = 1..1000; + + // Need to declare the correct WMNCPaint record as the VCL (D5-) doesn't. + {$if CompilerVersion >= 23} + TRealWMNCPaint = TWMNCPaint; + {$else} + TRealWMNCPaint = packed record + Msg: UINT; + Rgn: HRGN; + lParam: LPARAM; + Result: LRESULT; + end; + + // The next two message records are not declared in Delphi 6 and lower. + TWMPrint = packed record + Msg: UINT; + DC: HDC; + Flags: LPARAM; + Result: LRESULT; + end; + + TWMPrintClient = TWMPrint; + {$ifend} + + // Be careful when adding new states as this might change the size of the type which in turn + // changes the alignment in the node record as well as the stream chunks. + // Do not reorder the states and always add new states at the end of this enumeration in order to avoid + // breaking existing code. + TVirtualNodeState = ( + vsInitialized, // Set after the node has been initialized. + vsChecking, // Node's check state is changing, avoid propagation. + vsCutOrCopy, // Node is selected as cut or copy and paste source. + vsDisabled, // Set if node is disabled. + vsDeleting, // Set when the node is about to be freed. + vsExpanded, // Set if the node is expanded. + vsHasChildren, // Indicates the presence of child nodes without actually setting them. + vsVisible, // Indicate whether the node is visible or not (independant of the expand states of its parents). + vsSelected, // Set if the node is in the current selection. + vsInitialUserData, // Set if (via AddChild or InsertNode) initial user data has been set which requires OnFreeNode. + vsAllChildrenHidden, // Set if vsHasChildren is set and no child node has the vsVisible flag set. + vsClearing, // A node's children are being deleted. Don't register structure change event. + vsMultiline, // Node text is wrapped at the cell boundaries instead of being shorted. + vsHeightMeasured, // Node height has been determined and does not need a recalculation. + vsToggling, // Set when a node is expanded/collapsed to prevent recursive calls. + vsFiltered // Indicates that the node should not be painted (without effecting its children). + ); + TVirtualNodeStates = set of TVirtualNodeState; + + // States used in InitNode to indicate states a node shall initially have. + TVirtualNodeInitState = ( + ivsDisabled, + ivsExpanded, + ivsHasChildren, + ivsMultiline, + ivsSelected, + ivsFiltered, + ivsReInit + ); + TVirtualNodeInitStates = set of TVirtualNodeInitState; + + TScrollBarStyle = ( + sbmRegular, + sbm3D + ); + + // Options per column. + TVTColumnOption = ( + coAllowClick, // Column can be clicked (must be enabled too). + coDraggable, // Column can be dragged. + coEnabled, // Column is enabled. + coParentBidiMode, // Column uses the parent's bidi mode. + coParentColor, // Column uses the parent's background color. + coResizable, // Column can be resized. + coShowDropMark, // Column shows the drop mark if it is currently the drop target. + coVisible, // Column is shown. + coAutoSpring, // Column takes part in the auto spring feature of the header (must be resizable too). + coFixed, // Column is fixed and can not be selected or scrolled etc. + coSmartResize, // Column is resized to its largest entry which is in view (instead of its largest + // visible entry). + coAllowFocus, // Column can be focused. + coDisableAnimatedResize, // Column resizing is not animated. + coWrapCaption, // Caption could be wrapped across several header lines to fit columns width. + coUseCaptionAlignment // Column's caption has its own aligment. + ); + TVTColumnOptions = set of TVTColumnOption; + + // These flags are used to indicate where a click in the header happened. + TVTHeaderHitPosition = ( + hhiNoWhere, // No column is involved (possible only if the tree is smaller than the client area). + hhiOnColumn, // On a column. + hhiOnIcon, // On the bitmap associated with a column. + hhiOnCheckbox // On the checkbox if enabled. + ); + TVTHeaderHitPositions = set of TVTHeaderHitPosition; + + // These flags are returned by the hit test method. + THitPosition = ( + hiAbove, // above the client area (if relative) or the absolute tree area + hiBelow, // below the client area (if relative) or the absolute tree area + hiNowhere, // no node is involved (possible only if the tree is not as tall as the client area) + hiOnItem, // on the bitmaps/buttons or label associated with an item + hiOnItemButton, // on the button associated with an item + hiOnItemButtonExact, // exactly on the button associated with an item + hiOnItemCheckbox, // on the checkbox if enabled + hiOnItemIndent, // in the indentation area in front of a node + hiOnItemLabel, // on the normal text area associated with an item + hiOnItemLeft, // in the area to the left of a node's text area (e.g. when right aligned or centered) + hiOnItemRight, // in the area to the right of a node's text area (e.g. if left aligned or centered) + hiOnNormalIcon, // on the "normal" image + hiOnStateIcon, // on the state image + hiToLeft, // to the left of the client area (if relative) or the absolute tree area + hiToRight, // to the right of the client area (if relative) or the absolute tree area + hiUpperSplitter, // in the upper splitter area of a node + hiLowerSplitter // in the lower splitter area of a node + ); + THitPositions = set of THitPosition; + + TCheckType = ( + ctNone, + ctTriStateCheckBox, + ctCheckBox, + ctRadioButton, + ctButton + ); + + // The check states include both, transient and fluent (temporary) states. The only temporary state defined so + // far is the pressed state. + TCheckState = ( + csUncheckedNormal, // unchecked and not pressed + csUncheckedPressed, // unchecked and pressed + csCheckedNormal, // checked and not pressed + csCheckedPressed, // checked and pressed + csMixedNormal, // 3-state check box and not pressed + csMixedPressed // 3-state check box and pressed + ); + + TCheckImageKind = ( + ckLightCheck, // gray cross + ckDarkCheck, // black cross + ckLightTick, // gray tick mark + ckDarkTick, // black tick mark + ckFlat, // flat images (no 3D border) + ckXP, // Windows XP style + ckCustom, // application defined check images + ckSystemFlat, // Flat system defined check images. + ckSystemDefault // Uses the system check images, theme aware. + ); + + // mode to describe a move action + TVTNodeAttachMode = ( + amNoWhere, // just for simplified tests, means to ignore the Add/Insert command + amInsertBefore, // insert node just before destination (as sibling of destination) + amInsertAfter, // insert node just after destionation (as sibling of destination) + amAddChildFirst, // add node as first child of destination + amAddChildLast // add node as last child of destination + ); + + // modes to determine drop position further + TDropMode = ( + dmNowhere, + dmAbove, + dmOnNode, + dmBelow + ); + + // operations basically allowed during drag'n drop + TDragOperation = ( + doCopy, + doMove, + doLink + ); + TDragOperations = set of TDragOperation; + + TVTImageKind = ( + ikNormal, + ikSelected, + ikState, + ikOverlay + ); + + TVTHintMode = ( + hmDefault, // show the hint of the control + hmHint, // show node specific hint string returned by the application + hmHintAndDefault, // same as hmHint but show the control's hint if no node is concerned + hmTooltip // show the text of the node if it isn't already fully shown + ); + + // Indicates how to format a tooltip. + TVTTooltipLineBreakStyle = ( + hlbDefault, // Use multi-line style of the node. + hlbForceSingleLine, // Use single line hint. + hlbForceMultiLine // Use multi line hint. + ); + + TMouseButtons = set of TMouseButton; + + // Used to describe the action to do when using the OnBeforeItemErase event. + TItemEraseAction = ( + eaColor, // Use the provided color to erase the background instead the one of the tree. + eaDefault, // The tree should erase the item's background (bitmap or solid). + eaNone // Do nothing. Let the application paint the background. + ); + + + // There is a heap of switchable behavior in the tree. Since published properties may never exceed 4 bytes, + // which limits sets to at most 32 members, and because for better overview tree options are splitted + // in various sub-options and are held in a commom options class. + // + // Options to customize tree appearance: + TVTPaintOption = ( + toHideFocusRect, // Avoid drawing the dotted rectangle around the currently focused node. + toHideSelection, // Selected nodes are drawn as unselected nodes if the tree is unfocused. + toHotTrack, // Track which node is under the mouse cursor. + toPopupMode, // Paint tree as would it always have the focus (useful for tree combo boxes etc.) + toShowBackground, // Use the background image if there's one. + toShowButtons, // Display collapse/expand buttons left to a node. + toShowDropmark, // Show the dropmark during drag'n drop operations. + toShowHorzGridLines, // Display horizontal lines to simulate a grid. + toShowRoot, // Show lines also at top level (does not show the hidden/internal root node). + toShowTreeLines, // Display tree lines to show hierarchy of nodes. + toShowVertGridLines, // Display vertical lines (depending on columns) to simulate a grid. + toThemeAware, // Draw UI elements (header, tree buttons etc.) according to the current theme if + // enabled (Windows XP+ only, application must be themed). + toUseBlendedImages, // Enable alpha blending for ghosted nodes or those which are being cut/copied. + toGhostedIfUnfocused, // Ghosted images are still shown as ghosted if unfocused (otherwise the become non-ghosted + // images). + toFullVertGridLines, // Display vertical lines over the full client area, not only the space occupied by nodes. + // This option only has an effect if toShowVertGridLines is enabled too. + toAlwaysHideSelection, // Do not draw node selection, regardless of focused state. + toUseBlendedSelection, // Enable alpha blending for node selections. + toStaticBackground, // Show simple static background instead of a tiled one. + toChildrenAbove, // Display child nodes above their parent. + toFixedIndent, // Draw the tree with a fixed indent. + toUseExplorerTheme, // Use the explorer theme if run under Windows Vista (or above). + toHideTreeLinesIfThemed, // Do not show tree lines if theming is used. + toShowFilteredNodes // Draw nodes even if they are filtered out. + ); + TVTPaintOptions = set of TVTPaintOption; + + // Options to toggle animation support: + TVTAnimationOption = ( + toAnimatedToggle, // Expanding and collapsing a node is animated (quick window scroll). + toAdvancedAnimatedToggle // Do some advanced animation effects when toggling a node. + ); + TVTAnimationOptions = set of TVTAnimationOption; + + // Options which toggle automatic handling of certain situations: + TVTAutoOption = ( + toAutoDropExpand, // Expand node if it is the drop target for more than a certain time. + toAutoExpand, // Nodes are expanded (collapsed) when getting (losing) the focus. + toAutoScroll, // Scroll if mouse is near the border while dragging or selecting. + toAutoScrollOnExpand, // Scroll as many child nodes in view as possible after expanding a node. + toAutoSort, // Sort tree when Header.SortColumn or Header.SortDirection change or sort node if + // child nodes are added. + toAutoSpanColumns, // Large entries continue into next column(s) if there's no text in them (no clipping). + toAutoTristateTracking, // Checkstates are automatically propagated for tri state check boxes. + toAutoHideButtons, // Node buttons are hidden when there are child nodes, but all are invisible. + toAutoDeleteMovedNodes, // Delete nodes which where moved in a drag operation (if not directed otherwise). + toDisableAutoscrollOnFocus, // Disable scrolling a node or column into view if it gets focused. + toAutoChangeScale, // Change default node height automatically if the system's font scale is set to big fonts. + toAutoFreeOnCollapse, // Frees any child node after a node has been collapsed (HasChildren flag stays there). + toDisableAutoscrollOnEdit, // Do not center a node horizontally when it is edited. + toAutoBidiColumnOrdering // When set then columns (if any exist) will be reordered from lowest index to highest index + // and vice versa when the tree's bidi mode is changed. + ); + TVTAutoOptions = set of TVTAutoOption; + + // Options which determine the tree's behavior when selecting nodes: + TVTSelectionOption = ( + toDisableDrawSelection, // Prevent user from selecting with the selection rectangle in multiselect mode. + toExtendedFocus, // Entries other than in the main column can be selected, edited etc. + toFullRowSelect, // Hit test as well as selection highlight are not constrained to the text of a node. + toLevelSelectConstraint, // Constrain selection to the same level as the selection anchor. + toMiddleClickSelect, // Allow selection, dragging etc. with the middle mouse button. This and toWheelPanning + // are mutual exclusive. + toMultiSelect, // Allow more than one node to be selected. + toRightClickSelect, // Allow selection, dragging etc. with the right mouse button. + toSiblingSelectConstraint, // Constrain selection to nodes with same parent. + toCenterScrollIntoView, // Center nodes vertically in the client area when scrolling into view. + toSimpleDrawSelection // Simplifies draw selection, so a node's caption does not need to intersect with the + // selection rectangle. + ); + TVTSelectionOptions = set of TVTSelectionOption; + + // Options which do not fit into any of the other groups: + TVTMiscOption = ( + toAcceptOLEDrop, // Register tree as OLE accepting drop target + toCheckSupport, // Show checkboxes/radio buttons. + toEditable, // Node captions can be edited. + toFullRepaintOnResize, // Fully invalidate the tree when its window is resized (CS_HREDRAW/CS_VREDRAW). + toGridExtensions, // Use some special enhancements to simulate and support grid behavior. + toInitOnSave, // Initialize nodes when saving a tree to a stream. + toReportMode, // Tree behaves like TListView in report mode. + toToggleOnDblClick, // Toggle node expansion state when it is double clicked. + toWheelPanning, // Support for mouse panning (wheel mice only). This option and toMiddleClickSelect are + // mutal exclusive, where panning has precedence. + toReadOnly, // The tree does not allow to be modified in any way. No action is executed and + // node editing is not possible. + toVariableNodeHeight, // When set then GetNodeHeight will trigger OnMeasureItem to allow variable node heights. + toFullRowDrag, // Start node dragging by clicking anywhere in it instead only on the caption or image. + // Must be used together with toDisableDrawSelection. + toNodeHeightResize, // Allows changing a node's height via mouse. + toNodeHeightDblClickResize, // Allows to reset a node's height to FDefaultNodeHeight via a double click. + toEditOnClick, // Editing mode can be entered with a single click + toEditOnDblClick // Editing mode can be entered with a double click + ); + TVTMiscOptions = set of TVTMiscOption; + + // Options to control data export + TVTExportMode = ( + emAll, // export all records (regardless checked state) + emChecked, // export checked records only + emUnchecked // export unchecked records only + ); + + // Kinds of operations + TVTOperationKind = ( + okAutoFitColumns, + okGetMaxColumnWidth, + okSortNode, + okSortTree + ); + TVTOperationKinds = set of TVTOperationKind; + +const + DefaultPaintOptions = [toShowButtons, toShowDropmark, toShowTreeLines, toShowRoot, toThemeAware, toUseBlendedImages]; + DefaultAnimationOptions = []; + DefaultAutoOptions = [toAutoDropExpand, toAutoTristateTracking, toAutoScrollOnExpand, toAutoDeleteMovedNodes]; + DefaultSelectionOptions = []; + DefaultMiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, + toEditOnClick]; + DefaultColumnOptions = [coAllowClick, coDraggable, coEnabled, coParentColor, coParentBidiMode, coResizable, + coShowDropmark, coVisible, coAllowFocus]; + +type + TBaseVirtualTree = class; + TVirtualTreeClass = class of TBaseVirtualTree; + + PVirtualNode = ^TVirtualNode; + + TColumnIndex = type Integer; + TColumnPosition = type Cardinal; + + // This record must already be defined here and not later because otherwise BCB users will not be able + // to compile (conversion done by BCB is wrong). + TCacheEntry = record + Node: PVirtualNode; + AbsoluteTop: Cardinal; + end; + + TCache = array of TCacheEntry; + TNodeArray = array of PVirtualNode; + + TCustomVirtualTreeOptions = class(TPersistent) + private + FOwner: TBaseVirtualTree; + FPaintOptions: TVTPaintOptions; + FAnimationOptions: TVTAnimationOptions; + FAutoOptions: TVTAutoOptions; + FSelectionOptions: TVTSelectionOptions; + FMiscOptions: TVTMiscOptions; + FExportMode: TVTExportMode; + procedure SetAnimationOptions(const Value: TVTAnimationOptions); + procedure SetAutoOptions(const Value: TVTAutoOptions); + procedure SetMiscOptions(const Value: TVTMiscOptions); + procedure SetPaintOptions(const Value: TVTPaintOptions); + procedure SetSelectionOptions(const Value: TVTSelectionOptions); + protected + property AnimationOptions: TVTAnimationOptions read FAnimationOptions write SetAnimationOptions + default DefaultAnimationOptions; + property AutoOptions: TVTAutoOptions read FAutoOptions write SetAutoOptions default DefaultAutoOptions; + property ExportMode: TVTExportMode read FExportMode write FExportMode default emAll; + property MiscOptions: TVTMiscOptions read FMiscOptions write SetMiscOptions default DefaultMiscOptions; + property PaintOptions: TVTPaintOptions read FPaintOptions write SetPaintOptions default DefaultPaintOptions; + property SelectionOptions: TVTSelectionOptions read FSelectionOptions write SetSelectionOptions + default DefaultSelectionOptions; + public + constructor Create(AOwner: TBaseVirtualTree); virtual; + + procedure AssignTo(Dest: TPersistent); override; + + property Owner: TBaseVirtualTree read FOwner; + end; + + TTreeOptionsClass = class of TCustomVirtualTreeOptions; + + TVirtualTreeOptions = class(TCustomVirtualTreeOptions) + published + property AnimationOptions; + property AutoOptions; + property ExportMode; + property MiscOptions; + property PaintOptions; + property SelectionOptions; + end; + + // Used in the CF_VTREFERENCE clipboard format. + PVTReference = ^TVTReference; + TVTReference = record + Process: Cardinal; + Tree: TBaseVirtualTree; + end; + + TVirtualNode = packed record + Index, // index of node with regard to its parent + ChildCount: Cardinal; // number of child nodes + NodeHeight: Word; // height in pixels + States: TVirtualNodeStates; // states describing various properties of the node (expanded, initialized etc.) + Align: Byte; // line/button alignment + CheckState: TCheckState; // indicates the current check state (e.g. checked, pressed etc.) + CheckType: TCheckType; // indicates which check type shall be used for this node + Dummy: Byte; // dummy value to fill DWORD boundary + TotalCount, // sum of this node, all of its child nodes and their child nodes etc. + TotalHeight: Cardinal; // height in pixels this node covers on screen including the height of all of its + // children + // Note: Some copy routines require that all pointers (as well as the data area) in a node are + // located at the end of the node! Hence if you want to add new member fields (except pointers to internal + // data) then put them before field Parent. + Parent, // reference to the node's parent (for the root this contains the treeview) + PrevSibling, // link to the node's previous sibling or nil if it is the first node + NextSibling, // link to the node's next sibling or nil if it is the last node + FirstChild, // link to the node's first child... + LastChild: PVirtualNode; // link to the node's last child... + Data: record end; // this is a placeholder, each node gets extra data determined by NodeDataSize + end; + + // Structure used when info about a certain position in the header is needed. + TVTHeaderHitInfo = record + X, + Y: Integer; + Button: TMouseButton; + Shift: TShiftState; + Column: TColumnIndex; + HitPosition: TVTHeaderHitPositions; + end; + + // Structure used when info about a certain position in the tree is needed. + THitInfo = record + HitNode: PVirtualNode; + HitPositions: THitPositions; + HitColumn: TColumnIndex; + end; + + // auto scroll directions + TScrollDirections = set of ( + sdLeft, + sdUp, + sdRight, + sdDown + ); + + // OLE drag'n drop support + TFormatEtcArray = array of TFormatEtc; + TFormatArray = array of Word; + + // IDataObject.SetData support + TInternalStgMedium = packed record + Format: TClipFormat; + Medium: TStgMedium; + end; + TInternalStgMediumArray = array of TInternalStgMedium; + + TEnumFormatEtc = class(TInterfacedObject, IEnumFormatEtc) + private + FTree: TBaseVirtualTree; + FFormatEtcArray: TFormatEtcArray; + FCurrentIndex: Integer; + public + constructor Create(Tree: TBaseVirtualTree; AFormatEtcArray: TFormatEtcArray); + + function Clone(out Enum: IEnumFormatEtc): HResult; stdcall; + function Next(celt: Integer; out elt; pceltFetched: PLongint): HResult; stdcall; + function Reset: HResult; stdcall; + function Skip(celt: Integer): HResult; stdcall; + end; + + // ----- OLE drag'n drop handling + + { 01.05.2006 Jim - Problem with BDS2006 C++ compiler and ambiguous defines + {$EXTERNALSYM IDropTargetHelper} + + IDropTargetHelper = interface(IUnknown) + [SID_IDropTargetHelper] + function DragEnter(hwndTarget: HWND; pDataObject: IDataObject; var ppt: TPoint; dwEffect: Integer): HRESULT; stdcall; + function DragLeave: HRESULT; stdcall; + function DragOver(var ppt: TPoint; dwEffect: Integer): HRESULT; stdcall; + function Drop(pDataObject: IDataObject; var ppt: TPoint; dwEffect: Integer): HRESULT; stdcall; + function Show(fShow: Boolean): HRESULT; stdcall; + end; + + PSHDragImage = ^TSHDragImage; + TSHDragImage = packed record + sizeDragImage: TSize; + ptOffset: TPoint; + hbmpDragImage: HBITMAP; + ColorRef: TColorRef; + end; + + IDragSourceHelper = interface(IUnknown) + [SID_IDragSourceHelper] + function InitializeFromBitmap(var SHDragImage: TSHDragImage; pDataObject: IDataObject): HRESULT; stdcall; + function InitializeFromWindow(Window: HWND; var ppt: TPoint; pDataObject: IDataObject): HRESULT; stdcall; + end; + + IVTDragManager = interface(IUnknown) + ['{C4B25559-14DA-446B-8901-0C879000EB16}'] + procedure ForceDragLeave; stdcall; + function GetDataObject: IDataObject; stdcall; + function GetDragSource: TBaseVirtualTree; stdcall; + function GetDropTargetHelperSupported: Boolean; stdcall; + function GetIsDropTarget: Boolean; stdcall; + + property DataObject: IDataObject read GetDataObject; + property DragSource: TBaseVirtualTree read GetDragSource; + property DropTargetHelperSupported: Boolean read GetDropTargetHelperSupported; + property IsDropTarget: Boolean read GetIsDropTarget; + end; + + // This data object is used in two different places. One is for clipboard operations and the other while dragging. + TVTDataObject = class(TInterfacedObject, IDataObject) + private + FOwner: TBaseVirtualTree; // The tree which provides clipboard or drag data. + FForClipboard: Boolean; // Determines which data to render with GetData. + FFormatEtcArray: TFormatEtcArray; + FInternalStgMediumArray: TInternalStgMediumArray; // The available formats in the DataObject + FAdviseHolder: IDataAdviseHolder; // Reference to an OLE supplied implementation for advising. + protected + function CanonicalIUnknown(TestUnknown: IUnknown): IUnknown; + function EqualFormatEtc(FormatEtc1, FormatEtc2: TFormatEtc): Boolean; + function FindFormatEtc(TestFormatEtc: TFormatEtc; const FormatEtcArray: TFormatEtcArray): integer; + function FindInternalStgMedium(Format: TClipFormat): PStgMedium; + function HGlobalClone(HGlobal: THandle): THandle; + function RenderInternalOLEData(const FormatEtcIn: TFormatEtc; var Medium: TStgMedium; var OLEResult: HResult): Boolean; + function StgMediumIncRef(const InStgMedium: TStgMedium; var OutStgMedium: TStgMedium; + CopyInMedium: Boolean; DataObject: IDataObject): HRESULT; + + property ForClipboard: Boolean read FForClipboard; + property FormatEtcArray: TFormatEtcArray read FFormatEtcArray write FFormatEtcArray; + property InternalStgMediumArray: TInternalStgMediumArray read FInternalStgMediumArray write FInternalStgMediumArray; + property Owner: TBaseVirtualTree read FOwner; + public + constructor Create(AOwner: TBaseVirtualTree; ForClipboard: Boolean); virtual; + destructor Destroy; override; + + function DAdvise(const FormatEtc: TFormatEtc; advf: Integer; const advSink: IAdviseSink; out dwConnection: Integer): + HResult; virtual; stdcall; + function DUnadvise(dwConnection: Integer): HResult; virtual; stdcall; + function EnumDAdvise(out enumAdvise: IEnumStatData): HResult; virtual; stdcall; + function EnumFormatEtc(Direction: Integer; out EnumFormatEtc: IEnumFormatEtc): HResult; virtual; stdcall; + function GetCanonicalFormatEtc(const FormatEtc: TFormatEtc; out FormatEtcOut: TFormatEtc): HResult; virtual; stdcall; + function GetData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium): HResult; virtual; stdcall; + function GetDataHere(const FormatEtc: TFormatEtc; out Medium: TStgMedium): HResult; virtual; stdcall; + function QueryGetData(const FormatEtc: TFormatEtc): HResult; virtual; stdcall; + function SetData(const FormatEtc: TFormatEtc; var Medium: TStgMedium; DoRelease: BOOL): HResult; virtual; stdcall; + end; + + // TVTDragManager is a class to manage drag and drop in a Virtual Treeview. + TVTDragManager = class(TInterfacedObject, IVTDragManager, IDropSource, IDropTarget) + private + FOwner, // The tree which is responsible for drag management. + FDragSource: TBaseVirtualTree; // Reference to the source tree if the source was a VT, might be different than + // the owner tree. + FIsDropTarget: Boolean; // True if the owner is currently the drop target. + FDataObject: IDataObject; // A reference to the data object passed in by DragEnter (only used when the owner + // tree is the current drop target). + FDropTargetHelper: IDropTargetHelper; // Win2k > Drag image support + FFullDragging: BOOL; // True, if full dragging is currently enabled in the system. + + function GetDataObject: IDataObject; stdcall; + function GetDragSource: TBaseVirtualTree; stdcall; + function GetDropTargetHelperSupported: Boolean; stdcall; + function GetIsDropTarget: Boolean; stdcall; + public + constructor Create(AOwner: TBaseVirtualTree); virtual; + destructor Destroy; override; + + function DragEnter(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; + var Effect: Longint): HResult; stdcall; + function DragLeave: HResult; stdcall; + function DragOver(KeyState: Integer; Pt: TPoint; var Effect: LongInt): HResult; stdcall; + function Drop(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; var Effect: Integer): HResult; stdcall; + procedure ForceDragLeave; stdcall; + function GiveFeedback(Effect: Integer): HResult; stdcall; + function QueryContinueDrag(EscapePressed: BOOL; KeyState: Integer): HResult; stdcall; + end; + + PVTHintData = ^TVTHintData; + TVTHintData = record + Tree: TBaseVirtualTree; + Node: PVirtualNode; + Column: TColumnIndex; + HintRect: TRect; // used for draw trees only, string trees get the size from the hint string + DefaultHint: UnicodeString; // used only if there is no node specific hint string available + // or a header hint is about to appear + HintText: UnicodeString; // set when size of the hint window is calculated + BidiMode: TBidiMode; + Alignment: TAlignment; + LineBreakStyle: TVTToolTipLineBreakStyle; + end; + + // Determines the kind of animation when a hint is activated. + THintAnimationType = ( + hatNone, // no animation at all, just display hint/tooltip + hatFade, // fade in the hint/tooltip, like in Windows 2000 + hatSlide, // slide in the hint/tooltip, like in Windows 98 + hatSystemDefault // use what the system is using (slide for Win9x, slide/fade for Win2K+, depends on settings) + ); + + // The trees need an own hint window class because of Unicode output and adjusted font. + TVirtualTreeHintWindow = class(THintWindow) + private + FHintData: TVTHintData; + FBackground, + FDrawBuffer, + FTarget: TBitmap; + FTextHeight: Integer; + function AnimationCallback(Step, StepSize: Integer; Data: Pointer): Boolean; + procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED; + function GetHintWindowDestroyed: Boolean; + procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND; + procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT; + procedure WMShowWindow(var Message: TWMShowWindow); message WM_SHOWWINDOW; + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure InternalPaint(Step, StepSize: Integer); + procedure Paint; override; + + property Background: TBitmap read FBackground; + property DrawBuffer: TBitmap read FDrawBuffer; + property HintData: TVTHintData read FHintData; + property HintWindowDestroyed: Boolean read GetHintWindowDestroyed; + property Target: TBitmap read FTarget; + property TextHeight: Integer read FTextHeight; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + procedure ActivateHint(Rect: TRect; const AHint: string); override; + function CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; override; + function IsHintMsg(var Msg: TMsg): Boolean; override; + end; + + // Drag image support for the tree. + TVTTransparency = 0..255; + TVTBias = -128..127; + + // Simple move limitation for the drag image. + TVTDragMoveRestriction = ( + dmrNone, + dmrHorizontalOnly, + dmrVerticalOnly + ); + + TVTDragImageStates = set of ( + disHidden, // Internal drag image is currently hidden (always hidden if drag image helper interfaces are used). + disInDrag, // Drag image class is currently being used. + disPrepared, // Drag image class is prepared. + disSystemSupport // Running on Windows 2000 or higher. System supports drag images natively. + ); + + // Class to manage header and tree drag image during a drag'n drop operation. + TVTDragImage = class + private + FOwner: TBaseVirtualTree; + FBackImage, // backup of overwritten screen area + FAlphaImage, // target for alpha blending + FDragImage: TBitmap; // the actual drag image to blend to screen + FImagePosition, // position of image (upper left corner) in screen coordinates + FLastPosition: TPoint; // last mouse position in screen coordinates + FTransparency: TVTTransparency; // alpha value of the drag image (0 - fully transparent, 255 - fully opaque) + FPreBlendBias, // value to darken or lighten the drag image before it is blended + FPostBlendBias: TVTBias; // value to darken or lighten the alpha blend result + FFade: Boolean; // determines whether to fade the drag image from center to borders or not + FRestriction: TVTDragMoveRestriction; // determines in which directions the drag image can be moved + FColorKey: TColor; // color to make fully transparent regardless of any other setting + FStates: TVTDragImageStates; // Determines the states of the drag image class. + function GetVisible: Boolean; // True if the drag image is currently hidden (used only when dragging) + protected + procedure InternalShowDragImage(ScreenDC: HDC); + procedure MakeAlphaChannel(Source, Target: TBitmap); + public + constructor Create(AOwner: TBaseVirtualTree); + destructor Destroy; override; + + function DragTo(P: TPoint; ForceRepaint: Boolean): Boolean; + procedure EndDrag; + function GetDragImageRect: TRect; + procedure HideDragImage; + procedure PrepareDrag(DragImage: TBitmap; ImagePosition, HotSpot: TPoint; const DataObject: IDataObject); + procedure RecaptureBackground(Tree: TBaseVirtualTree; R: TRect; VisibleRegion: HRGN; CaptureNCArea, + ReshowDragImage: Boolean); + procedure ShowDragImage; + function WillMove(P: TPoint): Boolean; + + property ColorKey: TColor read FColorKey write FColorKey default clWindow; + property Fade: Boolean read FFade write FFade default False; + property MoveRestriction: TVTDragMoveRestriction read FRestriction write FRestriction default dmrNone; + property PostBlendBias: TVTBias read FPostBlendBias write FPostBlendBias default 0; + property PreBlendBias: TVTBias read FPreBlendBias write FPreBlendBias default 0; + property Transparency: TVTTransparency read FTransparency write FTransparency default 128; + property Visible: Boolean read GetVisible; + end; + + // tree columns implementation + TVirtualTreeColumns = class; + TVTHeader = class; + + TVirtualTreeColumnStyle = ( + vsText, + vsOwnerDraw + ); + + TVTHeaderColumnLayout = ( + blGlyphLeft, + blGlyphRight, + blGlyphTop, + blGlyphBottom + ); + + TSortDirection = ( + sdAscending, + sdDescending + ); + + TVirtualTreeColumn = class(TCollectionItem) + private + FText, + FHint: UnicodeString; + FLeft, + FWidth: Integer; + FPosition: TColumnPosition; + FMinWidth: Integer; + FMaxWidth: Integer; + FStyle: TVirtualTreeColumnStyle; + FImageIndex: TImageIndex; + FBiDiMode: TBiDiMode; + FLayout: TVTHeaderColumnLayout; + FMargin, + FSpacing: Integer; + FOptions: TVTColumnOptions; + FTag: Integer; + FAlignment: TAlignment; + FCaptionAlignment: TAlignment; // Alignment of the caption. + FLastWidth: Integer; + FColor: TColor; + FBonusPixel: Boolean; + FSpringRest: Single; // Accumulator for width adjustment when auto spring option is enabled. + FCaptionText: UnicodeString; + FCheckBox: Boolean; + FCheckType: TCheckType; + FCheckState: TCheckState; + FImageRect: TRect; + FHasImage: Boolean; + fDefaultSortDirection: TSortDirection; + function GetCaptionAlignment: TAlignment; + function GetLeft: Integer; + function IsBiDiModeStored: Boolean; + function IsCaptionAlignmentStored: Boolean; + function IsColorStored: Boolean; + procedure SetAlignment(const Value: TAlignment); + procedure SetBiDiMode(Value: TBiDiMode); + procedure SetCaptionAlignment(const Value: TAlignment); + procedure SetCheckBox(Value: Boolean); + procedure SetCheckState(Value: TCheckState); + procedure SetCheckType(Value: TCheckType); + procedure SetColor(const Value: TColor); + procedure SetImageIndex(Value: TImageIndex); + procedure SetLayout(Value: TVTHeaderColumnLayout); + procedure SetMargin(Value: Integer); + procedure SetMaxWidth(Value: Integer); + procedure SetMinWidth(Value: Integer); + procedure SetOptions(Value: TVTColumnOptions); + procedure SetPosition(Value: TColumnPosition); + procedure SetSpacing(Value: Integer); + procedure SetStyle(Value: TVirtualTreeColumnStyle); + procedure SetText(const Value: UnicodeString); + procedure SetWidth(Value: Integer); + protected + procedure ComputeHeaderLayout(DC: HDC; Client: TRect; UseHeaderGlyph, UseSortGlyph: Boolean; + var HeaderGlyphPos, SortGlyphPos: TPoint; var SortGlyphSize: TSize; var TextBounds: TRect; DrawFormat: Cardinal; + CalculateTextRect: Boolean = False); + procedure DefineProperties(Filer: TFiler); override; + procedure GetAbsoluteBounds(var Left, Right: Integer); + function GetDisplayName: string; override; + function GetOwner: TVirtualTreeColumns; reintroduce; + procedure ReadHint(Reader: TReader); + procedure ReadText(Reader: TReader); + procedure WriteHint(Writer: TWriter); + procedure WriteText(Writer: TWriter); + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + + procedure Assign(Source: TPersistent); override; +{$ifdef COMPILER_12_UP} + function Equals(OtherColumnObj: TObject): Boolean; override; +{$else} + function Equals(OtherColumnObj: TObject): Boolean; +{$endif} + function GetRect: TRect; virtual; + procedure LoadFromStream(const Stream: TStream; Version: Integer); + procedure ParentBiDiModeChanged; + procedure ParentColorChanged; + procedure RestoreLastWidth; + procedure SaveToStream(const Stream: TStream); + function UseRightToLeftReading: Boolean; + + property Left: Integer read GetLeft; + property Owner: TVirtualTreeColumns read GetOwner; + published + property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify; + property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode stored IsBiDiModeStored; + property CaptionAlignment: TAlignment read GetCaptionAlignment write SetCaptionAlignment + stored IsCaptionAlignmentStored default taLeftJustify; + property CaptionText: UnicodeString read FCaptionText stored False; + property CheckType: TCheckType read FCheckType write SetCheckType default ctCheckBox; + property CheckState: TCheckState read FCheckState write SetCheckState default csUncheckedNormal; + property CheckBox: Boolean read FCheckBox write SetCheckBox default False; + property Color: TColor read FColor write SetColor stored IsColorStored; + property DefaultSortDirection: TSortDirection read fDefaultSortDirection write fDefaultSortDirection default sdAscending; + property Hint: UnicodeString read FHint write FHint stored False; + property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1; + property Layout: TVTHeaderColumnLayout read FLayout write SetLayout default blGlyphLeft; + property Margin: Integer read FMargin write SetMargin default 4; + property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 10000; + property MinWidth: Integer read FMinWidth write SetMinWidth default 10; + property Options: TVTColumnOptions read FOptions write SetOptions default DefaultColumnOptions; + property Position: TColumnPosition read FPosition write SetPosition; + property Spacing: Integer read FSpacing write SetSpacing default 4; + property Style: TVirtualTreeColumnStyle read FStyle write SetStyle default vsText; + property Tag: Integer read FTag write FTag default 0; + property Text: UnicodeString read FText write SetText stored False; // Never let the VCL store the wide string, + // it is simply unable to write it correctly. + // We use DefineProperties here. + property Width: Integer read FWidth write SetWidth default 50; + end; + + TVirtualTreeColumnClass = class of TVirtualTreeColumn; + + TColumnsArray = array of TVirtualTreeColumn; + TCardinalArray = array of Cardinal; + TIndexArray = array of TColumnIndex; + + TVirtualTreeColumns = class(TCollection) + private + FHeader: TVTHeader; + FHeaderBitmap: TBitmap; // backbuffer for drawing + FHoverIndex, // currently "hot" column + FDownIndex, // Column on which a mouse button is held down. + FTrackIndex: TColumnIndex; // Index of column which is currently being resized. + FClickIndex: TColumnIndex; // Index of the last clicked column. + FCheckBoxHit: Boolean; // True if the last click was on a header checkbox. + FPositionToIndex: TIndexArray; + FDefaultWidth: Integer; // the width columns are created with + FNeedPositionsFix: Boolean; // True if FixPositions must still be called after DFM loading or Bidi mode change. + FClearing: Boolean; // True if columns are being deleted entirely. + + function GetCount: Integer; + function GetItem(Index: TColumnIndex): TVirtualTreeColumn; + function GetNewIndex(P: TPoint; var OldIndex: TColumnIndex): Boolean; + procedure SetDefaultWidth(Value: Integer); + procedure SetItem(Index: TColumnIndex; Value: TVirtualTreeColumn); + protected + // drag support + FDragIndex: TColumnIndex; // index of column currently being dragged + FDropTarget: TColumnIndex; // current target column (index) while dragging + FDropBefore: Boolean; // True if drop position is in the left half of a column, False for the right + // side to drop the dragged column to + + procedure AdjustAutoSize(CurrentIndex: TColumnIndex; Force: Boolean = False); + function AdjustDownColumn(P: TPoint): TColumnIndex; + function AdjustHoverColumn(P: TPoint): Boolean; + procedure AdjustPosition(Column: TVirtualTreeColumn; Position: Cardinal); + function CanSplitterResize(P: TPoint; Column: TColumnIndex): Boolean; + procedure DoCanSplitterResize(P: TPoint; Column: TColumnIndex; var Allowed: Boolean); virtual; + procedure DrawButtonText(DC: HDC; Caption: UnicodeString; Bounds: TRect; Enabled, Hot: Boolean; DrawFormat: Cardinal; + WrapCaption: Boolean); + procedure FixPositions; + function GetColumnAndBounds(P: TPoint; var ColumnLeft, ColumnRight: Integer; Relative: Boolean = True): Integer; + function GetOwner: TPersistent; override; + procedure HandleClick(P: TPoint; Button: TMouseButton; Force, DblClick: Boolean); virtual; + procedure IndexChanged(OldIndex, NewIndex: Integer); + procedure InitializePositionArray; + procedure Notify(Item: TCollectionItem; Action: TCollectionNotification); override; + procedure ReorderColumns(RTL: Boolean); + procedure Update(Item: TCollectionItem); override; + procedure UpdatePositions(Force: Boolean = False); + + property HeaderBitmap: TBitmap read FHeaderBitmap; + property PositionToIndex: TIndexArray read FPositionToIndex; + public + constructor Create(AOwner: TVTHeader); + destructor Destroy; override; + + function Add: TVirtualTreeColumn; virtual; + procedure AnimatedResize(Column: TColumnIndex; NewWidth: Integer); + procedure Assign(Source: TPersistent); override; + procedure Clear; virtual; + function ColumnFromPosition(P: TPoint; Relative: Boolean = True): TColumnIndex; overload; virtual; + function ColumnFromPosition(PositionIndex: TColumnPosition): TColumnIndex; overload; virtual; +{$ifdef COMPILER_12_UP} + function Equals(OtherColumnsObj: TObject): Boolean; override; +{$else} + function Equals(OtherColumnsObj: TObject): Boolean; +{$endif} + procedure GetColumnBounds(Column: TColumnIndex; var Left, Right: Integer); + function GetFirstVisibleColumn(ConsiderAllowFocus: Boolean = False): TColumnIndex; + function GetLastVisibleColumn(ConsiderAllowFocus: Boolean = False): TColumnIndex; + function GetNextColumn(Column: TColumnIndex): TColumnIndex; + function GetNextVisibleColumn(Column: TColumnIndex; ConsiderAllowFocus: Boolean = False): TColumnIndex; + function GetPreviousColumn(Column: TColumnIndex): TColumnIndex; + function GetPreviousVisibleColumn(Column: TColumnIndex; ConsiderAllowFocus: Boolean = False): TColumnIndex; + function GetScrollWidth: Integer; + function GetVisibleColumns: TColumnsArray; + function GetVisibleFixedWidth: Integer; + function IsValidColumn(Column: TColumnIndex): Boolean; + procedure LoadFromStream(const Stream: TStream; Version: Integer); + procedure PaintHeader(DC: HDC; R: TRect; HOffset: Integer); overload; virtual; + procedure PaintHeader(TargetCanvas: TCanvas; R: TRect; const Target: TPoint; + RTLOffset: Integer = 0); overload; virtual; + procedure SaveToStream(const Stream: TStream); + function TotalWidth: Integer; + + property Count: Integer read GetCount; + property ClickIndex: TColumnIndex read FClickIndex; + property DefaultWidth: Integer read FDefaultWidth write SetDefaultWidth default 50; + property Items[Index: TColumnIndex]: TVirtualTreeColumn read GetItem write SetItem; default; + property Header: TVTHeader read FHeader; + property TrackIndex: TColumnIndex read FTrackIndex; + end; + + TVirtualTreeColumnsClass = class of TVirtualTreeColumns; + + TVTConstraintPercent = 0..100; + TVTFixedAreaConstraints = class(TPersistent) + private + FHeader: TVTHeader; + FMaxHeightPercent, + FMaxWidthPercent, + FMinHeightPercent, + FMinWidthPercent: TVTConstraintPercent; + FOnChange: TNotifyEvent; + procedure SetConstraints(Index: Integer; Value: TVTConstraintPercent); + protected + procedure Change; + property Header: TVTHeader read FHeader; + public + constructor Create(AOwner: TVTHeader); + + procedure Assign(Source: TPersistent); override; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + published + property MaxHeightPercent: TVTConstraintPercent index 0 read FMaxHeightPercent write SetConstraints default 0; + property MaxWidthPercent: TVTConstraintPercent index 1 read FMaxWidthPercent write SetConstraints default 0; + property MinHeightPercent: TVTConstraintPercent index 2 read FMinHeightPercent write SetConstraints default 0; + property MinWidthPercent: TVTConstraintPercent index 3 read FMinWidthPercent write SetConstraints default 0; + end; + + TVTHeaderStyle = ( + hsThickButtons, // TButton look and feel + hsFlatButtons, // flatter look than hsThickButton, like an always raised flat TToolButton + hsPlates // flat TToolButton look and feel (raise on hover etc.) + ); + + TVTHeaderOption = ( + hoAutoResize, // Adjust a column so that the header never exceeds the client width of the owner control. + hoColumnResize, // Resizing columns with the mouse is allowed. + hoDblClickResize, // Allows a column to resize itself to its largest entry. + hoDrag, // Dragging columns is allowed. + hoHotTrack, // Header captions are highlighted when mouse is over a particular column. + hoOwnerDraw, // Header items with the owner draw style can be drawn by the application via event. + hoRestrictDrag, // Header can only be dragged horizontally. + hoShowHint, // Show application defined header hint. + hoShowImages, // Show header images. + hoShowSortGlyphs, // Allow visible sort glyphs. + hoVisible, // Header is visible. + hoAutoSpring, // Distribute size changes of the header to all columns, which are sizable and have the + // coAutoSpring option enabled. hoAutoResize must be enabled too. + hoFullRepaintOnResize, // Fully invalidate the header (instead of subsequent columns only) when a column is resized. + hoDisableAnimatedResize, // Disable animated resize for all columns. + hoHeightResize, // Allow resizing header height via mouse. + hoHeightDblClickResize, // Allow the header to resize itself to its default height. + hoHeaderClickAutoSort // Clicks on the header will make the clicked column the SortColumn or toggle sort direction if + // it already was the sort column + ); + TVTHeaderOptions = set of TVTHeaderOption; + + THeaderState = ( + hsAutoSizing, // auto size chain is in progess, do not trigger again on WM_SIZE + hsDragging, // header dragging is in progress (only if enabled) + hsDragPending, // left button is down, user might want to start dragging a column + hsLoading, // The header currently loads from stream, so updates are not necessary. + hsColumnWidthTracking, // column resizing is in progress + hsColumnWidthTrackPending, // left button is down, user might want to start resize a column + hsHeightTracking, // height resizing is in progress + hsHeightTrackPending, // left button is down, user might want to start changing height + hsResizing, // multi column resizing in progress + hsScaling, // the header is scaled after a change of FixedAreaConstraints or client size + hsNeedScaling // the header needs to be scaled + ); + THeaderStates = set of THeaderState; + + // describes the used column resize behaviour for AutoFitColumns + TSmartAutoFitType = ( + smaAllColumns, // consider nodes in view only for all columns + smaNoColumn, // consider nodes in view only for no column + smaUseColumnOption // use coSmartResize of the corresponding column + ); + + // desribes what made a structure change event happen + TChangeReason = ( + crIgnore, // used as placeholder + crAccumulated, // used for delayed changes + crChildAdded, // one or more child nodes have been added + crChildDeleted, // one or more child nodes have been deleted + crNodeAdded, // a node has been added + crNodeCopied, // a node has been duplicated + crNodeMoved // a node has been moved to a new place + ); + + TVTHeader = class(TPersistent) + private + FOwner: TBaseVirtualTree; + FColumns: TVirtualTreeColumns; + FHeight: Integer; + FFont: TFont; + FParentFont: Boolean; + FOptions: TVTHeaderOptions; + FStyle: TVTHeaderStyle; // button style + FBackground: TColor; + FAutoSizeIndex: TColumnIndex; + FPopupMenu: TPopupMenu; + FMainColumn: TColumnIndex; // the column which holds the tree + FMaxHeight: Integer; + FMinHeight: Integer; + FDefaultHeight: Integer; + FFixedAreaConstraints: TVTFixedAreaConstraints; // Percentages for the fixed area (header, fixed columns). + FImages: TCustomImageList; + FImageChangeLink: TChangeLink; // connections to the image list to get notified about changes + FSortColumn: TColumnIndex; + FSortDirection: TSortDirection; + FDragImage: TVTDragImage; // drag image management during header drag + FLastWidth: Integer; // Used to adjust spring columns. This is the width of all visible columns, + // not the header rectangle. + procedure FontChanged(Sender: TObject); + function GetMainColumn: TColumnIndex; + function GetUseColumns: Boolean; + function IsFontStored: Boolean; + procedure SetAutoSizeIndex(Value: TColumnIndex); + procedure SetBackground(Value: TColor); + procedure SetColumns(Value: TVirtualTreeColumns); + procedure SetDefaultHeight(Value: Integer); + procedure SetFont(const Value: TFont); + procedure SetHeight(Value: Integer); + procedure SetImages(const Value: TCustomImageList); + procedure SetMainColumn(Value: TColumnIndex); + procedure SetMaxHeight(Value: Integer); + procedure SetMinHeight(Value: Integer); + procedure SetOptions(Value: TVTHeaderOptions); + procedure SetParentFont(Value: Boolean); + procedure SetSortColumn(Value: TColumnIndex); + procedure SetSortDirection(const Value: TSortDirection); + procedure SetStyle(Value: TVTHeaderStyle); + protected + FStates: THeaderStates; // Used to keep track of internal states the header can enter. + FDragStart: TPoint; // initial mouse drag position + FTrackStart: TPoint; // client coordinates of the tracking start point + FTrackPoint: TPoint; // Client coordinate where the tracking started. + + function CanSplitterResize(P: TPoint): Boolean; + function CanWriteColumns: Boolean; virtual; + procedure ChangeScale(M, D: Integer); virtual; + function DetermineSplitterIndex(P: TPoint): Boolean; virtual; + procedure DoAfterAutoFitColumn(Column: TColumnIndex); virtual; + procedure DoAfterColumnWidthTracking(Column: TColumnIndex); virtual; + procedure DoAfterHeightTracking; virtual; + function DoBeforeAutoFitColumn(Column: TColumnIndex; SmartAutoFitType: TSmartAutoFitType): Boolean; virtual; + procedure DoBeforeColumnWidthTracking(Column: TColumnIndex; Shift: TShiftState); virtual; + procedure DoBeforeHeightTracking(Shift: TShiftState); virtual; + procedure DoCanSplitterResize(P: TPoint; var Allowed: Boolean); virtual; + function DoColumnWidthDblClickResize(Column: TColumnIndex; P: TPoint; Shift: TShiftState): Boolean; virtual; + function DoColumnWidthTracking(Column: TColumnIndex; Shift: TShiftState; var TrackPoint: TPoint; P: TPoint): Boolean; virtual; + function DoGetPopupMenu(Column: TColumnIndex; Position: TPoint): TPopupMenu; virtual; + function DoHeightTracking(var P: TPoint; Shift: TShiftState): Boolean; virtual; + function DoHeightDblClickResize(var P: TPoint; Shift: TShiftState): Boolean; virtual; + procedure DoSetSortColumn(Value: TColumnIndex); virtual; + procedure DragTo(P: TPoint); + procedure FixedAreaConstraintsChanged(Sender: TObject); + function GetColumnsClass: TVirtualTreeColumnsClass; virtual; + function GetOwner: TPersistent; override; + function GetShiftState: TShiftState; + function HandleHeaderMouseMove(var Message: TWMMouseMove): Boolean; + function HandleMessage(var Message: TMessage): Boolean; virtual; + procedure ImageListChange(Sender: TObject); + procedure PrepareDrag(P, Start: TPoint); + procedure ReadColumns(Reader: TReader); + procedure RecalculateHeader; virtual; + procedure RescaleHeader; + procedure UpdateMainColumn; + procedure UpdateSpringColumns; + procedure WriteColumns(Writer: TWriter); + public + constructor Create(AOwner: TBaseVirtualTree); virtual; + destructor Destroy; override; + + function AllowFocus(ColumnIndex: TColumnIndex): Boolean; + procedure Assign(Source: TPersistent); override; + procedure AutoFitColumns(Animated: Boolean = True; SmartAutoFitType: TSmartAutoFitType = smaUseColumnOption; + RangeStartCol: Integer = NoColumn; RangeEndCol: Integer = NoColumn); virtual; + function InHeader(P: TPoint): Boolean; virtual; + function InHeaderSplitterArea(P: TPoint): Boolean; virtual; + procedure Invalidate(Column: TVirtualTreeColumn; ExpandToBorder: Boolean = False); + procedure LoadFromStream(const Stream: TStream); virtual; + function ResizeColumns(ChangeBy: Integer; RangeStartCol: TColumnIndex; RangeEndCol: TColumnIndex; + Options: TVTColumnOptions = [coVisible]): Integer; + procedure RestoreColumns; + procedure SaveToStream(const Stream: TStream); virtual; + + property DragImage: TVTDragImage read FDragImage; + property States: THeaderStates read FStates; + property Treeview: TBaseVirtualTree read FOwner; + property UseColumns: Boolean read GetUseColumns; + published + property AutoSizeIndex: TColumnIndex read FAutoSizeIndex write SetAutoSizeIndex; + property Background: TColor read FBackground write SetBackground default clBtnFace; + property Columns: TVirtualTreeColumns read FColumns write SetColumns stored False; // Stored by the owner tree to + // support VFI. + property DefaultHeight: Integer read FDefaultHeight write SetDefaultHeight default 17; + property Font: TFont read FFont write SetFont stored IsFontStored; + property FixedAreaConstraints: TVTFixedAreaConstraints read FFixedAreaConstraints write FFixedAreaConstraints; + property Height: Integer read FHeight write SetHeight default 17; + property Images: TCustomImageList read FImages write SetImages; + property MainColumn: TColumnIndex read GetMainColumn write SetMainColumn default 0; + property MaxHeight: Integer read FMaxHeight write SetMaxHeight default 10000; + property MinHeight: Integer read FMinHeight write SetMinHeight default 10; + property Options: TVTHeaderOptions read FOptions write SetOptions default [hoColumnResize, hoDrag, hoShowSortGlyphs]; + property ParentFont: Boolean read FParentFont write SetParentFont default False; + property PopupMenu: TPopupMenu read FPopupMenu write FPopUpMenu; + property SortColumn: TColumnIndex read FSortColumn write SetSortColumn default NoColumn; + property SortDirection: TSortDirection read FSortDirection write SetSortDirection default sdAscending; + property Style: TVTHeaderStyle read FStyle write SetStyle default hsThickButtons; + end; + + TVTHeaderClass = class of TVTHeader; + + // Communication interface between a tree editor and the tree itself (declared as using stdcall in case it + // is implemented in a (C/C++) DLL). The GUID is not nessecary in Delphi but important for BCB users + // to allow QueryInterface and _uuidof calls. + IVTEditLink = interface + ['{2BE3EAFA-5ACB-45B4-9D9A-B58BCC496E17}'] + function BeginEdit: Boolean; stdcall; // Called when editing actually starts. + function CancelEdit: Boolean; stdcall; // Called when editing has been cancelled by the tree. + function EndEdit: Boolean; stdcall; // Called when editing has been finished by the tree. + function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall; + // Called after creation to allow a setup. + function GetBounds: TRect; stdcall; // Called to get the current size of the edit window + // (only important if the edit resizes itself). + procedure ProcessMessage(var Message: TMessage); stdcall; + // Used to forward messages to the edit window(s)- + procedure SetBounds(R: TRect); stdcall; // Called to place the editor. + end; + + // Indicates in the OnUpdating event what state the tree is currently in. + TVTUpdateState = ( + usBegin, // The tree just entered the update state (BeginUpdate call for the first time). + usBeginSynch, // The tree just entered the synch update state (BeginSynch call for the first time). + usSynch, // Begin/EndSynch has been called but the tree did not change the update state. + usUpdate, // Begin/EndUpdate has been called but the tree did not change the update state. + usEnd, // The tree just left the update state (EndUpdate called for the last level). + usEndSynch // The tree just left the synch update state (EndSynch called for the last level). + ); + + // Used during owner draw of the header to indicate which drop mark for the column must be drawn. + TVTDropMarkMode = ( + dmmNone, + dmmLeft, + dmmRight + ); + + // This structure carries all important information about header painting and is used in the advanced header painting. + THeaderPaintInfo = record + TargetCanvas: TCanvas; + Column: TVirtualTreeColumn; + PaintRectangle: TRect; + TextRectangle: TRect; + IsHoverIndex, + IsDownIndex, + IsEnabled, + ShowHeaderGlyph, + ShowSortGlyph, + ShowRightBorder: Boolean; + DropMark: TVTDropMarkMode; + GlyphPos, + SortGlyphPos: TPoint; + end; + + // These elements are used both to query the application, which of them it wants to draw itself and to tell it during + // painting, which elements must be drawn during the advanced custom draw events. + THeaderPaintElements = set of ( + hpeBackground, + hpeDropMark, + hpeHeaderGlyph, + hpeSortGlyph, + hpeText + ); + + // Various events must be handled at different places than they were initiated or need + // a persistent storage until they are reset. + TVirtualTreeStates = set of ( + tsCancelHintAnimation, // Set when a new hint is about to show but an old hint is still being animated. + tsChangePending, // A selection change is pending. + tsCheckPropagation, // Set during automatic check state propagation. + tsCollapsing, // A full collapse operation is in progress. + tsToggleFocusedSelection, // Node selection was modifed using Ctrl-click. Change selection state on next mouse up. + tsClearPending, // Need to clear the current selection on next mouse move. + tsClipboardFlushing, // Set during flushing the clipboard to avoid freeing the content. + tsCopyPending, // Indicates a pending copy operation which needs to be finished. + tsCutPending, // Indicates a pending cut operation which needs to be finished. + tsDrawSelPending, // Multiselection only. User held down the left mouse button on a free + // area and might want to start draw selection. + tsDrawSelecting, // Multiselection only. Draw selection has actually started. + tsEditing, // Indicates that an edit operation is currently in progress. + tsEditPending, // An mouse up start edit if dragging has not started. + tsExpanding, // A full expand operation is in progress. + tsNodeHeightTracking, // A node height changing operation is in progress. + tsNodeHeightTrackPending, // left button is down, user might want to start changing a node's height. + tsHint, // Set when our hint is visible or soon will be. + tsInAnimation, // Set if the tree is currently in an animation loop. + tsIncrementalSearching, // Set when the user starts incremental search. + tsIncrementalSearchPending, // Set in WM_KEYDOWN to tell to use the char in WM_CHAR for incremental search. + tsIterating, // Set when IterateSubtree is currently in progress. + tsKeyCheckPending, // A check operation is under way, initiated by a key press (space key). Ignore mouse. + tsLeftButtonDown, // Set when the left mouse button is down. + tsLeftDblClick, // Set when the left mouse button was doubly clicked. + tsMouseCheckPending, // A check operation is under way, initiated by a mouse click. Ignore space key. + tsMiddleButtonDown, // Set when the middle mouse button is down. + tsMiddleDblClick, // Set when the middle mouse button was doubly clicked. + tsNeedScale, // On next ChangeScale scale the default node height. + tsNeedRootCountUpdate, // Set if while loading a root node count is set. + tsOLEDragging, // OLE dragging in progress. + tsOLEDragPending, // User has requested to start delayed dragging. + tsPainting, // The tree is currently painting itself. + tsRightButtonDown, // Set when the right mouse button is down. + tsRightDblClick, // Set when the right mouse button was doubly clicked. + tsPopupMenuShown, // The user clicked the right mouse button, which might cause a popup menu to appear. + tsScrolling, // Set when autoscrolling is active. + tsScrollPending, // Set when waiting for the scroll delay time to elapse. + tsSizing, // Set when the tree window is being resized. This is used to prevent recursive calls + // due to setting the scrollbars when sizing. + tsStopValidation, // Cache validation can be stopped (usually because a change has occured meanwhile). + tsStructureChangePending, // The structure of the tree has been changed while the update was locked. + tsSynchMode, // Set when the tree is in synch mode, where no timer events are triggered. + tsThumbTracking, // Stop updating the horizontal scroll bar while dragging the vertical thumb and vice versa. + tsToggling, // A toggle operation (for some node) is in progress. + tsUpdateHiddenChildrenNeeded, // Pending update for the hidden children flag after massive visibility changes. + tsUpdating, // The tree does currently not update its window because a BeginUpdate has not yet ended. + tsUseCache, // The tree's node caches are validated and non-empty. + tsUserDragObject, // Signals that the application created an own drag object in OnStartDrag. + tsUseThemes, // The tree runs under WinXP+, is theme aware and themes are enabled. + tsValidating, // The tree's node caches are currently validated. + tsValidationNeeded, // Something in the structure of the tree has changed. The cache needs validation. + tsVCLDragging, // VCL drag'n drop in progress. + tsVCLDragPending, // One-shot flag to avoid clearing the current selection on implicit mouse up for VCL drag. + tsVCLDragFinished, // Flag to avoid triggering the OnColumnClick event twice + tsWheelPanning, // Wheel mouse panning is active or soon will be. + tsWheelScrolling, // Wheel mouse scrolling is active or soon will be. + tsWindowCreating, // Set during window handle creation to avoid frequent unnecessary updates. + tsUseExplorerTheme // The tree runs under WinVista+ and is using the explorer theme + ); + + TChangeStates = set of ( + csStopValidation, // Cache validation can be stopped (usually because a change has occured meanwhile). + csUseCache, // The tree's node caches are validated and non-empty. + csValidating, // The tree's node caches are currently validated. + csValidationNeeded // Something in the structure of the tree has changed. The cache needs validation. + ); + + // determines whether and how the drag image is to show + TVTDragImageKind = ( + diComplete, // show a complete drag image with all columns, only visible columns are shown + diMainColumnOnly, // show only the main column (the tree column) + diNoImage // don't show a drag image at all + ); + + // Switch for OLE and VCL drag'n drop. Because it is not possible to have both simultanously. + TVTDragType = ( + dtOLE, + dtVCL + ); + + // options which determine what to draw in PaintTree + TVTInternalPaintOption = ( + poBackground, // draw background image if there is any and it is enabled + poColumnColor, // erase node's background with the column's color + poDrawFocusRect, // draw focus rectangle around the focused node + poDrawSelection, // draw selected nodes with the normal selection color + poDrawDropMark, // draw drop mark if a node is currently the drop target + poGridLines, // draw grid lines if enabled + poMainOnly, // draw only the main column + poSelectedOnly, // draw only selected nodes + poUnbuffered // draw directly onto the target canvas; especially useful when printing + ); + TVTInternalPaintOptions = set of TVTInternalPaintOption; + + // Determines the look of a tree's lines. + TVTLineStyle = ( + lsCustomStyle, // application provides a line pattern + lsDotted, // usual dotted lines (default) + lsSolid // simple solid lines + ); + + // TVTLineType is used during painting a tree + TVTLineType = ( + ltNone, // no line at all + ltBottomRight, // a line from bottom to the center and from there to the right + ltTopDown, // a line from top to bottom + ltTopDownRight, // a line from top to bottom and from center to the right + ltRight, // a line from center to the right + ltTopRight, // a line from bottom to center and from there to the right + // special styles for alternative drawings of tree lines + ltLeft, // a line from top to bottom at the left + ltLeftBottom // a combination of ltLeft and a line at the bottom from left to right + ); + + // Determines how to draw tree lines. + TVTLineMode = ( + lmNormal, // usual tree lines (as in TTreeview) + lmBands // looks similar to a Nassi-Schneidermann diagram + ); + + // A collection of line type IDs which is used while painting a node. + TLineImage = array of TVTLineType; + + TVTScrollIncrement = 1..10000; + + // Export type + TVTExportType = ( + etRTF, // contentToRTF + etHTML, // contentToHTML + etText, // contentToText + etExcel, // supported by external tools + etWord, // supported by external tools + etCustom // supported by external tools + ); + + TVTNodeExportEvent = function (Sender: TBaseVirtualTree; aExportType: TVTExportType; Node: PVirtualNode): Boolean of object; + TVTColumnExportEvent = procedure (Sender: TBaseVirtualTree; aExportType: TVTExportType; Column: TVirtualTreeColumn) of object; + TVTTreeExportEvent = procedure(Sender: TBaseVirtualTree; aExportType: TVTExportType) of object; + + // A class to manage scroll bar aspects. + TScrollBarOptions = class(TPersistent) + private + FAlwaysVisible: Boolean; + FOwner: TBaseVirtualTree; + FScrollBars: TScrollStyle; // used to hide or show vertical and/or horizontal scrollbar + FScrollBarStyle: TScrollBarStyle; // kind of scrollbars to use + FIncrementX, + FIncrementY: TVTScrollIncrement; // number of pixels to scroll in one step (when auto scrolling) + procedure SetAlwaysVisible(Value: Boolean); + procedure SetScrollBars(Value: TScrollStyle); + procedure SetScrollBarStyle(Value: TScrollBarStyle); + protected + function GetOwner: TPersistent; override; + public + constructor Create(AOwner: TBaseVirtualTree); + + procedure Assign(Source: TPersistent); override; + published + property AlwaysVisible: Boolean read FAlwaysVisible write SetAlwaysVisible default False; + property HorizontalIncrement: TVTScrollIncrement read FIncrementX write FIncrementX default 20; + property ScrollBars: TScrollStyle read FScrollbars write SetScrollBars default ssBoth; + property ScrollBarStyle: TScrollBarStyle read FScrollBarStyle write SetScrollBarStyle default sbmRegular; + property VerticalIncrement: TVTScrollIncrement read FIncrementY write FIncrementY default 20; + end; + + // class to collect all switchable colors into one place + TVTColors = class(TPersistent) + private + FOwner: TBaseVirtualTree; + FColors: array[0..15] of TColor; + function GetColor(const Index: Integer): TColor; + procedure SetColor(const Index: Integer; const Value: TColor); + public + constructor Create(AOwner: TBaseVirtualTree); + + procedure Assign(Source: TPersistent); override; + published + property BorderColor: TColor index 7 read GetColor write SetColor default clBtnFace; + property DisabledColor: TColor index 0 read GetColor write SetColor default clBtnShadow; + property DropMarkColor: TColor index 1 read GetColor write SetColor default clHighlight; + property DropTargetColor: TColor index 2 read GetColor write SetColor default clHighLight; + property DropTargetBorderColor: TColor index 11 read GetColor write SetColor default clHighLight; + property FocusedSelectionColor: TColor index 3 read GetColor write SetColor default clHighLight; + property FocusedSelectionBorderColor: TColor index 9 read GetColor write SetColor default clHighLight; + property GridLineColor: TColor index 4 read GetColor write SetColor default clBtnFace; + property HeaderHotColor: TColor index 14 read GetColor write SetColor default clBtnShadow; + property HotColor: TColor index 8 read GetColor write SetColor default clWindowText; + property SelectionRectangleBlendColor: TColor index 12 read GetColor write SetColor default clHighlight; + property SelectionRectangleBorderColor: TColor index 13 read GetColor write SetColor default clHighlight; + property SelectionTextColor: TColor index 15 read GetColor write SetColor default clHighlightText; + property TreeLineColor: TColor index 5 read GetColor write SetColor default clBtnShadow; + property UnfocusedSelectionColor: TColor index 6 read GetColor write SetColor default clBtnFace; + property UnfocusedSelectionBorderColor: TColor index 10 read GetColor write SetColor default clBtnFace; + end; + + // For painting a node and its columns/cells a lot of information must be passed frequently around. + TVTImageInfo = record + Index: Integer; // Index in the associated image list. + XPos, // Horizontal position in the current target canvas. + YPos: Integer; // Vertical position in the current target canvas. + Ghosted: Boolean; // Flag to indicate that the image must be drawn slightly lighter. + Images: TCustomImageList; // The image list to be used for painting. + end; + + TVTImageInfoIndex = ( + iiNormal, + iiState, + iiCheck, + iiOverlay + ); + + // Options which are used when modifying the scroll offsets. + TScrollUpdateOptions = set of ( + suoRepaintHeader, // if suoUpdateNCArea is also set then invalidate the header + suoRepaintScrollbars, // if suoUpdateNCArea is also set then repaint both scrollbars after updating them + suoScrollClientArea, // scroll and invalidate the proper part of the client area + suoUpdateNCArea // update non-client area (scrollbars, header) + ); + + // Determines the look of a tree's buttons. + TVTButtonStyle = ( + bsRectangle, // traditional Windows look (plus/minus buttons) + bsTriangle // traditional Macintosh look + ); + + // TButtonFillMode is only used when the button style is bsRectangle and determines how to fill the interior. + TVTButtonFillMode = ( + fmTreeColor, // solid color, uses the tree's background color + fmWindowColor, // solid color, uses clWindow + fmShaded, // color gradient, Windows XP style (legacy code, use toThemeAware on Windows XP instead) + fmTransparent // transparent color, use the item's background color + ); + + TVTPaintInfo = record + Canvas: TCanvas; // the canvas to paint on + PaintOptions: TVTInternalPaintOptions; // a copy of the paint options passed to PaintTree + Node: PVirtualNode; // the node to paint + Column: TColumnIndex; // the node's column index to paint + Position: TColumnPosition; // the column position of the node + CellRect, // the node cell + ContentRect: TRect; // the area of the cell used for the node's content + NodeWidth: Integer; // the actual node width + Alignment: TAlignment; // how to align within the node rectangle + CaptionAlignment: TAlignment; // how to align text within the caption rectangle + BidiMode: TBidiMode; // directionality to be used for painting + BrushOrigin: TPoint; // the alignment for the brush used to draw dotted lines + ImageInfo: array[TVTImageInfoIndex] of TVTImageInfo; // info about each possible node image + end; + + // Method called by the Animate routine for each animation step. + TVTAnimationCallback = function(Step, StepSize: Integer; Data: Pointer): Boolean of object; + + TVTIncrementalSearch = ( + isAll, // search every node in tree, initialize if necessary + isNone, // disable incremental search + isInitializedOnly, // search only initialized nodes, skip others + isVisibleOnly // search only visible nodes, initialize if necessary + ); + + // Determines which direction to use when advancing nodes during an incremental search. + TVTSearchDirection = ( + sdForward, + sdBackward + ); + + // Determines where to start incremental searching for each key press. + TVTSearchStart = ( + ssAlwaysStartOver, // always use the first/last node (depending on direction) to search from + ssLastHit, // use the last found node + ssFocusedNode // use the currently focused node + ); + + // Determines how to use the align member of a node. + TVTNodeAlignment = ( + naFromBottom, // the align member specifies amount of units (usually pixels) from top border of the node + naFromTop, // align is to be measured from bottom + naProportional // align is to be measure in percent of the entire node height and relative to top + ); + + // Determines how to draw the selection rectangle used for draw selection. + TVTDrawSelectionMode = ( + smDottedRectangle, // same as DrawFocusRect + smBlendedRectangle // alpha blending, uses special colors (see TVTColors) + ); + + // Determines for which purpose the cell paint event is called. + TVTCellPaintMode = ( + cpmPaint, // painting the cell + cpmGetContentMargin // getting cell content margin + ); + + // Determines which sides of the cell content margin should be considered. + TVTCellContentMarginType = ( + ccmtAllSides, // consider all sides + ccmtTopLeftOnly, // consider top margin and left margin only + ccmtBottomRightOnly // consider bottom margin and right margin only + ); + + TClipboardFormats = class(TStringList) + private + FOwner: TBaseVirtualTree; + public + constructor Create(AOwner: TBaseVirtualTree); virtual; + + function Add(const S: string): Integer; override; + procedure Insert(Index: Integer; const S: string); override; + property Owner: TBaseVirtualTree read FOwner; + end; + + // ----- Event prototypes: + + // node enumeration + TVTGetNodeProc = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Data: Pointer; var Abort: Boolean) of object; + + // node events + TVTChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var Allowed: Boolean) of object; + TVTCheckChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var NewState: TCheckState; + var Allowed: Boolean) of object; + TVTChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTStructureChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Reason: TChangeReason) of object; + TVTEditCancelEvent = procedure(Sender: TBaseVirtualTree; Column: TColumnIndex) of object; + TVTEditChangingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var Allowed: Boolean) of object; + TVTEditChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex) of object; + TVTFreeNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTFocusChangingEvent = procedure(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn, + NewColumn: TColumnIndex; var Allowed: Boolean) of object; + TVTFocusChangeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex) of object; + TVTAddToSelectionEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTRemoveFromSelectionEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTGetImageEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var Ghosted: Boolean; var ImageIndex: Integer) of object; + TVTGetImageExEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var Ghosted: Boolean; var ImageIndex: Integer; var ImageList: TCustomImageList) of object; + TVTGetImageTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var ImageText: UnicodeString) of object; + TVTHotNodeChangeEvent = procedure(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode) of object; + TVTInitChildrenEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal) of object; + TVTInitNodeEvent = procedure(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; + var InitialStates: TVirtualNodeInitStates) of object; + TVTPopupEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; const P: TPoint; + var AskParent: Boolean; var PopupMenu: TPopupMenu) of object; + TVTHelpContextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var HelpContext: Integer) of object; + TVTCreateEditorEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + out EditLink: IVTEditLink) of object; + TVTSaveTreeEvent = procedure(Sender: TBaseVirtualTree; Stream: TStream) of object; + TVTSaveNodeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Stream: TStream) of object; + + // header/column events + TVTHeaderClickEvent = procedure(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo) of object; + TVTHeaderMouseEvent = procedure(Sender: TVTHeader; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object; + TVTHeaderMouseMoveEvent = procedure(Sender: TVTHeader; Shift: TShiftState; X, Y: Integer) of object; + TVTBeforeHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; Shift: TShiftState) of object; + TVTAfterHeaderHeightTrackingEvent = procedure(Sender: TVTHeader) of object; + TVTHeaderHeightTrackingEvent = procedure(Sender: TVTHeader; var P: TPoint; Shift: TShiftState; var Allowed: Boolean) of object; + TVTHeaderHeightDblClickResizeEvent = procedure(Sender: TVTHeader; var P: TPoint; Shift: TShiftState; var Allowed: Boolean) of object; + TVTHeaderNotifyEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object; + TVTHeaderDraggingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var Allowed: Boolean) of object; + TVTHeaderDraggedEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; OldPosition: Integer) of object; + TVTHeaderDraggedOutEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; DropPosition: TPoint) of object; + TVTHeaderPaintEvent = procedure(Sender: TVTHeader; HeaderCanvas: TCanvas; Column: TVirtualTreeColumn; R: TRect; Hover, + Pressed: Boolean; DropMark: TVTDropMarkMode) of object; + TVTHeaderPaintQueryElementsEvent = procedure(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo; + var Elements: THeaderPaintElements) of object; + TVTAdvancedHeaderPaintEvent = procedure(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo; + const Elements: THeaderPaintElements) of object; + TVTBeforeAutoFitColumnsEvent = procedure(Sender: TVTHeader; var SmartAutoFitType: TSmartAutoFitType) of object; + TVTBeforeAutoFitColumnEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var SmartAutoFitType: TSmartAutoFitType; + var Allowed: Boolean) of object; + TVTAfterAutoFitColumnEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object; + TVTAfterAutoFitColumnsEvent = procedure(Sender: TVTHeader) of object; + TVTColumnClickEvent = procedure (Sender: TBaseVirtualTree; Column: TColumnIndex; Shift: TShiftState) of object; + TVTColumnDblClickEvent = procedure (Sender: TBaseVirtualTree; Column: TColumnIndex; Shift: TShiftState) of object; + TVTColumnWidthDblClickResizeEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState; P: TPoint; + var Allowed: Boolean) of object; + TVTBeforeColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState) of object; + TVTAfterColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex) of object; + TVTColumnWidthTrackingEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; Shift: TShiftState; var TrackPoint: TPoint; P: TPoint; + var Allowed: Boolean) of object; + TVTGetHeaderCursorEvent = procedure(Sender: TVTHeader; var Cursor: HCURSOR) of object; + TVTBeforeGetMaxColumnWidthEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var UseSmartColumnWidth: Boolean) of object; + TVTAfterGetMaxColumnWidthEvent = procedure(Sender: TVTHeader; Column: TColumnIndex; var MaxWidth: Integer) of object; + TVTCanSplitterResizeColumnEvent = procedure(Sender: TVTHeader; P: TPoint; Column: TColumnIndex; var Allowed: Boolean) of object; + TVTCanSplitterResizeHeaderEvent = procedure(SendeR: TVTHeader; P: TPoint; var Allowed: Boolean) of object; + + // move, copy and node tracking events + TVTNodeMovedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTNodeMovingEvent = procedure(Sender: TBaseVirtualTree; Node, Target: PVirtualNode; + var Allowed: Boolean) of object; + TVTNodeCopiedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode) of object; + TVTNodeCopyingEvent = procedure(Sender: TBaseVirtualTree; Node, Target: PVirtualNode; + var Allowed: Boolean) of object; + TVTNodeClickEvent = procedure(Sender: TBaseVirtualTree; const HitInfo: THitInfo) of object; + TVTNodeHeightTrackingEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState; + var TrackPoint: TPoint; P: TPoint; var Allowed: Boolean) of object; + TVTNodeHeightDblClickResizeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + Shift: TShiftState; P: TPoint; var Allowed: Boolean) of object; + TVTCanSplitterResizeNodeEvent = procedure(Sender: TBaseVirtualTree; P: TPoint; Node: PVirtualNode; + Column: TColumnIndex; var Allowed: Boolean) of object; + + // drag'n drop/OLE events + TVTCreateDragManagerEvent = procedure(Sender: TBaseVirtualTree; out DragManager: IVTDragManager) of object; + TVTCreateDataObjectEvent = procedure(Sender: TBaseVirtualTree; out IDataObject: IDataObject) of object; + TVTDragAllowedEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var Allowed: Boolean) of object; + TVTDragOverEvent = procedure(Sender: TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState; + Pt: TPoint; Mode: TDropMode; var Effect: Integer; var Accept: Boolean) of object; + TVTDragDropEvent = procedure(Sender: TBaseVirtualTree; Source: TObject; DataObject: IDataObject; + Formats: TFormatArray; Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode) of object; + TVTRenderOLEDataEvent = procedure(Sender: TBaseVirtualTree; const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; + ForClipboard: Boolean; var Result: HRESULT) of object; + TVTGetUserClipboardFormatsEvent = procedure(Sender: TBaseVirtualTree; var Formats: TFormatEtcArray) of object; + + // paint events + TVTBeforeItemEraseEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect; + var ItemColor: TColor; var EraseAction: TItemEraseAction) of object; + TVTAfterItemEraseEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + ItemRect: TRect) of object; + TVTBeforeItemPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + ItemRect: TRect; var CustomDraw: Boolean) of object; + TVTAfterItemPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + ItemRect: TRect) of object; + TVTBeforeCellPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect) of object; + TVTAfterCellPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; CellRect: TRect) of object; + TVTPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas) of object; + TVTBackgroundPaintEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; R: TRect; + var Handled: Boolean) of object; + TVTGetLineStyleEvent = procedure(Sender: TBaseVirtualTree; var Bits: Pointer) of object; + TVTMeasureItemEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + var NodeHeight: Integer) of object; + + // search, sort + TVTCompareEvent = procedure(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex; + var Result: Integer) of object; + TVTIncrementalSearchEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: UnicodeString; + var Result: Integer) of object; + + // operations + TVTOperationEvent = procedure(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind) of object; + + // miscellaneous + TVTBeforeDrawLineImageEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Level: Integer; var PosX: Integer) of object; + TVTGetNodeDataSizeEvent = procedure(Sender: TBaseVirtualTree; var NodeDataSize: Integer) of object; + TVTKeyActionEvent = procedure(Sender: TBaseVirtualTree; var CharCode: Word; var Shift: TShiftState; + var DoDefault: Boolean) of object; + TVTScrollEvent = procedure(Sender: TBaseVirtualTree; DeltaX, DeltaY: Integer) of object; + TVTUpdatingEvent = procedure(Sender: TBaseVirtualTree; State: TVTUpdateState) of object; + TVTGetCursorEvent = procedure(Sender: TBaseVirtualTree; var Cursor: TCursor) of object; + TVTStateChangeEvent = procedure(Sender: TBaseVirtualTree; Enter, Leave: TVirtualTreeStates) of object; + TVTGetCellIsEmptyEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var IsEmpty: Boolean) of object; + TVTScrollbarShowEvent = procedure(Sender: TBaseVirtualTree; Bar: Integer; Show: Boolean) of object; + + // Helper types for node iterations. + TGetFirstNodeProc = function: PVirtualNode of object; + TGetNextNodeProc = function(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode of object; + + TVZVirtualNodeEnumerationMode = ( + vneAll, + vneChecked, + vneChild, + vneCutCopy, + vneInitialized, + vneLeaf, + vneLevel, + vneNoInit, + vneSelected, + vneVisible, + vneVisibleChild, + vneVisibleNoInitChild, + vneVisibleNoInit + ); + + PVTVirtualNodeEnumeration = ^TVTVirtualNodeEnumeration; + + TVTVirtualNodeEnumerator = {$ifdef COMPILER_10_UP}record{$else}class{$endif} + private + FNode: PVirtualNode; + FCanModeNext: Boolean; + FEnumeration: PVTVirtualNodeEnumeration; + function GetCurrent: PVirtualNode; {$ifdef COMPILER_10_UP}inline;{$endif} + public + function MoveNext: Boolean; {$ifdef COMPILER_10_UP}inline;{$endif} + property Current: PVirtualNode read GetCurrent; + end; + + TVTVirtualNodeEnumeration = {$ifdef COMPILER_10_UP}record{$else}object{$endif} + private + FMode: TVZVirtualNodeEnumerationMode; + FTree: TBaseVirtualTree; + // GetNextXxx parameters: + FConsiderChildrenAbove: Boolean; + FNode: PVirtualNode; + FNodeLevel: Cardinal; + FState: TCheckState; + FIncludeFiltered: Boolean; + public + function GetEnumerator: TVTVirtualNodeEnumerator; + private + function GetNext(Node: PVirtualNode): PVirtualNode; + end; + + // ----- TBaseVirtualTree + TBaseVirtualTree = class(TCustomControl) + private + FBorderStyle: TBorderStyle; + FHeader: TVTHeader; + FRoot: PVirtualNode; + FDefaultNodeHeight, + FIndent: Cardinal; + FOptions: TCustomVirtualTreeOptions; + FUpdateCount: Cardinal; // update stopper, updates of the tree control are only done if = 0 + FSynchUpdateCount: Cardinal; // synchronizer, causes all events which are usually done via timers + // to happen immediately, regardless of the normal update state + FNodeDataSize: Integer; // number of bytes to allocate with each node (in addition to its base + // structure and the internal data), if -1 then do callback + FStates: TVirtualTreeStates; // various active/pending states the tree needs to consider + FLastSelected, + FFocusedNode: PVirtualNode; + FEditColumn, // column to be edited (focused node) + FFocusedColumn: TColumnIndex; // NoColumn if no columns are active otherwise the last hit column of + // the currently focused node + FHeightTrackPoint: TPoint; // Starting point of a node's height changing operation. + FHeightTrackNode: PVirtualNode; // Node which height is being changed. + FHeightTrackColumn: TColumnIndex; // Initial column where the height changing operation takes place. + FScrollDirections: TScrollDirections; // directions to scroll client area into depending on mouse position + FLastStructureChangeReason: TChangeReason; // Used for delayed structure change event. + FLastStructureChangeNode, // dito + FLastChangedNode, // used for delayed change event + FCurrentHotNode: PVirtualNode; // Node over which the mouse is hovering. + FCurrentHotColumn: TColumnIndex; // Column over which the mouse is hovering. + FHotNodeButtonHit: Boolean; // Indicates wether the mouse is hovering over the hot node's button. + FLastSelRect, + FNewSelRect: TRect; // used while doing draw selection + FHotCursor: TCursor; // can be set to additionally indicate the current hot node + FAnimationType: THintAnimationType; // none, fade in, slide in animation (just like those animations used + // in Win98 (slide) and Windows 2000 (fade)) + FHintMode: TVTHintMode; // determines the kind of the hint window + FHintData: TVTHintData; // used while preparing the hint window + FChangeDelay: Cardinal; // used to delay OnChange event + FEditDelay: Cardinal; // determines time to elapse before a node goes into edit mode + FPositionCache: TCache; // array which stores node references ordered by vertical positions + // (see also DoValidateCache for more information) + FVisibleCount: Cardinal; // number of currently visible nodes + FStartIndex: Cardinal; // index to start validating cache from + FSelection: TNodeArray; // list of currently selected nodes + FSelectionCount: Integer; // number of currently selected nodes (size of FSelection might differ) + FSelectionLocked: Boolean; // prevents the tree from changing the selection + FRangeAnchor: PVirtualNode; // anchor node for selection with the keyboard, determines start of a + // selection range + FCheckNode: PVirtualNode; // node which "captures" a check event + FPendingCheckState: TCheckState; // the new state the check node will get if all went fine + FCheckPropagationCount: Cardinal; // nesting level of check propagation (WL, 05.02.2004) + FLastSelectionLevel: Integer; // keeps the last node level for constrained multiselection + FDrawSelShiftState: TShiftState; // keeps the initial shift state when the user starts selection with + // the mouse + FEditLink: IVTEditLink; // used to comunicate with an application defined editor + FTempNodeCache: TNodeArray; // used at various places to hold temporarily a bunch of node refs. + FTempNodeCount: Cardinal; // number of nodes in FTempNodeCache + FBackground: TPicture; // A background image loadable at design and runtime. + FMargin: Integer; // horizontal border distance + FTextMargin: Integer; // space between the node's text and its horizontal bounds + FBackgroundOffsetX, + FBackgroundOffsetY: Integer; // used to fine tune the position of the background image + FAnimationDuration: Cardinal; // specifies how long an animation shall take (expanding, hint) + FWantTabs: Boolean; // If True then the tree also consumes the tab key. + FNodeAlignment: TVTNodeAlignment; // determines how to interpret the align member of a node + FHeaderRect: TRect; // Space which the header currently uses in the control (window coords). + FLastHintRect: TRect; // Area which the mouse must leave to reshow a hint. + FUpdateRect: TRect; + FEmptyListMessage: UnicodeString; // Optional message that will be displayed if no nodes exist in the control. + + // paint support and images + FPlusBM, + FMinusBM, // small bitmaps used for tree buttons + FHotPlusBM, + FHotMinusBM: TBitmap; // small bitmaps used for hot tree buttons + FImages, // normal images in the tree + FStateImages, // state images in the tree + FCustomCheckImages: TCustomImageList; // application defined check images + FCheckImageKind: TCheckImageKind; // light or dark, cross marks or tick marks + FCheckImages: TCustomImageList; // Reference to global image list to be used for the check images. + FImageChangeLink, + FStateChangeLink, + FCustomCheckChangeLink: TChangeLink; // connections to the image lists + FOldFontChange: TNotifyEvent; // helper method pointer for tracking font changes in the off screen buffer + FFontChanged: Boolean; // flag for keeping informed about font changes in the off screen buffer + FColors: TVTColors; // class comprising all customizable colors in the tree + FButtonStyle: TVTButtonStyle; // style of the tree buttons + FButtonFillMode: TVTButtonFillMode; // for rectangular tree buttons only: how to fill them + FLineStyle: TVTLineStyle; // style of the tree lines + FLineMode: TVTLineMode; // tree lines or bands etc. + FDottedBrush: HBRUSH; // used to paint dotted lines without special pens + FSelectionCurveRadius: Cardinal; // radius for rounded selection rectangles + FSelectionBlendFactor: Byte; // Determines the factor by which the selection rectangle is to be + // faded if enabled. + FDrawSelectionMode: TVTDrawSelectionMode; // determines the paint mode for draw selection + + // alignment and directionality support + FAlignment: TAlignment; // default alignment of the tree if no columns are shown + + // drag'n drop and clipboard support + FDragImageKind: TVTDragImageKind; // determines whether or not and what to show in the drag image + FDragOperations: TDragOperations; // determines which operations are allowed during drag'n drop + FDragThreshold: Integer; // used to determine when to actually start a drag'n drop operation + FDragManager: IVTDragManager; // drag'n drop, cut'n paste + FDropTargetNode: PVirtualNode; // node currently selected as drop target + FLastDropMode: TDropMode; // set while dragging and used to track changes + FDragSelection: TNodeArray; // temporary copy of FSelection used during drag'n drop + FDragType: TVTDragType; // used to switch between OLE and VCL drag'n drop + FDragImage: TVTDragImage; // drag image management + FDragWidth, + FDragHeight: Integer; // size of the drag image, the larger the more CPU power is needed + FClipboardFormats: TClipboardFormats; // a list of clipboard format descriptions enabled for this tree + FLastVCLDragTarget: PVirtualNode; // A node cache for VCL drag'n drop (keywords: DragLeave on DragDrop). + FVCLDragEffect: Integer; // A cache for VCL drag'n drop to keep the current drop effect. + + // scroll support + FScrollBarOptions: TScrollBarOptions; // common properties of horizontal and vertical scrollbar + FAutoScrollInterval: TAutoScrollInterval; // determines speed of auto scrolling + FAutoScrollDelay: Cardinal; // amount of milliseconds to wait until autoscrolling becomes active + FAutoExpandDelay: Cardinal; // amount of milliseconds to wait until a node is expanded if it is the + // drop target + FOffsetX: Integer; + FOffsetY: Integer; // Determines left and top scroll offset. + FEffectiveOffsetX: Integer; // Actual position of the horizontal scroll bar (varies depending on bidi mode). + FRangeX, + FRangeY: Cardinal; // current virtual width and height of the tree + FBottomSpace: Cardinal; // Extra space below the last node. + + FDefaultPasteMode: TVTNodeAttachMode; // Used to determine where to add pasted nodes to. + FSingletonNodeArray: TNodeArray; // Contains only one element for quick addition of single nodes + // to the selection. + FDragScrollStart: Cardinal; // Contains the start time when a tree does auto scrolling as drop target. + + // search + FIncrementalSearch: TVTIncrementalSearch; // Used to determine whether and how incremental search is to be used. + FSearchTimeout: Cardinal; // Number of milliseconds after which to stop incremental searching. + FSearchBuffer: UnicodeString; // Collects a sequence of keypresses used to do incremental searching. + FLastSearchNode: PVirtualNode; // Reference to node which was last found as search fit. + FSearchDirection: TVTSearchDirection; // Direction to incrementally search the tree. + FSearchStart: TVTSearchStart; // Where to start iteration on each key press. + + // miscellanous + FTotalInternalDataSize: Cardinal; // Cache of the sum of the necessary internal data size for all tree + // classes derived from this base class. + FPanningWindow: HWND; // Helper window for wheel panning + FPanningCursor: HCURSOR; // Current wheel panning cursor. + FPanningImage: TBitmap; // A little 32x32 bitmap to indicate the panning reference point. + FLastClickPos: TPoint; // Used for retained drag start and wheel mouse scrolling. + FOperationCount: Cardinal; // Counts how many nested long-running operations are in progress. + FOperationCanceled: Boolean; // Used to indicate that a long-running operation should be canceled. + + // MSAA support + FAccessible: IAccessible; // The IAccessible interface to the window itself. + FAccessibleItem: IAccessible; // The IAccessible to the item that currently has focus. + FAccessibleName: string; // The name the window is given for screen readers. + + // export + FOnBeforeNodeExport: TVTNodeExportEvent; // called before exporting a node + FOnNodeExport: TVTNodeExportEvent; + FOnAfterNodeExport: TVTNodeExportEvent; // called after exporting a node + FOnBeforeColumnExport: TVTColumnExportEvent; // called before exporting a column + FOnColumnExport: TVTColumnExportEvent; + FOnAfterColumnExport: TVTColumnExportEvent; // called after exporting a column + FOnBeforeTreeExport: TVTTreeExportEvent; // called before starting the export + FOnAfterTreeExport: TVTTreeExportEvent; // called after finishing the export + FOnBeforeHeaderExport: TVTTreeExportEvent; // called before exporting the header + FOnAfterHeaderExport: TVTTreeExportEvent; // called after exporting the header + + // common events + FOnChange: TVTChangeEvent; // selection change + FOnStructureChange: TVTStructureChangeEvent; // structural change like adding nodes etc. + FOnInitChildren: TVTInitChildrenEvent; // called when a node's children are needed (expanding etc.) + FOnInitNode: TVTInitNodeEvent; // called when a node needs to be initialized (child count etc.) + FOnFreeNode: TVTFreeNodeEvent; // called when a node is about to be destroyed, user data can and should + // be freed in this event + FOnGetImage: TVTGetImageEvent; // Used to retrieve the image index of a given node. + FOnGetImageEx: TVTGetImageExEvent; // Used to retrieve the image index of a given node along with a custom + // image list. + FOnGetImageText: TVTGetImageTextEvent; // Used to retrieve the image alternative text of a given node. + // Used by the accessibility interface to provide useful text for status images. + FOnHotChange: TVTHotNodeChangeEvent; // called when the current "hot" node (that is, the node under the mouse) + // changes and hot tracking is enabled + FOnExpanding, // called just before a node is expanded + FOnCollapsing: TVTChangingEvent; // called just before a node is collapsed + FOnChecking: TVTCheckChangingEvent; // called just before a node's check state is changed + FOnExpanded, // called after a node has been expanded + FOnCollapsed, // called after a node has been collapsed + FOnChecked: TVTChangeEvent; // called after a node's check state has been changed + FOnResetNode: TVTChangeEvent; // called when a node is set to be uninitialized + FOnNodeMoving: TVTNodeMovingEvent; // called just before a node is moved from one parent node to another + // (this can be cancelled) + FOnNodeMoved: TVTNodeMovedEvent; // called after a node and its children have been moved to another + // parent node (probably another tree, but within the same application) + FOnNodeCopying: TVTNodeCopyingEvent; // called when a node is copied to another parent node (probably in + // another tree, but within the same application, can be cancelled) + FOnNodeClick: TVTNodeClickEvent; // called when the user clicks on a node + FOnNodeDblClick: TVTNodeClickEvent; // called when the user double clicks on a node + FOnCanSplitterResizeNode: TVTCanSplitterResizeNodeEvent; // called to query the application wether resizing a node is allowed + FOnNodeHeightTracking: TVTNodeHeightTrackingEvent; // called when a node's height is being changed via mouse + FOnNodeHeightDblClickResize: TVTNodeHeightDblClickResizeEvent; // called when a node's vertical splitter is double clicked + FOnNodeCopied: TVTNodeCopiedEvent; // call after a node has been copied + FOnEditing: TVTEditChangingEvent; // called just before a node goes into edit mode + FOnEditCancelled: TVTEditCancelEvent; // called when editing has been cancelled + FOnEdited: TVTEditChangeEvent; // called when editing has successfully been finished + FOnFocusChanging: TVTFocusChangingEvent; // called when the focus is about to go to a new node and/or column + // (can be cancelled) + FOnFocusChanged: TVTFocusChangeEvent; // called when the focus goes to a new node and/or column + FOnAddToSelection: TVTAddToSelectionEvent; // called when a node is added to the selection + FOnRemoveFromSelection: TVTRemoveFromSelectionEvent; // called when a node is removed from the selection + FOnGetPopupMenu: TVTPopupEvent; // called when the popup for a node or the header needs to be shown + FOnGetHelpContext: TVTHelpContextEvent; // called when a node specific help theme should be called + FOnCreateEditor: TVTCreateEditorEvent; // called when a node goes into edit mode, this allows applications + // to supply their own editor + FOnLoadNode, // called after a node has been loaded from a stream (file, clipboard, + // OLE drag'n drop) to allow an application to load their own data + // saved in OnSaveNode + FOnSaveNode: TVTSaveNodeEvent; // called when a node needs to be serialized into a stream + // (see OnLoadNode) to give the application the opportunity to save + // their node specific, persistent data (note: never save memory + // references) + FOnLoadTree, // called after the tree has been loaded from a stream to allow an + // application to load their own data saved in OnSaveTree + FOnSaveTree: TVTSaveTreeEvent; // called after the tree has been saved to a stream to allow an + // application to save its own data + + // header/column mouse events + FOnAfterAutoFitColumn: TVTAfterAutoFitColumnEvent; + FOnAfterAutoFitColumns: TVTAfterAutoFitColumnsEvent; + FOnBeforeAutoFitColumns: TVTBeforeAutoFitColumnsEvent; + FOnBeforeAutoFitColumn: TVTBeforeAutoFitColumnEvent; + FOnHeaderClick: TVTHeaderClickEvent; + FOnHeaderDblClick: TVTHeaderClickEvent; + FOnAfterHeaderHeightTracking: TVTAfterHeaderHeightTrackingEvent; + FOnBeforeHeaderHeightTracking: TVTBeforeHeaderHeightTrackingEvent; + FOnHeaderHeightTracking: TVTHeaderHeightTrackingEvent; + FOnHeaderHeightDblClickResize: TVTHeaderHeightDblClickResizeEvent; + FOnHeaderMouseDown, + FOnHeaderMouseUp: TVTHeaderMouseEvent; + FOnHeaderMouseMove: TVTHeaderMouseMoveEvent; + FOnAfterGetMaxColumnWidth: TVTAfterGetMaxColumnWidthEvent; + FOnBeforeGetMaxColumnWidth: TVTBeforeGetMaxColumnWidthEvent; + FOnColumnClick: TVTColumnClickEvent; + FOnColumnDblClick: TVTColumnDblClickEvent; + FOnColumnResize: TVTHeaderNotifyEvent; + FOnColumnWidthDblClickResize: TVTColumnWidthDblClickResizeEvent; + FOnAfterColumnWidthTracking: TVTAfterColumnWidthTrackingEvent; + FOnBeforeColumnWidthTracking: TVTBeforeColumnWidthTrackingEvent; + FOnColumnWidthTracking: TVTColumnWidthTrackingEvent; + FOnGetHeaderCursor: TVTGetHeaderCursorEvent; // triggered to allow the app. to use customized cursors for the header + FOnCanSplitterResizeColumn: TVTCanSplitterResizeColumnEvent; + FOnCanSplitterResizeHeader: TVTCanSplitterResizeHeaderEvent; + + // paint events + FOnAfterPaint, // triggered when the tree has entirely been painted + FOnBeforePaint: TVTPaintEvent; // triggered when the tree is about to be painted + FOnAfterItemPaint: TVTAfterItemPaintEvent; // triggered after an item has been painted + FOnBeforeItemPaint: TVTBeforeItemPaintEvent; // triggered when an item is about to be painted + FOnBeforeItemErase: TVTBeforeItemEraseEvent; // triggered when an item's background is about to be erased + FOnAfterItemErase: TVTAfterItemEraseEvent; // triggered after an item's background has been erased + FOnAfterCellPaint: TVTAfterCellPaintEvent; // triggered after a column of an item has been painted + FOnBeforeCellPaint: TVTBeforeCellPaintEvent; // triggered when a column of an item is about to be painted + FOnHeaderDraw: TVTHeaderPaintEvent; // Used when owner draw is enabled for the header and a column is set + // to owner draw mode. + FOnHeaderDrawQueryElements: TVTHeaderPaintQueryElementsEvent; // Used for advanced header painting to query the + // application for the elements, which are drawn by it and which should + // be drawn by the tree. + FOnAdvancedHeaderDraw: TVTAdvancedHeaderPaintEvent; // Used when owner draw is enabled for the header and a column + // is set to owner draw mode. But only if OnHeaderDrawQueryElements + // returns at least one element to be drawn by the application. + // In this case OnHeaderDraw is not used. + FOnGetLineStyle: TVTGetLineStyleEvent; // triggered when a custom line style is used and the pattern brush + // needs to be build + FOnPaintBackground: TVTBackgroundPaintEvent; // triggered if a part of the tree's background must be erased which is + // not covered by any node + FOnMeasureItem: TVTMeasureItemEvent; // Triggered when a node is about to be drawn and its height was not yet + // determined by the application. + + // drag'n drop events + FOnCreateDragManager: TVTCreateDragManagerEvent; // called to allow for app./descendant defined drag managers + FOnCreateDataObject: TVTCreateDataObjectEvent; // called to allow for app./descendant defined data objects + FOnDragAllowed: TVTDragAllowedEvent; // used to get permission for manual drag in mouse down + FOnDragOver: TVTDragOverEvent; // called for every mouse move + FOnDragDrop: TVTDragDropEvent; // called on release of mouse button (if drop was allowed) + FOnHeaderDragged: TVTHeaderDraggedEvent; // header (column) drag'n drop + FOnHeaderDraggedOut: TVTHeaderDraggedOutEvent; // header (column) drag'n drop, which did not result in a valid drop. + FOnHeaderDragging: TVTHeaderDraggingEvent; // header (column) drag'n drop + FOnRenderOLEData: TVTRenderOLEDataEvent; // application/descendant defined clipboard formats + FOnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent; // gives application/descendants the opportunity to + // add own clipboard formats on the fly + + // miscellanous events + FOnGetNodeDataSize: TVTGetNodeDataSizeEvent; // Called if NodeDataSize is -1. + FOnBeforeDrawLineImage: TVTBeforeDrawLineImageEvent; // Called to allow adjusting the indention of treelines. + FOnKeyAction: TVTKeyActionEvent; // Used to selectively prevent key actions (full expand on Ctrl+'+' etc.). + FOnScroll: TVTScrollEvent; // Called when one or both paint offsets changed. + FOnUpdating: TVTUpdatingEvent; // Called from BeginUpdate, EndUpdate, BeginSynch and EndSynch. + FOnGetCursor: TVTGetCursorEvent; // Called to allow the app. to set individual cursors. + FOnStateChange: TVTStateChangeEvent; // Called whenever a state in the tree changes. + FOnGetCellIsEmpty: TVTGetCellIsEmptyEvent; // Called when the tree needs to know if a cell is empty. + FOnShowScrollbar: TVTScrollbarShowEvent; // Called when a scrollbar is changed in its visibility. + + // search, sort + FOnCompareNodes: TVTCompareEvent; // used during sort + FOnIncrementalSearch: TVTIncrementalSearchEvent; // triggered on every key press (not key down) + + // operations + FOnStartOperation: TVTOperationEvent; // Called when an operation starts + FOnEndOperation: TVTOperationEvent; // Called when an operation ends + + procedure AdjustCoordinatesByIndent(var PaintInfo: TVTPaintInfo; Indent: Integer); + procedure AdjustTotalCount(Node: PVirtualNode; Value: Integer; relative: Boolean = False); + procedure AdjustTotalHeight(Node: PVirtualNode; Value: Integer; relative: Boolean = False); + function CalculateCacheEntryCount: Integer; + procedure CalculateVerticalAlignments(ShowImages, ShowStateImages: Boolean; Node: PVirtualNode; var VAlign, + VButtonAlign: Integer); + function ChangeCheckState(Node: PVirtualNode; Value: TCheckState): Boolean; + function CollectSelectedNodesLTR(MainColumn, NodeLeft, NodeRight: Integer; Alignment: TAlignment; OldRect, + NewRect: TRect): Boolean; + function CollectSelectedNodesRTL(MainColumn, NodeLeft, NodeRight: Integer; Alignment: TAlignment; OldRect, + NewRect: TRect): Boolean; + procedure ClearNodeBackground(const PaintInfo: TVTPaintInfo; UseBackground, Floating: Boolean; R: TRect); + function CompareNodePositions(Node1, Node2: PVirtualNode; ConsiderChildrenAbove: Boolean = False): Integer; + procedure DrawLineImage(const PaintInfo: TVTPaintInfo; X, Y, H, VAlign: Integer; Style: TVTLineType; Reverse: Boolean); + function FindInPositionCache(Node: PVirtualNode; var CurrentPos: Cardinal): PVirtualNode; overload; + function FindInPositionCache(Position: Cardinal; var CurrentPos: Cardinal): PVirtualNode; overload; + procedure FixupTotalCount(Node: PVirtualNode); + procedure FixupTotalHeight(Node: PVirtualNode); + function GetBottomNode: PVirtualNode; + function GetCheckedCount: Integer; + function GetCheckState(Node: PVirtualNode): TCheckState; + function GetCheckType(Node: PVirtualNode): TCheckType; + function GetChildCount(Node: PVirtualNode): Cardinal; + function GetChildrenInitialized(Node: PVirtualNode): Boolean; + function GetCutCopyCount: Integer; + function GetDisabled(Node: PVirtualNode): Boolean; + function GetDragManager: IVTDragManager; + function GetExpanded(Node: PVirtualNode): Boolean; + function GetFiltered(Node: PVirtualNode): Boolean; + function GetFullyVisible(Node: PVirtualNode): Boolean; + function GetHasChildren(Node: PVirtualNode): Boolean; + function GetMultiline(Node: PVirtualNode): Boolean; + function GetNodeHeight(Node: PVirtualNode): Cardinal; + function GetNodeParent(Node: PVirtualNode): PVirtualNode; + function GetOffsetXY: TPoint; + function GetRootNodeCount: Cardinal; + function GetSelected(Node: PVirtualNode): Boolean; + function GetTopNode: PVirtualNode; + function GetTotalCount: Cardinal; + function GetVerticalAlignment(Node: PVirtualNode): Byte; + function GetVisible(Node: PVirtualNode): Boolean; + function GetVisiblePath(Node: PVirtualNode): Boolean; + procedure HandleClickSelection(LastFocused, NewNode: PVirtualNode; Shift: TShiftState; DragPending: Boolean); + function HandleDrawSelection(X, Y: Integer): Boolean; + function HasVisibleNextSibling(Node: PVirtualNode): Boolean; + function HasVisiblePreviousSibling(Node: PVirtualNode): Boolean; + procedure ImageListChange(Sender: TObject); + procedure InitializeFirstColumnValues(var PaintInfo: TVTPaintInfo); + procedure InitRootNode(OldSize: Cardinal = 0); + procedure InterruptValidation; + function IsFirstVisibleChild(Parent, Node: PVirtualNode): Boolean; + function IsLastVisibleChild(Parent, Node: PVirtualNode): Boolean; + function MakeNewNode: PVirtualNode; + function PackArray({*}const TheArray: TNodeArray; Count: Integer): Integer; + procedure PrepareBitmaps(NeedButtons, NeedLines: Boolean); + procedure ReadOldOptions(Reader: TReader); + procedure SetAlignment(const Value: TAlignment); + procedure SetAnimationDuration(const Value: Cardinal); + procedure SetBackground(const Value: TPicture); + procedure SetBackgroundOffset(const Index, Value: Integer); + procedure SetBorderStyle(Value: TBorderStyle); + procedure SetBottomNode(Node: PVirtualNode); + procedure SetBottomSpace(const Value: Cardinal); + procedure SetButtonFillMode(const Value: TVTButtonFillMode); + procedure SetButtonStyle(const Value: TVTButtonStyle); + procedure SetCheckImageKind(Value: TCheckImageKind); + procedure SetCheckState(Node: PVirtualNode; Value: TCheckState); + procedure SetCheckType(Node: PVirtualNode; Value: TCheckType); + procedure SetChildCount(Node: PVirtualNode; NewChildCount: Cardinal); + procedure SetClipboardFormats(const Value: TClipboardFormats); + procedure SetColors(const Value: TVTColors); + procedure SetCustomCheckImages(const Value: TCustomImageList); + procedure SetDefaultNodeHeight(Value: Cardinal); + procedure SetDisabled(Node: PVirtualNode; Value: Boolean); + procedure SetEmptyListMessage(const Value: UnicodeString); + procedure SetExpanded(Node: PVirtualNode; Value: Boolean); + procedure SetFocusedColumn(Value: TColumnIndex); + procedure SetFocusedNode(Value: PVirtualNode); + procedure SetFullyVisible(Node: PVirtualNode; Value: Boolean); + procedure SetHasChildren(Node: PVirtualNode; Value: Boolean); + procedure SetHeader(const Value: TVTHeader); + procedure SetFiltered(Node: PVirtualNode; Value: Boolean); + procedure SetImages(const Value: TCustomImageList); + procedure SetIndent(Value: Cardinal); + procedure SetLineMode(const Value: TVTLineMode); + procedure SetLineStyle(const Value: TVTLineStyle); + procedure SetMargin(Value: Integer); + procedure SetMultiline(Node: PVirtualNode; const Value: Boolean); + procedure SetNodeAlignment(const Value: TVTNodeAlignment); + procedure SetNodeDataSize(Value: Integer); + procedure SetNodeHeight(Node: PVirtualNode; Value: Cardinal); + procedure SetNodeParent(Node: PVirtualNode; const Value: PVirtualNode); + procedure SetOffsetX(const Value: Integer); + procedure SetOffsetXY(const Value: TPoint); + procedure SetOffsetY(const Value: Integer); + procedure SetOptions(const Value: TCustomVirtualTreeOptions); + procedure SetRootNodeCount(Value: Cardinal); + procedure SetScrollBarOptions(Value: TScrollBarOptions); + procedure SetSearchOption(const Value: TVTIncrementalSearch); + procedure SetSelected(Node: PVirtualNode; Value: Boolean); + procedure SetSelectionCurveRadius(const Value: Cardinal); + procedure SetStateImages(const Value: TCustomImageList); + procedure SetTextMargin(Value: Integer); + procedure SetTopNode(Node: PVirtualNode); + procedure SetUpdateState(Updating: Boolean); + procedure SetVerticalAlignment(Node: PVirtualNode; Value: Byte); + procedure SetVisible(Node: PVirtualNode; Value: Boolean); + procedure SetVisiblePath(Node: PVirtualNode; Value: Boolean); + procedure StaticBackground(Source: TBitmap; Target: TCanvas; OffsetPosition: TPoint; R: TRect); + procedure StopTimer(ID: Integer); + procedure TileBackground(Source: TBitmap; Target: TCanvas; Offset: TPoint; R: TRect); + function ToggleCallback(Step, StepSize: Integer; Data: Pointer): Boolean; + + procedure CMColorChange(var Message: TMessage); message CM_COLORCHANGED; + procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED; + procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED; + procedure CMDenySubclassing(var Message: TMessage); message CM_DENYSUBCLASSING; + procedure CMDrag(var Message: TCMDrag); message CM_DRAG; + procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW; + procedure CMHintShowPause(var Message: TCMHintShowPause); message CM_HINTSHOWPAUSE; + procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; + procedure CMMouseWheel(var Message: TCMMouseWheel); message CM_MOUSEWHEEL; + procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE; + procedure TVMGetItem(var Message: TMessage); message TVM_GETITEM; + procedure TVMGetItemRect(var Message: TMessage); message TVM_GETITEMRECT; + procedure TVMGetNextItem(var Message: TMessage); message TVM_GETNEXTITEM; + procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE; + procedure WMChangeState(var Message: TMessage); message WM_CHANGESTATE; + procedure WMChar(var Message: TWMChar); message WM_CHAR; + procedure WMContextMenu(var Message: TWMContextMenu); message WM_CONTEXTMENU; + procedure WMCopy(var Message: TWMCopy); message WM_COPY; + procedure WMCut(var Message: TWMCut); message WM_CUT; + procedure WMEnable(var Message: TWMEnable); message WM_ENABLE; + procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND; + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT; + procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL; + procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN; + procedure WMKeyUp(var Message: TWMKeyUp); message WM_KEYUP; + procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS; + procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK; + procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN; + procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP; + procedure WMMButtonDblClk(var Message: TWMMButtonDblClk); message WM_MBUTTONDBLCLK; + procedure WMMButtonDown(var Message: TWMMButtonDown); message WM_MBUTTONDOWN; + procedure WMMButtonUp(var Message: TWMMButtonUp); message WM_MBUTTONUP; + procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE; + procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY; + procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST; + procedure WMNCPaint(var Message: TRealWMNCPaint); message WM_NCPAINT; + procedure WMPaint(var Message: TWMPaint); message WM_PAINT; + procedure WMPaste(var Message: TWMPaste); message WM_PASTE; + procedure WMPrint(var Message: TWMPrint); message WM_PRINT; + procedure WMPrintClient(var Message: TWMPrintClient); message WM_PRINTCLIENT; + procedure WMRButtonDblClk(var Message: TWMRButtonDblClk); message WM_RBUTTONDBLCLK; + procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN; + procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP; + procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR; + procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS; + procedure WMSize(var Message: TWMSize); message WM_SIZE; + procedure WMTimer(var Message: TWMTimer); message WM_TIMER; + procedure WMThemeChanged(var Message: TMessage); message WM_THEMECHANGED; + procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL; + protected + procedure AddToSelection(Node: PVirtualNode); overload; virtual; + procedure AddToSelection(const NewItems: TNodeArray; NewLength: Integer; ForceInsert: Boolean = False); overload; virtual; + procedure AdjustImageBorder(Images: TCustomImageList; BidiMode: TBidiMode; VAlign: Integer; var R: TRect; + var ImageInfo: TVTImageInfo); virtual; + procedure AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); virtual; + procedure AdjustPanningCursor(X, Y: Integer); virtual; + procedure AdviseChangeEvent(StructureChange: Boolean; Node: PVirtualNode; Reason: TChangeReason); virtual; + function AllocateInternalDataArea(Size: Cardinal): Cardinal; virtual; + procedure Animate(Steps, Duration: Cardinal; Callback: TVTAnimationCallback; Data: Pointer); virtual; + function CalculateSelectionRect(X, Y: Integer): Boolean; virtual; + function CanAutoScroll: Boolean; virtual; + function CanShowDragImage: Boolean; virtual; + function CanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex): Boolean; + procedure Change(Node: PVirtualNode); virtual; + procedure ChangeScale(M, D: Integer); override; + function CheckParentCheckState(Node: PVirtualNode; NewCheckState: TCheckState): Boolean; virtual; + procedure ClearTempCache; virtual; + function ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; + function ComputeRTLOffset(ExcludeScrollbar: Boolean = False): Integer; virtual; + function CountLevelDifference(Node1, Node2: PVirtualNode): Integer; virtual; + function CountVisibleChildren(Node: PVirtualNode): Cardinal; virtual; + procedure CreateParams(var Params: TCreateParams); override; + procedure CreateWnd; override; + procedure DefineProperties(Filer: TFiler); override; + function DetermineDropMode(const P: TPoint; var HitInfo: THitInfo; var NodeRect: TRect): TDropMode; virtual; + procedure DetermineHiddenChildrenFlag(Node: PVirtualNode); virtual; + procedure DetermineHiddenChildrenFlagAllNodes; virtual; + procedure DetermineHitPositionLTR(var HitInfo: THitInfo; Offset, Right: Integer; Alignment: TAlignment); virtual; + procedure DetermineHitPositionRTL(var HitInfo: THitInfo; Offset, Right: Integer; Alignment: TAlignment); virtual; + function DetermineLineImageAndSelectLevel(Node: PVirtualNode; var LineImage: TLineImage): Integer; virtual; + function DetermineNextCheckState(CheckType: TCheckType; CheckState: TCheckState): TCheckState; virtual; + function DetermineScrollDirections(X, Y: Integer): TScrollDirections; virtual; + procedure DoAdvancedHeaderDraw(var PaintInfo: THeaderPaintInfo; const Elements: THeaderPaintElements); virtual; + procedure DoAfterCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; CellRect: TRect); virtual; + procedure DoAfterItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); virtual; + procedure DoAfterItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); virtual; + procedure DoAfterPaint(Canvas: TCanvas); virtual; + procedure DoAutoScroll(X, Y: Integer); virtual; + function DoBeforeDrag(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; + procedure DoBeforeCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); virtual; + procedure DoBeforeItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect; var Color: TColor; + var EraseAction: TItemEraseAction); virtual; + function DoBeforeItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect): Boolean; virtual; + procedure DoBeforePaint(Canvas: TCanvas); virtual; + function DoCancelEdit: Boolean; virtual; + procedure DoCanEdit(Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean); virtual; + procedure DoCanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex; + var Allowed: Boolean); virtual; + procedure DoChange(Node: PVirtualNode); virtual; + procedure DoCheckClick(Node: PVirtualNode; NewCheckState: TCheckState); virtual; + procedure DoChecked(Node: PVirtualNode); virtual; + function DoChecking(Node: PVirtualNode; var NewCheckState: TCheckState): Boolean; virtual; + procedure DoCollapsed(Node: PVirtualNode); virtual; + function DoCollapsing(Node: PVirtualNode): Boolean; virtual; + procedure DoColumnClick(Column: TColumnIndex; Shift: TShiftState); virtual; + procedure DoColumnDblClick(Column: TColumnIndex; Shift: TShiftState); virtual; + procedure DoColumnResize(Column: TColumnIndex); virtual; + function DoCompare(Node1, Node2: PVirtualNode; Column: TColumnIndex): Integer; virtual; + function DoCreateDataObject: IDataObject; virtual; + function DoCreateDragManager: IVTDragManager; virtual; + function DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; virtual; + procedure DoDragging(P: TPoint); virtual; + procedure DoDragExpand; virtual; + procedure DoBeforeDrawLineImage(Node: PVirtualNode; Level: Integer; var XPos: Integer); virtual; + function DoDragOver(Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode; + var Effect: Integer): Boolean; virtual; + procedure DoDragDrop(Source: TObject; DataObject: IDataObject; Formats: TFormatArray; Shift: TShiftState; Pt: TPoint; + var Effect: Integer; Mode: TDropMode); virtual; + procedure DoEdit; virtual; + procedure DoEndDrag(Target: TObject; X, Y: Integer); override; + function DoEndEdit: Boolean; virtual; + procedure DoEndOperation(OperationKind: TVTOperationKind); virtual; + procedure DoExpanded(Node: PVirtualNode); virtual; + function DoExpanding(Node: PVirtualNode): Boolean; virtual; + procedure DoFocusChange(Node: PVirtualNode; Column: TColumnIndex); virtual; + function DoFocusChanging(OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex): Boolean; virtual; + procedure DoFocusNode(Node: PVirtualNode; Ask: Boolean); virtual; + procedure DoFreeNode(Node: PVirtualNode); virtual; + function DoGetAnimationType: THintAnimationType; virtual; + function DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex; + CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; virtual; + procedure DoGetCursor(var Cursor: TCursor); virtual; + procedure DoGetHeaderCursor(var Cursor: HCURSOR); virtual; + function DoGetImageIndex(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var Ghosted: Boolean; var Index: Integer): TCustomImageList; virtual; + procedure DoGetImageText(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var ImageText: UnicodeString); virtual; + procedure DoGetLineStyle(var Bits: Pointer); virtual; + function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; virtual; + function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; virtual; + function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; virtual; + function DoGetPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint): TPopupMenu; virtual; + procedure DoGetUserClipboardFormats(var Formats: TFormatEtcArray); virtual; + procedure DoHeaderClick(HitInfo: TVTHeaderHitInfo); virtual; + procedure DoHeaderDblClick(HitInfo: TVTHeaderHitInfo); virtual; + procedure DoHeaderDragged(Column: TColumnIndex; OldPosition: TColumnPosition); virtual; + procedure DoHeaderDraggedOut(Column: TColumnIndex; DropPosition: TPoint); virtual; + function DoHeaderDragging(Column: TColumnIndex): Boolean; virtual; + procedure DoHeaderDraw(Canvas: TCanvas; Column: TVirtualTreeColumn; R: TRect; Hover, Pressed: Boolean; + DropMark: TVTDropMarkMode); virtual; + procedure DoHeaderDrawQueryElements(var PaintInfo: THeaderPaintInfo; var Elements: THeaderPaintElements); virtual; + procedure DoHeaderMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual; + procedure DoHeaderMouseMove(Shift: TShiftState; X, Y: Integer); virtual; + procedure DoHeaderMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual; + procedure DoHotChange(Old, New: PVirtualNode); virtual; + function DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; virtual; + procedure DoInitChildren(Node: PVirtualNode; var ChildCount: Cardinal); virtual; + procedure DoInitNode(Parent, Node: PVirtualNode; var InitStates: TVirtualNodeInitStates); virtual; + function DoKeyAction(var CharCode: Word; var Shift: TShiftState): Boolean; virtual; + procedure DoLoadUserData(Node: PVirtualNode; Stream: TStream); virtual; + procedure DoMeasureItem(TargetCanvas: TCanvas; Node: PVirtualNode; var NodeHeight: Integer); virtual; + procedure DoNodeCopied(Node: PVirtualNode); virtual; + function DoNodeCopying(Node, NewParent: PVirtualNode): Boolean; virtual; + procedure DoNodeClick(const HitInfo: THitInfo); virtual; + procedure DoNodeDblClick(const HitInfo: THitInfo); virtual; + function DoNodeHeightDblClickResize(Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState; + P: TPoint): Boolean; virtual; + function DoNodeHeightTracking(Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState; + var TrackPoint: TPoint; P: TPoint): Boolean; virtual; + procedure DoNodeMoved(Node: PVirtualNode); virtual; + function DoNodeMoving(Node, NewParent: PVirtualNode): Boolean; virtual; + function DoPaintBackground(Canvas: TCanvas; R: TRect): Boolean; virtual; + procedure DoPaintDropMark(Canvas: TCanvas; Node: PVirtualNode; R: TRect); virtual; + procedure DoPaintNode(var PaintInfo: TVTPaintInfo); virtual; + procedure DoPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint); virtual; + function DoRenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; + ForClipboard: Boolean): HRESULT; virtual; + procedure DoReset(Node: PVirtualNode); virtual; + procedure DoSaveUserData(Node: PVirtualNode; Stream: TStream); virtual; + procedure DoScroll(DeltaX, DeltaY: Integer); virtual; + function DoSetOffsetXY(Value: TPoint; Options: TScrollUpdateOptions; ClipRect: PRect = nil): Boolean; virtual; + procedure DoShowScrollbar(Bar: Integer; Show: Boolean); virtual; + procedure DoStartDrag(var DragObject: TDragObject); override; + procedure DoStartOperation(OperationKind: TVTOperationKind); virtual; + procedure DoStateChange(Enter: TVirtualTreeStates; Leave: TVirtualTreeStates = []); virtual; + procedure DoStructureChange(Node: PVirtualNode; Reason: TChangeReason); virtual; + procedure DoTimerScroll; virtual; + procedure DoUpdating(State: TVTUpdateState); virtual; + function DoValidateCache: Boolean; virtual; + procedure DragAndDrop(AllowedEffects: Integer; DataObject: IDataObject; + var DragEffect: Integer); virtual; + procedure DragCanceled; override; + function DragDrop(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; + var Effect: Integer): HResult; reintroduce; virtual; + function DragEnter(KeyState: Integer; Pt: TPoint; var Effect: Integer): HResult; virtual; + procedure DragFinished; virtual; + procedure DragLeave; virtual; + function DragOver(Source: TObject; KeyState: Integer; DragState: TDragState; Pt: TPoint; + var Effect: LongInt): HResult; reintroduce; virtual; + procedure DrawDottedHLine(const PaintInfo: TVTPaintInfo; Left, Right, Top: Integer); virtual; + procedure DrawDottedVLine(const PaintInfo: TVTPaintInfo; Top, Bottom, Left: Integer); virtual; + procedure EndOperation(OperationKind: TVTOperationKind); + function FindNodeInSelection(P: PVirtualNode; var Index: Integer; LowBound, HighBound: Integer): Boolean; virtual; + procedure FinishChunkHeader(Stream: TStream; StartPos, EndPos: Integer); virtual; + procedure FontChanged(AFont: TObject); virtual; + function GetBorderDimensions: TSize; virtual; + function GetCheckImage(Node: PVirtualNode; ImgCheckType: TCheckType = ctNone; + ImgCheckState: TCheckState = csUncheckedNormal; ImgEnabled: Boolean = True): Integer; virtual; + class function GetCheckImageListFor(Kind: TCheckImageKind): TCustomImageList; virtual; + function GetColumnClass: TVirtualTreeColumnClass; virtual; + function GetHeaderClass: TVTHeaderClass; virtual; + function GetHintWindowClass: THintWindowClass; virtual; + procedure GetImageIndex(var Info: TVTPaintInfo; Kind: TVTImageKind; InfoIndex: TVTImageInfoIndex; + DefaultImages: TCustomImageList); virtual; + function GetMaxRightExtend: Cardinal; virtual; + procedure GetNativeClipboardFormats(var Formats: TFormatEtcArray); virtual; + function GetOperationCanceled: Boolean; + function GetOptionsClass: TTreeOptionsClass; virtual; + function GetTreeFromDataObject(const DataObject: IDataObject): TBaseVirtualTree; virtual; + procedure HandleHotTrack(X, Y: Integer); virtual; + procedure HandleIncrementalSearch(CharCode: Word); virtual; + procedure HandleMouseDblClick(var Message: TWMMouse; const HitInfo: THitInfo); virtual; + procedure HandleMouseDown(var Message: TWMMouse; var HitInfo: THitInfo); virtual; + procedure HandleMouseUp(var Message: TWMMouse; const HitInfo: THitInfo); virtual; + function HasImage(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex): Boolean; virtual; + function HasPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Pos: TPoint): Boolean; virtual; + procedure InitChildren(Node: PVirtualNode); virtual; + procedure InitNode(Node: PVirtualNode); virtual; + procedure InternalAddFromStream(Stream: TStream; Version: Integer; Node: PVirtualNode); virtual; + function InternalAddToSelection(Node: PVirtualNode; ForceInsert: Boolean): Boolean; overload; + function InternalAddToSelection(const NewItems: TNodeArray; NewLength: Integer; + ForceInsert: Boolean): Boolean; overload; + procedure InternalCacheNode(Node: PVirtualNode); virtual; + procedure InternalClearSelection; virtual; + procedure InternalConnectNode(Node, Destination: PVirtualNode; Target: TBaseVirtualTree; Mode: TVTNodeAttachMode); virtual; + function InternalData(Node: PVirtualNode): Pointer; + procedure InternalDisconnectNode(Node: PVirtualNode; KeepFocus: Boolean; Reindex: Boolean = True); virtual; + procedure InternalRemoveFromSelection(Node: PVirtualNode); virtual; + procedure InvalidateCache; + procedure Loaded; override; + procedure MainColumnChanged; virtual; + procedure MarkCutCopyNodes; virtual; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure OriginalWMNCPaint(DC: HDC); virtual; + procedure Paint; override; + procedure PaintCheckImage(Canvas: TCanvas; const ImageInfo: TVTImageInfo; Selected: Boolean); virtual; + procedure PaintImage(var PaintInfo: TVTPaintInfo; ImageInfoIndex: TVTImageInfoIndex; DoOverlay: Boolean); virtual; + procedure PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const R: TRect; ButtonX, + ButtonY: Integer; BidiMode: TBiDiMode); virtual; + procedure PaintTreeLines(const PaintInfo: TVTPaintInfo; VAlignment, IndentSize: Integer; + LineImage: TLineImage); virtual; + procedure PaintSelectionRectangle(Target: TCanvas; WindowOrgX: Integer; const SelectionRect: TRect; + TargetRect: TRect); virtual; + procedure PanningWindowProc(var Message: TMessage); virtual; + procedure PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX, MaxWidth: Integer); virtual; + function ReadChunk(Stream: TStream; Version: Integer; Node: PVirtualNode; ChunkType, + ChunkSize: Integer): Boolean; virtual; + procedure ReadNode(Stream: TStream; Version: Integer; Node: PVirtualNode); virtual; + procedure RedirectFontChangeEvent(Canvas: TCanvas); virtual; + procedure RemoveFromSelection(Node: PVirtualNode); virtual; + function RenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; ForClipboard: Boolean): HResult; virtual; + procedure ResetRangeAnchor; virtual; + procedure RestoreFontChangeEvent(Canvas: TCanvas); virtual; + procedure SelectNodes(StartNode, EndNode: PVirtualNode; AddOnly: Boolean); virtual; + procedure SetFocusedNodeAndColumn(Node: PVirtualNode; Column: TColumnIndex); virtual; + procedure SkipNode(Stream: TStream); virtual; + procedure StartOperation(OperationKind: TVTOperationKind); + procedure StartWheelPanning(Position: TPoint); virtual; + procedure StopWheelPanning; virtual; + procedure StructureChange(Node: PVirtualNode; Reason: TChangeReason); virtual; + function SuggestDropEffect(Source: TObject; Shift: TShiftState; Pt: TPoint; AllowedEffects: Integer): Integer; virtual; + procedure ToggleSelection(StartNode, EndNode: PVirtualNode); virtual; + procedure UnselectNodes(StartNode, EndNode: PVirtualNode); virtual; + procedure UpdateColumnCheckState(Col: TVirtualTreeColumn); + procedure UpdateDesigner; virtual; + procedure UpdateEditBounds; virtual; + procedure UpdateHeaderRect; virtual; + procedure UpdateWindowAndDragImage(const Tree: TBaseVirtualTree; TreeRect: TRect; UpdateNCArea, + ReshowDragImage: Boolean); virtual; + procedure ValidateCache; virtual; + procedure ValidateNodeDataSize(var Size: Integer); virtual; + procedure WndProc(var Message: TMessage); override; + procedure WriteChunks(Stream: TStream; Node: PVirtualNode); virtual; + procedure WriteNode(Stream: TStream; Node: PVirtualNode); virtual; + + property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify; + property AnimationDuration: Cardinal read FAnimationDuration write SetAnimationDuration default 200; + property AutoExpandDelay: Cardinal read FAutoExpandDelay write FAutoExpandDelay default 1000; + property AutoScrollDelay: Cardinal read FAutoScrollDelay write FAutoScrollDelay default 1000; + property AutoScrollInterval: TAutoScrollInterval read FAutoScrollInterval write FAutoScrollInterval default 1; + property Background: TPicture read FBackground write SetBackground; + property BackgroundOffsetX: Integer index 0 read FBackgroundOffsetX write SetBackgroundOffset default 0; + property BackgroundOffsetY: Integer index 1 read FBackgroundOffsetY write SetBackgroundOffset default 0; + property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle; + property BottomSpace: Cardinal read FBottomSpace write SetBottomSpace default 0; + property ButtonFillMode: TVTButtonFillMode read FButtonFillMode write SetButtonFillMode default fmTreeColor; + property ButtonStyle: TVTButtonStyle read FButtonStyle write SetButtonStyle default bsRectangle; + property ChangeDelay: Cardinal read FChangeDelay write FChangeDelay default 0; + property CheckImageKind: TCheckImageKind read FCheckImageKind write SetCheckImageKind default ckSystemDefault; + property ClipboardFormats: TClipboardFormats read FClipboardFormats write SetClipboardFormats; + property Colors: TVTColors read FColors write SetColors; + property CustomCheckImages: TCustomImageList read FCustomCheckImages write SetCustomCheckImages; + property DefaultNodeHeight: Cardinal read FDefaultNodeHeight write SetDefaultNodeHeight default 18; + property DefaultPasteMode: TVTNodeAttachMode read FDefaultPasteMode write FDefaultPasteMode default amAddChildLast; + property DragHeight: Integer read FDragHeight write FDragHeight default 350; + property DragImageKind: TVTDragImageKind read FDragImageKind write FDragImageKind default diComplete; + property DragOperations: TDragOperations read FDragOperations write FDragOperations default [doCopy, doMove]; + property DragSelection: TNodeArray read FDragSelection; + property DragType: TVTDragType read FDragType write FDragType default dtOLE; + property DragWidth: Integer read FDragWidth write FDragWidth default 200; + property DrawSelectionMode: TVTDrawSelectionMode read FDrawSelectionMode write FDrawSelectionMode + default smDottedRectangle; + property EditColumn: TColumnIndex read FEditColumn write FEditColumn; + property EditDelay: Cardinal read FEditDelay write FEditDelay default 1000; + property EffectiveOffsetX: Integer read FEffectiveOffsetX; + property Header: TVTHeader read FHeader write SetHeader; + property HeaderRect: TRect read FHeaderRect; + property HintAnimation: THintAnimationType read FAnimationType write FAnimationType default hatSystemDefault; + property HintMode: TVTHintMode read FHintMode write FHintMode default hmDefault; + property HintData: TVTHintData read FHintData write FHintData; + property HotCursor: TCursor read FHotCursor write FHotCursor default crDefault; + property Images: TCustomImageList read FImages write SetImages; + property IncrementalSearch: TVTIncrementalSearch read FIncrementalSearch write SetSearchOption default isNone; + property IncrementalSearchDirection: TVTSearchDirection read FSearchDirection write FSearchDirection default sdForward; + property IncrementalSearchStart: TVTSearchStart read FSearchStart write FSearchStart default ssFocusedNode; + property IncrementalSearchTimeout: Cardinal read FSearchTimeout write FSearchTimeout default 1000; + property Indent: Cardinal read FIndent write SetIndent default 18; + property LastClickPos: TPoint read FLastClickPos write FLastClickPos; + property LastDropMode: TDropMode read FLastDropMode write FlastDropMode; + property LastHintRect: TRect read FLastHintRect write FLastHintRect; + property LineMode: TVTLineMode read FLineMode write SetLineMode default lmNormal; + property LineStyle: TVTLineStyle read FLineStyle write SetLineStyle default lsDotted; + property Margin: Integer read FMargin write SetMargin default 4; + property NodeAlignment: TVTNodeAlignment read FNodeAlignment write SetNodeAlignment default naProportional; + property NodeDataSize: Integer read FNodeDataSize write SetNodeDataSize default -1; + property OperationCanceled: Boolean read GetOperationCanceled; + property HotMinusBM: TBitmap read FHotMinusBM; + property HotPlusBM: TBitmap read FHotPlusBM; + property MinusBM: TBitmap read FMinusBM; + property PlusBM: TBitmap read FPlusBM; + property RangeX: Cardinal read FRangeX; + property RangeY: Cardinal read FRangeY; + property RootNodeCount: Cardinal read GetRootNodeCount write SetRootNodeCount default 0; + property ScrollBarOptions: TScrollBarOptions read FScrollBarOptions write SetScrollBarOptions; + property SelectionBlendFactor: Byte read FSelectionBlendFactor write FSelectionBlendFactor default 128; + property SelectionCurveRadius: Cardinal read FSelectionCurveRadius write SetSelectionCurveRadius default 0; + property StateImages: TCustomImageList read FStateImages write SetStateImages; + property TextMargin: Integer read FTextMargin write SetTextMargin default 4; + property TotalInternalDataSize: Cardinal read FTotalInternalDataSize; + property TreeOptions: TCustomVirtualTreeOptions read FOptions write SetOptions; + property WantTabs: Boolean read FWantTabs write FWantTabs default False; + + property OnAddToSelection: TVTAddToSelectionEvent read FOnAddToSelection write FOnAddToSelection; + property OnAdvancedHeaderDraw: TVTAdvancedHeaderPaintEvent read FOnAdvancedHeaderDraw write FOnAdvancedHeaderDraw; + property OnAfterAutoFitColumn: TVTAfterAutoFitColumnEvent read FOnAfterAutoFitColumn write FOnAfterAutoFitColumn; + property OnAfterAutoFitColumns: TVTAfterAutoFitColumnsEvent read FOnAfterAutoFitColumns write FOnAfterAutoFitColumns; + property OnAfterCellPaint: TVTAfterCellPaintEvent read FOnAfterCellPaint write FOnAfterCellPaint; + property OnAfterColumnExport : TVTColumnExportEvent read FOnAfterColumnExport write FOnAfterColumnExport; + property OnAfterColumnWidthTracking: TVTAfterColumnWidthTrackingEvent read FOnAfterColumnWidthTracking write FOnAfterColumnWidthTracking; + property OnAfterGetMaxColumnWidth: TVTAfterGetMaxColumnWidthEvent read FOnAfterGetMaxColumnWidth write FOnAfterGetMaxColumnWidth; + property OnAfterHeaderExport: TVTTreeExportEvent read FOnBeforeHeaderExport write FOnBeforeHeaderExport; + property OnAfterHeaderHeightTracking: TVTAfterHeaderHeightTrackingEvent read FOnAfterHeaderHeightTracking + write FOnAfterHeaderHeightTracking; + property OnAfterItemErase: TVTAfterItemEraseEvent read FOnAfterItemErase write FOnAfterItemErase; + property OnAfterItemPaint: TVTAfterItemPaintEvent read FOnAfterItemPaint write FOnAfterItemPaint; + property OnAfterNodeExport: TVTNodeExportEvent read FOnAfterNodeExport write FOnAfterNodeExport; + property OnAfterPaint: TVTPaintEvent read FOnAfterPaint write FOnAfterPaint; + property OnAfterTreeExport: TVTTreeExportEvent read FOnAfterTreeExport write FOnAfterTreeExport; + property OnBeforeAutoFitColumn: TVTBeforeAutoFitColumnEvent read FOnBeforeAutoFitColumn write FOnBeforeAutoFitColumn; + property OnBeforeAutoFitColumns: TVTBeforeAutoFitColumnsEvent read FOnBeforeAutoFitColumns write FOnBeforeAutoFitColumns; + property OnBeforeCellPaint: TVTBeforeCellPaintEvent read FOnBeforeCellPaint write FOnBeforeCellPaint; + property OnBeforeColumnExport: TVTColumnExportEvent read FOnBeforeColumnExport write FOnBeforeColumnExport; + property OnBeforeColumnWidthTracking: TVTBeforeColumnWidthTrackingEvent read FOnBeforeColumnWidthTracking + write FOnBeforeColumnWidthTracking; + property OnBeforeDrawTreeLine: TVTBeforeDrawLineImageEvent read FOnBeforeDrawLineImage write FOnBeforeDrawLineImage; + property OnBeforeGetMaxColumnWidth: TVTBeforeGetMaxColumnWidthEvent read FOnBeforeGetMaxColumnWidth write FOnBeforeGetMaxColumnWidth; + property OnBeforeHeaderExport: TVTTreeExportEvent read FOnBeforeHeaderExport write FOnBeforeHeaderExport; + property OnBeforeHeaderHeightTracking: TVTBeforeHeaderHeightTrackingEvent read FOnBeforeHeaderHeightTracking + write FOnBeforeHeaderHeightTracking; + property OnBeforeItemErase: TVTBeforeItemEraseEvent read FOnBeforeItemErase write FOnBeforeItemErase; + property OnBeforeItemPaint: TVTBeforeItemPaintEvent read FOnBeforeItemPaint write FOnBeforeItemPaint; + property OnBeforeNodeExport: TVTNodeExportEvent read FOnBeforeNodeExport write FOnBeforeNodeExport; + property OnBeforePaint: TVTPaintEvent read FOnBeforePaint write FOnBeforePaint; + property OnBeforeTreeExport: TVTTreeExportEvent read FOnBeforeTreeExport write FOnBeforeTreeExport; + property OnCanSplitterResizeColumn: TVTCanSplitterResizeColumnEvent read FOnCanSplitterResizeColumn write FOnCanSplitterResizeColumn; + property OnCanSplitterResizeHeader: TVTCanSplitterResizeHeaderEvent read FOnCanSplitterResizeHeader write FOnCanSplitterResizeHeader; + property OnCanSplitterResizeNode: TVTCanSplitterResizeNodeEvent read FOnCanSplitterResizeNode write FOnCanSplitterResizeNode; + property OnChange: TVTChangeEvent read FOnChange write FOnChange; + property OnChecked: TVTChangeEvent read FOnChecked write FOnChecked; + property OnChecking: TVTCheckChangingEvent read FOnChecking write FOnChecking; + property OnCollapsed: TVTChangeEvent read FOnCollapsed write FOnCollapsed; + property OnCollapsing: TVTChangingEvent read FOnCollapsing write FOnCollapsing; + property OnColumnClick: TVTColumnClickEvent read FOnColumnClick write FOnColumnClick; + property OnColumnDblClick: TVTColumnDblClickEvent read FOnColumnDblClick write FOnColumnDblClick; + property OnColumnExport : TVTColumnExportEvent read FOnColumnExport write FOnColumnExport; + property OnColumnResize: TVTHeaderNotifyEvent read FOnColumnResize write FOnColumnResize; + property OnColumnWidthDblClickResize: TVTColumnWidthDblClickResizeEvent read FOnColumnWidthDblClickResize + write FOnColumnWidthDblClickResize; + property OnColumnWidthTracking: TVTColumnWidthTrackingEvent read FOnColumnWidthTracking write FOnColumnWidthTracking; + property OnCompareNodes: TVTCompareEvent read FOnCompareNodes write FOnCompareNodes; + property OnCreateDataObject: TVTCreateDataObjectEvent read FOnCreateDataObject write FOnCreateDataObject; + property OnCreateDragManager: TVTCreateDragManagerEvent read FOnCreateDragManager write FOnCreateDragManager; + property OnCreateEditor: TVTCreateEditorEvent read FOnCreateEditor write FOnCreateEditor; + property OnDragAllowed: TVTDragAllowedEvent read FOnDragAllowed write FOnDragAllowed; + property OnDragOver: TVTDragOverEvent read FOnDragOver write FOnDragOver; + property OnDragDrop: TVTDragDropEvent read FOnDragDrop write FOnDragDrop; + property OnEditCancelled: TVTEditCancelEvent read FOnEditCancelled write FOnEditCancelled; + property OnEditing: TVTEditChangingEvent read FOnEditing write FOnEditing; + property OnEdited: TVTEditChangeEvent read FOnEdited write FOnEdited; + property OnEndOperation: TVTOperationEvent read FOnEndOperation write FOnEndOperation; + property OnExpanded: TVTChangeEvent read FOnExpanded write FOnExpanded; + property OnExpanding: TVTChangingEvent read FOnExpanding write FOnExpanding; + property OnFocusChanged: TVTFocusChangeEvent read FOnFocusChanged write FOnFocusChanged; + property OnFocusChanging: TVTFocusChangingEvent read FOnFocusChanging write FOnFocusChanging; + property OnFreeNode: TVTFreeNodeEvent read FOnFreeNode write FOnFreeNode; + property OnGetCellIsEmpty: TVTGetCellIsEmptyEvent read FOnGetCellIsEmpty write FOnGetCellIsEmpty; + property OnGetCursor: TVTGetCursorEvent read FOnGetCursor write FOnGetCursor; + property OnGetHeaderCursor: TVTGetHeaderCursorEvent read FOnGetHeaderCursor write FOnGetHeaderCursor; + property OnGetHelpContext: TVTHelpContextEvent read FOnGetHelpContext write FOnGetHelpContext; + property OnGetImageIndex: TVTGetImageEvent read FOnGetImage write FOnGetImage; + property OnGetImageIndexEx: TVTGetImageExEvent read FOnGetImageEx write FOnGetImageEx; + property OnGetImageText: TVTGetImageTextEvent read FOnGetImageText write FOnGetImageText; + property OnGetLineStyle: TVTGetLineStyleEvent read FOnGetLineStyle write FOnGetLineStyle; + property OnGetNodeDataSize: TVTGetNodeDataSizeEvent read FOnGetNodeDataSize write FOnGetNodeDataSize; + property OnGetPopupMenu: TVTPopupEvent read FOnGetPopupMenu write FOnGetPopupMenu; + property OnGetUserClipboardFormats: TVTGetUserClipboardFormatsEvent read FOnGetUserClipboardFormats + write FOnGetUserClipboardFormats; + property OnHeaderClick: TVTHeaderClickEvent read FOnHeaderClick write FOnHeaderClick; + property OnHeaderDblClick: TVTHeaderClickEvent read FOnHeaderDblClick write FOnHeaderDblClick; + property OnHeaderDragged: TVTHeaderDraggedEvent read FOnHeaderDragged write FOnHeaderDragged; + property OnHeaderDraggedOut: TVTHeaderDraggedOutEvent read FOnHeaderDraggedOut write FOnHeaderDraggedOut; + property OnHeaderDragging: TVTHeaderDraggingEvent read FOnHeaderDragging write FOnHeaderDragging; + property OnHeaderDraw: TVTHeaderPaintEvent read FOnHeaderDraw write FOnHeaderDraw; + property OnHeaderDrawQueryElements: TVTHeaderPaintQueryElementsEvent read FOnHeaderDrawQueryElements + write FOnHeaderDrawQueryElements; + property OnHeaderHeightTracking: TVTHeaderHeightTrackingEvent read FOnHeaderHeightTracking + write FOnHeaderHeightTracking; + property OnHeaderHeightDblClickResize: TVTHeaderHeightDblClickResizeEvent read FOnHeaderHeightDblClickResize + write FOnHeaderHeightDblClickResize; + property OnHeaderMouseDown: TVTHeaderMouseEvent read FOnHeaderMouseDown write FOnHeaderMouseDown; + property OnHeaderMouseMove: TVTHeaderMouseMoveEvent read FOnHeaderMouseMove write FOnHeaderMouseMove; + property OnHeaderMouseUp: TVTHeaderMouseEvent read FOnHeaderMouseUp write FOnHeaderMouseUp; + property OnHotChange: TVTHotNodeChangeEvent read FOnHotChange write FOnHotChange; + property OnIncrementalSearch: TVTIncrementalSearchEvent read FOnIncrementalSearch write FOnIncrementalSearch; + property OnInitChildren: TVTInitChildrenEvent read FOnInitChildren write FOnInitChildren; + property OnInitNode: TVTInitNodeEvent read FOnInitNode write FOnInitNode; + property OnKeyAction: TVTKeyActionEvent read FOnKeyAction write FOnKeyAction; + property OnLoadNode: TVTSaveNodeEvent read FOnLoadNode write FOnLoadNode; + property OnLoadTree: TVTSaveTreeEvent read FOnLoadTree write FOnLoadTree; + property OnMeasureItem: TVTMeasureItemEvent read FOnMeasureItem write FOnMeasureItem; + property OnNodeClick: TVTNodeClickEvent read FOnNodeClick write FOnNodeClick; + property OnNodeCopied: TVTNodeCopiedEvent read FOnNodeCopied write FOnNodeCopied; + property OnNodeCopying: TVTNodeCopyingEvent read FOnNodeCopying write FOnNodeCopying; + property OnNodeDblClick: TVTNodeClickEvent read FOnNodeDblClick write FOnNodeDblClick; + property OnNodeExport: TVTNodeExportEvent read FOnNodeExport write FOnNodeExport; + property OnNodeHeightTracking: TVTNodeHeightTrackingEvent read FOnNodeHeightTracking write FOnNodeHeightTracking; + property OnNodeHeightDblClickResize: TVTNodeHeightDblClickResizeEvent read FOnNodeHeightDblClickResize + write FOnNodeHeightDblClickResize; + property OnNodeMoved: TVTNodeMovedEvent read FOnNodeMoved write FOnNodeMoved; + property OnNodeMoving: TVTNodeMovingEvent read FOnNodeMoving write FOnNodeMoving; + property OnPaintBackground: TVTBackgroundPaintEvent read FOnPaintBackground write FOnPaintBackground; + property OnRemoveFromSelection: TVTRemoveFromSelectionEvent read FOnRemoveFromSelection write FOnRemoveFromSelection; + property OnRenderOLEData: TVTRenderOLEDataEvent read FOnRenderOLEData write FOnRenderOLEData; + property OnResetNode: TVTChangeEvent read FOnResetNode write FOnResetNode; + property OnSaveNode: TVTSaveNodeEvent read FOnSaveNode write FOnSaveNode; + property OnSaveTree: TVTSaveTreeEvent read FOnSaveTree write FOnSaveTree; + property OnScroll: TVTScrollEvent read FOnScroll write FOnScroll; + property OnShowScrollbar: TVTScrollbarShowEvent read FOnShowScrollbar write FOnShowScrollbar; + property OnStartOperation: TVTOperationEvent read FOnStartOperation write FOnStartOperation; + property OnStateChange: TVTStateChangeEvent read FOnStateChange write FOnStateChange; + property OnStructureChange: TVTStructureChangeEvent read FOnStructureChange write FOnStructureChange; + property OnUpdating: TVTUpdatingEvent read FOnUpdating write FOnUpdating; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + function AbsoluteIndex(Node: PVirtualNode): Cardinal; + function AddChild(Parent: PVirtualNode; UserData: Pointer = nil): PVirtualNode; virtual; + procedure AddFromStream(Stream: TStream; TargetNode: PVirtualNode); + procedure AfterConstruction; override; + procedure Assign(Source: TPersistent); override; + procedure BeginDrag(Immediate: Boolean; Threshold: Integer = -1); + procedure BeginSynch; + procedure BeginUpdate; virtual; + procedure CancelCutOrCopy; + function CancelEditNode: Boolean; + procedure CancelOperation; + function CanEdit(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; + function CanFocus: Boolean; override; + procedure Clear; virtual; + procedure ClearChecked; + procedure ClearSelection; + function CopyTo(Source: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean): PVirtualNode; overload; + function CopyTo(Source, Target: PVirtualNode; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean): PVirtualNode; overload; + procedure CopyToClipBoard; virtual; + procedure CutToClipBoard; virtual; + procedure DeleteChildren(Node: PVirtualNode; ResetHasChildren: Boolean = False); + procedure DeleteNode(Node: PVirtualNode; Reindex: Boolean = True); + procedure DeleteSelectedNodes; virtual; + function Dragging: Boolean; + function EditNode(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; + function EndEditNode: Boolean; + procedure EndSynch; + procedure EndUpdate; virtual; + function ExecuteAction(Action: TBasicAction): Boolean; override; + procedure FinishCutOrCopy; + procedure FlushClipboard; + procedure FullCollapse(Node: PVirtualNode = nil); virtual; + procedure FullExpand(Node: PVirtualNode = nil); virtual; + function GetControlsAlignment: TAlignment; override; + function GetDisplayRect(Node: PVirtualNode; Column: TColumnIndex; TextOnly: Boolean; Unclipped: Boolean = False; + ApplyCellContentMargin: Boolean = False): TRect; + function GetEffectivelyFiltered(Node: PVirtualNode): Boolean; + function GetEffectivelyVisible(Node: PVirtualNode): Boolean; + function GetFirst(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstChecked(State: TCheckState = csCheckedNormal; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstChild(Node: PVirtualNode): PVirtualNode; + function GetFirstCutCopy(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstInitialized(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstLeaf: PVirtualNode; + function GetFirstLevel(NodeLevel: Cardinal): PVirtualNode; + function GetFirstNoInit(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstSelected(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + function GetFirstVisibleChild(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetFirstVisibleChildNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetFirstVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + procedure GetHitTestInfoAt(X, Y: Integer; Relative: Boolean; var HitInfo: THitInfo); virtual; + function GetLast(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetLastInitialized(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetLastNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetLastChild(Node: PVirtualNode): PVirtualNode; + function GetLastChildNoInit(Node: PVirtualNode): PVirtualNode; + function GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + function GetLastVisibleChild(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetLastVisibleChildNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetLastVisibleNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + function GetMaxColumnWidth(Column: TColumnIndex; UseSmartColumnWidth: Boolean = False): Integer; virtual; + function GetNext(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetNextChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; overload; + function GetNextChecked(Node: PVirtualNode; ConsiderChildrenAbove: Boolean): PVirtualNode; overload; + function GetNextCutCopy(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetNextInitialized(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetNextLeaf(Node: PVirtualNode): PVirtualNode; + function GetNextLevel(Node: PVirtualNode; NodeLevel: Cardinal): PVirtualNode; + function GetNextNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetNextSelected(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetNextSibling(Node: PVirtualNode): PVirtualNode; + function GetNextVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + function GetNextVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + function GetNextVisibleSibling(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetNextVisibleSiblingNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetNodeAt(X, Y: Integer): PVirtualNode; overload; + function GetNodeAt(X, Y: Integer; Relative: Boolean; var NodeTop: Integer): PVirtualNode; overload; + function GetNodeData(Node: PVirtualNode): Pointer; + function GetNodeLevel(Node: PVirtualNode): Cardinal; + function GetPrevious(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousCutCopy(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousInitialized(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousLeaf(Node: PVirtualNode): PVirtualNode; + function GetPreviousLevel(Node: PVirtualNode; NodeLevel: Cardinal): PVirtualNode; + function GetPreviousNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousSelected(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + function GetPreviousSibling(Node: PVirtualNode): PVirtualNode; + function GetPreviousVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + function GetPreviousVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + function GetPreviousVisibleSibling(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetPreviousVisibleSiblingNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function GetSortedCutCopySet(Resolve: Boolean): TNodeArray; + function GetSortedSelection(Resolve: Boolean): TNodeArray; + procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; + var Text: UnicodeString); virtual; + function GetTreeRect: TRect; + function GetVisibleParent(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + function HasAsParent(Node, PotentialParent: PVirtualNode): Boolean; + function InsertNode(Node: PVirtualNode; Mode: TVTNodeAttachMode; UserData: Pointer = nil): PVirtualNode; + procedure InvalidateChildren(Node: PVirtualNode; Recursive: Boolean); + procedure InvalidateColumn(Column: TColumnIndex); + function InvalidateNode(Node: PVirtualNode): TRect; virtual; + procedure InvalidateToBottom(Node: PVirtualNode); + procedure InvertSelection(VisibleOnly: Boolean); + function IsEditing: Boolean; + function IsMouseSelecting: Boolean; + function IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer; Filter: TVirtualNodeStates = []; + DoInit: Boolean = False; ChildNodesOnly: Boolean = False): PVirtualNode; + procedure LoadFromFile(const FileName: TFileName); virtual; + procedure LoadFromStream(Stream: TStream); virtual; + procedure MeasureItemHeight(const Canvas: TCanvas; Node: PVirtualNode); + procedure MoveTo(Source, Target: PVirtualNode; Mode: TVTNodeAttachMode; ChildrenOnly: Boolean); overload; + procedure MoveTo(Node: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean); overload; + procedure PaintTree(TargetCanvas: TCanvas; Window: TRect; Target: TPoint; PaintOptions: TVTInternalPaintOptions; + PixelFormat: TPixelFormat = pfDevice); virtual; + function PasteFromClipboard: Boolean; virtual; + procedure PrepareDragImage(HotSpot: TPoint; const DataObject: IDataObject); + procedure Print(Printer: TPrinter; PrintHeader: Boolean); + function ProcessDrop(DataObject: IDataObject; TargetNode: PVirtualNode; var Effect: Integer; Mode: + TVTNodeAttachMode): Boolean; + function ProcessOLEData(Source: TBaseVirtualTree; DataObject: IDataObject; TargetNode: PVirtualNode; + Mode: TVTNodeAttachMode; Optimized: Boolean): Boolean; + procedure RepaintNode(Node: PVirtualNode); + procedure ReinitChildren(Node: PVirtualNode; Recursive: Boolean); virtual; + procedure ReinitNode(Node: PVirtualNode; Recursive: Boolean); virtual; + procedure ResetNode(Node: PVirtualNode); virtual; + procedure SaveToFile(const FileName: TFileName); + procedure SaveToStream(Stream: TStream; Node: PVirtualNode = nil); virtual; + function ScrollIntoView(Node: PVirtualNode; Center: Boolean; Horizontally: Boolean = False): Boolean; overload; + function ScrollIntoView(Column: TColumnIndex; Center: Boolean): Boolean; overload; + procedure SelectAll(VisibleOnly: Boolean); + procedure Sort(Node: PVirtualNode; Column: TColumnIndex; Direction: TSortDirection; DoInit: Boolean = True); virtual; + procedure SortTree(Column: TColumnIndex; Direction: TSortDirection; DoInit: Boolean = True); virtual; + procedure ToggleNode(Node: PVirtualNode); + function UpdateAction(Action: TBasicAction): Boolean; override; + procedure UpdateHorizontalRange; + procedure UpdateHorizontalScrollBar(DoRepaint: Boolean); + procedure UpdateRanges; + procedure UpdateScrollBars(DoRepaint: Boolean); virtual; + procedure UpdateVerticalRange; + procedure UpdateVerticalScrollBar(DoRepaint: Boolean); + function UseRightToLeftReading: Boolean; + procedure ValidateChildren(Node: PVirtualNode; Recursive: Boolean); + procedure ValidateNode(Node: PVirtualNode; Recursive: Boolean); + + { Enumerations } + function Nodes(ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function CheckedNodes(State: TCheckState = csCheckedNormal; ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function ChildNodes(Node: PVirtualNode): TVTVirtualNodeEnumeration; + function CutCopyNodes(ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function InitializedNodes(ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function LeafNodes: TVTVirtualNodeEnumeration; + function LevelNodes(NodeLevel: Cardinal): TVTVirtualNodeEnumeration; + function NoInitNodes(ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function SelectedNodes(ConsiderChildrenAbove: Boolean = False): TVTVirtualNodeEnumeration; + function VisibleNodes(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): TVTVirtualNodeEnumeration; + function VisibleChildNodes(Node: PVirtualNode; IncludeFiltered: Boolean = False): TVTVirtualNodeEnumeration; + function VisibleChildNoInitNodes(Node: PVirtualNode; IncludeFiltered: Boolean = False): TVTVirtualNodeEnumeration; + function VisibleNoInitNodes(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): TVTVirtualNodeEnumeration; + + property Accessible: IAccessible read FAccessible write FAccessible; + property AccessibleItem: IAccessible read FAccessibleItem write FAccessibleItem; + property AccessibleName: string read FAccessibleName write FAccessibleName; + property BottomNode: PVirtualNode read GetBottomNode write SetBottomNode; + property CheckedCount: Integer read GetCheckedCount; + property CheckImages: TCustomImageList read FCheckImages; + property CheckState[Node: PVirtualNode]: TCheckState read GetCheckState write SetCheckState; + property CheckType[Node: PVirtualNode]: TCheckType read GetCheckType write SetCheckType; + property ChildCount[Node: PVirtualNode]: Cardinal read GetChildCount write SetChildCount; + property ChildrenInitialized[Node: PVirtualNode]: Boolean read GetChildrenInitialized; + property CutCopyCount: Integer read GetCutCopyCount; + property DragImage: TVTDragImage read FDragImage; + property DragManager: IVTDragManager read GetDragManager; + property DropTargetNode: PVirtualNode read FDropTargetNode; + property EditLink: IVTEditLink read FEditLink; + property EmptyListMessage: UnicodeString read FEmptyListMessage write SetEmptyListMessage; + property Expanded[Node: PVirtualNode]: Boolean read GetExpanded write SetExpanded; + property FocusedColumn: TColumnIndex read FFocusedColumn write SetFocusedColumn default InvalidColumn; + property FocusedNode: PVirtualNode read FFocusedNode write SetFocusedNode; + property Font; + property FullyVisible[Node: PVirtualNode]: Boolean read GetFullyVisible write SetFullyVisible; + property HasChildren[Node: PVirtualNode]: Boolean read GetHasChildren write SetHasChildren; + property HotNode: PVirtualNode read FCurrentHotNode; + property IsDisabled[Node: PVirtualNode]: Boolean read GetDisabled write SetDisabled; + property IsEffectivelyFiltered[Node: PVirtualNode]: Boolean read GetEffectivelyFiltered; + property IsEffectivelyVisible[Node: PVirtualNode]: Boolean read GetEffectivelyVisible; + property IsFiltered[Node: PVirtualNode]: Boolean read GetFiltered write SetFiltered; + property IsVisible[Node: PVirtualNode]: Boolean read GetVisible write SetVisible; + property MultiLine[Node: PVirtualNode]: Boolean read GetMultiline write SetMultiline; + property NodeHeight[Node: PVirtualNode]: Cardinal read GetNodeHeight write SetNodeHeight; + property NodeParent[Node: PVirtualNode]: PVirtualNode read GetNodeParent write SetNodeParent; + property OffsetX: Integer read FOffsetX write SetOffsetX; + property OffsetXY: TPoint read GetOffsetXY write SetOffsetXY; + property OffsetY: Integer read FOffsetY write SetOffsetY; + property OperationCount: Cardinal read FOperationCount; + property RootNode: PVirtualNode read FRoot; + property SearchBuffer: UnicodeString read FSearchBuffer; + property Selected[Node: PVirtualNode]: Boolean read GetSelected write SetSelected; + property SelectionLocked: Boolean read FSelectionLocked write FSelectionLocked; + property TotalCount: Cardinal read GetTotalCount; + property TreeStates: TVirtualTreeStates read FStates write FStates; + property SelectedCount: Integer read FSelectionCount; + property TopNode: PVirtualNode read GetTopNode write SetTopNode; + property VerticalAlignment[Node: PVirtualNode]: Byte read GetVerticalAlignment write SetVerticalAlignment; + property VisibleCount: Cardinal read FVisibleCount; + property VisiblePath[Node: PVirtualNode]: Boolean read GetVisiblePath write SetVisiblePath; + property UpdateCount: Cardinal read FUpdateCount; + end; + + + // --------- TCustomVirtualStringTree + + // Options regarding strings (useful only for the string tree and descendants): + TVTStringOption = ( + toSaveCaptions, // If set then the caption is automatically saved with the tree node, regardless of what is + // saved in the user data. + toShowStaticText, // Show static text in a caption which can be differently formatted than the caption + // but cannot be edited. + toAutoAcceptEditChange // Automatically accept changes during edit if the user finishes editing other then + // VK_RETURN or ESC. If not set then changes are cancelled. + ); + TVTStringOptions = set of TVTStringOption; + +const + DefaultStringOptions = [toSaveCaptions, toAutoAcceptEditChange]; + +type + TCustomStringTreeOptions = class(TCustomVirtualTreeOptions) + private + FStringOptions: TVTStringOptions; + procedure SetStringOptions(const Value: TVTStringOptions); + protected + property StringOptions: TVTStringOptions read FStringOptions write SetStringOptions default DefaultStringOptions; + public + constructor Create(AOwner: TBaseVirtualTree); override; + + procedure AssignTo(Dest: TPersistent); override; + end; + + TStringTreeOptions = class(TCustomStringTreeOptions) + published + property AnimationOptions; + property AutoOptions; + property ExportMode; + property MiscOptions; + property PaintOptions; + property SelectionOptions; + property StringOptions; + end; + + TCustomVirtualStringTree = class; + + // Edit support classes. + TStringEditLink = class; + + {$ifdef TntSupport} + TVTEdit = class(TTntEdit) + {$else} + TVTEdit = class(TCustomEdit) + {$endif TntSupport} + private + procedure CMAutoAdjust(var Message: TMessage); message CM_AUTOADJUST; + procedure CMExit(var Message: TMessage); message CM_EXIT; + procedure CMRelease(var Message: TMessage); message CM_RELEASE; + procedure CNCommand(var Message: TWMCommand); message CN_COMMAND; + procedure WMChar(var Message: TWMChar); message WM_CHAR; + procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY; + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN; + protected + FRefLink: IVTEditLink; + FLink: TStringEditLink; + procedure AutoAdjustSize; virtual; + procedure CreateParams(var Params: TCreateParams); override; + public + constructor Create(Link: TStringEditLink); reintroduce; + + procedure Release; virtual; + + property AutoSelect; + property AutoSize; + property BorderStyle; + property CharCase; + property HideSelection; + property MaxLength; + property OEMConvert; + property PasswordChar; + end; + + TStringEditLink = class(TInterfacedObject, IVTEditLink) + private + FEdit: TVTEdit; // A normal custom edit control. + procedure SetEdit(const Value: TVTEdit); + protected + FTree: TCustomVirtualStringTree; // A back reference to the tree calling. + FNode: PVirtualNode; // The node to be edited. + FColumn: TColumnIndex; // The column of the node. + FAlignment: TAlignment; + FTextBounds: TRect; // Smallest rectangle around the text. + FStopping: Boolean; // Set to True when the edit link requests stopping the edit action. + public + constructor Create; virtual; + destructor Destroy; override; + + function BeginEdit: Boolean; virtual; stdcall; + function CancelEdit: Boolean; virtual; stdcall; + property Edit: TVTEdit read FEdit write SetEdit; + function EndEdit: Boolean; virtual; stdcall; + function GetBounds: TRect; virtual; stdcall; + function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; stdcall; + procedure ProcessMessage(var Message: TMessage); virtual; stdcall; + procedure SetBounds(R: TRect); virtual; stdcall; + end; + + // Describes the type of text to return in the text and draw info retrival events. + TVSTTextType = ( + ttNormal, // normal label of the node, this is also the text which can be edited + ttStatic // static (non-editable) text after the normal text + ); + + // Describes the source to use when converting a string tree into a string for clipboard etc. + TVSTTextSourceType = ( + tstAll, // All nodes are rendered. Initialization is done on the fly. + tstInitialized, // Only initialized nodes are rendered. + tstSelected, // Only selected nodes are rendered. + tstCutCopySet, // Only nodes currently marked as being in the cut/copy clipboard set are rendered. + tstVisible, // Only visible nodes are rendered. + tstChecked // Only checked nodes are rendered + ); + + TVTPaintText = procedure(Sender: TBaseVirtualTree; const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + TextType: TVSTTextType) of object; + TVSTGetTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + TextType: TVSTTextType; var CellText: UnicodeString) of object; + TVSTGetHintEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: UnicodeString) of object; + // New text can only be set for variable caption. + TVSTNewTextEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + NewText: UnicodeString) of object; + TVSTShortenStringEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; const S: UnicodeString; TextSpace: Integer; var Result: UnicodeString; + var Done: Boolean) of object; + TVTMeasureTextEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; const Text: UnicodeString; var Extent: Integer) of object; + TVTDrawTextEvent = procedure(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; const Text: UnicodeString; const CellRect: TRect; var DefaultDraw: Boolean) of object; + + TCustomVirtualStringTree = class(TBaseVirtualTree) + private + FDefaultText: UnicodeString; // text to show if there's no OnGetText event handler (e.g. at design time) + FTextHeight: Integer; // true size of the font + FEllipsisWidth: Integer; // width of '...' for the current font + FInternalDataOffset: Cardinal; // offset to the internal data of the string tree + + FOnPaintText: TVTPaintText; // triggered before either normal or fixed text is painted to allow + // even finer customization (kind of sub cell painting) + FOnGetText: TVSTGetTextEvent; // used to retrieve the string to be displayed for a specific node + FOnGetHint: TVSTGetHintEvent; // used to retrieve the hint to be displayed for a specific node + FOnNewText: TVSTNewTextEvent; // used to notify the application about an edited node caption + FOnShortenString: TVSTShortenStringEvent; // used to allow the application a customized string shortage + FOnMeasureTextWidth: TVTMeasureTextEvent; // used to adjust the width of the cells + FOnMeasureTextHeight: TVTMeasureTextEvent; + FOnDrawText: TVTDrawTextEvent; // used to custom draw the node text + + function GetImageText(Node: PVirtualNode; Kind: TVTImageKind; + Column: TColumnIndex): UnicodeString; + procedure GetRenderStartValues(Source: TVSTTextSourceType; var Node: PVirtualNode; + var NextNodeProc: TGetNextNodeProc); + function GetOptions: TCustomStringTreeOptions; + function GetText(Node: PVirtualNode; Column: TColumnIndex): UnicodeString; + procedure InitializeTextProperties(var PaintInfo: TVTPaintInfo); + procedure PaintNormalText(var PaintInfo: TVTPaintInfo; TextOutFlags: Integer; Text: UnicodeString); + procedure PaintStaticText(const PaintInfo: TVTPaintInfo; TextOutFlags: Integer; const Text: UnicodeString); + procedure ReadText(Reader: TReader); + procedure SetDefaultText(const Value: UnicodeString); + procedure SetOptions(const Value: TCustomStringTreeOptions); + procedure SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: UnicodeString); + procedure WriteText(Writer: TWriter); + + procedure WMSetFont(var Msg: TWMSetFont); message WM_SETFONT; + procedure GetDataFromGrid(const AStrings : TStringList; const IncludeHeading : Boolean=True); + protected + procedure AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); override; + function CanExportNode(Node: PVirtualNode): Boolean; + function CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; Text: UnicodeString): Integer; virtual; + function ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; override; + procedure DefineProperties(Filer: TFiler); override; + function DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; override; + function DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; override; + function DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; override; + function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; override; + procedure DoGetText(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; + var Text: UnicodeString); virtual; + function DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; override; + procedure DoNewText(Node: PVirtualNode; Column: TColumnIndex; Text: UnicodeString); virtual; + procedure DoPaintNode(var PaintInfo: TVTPaintInfo); override; + procedure DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; + TextType: TVSTTextType); virtual; + function DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const S: UnicodeString; Width: Integer; + EllipsisWidth: Integer = 0): UnicodeString; virtual; + procedure DoTextDrawing(var PaintInfo: TVTPaintInfo; Text: UnicodeString; CellRect: TRect; DrawFormat: Cardinal); virtual; + function DoTextMeasuring(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; Text: UnicodeString): TSize; virtual; + function GetOptionsClass: TTreeOptionsClass; override; + function InternalData(Node: PVirtualNode): Pointer; + procedure MainColumnChanged; override; + function ReadChunk(Stream: TStream; Version: Integer; Node: PVirtualNode; ChunkType, + ChunkSize: Integer): Boolean; override; + procedure ReadOldStringOptions(Reader: TReader); + function RenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; ForClipboard: Boolean): HResult; override; + procedure WriteChunks(Stream: TStream; Node: PVirtualNode); override; + + property DefaultText: UnicodeString read FDefaultText write SetDefaultText stored False; + property EllipsisWidth: Integer read FEllipsisWidth; + property TreeOptions: TCustomStringTreeOptions read GetOptions write SetOptions; + + property OnGetHint: TVSTGetHintEvent read FOnGetHint write FOnGetHint; + property OnGetText: TVSTGetTextEvent read FOnGetText write FOnGetText; + property OnNewText: TVSTNewTextEvent read FOnNewText write FOnNewText; + property OnPaintText: TVTPaintText read FOnPaintText write FOnPaintText; + property OnShortenString: TVSTShortenStringEvent read FOnShortenString write FOnShortenString; + property OnMeasureTextWidth: TVTMeasureTextEvent read FOnMeasureTextWidth write FOnMeasureTextWidth; + property OnMeasureTextHeight: TVTMeasureTextEvent read FOnMeasureTextHeight write FOnMeasureTextHeight; + property OnDrawText: TVTDrawTextEvent read FOnDrawText write FOnDrawText; + public + constructor Create(AOwner: TComponent); override; + + function ComputeNodeHeight(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; S: UnicodeString = ''): Integer; virtual; + function ContentToClipboard(Format: Word; Source: TVSTTextSourceType): HGLOBAL; + procedure ContentToCustom(Source: TVSTTextSourceType); + function ContentToHTML(Source: TVSTTextSourceType; Caption: UnicodeString = ''): AnsiString; + function ContentToRTF(Source: TVSTTextSourceType): AnsiString; + function ContentToText(Source: TVSTTextSourceType; Separator: AnsiChar): AnsiString; overload; + function ContentToText(Source: TVSTTextSourceType; const Separator: AnsiString): AnsiString; overload; + function ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): UnicodeString; overload; + function ContentToUnicode(Source: TVSTTextSourceType; const Separator: UnicodeString): UnicodeString; overload; + procedure GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; + var Text: UnicodeString); override; + function InvalidateNode(Node: PVirtualNode): TRect; override; + function Path(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; Delimiter: WideChar): UnicodeString; + procedure ReinitNode(Node: PVirtualNode; Recursive: Boolean); override; + + function SaveToCSVFile(const FileNameWithPath : TFileName; const IncludeHeading : Boolean) : Boolean; + property ImageText[Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex]: UnicodeString read GetImageText; + property Text[Node: PVirtualNode; Column: TColumnIndex]: UnicodeString read GetText write SetText; + end; + + TVirtualStringTree = class(TCustomVirtualStringTree) + private + function GetOptions: TStringTreeOptions; + procedure SetOptions(const Value: TStringTreeOptions); + protected + function GetOptionsClass: TTreeOptionsClass; override; + public + property Canvas; + published + property AccessibleName; + property Action; + property Align; + property Alignment; + property Anchors; + property AnimationDuration; + property AutoExpandDelay; + property AutoScrollDelay; + property AutoScrollInterval; + property Background; + property BackgroundOffsetX; + property BackgroundOffsetY; + property BiDiMode; + property BevelEdges; + property BevelInner; + property BevelOuter; + property BevelKind; + property BevelWidth; + property BorderStyle; + property BottomSpace; + property ButtonFillMode; + property ButtonStyle; + property BorderWidth; + property ChangeDelay; + property CheckImageKind; + property ClipboardFormats; + property Color; + property Colors; + property Constraints; + property Ctl3D; + property CustomCheckImages; + property DefaultNodeHeight; + property DefaultPasteMode; + property DefaultText; + property DragCursor; + property DragHeight; + property DragKind; + property DragImageKind; + property DragMode; + property DragOperations; + property DragType; + property DragWidth; + property DrawSelectionMode; + property EditDelay; + property Enabled; + property Font; + property Header; + property HintAnimation; + property HintMode; + property HotCursor; + property Images; + property IncrementalSearch; + property IncrementalSearchDirection; + property IncrementalSearchStart; + property IncrementalSearchTimeout; + property Indent; + property LineMode; + property LineStyle; + property Margin; + property NodeAlignment; + property NodeDataSize; + property OperationCanceled; + property ParentBiDiMode; + property ParentColor default False; + property ParentCtl3D; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property RootNodeCount; + property ScrollBarOptions; + property SelectionBlendFactor; + property SelectionCurveRadius; + property ShowHint; + property StateImages; + property TabOrder; + property TabStop default True; + property TextMargin; + property TreeOptions: TStringTreeOptions read GetOptions write SetOptions; + property Visible; + property WantTabs; + + property OnAddToSelection; + property OnAdvancedHeaderDraw; + property OnAfterAutoFitColumn; + property OnAfterAutoFitColumns; + property OnAfterCellPaint; + property OnAfterColumnExport; + property OnAfterColumnWidthTracking; + property OnAfterGetMaxColumnWidth; + property OnAfterHeaderExport; + property OnAfterHeaderHeightTracking; + property OnAfterItemErase; + property OnAfterItemPaint; + property OnAfterNodeExport; + property OnAfterPaint; + property OnAfterTreeExport; + property OnBeforeAutoFitColumn; + property OnBeforeAutoFitColumns; + property OnBeforeCellPaint; + property OnBeforeColumnExport; + property OnBeforeColumnWidthTracking; + property OnBeforeDrawTreeLine; + property OnBeforeGetMaxColumnWidth; + property OnBeforeHeaderExport; + property OnBeforeHeaderHeightTracking; + property OnBeforeItemErase; + property OnBeforeItemPaint; + property OnBeforeNodeExport; + property OnBeforePaint; + property OnBeforeTreeExport; + property OnCanSplitterResizeColumn; + property OnCanSplitterResizeHeader; + property OnCanSplitterResizeNode; + property OnChange; + property OnChecked; + property OnChecking; + property OnClick; + property OnCollapsed; + property OnCollapsing; + property OnColumnClick; + property OnColumnDblClick; + property OnColumnExport; + property OnColumnResize; + property OnColumnWidthDblClickResize; + property OnColumnWidthTracking; + property OnCompareNodes; + property OnContextPopup; + property OnCreateDataObject; + property OnCreateDragManager; + property OnCreateEditor; + property OnDblClick; + property OnDragAllowed; + property OnDragOver; + property OnDragDrop; + property OnDrawText; + property OnEditCancelled; + property OnEdited; + property OnEditing; + property OnEndDock; + property OnEndDrag; + property OnEndOperation; + property OnEnter; + property OnExit; + property OnExpanded; + property OnExpanding; + property OnFocusChanged; + property OnFocusChanging; + property OnFreeNode; + property OnGetCellIsEmpty; + property OnGetCursor; + property OnGetHeaderCursor; + property OnGetText; + property OnPaintText; + property OnGetHelpContext; + property OnGetImageIndex; + property OnGetImageIndexEx; + property OnGetImageText; + property OnGetHint; + property OnGetLineStyle; + property OnGetNodeDataSize; + property OnGetPopupMenu; + property OnGetUserClipboardFormats; + property OnHeaderClick; + property OnHeaderDblClick; + property OnHeaderDragged; + property OnHeaderDraggedOut; + property OnHeaderDragging; + property OnHeaderDraw; + property OnHeaderDrawQueryElements; + property OnHeaderHeightDblClickResize; + property OnHeaderHeightTracking; + property OnHeaderMouseDown; + property OnHeaderMouseMove; + property OnHeaderMouseUp; + property OnHotChange; + property OnIncrementalSearch; + property OnInitChildren; + property OnInitNode; + property OnKeyAction; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnLoadNode; + property OnLoadTree; + property OnMeasureItem; + property OnMeasureTextWidth; + property OnMeasureTextHeight; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnMouseWheel; + property OnNewText; + property OnNodeClick; + property OnNodeCopied; + property OnNodeCopying; + property OnNodeDblClick; + property OnNodeExport; + property OnNodeHeightDblClickResize; + property OnNodeHeightTracking; + property OnNodeMoved; + property OnNodeMoving; + property OnPaintBackground; + property OnRemoveFromSelection; + property OnRenderOLEData; + property OnResetNode; + property OnResize; + property OnSaveNode; + property OnSaveTree; + property OnScroll; + property OnShortenString; + property OnShowScrollbar; + property OnStartDock; + property OnStartDrag; + property OnStartOperation; + property OnStateChange; + property OnStructureChange; + property OnUpdating; + {$if CompilerVersion>=21} + property OnCanResize; + {$ifend} + end; + + TVTDrawHintEvent = procedure(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; R: TRect; + Column: TColumnIndex) of object; + TVTDrawNodeEvent = procedure(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo) of object; + TVTGetCellContentMarginEvent = procedure(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; CellContentMarginType: TVTCellContentMarginType; var CellContentMargin: TPoint) of object; + TVTGetNodeWidthEvent = procedure(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; + Column: TColumnIndex; var NodeWidth: Integer) of object; + TVTGetHintSizeEvent = procedure(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var R: TRect) of object; + + // Tree descendant to let an application draw its stuff itself. + TCustomVirtualDrawTree = class(TBaseVirtualTree) + private + FOnDrawNode: TVTDrawNodeEvent; + FOnGetCellContentMargin: TVTGetCellContentMarginEvent; + FOnGetNodeWidth: TVTGetNodeWidthEvent; + FOnGetHintSize: TVTGetHintSizeEvent; + FOnDrawHint: TVTDrawHintEvent; + protected + procedure DoDrawHint(Canvas: TCanvas; Node: PVirtualNode; R: TRect; Column: TColumnIndex); + function DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex; + CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; override; + procedure DoGetHintSize(Node: PVirtualNode; Column: TColumnIndex; var R: TRect); virtual; + function DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; override; + procedure DoPaintNode(var PaintInfo: TVTPaintInfo); override; + + property OnDrawHint: TVTDrawHintEvent read FOnDrawHint write FOnDrawHint; + property OnDrawNode: TVTDrawNodeEvent read FOnDrawNode write FOnDrawNode; + property OnGetCellContentMargin: TVTGetCellContentMarginEvent read FOnGetCellContentMargin write FOnGetCellContentMargin; + property OnGetHintSize: TVTGetHintSizeEvent read FOnGetHintSize write FOnGetHintSize; + property OnGetNodeWidth: TVTGetNodeWidthEvent read FOnGetNodeWidth write FOnGetNodeWidth; + end; + + TVirtualDrawTree = class(TCustomVirtualDrawTree) + private + function GetOptions: TVirtualTreeOptions; + procedure SetOptions(const Value: TVirtualTreeOptions); + protected + function GetOptionsClass: TTreeOptionsClass; override; + public + property Canvas; + published + property Action; + property Align; + property Alignment; + property Anchors; + property AnimationDuration; + property AutoExpandDelay; + property AutoScrollDelay; + property AutoScrollInterval; + property Background; + property BackgroundOffsetX; + property BackgroundOffsetY; + property BiDiMode; + property BevelEdges; + property BevelInner; + property BevelOuter; + property BevelKind; + property BevelWidth; + property BorderStyle; + property BottomSpace; + property ButtonFillMode; + property ButtonStyle; + property BorderWidth; + property ChangeDelay; + property CheckImageKind; + property ClipboardFormats; + property Color; + property Colors; + property Constraints; + property Ctl3D; + property CustomCheckImages; + property DefaultNodeHeight; + property DefaultPasteMode; + property DragCursor; + property DragHeight; + property DragKind; + property DragImageKind; + property DragMode; + property DragOperations; + property DragType; + property DragWidth; + property DrawSelectionMode; + property EditDelay; + property Enabled; + property Font; + property Header; + property HintAnimation; + property HintMode; + property HotCursor; + property Images; + property IncrementalSearch; + property IncrementalSearchDirection; + property IncrementalSearchStart; + property IncrementalSearchTimeout; + property Indent; + property LineMode; + property LineStyle; + property Margin; + property NodeAlignment; + property NodeDataSize; + property OperationCanceled; + property ParentBiDiMode; + property ParentColor default False; + property ParentCtl3D; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property RootNodeCount; + property ScrollBarOptions; + property SelectionBlendFactor; + property SelectionCurveRadius; + property ShowHint; + property StateImages; + property TabOrder; + property TabStop default True; + property TextMargin; + property TreeOptions: TVirtualTreeOptions read GetOptions write SetOptions; + property Visible; + property WantTabs; + + property OnAddToSelection; + property OnAdvancedHeaderDraw; + property OnAfterAutoFitColumn; + property OnAfterAutoFitColumns; + property OnAfterCellPaint; + property OnAfterColumnExport; + property OnAfterColumnWidthTracking; + property OnAfterGetMaxColumnWidth; + property OnAfterHeaderExport; + property OnAfterHeaderHeightTracking; + property OnAfterItemErase; + property OnAfterItemPaint; + property OnAfterNodeExport; + property OnAfterPaint; + property OnAfterTreeExport; + property OnBeforeAutoFitColumn; + property OnBeforeAutoFitColumns; + property OnBeforeCellPaint; + property OnBeforeColumnExport; + property OnBeforeColumnWidthTracking; + property OnBeforeDrawTreeLine; + property OnBeforeGetMaxColumnWidth; + property OnBeforeHeaderExport; + property OnBeforeHeaderHeightTracking; + property OnBeforeItemErase; + property OnBeforeItemPaint; + property OnBeforeNodeExport; + property OnBeforePaint; + property OnBeforeTreeExport; + property OnCanSplitterResizeColumn; + property OnCanSplitterResizeHeader; + property OnCanSplitterResizeNode; + property OnChange; + property OnChecked; + property OnChecking; + property OnClick; + property OnCollapsed; + property OnCollapsing; + property OnColumnClick; + property OnColumnDblClick; + property OnColumnExport; + property OnColumnResize; + property OnColumnWidthDblClickResize; + property OnColumnWidthTracking; + property OnCompareNodes; + property OnContextPopup; + property OnCreateDataObject; + property OnCreateDragManager; + property OnCreateEditor; + property OnDblClick; + property OnDragAllowed; + property OnDragOver; + property OnDragDrop; + property OnDrawHint; + property OnDrawNode; + property OnEdited; + property OnEditing; + property OnEndDock; + property OnEndDrag; + property OnEndOperation; + property OnEnter; + property OnExit; + property OnExpanded; + property OnExpanding; + property OnFocusChanged; + property OnFocusChanging; + property OnFreeNode; + property OnGetCellIsEmpty; + property OnGetCursor; + property OnGetHeaderCursor; + property OnGetHelpContext; + property OnGetHintSize; + property OnGetImageIndex; + property OnGetImageIndexEx; + property OnGetLineStyle; + property OnGetNodeDataSize; + property OnGetNodeWidth; + property OnGetPopupMenu; + property OnGetUserClipboardFormats; + property OnHeaderClick; + property OnHeaderDblClick; + property OnHeaderDragged; + property OnHeaderDraggedOut; + property OnHeaderDragging; + property OnHeaderDraw; + property OnHeaderDrawQueryElements; + property OnHeaderHeightTracking; + property OnHeaderHeightDblClickResize; + property OnHeaderMouseDown; + property OnHeaderMouseMove; + property OnHeaderMouseUp; + property OnHotChange; + property OnIncrementalSearch; + property OnInitChildren; + property OnInitNode; + property OnKeyAction; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnLoadNode; + property OnLoadTree; + property OnMeasureItem; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnMouseWheel; + property OnNodeClick; + property OnNodeCopied; + property OnNodeCopying; + property OnNodeDblClick; + property OnNodeExport; + property OnNodeHeightTracking; + property OnNodeHeightDblClickResize; + property OnNodeMoved; + property OnNodeMoving; + property OnPaintBackground; + property OnRemoveFromSelection; + property OnRenderOLEData; + property OnResetNode; + property OnResize; + property OnSaveNode; + property OnSaveTree; + property OnScroll; + property OnShowScrollbar; + property OnStartDock; + property OnStartDrag; + property OnStartOperation; + property OnStateChange; + property OnStructureChange; + property OnUpdating; + end; + +type + // Describes the mode how to blend pixels. + TBlendMode = ( + bmConstantAlpha, // apply given constant alpha + bmPerPixelAlpha, // use alpha value of the source pixel + bmMasterAlpha, // use alpha value of source pixel and multiply it with the constant alpha value + bmConstantAlphaAndColor // blend the destination color with the given constant color und the constant alpha value + ); + +// OLE Clipboard and drag'n drop helper +procedure EnumerateVTClipboardFormats(TreeClass: TVirtualTreeClass; const List: TStrings); overload; +procedure EnumerateVTClipboardFormats(TreeClass: TVirtualTreeClass; var Formats: TFormatEtcArray); overload; +function GetVTClipboardFormatDescription(AFormat: Word): string; +procedure RegisterVTClipboardFormat(AFormat: Word; TreeClass: TVirtualTreeClass; Priority: Cardinal); overload; +function RegisterVTClipboardFormat(Description: string; TreeClass: TVirtualTreeClass; Priority: Cardinal; + tymed: Integer = TYMED_HGLOBAL; ptd: PDVTargetDevice = nil; dwAspect: Integer = DVASPECT_CONTENT; + lindex: Integer = -1): Word; overload; + +// utility routines +procedure AlphaBlend(Source, Destination: HDC; R: TRect; Target: TPoint; Mode: TBlendMode; ConstantAlpha, Bias: Integer); +procedure PrtStretchDrawDIB(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap); +function ShortenString(DC: HDC; const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString; +function TreeFromNode(Node: PVirtualNode): TBaseVirtualTree; +procedure GetStringDrawRect(DC: HDC; const S: UnicodeString; var Bounds: TRect; DrawFormat: Cardinal); +function WrapString(DC: HDC; const S: UnicodeString; const Bounds: TRect; RTL: Boolean; + DrawFormat: Cardinal): UnicodeString; + +//---------------------------------------------------------------------------------------------------------------------- + +implementation + +{$R VirtualTrees.res} + +uses + Consts, Math, + AxCtrls, // TOLEStream + MMSystem, // for animation timer (does not include further resources) + TypInfo, // for migration stuff + ActnList, + StdActns, // for standard action support + {$ifdef UNICODE} + AnsiStrings, + {$endif UNICODE} + StrUtils, + DUnitM.VTAccessibilityFactory; // accessibility helper class + +resourcestring + // Localizable strings. + SEditLinkIsNil = 'Edit link must not be nil.'; + SWrongMoveError = 'Target node cannot be a child node of the node to be moved.'; + SWrongStreamFormat = 'Unable to load tree structure, the format is wrong.'; + SWrongStreamVersion = 'Unable to load tree structure, the version is unknown.'; + SStreamTooSmall = 'Unable to load tree structure, not enough data available.'; + SCorruptStream1 = 'Stream data corrupt. A node''s anchor chunk is missing.'; + SCorruptStream2 = 'Stream data corrupt. Unexpected data after node''s end position.'; + SClipboardFailed = 'Clipboard operation failed.'; + SCannotSetUserData = 'Cannot set initial user data because there is not enough user data space allocated.'; + +const + ClipboardStates = [tsCopyPending, tsCutPending]; + DefaultScrollUpdateFlags = [suoRepaintHeader, suoRepaintScrollbars, suoScrollClientArea, suoUpdateNCArea]; + MinimumTimerInterval = 1; // minimum resolution for timeGetTime + TreeNodeSize = (SizeOf(TVirtualNode) + (SizeOf(Pointer) - 1)) and not (SizeOf(Pointer) - 1); // used for node allocation and access to internal data + + // Lookup to quickly convert a specific check state into its pressed counterpart and vice versa. + PressedState: array[TCheckState] of TCheckState = ( + csUncheckedPressed, csUncheckedPressed, csCheckedPressed, csCheckedPressed, csMixedPressed, csMixedPressed + ); + UnpressedState: array[TCheckState] of TCheckState = ( + csUncheckedNormal, csUncheckedNormal, csCheckedNormal, csCheckedNormal, csMixedNormal, csMixedNormal + ); + MouseButtonDown = [tsLeftButtonDown, tsMiddleButtonDown, tsRightButtonDown]; + + // Do not modify the copyright in any way! Usage of this unit is prohibited without the copyright notice + // in the compiled binary file. + Copyright: string = 'Virtual Treeview © 1999, 2010 Mike Lischke'; + +var + StandardOLEFormat: TFormatEtc = ( + // Format must later be set. + cfFormat: 0; + // No specific target device to render on. + ptd: nil; + // Normal content to render. + dwAspect: DVASPECT_CONTENT; + // No specific page of multipage data (we don't use multipage data by default). + lindex: -1; + // Acceptable storage formats are IStream and global memory. The first is preferred. + tymed: TYMED_ISTREAM or TYMED_HGLOBAL; + ); + +type + // protection against TRect record method that cause problems with with-statements + TWithSafeRect = record + case Integer of + 0: (Left, Top, Right, Bottom: Longint); + 1: (TopLeft, BottomRight: TPoint); + end; + +type // streaming support + TMagicID = array[0..5] of WideChar; + + TChunkHeader = record + ChunkType, + ChunkSize: Integer; // contains the size of the chunk excluding the header + end; + + // base information about a node + TBaseChunkBody = packed record + ChildCount, + NodeHeight: Cardinal; + States: TVirtualNodeStates; + Align: Byte; + CheckState: TCheckState; + CheckType: TCheckType; + Reserved: Cardinal; + end; + + TBaseChunk = packed record + Header: TChunkHeader; + Body: TBaseChunkBody; + end; + + // Toggle animation modes. + TToggleAnimationMode = ( + tamScrollUp, + tamScrollDown, + tamNoScroll + ); + + // Internally used data for animations. + TToggleAnimationData = record + Window: HWND; // copy of the tree's window handle + DC: HDC; // the DC of the window to erase uncovered parts + Brush: HBRUSH; // the brush to be used to erase uncovered parts + R1, + R2: TRect; // animation rectangles + Mode1, + Mode2: TToggleAnimationMode; // animation modes + ScaleFactor: Double; // the factor between the missing step size when doing two animations + MissedSteps: Double; + end; + + TCanvasEx = class(TCanvas); + +const + MagicID: TMagicID = (#$2045, 'V', 'T', WideChar(VTTreeStreamVersion), ' ', #$2046); + + // chunk IDs + NodeChunk = 1; + BaseChunk = 2; // chunk containing node state, check state, child node count etc. + // this chunk is immediately followed by all child nodes + CaptionChunk = 3; // used by the string tree to store a node's caption + UserChunk = 4; // used for data supplied by the application + + {$ifndef COMPILER_11_UP} + const + TVP_HOTGLYPH = 4; + {$endif COMPILER_11_UP} + + RTLFlag: array[Boolean] of Integer = (0, ETO_RTLREADING); + AlignmentToDrawFlag: array[TAlignment] of Cardinal = (DT_LEFT, DT_RIGHT, DT_CENTER); + + WideNull = WideChar(#0); + WideCR = WideChar(#13); + WideLF = WideChar(#10); + WideLineSeparator = WideChar(#2028); + +type + TCriticalSection = class(TObject) + protected + FSection: TRTLCriticalSection; + public + constructor Create; + destructor Destroy; override; + + procedure Enter; + procedure Leave; + end; + + // internal worker thread + TWorkerThread = class(TThread) + private + FCurrentTree: TBaseVirtualTree; + FWaiterList: TThreadList; + FRefCount: Cardinal; + protected + procedure CancelValidation(Tree: TBaseVirtualTree); + procedure ChangeTreeStates(EnterStates, LeaveStates: TChangeStates); + procedure Execute; override; + public + constructor Create(CreateSuspended: Boolean); + destructor Destroy; override; + + procedure AddTree(Tree: TBaseVirtualTree); + procedure RemoveTree(Tree: TBaseVirtualTree); + + property CurrentTree: TBaseVirtualTree read FCurrentTree; + end; + + // Helper classes to speed up rendering text formats for clipboard and drag'n drop transfers. + TBufferedAnsiString = class + private + FStart, + FPosition, + FEnd: PAnsiChar; + function GetAsString: AnsiString; + public + destructor Destroy; override; + + procedure Add(const S: AnsiString); + procedure AddNewLine; + + property AsString: AnsiString read GetAsString; + end; + + TWideBufferedString = class + private + FStart, + FPosition, + FEnd: PWideChar; + function GetAsString: UnicodeString; + public + destructor Destroy; override; + + procedure Add(const S: UnicodeString); + procedure AddNewLine; + + property AsString: UnicodeString read GetAsString; + end; + +var + WorkerThread: TWorkerThread; + WorkEvent: THandle; + Watcher: TCriticalSection; + LightCheckImages, // global light check images + DarkCheckImages, // global heavy check images + LightTickImages, // global light tick images + DarkTickImages, // global heavy check images + FlatImages, // global flat check images + XPImages, // global XP style check images + UtilityImages, // some small additional images (e.g for header dragging) + SystemCheckImages, // global system check images + SystemFlatCheckImages: TImageList; // global flat system check images + Initialized: Boolean; // True if global structures have been initialized. + NeedToUnitialize: Boolean; // True if the OLE subsystem could be initialized successfully. + +//----------------- TClipboardFormats ---------------------------------------------------------------------------------- + +type + PClipboardFormatListEntry = ^TClipboardFormatListEntry; + TClipboardFormatListEntry = record + Description: string; // The string used to register the format with Windows. + TreeClass: TVirtualTreeClass; // The tree class which supports rendering this format. + Priority: Cardinal; // Number which determines the order of formats used in IDataObject. + FormatEtc: TFormatEtc; // The definition of the format in the IDataObject. + end; + + TClipboardFormatList = class + private + FList: TList; + procedure Sort; + public + constructor Create; + destructor Destroy; override; + + procedure Add(FormatString: string; AClass: TVirtualTreeClass; Priority: Cardinal; AFormatEtc: TFormatEtc); + procedure Clear; + procedure EnumerateFormats(TreeClass: TVirtualTreeClass; var Formats: TFormatEtcArray; + const AllowedFormats: TClipboardFormats = nil); overload; + procedure EnumerateFormats(TreeClass: TVirtualTreeClass; const Formats: TStrings); overload; + function FindFormat(FormatString: string): PClipboardFormatListEntry; overload; + function FindFormat(FormatString: string; var Fmt: Word): TVirtualTreeClass; overload; + function FindFormat(Fmt: Word; var Description: string): TVirtualTreeClass; overload; + end; + +var + InternalClipboardFormats: TClipboardFormatList; + +//---------------------------------------------------------------------------------------------------------------------- + +constructor TClipboardFormatList.Create; + +begin + FList := TList.Create; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TClipboardFormatList.Destroy; + +begin + Clear; + FList.Free; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormatList.Sort; + +// Sorts all entry for priority (increasing priority value). + + //--------------- local function -------------------------------------------- + + procedure QuickSort(L, R: Integer); + + var + I, J: Integer; + P, T: PClipboardFormatListEntry; + + begin + repeat + I := L; + J := R; + P := FList[(L + R) shr 1]; + repeat + while PClipboardFormatListEntry(FList[I]).Priority < P.Priority do + Inc(I); + while PClipboardFormatListEntry(Flist[J]).Priority > P.Priority do + Dec(J); + if I <= J then + begin + T := Flist[I]; + FList[I] := FList[J]; + FList[J] := T; + Inc(I); + Dec(J); + end; + until I > J; + if L < J then + QuickSort(L, J); + L := I; + until I >= R; + end; + + //--------------- end local function ---------------------------------------- + +begin + if FList.Count > 1 then + QuickSort(0, FList.Count - 1); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormatList.Add(FormatString: string; AClass: TVirtualTreeClass; Priority: Cardinal; + AFormatEtc: TFormatEtc); + +// Adds the given data to the internal list. The priority value is used to sort formats for importance. Larger priority +// values mean less priority. + +var + Entry: PClipboardFormatListEntry; + +begin + New(Entry); + Entry.Description := FormatString; + Entry.TreeClass := AClass; + Entry.Priority := Priority; + Entry.FormatEtc := AFormatEtc; + FList.Add(Entry); + + Sort; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormatList.Clear; + +var + I: Integer; + +begin + for I := 0 to FList.Count - 1 do + Dispose(PClipboardFormatListEntry(FList[I])); + FList.Clear; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormatList.EnumerateFormats(TreeClass: TVirtualTreeClass; var Formats: TFormatEtcArray; + const AllowedFormats: TClipboardFormats = nil); + +// Returns a list of format records for the given class. If assigned the AllowedFormats is used to limit the +// enumerated formats to those described in the list. + +var + I, Count: Integer; + Entry: PClipboardFormatListEntry; + +begin + SetLength(Formats, FList.Count); + Count := 0; + for I := 0 to FList.Count - 1 do + begin + Entry := FList[I]; + // Does the tree class support this clipboard format? + if TreeClass.InheritsFrom(Entry.TreeClass) then + begin + // Is this format allowed to be included? + if (AllowedFormats = nil) or (AllowedFormats.IndexOf(Entry.Description) > -1) then + begin + // The list could change before we use the FormatEtc so it is best not to pass a pointer to the true FormatEtc + // structure. Instead make a copy and send that. + Formats[Count] := Entry.FormatEtc; + Inc(Count); + end; + end; + end; + SetLength(Formats, Count); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormatList.EnumerateFormats(TreeClass: TVirtualTreeClass; const Formats: TStrings); + +// Returns a list of format descriptions for the given class. + +var + I: Integer; + Entry: PClipboardFormatListEntry; + +begin + for I := 0 to FList.Count - 1 do + begin + Entry := FList[I]; + if TreeClass.InheritsFrom(Entry.TreeClass) then + Formats.Add(Entry.Description); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TClipboardFormatList.FindFormat(FormatString: string): PClipboardFormatListEntry; + +var + I: Integer; + Entry: PClipboardFormatListEntry; + +begin + Result := nil; + for I := FList.Count - 1 downto 0 do + begin + Entry := FList[I]; + if CompareText(Entry.Description, FormatString) = 0 then + begin + Result := Entry; + Break; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TClipboardFormatList.FindFormat(FormatString: string; var Fmt: Word): TVirtualTreeClass; + +var + I: Integer; + Entry: PClipboardFormatListEntry; + +begin + Result := nil; + for I := FList.Count - 1 downto 0 do + begin + Entry := FList[I]; + if CompareText(Entry.Description, FormatString) = 0 then + begin + Result := Entry.TreeClass; + Fmt := Entry.FormatEtc.cfFormat; + Break; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TClipboardFormatList.FindFormat(Fmt: Word; var Description: string): TVirtualTreeClass; + +var + I: Integer; + Entry: PClipboardFormatListEntry; + +begin + Result := nil; + for I := FList.Count - 1 downto 0 do + begin + Entry := FList[I]; + if Entry.FormatEtc.cfFormat = Fmt then + begin + Result := Entry.TreeClass; + Description := Entry.Description; + Break; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + TClipboardFormatEntry = record + ID: Word; + Description: string; + end; + +var + ClipboardDescriptions: array [1..CF_MAX - 1] of TClipboardFormatEntry = ( + (ID: CF_TEXT; Description: 'Plain text'), // Do not localize + (ID: CF_BITMAP; Description: 'Windows bitmap'), // Do not localize + (ID: CF_METAFILEPICT; Description: 'Windows metafile'), // Do not localize + (ID: CF_SYLK; Description: 'Symbolic link'), // Do not localize + (ID: CF_DIF; Description: 'Data interchange format'), // Do not localize + (ID: CF_TIFF; Description: 'Tiff image'), // Do not localize + (ID: CF_OEMTEXT; Description: 'OEM text'), // Do not localize + (ID: CF_DIB; Description: 'DIB image'), // Do not localize + (ID: CF_PALETTE; Description: 'Palette data'), // Do not localize + (ID: CF_PENDATA; Description: 'Pen data'), // Do not localize + (ID: CF_RIFF; Description: 'Riff audio data'), // Do not localize + (ID: CF_WAVE; Description: 'Wav audio data'), // Do not localize + (ID: CF_UNICODETEXT; Description: 'Unicode text'), // Do not localize + (ID: CF_ENHMETAFILE; Description: 'Enhanced metafile image'), // Do not localize + (ID: CF_HDROP; Description: 'File name(s)'), // Do not localize + (ID: CF_LOCALE; Description: 'Locale descriptor') // Do not localize + {$if CompilerVersion >= 23} + ,(ID: CF_DIBV5; Description: 'DIB image V5') // Do not localize + {$ifend} + ); + +//---------------------------------------------------------------------------------------------------------------------- + +procedure EnumerateVTClipboardFormats(TreeClass: TVirtualTreeClass; const List: TStrings); + +begin + if InternalClipboardFormats = nil then + InternalClipboardFormats := TClipboardFormatList.Create; + InternalClipboardFormats.EnumerateFormats(TreeClass, List); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure EnumerateVTClipboardFormats(TreeClass: TVirtualTreeClass; var Formats: TFormatEtcArray); + +begin + if InternalClipboardFormats = nil then + InternalClipboardFormats := TClipboardFormatList.Create; + InternalClipboardFormats.EnumerateFormats(TreeClass, Formats); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function GetVTClipboardFormatDescription(AFormat: Word): string; + +begin + if InternalClipboardFormats = nil then + InternalClipboardFormats := TClipboardFormatList.Create; + if InternalClipboardFormats.FindFormat(AFormat, Result) = nil then + Result := ''; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure RegisterVTClipboardFormat(AFormat: Word; TreeClass: TVirtualTreeClass; Priority: Cardinal); + +// Registers the given clipboard format for the given TreeClass. + +var + I: Integer; + Buffer: array[0..2048] of Char; + FormatEtc: TFormatEtc; + +begin + if InternalClipboardFormats = nil then + InternalClipboardFormats := TClipboardFormatList.Create; + + // Assumes a HGlobal format. + FormatEtc.cfFormat := AFormat; + FormatEtc.ptd := nil; + FormatEtc.dwAspect := DVASPECT_CONTENT; + FormatEtc.lindex := -1; + FormatEtc.tymed := TYMED_HGLOBAL; + + // Determine description string of the given format. For predefined formats we need the lookup table because they + // don't have a description string. For registered formats the description string is the string which was used + // to register them. + if AFormat < CF_MAX then + begin + for I := 1 to High(ClipboardDescriptions) do + if ClipboardDescriptions[I].ID = AFormat then + begin + InternalClipboardFormats.Add(ClipboardDescriptions[I].Description, TreeClass, Priority, FormatEtc); + Break; + end; + end + else + begin + GetClipboardFormatName(AFormat, Buffer, Length(Buffer)); + InternalClipboardFormats.Add(Buffer, TreeClass, Priority, FormatEtc); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function RegisterVTClipboardFormat(Description: string; TreeClass: TVirtualTreeClass; Priority: Cardinal; + tymed: Integer = TYMED_HGLOBAL; ptd: PDVTargetDevice = nil; dwAspect: Integer = DVASPECT_CONTENT; + lindex: Integer = -1): Word; + +// Alternative method to register a certain clipboard format for a given tree class. Registration with the +// clipboard is done here too and the assigned ID returned by the function. +// tymed may contain or'ed TYMED constants which allows to register several storage formats for one clipboard format. + +var + FormatEtc: TFormatEtc; + +begin + if InternalClipboardFormats = nil then + InternalClipboardFormats := TClipboardFormatList.Create; + Result := RegisterClipboardFormat(PChar(Description)); + FormatEtc.cfFormat := Result; + FormatEtc.ptd := ptd; + FormatEtc.dwAspect := dwAspect; + FormatEtc.lindex := lindex; + FormatEtc.tymed := tymed; + InternalClipboardFormats.Add(Description, TreeClass, Priority, FormatEtc); +end; + +//----------------- utility functions ---------------------------------------------------------------------------------- + +procedure ShowError(Msg: UnicodeString; HelpContext: Integer); + +begin + raise EVirtualTreeError.CreateHelp(Msg, HelpContext); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TreeFromNode(Node: PVirtualNode): TBaseVirtualTree; + +// Returns the tree the node currently belongs to or nil if the node is not attached to a tree. + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + + // The root node is marked by having its NextSibling (and PrevSibling) pointing to itself. + while Assigned(Node) and (Node.NextSibling <> Node) do + Node := Node.Parent; + if Assigned(Node) then + Result := TBaseVirtualTree(Node.Parent) + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function OrderRect(const R: TRect): TRect; + +// Converts the incoming rectangle so that left and top are always less than or equal to right and bottom. + +begin + if R.Left < R.Right then + begin + Result.Left := R.Left; + Result.Right := R.Right; + end + else + begin + Result.Left := R.Right; + Result.Right := R.Left; + end; + if R.Top < R.Bottom then + begin + Result.Top := R.Top; + Result.Bottom := R.Bottom; + end + else + begin + Result.Top := R.Bottom; + Result.Bottom := R.Top; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure QuickSort(const TheArray: TNodeArray; L, R: Integer); + +var + I, J: Integer; + P, T: Pointer; + +begin + repeat + I := L; + J := R; + P := TheArray[(L + R) shr 1]; + repeat + while PAnsiChar(TheArray[I]) < PAnsiChar(P) do + Inc(I); + while PAnsiChar(TheArray[J]) > PAnsiChar(P) do + Dec(J); + if I <= J then + begin + T := TheArray[I]; + TheArray[I] := TheArray[J]; + TheArray[J] := T; + Inc(I); + Dec(J); + end; + until I > J; + if L < J then + QuickSort(TheArray, L, J); + L := I; + until I >= R; +end; + + +//---------------------------------------------------------------------------------------------------------------------- + +function ShortenString(DC: HDC; const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString; + +// Adjusts the given string S so that it fits into the given width. EllipsisWidth gives the width of +// the three points to be added to the shorted string. If this value is 0 then it will be determined implicitely. +// For higher speed (and multiple entries to be shorted) specify this value explicitely. +// Note: It is assumed that the string really needs shortage. Check this in advance. + +var + Size: TSize; + Len: Integer; + L, H, N, W: Integer; + +begin + Len := Length(S); + if (Len = 0) or (Width <= 0) then + Result := '' + else + begin + // Determine width of triple point using the current DC settings (if not already done). + if EllipsisWidth = 0 then + begin + GetTextExtentPoint32W(DC, '...', 3, Size); + EllipsisWidth := Size.cx; + end; + + if Width <= EllipsisWidth then + Result := '' + else + begin + // Do a binary search for the optimal string length which fits into the given width. + L := 0; + H := Len - 1; + while L < H do + begin + N := (L + H + 1) shr 1; + GetTextExtentPoint32W(DC, PWideChar(S), N, Size); + W := Size.cx + EllipsisWidth; + if W <= Width then + L := N + else + H := N - 1; + end; + Result := Copy(S, 1, L) + '...' + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function WrapString(DC: HDC; const S: UnicodeString; const Bounds: TRect; RTL: Boolean; + DrawFormat: Cardinal): UnicodeString; + +// Wrap the given string S so that it fits into a space of given width. +// RTL determines if right-to-left reading is active. + +var + Width, + Len, + WordCounter, + WordsInLine, + I, W: Integer; + Buffer, + Line: UnicodeString; + Words: Array of UnicodeString; + R: TRect; + +begin + Result := ''; + Width := Bounds.Right - Bounds.Left; + R := Rect(0, 0, 0, 0); + + // Leading and trailing are ignored. + Buffer := Trim(S); + Len := Length(Buffer); + if Len < 1 then + Exit; + + // Count the words in the string. + WordCounter := 1; + for I := 1 to Len do + if Buffer[I] = ' ' then + Inc(WordCounter); + SetLength(Words, WordCounter); + + if RTL then + begin + // At first we split the string into words with the last word being the + // first element in Words. + W := 0; + for I := 1 to Len do + if Buffer[I] = ' ' then + Inc(W) + else + Words[W] := Words[W] + Buffer[I]; + + // Compose Result. + while WordCounter > 0 do + begin + WordsInLine := 0; + Line := ''; + + while WordCounter > 0 do + begin + GetStringDrawRect(DC, Line + IfThen(WordsInLine > 0, ' ', '') + Words[WordCounter - 1], R, DrawFormat); + if R.Right > Width then + begin + // If at least one word fits into this line then continue with the next line. + if WordsInLine > 0 then + Break; + + Buffer := Words[WordCounter - 1]; + if Len > 1 then + begin + for Len := Length(Buffer) - 1 downto 2 do + begin + GetStringDrawRect(DC, RightStr(Buffer, Len), R, DrawFormat); + if R.Right <= Width then + Break; + end; + end + else + Len := Length(Buffer); + + Line := Line + RightStr(Buffer, Max(Len, 1)); + Words[WordCounter - 1] := LeftStr(Buffer, Length(Buffer) - Max(Len, 1)); + if Words[WordCounter - 1] = '' then + Dec(WordCounter); + Break; + end + else + begin + Dec(WordCounter); + Line := Words[WordCounter] + IfThen(WordsInLine > 0, ' ', '') + Line; + Inc(WordsInLine); + end; + end; + + Result := Result + Line + WideLF; + end; + end + else + begin + // At first we split the string into words with the last word being the + // first element in Words. + W := WordCounter - 1; + for I := 1 to Len do + if Buffer[I] = ' ' then + Dec(W) + else + Words[W] := Words[W] + Buffer[I]; + + // Compose Result. + while WordCounter > 0 do + begin + WordsInLine := 0; + Line := ''; + + while WordCounter > 0 do + begin + GetStringDrawRect(DC, Line + IfThen(WordsInLine > 0, ' ', '') + Words[WordCounter - 1], R, DrawFormat); + if R.Right > Width then + begin + // If at least one word fits into this line then continue with the next line. + if WordsInLine > 0 then + Break; + + Buffer := Words[WordCounter - 1]; + if Len > 1 then + begin + for Len := Length(Buffer) - 1 downto 2 do + begin + GetStringDrawRect(DC, LeftStr(Buffer, Len), R, DrawFormat); + if R.Right <= Width then + Break; + end; + end + else + Len := Length(Buffer); + + Line := Line + LeftStr(Buffer, Max(Len, 1)); + Words[WordCounter - 1] := RightStr(Buffer, Length(Buffer) - Max(Len, 1)); + if Words[WordCounter - 1] = '' then + Dec(WordCounter); + Break; + end + else + begin + Dec(WordCounter); + Line := Line + IfThen(WordsInLine > 0, ' ', '') + Words[WordCounter]; + Inc(WordsInLine); + end; + end; + + Result := Result + Line + WideLF; + end; + end; + + Len := Length(Result); + if Result[Len] = WideLF then + SetLength(Result, Len - 1); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure GetStringDrawRect(DC: HDC; const S: UnicodeString; var Bounds: TRect; DrawFormat: Cardinal); + +// Calculates bounds of a drawing rectangle for the given string + +begin + Bounds.Right := Bounds.Left + 1; + Bounds.Bottom := Bounds.Top + 1; + + Windows.DrawTextW(DC, PWideChar(S), Length(S), Bounds, DrawFormat or DT_CALCRECT) +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure FillDragRectangles(DragWidth, DragHeight, DeltaX, DeltaY: Integer; var RClip, RScroll, RSamp1, RSamp2, RDraw1, + RDraw2: TRect); + +// Fills the given rectangles with values which can be used while dragging around an image +// (used in DragMove of the drag manager and DragTo of the header columns). + +begin + // ScrollDC limits + RClip := Rect(0, 0, DragWidth, DragHeight); + if DeltaX > 0 then + begin + // move to the left + if DeltaY = 0 then + begin + // move only to the left + // background movement + RScroll := Rect(0, 0, DragWidth - DeltaX, DragHeight); + RSamp1 := Rect(0, 0, DeltaX, DragHeight); + RDraw1 := Rect(DragWidth - DeltaX, 0, DeltaX, DragHeight); + end + else + if DeltaY < 0 then + begin + // move to bottom left + RScroll := Rect(0, -DeltaY, DragWidth - DeltaX, DragHeight); + RSamp1 := Rect(0, 0, DeltaX, DragHeight); + RSamp2 := Rect(DeltaX, DragHeight + DeltaY, DragWidth - DeltaX, -DeltaY); + RDraw1 := Rect(0, 0, DragWidth - DeltaX, -DeltaY); + RDraw2 := Rect(DragWidth - DeltaX, 0, DeltaX, DragHeight); + end + else + begin + // move to upper left + RScroll := Rect(0, 0, DragWidth - DeltaX, DragHeight - DeltaY); + RSamp1 := Rect(0, 0, DeltaX, DragHeight); + RSamp2 := Rect(DeltaX, 0, DragWidth - DeltaX, DeltaY); + RDraw1 := Rect(0, DragHeight - DeltaY, DragWidth - DeltaX, DeltaY); + RDraw2 := Rect(DragWidth - DeltaX, 0, DeltaX, DragHeight); + end; + end + else + if DeltaX = 0 then + begin + // vertical movement only + if DeltaY < 0 then + begin + // move downwards + RScroll := Rect(0, -DeltaY, DragWidth, DragHeight); + RSamp2 := Rect(0, DragHeight + DeltaY, DragWidth, -DeltaY); + RDraw2 := Rect(0, 0, DragWidth, -DeltaY); + end + else + begin + // move upwards + RScroll := Rect(0, 0, DragWidth, DragHeight - DeltaY); + RSamp2 := Rect(0, 0, DragWidth, DeltaY); + RDraw2 := Rect(0, DragHeight - DeltaY, DragWidth, DeltaY); + end; + end + else + begin + // move to the right + if DeltaY > 0 then + begin + // move up right + RScroll := Rect(-DeltaX, 0, DragWidth, DragHeight); + RSamp1 := Rect(0, 0, DragWidth + DeltaX, DeltaY); + RSamp2 := Rect(DragWidth + DeltaX, 0, -DeltaX, DragHeight); + RDraw1 := Rect(0, 0, -DeltaX, DragHeight); + RDraw2 := Rect(-DeltaX, DragHeight - DeltaY, DragWidth + DeltaX, DeltaY); + end + else + if DeltaY = 0 then + begin + // to the right only + RScroll := Rect(-DeltaX, 0, DragWidth, DragHeight); + RSamp1 := Rect(DragWidth + DeltaX, 0, -DeltaX, DragHeight); + RDraw1 := Rect(0, 0, -DeltaX, DragHeight); + end + else + begin + // move down right + RScroll := Rect(-DeltaX, -DeltaY, DragWidth, DragHeight); + RSamp1 := Rect(0, DragHeight + DeltaY, DragWidth + DeltaX, -DeltaY); + RSamp2 := Rect(DragWidth + DeltaX, 0, -DeltaX, DragHeight); + RDraw1 := Rect(0, 0, -DeltaX, DragHeight); + RDraw2 := Rect(-DeltaX, 0, DragWidth + DeltaX, -DeltaY); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure AlphaBlendLineConstant(Source, Destination: Pointer; Count: Integer; ConstantAlpha, Bias: Integer); + +// Blends a line of Count pixels from Source to Destination using a constant alpha value. +// The layout of a pixel must be BGRA where A is ignored (but is calculated as the other components). +// ConstantAlpha must be in the range 0..255 where 0 means totally transparent (destination pixel only) +// and 255 totally opaque (source pixel only). +// Bias is an additional value which gets added to every component and must be in the range -128..127 +// +{$ifdef CPUX64} +// RCX contains Source +// RDX contains Destination +// R8D contains Count +// R9D contains ConstantAlpha +// Bias is on the stack + +asm + //.NOFRAME + + // Load XMM3 with the constant alpha value (replicate it for every component). + // Expand it to word size. + MOVD XMM3, R9D // ConstantAlpha + PUNPCKLWD XMM3, XMM3 + PUNPCKLDQ XMM3, XMM3 + + // Load XMM5 with the bias value. + MOVD XMM5, [Bias] + PUNPCKLWD XMM5, XMM5 + PUNPCKLDQ XMM5, XMM5 + + // Load XMM4 with 128 to allow for saturated biasing. + MOV R10D, 128 + MOVD XMM4, R10D + PUNPCKLWD XMM4, XMM4 + PUNPCKLDQ XMM4, XMM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + MOVD XMM1, DWORD PTR [RCX] // data is unaligned + MOVD XMM2, DWORD PTR [RDX] // data is unaligned + PXOR XMM0, XMM0 // clear source pixel register for unpacking + PUNPCKLBW XMM0, XMM1{[RCX]} // unpack source pixel byte values into words + PSRLW XMM0, 8 // move higher bytes to lower bytes + PXOR XMM1, XMM1 // clear target pixel register for unpacking + PUNPCKLBW XMM1, XMM2{[RDX]} // unpack target pixel byte values into words + MOVQ XMM2, XMM1 // make a copy of the shifted values, we need them again + PSRLW XMM1, 8 // move higher bytes to lower bytes + + // calculation is: target = (alpha * (source - target) + 256 * target) / 256 + PSUBW XMM0, XMM1 // source - target + PMULLW XMM0, XMM3 // alpha * (source - target) + PADDW XMM0, XMM2 // add target (in shifted form) + PSRLW XMM0, 8 // divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + PSUBW XMM0, XMM4 + PADDSW XMM0, XMM5 + PADDW XMM0, XMM4 + PACKUSWB XMM0, XMM0 // convert words to bytes with saturation + MOVD DWORD PTR [RDX], XMM0 // store the result +@3: + ADD RCX, 4 + ADD RDX, 4 + DEC R8D + JNZ @1 +end; +{$else} +// EAX contains Source +// EDX contains Destination +// ECX contains Count +// ConstantAlpha and Bias are on the stack + +asm + PUSH ESI // save used registers + PUSH EDI + + MOV ESI, EAX // ESI becomes the actual source pointer + MOV EDI, EDX // EDI becomes the actual target pointer + + // Load MM6 with the constant alpha value (replicate it for every component). + // Expand it to word size. + MOV EAX, [ConstantAlpha] + DB $0F, $6E, $F0 /// MOVD MM6, EAX + DB $0F, $61, $F6 /// PUNPCKLWD MM6, MM6 + DB $0F, $62, $F6 /// PUNPCKLDQ MM6, MM6 + + // Load MM5 with the bias value. + MOV EAX, [Bias] + DB $0F, $6E, $E8 /// MOVD MM5, EAX + DB $0F, $61, $ED /// PUNPCKLWD MM5, MM5 + DB $0F, $62, $ED /// PUNPCKLDQ MM5, MM5 + + // Load MM4 with 128 to allow for saturated biasing. + MOV EAX, 128 + DB $0F, $6E, $E0 /// MOVD MM4, EAX + DB $0F, $61, $E4 /// PUNPCKLWD MM4, MM4 + DB $0F, $62, $E4 /// PUNPCKLDQ MM4, MM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + DB $0F, $EF, $C0 /// PXOR MM0, MM0, clear source pixel register for unpacking + DB $0F, $60, $06 /// PUNPCKLBW MM0, [ESI], unpack source pixel byte values into words + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, move higher bytes to lower bytes + DB $0F, $EF, $C9 /// PXOR MM1, MM1, clear target pixel register for unpacking + DB $0F, $60, $0F /// PUNPCKLBW MM1, [EDI], unpack target pixel byte values into words + DB $0F, $6F, $D1 /// MOVQ MM2, MM1, make a copy of the shifted values, we need them again + DB $0F, $71, $D1, $08 /// PSRLW MM1, 8, move higher bytes to lower bytes + + // calculation is: target = (alpha * (source - target) + 256 * target) / 256 + DB $0F, $F9, $C1 /// PSUBW MM0, MM1, source - target + DB $0F, $D5, $C6 /// PMULLW MM0, MM6, alpha * (source - target) + DB $0F, $FD, $C2 /// PADDW MM0, MM2, add target (in shifted form) + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + DB $0F, $F9, $C4 /// PSUBW MM0, MM4 + DB $0F, $ED, $C5 /// PADDSW MM0, MM5 + DB $0F, $FD, $C4 /// PADDW MM0, MM4 + DB $0F, $67, $C0 /// PACKUSWB MM0, MM0, convert words to bytes with saturation + DB $0F, $7E, $07 /// MOVD [EDI], MM0, store the result +@3: + ADD ESI, 4 + ADD EDI, 4 + DEC ECX + JNZ @1 + POP EDI + POP ESI +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure AlphaBlendLinePerPixel(Source, Destination: Pointer; Count, Bias: Integer); + +// Blends a line of Count pixels from Source to Destination using the alpha value of the source pixels. +// The layout of a pixel must be BGRA. +// Bias is an additional value which gets added to every component and must be in the range -128..127 +// +{$ifdef CPUX64} +// RCX contains Source +// RDX contains Destination +// R8D contains Count +// R9D contains Bias + +asm + //.NOFRAME + + // Load XMM5 with the bias value. + MOVD XMM5, R9D // Bias + PUNPCKLWD XMM5, XMM5 + PUNPCKLDQ XMM5, XMM5 + + // Load XMM4 with 128 to allow for saturated biasing. + MOV R10D, 128 + MOVD XMM4, R10D + PUNPCKLWD XMM4, XMM4 + PUNPCKLDQ XMM4, XMM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + MOVD XMM1, DWORD PTR [RCX] // data is unaligned + MOVD XMM2, DWORD PTR [RDX] // data is unaligned + PXOR XMM0, XMM0 // clear source pixel register for unpacking + PUNPCKLBW XMM0, XMM1{[RCX]} // unpack source pixel byte values into words + PSRLW XMM0, 8 // move higher bytes to lower bytes + PXOR XMM1, XMM1 // clear target pixel register for unpacking + PUNPCKLBW XMM1, XMM2{[RDX]} // unpack target pixel byte values into words + MOVQ XMM2, XMM1 // make a copy of the shifted values, we need them again + PSRLW XMM1, 8 // move higher bytes to lower bytes + + // Load XMM3 with the source alpha value (replicate it for every component). + // Expand it to word size. + MOVQ XMM3, XMM0 + PUNPCKHWD XMM3, XMM3 + PUNPCKHDQ XMM3, XMM3 + + // calculation is: target = (alpha * (source - target) + 256 * target) / 256 + PSUBW XMM0, XMM1 // source - target + PMULLW XMM0, XMM3 // alpha * (source - target) + PADDW XMM0, XMM2 // add target (in shifted form) + PSRLW XMM0, 8 // divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + PSUBW XMM0, XMM4 + PADDSW XMM0, XMM5 + PADDW XMM0, XMM4 + PACKUSWB XMM0, XMM0 // convert words to bytes with saturation + MOVD DWORD PTR [RDX], XMM0 // store the result +@3: + ADD RCX, 4 + ADD RDX, 4 + DEC R8D + JNZ @1 +end; +{$else} +// EAX contains Source +// EDX contains Destination +// ECX contains Count +// Bias is on the stack + +asm + PUSH ESI // save used registers + PUSH EDI + + MOV ESI, EAX // ESI becomes the actual source pointer + MOV EDI, EDX // EDI becomes the actual target pointer + + // Load MM5 with the bias value. + MOV EAX, [Bias] + DB $0F, $6E, $E8 /// MOVD MM5, EAX + DB $0F, $61, $ED /// PUNPCKLWD MM5, MM5 + DB $0F, $62, $ED /// PUNPCKLDQ MM5, MM5 + + // Load MM4 with 128 to allow for saturated biasing. + MOV EAX, 128 + DB $0F, $6E, $E0 /// MOVD MM4, EAX + DB $0F, $61, $E4 /// PUNPCKLWD MM4, MM4 + DB $0F, $62, $E4 /// PUNPCKLDQ MM4, MM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + DB $0F, $EF, $C0 /// PXOR MM0, MM0, clear source pixel register for unpacking + DB $0F, $60, $06 /// PUNPCKLBW MM0, [ESI], unpack source pixel byte values into words + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, move higher bytes to lower bytes + DB $0F, $EF, $C9 /// PXOR MM1, MM1, clear target pixel register for unpacking + DB $0F, $60, $0F /// PUNPCKLBW MM1, [EDI], unpack target pixel byte values into words + DB $0F, $6F, $D1 /// MOVQ MM2, MM1, make a copy of the shifted values, we need them again + DB $0F, $71, $D1, $08 /// PSRLW MM1, 8, move higher bytes to lower bytes + + // Load MM6 with the source alpha value (replicate it for every component). + // Expand it to word size. + DB $0F, $6F, $F0 /// MOVQ MM6, MM0 + DB $0F, $69, $F6 /// PUNPCKHWD MM6, MM6 + DB $0F, $6A, $F6 /// PUNPCKHDQ MM6, MM6 + + // calculation is: target = (alpha * (source - target) + 256 * target) / 256 + DB $0F, $F9, $C1 /// PSUBW MM0, MM1, source - target + DB $0F, $D5, $C6 /// PMULLW MM0, MM6, alpha * (source - target) + DB $0F, $FD, $C2 /// PADDW MM0, MM2, add target (in shifted form) + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + DB $0F, $F9, $C4 /// PSUBW MM0, MM4 + DB $0F, $ED, $C5 /// PADDSW MM0, MM5 + DB $0F, $FD, $C4 /// PADDW MM0, MM4 + DB $0F, $67, $C0 /// PACKUSWB MM0, MM0, convert words to bytes with saturation + DB $0F, $7E, $07 /// MOVD [EDI], MM0, store the result +@3: + ADD ESI, 4 + ADD EDI, 4 + DEC ECX + JNZ @1 + POP EDI + POP ESI +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure AlphaBlendLineMaster(Source, Destination: Pointer; Count: Integer; ConstantAlpha, Bias: Integer); + +// Blends a line of Count pixels from Source to Destination using the source pixel and a constant alpha value. +// The layout of a pixel must be BGRA. +// ConstantAlpha must be in the range 0..255. +// Bias is an additional value which gets added to every component and must be in the range -128..127 +// +{$ifdef CPUX64} +// RCX contains Source +// RDX contains Destination +// R8D contains Count +// R9D contains ConstantAlpha +// Bias is on the stack + +asm + .SAVENV XMM6 + + // Load XMM3 with the constant alpha value (replicate it for every component). + // Expand it to word size. + MOVD XMM3, R9D // ConstantAlpha + PUNPCKLWD XMM3, XMM3 + PUNPCKLDQ XMM3, XMM3 + + // Load XMM5 with the bias value. + MOV R10D, [Bias] + MOVD XMM5, R10D + PUNPCKLWD XMM5, XMM5 + PUNPCKLDQ XMM5, XMM5 + + // Load XMM4 with 128 to allow for saturated biasing. + MOV R10D, 128 + MOVD XMM4, R10D + PUNPCKLWD XMM4, XMM4 + PUNPCKLDQ XMM4, XMM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + MOVD XMM1, DWORD PTR [RCX] // data is unaligned + MOVD XMM2, DWORD PTR [RDX] // data is unaligned + PXOR XMM0, XMM0 // clear source pixel register for unpacking + PUNPCKLBW XMM0, XMM1{[RCX]} // unpack source pixel byte values into words + PSRLW XMM0, 8 // move higher bytes to lower bytes + PXOR XMM1, XMM1 // clear target pixel register for unpacking + PUNPCKLBW XMM1, XMM2{[RCX]} // unpack target pixel byte values into words + MOVQ XMM2, XMM1 // make a copy of the shifted values, we need them again + PSRLW XMM1, 8 // move higher bytes to lower bytes + + // Load XMM6 with the source alpha value (replicate it for every component). + // Expand it to word size. + MOVQ XMM6, XMM0 + PUNPCKHWD XMM6, XMM6 + PUNPCKHDQ XMM6, XMM6 + PMULLW XMM6, XMM3 // source alpha * master alpha + PSRLW XMM6, 8 // divide by 256 + + // calculation is: target = (alpha * master alpha * (source - target) + 256 * target) / 256 + PSUBW XMM0, XMM1 // source - target + PMULLW XMM0, XMM6 // alpha * (source - target) + PADDW XMM0, XMM2 // add target (in shifted form) + PSRLW XMM0, 8 // divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + PSUBW XMM0, XMM4 + PADDSW XMM0, XMM5 + PADDW XMM0, XMM4 + PACKUSWB XMM0, XMM0 // convert words to bytes with saturation + MOVD DWORD PTR [RDX], XMM0 // store the result +@3: + ADD RCX, 4 + ADD RDX, 4 + DEC R8D + JNZ @1 +end; +{$else} +// EAX contains Source +// EDX contains Destination +// ECX contains Count +// ConstantAlpha and Bias are on the stack + +asm + PUSH ESI // save used registers + PUSH EDI + + MOV ESI, EAX // ESI becomes the actual source pointer + MOV EDI, EDX // EDI becomes the actual target pointer + + // Load MM6 with the constant alpha value (replicate it for every component). + // Expand it to word size. + MOV EAX, [ConstantAlpha] + DB $0F, $6E, $F0 /// MOVD MM6, EAX + DB $0F, $61, $F6 /// PUNPCKLWD MM6, MM6 + DB $0F, $62, $F6 /// PUNPCKLDQ MM6, MM6 + + // Load MM5 with the bias value. + MOV EAX, [Bias] + DB $0F, $6E, $E8 /// MOVD MM5, EAX + DB $0F, $61, $ED /// PUNPCKLWD MM5, MM5 + DB $0F, $62, $ED /// PUNPCKLDQ MM5, MM5 + + // Load MM4 with 128 to allow for saturated biasing. + MOV EAX, 128 + DB $0F, $6E, $E0 /// MOVD MM4, EAX + DB $0F, $61, $E4 /// PUNPCKLWD MM4, MM4 + DB $0F, $62, $E4 /// PUNPCKLDQ MM4, MM4 + +@1: // The pixel loop calculates an entire pixel in one run. + // Note: The pixel byte values are expanded into the higher bytes of a word due + // to the way unpacking works. We compensate for this with an extra shift. + DB $0F, $EF, $C0 /// PXOR MM0, MM0, clear source pixel register for unpacking + DB $0F, $60, $06 /// PUNPCKLBW MM0, [ESI], unpack source pixel byte values into words + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, move higher bytes to lower bytes + DB $0F, $EF, $C9 /// PXOR MM1, MM1, clear target pixel register for unpacking + DB $0F, $60, $0F /// PUNPCKLBW MM1, [EDI], unpack target pixel byte values into words + DB $0F, $6F, $D1 /// MOVQ MM2, MM1, make a copy of the shifted values, we need them again + DB $0F, $71, $D1, $08 /// PSRLW MM1, 8, move higher bytes to lower bytes + + // Load MM7 with the source alpha value (replicate it for every component). + // Expand it to word size. + DB $0F, $6F, $F8 /// MOVQ MM7, MM0 + DB $0F, $69, $FF /// PUNPCKHWD MM7, MM7 + DB $0F, $6A, $FF /// PUNPCKHDQ MM7, MM7 + DB $0F, $D5, $FE /// PMULLW MM7, MM6, source alpha * master alpha + DB $0F, $71, $D7, $08 /// PSRLW MM7, 8, divide by 256 + + // calculation is: target = (alpha * master alpha * (source - target) + 256 * target) / 256 + DB $0F, $F9, $C1 /// PSUBW MM0, MM1, source - target + DB $0F, $D5, $C7 /// PMULLW MM0, MM7, alpha * (source - target) + DB $0F, $FD, $C2 /// PADDW MM0, MM2, add target (in shifted form) + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8, divide by 256 + + // Bias is accounted for by conversion of range 0..255 to -128..127, + // doing a saturated add and convert back to 0..255. + DB $0F, $F9, $C4 /// PSUBW MM0, MM4 + DB $0F, $ED, $C5 /// PADDSW MM0, MM5 + DB $0F, $FD, $C4 /// PADDW MM0, MM4 + DB $0F, $67, $C0 /// PACKUSWB MM0, MM0, convert words to bytes with saturation + DB $0F, $7E, $07 /// MOVD [EDI], MM0, store the result +@3: + ADD ESI, 4 + ADD EDI, 4 + DEC ECX + JNZ @1 + POP EDI + POP ESI +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure AlphaBlendLineMasterAndColor(Destination: Pointer; Count: Integer; ConstantAlpha, Color: Integer); + +// Blends a line of Count pixels in Destination against the given color using a constant alpha value. +// The layout of a pixel must be BGRA and Color must be rrggbb00 (as stored by a COLORREF). +// ConstantAlpha must be in the range 0..255. +// +{$ifdef CPUX64} +// RCX contains Destination +// EDX contains Count +// R8D contains ConstantAlpha +// R9D contains Color + +asm + //.NOFRAME + + // The used formula is: target = (alpha * color + (256 - alpha) * target) / 256. + // alpha * color (factor 1) and 256 - alpha (factor 2) are constant values which can be calculated in advance. + // The remaining calculation is therefore: target = (F1 + F2 * target) / 256 + + // Load XMM3 with the constant alpha value (replicate it for every component). + // Expand it to word size. (Every calculation here works on word sized operands.) + MOVD XMM3, R8D // ConstantAlpha + PUNPCKLWD XMM3, XMM3 + PUNPCKLDQ XMM3, XMM3 + + // Calculate factor 2. + MOV R10D, $100 + MOVD XMM2, R10D + PUNPCKLWD XMM2, XMM2 + PUNPCKLDQ XMM2, XMM2 + PSUBW XMM2, XMM3 // XMM2 contains now: 255 - alpha = F2 + + // Now calculate factor 1. Alpha is still in XMM3, but the r and b components of Color must be swapped. + BSWAP R9D // Color + ROR R9D, 8 + MOVD XMM1, R9D // Load the color and convert to word sized values. + PXOR XMM4, XMM4 + PUNPCKLBW XMM1, XMM4 + PMULLW XMM1, XMM3 // XMM1 contains now: color * alpha = F1 + +@1: // The pixel loop calculates an entire pixel in one run. + MOVD XMM0, DWORD PTR [RCX] + PUNPCKLBW XMM0, XMM4 + + PMULLW XMM0, XMM2 // calculate F1 + F2 * target + PADDW XMM0, XMM1 + PSRLW XMM0, 8 // divide by 256 + + PACKUSWB XMM0, XMM0 // convert words to bytes with saturation + MOVD DWORD PTR [RCX], XMM0 // store the result + + ADD RCX, 4 + DEC EDX + JNZ @1 +end; +{$else} +// EAX contains Destination +// EDX contains Count +// ECX contains ConstantAlpha +// Color is passed on the stack + +asm + // The used formula is: target = (alpha * color + (256 - alpha) * target) / 256. + // alpha * color (factor 1) and 256 - alpha (factor 2) are constant values which can be calculated in advance. + // The remaining calculation is therefore: target = (F1 + F2 * target) / 256 + + // Load MM3 with the constant alpha value (replicate it for every component). + // Expand it to word size. (Every calculation here works on word sized operands.) + DB $0F, $6E, $D9 /// MOVD MM3, ECX + DB $0F, $61, $DB /// PUNPCKLWD MM3, MM3 + DB $0F, $62, $DB /// PUNPCKLDQ MM3, MM3 + + // Calculate factor 2. + MOV ECX, $100 + DB $0F, $6E, $D1 /// MOVD MM2, ECX + DB $0F, $61, $D2 /// PUNPCKLWD MM2, MM2 + DB $0F, $62, $D2 /// PUNPCKLDQ MM2, MM2 + DB $0F, $F9, $D3 /// PSUBW MM2, MM3 // MM2 contains now: 255 - alpha = F2 + + // Now calculate factor 1. Alpha is still in MM3, but the r and b components of Color must be swapped. + MOV ECX, [Color] + BSWAP ECX + ROR ECX, 8 + DB $0F, $6E, $C9 /// MOVD MM1, ECX // Load the color and convert to word sized values. + DB $0F, $EF, $E4 /// PXOR MM4, MM4 + DB $0F, $60, $CC /// PUNPCKLBW MM1, MM4 + DB $0F, $D5, $CB /// PMULLW MM1, MM3 // MM1 contains now: color * alpha = F1 + +@1: // The pixel loop calculates an entire pixel in one run. + DB $0F, $6E, $00 /// MOVD MM0, [EAX] + DB $0F, $60, $C4 /// PUNPCKLBW MM0, MM4 + + DB $0F, $D5, $C2 /// PMULLW MM0, MM2 // calculate F1 + F2 * target + DB $0F, $FD, $C1 /// PADDW MM0, MM1 + DB $0F, $71, $D0, $08 /// PSRLW MM0, 8 // divide by 256 + + DB $0F, $67, $C0 /// PACKUSWB MM0, MM0 // convert words to bytes with saturation + DB $0F, $7E, $00 /// MOVD [EAX], MM0 // store the result + + ADD EAX, 4 + DEC EDX + JNZ @1 +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure EMMS; + +// Reset MMX state to use the FPU for other tasks again. + +{$ifdef CPUX64} + inline; +begin +end; +{$else} +asm + DB $0F, $77 /// EMMS +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +function GetBitmapBitsFromDeviceContext(DC: HDC; var Width, Height: Integer): Pointer; + +// Helper function used to retrieve the bitmap selected into the given device context. If there is a bitmap then +// the function will return a pointer to its bits otherwise nil is returned. +// Additionally the dimensions of the bitmap are returned. + +var + Bitmap: HBITMAP; + DIB: TDIBSection; + +begin + Result := nil; + Width := 0; + Height := 0; + + Bitmap := GetCurrentObject(DC, OBJ_BITMAP); + if Bitmap <> 0 then + begin + if GetObject(Bitmap, SizeOf(DIB), @DIB) = SizeOf(DIB) then + begin + Assert(DIB.dsBm.bmPlanes * DIB.dsBm.bmBitsPixel = 32, 'Alpha blending error: bitmap must use 32 bpp.'); + Result := DIB.dsBm.bmBits; + Width := DIB.dsBmih.biWidth; + Height := DIB.dsBmih.biHeight; + end; + end; + Assert(Result <> nil, 'Alpha blending DC error: no bitmap available.'); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function CalculateScanline(Bits: Pointer; Width, Height, Row: Integer): Pointer; + +// Helper function to calculate the start address for the given row. + +begin + if Height > 0 then // bottom-up DIB + Row := Height - Row - 1; + // Return DWORD aligned address of the requested scanline. + Result := PAnsiChar(Bits) + Row * ((Width * 32 + 31) and not 31) div 8; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure AlphaBlend(Source, Destination: HDC; R: TRect; Target: TPoint; Mode: TBlendMode; ConstantAlpha, Bias: Integer); + +// Optimized alpha blend procedure using MMX instructions to perform as quick as possible. +// For this procedure to work properly it is important that both source and target bitmap use the 32 bit color format. +// R describes the source rectangle to work on. +// Target is the place (upper left corner) in the target bitmap where to blend to. Note that source width + X offset +// must be less or equal to the target width. Similar for the height. +// If Mode is bmConstantAlpha then the blend operation uses the given ConstantAlpha value for all pixels. +// If Mode is bmPerPixelAlpha then each pixel is blended using its individual alpha value (the alpha value of the source). +// If Mode is bmMasterAlpha then each pixel is blended using its individual alpha value multiplied by ConstantAlpha. +// If Mode is bmConstantAlphaAndColor then each destination pixel is blended using ConstantAlpha but also a constant +// color which will be obtained from Bias. In this case no offset value is added, otherwise Bias is used as offset. +// Blending of a color into target only (bmConstantAlphaAndColor) ignores Source (the DC) and Target (the position). +// CAUTION: This procedure does not check whether MMX instructions are actually available! Call it only if MMX is really +// usable. + +var + Y: Integer; + SourceRun, + TargetRun: PByte; + + SourceBits, + DestBits: Pointer; + SourceWidth, + SourceHeight, + DestWidth, + DestHeight: Integer; + +begin + if not IsRectEmpty(R) then + begin + // Note: it is tempting to optimize the special cases for constant alpha 0 and 255 by just ignoring soure + // (alpha = 0) or simply do a blit (alpha = 255). But this does not take the bias into account. + case Mode of + bmConstantAlpha: + begin + // Get a pointer to the bitmap bits for the source and target device contexts. + // Note: this supposes that both contexts do actually have bitmaps assigned! + SourceBits := GetBitmapBitsFromDeviceContext(Source, SourceWidth, SourceHeight); + DestBits := GetBitmapBitsFromDeviceContext(Destination, DestWidth, DestHeight); + if Assigned(SourceBits) and Assigned(DestBits) then + begin + for Y := 0 to R.Bottom - R.Top - 1 do + begin + SourceRun := CalculateScanline(SourceBits, SourceWidth, SourceHeight, Y + R.Top); + Inc(SourceRun, 4 * R.Left); + TargetRun := CalculateScanline(DestBits, DestWidth, DestHeight, Y + Target.Y); + Inc(TargetRun, 4 * Target.X); + AlphaBlendLineConstant(SourceRun, TargetRun, R.Right - R.Left, ConstantAlpha, Bias); + end; + end; + EMMS; + end; + bmPerPixelAlpha: + begin + SourceBits := GetBitmapBitsFromDeviceContext(Source, SourceWidth, SourceHeight); + DestBits := GetBitmapBitsFromDeviceContext(Destination, DestWidth, DestHeight); + if Assigned(SourceBits) and Assigned(DestBits) then + begin + for Y := 0 to R.Bottom - R.Top - 1 do + begin + SourceRun := CalculateScanline(SourceBits, SourceWidth, SourceHeight, Y + R.Top); + Inc(SourceRun, 4 * R.Left); + TargetRun := CalculateScanline(DestBits, DestWidth, DestHeight, Y + Target.Y); + Inc(TargetRun, 4 * Target.X); + AlphaBlendLinePerPixel(SourceRun, TargetRun, R.Right - R.Left, Bias); + end; + end; + EMMS; + end; + bmMasterAlpha: + begin + SourceBits := GetBitmapBitsFromDeviceContext(Source, SourceWidth, SourceHeight); + DestBits := GetBitmapBitsFromDeviceContext(Destination, DestWidth, DestHeight); + if Assigned(SourceBits) and Assigned(DestBits) then + begin + for Y := 0 to R.Bottom - R.Top - 1 do + begin + SourceRun := CalculateScanline(SourceBits, SourceWidth, SourceHeight, Y + R.Top); + Inc(SourceRun, 4 * Target.X); + TargetRun := CalculateScanline(DestBits, DestWidth, DestHeight, Y + Target.Y); + AlphaBlendLineMaster(SourceRun, TargetRun, R.Right - R.Left, ConstantAlpha, Bias); + end; + end; + EMMS; + end; + bmConstantAlphaAndColor: + begin + // Source is ignored since there is a constant color value. + DestBits := GetBitmapBitsFromDeviceContext(Destination, DestWidth, DestHeight); + if Assigned(DestBits) then + begin + for Y := 0 to R.Bottom - R.Top - 1 do + begin + TargetRun := CalculateScanline(DestBits, DestWidth, DestHeight, Y + R.Top); + Inc(TargetRun, 4 * R.Left); + AlphaBlendLineMasterAndColor(TargetRun, R.Right - R.Left, ConstantAlpha, Bias); + end; + end; + EMMS; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function GetRGBColor(Value: TColor): DWORD; + +// Little helper to convert a Delphi color to an image list color. + +begin + Result := ColorToRGB(Value); + case Result of + clNone: + Result := CLR_NONE; + clDefault: + Result := CLR_DEFAULT; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +const + Grays: array[0..3] of TColor = (clWhite, clSilver, clGray, clBlack); + SysGrays: array[0..3] of TColor = (clWindow, clBtnFace, clBtnShadow, clBtnText); + +procedure ConvertImageList(IL: TImageList; const ImageName: string; ColorRemapping: Boolean = True); + +// Loads a bunch of images given by ImageName into IL. If ColorRemapping = True then a mapping of gray values to +// system colors is performed. + +var + Images, + OneImage: TBitmap; + I: Integer; + MaskColor: TColor; + Source, + Dest: TRect; + +begin + Watcher.Enter; + try + // Since we want the image list appearing in the correct system colors, we have to remap its colors. + Images := TBitmap.Create; + OneImage := TBitmap.Create; + if ColorRemapping then + Images.Handle := CreateMappedRes(FindClassHInstance(TBaseVirtualTree), PChar(ImageName), Grays, SysGrays) + else + Images.Handle := LoadBitmap(FindClassHInstance(TBaseVirtualTree), PChar(ImageName)); + + try + Assert(Images.Height > 0, 'Internal image "' + ImageName + '" is missing or corrupt.'); + + // It is assumed that the image height determines also the width of one entry in the image list. + IL.Clear; + IL.Height := Images.Height; + IL.Width := Images.Height; + OneImage.Width := IL.Width; + OneImage.Height := IL.Height; + MaskColor := Images.Canvas.Pixels[0, 0]; // this is usually clFuchsia + Dest := Rect(0, 0, IL.Width, IL.Height); + for I := 0 to (Images.Width div Images.Height) - 1 do + begin + Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height); + OneImage.Canvas.CopyRect(Dest, Images.Canvas, Source); + IL.AddMasked(OneImage, MaskColor); + end; + finally + Images.Free; + OneImage.Free; + end; + finally + Watcher.Leave; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure CreateSystemImageSet(var IL: TImageList; Flags: Cardinal; Flat: Boolean); + +// Creates a system check image set. +// Note: the DarkCheckImages and FlatImages image lists must already be filled, as some images from them are copied here. + +const + MaskColor: TColor = clRed; + +var + BM: TBitmap; + + //--------------- local functions ------------------------------------------- + + procedure AddNodeImages(IL: TImageList); + + var + I: Integer; + OffsetX, + OffsetY: Integer; + + begin + // The offsets are used to center the node images in case the sizes differ. + OffsetX := (IL.Width - DarkCheckImages.Width) div 2; + OffsetY := (IL.Height - DarkCheckImages.Height) div 2; + for I := 21 to 24 do + begin + BM.Canvas.Brush.Color := MaskColor; + BM.Canvas.FillRect(Rect(0, 0, BM.Width, BM.Height)); + if Flat then + FlatImages.Draw(BM.Canvas, OffsetX, OffsetY, I) + else + DarkCheckImages.Draw(BM.Canvas, OffsetX, OffsetY, I); + IL.AddMasked(BM, MaskColor); + end; + end; + + //--------------------------------------------------------------------------- + + procedure AddSystemImage(IL: TImageList; Index: Integer); + + var + ButtonState: Cardinal; + ButtonType: Cardinal; + + begin + BM.Canvas.Brush.Color := MaskColor; + BM.Canvas.FillRect(Rect(0, 0, BM.Width, BM.Height)); + if Index < 8 then + ButtonType := DFCS_BUTTONRADIO + else + ButtonType := DFCS_BUTTONCHECK; + if Index >= 16 then + ButtonType := ButtonType or DFCS_BUTTON3STATE; + + case Index mod 4 of + 0: + ButtonState := 0; + 1: + ButtonState := DFCS_HOT; + 2: + ButtonState := DFCS_PUSHED; + else + ButtonState := DFCS_INACTIVE; + end; + if Index in [4..7, 12..19] then + ButtonState := ButtonState or DFCS_CHECKED; + if Flat then + ButtonState := ButtonState or DFCS_FLAT; + DrawFrameControl(BM.Canvas.Handle, Rect(1, 2, BM.Width - 2, BM.Height - 1), DFC_BUTTON, ButtonType or ButtonState); + IL.AddMasked(BM, MaskColor); + end; + + //--------------- end local functions --------------------------------------- + +var + I, Width, Height: Integer; + +begin + Width := GetSystemMetrics(SM_CXMENUCHECK) + 3; + Height := GetSystemMetrics(SM_CYMENUCHECK) + 3; + IL := TImageList.CreateSize(Width, Height); + with IL do + Handle := ImageList_Create(Width, Height, Flags, 0, AllocBy); + IL.Masked := True; + IL.BkColor := clWhite; + + // Create a temporary bitmap, which holds the intermediate images. + BM := TBitmap.Create; + try + // Make the bitmap the same size as the image list is to avoid problems when adding. + BM.Width := IL.Width; + BM.Height := IL.Height; + BM.Canvas.Brush.Color := MaskColor; + BM.Canvas.Brush.Style := bsSolid; + BM.Canvas.FillRect(Rect(0, 0, BM.Width, BM.Height)); + IL.AddMasked(BM, MaskColor); + + // Add the 20 system checkbox and radiobutton images. + for I := 0 to 19 do + AddSystemImage(IL, I); + // Add the 4 node images from the dark check set. + AddNodeImages(IL); + + finally + BM.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function HasMMX: Boolean; + +// Helper method to determine whether the current processor supports MMX. + +{$ifdef CPUX64} +begin + // We use SSE2 in the "MMX-functions" + Result := True; +end; +{$else} +asm + PUSH EBX + XOR EAX, EAX // Result := False + PUSHFD // determine if the processor supports the CPUID command + POP EDX + MOV ECX, EDX + XOR EDX, $200000 + PUSH EDX + POPFD + PUSHFD + POP EDX + XOR ECX, EDX + JZ @1 // no CPUID support so we can't even get to the feature information + PUSH EDX + POPFD + + MOV EAX, 1 + DW $A20F // CPUID, EAX contains now version info and EDX feature information + MOV EBX, EAX // free EAX to get the result value + XOR EAX, EAX // Result := False + CMP EBX, $50 + JB @1 // if processor family is < 5 then it is not a Pentium class processor + TEST EDX, $800000 + JZ @1 // if the MMX bit is not set then we don't have MMX + INC EAX // Result := True +@1: + POP EBX +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure PrtStretchDrawDIB(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap); + +// Stretch draw on to the new canvas. + +var + Header, + Bits: Pointer; + HeaderSize, + BitsSize: Cardinal; + +begin + GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize); + + GetMem(Header, HeaderSize); + GetMem(Bits, BitsSize); + try + GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^); + StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top, DestRect.Right - DestRect.Left, DestRect.Bottom - + DestRect.Top, 0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo(Header^), DIB_RGB_COLORS, SRCCOPY); + finally + FreeMem(Header); + FreeMem(Bits); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure ClipCanvas(Canvas: TCanvas; ClipRect: TRect; VisibleRegion: HRGN = 0); + +// Clip a given canvas to ClipRect while transforming the given rect to device coordinates. + +var + ClipRegion: HRGN; + +begin + // Regions expect their coordinates in device coordinates, hence we have to transform the region rectangle. + LPtoDP(Canvas.Handle, ClipRect, 2); + ClipRegion := CreateRectRgnIndirect(ClipRect); + if VisibleRegion <> 0 then + CombineRgn(ClipRegion, ClipRegion, VisibleRegion, RGN_AND); + SelectClipRgn(Canvas.Handle, ClipRegion); + DeleteObject(ClipRegion); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure SetCanvasOrigin(Canvas: TCanvas; X, Y: Integer); + +// Set the coordinate space origin of a given canvas. + +var + P: TPoint; + +begin + // Reset origin as otherwise we would accumulate the origin shifts when calling LPtoDP. + SetWindowOrgEx(Canvas.Handle, 0, 0, nil); + + // The shifting is expected in physical points, so we have to transform them accordingly. + P := Point(X, Y); + LPtoDP(Canvas.Handle, P, 1); + + // Do the shift. + SetWindowOrgEx(Canvas.Handle, P.X, P.Y, nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure SetBrushOrigin(Canvas: TCanvas; X, Y: Integer); + +// Set the brush origin of a given canvas. + +var + P: TPoint; + +begin + P := Point(X, Y); + LPtoDP(Canvas.Handle, P, 1); + SetBrushOrgEx(Canvas.Handle, P.X, P.Y, nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure InitializeGlobalStructures; + +// initialization of stuff global to the unit + +var + Flags: Cardinal; + +begin + Initialized := True; + + // For the drag image a fast MMX blend routine is used. We have to make sure MMX is available. + MMXAvailable := HasMMX; + IsWinVistaOrAbove := (Win32MajorVersion >= 6); + + // Initialize OLE subsystem for drag'n drop and clipboard operations. + NeedToUnitialize := Succeeded(OleInitialize(nil)); + + // Register the tree reference clipboard format. Others will be handled in InternalClipboarFormats. + CF_VTREFERENCE := RegisterClipboardFormat(CFSTR_VTREFERENCE); + + // Load all internal image lists and convert their colors to current desktop color scheme. + // In order to use high color images we have to create the image list handle ourselves. + Flags := ILC_COLOR32 or ILC_MASK; + LightCheckImages := TImageList.Create(nil); + with LightCheckImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(LightCheckImages, 'VT_CHECK_LIGHT'); + + DarkCheckImages := TImageList.CreateSize(16, 16); + with DarkCheckImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(DarkCheckImages, 'VT_CHECK_DARK'); + + LightTickImages := TImageList.CreateSize(16, 16); + with LightTickImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(LightTickImages, 'VT_TICK_LIGHT'); + + DarkTickImages := TImageList.CreateSize(16, 16); + with DarkTickImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(DarkTickImages, 'VT_TICK_DARK'); + + FlatImages := TImageList.CreateSize(16, 16); + with FlatImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(FlatImages, 'VT_FLAT'); + + XPImages := TImageList.CreateSize(16, 16); + with XPImages do + Handle := ImageList_Create(16, 16, Flags, 0, AllocBy); + ConvertImageList(XPImages, 'VT_XP', False); + + UtilityImages := TImageList.CreateSize(UtilityImageSize, UtilityImageSize); + with UtilityImages do + Handle := ImageList_Create(UtilityImageSize, UtilityImageSize, Flags, 0, AllocBy); + ConvertImageList(UtilityImages, 'VT_UTILITIES'); + + CreateSystemImageSet(SystemCheckImages, Flags, False); + CreateSystemImageSet(SystemFlatCheckImages, Flags, True); + + // Specify an useful timer resolution for timeGetTime. + timeBeginPeriod(MinimumTimerInterval); + + // Delphi (at least version 6 and lower) does not provide a standard split cursor. + // Hence we have to load our own. + Screen.Cursors[crHeaderSplit] := LoadCursor(HInstance, 'VT_HEADERSPLIT'); + Screen.Cursors[crVertSplit] := LoadCursor(HInstance, 'VT_VERTSPLIT'); + + // Clipboard format registration. + // Native clipboard format. Needs a new identifier and has an average priority to allow other formats to take over. + // This format is supposed to use the IStream storage format but unfortunately this does not work when + // OLEFlushClipboard is used. Hence it is disabled until somebody finds a solution. + CF_VIRTUALTREE := RegisterVTClipboardFormat(CFSTR_VIRTUALTREE, TBaseVirtualTree, 50, TYMED_HGLOBAL {or TYMED_ISTREAM}); + // Specialized string tree formats. + CF_HTML := RegisterVTClipboardFormat(CFSTR_HTML, TCustomVirtualStringTree, 80); + CF_VRTFNOOBJS := RegisterVTClipboardFormat(CFSTR_RTFNOOBJS, TCustomVirtualStringTree, 84); + CF_VRTF := RegisterVTClipboardFormat(CFSTR_RTF, TCustomVirtualStringTree, 85); + CF_CSV := RegisterVTClipboardFormat(CFSTR_CSV, TCustomVirtualStringTree, 90); + // Predefined clipboard formats. Just add them to the internal list. + RegisterVTClipboardFormat(CF_TEXT, TCustomVirtualStringTree, 100); + RegisterVTClipboardFormat(CF_UNICODETEXT, TCustomVirtualStringTree, 95); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure FinalizeGlobalStructures; + +var + HintWasEnabled: Boolean; + +begin + timeEndPeriod(MinimumTimerInterval); + + LightCheckImages.Free; + LightCheckImages := nil; + DarkCheckImages.Free; + DarkCheckImages := nil; + LightTickImages.Free; + LightTickImages := nil; + DarkTickImages.Free; + DarkTickImages := nil; + FlatImages.Free; + FlatImages := nil; + XPImages.Free; + XPImages := nil; + UtilityImages.Free; + UtilityImages := nil; + SystemCheckImages.Free; + SystemCheckImages := nil; + SystemFlatCheckImages.Free; + SystemFlatCheckImages := nil; + + if NeedToUnitialize then + OleUninitialize; + + // If VT is used in a package and its special hint window was used then the last instance of this + // window is not freed correctly (bug in the VCL). We explicitely tell the application to free it + // otherwise an AV is raised due to access to an invalid memory area. + if ModuleIsPackage then + begin + HintWasEnabled := Application.ShowHint; + Application.ShowHint := False; + if HintWasEnabled then + Application.ShowHint := True; + end; +end; + +//----------------- TCriticalSection ----------------------------------------------------------------------------------- + +constructor TCriticalSection.Create; + +begin + inherited Create; + InitializeCriticalSection(FSection); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TCriticalSection.Destroy; + +begin + DeleteCriticalSection(FSection); + + inherited Destroy; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCriticalSection.Enter; + +begin + EnterCriticalSection(FSection); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCriticalSection.Leave; + +begin + LeaveCriticalSection(FSection); +end; + +//----------------- TWorkerThread -------------------------------------------------------------------------------------- + +procedure AddThreadReference; +begin + if not Assigned(WorkerThread) then + begin + // Create an event used to trigger our worker thread when something is to do. + WorkEvent := CreateEvent(nil, False, False, nil); + if WorkEvent = 0 then + RaiseLastOSError; + + // Create worker thread, initialize it and send it to its wait loop. + WorkerThread := TWorkerThread.Create(False); + end; + Inc(WorkerThread.FRefCount); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure ReleaseThreadReference(Tree: TBaseVirtualTree); + +begin + if Assigned(WorkerThread) then + begin + Dec(WorkerThread.FRefCount); + + // Make sure there is no reference remaining to the releasing tree. + Tree.InterruptValidation; + + if WorkerThread.FRefCount = 0 then + begin + with WorkerThread do + begin + Terminate; + SetEvent(WorkEvent); + end; + FreeAndNil(WorkerThread); + CloseHandle(WorkEvent); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +constructor TWorkerThread.Create(CreateSuspended: Boolean); + +begin + inherited Create(CreateSuspended); + FWaiterList := TThreadList.Create; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TWorkerThread.Destroy; + +begin + // First let the ancestor stop the thread before freeing our resources. + inherited; + + FWaiterList.Free; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWorkerThread.CancelValidation(Tree: TBaseVirtualTree); + +var + Msg: TMsg; + +begin + // Wait for any references to this tree to be released. + // Pump WM_CHANGESTATE messages so the thread doesn't block on SendMessage calls. + while FCurrentTree = Tree do + begin + if Tree.HandleAllocated and PeekMessage(Msg, Tree.Handle, WM_CHANGESTATE, WM_CHANGESTATE, PM_REMOVE) then + begin + TranslateMessage(Msg); + DispatchMessage(Msg); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWorkerThread.ChangeTreeStates(EnterStates, LeaveStates: TChangeStates); + +begin + if Assigned(FCurrentTree) and (FCurrentTree.HandleAllocated) then + SendMessage(FCurrentTree.Handle, WM_CHANGESTATE, Byte(EnterStates), Byte(LeaveStates)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWorkerThread.Execute; + +// Does some background tasks, like validating tree caches. + +var + EnterStates, + LeaveStates: TChangeStates; + +begin + while not Terminated do + begin + WaitForSingleObject(WorkEvent, INFINITE); + if not Terminated then + begin + // Get the next waiting tree. + with FWaiterList.LockList do + try + if Count > 0 then + begin + FCurrentTree := Items[0]; + // Remove this tree from waiter list. + Delete(0); + // If there is yet another tree to work on then set the work event to keep looping. + if Count > 0 then + SetEvent(WorkEvent); + end + else + FCurrentTree := nil; + finally + FWaiterList.UnlockList; + end; + + // Something to do? + if Assigned(FCurrentTree) then + begin + try + ChangeTreeStates([csValidating], [csUseCache]); + EnterStates := []; + if not (tsStopValidation in FCurrentTree.FStates) and FCurrentTree.DoValidateCache then + EnterStates := [csUseCache]; + + finally + LeaveStates := [csValidating, csStopValidation]; + if csUseCache in EnterStates then + Include(LeaveStates, csValidationNeeded); + ChangeTreeStates(EnterStates, LeaveStates); + FCurrentTree := nil; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWorkerThread.AddTree(Tree: TBaseVirtualTree); + +begin + Assert(Assigned(Tree), 'Tree must not be nil.'); + + // Remove validation stop flag, just in case it is still set. + Tree.DoStateChange([], [tsStopValidation]); + with FWaiterList.LockList do + try + if IndexOf(Tree) = -1 then + Add(Tree); + finally + FWaiterList.UnlockList; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWorkerThread.RemoveTree(Tree: TBaseVirtualTree); + +begin + Assert(Assigned(Tree), 'Tree must not be nil.'); + + with FWaiterList.LockList do + try + Remove(Tree); + finally + FWaiterList.UnlockList; // Seen several AVs in this line, was called from TWorkerThrea.Destroy. Joachim Marder. + end; + CancelValidation(Tree); +end; + +//----------------- TBufferedAnsiString ------------------------------------------------------------------------------------ + +const + AllocIncrement = 2 shl 11; // Must be a power of 2. + +destructor TBufferedAnsiString.Destroy; + +begin + FreeMem(FStart); + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBufferedAnsiString.GetAsString: AnsiString; + +begin + SetString(Result, FStart, FPosition - FStart); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBufferedAnsiString.Add(const S: AnsiString); + +var + NewLen, + LastOffset, + Len: Integer; + +begin + Len := Length(S); + // Make room for the new string. + if FEnd - FPosition <= Len then + begin + // Round up NewLen so it is always a multiple of AllocIncrement. + NewLen := FEnd - FStart + (Len + AllocIncrement - 1) and not (AllocIncrement - 1); + // Keep last offset to restore it correctly in the case that FStart gets a new memory block assigned. + LastOffset := FPosition - FStart; + ReallocMem(FStart, NewLen); + FPosition := FStart + LastOffset; + FEnd := FStart + NewLen; + end; + Move(PAnsiChar(S)^, FPosition^, Len); + Inc(FPosition, Len); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBufferedAnsiString.AddNewLine; + +var + NewLen, + LastOffset: Integer; + +begin + // Make room for the CR/LF characters. + if FEnd - FPosition <= 2 then + begin + // Round up NewLen so it is always a multiple of AllocIncrement. + NewLen := FEnd - FStart + (2 + AllocIncrement - 1) and not (AllocIncrement - 1); + // Keep last offset to restore it correctly in the case that FStart gets a new memory block assigned. + LastOffset := FPosition - FStart; + ReallocMem(FStart, NewLen); + FPosition := FStart + LastOffset; + FEnd := FStart + NewLen; + end; + FPosition^ := #13; + Inc(FPosition); + FPosition^ := #10; + Inc(FPosition); +end; + +//----------------- TWideBufferedString -------------------------------------------------------------------------------- + +destructor TWideBufferedString.Destroy; + +begin + FreeMem(FStart); + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TWideBufferedString.GetAsString: UnicodeString; + +begin + SetString(Result, FStart, FPosition - FStart); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWideBufferedString.Add(const S: UnicodeString); + +var + NewLen, + LastOffset, + Len: Integer; + +begin + Len := Length(S); + // Make room for the new string. + if FEnd - FPosition <= Len then + begin + // Round up NewLen so it is always a multiple of AllocIncrement. + NewLen := FEnd - FStart + (Len + AllocIncrement - 1) and not (AllocIncrement - 1); + // Keep last offset to restore it correctly in the case that FStart gets a new memory block assigned. + LastOffset := FPosition - FStart; + ReallocMem(FStart, 2 * NewLen); + FPosition := FStart + LastOffset; + FEnd := FStart + NewLen; + end; + Move(PWideChar(S)^, FPosition^, 2 * Len); + Inc(FPosition, Len); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TWideBufferedString.AddNewLine; + +var + NewLen, + LastOffset: Integer; + +begin + // Make room for the CR/LF characters. + if FEnd - FPosition <= 4 then + begin + // Round up NewLen so it is always a multiple of AllocIncrement. + NewLen := FEnd - FStart + (2 + AllocIncrement - 1) and not (AllocIncrement - 1); + // Keep last offset to restore it correctly in the case that FStart gets a new memory block assigned. + LastOffset := FPosition - FStart; + ReallocMem(FStart, 2 * NewLen); + FPosition := FStart + LastOffset; + FEnd := FStart + NewLen; + end; + FPosition^ := #13; + Inc(FPosition); + FPosition^ := #10; + Inc(FPosition); +end; + +//----------------- TCustomVirtualTreeOptions -------------------------------------------------------------------------- + +constructor TCustomVirtualTreeOptions.Create(AOwner: TBaseVirtualTree); + +begin + FOwner := AOwner; + + FPaintOptions := DefaultPaintOptions; + FAnimationOptions := DefaultAnimationOptions; + FAutoOptions := DefaultAutoOptions; + FSelectionOptions := DefaultSelectionOptions; + FMiscOptions := DefaultMiscOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.SetAnimationOptions(const Value: TVTAnimationOptions); + +begin + FAnimationOptions := Value; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.SetAutoOptions(const Value: TVTAutoOptions); + +var + ChangedOptions: TVTAutoOptions; + +begin + if FAutoOptions <> Value then + begin + // Exclusive ORing to get all entries wich are in either set but not in both. + ChangedOptions := FAutoOptions + Value - (FAutoOptions * Value); + FAutoOptions := Value; + with FOwner do + if (toAutoSpanColumns in ChangedOptions) and not (csLoading in ComponentState) and HandleAllocated then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.SetMiscOptions(const Value: TVTMiscOptions); + +var + ToBeSet, + ToBeCleared: TVTMiscOptions; + +begin + if FMiscOptions <> Value then + begin + ToBeSet := Value - FMiscOptions; + ToBeCleared := FMiscOptions - Value; + FMiscOptions := Value; + + with FOwner do + if not (csLoading in ComponentState) and HandleAllocated then + begin + if toCheckSupport in ToBeSet + ToBeCleared then + Invalidate; + if not (csDesigning in ComponentState) then + begin + if toFullRepaintOnResize in TobeSet + ToBeCleared then + RecreateWnd; + if toAcceptOLEDrop in ToBeSet then + RegisterDragDrop(Handle, DragManager as IDropTarget); + if toAcceptOLEDrop in ToBeCleared then + RevokeDragDrop(Handle); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.SetPaintOptions(const Value: TVTPaintOptions); + +var + ToBeSet, + ToBeCleared: TVTPaintOptions; + Run: PVirtualNode; + HandleWasAllocated: Boolean; + +begin + if FPaintOptions <> Value then + begin + ToBeSet := Value - FPaintOptions; + ToBeCleared := FPaintOptions - Value; + FPaintOptions := Value; + with FOwner do + begin + HandleWasAllocated := HandleAllocated; + + if not (csLoading in ComponentState) and (toShowFilteredNodes in ToBeSet + ToBeCleared) then + begin + if HandleWasAllocated then + BeginUpdate; + InterruptValidation; + Run := GetFirstNoInit; + while Assigned(Run) do + begin + if (vsFiltered in Run.States) then + begin + if FullyVisible[Run] then + begin + if toShowFilteredNodes in ToBeSet then + Inc(FVisibleCount) + else + Dec(FVisibleCount); + end; + if toShowFilteredNodes in ToBeSet then + AdjustTotalHeight(Run, Run.NodeHeight, True) + else + AdjustTotalHeight(Run, -Run.NodeHeight, True); + end; + Run := GetNextNoInit(Run); + end; + if HandleWasAllocated then + EndUpdate; + end; + + if HandleAllocated then + begin + if IsWinVistaOrAbove and ((tsUseThemes in FStates) or + ((toThemeAware in ToBeSet) and ThemeServices.ThemesEnabled)) and + (toUseExplorerTheme in (ToBeSet + ToBeCleared)) then + if toUseExplorerTheme in ToBeSet then + begin + SetWindowTheme(Handle, 'explorer', nil); + DoStateChange([tsUseExplorerTheme]); + end + else + if toUseExplorerTheme in ToBeCleared then + begin + SetWindowTheme(Handle, '', nil); + DoStateChange([], [tsUseExplorerTheme]); + end; + + if not (csLoading in ComponentState) then + begin + if (toThemeAware in ToBeSet + ToBeCleared) or (toUseExplorerTheme in ToBeSet + ToBeCleared) then + begin + if (toThemeAware in ToBeSet) and ThemeServices.ThemesEnabled then + DoStateChange([tsUseThemes]) + else + if (toThemeAware in ToBeCleared) then + DoStateChange([], [tsUseThemes]); + + PrepareBitmaps(True, False); + RedrawWindow(Handle, nil, 0, RDW_INVALIDATE or RDW_VALIDATE or RDW_FRAME); + end; + + if toChildrenAbove in ToBeSet + ToBeCleared then + begin + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + Invalidate; + end; + end; + + Invalidate; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.SetSelectionOptions(const Value: TVTSelectionOptions); + +var + ToBeSet, + ToBeCleared: TVTSelectionOptions; + +begin + if FSelectionOptions <> Value then + begin + ToBeSet := Value - FSelectionOptions; + ToBeCleared := FSelectionOptions - Value; + FSelectionOptions := Value; + + with FOwner do + begin + if (toMultiSelect in (ToBeCleared + ToBeSet)) or + ([toLevelSelectConstraint, toSiblingSelectConstraint] * ToBeSet <> []) then + ClearSelection; + + if (toExtendedFocus in ToBeCleared) and (FFocusedColumn > 0) and HandleAllocated then + begin + FFocusedColumn := FHeader.MainColumn; + Invalidate; + end; + + if not (toExtendedFocus in FSelectionOptions) then + FFocusedColumn := FHeader.MainColumn; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualTreeOptions.AssignTo(Dest: TPersistent); + +begin + if Dest is TCustomVirtualTreeOptions then + begin + with Dest as TCustomVirtualTreeOptions do + begin + PaintOptions := Self.PaintOptions; + AnimationOptions := Self.AnimationOptions; + AutoOptions := Self.AutoOptions; + SelectionOptions := Self.SelectionOptions; + MiscOptions := Self.MiscOptions; + end; + end + else + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +// OLE drag and drop support classes +// This is quite heavy stuff (compared with the VCL implementation) but is much better suited to fit the needs +// of DD'ing various kinds of virtual data and works also between applications. + +//----------------- TEnumFormatEtc ------------------------------------------------------------------------------------- + +constructor TEnumFormatEtc.Create(Tree: TBaseVirtualTree; AFormatEtcArray: TFormatEtcArray); + +var + I: Integer; + +begin + inherited Create; + + FTree := Tree; + // Make a local copy of the format data. + SetLength(FFormatEtcArray, Length(AFormatEtcArray)); + for I := 0 to High(AFormatEtcArray) do + FFormatEtcArray[I] := AFormatEtcArray[I]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TEnumFormatEtc.Clone(out Enum: IEnumFormatEtc): HResult; + +var + AClone: TEnumFormatEtc; + +begin + Result := S_OK; + try + AClone := TEnumFormatEtc.Create(nil, FFormatEtcArray); + AClone.FCurrentIndex := FCurrentIndex; + Enum := AClone as IEnumFormatEtc; + except + Result := E_FAIL; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TEnumFormatEtc.Next(celt: Integer; out elt; pceltFetched: PLongint): HResult; + +var + CopyCount: Integer; + +begin + Result := S_FALSE; + CopyCount := Length(FFormatEtcArray) - FCurrentIndex; + if celt < CopyCount then + CopyCount := celt; + if CopyCount > 0 then + begin + Move(FFormatEtcArray[FCurrentIndex], elt, CopyCount * SizeOf(TFormatEtc)); + Inc(FCurrentIndex, CopyCount); + Result := S_OK; + end; + if Assigned(pceltFetched) then + pceltFetched^ := CopyCount; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TEnumFormatEtc.Reset: HResult; + +begin + FCurrentIndex := 0; + Result := S_OK; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TEnumFormatEtc.Skip(celt: Integer): HResult; + +begin + if FCurrentIndex + celt < High(FFormatEtcArray) then + begin + Inc(FCurrentIndex, celt); + Result := S_Ok; + end + else + Result := S_FALSE; +end; + +//----------------- TVTDataObject -------------------------------------------------------------------------------------- + +constructor TVTDataObject.Create(AOwner: TBaseVirtualTree; ForClipboard: Boolean); + +begin + inherited Create; + + FOwner := AOwner; + FForClipboard := ForClipboard; + FOwner.GetNativeClipboardFormats(FFormatEtcArray); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVTDataObject.Destroy; + +var + I: Integer; + StgMedium: PStgMedium; + +begin + // Cancel a pending clipboard operation if this data object was created for the clipboard and + // is freed because something else is placed there. + if FForClipboard and not (tsClipboardFlushing in FOwner.FStates) then + FOwner.CancelCutOrCopy; + + // Release any internal clipboard formats + for I := 0 to High(FormatEtcArray) do + begin + StgMedium := FindInternalStgMedium(FormatEtcArray[I].cfFormat); + if Assigned(StgMedium) then + ReleaseStgMedium(StgMedium^); + end; + + FormatEtcArray := nil; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.CanonicalIUnknown(TestUnknown: IUnknown): IUnknown; + +// Uses COM object identity: An explicit call to the IUnknown::QueryInterface method, requesting the IUnknown +// interface, will always return the same pointer. + +begin + if Assigned(TestUnknown) then + begin + if TestUnknown.QueryInterface(IUnknown, Result) = 0 then + Result._Release // Don't actually need it just need the pointer value + else + Result := TestUnknown + end + else + Result := TestUnknown +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.EqualFormatEtc(FormatEtc1, FormatEtc2: TFormatEtc): Boolean; + +begin + Result := (FormatEtc1.cfFormat = FormatEtc2.cfFormat) and (FormatEtc1.ptd = FormatEtc2.ptd) and + (FormatEtc1.dwAspect = FormatEtc2.dwAspect) and (FormatEtc1.lindex = FormatEtc2.lindex) and + (FormatEtc1.tymed and FormatEtc2.tymed <> 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.FindFormatEtc(TestFormatEtc: TFormatEtc; const FormatEtcArray: TFormatEtcArray): integer; + +var + I: integer; + +begin + Result := -1; + for I := 0 to High(FormatEtcArray) do + begin + if EqualFormatEtc(TestFormatEtc, FormatEtcArray[I]) then + begin + Result := I; + Break; + end + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.FindInternalStgMedium(Format: TClipFormat): PStgMedium; + +var + I: integer; +begin + Result := nil; + for I := 0 to High(InternalStgMediumArray) do + begin + if Format = InternalStgMediumArray[I].Format then + begin + Result := @InternalStgMediumArray[I].Medium; + Break; + end + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.HGlobalClone(HGlobal: THandle): THandle; + +// Returns a global memory block that is a copy of the passed memory block. + +var + Size: Cardinal; + Data, + NewData: PByte; + +begin + Size := GlobalSize(HGlobal); + Result := GlobalAlloc(GPTR, Size); + Data := GlobalLock(hGlobal); + try + NewData := GlobalLock(Result); + try + Move(Data^, NewData^, Size); + finally + GlobalUnLock(Result); + end + finally + GlobalUnLock(hGlobal); + end +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.RenderInternalOLEData(const FormatEtcIn: TFormatEtc; var Medium: TStgMedium; + var OLEResult: HResult): Boolean; + +// Tries to render one of the formats which have been stored via the SetData method. +// Since this data is already there it is just copied or its reference count is increased (depending on storage medium). + +var + InternalMedium: PStgMedium; + +begin + Result := True; + InternalMedium := FindInternalStgMedium(FormatEtcIn.cfFormat); + if Assigned(InternalMedium) then + OLEResult := StgMediumIncRef(InternalMedium^, Medium, False, Self as IDataObject) + else + Result := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.StgMediumIncRef(const InStgMedium: TStgMedium; var OutStgMedium: TStgMedium; + CopyInMedium: Boolean; DataObject: IDataObject): HRESULT; + +// InStgMedium is the data that is requested, OutStgMedium is the data that we are to return either a copy of or +// increase the IDataObject's reference and send ourselves back as the data (unkForRelease). The InStgMedium is usually +// the result of a call to find a particular FormatEtc that has been stored locally through a call to SetData. +// If CopyInMedium is not true we already have a local copy of the data when the SetData function was called (during +// that call the CopyInMedium must be true). Then as the caller asks for the data through GetData we do not have to make +// copy of the data for the caller only to have them destroy it then need us to copy it again if necessary. +// This way we increase the reference count to ourselves and pass the STGMEDIUM structure initially stored in SetData. +// This way when the caller frees the structure it sees the unkForRelease is not nil and calls Release on the object +// instead of destroying the actual data. + +var + Len: Integer; + +begin + Result := S_OK; + + // Simply copy all fields to start with. + OutStgMedium := InStgMedium; + // The data handled here always results from a call of SetData we got. This ensures only one storage format + // is indicated and hence the case statement below is safe (IDataObject.GetData can optionally use several + // storage formats). + case InStgMedium.tymed of + TYMED_HGLOBAL: + begin + if CopyInMedium then + begin + // Generate a unique copy of the data passed + OutStgMedium.hGlobal := HGlobalClone(InStgMedium.hGlobal); + if OutStgMedium.hGlobal = 0 then + Result := E_OUTOFMEMORY + end + else + // Don't generate a copy just use ourselves and the copy previously saved. + OutStgMedium.unkForRelease := Pointer(DataObject); // Does not increase RefCount. + end; + TYMED_FILE: + begin + Len := lstrLenW(InStgMedium.lpszFileName) + 1; // Don't forget the terminating null character. + OutStgMedium.lpszFileName := CoTaskMemAlloc(2 * Len); + Move(InStgMedium.lpszFileName^, OutStgMedium.lpszFileName^, 2 * Len); + end; + TYMED_ISTREAM: + IUnknown(OutStgMedium.stm)._AddRef; + TYMED_ISTORAGE: + IUnknown(OutStgMedium.stg)._AddRef; + TYMED_GDI: + if not CopyInMedium then + // Don't generate a copy just use ourselves and the previously saved data. + OutStgMedium.unkForRelease := Pointer(DataObject) // Does not increase RefCount. + else + Result := DV_E_TYMED; // Don't know how to copy GDI objects right now. + TYMED_MFPICT: + if not CopyInMedium then + // Don't generate a copy just use ourselves and the previously saved data. + OutStgMedium.unkForRelease := Pointer(DataObject) // Does not increase RefCount. + else + Result := DV_E_TYMED; // Don't know how to copy MetaFile objects right now. + TYMED_ENHMF: + if not CopyInMedium then + // Don't generate a copy just use ourselves and the previously saved data. + OutStgMedium.unkForRelease := Pointer(DataObject) // Does not increase RefCount. + else + Result := DV_E_TYMED; // Don't know how to copy enhanced metafiles objects right now. + else + Result := DV_E_TYMED; + end; + + if (Result = S_OK) and Assigned(OutStgMedium.unkForRelease) then + IUnknown(OutStgMedium.unkForRelease)._AddRef; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.DAdvise(const FormatEtc: TFormatEtc; advf: Integer; const advSink: IAdviseSink; + out dwConnection: Integer): HResult; + +// Advise sink management is greatly simplified by the IDataAdviseHolder interface. +// We use this interface and forward all concerning calls to it. + +begin + Result := S_OK; + if FAdviseHolder = nil then + Result := CreateDataAdviseHolder(FAdviseHolder); + if Result = S_OK then + Result := FAdviseHolder.Advise(Self as IDataObject, FormatEtc, advf, advSink, dwConnection); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.DUnadvise(dwConnection: Integer): HResult; + +begin + if FAdviseHolder = nil then + Result := E_NOTIMPL + else + Result := FAdviseHolder.Unadvise(dwConnection); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.EnumDAdvise(out enumAdvise: IEnumStatData): HResult; + +begin + if FAdviseHolder = nil then + Result := OLE_E_ADVISENOTSUPPORTED + else + Result := FAdviseHolder.EnumAdvise(enumAdvise); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.EnumFormatEtc(Direction: Integer; out EnumFormatEtc: IEnumFormatEtc): HResult; + +var + NewList: TEnumFormatEtc; + +begin + Result := E_FAIL; + if Direction = DATADIR_GET then + begin + NewList := TEnumFormatEtc.Create(FOwner, FormatEtcArray); + EnumFormatEtc := NewList as IEnumFormatEtc; + Result := S_OK; + end + else + EnumFormatEtc := nil; + if EnumFormatEtc = nil then + Result := OLE_S_USEREG; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.GetCanonicalFormatEtc(const FormatEtc: TFormatEtc; out FormatEtcOut: TFormatEtc): HResult; + +begin + Result := DATA_S_SAMEFORMATETC; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.GetData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium): HResult; + +// Data is requested by clipboard or drop target. This method dispatchs the call +// depending on the data being requested. + +var + I: Integer; + Data: PVTReference; + +begin + // The tree reference format is always supported and returned from here. + if FormatEtcIn.cfFormat = CF_VTREFERENCE then + begin + // Note: this format is not used while flushing the clipboard to avoid a dangling reference + // when the owner tree is destroyed before the clipboard data is replaced with something else. + if tsClipboardFlushing in FOwner.FStates then + Result := E_FAIL + else + begin + Medium.hGlobal := GlobalAlloc(GHND or GMEM_SHARE, SizeOf(TVTReference)); + Data := GlobalLock(Medium.hGlobal); + Data.Process := GetCurrentProcessID; + Data.Tree := FOwner; + GlobalUnlock(Medium.hGlobal); + Medium.tymed := TYMED_HGLOBAL; + Medium.unkForRelease := nil; + Result := S_OK; + end; + end + else + begin + try + // See if we accept this type and if not get the correct return value. + Result := QueryGetData(FormatEtcIn); + if Result = S_OK then + begin + for I := 0 to High(FormatEtcArray) do + begin + if EqualFormatEtc(FormatEtcIn, FormatEtcArray[I]) then + begin + if not RenderInternalOLEData(FormatEtcIn, Medium, Result) then + Result := FOwner.RenderOLEData(FormatEtcIn, Medium, FForClipboard); + Break; + end; + end + end + except + ZeroMemory (@Medium, SizeOf(Medium)); + Result := E_FAIL; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.GetDataHere(const FormatEtc: TFormatEtc; out Medium: TStgMedium): HResult; + +begin + Result := E_NOTIMPL; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.QueryGetData(const FormatEtc: TFormatEtc): HResult; + +var + I: Integer; + +begin + Result := DV_E_CLIPFORMAT; + for I := 0 to High(FFormatEtcArray) do + begin + if FormatEtc.cfFormat = FFormatEtcArray[I].cfFormat then + begin + if (FormatEtc.tymed and FFormatEtcArray[I].tymed) <> 0 then + begin + if FormatEtc.dwAspect = FFormatEtcArray[I].dwAspect then + begin + if FormatEtc.lindex = FFormatEtcArray[I].lindex then + begin + Result := S_OK; + Break; + end + else + Result := DV_E_LINDEX; + end + else + Result := DV_E_DVASPECT; + end + else + Result := DV_E_TYMED; + end; + end +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDataObject.SetData(const FormatEtc: TFormatEtc; var Medium: TStgMedium; DoRelease: BOOL): HResult; + +// Allows dynamic adding to the IDataObject during its existance. Most noteably it is used to implement +// IDropSourceHelper and allows to set a special format for optimized moves during a shell transfer. + +var + Index: Integer; + LocalStgMedium: PStgMedium; + +begin + // See if we already have a format of that type available. + Index := FindFormatEtc(FormatEtc, FormatEtcArray); + if Index > - 1 then + begin + // Just use the TFormatEct in the array after releasing the data. + LocalStgMedium := FindInternalStgMedium(FormatEtcArray[Index].cfFormat); + if Assigned(LocalStgMedium) then + begin + ReleaseStgMedium(LocalStgMedium^); + ZeroMemory(LocalStgMedium, SizeOf(LocalStgMedium^)); + end; + end + else + begin + // It is a new format so create a new TFormatCollectionItem, copy the + // FormatEtc parameter into the new object and and put it in the list. + SetLength(FFormatEtcArray, Length(FormatEtcArray) + 1); + FormatEtcArray[High(FormatEtcArray)] := FormatEtc; + + // Create a new InternalStgMedium and initialize it and associate it with the format. + SetLength(FInternalStgMediumArray, Length(InternalStgMediumArray) + 1); + InternalStgMediumArray[High(InternalStgMediumArray)].Format := FormatEtc.cfFormat; + LocalStgMedium := @InternalStgMediumArray[High(InternalStgMediumArray)].Medium; + ZeroMemory(LocalStgMedium, SizeOf(LocalStgMedium^)); + end; + + if DoRelease then + begin + // We are simply being given the data and we take control of it. + LocalStgMedium^ := Medium; + Result := S_OK + end + else + begin + // We need to reference count or copy the data and keep our own references to it. + Result := StgMediumIncRef(Medium, LocalStgMedium^, True, Self as IDataObject); + + // Can get a circular reference if the client calls GetData then calls SetData with the same StgMedium. + // Because the unkForRelease for the IDataObject can be marshalled it is necessary to get pointers that + // can be correctly compared. See the IDragSourceHelper article by Raymond Chen at MSDN. + if Assigned(LocalStgMedium.unkForRelease) then + begin + if CanonicalIUnknown(Self) = CanonicalIUnknown(IUnknown(LocalStgMedium.unkForRelease)) then + IUnknown(LocalStgMedium.unkForRelease) := nil; // release the interface + end; + end; + + // Tell all registered advice sinks about the data change. + if Assigned(FAdviseHolder) then + FAdviseHolder.SendOnDataChange(Self as IDataObject, 0, 0); +end; + +//----------------- TVTDragManager ------------------------------------------------------------------------------------- + +constructor TVTDragManager.Create(AOwner: TBaseVirtualTree); + +begin + inherited Create; + FOwner := AOwner; + + // Create an instance of the drop target helper interface. This will fail but not harm on systems which do + // not support this interface (everything below Windows 2000); + CoCreateInstance(CLSID_DragDropHelper, nil, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, FDropTargetHelper); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVTDragManager.Destroy; + +begin + // Set the owner's reference to us to nil otherwise it will access an invalid pointer + // after our desctruction is complete. + Pointer(FOwner.FDragManager) := nil; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.GetDataObject: IDataObject; + +begin + // When the owner tree starts a drag operation then it gets a data object here to pass it to the OLE subsystem. + // In this case there is no local reference to a data object and one is created (but not stored). + // If there is a local reference then the owner tree is currently the drop target and the stored interface is + // that of the drag initiator. + if Assigned(FDataObject) then + Result := FDataObject + else + begin + Result := FOwner.DoCreateDataObject; + if Result = nil then + Result := TVTDataObject.Create(FOwner, False) as IDataObject; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.GetDragSource: TBaseVirtualTree; + +begin + Result := FDragSource; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.GetDropTargetHelperSupported: Boolean; + +begin + Result := Assigned(FDropTargetHelper); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.GetIsDropTarget: Boolean; + +begin + Result := FIsDropTarget; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.DragEnter(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; + var Effect: Integer): HResult; + +begin + FDataObject := DataObject; + FIsDropTarget := True; + + SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, @FFullDragging, 0); + // If full dragging of window contents is disabled in the system then our tree windows will be locked + // and cannot be updated during a drag operation. With the following call painting is again enabled. + if not FFullDragging then + LockWindowUpdate(0); + if Assigned(FDropTargetHelper) and FFullDragging then + FDropTargetHelper.DragEnter(FOwner.Handle, DataObject, Pt, Effect); + + FDragSource := FOwner.GetTreeFromDataObject(DataObject); + Result := FOwner.DragEnter(KeyState, Pt, Effect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.DragLeave: HResult; + +begin + if Assigned(FDropTargetHelper) and FFullDragging then + FDropTargetHelper.DragLeave; + + FOwner.DragLeave; + FIsDropTarget := False; + FDragSource := nil; + FDataObject := nil; + Result := NOERROR; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.DragOver(KeyState: Integer; Pt: TPoint; var Effect: LongInt): HResult; + +begin + if Assigned(FDropTargetHelper) and FFullDragging then + FDropTargetHelper.DragOver(Pt, Effect); + + Result := FOwner.DragOver(FDragSource, KeyState, dsDragMove, Pt, Effect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.Drop(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; + var Effect: Integer): HResult; + +begin + if Assigned(FDropTargetHelper) and FFullDragging then + FDropTargetHelper.Drop(DataObject, Pt, Effect); + + Result := FOwner.DragDrop(DataObject, KeyState, Pt, Effect); + FIsDropTarget := False; + FDataObject := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragManager.ForceDragLeave; + +// Some drop targets, e.g. Internet Explorer leave a drag image on screen instead removing it when they receive +// a drop action. This method calls the drop target helper's DragLeave method to ensure it removes the drag image from +// screen. Unfortunately, sometimes not even this does help (e.g. when dragging text from VT to a text field in IE). + +begin + if Assigned(FDropTargetHelper) and FFullDragging then + FDropTargetHelper.DragLeave; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.GiveFeedback(Effect: Integer): HResult; + +begin + Result := DRAGDROP_S_USEDEFAULTCURSORS; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragManager.QueryContinueDrag(EscapePressed: BOOL; KeyState: Integer): HResult; + +var + RButton, + LButton: Boolean; + +begin + LButton := (KeyState and MK_LBUTTON) <> 0; + RButton := (KeyState and MK_RBUTTON) <> 0; + + // Drag'n drop canceled by pressing both mouse buttons or Esc? + if (LButton and RButton) or EscapePressed then + Result := DRAGDROP_S_CANCEL + else + // Drag'n drop finished? + if not (LButton or RButton) then + Result := DRAGDROP_S_DROP + else + Result := S_OK; +end; + +//----------------- TVirtualTreeHintWindow ----------------------------------------------------------------------------- + +var + // This variable is necessary to coordinate the complex interaction between different hints in the application + // and animated hints in our own class. Under certain conditions it can happen that our hint window is destroyed + // while it is still in the animation loop. + FHintWindowDestroyed: Boolean = True; + +constructor TVirtualTreeHintWindow.Create(AOwner: TComponent); + +begin + inherited; + + FBackground := TBitmap.Create; + FBackground.PixelFormat := pf32Bit; + FDrawBuffer := TBitmap.Create; + FDrawBuffer.PixelFormat := pf32Bit; + FTarget := TBitmap.Create; + FTarget.PixelFormat := pf32Bit; + + DoubleBuffered := False; // we do our own buffering + FHintWindowDestroyed := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVirtualTreeHintWindow.Destroy; + +begin + FHintWindowDestroyed := True; + + FTarget.Free; + FDrawBuffer.Free; + FBackground.Free; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeHintWindow.AnimationCallback(Step, StepSize: Integer; Data: Pointer): Boolean; + +begin + Result := not FHintWindowDestroyed and HandleAllocated and IsWindowVisible(Handle) and + Assigned(FHintData.Tree) and not (tsCancelHintAnimation in FHintData.Tree.FStates); + if Result then + begin + InternalPaint(Step, StepSize); + // We have to allow certain messages to be processed normally for various reasons. + // This introduces another problem however if this hint window is destroyed + // while it is still in the animation loop. A global variable keeps track of + // that case. This is reliable because we can only have one (internal) hint window. + Application.ProcessMessages; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.CMTextChanged(var Message: TMessage); + +begin + // swallow this message to prevent the ancestor from resizing the window (we don't use the caption anyway) +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeHintWindow.GetHintWindowDestroyed; + +// This function exists to inform descendants if the hint window has been destroyed. + +begin + Result := FHintWindowDestroyed; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.WMEraseBkgnd(var Message: TWMEraseBkgnd); + +// The control is fully painted by own code so don't erase its background as this causes flickering. + +begin + Message.Result := 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.WMNCPaint(var Message: TMessage); + +// The control is fully painted by own code so don't paint any borders. + +begin + Message.Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.WMShowWindow(var Message: TWMShowWindow); + +// Clear hint data when the window becomes hidden. + +begin + if not Message.Show then + begin + // Don't touch the last hint rectangle stored in the associated tree to avoid flickering in certain situations. + Finalize(FHintData); + ZeroMemory (@FHintData, SizeOf(FHintData)); + + // If the hint window destruction flag to stop any hint window animation was set by a tree + // during its destruction then reset it here to allow other tree instances to still use + // this hint window. + FHintWindowDestroyed := False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.CreateParams(var Params: TCreateParams); + +begin + inherited CreateParams(Params); + + with Params do + begin + Style := WS_POPUP; + ExStyle := ExStyle and not WS_EX_CLIENTEDGE; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.InternalPaint(Step, StepSize: Integer); + + //--------------- local functions ------------------------------------------- + + procedure DoShadowBlend(DC: HDC; R: TRect; Alpha: Integer); + + // Helper routine for shadow blending to shorten the parameter list in frequent calls. + + begin + AlphaBlend(0, DC, R, Point(0, 0), bmConstantAlphaAndColor, Alpha, clBlack); + end; + + //--------------------------------------------------------------------------- + + procedure DrawHintShadow(Canvas: TCanvas; ShadowSize: Integer); + + var + R: TRect; + + begin + // Bottom shadow. + R := Rect(ShadowSize, Height - ShadowSize, Width, Height); + DoShadowBlend(Canvas.Handle, R, 5); + Inc(R.Left); + Dec(R.Right); + Dec(R.Bottom); + DoShadowBlend(Canvas.Handle, R, 10); + Inc(R.Left); + Dec(R.Right); + Dec(R.Bottom); + DoShadowBlend(Canvas.Handle, R, 20); + Inc(R.Left); + Dec(R.Right); + Dec(R.Bottom); + DoShadowBlend(Canvas.Handle, R, 35); + Inc(R.Left); + Dec(R.Right); + Dec(R.Bottom); + DoShadowBlend(Canvas.Handle, R, 50); + // Right shadow. + R := Rect(Width - ShadowSize, ShadowSize, Width, Height - ShadowSize); + DoShadowBlend(Canvas.Handle, R, 5); + Inc(R.Top); + Dec(R.Right); + DoShadowBlend(Canvas.Handle, R, 10); + Inc(R.Top); + Dec(R.Right); + DoShadowBlend(Canvas.Handle, R, 20); + Inc(R.Top); + Dec(R.Right); + DoShadowBlend(Canvas.Handle, R, 35); + Inc(R.Top); + Dec(R.Right); + DoShadowBlend(Canvas.Handle, R, 50); + end; + + //--------------- end local functions --------------------------------------- + +var + R: TRect; + Y: Integer; + S: UnicodeString; + DrawFormat: Cardinal; + Shadow: Integer; + +begin + Shadow := 0; + + with FHintData, FDrawBuffer do + begin + // Do actual painting only in the very first run. + if Step = 0 then + begin + // If the given node is nil then we have to display a header hint. + if (Node = nil) or (Tree.FHintMode <> hmToolTip) then + begin + Canvas.Font := Screen.HintFont; + Y := 2; + end + else + begin + Tree.GetTextInfo(Node, Column, Canvas.Font, R, S); + if LineBreakStyle = hlbForceMultiLine then + Y := 1 + else + Y := (R.Top - R.Bottom - Shadow + Self.Height) div 2; + end; + + R := Rect(0, 0, Width - Shadow, Height - Shadow); + + if (Tree is TCustomVirtualDrawTree) and Assigned(Node) then + begin + // The draw tree has by default no hint text so let it draw the hint itself. + (Tree as TCustomVirtualDrawTree).DoDrawHint(Canvas, Node, R, Column); + end + else + with Canvas do + begin + // Still force tooltip back and text color. + Font.Color := clInfoText; + Pen.Color := clBlack; + Brush.Color := clInfoBk; + Rectangle(R); + + // Determine text position and don't forget the border. + InflateRect(R, -1, -1); + + DrawFormat := DT_TOP or DT_NOPREFIX; + if BidiMode <> bdLeftToRight then + begin + DrawFormat := DrawFormat or DT_RIGHT or DT_RTLREADING; + Dec(R.Right, Tree.FTextMargin); + Inc(R.Right); + end + else + begin + DrawFormat := DrawFormat or DT_LEFT; + Inc(R.Left, Tree.FTextMargin); + end; + SetBkMode(Handle, Windows.TRANSPARENT); + R.Top := Y; + if Assigned(Node) and (LineBreakStyle = hlbForceMultiLine) then + DrawFormat := DrawFormat or DT_WORDBREAK; + Windows.DrawTextW(Handle, PWideChar(HintText), Length(HintText), R, DrawFormat) + end; + end; + end; + + if StepSize > 0 then + begin + if FHintData.Tree.DoGetAnimationType = hatFade then + begin + with FTarget do + BitBlt(Canvas.Handle, 0, 0, Width, Height, FBackground.Canvas.Handle, 0, 0, SRCCOPY); + // Main image. + AlphaBlend(FDrawBuffer.Canvas.Handle, FTarget.Canvas.Handle, Rect(0, 0, Width - Shadow, Height - Shadow), + Point(0, 0), bmConstantAlpha, MulDiv(Step, 256, FadeAnimationStepCount), 0); + + if Shadow > 0 then + DrawHintShadow(FTarget.Canvas, Shadow); + BitBlt(Canvas.Handle, 0, 0, Width, Height, FTarget.Canvas.Handle, 0, 0, SRCCOPY); + end + else + begin + // Slide is done by blitting "step" lines of the lower part of the hint window + // and fill the rest with the screen background. + + // 1) blit hint bitmap to the hint canvas + BitBlt(Canvas.Handle, 0, 0, Width - Shadow, Step, FDrawBuffer.Canvas.Handle, 0, Height - Step, SRCCOPY); + // 2) blit background rest to hint canvas + if Step <= Shadow then + Step := 0 + else + Dec(Step, Shadow); + BitBlt(Canvas.Handle, 0, Step, Width, Height - Step, FBackground.Canvas.Handle, 0, Step, SRCCOPY); + end; + end + else + // Last step during slide or the only step without animation. + if FHintData.Tree.DoGetAnimationType <> hatFade then + begin + if Shadow > 0 then + begin + with FBackground do + BitBlt(Canvas.Handle, 0, 0, Width - Shadow, Height - Shadow, FDrawBuffer.Canvas.Handle, 0, 0, SRCCOPY); + + DrawHintShadow(FBackground.Canvas, Shadow); + BitBlt(Canvas.Handle, 0, 0, Width, Height, FBackground.Canvas.Handle, 0, 0, SRCCOPY); + end + else + BitBlt(Canvas.Handle, 0, 0, Width, Height, FDrawBuffer.Canvas.Handle, 0, 0, SRCCOPY); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.Paint; + +begin + InternalPaint(0, 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeHintWindow.ActivateHint(Rect: TRect; const AHint: string); + +var + DC: HDC; + StopLastAnimation: Boolean; + +begin + if IsRectEmpty(Rect) or not Assigned(FHintData.Tree) then + Application.CancelHint + else + begin + // There is already an animation. Start a new one but do not continue the old one once we are finished here. + StopLastAnimation := (tsInAnimation in FHintData.Tree.FStates); + if StopLastAnimation then + FHintData.Tree.DoStateChange([], [tsInAnimation]); + + SetWindowPos(Handle, 0, Rect.Left, Rect.Top, Width, Height, SWP_HIDEWINDOW or SWP_NOACTIVATE or SWP_NOZORDER); + UpdateBoundsRect(Rect); + + // Make sure the whole hint is visible on the monitor. Don't forget multi-monitor systems with the + // primary monitor not being at the top-left corner. + if Rect.Top - Screen.DesktopTop + Height > Screen.DesktopHeight then + Rect.Top := Screen.DesktopHeight - Height + Screen.DesktopTop; + if Rect.Left - Screen.DesktopLeft + Width > Screen.DesktopWidth then + Rect.Left := Screen.DesktopWidth - Width + Screen.DesktopLeft; + if Rect.Bottom - Screen.DesktopTop < Screen.DesktopTop then + Rect.Bottom := Screen.DesktopTop + Screen.DesktopTop; + if Rect.Left - Screen.DesktopLeft < Screen.DesktopLeft then + Rect.Left := Screen.DesktopLeft + Screen.DesktopLeft; + + // adjust sizes of bitmaps + FDrawBuffer.Width := Width; + FDrawBuffer.Height := Height; + FBackground.Width := Width; + FBackground.Height := Height; + FTarget.Width := Width; + FTarget.Height := Height; + + FHintData.Tree.Update; + + // capture screen + DC := GetDC(0); + try + with TWithSafeRect(Rect) do + BitBlt(FBackground.Canvas.Handle, 0, 0, Width, Height, DC, Left, Top, SRCCOPY); + finally + ReleaseDC(0, DC); + end; + + SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, Width, Height, SWP_SHOWWINDOW or SWP_NOACTIVATE); + with FHintData.Tree do + case DoGetAnimationType of + hatNone: + InvalidateRect(Self.Handle, nil, False); + hatFade: + begin + // Make sure the window is not drawn unanimated. + ValidateRect(Self.Handle, nil); + // Empirically determined animation duration shows that fading needs about twice as much time as + // sliding to show a comparable visual effect. + Animate(FadeAnimationStepCount, 2 * FAnimationDuration, AnimationCallback, nil); + end; + hatSlide: + begin + // Make sure the window is not drawn unanimated. + ValidateRect(Self.Handle, nil); + Animate(Self.Height, FAnimationDuration, AnimationCallback, nil); + end; + end; + if not FHintWindowDestroyed and StopLastAnimation and Assigned(FHintData.Tree) then + FHintData.Tree.DoStateChange([tsCancelHintAnimation]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; + +var + TM: TTextMetric; + R: TRect; + +begin + if AData = nil then + // Defensive approach, it *can* happen that AData is nil. Maybe when several user defined hint classes are used. + Result := Rect(0, 0, 0, 0) + else + begin + // The hint window does not need any bidi mode setting but the caller of this method (TApplication.ActivateHint) + // does some unneccessary actions if the hint window is not left-to-right. + // The text alignment is based on the bidi mode passed in the hint data, hence we can + // simply set the window's mode to left-to-right (it might have been modified by the caller, if the + // tree window is right-to-left aligned). + BidiMode := bdLeftToRight; + + FHintData := PVTHintData(AData)^; + + with FHintData do + begin + // The draw tree gets its hint size by the application (but only if not a header hint is about to show). + // This size has already been determined in CMHintShow. + if (Tree is TCustomVirtualDrawTree) and Assigned(Node) then + Result := HintRect + else + begin + if Column <= NoColumn then + begin + BidiMode := Tree.BidiMode; + Alignment := Tree.Alignment; + end + else + begin + BidiMode := Tree.Header.Columns[Column].BidiMode; + Alignment := Tree.Header.Columns[Column].Alignment; + end; + + if BidiMode <> bdLeftToRight then + ChangeBidiModeAlignment(Alignment); + + if (Node = nil) or (Tree.FHintMode <> hmToolTip) then + Canvas.Font := Screen.HintFont + else + begin + Canvas.Font := Tree.Font; + if Tree is TCustomVirtualStringTree then + with TCustomVirtualStringTree(Tree) do + DoPaintText(Node, Self.Canvas, Column, ttNormal); + end; + + GetTextMetrics(Canvas.Handle, TM); + FTextHeight := TM.tmHeight; + LineBreakStyle := hlbDefault; + + if Length(DefaultHint) > 0 then + HintText := DefaultHint + else + if Tree.HintMode = hmToolTip then + HintText := Tree.DoGetNodeToolTip(Node, Column, LineBreakStyle) + else + HintText := Tree.DoGetNodeHint(Node, Column, LineBreakStyle); + + if Length(HintText) = 0 then + Result := Rect(0, 0, 0, 0) + else + begin + if Assigned(Node) and (Tree.FHintMode = hmToolTip) then + begin + // Determine actual line break style depending on what was returned by the methods and what's in the node. + if LineBreakStyle = hlbDefault then + if vsMultiline in Node.States then + LineBreakStyle := hlbForceMultiLine + else + LineBreakStyle := hlbForceSingleLine; + + // Hint for a node. + if LineBreakStyle = hlbForceMultiLine then + begin + // Multiline tooltips use the columns width but extend the bottom border to fit the whole caption. + Result := Tree.GetDisplayRect(Node, Column, True, False); + R := Result; + + // On Windows NT/2K/XP the behavior of the tooltip is slightly different to that on Windows 9x/Me. + // We don't have Unicode word wrap on the latter so the tooltip gets as wide as the largest line + // in the caption (limited by carriage return), which results in unoptimal overlay of the tooltip. + Windows.DrawTextW(Canvas.Handle, PWideChar(HintText), Length(HintText), R, DT_CALCRECT or DT_WORDBREAK); + if BidiMode = bdLeftToRight then + Result.Right := R.Right + Tree.FTextMargin + else + Result.Left := R.Left - Tree.FTextMargin + 1; + Result.Bottom := R.Bottom; + + Inc(Result.Right); + + // If the node height and the column width are both already large enough to cover the entire text, + // then we don't need the hint, though. + // However if the text is partially scrolled out of the client area then a hint is useful as well. + if (Tree.Header.Columns.Count > 0) and ((Integer(Tree.NodeHeight[Node]) + 2) >= (Result.Bottom - Result.Top)) and + ((Tree.Header.Columns[Column].Width + 2) >= (Result.Right - Result.Left)) and not + ((Result.Left < 0) or (Result.Right > Tree.ClientWidth + 3) or + (Result.Top < 0) or (Result.Bottom > Tree.ClientHeight + 3)) then + begin + Result := Rect(0, 0, 0, 0); + Exit; + end; + end + else + begin + Result := Tree.FLastHintRect; // = Tree.GetDisplayRect(Node, Column, True, True, True); see TBaseVirtualTree.CMHintShow + if toShowHorzGridLines in Tree.TreeOptions.PaintOptions then + Dec(Result.Bottom); + end; + + // Include a one pixel border. + InflateRect(Result, 1, 1); + + // Make the coordinates relative. They will again be offset by the caller code. + OffsetRect(Result, -Result.Left - 1, -Result.Top - 1); + end + else + begin + // Hint for a header or non-tooltip hint. + + // Start with the base size of the hint in client coordinates. + Result := Rect(0, 0, MaxWidth, FTextHeight); + // Calculate the true size of the text rectangle. + Windows.DrawTextW(Canvas.Handle, PWideChar(HintText), Length(HintText), Result, DT_CALCRECT); + // The height of the text plus 2 pixels vertical margin plus the border determine the hint window height. + Inc(Result.Bottom, 6); + // The text is centered horizontally with usual text margin for left and right borders (plus border). + If not Assigned(Tree) then exit;//Workaround, because we have seen several exceptions here caught by Eurekalog. Submitted as issue #114 to http://code.google.com/p/virtual-treeview/ + Inc(Result.Right, 2 * Tree.FTextMargin + 2); + end; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeHintWindow.IsHintMsg(var Msg: TMsg): Boolean; + +// The VCL is a bit too generous when telling that an existing hint can be cancelled. Need to specify further here. + +begin + Result := inherited IsHintMsg(Msg) and HandleAllocated and IsWindowVisible(Handle); + // Avoid that mouse moves over the non-client area or key presses cancel the current hint. + if Result and ((Msg.Message = WM_NCMOUSEMOVE) or ((Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST))) then + Result := False + else + // Work around problems with keypresses while doing hint animation. + if HandleAllocated and IsWindowVisible(Handle) and (Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST) and + (tsInAnimation in FHintData.Tree.FStates) and TranslateMessage(Msg) then + DispatchMessage(Msg); +end; + +//----------------- TVTDragImage --------------------------------------------------------------------------------------- + +constructor TVTDragImage.Create(AOwner: TBaseVirtualTree); + +begin + FOwner := AOwner; + FTransparency := 128; + FPreBlendBias := 0; + FPostBlendBias := 0; + FFade := False; + FRestriction := dmrNone; + FColorKey := clNone; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVTDragImage.Destroy; + +begin + EndDrag; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragImage.GetVisible: Boolean; + +// Returns True if the internal drag image is used (i.e. the system does not natively support drag images) and +// the internal image is currently visible on screen. + +begin + Result := FStates * [disHidden, disInDrag, disPrepared, disSystemSupport] = [disInDrag, disPrepared]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.InternalShowDragImage(ScreenDC: HDC); + +// Frequently called helper routine to actually do the blend and put it onto the screen. +// Only used if the system does not support drag images. + +var + BlendMode: TBlendMode; + +begin + with FAlphaImage do + BitBlt(Canvas.Handle, 0, 0, Width, Height, FBackImage.Canvas.Handle, 0, 0, SRCCOPY); + if not FFade and (FColorKey = clNone) then + BlendMode := bmConstantAlpha + else + BlendMode := bmMasterAlpha; + with FDragImage do + AlphaBlend(Canvas.Handle, FAlphaImage.Canvas.Handle, Rect(0, 0, Width, Height), Point(0, 0), BlendMode, + FTransparency, FPostBlendBias); + + with FAlphaImage do + BitBlt(ScreenDC, FImagePosition.X, FImagePosition.Y, Width, Height, Canvas.Handle, 0, 0, SRCCOPY); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.MakeAlphaChannel(Source, Target: TBitmap); + +// Helper method to create a proper alpha channel in Target (which must be in 32 bit pixel format), depending +// on the settings for the drag image and the color values in Source. +// Only used if the system does not support drag images. + +type + PBGRA = ^TBGRA; + TBGRA = packed record + case Boolean of + False: + (Color: Cardinal); + True: + (BGR: array[0..2] of Byte; + Alpha: Byte); + end; + +var + Color, + ColorKeyRef: COLORREF; + UseColorKey: Boolean; + SourceRun, + TargetRun: PBGRA; + X, Y, + MaxDimension, + HalfWidth, + HalfHeight: Integer; + T: Extended; + +begin + UseColorKey := ColorKey <> clNone; + ColorKeyRef := ColorToRGB(ColorKey) and $FFFFFF; + // Color values are in the form BGR (red on LSB) while bitmap colors are in the form ARGB (blue on LSB) + // hence we have to swap red and blue in the color key. + with TBGRA(ColorKeyRef) do + begin + X := BGR[0]; + BGR[0] := BGR[2]; + BGR[2] := X; + end; + + with Target do + begin + MaxDimension := Max(Width, Height); + + HalfWidth := Width div 2; + HalfHeight := Height div 2; + for Y := 0 to Height - 1 do + begin + TargetRun := Scanline[Y]; + SourceRun := Source.Scanline[Y]; + for X := 0 to Width - 1 do + begin + Color := SourceRun.Color and $FFFFFF; + if UseColorKey and (Color = ColorKeyRef) then + TargetRun.Alpha := 0 + else + begin + // If the color is not the given color key (or none is used) then do full calculation of a bell curve. + T := exp(-8 * Sqrt(Sqr((X - HalfWidth) / MaxDimension) + Sqr((Y - HalfHeight) / MaxDimension))); + TargetRun.Alpha := Round(255 * T); + end; + Inc(SourceRun); + Inc(TargetRun); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragImage.DragTo(P: TPoint; ForceRepaint: Boolean): Boolean; + +// Moves the drag image to a new position, which is determined from the passed point P and the previous +// mouse position. +// ForceRepaint is True if something on the screen changed and the back image must be refreshed. + +var + ScreenDC: HDC; + DeltaX, + DeltaY: Integer; + + // optimized drag image move support + RSamp1, + RSamp2, // newly added parts from screen which will be overwritten + RDraw1, + RDraw2, // parts to be restored to screen + RScroll, + RClip: TRect; // ScrollDC of the existent background + +begin + // Determine distances to move the drag image. Take care for restrictions. + case FRestriction of + dmrHorizontalOnly: + begin + DeltaX := FLastPosition.X - P.X; + DeltaY := 0; + end; + dmrVerticalOnly: + begin + DeltaX := 0; + DeltaY := FLastPosition.Y - P.Y; + end; + else // dmrNone + DeltaX := FLastPosition.X - P.X; + DeltaY := FLastPosition.Y - P.Y; + end; + + Result := (DeltaX <> 0) or (DeltaY <> 0) or ForceRepaint; + if Result then + begin + if Visible then + begin + // All this stuff is only called if we have to handle the drag image ourselves. If the system supports + // drag image then this is all never executed. + ScreenDC := GetDC(0); + try + if (Abs(DeltaX) >= FDragImage.Width) or (Abs(DeltaY) >= FDragImage.Height) or ForceRepaint then + begin + // If moved more than image size then just restore old screen and blit image to new position. + BitBlt(ScreenDC, FImagePosition.X, FImagePosition.Y, FBackImage.Width, FBackImage.Height, + FBackImage.Canvas.Handle, 0, 0, SRCCOPY); + + if ForceRepaint then + UpdateWindow(FOwner.Handle); + + Inc(FImagePosition.X, -DeltaX); + Inc(FImagePosition.Y, -DeltaY); + + BitBlt(FBackImage.Canvas.Handle, 0, 0, FBackImage.Width, FBackImage.Height, ScreenDC, FImagePosition.X, + FImagePosition.Y, SRCCOPY); + end + else + begin + // overlapping copy + FillDragRectangles(FDragImage.Width, FDragImage.Height, DeltaX, DeltaY, RClip, RScroll, RSamp1, RSamp2, RDraw1, + RDraw2); + + with FBackImage.Canvas do + begin + // restore uncovered areas of the screen + if DeltaX = 0 then + begin + with TWithSafeRect(RDraw2) do + BitBlt(ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, Right, Bottom, Handle, Left, Top, + SRCCOPY); + end + else + begin + if DeltaY = 0 then + begin + with TWithSafeRect(RDraw1) do + BitBlt(ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, Right, Bottom, Handle, Left, Top, + SRCCOPY); + end + else + begin + with TWithSafeRect(RDraw1) do + BitBlt(ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, Right, Bottom, Handle, Left, Top, + SRCCOPY); + with TWithSafeRect(RDraw2) do + BitBlt(ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, Right, Bottom, Handle, Left, Top, + SRCCOPY); + end; + end; + + // move existent background + ScrollDC(Handle, DeltaX, DeltaY, RScroll, RClip, 0, nil); + + Inc(FImagePosition.X, -DeltaX); + Inc(FImagePosition.Y, -DeltaY); + + // Get first and second additional rectangle from screen. + if DeltaX = 0 then + begin + with TWithSafeRect(RSamp2) do + BitBlt(Handle, Left, Top, Right, Bottom, ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, + SRCCOPY); + end + else + if DeltaY = 0 then + begin + with TWithSafeRect(RSamp1) do + BitBlt(Handle, Left, Top, Right, Bottom, ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, + SRCCOPY); + end + else + begin + with TWithSafeRect(RSamp1) do + BitBlt(Handle, Left, Top, Right, Bottom, ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, + SRCCOPY); + with TWithSafeRect(RSamp2) do + BitBlt(Handle, Left, Top, Right, Bottom, ScreenDC, FImagePosition.X + Left, FImagePosition.Y + Top, + SRCCOPY); + end; + end; + end; + InternalShowDragImage(ScreenDC); + finally + ReleaseDC(0, ScreenDC); + end; + end; + FLastPosition.X := P.X; + FLastPosition.Y := P.Y; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.EndDrag; + +begin + HideDragImage; + FStates := FStates - [disInDrag, disPrepared]; + + FBackImage.Free; + FBackImage := nil; + FDragImage.Free; + FDragImage := nil; + FAlphaImage.Free; + FAlphaImage := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragImage.GetDragImageRect: TRect; + +// Returns the current size and position of the drag image (screen coordinates). + +begin + if Visible then + begin + with FBackImage do + Result := Rect(FImagePosition.X, FImagePosition.Y, FImagePosition.X + Width, FImagePosition.Y + Height); + end + else + Result := Rect(0, 0, 0, 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.HideDragImage; + +var + ScreenDC: HDC; + +begin + if Visible then + begin + Include(FStates, disHidden); + ScreenDC := GetDC(0); + try + // restore screen + with FBackImage do + BitBlt(ScreenDC, FImagePosition.X, FImagePosition.Y, Width, Height, Canvas.Handle, 0, 0, SRCCOPY); + finally + ReleaseDC(0, ScreenDC); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.PrepareDrag(DragImage: TBitmap; ImagePosition, HotSpot: TPoint; const DataObject: IDataObject); + +// Creates all necessary structures to do alpha blended dragging using the given image. +// ImagePostion and Hotspot are given in screen coordinates. The first determines where to place the drag image while +// the second is the initial mouse position. +// This method also determines whether the system supports drag images natively. If so then only minimal structures +// are created. + +var + Width, + Height: Integer; + DragSourceHelper: IDragSourceHelper; + DragInfo: TSHDragImage; + +begin + Width := DragImage.Width; + Height := DragImage.Height; + + // Determine whether the system supports the drag helper interfaces. + if Assigned(DataObject) and Succeeded(CoCreateInstance(CLSID_DragDropHelper, nil, CLSCTX_INPROC_SERVER, + IID_IDragSourceHelper, DragSourceHelper)) then + begin + Include(FStates, disSystemSupport); + + // Supply the drag source helper with our drag image. + DragInfo.sizeDragImage.cx := Width; + DragInfo.sizeDragImage.cy := Height; + DragInfo.ptOffset.x := Width div 2; + DragInfo.ptOffset.y := Height div 2; + DragInfo.hbmpDragImage := CopyImage(DragImage.Handle, IMAGE_BITMAP, Width, Height, LR_COPYRETURNORG); + DragInfo.ColorRef := ColorToRGB(FColorKey); + if not Succeeded(DragSourceHelper.InitializeFromBitmap(DragInfo, DataObject)) then + begin + DeleteObject(DragInfo.hbmpDragImage); + Exclude(FStates, disSystemSupport); + end; + end + else + Exclude(FStates, disSystemSupport); + + if MMXAvailable and not (disSystemSupport in FStates) then + begin + FLastPosition := HotSpot; + + FDragImage := TBitmap.Create; + FDragImage.PixelFormat := pf32Bit; + FDragImage.Width := Width; + FDragImage.Height := Height; + + FAlphaImage := TBitmap.Create; + FAlphaImage.PixelFormat := pf32Bit; + FAlphaImage.Width := Width; + FAlphaImage.Height := Height; + + FBackImage := TBitmap.Create; + FBackImage.PixelFormat := pf32Bit; + FBackImage.Width := Width; + FBackImage.Height := Height; + + // Copy the given drag image and apply pre blend bias if required. + if FPreBlendBias = 0 then + with FDragImage do + BitBlt(Canvas.Handle, 0, 0, Width, Height, DragImage.Canvas.Handle, 0, 0, SRCCOPY) + else + AlphaBlend(DragImage.Canvas.Handle, FDragImage.Canvas.Handle, Rect(0, 0, Width, Height), Point(0, 0), + bmConstantAlpha, 255, FPreBlendBias); + + // Create a proper alpha channel also if no fading is required (transparent parts). + MakeAlphaChannel(DragImage, FDragImage); + + FImagePosition := ImagePosition; + + // Initially the drag image is hidden and will be shown during the immediately following DragEnter event. + FStates := FStates + [disInDrag, disHidden, disPrepared]; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.RecaptureBackground(Tree: TBaseVirtualTree; R: TRect; VisibleRegion: HRGN; + CaptureNCArea, ReshowDragImage: Boolean); + +// Notification by the drop target tree to update the background image because something in the tree has changed. +// Note: The passed rectangle is given in client coordinates of the current drop target tree (given in Tree). +// The caller does not check if the given rectangle is actually within the drag image. Hence this method must do +// all the checks. +// This method does nothing if the system manages the drag image. + +var + DragRect, + ClipRect: TRect; + PaintTarget: TPoint; + PaintOptions: TVTInternalPaintOptions; + ScreenDC: HDC; + +begin + // Recapturing means we want the tree to paint the new part into our back bitmap instead to the screen. + if Visible then + begin + // Create the minimum rectangle to be recaptured. + MapWindowPoints(Tree.Handle, 0, R, 2); + DragRect := GetDragImageRect; + IntersectRect(R, R, DragRect); + + OffsetRgn(VisibleRegion, -DragRect.Left, -DragRect.Top); + + // The target position for painting in the drag image is relative and can be determined from screen coordinates too. + PaintTarget.X := R.Left - DragRect.Left; + PaintTarget.Y := R.Top - DragRect.Top; + + // The source rectangle is determined by the offsets in the tree. + MapWindowPoints(0, Tree.Handle, R, 2); + OffsetRect(R, -Tree.FOffsetX, -Tree.FOffsetY); + + // Finally let the tree paint the relevant part and upate the drag image on screen. + PaintOptions := [poBackground, poColumnColor, poDrawFocusRect, poDrawDropMark, poDrawSelection, poGridLines]; + with FBackImage do + begin + ClipRect.TopLeft := PaintTarget; + ClipRect.Right := ClipRect.Left + R.Right - R.Left; + ClipRect.Bottom := ClipRect.Top + R.Bottom - R.Top; + ClipCanvas(Canvas, ClipRect, VisibleRegion); + Tree.PaintTree(Canvas, R, PaintTarget, PaintOptions); + + if CaptureNCArea then + begin + // For the non-client area we only need the visible region of the window as limit for painting. + SelectClipRgn(Canvas.Handle, VisibleRegion); + // Since WM_PRINT cannot be given a position where to draw we simply move the window origin and + // get the same effect. + GetWindowRect(Tree.Handle, ClipRect); + SetCanvasOrigin(Canvas, DragRect.Left - ClipRect.Left, DragRect.Top - ClipRect.Top); + Tree.Perform(WM_PRINT, WPARAM(Canvas.Handle), PRF_NONCLIENT); + SetCanvasOrigin(Canvas, 0, 0); + end; + SelectClipRgn(Canvas.Handle, 0); + + if ReshowDragImage then + begin + GDIFlush; + ScreenDC := GetDC(0); + try + InternalShowDragImage(ScreenDC); + finally + ReleaseDC(0, ScreenDC); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTDragImage.ShowDragImage; + +// Shows the drag image after it has been hidden by HideDragImage. +// Note: there might be a new background now. +// Also this method does nothing if the system manages the drag image. + +var + ScreenDC: HDC; + +begin + if FStates * [disInDrag, disHidden, disPrepared, disSystemSupport] = [disInDrag, disHidden, disPrepared] then + begin + Exclude(FStates, disHidden); + + GDIFlush; + ScreenDC := GetDC(0); + try + BitBlt(FBackImage.Canvas.Handle, 0, 0, FBackImage.Width, FBackImage.Height, ScreenDC, FImagePosition.X, + FImagePosition.Y, SRCCOPY); + + InternalShowDragImage(ScreenDC); + finally + ReleaseDC(0, ScreenDC); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTDragImage.WillMove(P: TPoint): Boolean; + +// This method determines whether the drag image would "physically" move when DragTo would be called with the same +// target point. +// Always returns False if the system drag image support is available. + +var + DeltaX, + DeltaY: Integer; + +begin + Result := Visible; + if Result then + begin + // Determine distances to move the drag image. Take care for restrictions. + case FRestriction of + dmrHorizontalOnly: + begin + DeltaX := FLastPosition.X - P.X; + DeltaY := 0; + end; + dmrVerticalOnly: + begin + DeltaX := 0; + DeltaY := FLastPosition.Y - P.Y; + end; + else // dmrNone + DeltaX := FLastPosition.X - P.X; + DeltaY := FLastPosition.Y - P.Y; + end; + + Result := (DeltaX <> 0) or (DeltaY <> 0); + end; +end; + +//----------------- TVTVirtualNodeEnumerator --------------------------------------------------------------------------- + +function TVTVirtualNodeEnumerator.GetCurrent: PVirtualNode; + +begin + Result := FNode; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTVirtualNodeEnumerator.MoveNext: Boolean; + +begin + Result := FCanModeNext; + if Result then + begin + FNode := FEnumeration.GetNext(FNode); + Result := FNode <> nil; + FCanModeNext := Result; + end; +end; + +//----------------- TVTVirtualNodeEnumeration -------------------------------------------------------------------------- + +function TVTVirtualNodeEnumeration.GetEnumerator: TVTVirtualNodeEnumerator; + +begin + {$ifdef COMPILER_10_UP} + {$else} + Result := TVTVirtualNodeEnumerator.Create; + {$endif COMPILER_10_UP} + Result.FNode := nil; + Result.FCanModeNext := True; + Result.FEnumeration := @Self; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTVirtualNodeEnumeration.GetNext(Node: PVirtualNode): PVirtualNode; +begin + case FMode of + vneAll: + if Node = nil then + Result := FTree.GetFirst(FConsiderChildrenAbove) + else + Result := FTree.GetNext(Node, FConsiderChildrenAbove); + + vneChecked: + if Node = nil then + Result := FTree.GetFirstChecked(FState, FConsiderChildrenAbove) + else + Result := FTree.GetNextChecked(Node, FState, FConsiderChildrenAbove); + + vneChild: + if Node = nil then + Result := FTree.GetFirstChild(FNode) + else + Result := FTree.GetNextSibling(Node); + + vneCutCopy: + if Node = nil then + Result := FTree.GetFirstCutCopy(FConsiderChildrenAbove) + else + Result := FTree.GetNextCutCopy(Node, FConsiderChildrenAbove); + + vneInitialized: + if Node = nil then + Result := FTree.GetFirstInitialized(FConsiderChildrenAbove) + else + Result := FTree.GetNextInitialized(Node, FConsiderChildrenAbove); + + vneLeaf: + if Node = nil then + Result := FTree.GetFirstLeaf + else + Result := FTree.GetNextLeaf(Node); + + vneLevel: + if Node = nil then + Result := FTree.GetFirstLevel(FNodeLevel) + else + Result := FTree.GetNextLevel(Node, FNodeLevel); + + vneNoInit: + if Node = nil then + Result := FTree.GetFirstNoInit(FConsiderChildrenAbove) + else + Result := FTree.GetNextNoInit(Node, FConsiderChildrenAbove); + + vneSelected: + if Node = nil then + Result := FTree.GetFirstSelected(FConsiderChildrenAbove) + else + Result := FTree.GetNextSelected(Node, FConsiderChildrenAbove); + + vneVisible: + begin + if Node = nil then + begin + Result := FTree.GetFirstVisible(FNode, FConsiderChildrenAbove, FIncludeFiltered); + if FIncludeFiltered or not FTree.IsEffectivelyFiltered[Result] then + Exit; + end; + repeat + Result := FTree.GetNextVisible(Node{, FConsiderChildrenAbove}); + until not Assigned(Result) or FIncludeFiltered or not FTree.IsEffectivelyFiltered[Result]; + end; + + vneVisibleChild: + if Node = nil then + Result := FTree.GetFirstVisibleChild(FNode, FIncludeFiltered) + else + Result := FTree.GetNextVisibleSibling(Node, FIncludeFiltered); + + vneVisibleNoInitChild: + if Node = nil then + Result := FTree.GetFirstVisibleChildNoInit(FNode, FIncludeFiltered) + else + Result := FTree.GetNextVisibleSiblingNoInit(Node, FIncludeFiltered); + + vneVisibleNoInit: + begin + if Node = nil then + begin + Result := FTree.GetFirstVisibleNoInit(FNode, FConsiderChildrenAbove, FIncludeFiltered); + if FIncludeFiltered or not FTree.IsEffectivelyFiltered[Result] then + Exit; + end; + repeat + Result := FTree.GetNextVisibleNoInit(Node, FConsiderChildrenAbove); + until not Assigned(Result) or FIncludeFiltered or not FTree.IsEffectivelyFiltered[Result]; + end; + else + Result := nil; + end; +end; + +//----------------- TVirtualTreeColumn --------------------------------------------------------------------------------- + +constructor TVirtualTreeColumn.Create(Collection: TCollection); + +begin + FMinWidth := 10; + FMaxWidth := 10000; + FImageIndex := -1; + FMargin := 4; + FSpacing := 4; + FText := ''; + FOptions := DefaultColumnOptions; + FAlignment := taLeftJustify; + FBidiMode := bdLeftToRight; + FColor := clWindow; + FLayout := blGlyphLeft; + FBonusPixel := False; + FCaptionAlignment := taLeftJustify; + FCheckType := ctCheckBox; + FCheckState := csUncheckedNormal; + FCheckBox := False; + FHasImage := False; + fDefaultSortDirection := sdAscending; + + inherited Create(Collection); + + FWidth := Owner.FDefaultWidth; + FLastWidth := Owner.FDefaultWidth; + FPosition := Owner.Count - 1; + // Read parent bidi mode and color values as default values. + ParentBiDiModeChanged; + ParentColorChanged; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVirtualTreeColumn.Destroy; + +var + I: Integer; + + //--------------- local function --------------------------------------------- + + procedure AdjustColumnIndex(var ColumnIndex: TColumnIndex); + + begin + if Index = ColumnIndex then + ColumnIndex := NoColumn + else + if Index < ColumnIndex then + Dec(ColumnIndex); + end; + + //--------------- end local function ----------------------------------------- + +begin + // Check if this column is somehow referenced by its collection parent or the header. + with Owner do + begin + // If the columns collection object is currently deleting all columns + // then we don't need to check the various cached indices individually. + if not FClearing then + begin + Header.Treeview.CancelEditNode; + IndexChanged(Index, -1); + + AdjustColumnIndex(FHoverIndex); + AdjustColumnIndex(FDownIndex); + AdjustColumnIndex(FTrackIndex); + AdjustColumnIndex(FClickIndex); + + with Header do + begin + AdjustColumnIndex(FAutoSizeIndex); + if Index = FMainColumn then + begin + // If the current main column is about to be destroyed then we have to find a new main column. + FMainColumn := NoColumn; + for I := 0 to Count - 1 do + if I <> Index then + begin + FMainColumn := I; + Break; + end; + end; + AdjustColumnIndex(FSortColumn); + end; + end; + end; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.GetCaptionAlignment: TAlignment; + +begin + if coUseCaptionAlignment in FOptions then + Result := FCaptionAlignment + else + Result := FAlignment; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.GetLeft: Integer; + +begin + Result := FLeft; + if [coVisible, coFixed] * FOptions <> [coVisible, coFixed] then + Dec(Result, Owner.Header.Treeview.FEffectiveOffsetX); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.IsBiDiModeStored: Boolean; + +begin + Result := not (coParentBiDiMode in FOptions); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.IsCaptionAlignmentStored: Boolean; + +begin + Result := coUseCaptionAlignment in FOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.IsColorStored: Boolean; + +begin + Result := not (coParentColor in FOptions); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetAlignment(const Value: TAlignment); + +begin + if FAlignment <> Value then + begin + FAlignment := Value; + Changed(False); + // Setting the alignment affects also the tree, hence invalidate it too. + Owner.Header.TreeView.Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetBiDiMode(Value: TBiDiMode); + +begin + if Value <> FBiDiMode then + begin + FBiDiMode := Value; + Exclude(FOptions, coParentBiDiMode); + Changed(False); + // Setting the alignment affects also the tree, hence invalidate it too. + Owner.Header.TreeView.Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetCaptionAlignment(const Value: TAlignment); + +begin + if not (coUseCaptionAlignment in FOptions) or (FCaptionAlignment <> Value) then + begin + FCaptionAlignment := Value; + Exclude(FOptions, coUseCaptionAlignment); + // Setting the alignment affects also the tree, hence invalidate it too. + Owner.Header.Invalidate(Self); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetColor(const Value: TColor); + +begin + if FColor <> Value then + begin + FColor := Value; + Exclude(FOptions, coParentColor); + Changed(False); + Owner.Header.TreeView.Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetCheckBox(Value: boolean); + +begin + if Value <> FCheckBox then + begin + FCheckBox := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetCheckState(Value: TCheckState); + +begin + if Value <> FCheckState then + begin + FCheckState := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetCheckType(Value: TCheckType); + +begin + if Value <> FCheckType then + begin + FCheckType := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetImageIndex(Value: TImageIndex); + +begin + if Value <> FImageIndex then + begin + FImageIndex := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetLayout(Value: TVTHeaderColumnLayout); + +begin + if FLayout <> Value then + begin + FLayout := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetMargin(Value: Integer); + +begin + // Compatibility setting for -1. + if Value < 0 then + Value := 4; + if FMargin <> Value then + begin + FMargin := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetMaxWidth(Value: Integer); + +begin + if Value < FMinWidth then + Value := FMinWidth; + FMaxWidth := Value; + SetWidth(FWidth); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetMinWidth(Value: Integer); + +begin + if Value < 0 then + Value := 0; + if Value > FMaxWidth then + Value := FMaxWidth; + FMinWidth := Value; + SetWidth(FWidth); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetOptions(Value: TVTColumnOptions); + +var + ToBeSet, + ToBeCleared: TVTColumnOptions; + VisibleChanged, + ColorChanged: Boolean; + +begin + if FOptions <> Value then + begin + ToBeCleared := FOptions - Value; + ToBeSet := Value - FOptions; + + FOptions := Value; + + VisibleChanged := coVisible in (ToBeSet + ToBeCleared); + ColorChanged := coParentColor in ToBeSet; + + if coParentBidiMode in ToBeSet then + ParentBiDiModeChanged; + if ColorChanged then + ParentColorChanged; + + if coAutoSpring in ToBeSet then + FSpringRest := 0; + + if ((coFixed in ToBeSet) or (coFixed in ToBeCleared)) and (coVisible in FOptions) then + Owner.Header.RescaleHeader; + + Changed(False); + // Need to repaint and adjust the owner tree too. + with Owner, Header.Treeview do + if not (csLoading in ComponentState) and (VisibleChanged or ColorChanged) and (UpdateCount = 0) and + HandleAllocated then + begin + Invalidate; + if VisibleChanged then + UpdateHorizontalScrollBar(False); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetPosition(Value: TColumnPosition); + +var + Temp: TColumnIndex; + +begin + if csLoading in Owner.Header.Treeview.ComponentState then + // Only cache the position for final fixup when loading from DFM. + FPosition := Value + else + begin + if Value >= TColumnPosition(Collection.Count) then + Value := Collection.Count - 1; + if FPosition <> Value then + begin + with Owner do + begin + InitializePositionArray; + Header.Treeview.CancelEditNode; + AdjustPosition(Self, Value); + Self.Changed(False); + + // Need to repaint. + with Header do + begin + if (UpdateCount = 0) and Treeview.HandleAllocated then + begin + Invalidate(Self); + Treeview.Invalidate; + end; + end; + end; + + // If the moved column is now within the fixed columns then we make it fixed as well. If it's not + // we clear the fixed state (in case that fixed column is moved outside fixed area). + if (coFixed in FOptions) and (FPosition > 0) then + Temp := Owner.ColumnFromPosition(FPosition - 1) + else + Temp := Owner.ColumnFromPosition(FPosition + 1); + + if Temp <> NoColumn then + begin + if coFixed in Owner[Temp].Options then + Options := Options + [coFixed] + else + Options := Options - [coFixed] + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetSpacing(Value: Integer); + +begin + if FSpacing <> Value then + begin + FSpacing := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetStyle(Value: TVirtualTreeColumnStyle); + +begin + if FStyle <> Value then + begin + FStyle := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetText(const Value: UnicodeString); + +begin + if FText <> Value then + begin + FText := Value; + Changed(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SetWidth(Value: Integer); + +var + EffectiveMaxWidth, + EffectiveMinWidth, + TotalFixedMaxWidth, + TotalFixedMinWidth: Integer; + I: TColumnIndex; + +begin + if not (hsScaling in Owner.FHeader.FStates) then + if ([coVisible, coFixed] * FOptions = [coVisible, coFixed]) then + begin + with Owner, FHeader, FFixedAreaConstraints, TreeView do + begin + TotalFixedMinWidth := 0; + TotalFixedMaxWidth := 0; + for I := 0 to FColumns.Count - 1 do + if ([coVisible, coFixed] * FColumns[I].FOptions = [coVisible, coFixed]) then + begin + Inc(TotalFixedMaxWidth, FColumns[I].FMaxWidth); + Inc(TotalFixedMinWidth, FColumns[I].FMinWidth); + end; + + // The percentage values have precedence over the pixel values. + TotalFixedMinWidth := IfThen(FMaxWidthPercent > 0, + Min((ClientWidth * FMaxWidthPercent) div 100, TotalFixedMinWidth), + TotalFixedMinWidth); + TotalFixedMaxWidth := IfThen(FMinWidthPercent > 0, + Max((ClientWidth * FMinWidthPercent) div 100, TotalFixedMaxWidth), + TotalFixedMaxWidth); + + EffectiveMaxWidth := Min(TotalFixedMaxWidth - (GetVisibleFixedWidth - Self.FWidth), FMaxWidth); + EffectiveMinWidth := Max(TotalFixedMinWidth - (GetVisibleFixedWidth - Self.FWidth), FMinWidth); + Value := Min(Max(Value, EffectiveMinWidth), EffectiveMaxWidth); + + if FMinWidthPercent > 0 then + Value := Max((ClientWidth * FMinWidthPercent) div 100 - GetVisibleFixedWidth + Self.FWidth, Value); + if FMaxWidthPercent > 0 then + Value := Min((ClientWidth * FMaxWidthPercent) div 100 - GetVisibleFixedWidth + Self.FWidth, Value); + end; + end + else + Value := Min(Max(Value, FMinWidth), FMaxWidth); + + if FWidth <> Value then + begin + FLastWidth := FWidth; + if not (hsResizing in Owner.Header.States) then + FBonusPixel := False; + with Owner, Header do + begin + if not (hoAutoResize in FOptions) or (Index <> FAutoSizeIndex) then + begin + FWidth := Value; + UpdatePositions; + end; + if not (csLoading in Treeview.ComponentState) and (UpdateCount = 0) then + begin + if hoAutoResize in FOptions then + AdjustAutoSize(Index); + Treeview.DoColumnResize(Index); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.ComputeHeaderLayout(DC: HDC; Client: TRect; UseHeaderGlyph, UseSortGlyph: Boolean; + var HeaderGlyphPos, SortGlyphPos: TPoint; var SortGlyphSize: TSize; var TextBounds: TRect; DrawFormat: Cardinal; + CalculateTextRect: Boolean = False); + +// The layout of a column header is determined by a lot of factors. This method takes them all into account and +// determines all necessary positions and bounds: +// - for the header text +// - the header glyph +// - the sort glyph + +var + TextSize: TSize; + TextPos, + ClientSize, + HeaderGlyphSize: TPoint; + CurrentAlignment: TAlignment; + MinLeft, + MaxRight, + TextSpacing: Integer; + UseText: Boolean; + R: TRect; + Theme: HTHEME; + +begin + UseText := Length(FText) > 0; + // If nothing is to show then don't waste time with useless preparation. + if not (UseText or UseHeaderGlyph or UseSortGlyph) then + Exit; + + CurrentAlignment := CaptionAlignment; + if FBidiMode <> bdLeftToRight then + ChangeBiDiModeAlignment(CurrentAlignment); + + // Calculate sizes of the involved items. + ClientSize := Point(Client.Right - Client.Left, Client.Bottom - Client.Top); + with Owner, Header do + begin + if UseHeaderGlyph then + if not FCheckBox then + HeaderGlyphSize := Point(FImages.Width, FImages.Height) + else + with TBaseVirtualTree.GetCheckImageListFor(FHeader.Treeview.CheckImageKind) do + HeaderGlyphSize := Point(Width, Height) + else + HeaderGlyphSize := Point(0, 0); + if UseSortGlyph then + begin + if tsUseExplorerTheme in FHeader.Treeview.FStates then + begin + R := Rect(0, 0, 100, 100); + Theme := OpenThemeData(FHeader.Treeview.Handle, 'HEADER'); + GetThemePartSize(Theme, DC, HP_HEADERSORTARROW, HSAS_SORTEDUP, @R, TS_TRUE, SortGlyphSize); + CloseThemeData(Theme); + end + else + begin + SortGlyphSize.cx := UtilityImages.Width; + SortGlyphSize.cy := UtilityImages.Height; + end; + + // In any case, the sort glyph is vertically centered. + SortGlyphPos.Y := (ClientSize.Y - SortGlyphSize.cy) div 2; + end + else + begin + SortGlyphSize.cx := 0; + SortGlyphSize.cy := 0; + end; + end; + + if UseText then + begin + if not (coWrapCaption in FOptions) then + begin + FCaptionText := FText; + GetTextExtentPoint32W(DC, PWideChar(FText), Length(FText), TextSize); + Inc(TextSize.cx, 2); + TextBounds := Rect(0, 0, TextSize.cx, TextSize.cy); + end + else + begin + R := Client; + if FCaptionText = '' then + FCaptionText := FText; + + GetStringDrawRect(DC, FCaptionText, R, DrawFormat); + TextSize.cx := Client.Right - Client.Left; + TextSize.cy := R.Bottom - R.Top; + TextBounds := Rect(0, 0, TextSize.cx, TextSize.cy); + end; + TextSpacing := FSpacing; + end + else + begin + TextSpacing := 0; + TextSize.cx := 0; + TextSize.cy := 0; + end; + + // Check first for the special case where nothing is shown except the sort glyph. + if UseSortGlyph and not (UseText or UseHeaderGlyph) then + begin + // Center the sort glyph in the available area if nothing else is there. + SortGlyphPos := Point((ClientSize.X - SortGlyphSize.cx) div 2, (ClientSize.Y - SortGlyphSize.cy) div 2); + end + else + begin + // Determine extents of text and glyph and calculate positions which are clear from the layout. + if (Layout in [blGlyphLeft, blGlyphRight]) or not UseHeaderGlyph then + begin + HeaderGlyphPos.Y := (ClientSize.Y - HeaderGlyphSize.Y) div 2; + // If the text is taller than the given height, perform no vertical centration as this + // would make the text even less readable. + //Using Max() fixes badly positioned text if Extra Large fonts have been activated in the Windows display options + TextPos.Y := Max(-5,(ClientSize.Y - TextSize.cy) div 2); + end + else + begin + if Layout = blGlyphTop then + begin + HeaderGlyphPos.Y := (ClientSize.Y - HeaderGlyphSize.Y - TextSize.cy - TextSpacing) div 2; + TextPos.Y := HeaderGlyphPos.Y + HeaderGlyphSize.Y + TextSpacing; + end + else + begin + TextPos.Y := (ClientSize.Y - HeaderGlyphSize.Y - TextSize.cy - TextSpacing) div 2; + HeaderGlyphPos.Y := TextPos.Y + TextSize.cy + TextSpacing; + end; + end; + + // Each alignment needs special consideration. + case CurrentAlignment of + taLeftJustify: + begin + MinLeft := FMargin; + if UseSortGlyph and (FBidiMode <> bdLeftToRight) then + begin + // In RTL context is the sort glyph placed on the left hand side. + SortGlyphPos.X := MinLeft; + Inc(MinLeft, SortGlyphSize.cx + FSpacing); + end; + if Layout in [blGlyphTop, blGlyphBottom] then + begin + // Header glyph is above or below text, so both must be considered when calculating + // the left positition of the sort glyph (if it is on the right hand side). + TextPos.X := MinLeft; + if UseHeaderGlyph then + begin + HeaderGlyphPos.X := (ClientSize.X - HeaderGlyphSize.X) div 2; + if HeaderGlyphPos.X < MinLeft then + HeaderGlyphPos.X := MinLeft; + MinLeft := Max(TextPos.X + TextSize.cx + TextSpacing, HeaderGlyphPos.X + HeaderGlyphSize.X + FSpacing); + end + else + MinLeft := TextPos.X + TextSize.cx + TextSpacing; + end + else + begin + // Everything is lined up. TextSpacing might be 0 if there is no text. + // This simplifies the calculation because no extra tests are necessary. + if UseHeaderGlyph and (Layout = blGlyphLeft) then + begin + HeaderGlyphPos.X := MinLeft; + Inc(MinLeft, HeaderGlyphSize.X + FSpacing); + end; + TextPos.X := MinLeft; + Inc(MinLeft, TextSize.cx + TextSpacing); + if UseHeaderGlyph and (Layout = blGlyphRight) then + begin + HeaderGlyphPos.X := MinLeft; + Inc(MinLeft, HeaderGlyphSize.X + FSpacing); + end; + end; + if UseSortGlyph and (FBidiMode = bdLeftToRight) then + SortGlyphPos.X := MinLeft; + end; + taCenter: + begin + if Layout in [blGlyphTop, blGlyphBottom] then + begin + HeaderGlyphPos.X := (ClientSize.X - HeaderGlyphSize.X) div 2; + TextPos.X := (ClientSize.X - TextSize.cx) div 2; + if UseSortGlyph then + Dec(TextPos.X, SortGlyphSize.cx div 2); + end + else + begin + MinLeft := (ClientSize.X - HeaderGlyphSize.X - TextSpacing - TextSize.cx) div 2; + if UseHeaderGlyph and (Layout = blGlyphLeft) then + begin + HeaderGlyphPos.X := MinLeft; + Inc(MinLeft, HeaderGlyphSize.X + TextSpacing); + end; + TextPos.X := MinLeft; + Inc(MinLeft, TextSize.cx + TextSpacing); + if UseHeaderGlyph and (Layout = blGlyphRight) then + HeaderGlyphPos.X := MinLeft; + end; + if UseHeaderGlyph then + begin + MinLeft := Min(HeaderGlyphPos.X, TextPos.X); + MaxRight := Max(HeaderGlyphPos.X + HeaderGlyphSize.X, TextPos.X + TextSize.cx); + end + else + begin + MinLeft := TextPos.X; + MaxRight := TextPos.X + TextSize.cx; + end; + // Place the sort glyph directly to the left or right of the larger item. + if UseSortGlyph then + if FBidiMode = bdLeftToRight then + begin + // Sort glyph on the right hand side. + SortGlyphPos.X := MaxRight + FSpacing; + end + else + begin + // Sort glyph on the left hand side. + SortGlyphPos.X := MinLeft - FSpacing - SortGlyphSize.cx; + end; + end; + else + // taRightJustify + MaxRight := ClientSize.X - FMargin; + if UseSortGlyph and (FBidiMode = bdLeftToRight) then + begin + // In LTR context is the sort glyph placed on the right hand side. + Dec(MaxRight, SortGlyphSize.cx); + SortGlyphPos.X := MaxRight; + Dec(MaxRight, FSpacing); + end; + if Layout in [blGlyphTop, blGlyphBottom] then + begin + TextPos.X := MaxRight - TextSize.cx; + if UseHeaderGlyph then + begin + HeaderGlyphPos.X := (ClientSize.X - HeaderGlyphSize.X) div 2; + if HeaderGlyphPos.X + HeaderGlyphSize.X + FSpacing > MaxRight then + HeaderGlyphPos.X := MaxRight - HeaderGlyphSize.X - FSpacing; + MaxRight := Min(TextPos.X - TextSpacing, HeaderGlyphPos.X - FSpacing); + end + else + MaxRight := TextPos.X - TextSpacing; + end + else + begin + // Everything is lined up. TextSpacing might be 0 if there is no text. + // This simplifies the calculation because no extra tests are necessary. + if UseHeaderGlyph and (Layout = blGlyphRight) then + begin + HeaderGlyphPos.X := MaxRight - HeaderGlyphSize.X; + MaxRight := HeaderGlyphPos.X - FSpacing; + end; + TextPos.X := MaxRight - TextSize.cx; + MaxRight := TextPos.X - TextSpacing; + if UseHeaderGlyph and (Layout = blGlyphLeft) then + begin + HeaderGlyphPos.X := MaxRight - HeaderGlyphSize.X; + MaxRight := HeaderGlyphPos.X - FSpacing; + end; + end; + if UseSortGlyph and (FBidiMode <> bdLeftToRight) then + SortGlyphPos.X := MaxRight - SortGlyphSize.cx; + end; + end; + + // Once the position of each element is determined there remains only one but important step. + // The horizontal positions of every element must be adjusted so that it always fits into the + // given header area. This is accomplished by shorten the text appropriately. + + // These are the maximum bounds. Nothing goes beyond them. + MinLeft := FMargin; + MaxRight := ClientSize.X - FMargin; + if UseSortGlyph then + begin + if FBidiMode = bdLeftToRight then + begin + // Sort glyph on the right hand side. + if SortGlyphPos.X + SortGlyphSize.cx > MaxRight then + SortGlyphPos.X := MaxRight - SortGlyphSize.cx; + MaxRight := SortGlyphPos.X - FSpacing; + end; + + // Consider also the left side of the sort glyph regardless of the bidi mode. + if SortGlyphPos.X < MinLeft then + SortGlyphPos.X := MinLeft; + // Left border needs only adjustment if the sort glyph marks the left border. + if FBidiMode <> bdLeftToRight then + MinLeft := SortGlyphPos.X + SortGlyphSize.cx + FSpacing; + + // Finally transform sort glyph to its actual position. + Inc(SortGlyphPos.X, Client.Left); + Inc(SortGlyphPos.Y, Client.Top); + end; + if UseHeaderGlyph then + begin + if HeaderGlyphPos.X + HeaderGlyphSize.X > MaxRight then + HeaderGlyphPos.X := MaxRight - HeaderGlyphSize.X; + if Layout = blGlyphRight then + MaxRight := HeaderGlyphPos.X - FSpacing; + if HeaderGlyphPos.X < MinLeft then + HeaderGlyphPos.X := MinLeft; + if Layout = blGlyphLeft then + MinLeft := HeaderGlyphPos.X + HeaderGlyphSize.X + FSpacing; + if FCheckBox and (Owner.Header.MainColumn = Self.Index) then + Dec(HeaderGlyphPos.X, 2 + 2 * Integer(toShowRoot in Owner.FHeader.Treeview.TreeOptions.FPaintOptions)); + // Finally transform header glyph to its actual position. + Inc(HeaderGlyphPos.X, Client.Left); + Inc(HeaderGlyphPos.Y, Client.Top); + end; + if UseText then + begin + if TextPos.X < MinLeft then + TextPos.X := MinLeft; + OffsetRect(TextBounds, TextPos.X, TextPos.Y); + if TextBounds.Right > MaxRight then + TextBounds.Right := MaxRight; + OffsetRect(TextBounds, Client.Left, Client.Top); + + if coWrapCaption in FOptions then + begin + // Wrap the column caption if necessary. + R := TextBounds; + FCaptionText := WrapString(DC, FText, R, DT_RTLREADING and DrawFormat <> 0, DrawFormat); + GetStringDrawRect(DC, FCaptionText, R, DrawFormat); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.DefineProperties(Filer: TFiler); + +begin + inherited; + + // Must define a new name for the properties otherwise the VCL will try to load the wide string + // without asking us and screws it completely up. + Filer.DefineProperty('WideText', ReadText, WriteText, FText <> ''); + Filer.DefineProperty('WideHint', ReadHint, WriteHint, FHint <> ''); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.GetAbsoluteBounds(var Left, Right: Integer); + +// Returns the column's left and right bounds in header coordinates, that is, independant of the scrolling position. + +begin + Left := FLeft; + Right := FLeft + FWidth; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.GetDisplayName: string; + +// Returns the column text if it only contains ANSI characters, otherwise the column id is returned because the IDE +// still cannot handle Unicode strings. + +var + I: Integer; + +begin + // Check if the text of the column contains characters > 255 + I := 1; + while I <= Length(FText) do + begin + if Ord(FText[I]) > 255 then + Break; + Inc(I); + end; + + if I > Length(FText) then + Result := FText // implicit conversion + else + Result := Format('Column %d', [Index]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.GetOwner: TVirtualTreeColumns; + +begin + Result := Collection as TVirtualTreeColumns; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.ReadText(Reader: TReader); + +begin + case Reader.NextValue of + vaLString, vaString: + SetText(Reader.ReadString); + else + SetText(Reader.ReadWideString); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.ReadHint(Reader: TReader); + +begin + case Reader.NextValue of + vaLString, vaString: + FHint := Reader.ReadString; + else + FHint := Reader.ReadWideString; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.WriteHint(Writer: TWriter); + +begin + Writer.WriteWideString(FHint); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.WriteText(Writer: TWriter); + +begin + Writer.WriteWideString(FText); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.Assign(Source: TPersistent); + +var + OldOptions: TVTColumnOptions; + +begin + if Source is TVirtualTreeColumn then + begin + OldOptions := FOptions; + FOptions := []; + + BiDiMode := TVirtualTreeColumn(Source).BiDiMode; + ImageIndex := TVirtualTreeColumn(Source).ImageIndex; + Layout := TVirtualTreeColumn(Source).Layout; + Margin := TVirtualTreeColumn(Source).Margin; + MaxWidth := TVirtualTreeColumn(Source).MaxWidth; + MinWidth := TVirtualTreeColumn(Source).MinWidth; + Position := TVirtualTreeColumn(Source).Position; + Spacing := TVirtualTreeColumn(Source).Spacing; + Style := TVirtualTreeColumn(Source).Style; + Text := TVirtualTreeColumn(Source).Text; + Hint := TVirtualTreeColumn(Source).Hint; + Width := TVirtualTreeColumn(Source).Width; + Alignment := TVirtualTreeColumn(Source).Alignment; + CaptionAlignment := TVirtualTreeColumn(Source).CaptionAlignment; + Color := TVirtualTreeColumn(Source).Color; + Tag := TVirtualTreeColumn(Source).Tag; + + // Order is important. Assign options last. + FOptions := OldOptions; + Options := TVirtualTreeColumn(Source).Options; + + Changed(False); + end + else + inherited Assign(Source); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.Equals(OtherColumnObj: TObject): Boolean; +var + OtherColumn : TVirtualTreeColumn; +begin + if OtherColumnObj is TVirtualTreeColumn then + begin + OtherColumn := TVirtualTreeColumn (OtherColumnObj); + Result := (BiDiMode = OtherColumn.BiDiMode) and + (ImageIndex = OtherColumn.ImageIndex) and + (Layout = OtherColumn.Layout) and + (Margin = OtherColumn.Margin) and + (MaxWidth = OtherColumn.MaxWidth) and + (MinWidth = OtherColumn.MinWidth) and + (Position = OtherColumn.Position) and + (Spacing = OtherColumn.Spacing) and + (Style = OtherColumn.Style) and + (Text = OtherColumn.Text) and + (Hint = OtherColumn.Hint) and + (Width = OtherColumn.Width) and + (Alignment = OtherColumn.Alignment) and + (CaptionAlignment = OtherColumn.CaptionAlignment) and + (Color = OtherColumn.Color) and + (Tag = OtherColumn.Tag) and + (Options = OtherColumn.Options) + end + else + Result := False +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.GetRect: TRect; + +// Returns the rectangle this column occupies in the header (relative to (0, 0) of the non-client area). + +begin + with TVirtualTreeColumns(GetOwner).FHeader do + Result := Treeview.FHeaderRect; + Inc(Result.Left, FLeft); + Result.Right := Result.Left + FWidth; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.LoadFromStream(const Stream: TStream; Version: Integer); + + //--------------- local function -------------------------------------------- + + function ConvertOptions(Value: Cardinal): TVTColumnOptions; + + // Converts the given raw value which represents column options for possibly older + // formats to the current format. + + begin + if Version >= 3 then + Result := TVTColumnOptions(Word(Value and $FFFF)) + else + if Version = 2 then + Result := TVTColumnOptions(Word(Value and $FF)) + else + begin + // In version 2 coParentColor has been added. This needs an option shift for older stream formats. + // The first (lower) 4 options remain as they are. + Result := TVTColumnOptions(Word(Value) and $F); + Value := (Value and not $F) shl 1; + Result := Result + TVTColumnOptions(Word(Value and $FF)); + end; + end; + + //--------------- end local function ---------------------------------------- + +var + Dummy: Integer; + S: UnicodeString; + +begin + with Stream do + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + SetLength(S, Dummy); + ReadBuffer(PWideChar(S)^, 2 * Dummy); + Text := S; + ReadBuffer(Dummy, SizeOf(Dummy)); + SetLength(FHint, Dummy); + ReadBuffer(PWideChar(FHint)^, 2 * Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + Width := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + MinWidth := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + MaxWidth := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Style := TVirtualTreeColumnStyle(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + ImageIndex := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Layout := TVTHeaderColumnLayout(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + Margin := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Spacing := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + BiDiMode := TBiDiMode(Dummy); + + ReadBuffer(Dummy, SizeOf(Dummy)); + Options := ConvertOptions(Dummy); + + if Version > 0 then + begin + // Parts which have been introduced/changed with header stream version 1+. + ReadBuffer(Dummy, SizeOf(Dummy)); + Tag := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Alignment := TAlignment(Dummy); + + if Version > 1 then + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + Color := TColor(Dummy); + end; + + if Version > 5 then + begin + if coUseCaptionAlignment in FOptions then + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + CaptionAlignment := TAlignment(Dummy); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.ParentBiDiModeChanged; + +var + Columns: TVirtualTreeColumns; + +begin + if coParentBiDiMode in FOptions then + begin + Columns := GetOwner as TVirtualTreeColumns; + if Assigned(Columns) and (FBidiMode <> Columns.FHeader.Treeview.BiDiMode) then + begin + FBiDiMode := Columns.FHeader.Treeview.BiDiMode; + Changed(False); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.ParentColorChanged; + +var + Columns: TVirtualTreeColumns; + +begin + if coParentColor in FOptions then + begin + Columns := GetOwner as TVirtualTreeColumns; + if Assigned(Columns) and (FColor <> Columns.FHeader.Treeview.Color) then + begin + FColor := Columns.FHeader.Treeview.Color; + Changed(False); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.RestoreLastWidth; + +begin + TVirtualTreeColumns(GetOwner).AnimatedResize(Index, FLastWidth); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumn.SaveToStream(const Stream: TStream); + +var + Dummy: Integer; + +begin + with Stream do + begin + Dummy := Length(FText); + WriteBuffer(Dummy, SizeOf(Dummy)); + WriteBuffer(PWideChar(FText)^, 2 * Dummy); + Dummy := Length(FHint); + WriteBuffer(Dummy, SizeOf(Dummy)); + WriteBuffer(PWideChar(FHint)^, 2 * Dummy); + WriteBuffer(FWidth, SizeOf(FWidth)); + WriteBuffer(FMinWidth, SizeOf(FMinWidth)); + WriteBuffer(FMaxWidth, SizeOf(FMaxWidth)); + Dummy := Ord(FStyle); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := FImageIndex; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Ord(FLayout); + WriteBuffer(Dummy, SizeOf(Dummy)); + WriteBuffer(FMargin, SizeOf(FMargin)); + WriteBuffer(FSpacing, SizeOf(FSpacing)); + Dummy := Ord(FBiDiMode); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Word(FOptions); + WriteBuffer(Dummy, SizeOf(Dummy)); + + // parts introduced with stream version 1 + WriteBuffer(FTag, SizeOf(Dummy)); + Dummy := Cardinal(FAlignment); + WriteBuffer(Dummy, SizeOf(Dummy)); + + // parts introduced with stream version 2 + Dummy := Integer(FColor); + WriteBuffer(Dummy, SizeOf(Dummy)); + + // parts introduced with stream version 6 + if coUseCaptionAlignment in FOptions then + begin + Dummy := Cardinal(FCaptionAlignment); + WriteBuffer(Dummy, SizeOf(Dummy)); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumn.UseRightToLeftReading: Boolean; + +begin + Result := FBiDiMode <> bdLeftToRight; +end; + +//----------------- TVirtualTreeColumns -------------------------------------------------------------------------------- + +constructor TVirtualTreeColumns.Create(AOwner: TVTHeader); + +var + ColumnClass: TVirtualTreeColumnClass; + +begin + FHeader := AOwner; + + // Determine column class to be used in the header. + ColumnClass := AOwner.FOwner.GetColumnClass; + // The owner tree always returns the default tree column class if not changed by application/descendants. + inherited Create(ColumnClass); + + FHeaderBitmap := TBitmap.Create; + FHeaderBitmap.PixelFormat := pf32Bit; + + FHoverIndex := NoColumn; + FDownIndex := NoColumn; + FClickIndex := NoColumn; + FDropTarget := NoColumn; + FTrackIndex := NoColumn; + FDefaultWidth := 50; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVirtualTreeColumns.Destroy; + +begin + FHeaderBitmap.Free; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetCount: Integer; + +begin + Result := inherited Count; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetItem(Index: TColumnIndex): TVirtualTreeColumn; + +begin + Result := TVirtualTreeColumn(inherited GetItem(Index)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetNewIndex(P: TPoint; var OldIndex: TColumnIndex): Boolean; + +var + NewIndex: Integer; + +begin + Result := False; + // convert to local coordinates + Inc(P.Y, FHeader.FHeight); + NewIndex := ColumnFromPosition(P); + if NewIndex <> OldIndex then + begin + if OldIndex > NoColumn then + FHeader.Invalidate(Items[OldIndex]); + OldIndex := NewIndex; + if OldIndex > NoColumn then + FHeader.Invalidate(Items[OldIndex]); + Result := True; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.SetDefaultWidth(Value: Integer); + +begin + FDefaultWidth := Value; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.SetItem(Index: TColumnIndex; Value: TVirtualTreeColumn); + +begin + inherited SetItem(Index, Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.AdjustAutoSize(CurrentIndex: TColumnIndex; Force: Boolean = False); + +// Called only if the header is in auto-size mode which means a column needs to be so large +// that it fills all the horizontal space not occupied by the other columns. +// CurrentIndex (if not InvalidColumn) describes which column has just been resized. + +var + NewValue, + AutoIndex, + Index, + RestWidth: Integer; + +begin + if Count > 0 then + begin + // Determine index to be used for auto resizing. This is usually given by the owner's AutoSizeIndex, but + // could be different if the column whose resize caused the invokation here is either the auto column itself + // or visually to the right of the auto size column. + AutoIndex := FHeader.FAutoSizeIndex; + if (AutoIndex < 0) or (AutoIndex >= Count) then + AutoIndex := Count - 1; + + if AutoIndex >= 0 then + begin + with FHeader.Treeview do + begin + if HandleAllocated then + RestWidth := ClientWidth + else + RestWidth := Width; + end; + + // Go through all columns and calculate the rest space remaining. + for Index := 0 to Count - 1 do + if (Index <> AutoIndex) and (coVisible in Items[Index].FOptions) then + Dec(RestWidth, Items[Index].Width); + + with Items[AutoIndex] do + begin + NewValue := Max(MinWidth, Min(MaxWidth, RestWidth)); + if Force or (FWidth <> NewValue) then + begin + FWidth := NewValue; + UpdatePositions; + FHeader.Treeview.DoColumnResize(AutoIndex); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.AdjustDownColumn(P: TPoint): TColumnIndex; + +// Determines the column from the given position and returns it. If this column is allowed to be clicked then +// it is also kept for later use. + +begin + // Convert to local coordinates. + Inc(P.Y, FHeader.FHeight); + Result := ColumnFromPosition(P); + if (Result > NoColumn) and (Result <> FDownIndex) and (coAllowClick in Items[Result].FOptions) and + (coEnabled in Items[Result].FOptions) then + begin + if FDownIndex > NoColumn then + FHeader.Invalidate(Items[FDownIndex]); + FDownIndex := Result; + FCheckBoxHit := Items[Result].FHasImage and PtInRect(Items[Result].FImageRect, P) and Items[Result].CheckBox; + FHeader.Invalidate(Items[FDownIndex]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.AdjustHoverColumn(P: TPoint): Boolean; + +// Determines the new hover column index and returns True if the index actually changed else False. + +begin + Result := GetNewIndex(P, FHoverIndex); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.AdjustPosition(Column: TVirtualTreeColumn; Position: Cardinal); + +// Reorders the column position array so that the given column gets the given position. + +var + OldPosition: Cardinal; + +begin + OldPosition := Column.Position; + if OldPosition <> Position then + begin + if OldPosition < Position then + begin + // column will be moved up so move down other entries + Move(FPositionToIndex[OldPosition + 1], FPositionToIndex[OldPosition], (Position - OldPosition) * SizeOf(Cardinal)); + end + else + begin + // column will be moved down so move up other entries + Move(FPositionToIndex[Position], FPositionToIndex[Position + 1], (OldPosition - Position) * SizeOf(Cardinal)); + end; + FPositionToIndex[Position] := Column.Index; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.CanSplitterResize(P: TPoint; Column: TColumnIndex): Boolean; + +begin + Result := (Column > NoColumn) and ([coResizable, coVisible] * Items[Column].FOptions = [coResizable, coVisible]); + DoCanSplitterResize(P, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.DoCanSplitterResize(P: TPoint; Column: TColumnIndex; var Allowed: Boolean); + +begin + if Assigned(FHeader.Treeview.FOnCanSplitterResizeColumn) then + FHeader.Treeview.FOnCanSplitterResizeColumn(FHeader, P, Column, Allowed); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.DrawButtonText(DC: HDC; Caption: UnicodeString; Bounds: TRect; Enabled, Hot: Boolean; + DrawFormat: Cardinal; WrapCaption: Boolean); + +var + TextSpace: Integer; + Size: TSize; + +begin + if not WrapCaption then + begin + // Do we need to shorten the caption due to limited space? + GetTextExtentPoint32W(DC, PWideChar(Caption), Length(Caption), Size); + TextSpace := Bounds.Right - Bounds.Left; + if TextSpace < Size.cx then + Caption := ShortenString(DC, Caption, TextSpace); + end; + + SetBkMode(DC, TRANSPARENT); + if not Enabled then + begin + OffsetRect(Bounds, 1, 1); + SetTextColor(DC, ColorToRGB(clBtnHighlight)); + Windows.DrawTextW(DC, PWideChar(Caption), Length(Caption), Bounds, DrawFormat); + OffsetRect(Bounds, -1, -1); + SetTextColor(DC, ColorToRGB(clBtnShadow)); + Windows.DrawTextW(DC, PWideChar(Caption), Length(Caption), Bounds, DrawFormat); + end + else + begin + if Hot then + SetTextColor(DC, ColorToRGB(FHeader.Treeview.FColors.HeaderHotColor)) + else + SetTextColor(DC, ColorToRGB(FHeader.FFont.Color)); + Windows.DrawTextW(DC, PWideChar(Caption), Length(Caption), Bounds, DrawFormat); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.FixPositions; + +// Fixes column positions after loading from DFM or Bidi mode change. + +var + I: Integer; + +begin + for I := 0 to Count - 1 do + FPositionToIndex[Items[I].Position] := I; + + FNeedPositionsFix := False; + UpdatePositions(True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetColumnAndBounds(P: TPoint; var ColumnLeft, ColumnRight: Integer; + Relative: Boolean = True): Integer; + +// Returns the column where the mouse is currently in as well as the left and right bound of +// this column (Left and Right are undetermined if no column is involved). + +var + I: Integer; + +begin + Result := InvalidColumn; + if Relative and (P.X > Header.Columns.GetVisibleFixedWidth) then + ColumnLeft := -FHeader.Treeview.FEffectiveOffsetX + else + ColumnLeft := 0; + + if FHeader.Treeview.UseRightToLeftAlignment then + Inc(ColumnLeft, FHeader.Treeview.ComputeRTLOffset(True)); + + for I := 0 to Count - 1 do + with Items[FPositionToIndex[I]] do + if coVisible in FOptions then + begin + ColumnRight := ColumnLeft + FWidth; + if P.X < ColumnRight then + begin + Result := FPositionToIndex[I]; + Exit; + end; + ColumnLeft := ColumnRight; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetOwner: TPersistent; + +begin + Result := FHeader; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.HandleClick(P: TPoint; Button: TMouseButton; Force, DblClick: Boolean); + +// Generates a click event if the mouse button has been released over the same column it was pressed first. +// Alternatively, Force might be set to True to indicate that the down index does not matter (right, middle and +// double click). + +var + HitInfo: TVTHeaderHitInfo; + NewClickIndex: Integer; + +begin + // Convert vertical position to local coordinates. + Inc(P.Y, FHeader.FHeight); + NewClickIndex := ColumnFromPosition(P); + with HitInfo do + begin + X := P.X; + Y := P.Y; + Shift := FHeader.GetShiftState; + if DblClick then + Shift := Shift + [ssDouble]; + end; + HitInfo.Button := Button; + + if (NewClickIndex > NoColumn) and (coAllowClick in Items[NewClickIndex].FOptions) and + ((NewClickIndex = FDownIndex) or Force) then + begin + FClickIndex := NewClickIndex; + HitInfo.Column := NewClickIndex; + HitInfo.HitPosition := [hhiOnColumn]; + + if Items[NewClickIndex].FHasImage and PtInRect(Items[NewClickIndex].FImageRect, P) then + begin + Include(HitInfo.HitPosition, hhiOnIcon); + if Items[NewClickIndex].CheckBox then + begin + if Button = mbLeft then + FHeader.Treeview.UpdateColumnCheckState(Items[NewClickIndex]); + Include(HitInfo.HitPosition, hhiOnCheckbox); + end; + end; + end + else + begin + FClickIndex := NoColumn; + HitInfo.Column := NoColumn; + HitInfo.HitPosition := [hhiNoWhere]; + end; + + if (hoHeaderClickAutoSort in Header.Options) and (HitInfo.Button = mbLeft) and not DblClick and (HitInfo.Column >= 0) then begin + // handle automatic setting of SortColumn and toggling of the sort order + if HitInfo.Column<>Header.SortColumn then begin + // set sort column + Header.SortColumn := HitInfo.Column; + Header.SortDirection := Self[Header.SortColumn].DefaultSortDirection + end//if + else begin + // toggle sort direction + if Header.SortDirection = sdDescending then + Header.SortDirection := sdAscending + else + Header.SortDirection := sdDescending + end;//else + end;//if + + if DblClick then + FHeader.Treeview.DoHeaderDblClick(HitInfo) + else + FHeader.Treeview.DoHeaderClick(HitInfo); + + if not (hhiNoWhere in HitInfo.HitPosition) then + FHeader.Invalidate(Items[NewClickIndex]); + if (FClickIndex > NoColumn) and (FClickIndex <> NewClickIndex) then + FHeader.Invalidate(Items[FClickIndex]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.IndexChanged(OldIndex, NewIndex: Integer); + +// Called by a column when its index in the collection changes. If NewIndex is -1 then the column is +// about to be removed, otherwise it is moved to a new index. +// The method will then update the position array to reflect the change. + +var + I: Integer; + Increment: Integer; + Lower, + Upper: Integer; + +begin + if NewIndex = -1 then + begin + // Find position in the array with the old index. + Upper := High(FPositionToIndex); + for I := 0 to Upper do + begin + if FPositionToIndex[I] = OldIndex then + begin + // Index found. Move all higher entries one step down and remove the last entry. + if I < Upper then + Move(FPositionToIndex[I + 1], FPositionToIndex[I], (Upper - I) * SizeOf(TColumnIndex)); + end; + // Decrease all indices, which are greater than the index to be deleted. + if FPositionToIndex[I] > OldIndex then + Dec(FPositionToIndex[I]); + end; + SetLength(FPositionToIndex, High(FPositionToIndex)); + end + else + begin + if OldIndex < NewIndex then + Increment := -1 + else + Increment := 1; + + Lower := Min(OldIndex, NewIndex); + Upper := Max(OldIndex, NewIndex); + for I := 0 to High(FPositionToIndex) do + begin + if (FPositionToIndex[I] >= Lower) and (FPositionToIndex[I] < Upper) then + Inc(FPositionToIndex[I], Increment) + else + if FPositionToIndex[I] = OldIndex then + FPositionToIndex[I] := NewIndex; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.InitializePositionArray; + +// Ensures that the column position array contains as many entries as columns are defined. +// The array is resized and initialized with default values if needed. + +var + I, OldSize: Integer; + Changed: Boolean; + +begin + if Count <> Length(FPositionToIndex) then + begin + OldSize := Length(FPositionToIndex); + SetLength(FPositionToIndex, Count); + if Count > OldSize then + begin + // New items have been added, just set their position to the same as their index. + for I := OldSize to Count - 1 do + FPositionToIndex[I] := I; + end + else + begin + // Items have been deleted, so reindex remaining entries by decrementing values larger than the highest + // possible index until no entry is higher than this limit. + repeat + Changed := False; + for I := 0 to Count - 1 do + if FPositionToIndex[I] >= Count then + begin + Dec(FPositionToIndex[I]); + Changed := True; + end; + until not Changed; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.Notify(Item: TCollectionItem; Action: TCollectionNotification); + +begin + if Action in [cnExtracting, cnDeleting] then + with Header.Treeview do + if not (csLoading in ComponentState) and (FFocusedColumn = Item.Index) then + FFocusedColumn := NoColumn; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.ReorderColumns(RTL: Boolean); + +var + I: Integer; + +begin + if RTL then + begin + for I := 0 to Count - 1 do + FPositionToIndex[I] := Count - I - 1; + end + else + begin + for I := 0 to Count - 1 do + FPositionToIndex[I] := I; + end; + + UpdatePositions(True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.Update(Item: TCollectionItem); + +begin + // This is the only place which gets notified when a new column has been added or removed + // and we need this event to adjust the column position array. + InitializePositionArray; + if csLoading in Header.Treeview.ComponentState then + FNeedPositionsFix := True + else + UpdatePositions; + + // The first column which is created is by definition also the main column. + if (Count > 0) and (Header.FMainColumn < 0) then + FHeader.FMainColumn := 0; + + if not (csLoading in Header.Treeview.ComponentState) and not (hsLoading in FHeader.FStates) then + begin + with FHeader do + begin + if hoAutoResize in FOptions then + AdjustAutoSize(InvalidColumn); + if Assigned(Item) then + Invalidate(Item as TVirtualTreeColumn) + else + if Treeview.HandleAllocated then + begin + Treeview.UpdateHorizontalScrollBar(False); + Invalidate(nil); + Treeview.Invalidate; + end; + + if not (tsUpdating in Treeview.FStates) then + // This is mainly to let the designer know when a change occurs at design time which + // doesn't involve the object inspector (like column resizing with the mouse). + // This does NOT include design time code as the communication is done via an interface. + Treeview.UpdateDesigner; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.UpdatePositions(Force: Boolean = False); + +// Recalculates the left border of every column and updates their position property according to the +// PostionToIndex array which primarily determines where each column is placed visually. + +var + I, RunningPos: Integer; + +begin + if not FNeedPositionsFix and (Force or (UpdateCount = 0)) then + begin + RunningPos := 0; + for I := 0 to High(FPositionToIndex) do + with Items[FPositionToIndex[I]] do + begin + FPosition := I; + FLeft := RunningPos; + if coVisible in FOptions then + Inc(RunningPos, FWidth); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.Add: TVirtualTreeColumn; + +begin + Result := TVirtualTreeColumn(inherited Add); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.AnimatedResize(Column: TColumnIndex; NewWidth: Integer); + +// Resizes the given column animated by scrolling the window DC. + +var + OldWidth: Integer; + DC: HDC; + I, + Steps, + DX: Integer; + HeaderScrollRect, + ScrollRect, + R: TRect; + + NewBrush, + LastBrush: HBRUSH; + +begin + if not IsValidColumn(Column) then exit; // Just in case. + + // Make sure the width constrains are considered. + if NewWidth < Items[Column].FMinWidth then + NewWidth := Items[Column].FMinWidth; + if NewWidth > Items[Column].FMaxWidth then + NewWidth := Items[Column].FMaxWidth; + + OldWidth := Items[Column].Width; + // Nothing to do if the width is the same. + if OldWidth <> NewWidth then + begin + if not ( (hoDisableAnimatedResize in FHeader.Options) or + (coDisableAnimatedResize in Items[Column].Options) ) then + begin + DC := GetWindowDC(FHeader.Treeview.Handle); + with FHeader.Treeview do + try + Steps := 32; + DX := (NewWidth - OldWidth) div Steps; + + // Determination of the scroll rectangle is a bit complicated since we neither want + // to scroll the scrollbars nor the border of the treeview window. + HeaderScrollRect := FHeaderRect; + ScrollRect := HeaderScrollRect; + // Exclude the header itself from scrolling. + ScrollRect.Top := ScrollRect.Bottom; + ScrollRect.Bottom := ScrollRect.Top + ClientHeight; + ScrollRect.Right := ScrollRect.Left + ClientWidth; + with Items[Column] do + Inc(ScrollRect.Left, FLeft + FWidth); + HeaderScrollRect.Left := ScrollRect.Left; + HeaderScrollRect.Right := ScrollRect.Right; + + // When the new width is larger then avoid artefacts on the left hand side + // by deleting a small stripe + if NewWidth > OldWidth then + begin + R := ScrollRect; + NewBrush := CreateSolidBrush(ColorToRGB(Color)); + LastBrush := SelectObject(DC, NewBrush); + R.Right := R.Left + DX; + FillRect(DC, R, NewBrush); + SelectObject(DC, LastBrush); + DeleteObject(NewBrush); + end + else + begin + Inc(HeaderScrollRect.Left, DX); + Inc(ScrollRect.Left, DX); + end; + + for I := 0 to Steps - 1 do + begin + ScrollDC(DC, DX, 0, HeaderScrollRect, HeaderScrollRect, 0, nil); + Inc(HeaderScrollRect.Left, DX); + ScrollDC(DC, DX, 0, ScrollRect, ScrollRect, 0, nil); + Inc(ScrollRect.Left, DX); + Sleep(1); + end; + finally + ReleaseDC(Handle, DC); + end; + end; + Items[Column].Width := NewWidth; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.Assign(Source: TPersistent); + +begin + // Let the collection class assign the items. + inherited; + + if Source is TVirtualTreeColumns then + begin + // Copying the position array is the only needed task here. + FPositionToIndex := Copy(TVirtualTreeColumns(Source).FPositionToIndex, 0, MaxInt); + + // Make sure the left edges are correct after assignment. + FNeedPositionsFix := False; + UpdatePositions(True); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.Clear; + +begin + FClearing := True; + try + Header.Treeview.CancelEditNode; + + // Since we're freeing all columns, the following have to be true when we're done. + FHoverIndex := NoColumn; + FDownIndex := NoColumn; + FTrackIndex := NoColumn; + FClickIndex := NoColumn; + FCheckBoxHit := False; + + with Header do + if not (hsLoading in FStates) then + begin + FAutoSizeIndex := NoColumn; + FMainColumn := NoColumn; + FSortColumn := NoColumn; + end; + + with Header.Treeview do + if not (csLoading in ComponentState) then + FFocusedColumn := NoColumn; + + inherited Clear; + finally + FClearing := False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.ColumnFromPosition(P: TPoint; Relative: Boolean = True): TColumnIndex; + +// Determines the current column based on the position passed in P. + +var + I, Sum: Integer; + +begin + Result := InvalidColumn; + + // The position must be within the header area, but we extend the vertical bounds to the entire treeview area. + if (P.X >= 0) and (P.Y >= 0) and (P.Y <= FHeader.TreeView.Height) then + with FHeader, Treeview do + begin + if Relative and (P.X > GetVisibleFixedWidth) then + Sum := -FEffectiveOffsetX + else + Sum := 0; + + if UseRightToLeftAlignment then + Inc(Sum, ComputeRTLOffset(True)); + + for I := 0 to Count - 1 do + if coVisible in Items[FPositionToIndex[I]].FOptions then + begin + Inc(Sum, Items[FPositionToIndex[I]].Width); + if P.X < Sum then + begin + Result := FPositionToIndex[I]; + Break; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.ColumnFromPosition(PositionIndex: TColumnPosition): TColumnIndex; + +// Returns the index of the column at the given position. + +begin + if Integer(PositionIndex) < Length(FPositionToIndex) then + Result := FPositionToIndex[PositionIndex] + else + Result := NoColumn; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.Equals(OtherColumnsObj: TObject): Boolean; + +// Compares itself with the given set of columns and returns True if all published properties are the same +// (including column order), otherwise False is returned. + +var + I: Integer; + OtherColumns : TVirtualTreeColumns; + +begin + if not (OtherColumnsObj is TVirtualTreeColumns) then + begin + Result := False; + Exit + end; + + OtherColumns := TVirtualTreeColumns (OtherColumnsObj); + + // Same number of columns? + Result := OtherColumns.Count = Count; + if Result then + begin + // Same order of columns? + Result := CompareMem(Pointer(FPositionToIndex), Pointer(OtherColumns.FPositionToIndex), + Length(FPositionToIndex) * SizeOf(TColumnIndex)); + if Result then + begin + for I := 0 to Count - 1 do + if not Items[I].Equals(OtherColumns[I]) then + begin + Result := False; + Break; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.GetColumnBounds(Column: TColumnIndex; var Left, Right: Integer); + +// Returns the left and right bound of the given column. If Column is NoColumn then the entire client width is returned. + +begin + if Column <= NoColumn then + begin + Left := 0; + Right := FHeader.Treeview.ClientWidth; + end + else + begin + Left := Items[Column].Left; + Right := Left + Items[Column].Width; + if FHeader.Treeview.UseRightToLeftAlignment then + begin + Inc(Left, FHeader.Treeview.ComputeRTLOffset(True)); + Inc(Right, FHeader.Treeview.ComputeRTLOffset(True)); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetScrollWidth: Integer; + +// Returns the average width of all visible, non-fixed columns. If there is no such column the indent is returned. + +var + I: Integer; + ScrollColumnCount: Integer; + +begin + + Result := 0; + + ScrollColumnCount := 0; + for I := 0 to FHeader.Columns.Count - 1 do + begin + if ([coVisible, coFixed] * FHeader.Columns[I].Options = [coVisible]) then + begin + Inc(Result, FHeader.Columns[I].Width); + Inc(ScrollColumnCount); + end; + end; + + if ScrollColumnCount > 0 then // use average width + Result := Round(Result / ScrollColumnCount) + else // use indent + Result := Integer(FHeader.Treeview.FIndent); + +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetFirstVisibleColumn(ConsiderAllowFocus: Boolean = False): TColumnIndex; + +// Returns the index of the first visible column or "InvalidColumn" if either no columns are defined or +// all columns are hidden. +// If ConsiderAllowFocus is True then the column has not only to be visible but also focus has to be allowed. + +var + I: Integer; + +begin + Result := InvalidColumn; + for I := 0 to Count - 1 do + if (coVisible in Items[FPositionToIndex[I]].FOptions) and + ( (not ConsiderAllowFocus) or + (coAllowFocus in Items[FPositionToIndex[I]].FOptions) + ) then + begin + Result := FPositionToIndex[I]; + Break; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetLastVisibleColumn(ConsiderAllowFocus: Boolean = False): TColumnIndex; + +// Returns the index of the last visible column or "InvalidColumn" if either no columns are defined or +// all columns are hidden. +// If ConsiderAllowFocus is True then the column has not only to be visible but also focus has to be allowed. + +var + I: Integer; + +begin + Result := InvalidColumn; + for I := Count - 1 downto 0 do + if (coVisible in Items[FPositionToIndex[I]].FOptions) and + ( (not ConsiderAllowFocus) or + (coAllowFocus in Items[FPositionToIndex[I]].FOptions) + ) then + begin + Result := FPositionToIndex[I]; + Break; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetNextColumn(Column: TColumnIndex): TColumnIndex; + +// Returns the next column in display order. Column is the index of an item in the collection (a column). + +var + Position: Integer; + +begin + if Column < 0 then + Result := InvalidColumn + else + begin + Position := Items[Column].Position; + if Position < Count - 1 then + Result := FPositionToIndex[Position + 1] + else + Result := InvalidColumn; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetNextVisibleColumn(Column: TColumnIndex; ConsiderAllowFocus: Boolean = False): TColumnIndex; + +// Returns the next visible column in display order, Column is an index into the columns list. +// If ConsiderAllowFocus is True then the column has not only to be visible but also focus has to be allowed. + +begin + Result := Column; + repeat + Result := GetNextColumn(Result); + until (Result = InvalidColumn) or + ( (coVisible in Items[Result].FOptions) and + ( (not ConsiderAllowFocus) or + (coAllowFocus in Items[Result].FOptions) + ) + ); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetPreviousColumn(Column: TColumnIndex): TColumnIndex; + +// Returns the previous column in display order, Column is an index into the columns list. + +var + Position: Integer; + +begin + if Column < 0 then + Result := InvalidColumn + else + begin + Position := Items[Column].Position; + if Position > 0 then + Result := FPositionToIndex[Position - 1] + else + Result := InvalidColumn; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetPreviousVisibleColumn(Column: TColumnIndex; ConsiderAllowFocus: Boolean = False): TColumnIndex; + +// Returns the previous visible column in display order, Column is an index into the columns list. +// If ConsiderAllowFocus is True then the column has not only to be visible but also focus has to be allowed. + +begin + Result := Column; + repeat + Result := GetPreviousColumn(Result); + until (Result = InvalidColumn) or + ( (coVisible in Items[Result].FOptions) and + ( (not ConsiderAllowFocus) or + (coAllowFocus in Items[Result].FOptions) + ) + ); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetVisibleColumns: TColumnsArray; + +// Returns a list of all currently visible columns in actual order. + +var + I, Counter: Integer; + +begin + SetLength(Result, Count); + Counter := 0; + + for I := 0 to Count - 1 do + if coVisible in Items[FPositionToIndex[I]].FOptions then + begin + Result[Counter] := Items[FPositionToIndex[I]]; + Inc(Counter); + end; + // Set result length to actual visible count. + SetLength(Result, Counter); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.GetVisibleFixedWidth: Integer; + +// Determines the horizontal space all visible and fixed columns occupy. + +var + I: Integer; + +begin + Result := 0; + for I := 0 to Count - 1 do + begin + if Items[I].Options * [coVisible, coFixed] = [coVisible, coFixed] then + Inc(Result, Items[I].Width); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.IsValidColumn(Column: TColumnIndex): Boolean; + +// Determines whether the given column is valid or not, that is, whether it is one of the current columns. + +begin + Result := (Column > NoColumn) and (Column < Count); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.LoadFromStream(const Stream: TStream; Version: Integer); + +var + I, + ItemCount: Integer; + +begin + Clear; + Stream.ReadBuffer(ItemCount, SizeOf(ItemCount)); + // number of columns + if ItemCount > 0 then + begin + BeginUpdate; + try + for I := 0 to ItemCount - 1 do + Add.LoadFromStream(Stream, Version); + SetLength(FPositionToIndex, ItemCount); + Stream.ReadBuffer(FPositionToIndex[0], ItemCount * SizeOf(TColumnIndex)); + UpdatePositions(True); + finally + EndUpdate; + end; + end; + + // Data introduced with header stream version 5 + if Version > 4 then + Stream.ReadBuffer(FDefaultWidth, SizeOf(FDefaultWidth)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.PaintHeader(DC: HDC; R: TRect; HOffset: Integer); + +// Backward compatible header paint method. This method takes care of visually moving floating columns + +var + VisibleFixedWidth: Integer; + RTLOffset: Integer; + + procedure PaintFixedArea; + + begin + if VisibleFixedWidth > 0 then + PaintHeader(FHeaderBitmap.Canvas, + Rect(0, 0, Min(R.Right, VisibleFixedWidth), R.Bottom - R.Top), + Point(R.Left, R.Top), RTLOffset); + end; + +begin + // Adjust size of the header bitmap + with TWithSafeRect(FHeader.Treeview.FHeaderRect) do + begin + FHeaderBitmap.Width := Max(Right, R.Right - R.Left); + FHeaderBitmap.Height := Bottom; + end; + + VisibleFixedWidth := GetVisibleFixedWidth; + + // Consider right-to-left directionality. + if FHeader.TreeView.UseRightToLeftAlignment then + RTLOffset := FHeader.Treeview.ComputeRTLOffset + else + RTLOffset := 0; + + if RTLOffset = 0 then + PaintFixedArea; + + // Paint the floating part of the header. + PaintHeader(FHeaderBitmap.Canvas, + Rect(VisibleFixedWidth - HOffset, 0, R.Right + VisibleFixedWidth - HOffset, R.Bottom - R.Top), + Point(R.Left + VisibleFixedWidth, R.Top), RTLOffset); + + // In case of right-to-left directionality we paint the fixed part last. + if RTLOffset <> 0 then + PaintFixedArea; + + // Blit the result to target. + with TWithSafeRect(R) do + BitBlt(DC, Left, Top, Right - Left, Bottom - Top, FHeaderBitmap.Canvas.Handle, Left, Top, SRCCOPY); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.PaintHeader(TargetCanvas: TCanvas; R: TRect; const Target: TPoint; + RTLOffset: Integer = 0); + +// Main paint method to draw the header. +// This procedure will paint the a slice (given in R) out of HeaderRect into TargetCanvas starting at position Target. +// This function does not offer the option to visually move floating columns due to scrolling. To accomplish this you +// need to call this method twice. + +const + SortGlyphs: array[TSortDirection, Boolean] of Integer = ( // ascending/descending, normal/XP style + (3, 5) {ascending}, (2, 4) {descending} + ); + +var + Run: TColumnIndex; + RightBorderFlag, + NormalButtonStyle, + NormalButtonFlags, + PressedButtonStyle, + PressedButtonFlags, + RaisedButtonStyle, + RaisedButtonFlags: Cardinal; + Images: TCustomImageList; + OwnerDraw, + AdvancedOwnerDraw: Boolean; + PaintInfo: THeaderPaintInfo; + RequestedElements, + ActualElements: THeaderPaintElements; + + //--------------- local functions ------------------------------------------- + + procedure PrepareButtonStyles; + + // Prepare the button styles and flags for later usage. + + begin + RaisedButtonStyle := 0; + RaisedButtonFlags := 0; + case FHeader.Style of + hsThickButtons: + begin + NormalButtonStyle := BDR_RAISEDINNER or BDR_RAISEDOUTER; + NormalButtonFlags := BF_LEFT or BF_TOP or BF_BOTTOM or BF_MIDDLE or BF_SOFT or BF_ADJUST; + PressedButtonStyle := BDR_RAISEDINNER or BDR_RAISEDOUTER; + PressedButtonFlags := NormalButtonFlags or BF_RIGHT or BF_FLAT or BF_ADJUST; + end; + hsFlatButtons: + begin + NormalButtonStyle := BDR_RAISEDINNER; + NormalButtonFlags := BF_LEFT or BF_TOP or BF_BOTTOM or BF_MIDDLE or BF_ADJUST; + PressedButtonStyle := BDR_SUNKENOUTER; + PressedButtonFlags := BF_RECT or BF_MIDDLE or BF_ADJUST; + end; + else + // hsPlates or hsXPStyle, values are not used in the latter case + begin + NormalButtonStyle := BDR_RAISEDINNER; + NormalButtonFlags := BF_RECT or BF_MIDDLE or BF_SOFT or BF_ADJUST; + PressedButtonStyle := BDR_SUNKENOUTER; + PressedButtonFlags := BF_RECT or BF_MIDDLE or BF_ADJUST; + RaisedButtonStyle := BDR_RAISEDINNER; + RaisedButtonFlags := BF_LEFT or BF_TOP or BF_BOTTOM or BF_MIDDLE or BF_ADJUST; + end; + end; + end; + + //--------------------------------------------------------------------------- + + procedure DrawBackground; + + // Draw the header background. + + var + BackgroundRect: TRect; + Details: TThemedElementDetails; + + begin + BackgroundRect := Rect(Target.X, Target.Y, Target.X + R.Right - R.Left, Target.Y + FHeader.Height); + + with TargetCanvas do + begin + if hpeBackground in RequestedElements then + FHeader.Treeview.DoAdvancedHeaderDraw(PaintInfo, [hpeBackground]) + else + begin + if tsUseThemes in FHeader.Treeview.FStates then + begin + Details := ThemeServices.GetElementDetails(thHeaderItemRightNormal); + ThemeServices.DrawElement(Handle, Details, BackgroundRect, @BackgroundRect); + end + else begin + Brush.Color := FHeader.FBackground; + FillRect(BackgroundRect); + end; + end; + end; + end; + + //--------------------------------------------------------------------------- + + procedure PaintColumnHeader(AColumn: TColumnIndex; ATargetRect: TRect); + + // Draw a single column to TargetRect. The clipping rect needs to be set before + // this procedure is called. + + var + Y: Integer; + SavedDC: Integer; + ColCaptionText: UnicodeString; + ColImageInfo: TVTImageInfo; + SortIndex: Integer; + SortGlyphSize: TSize; + Glyph: TThemedHeader; + Details: TThemedElementDetails; + WrapCaption: Boolean; + DrawFormat: Cardinal; + Pos: TRect; + + begin + ColImageInfo.Ghosted := False; + PaintInfo.Column := Items[AColumn]; + with PaintInfo, Column do + begin + IsHoverIndex := (AColumn = FHoverIndex) and (hoHotTrack in FHeader.FOptions) and (coEnabled in FOptions); + IsDownIndex := (AColumn = FDownIndex) and not FCheckBoxHit; + + if (coShowDropMark in FOptions) and (AColumn = FDropTarget) and (AColumn <> FDragIndex) then + begin + if FDropBefore then + DropMark := dmmLeft + else + DropMark := dmmRight; + end + else + DropMark := dmmNone; + + IsEnabled := (coEnabled in FOptions) and (FHeader.Treeview.Enabled); + ShowHeaderGlyph := (hoShowImages in FHeader.FOptions) and ((Assigned(Images) and (FImageIndex > -1)) or FCheckBox); + ShowSortGlyph := (AColumn = FHeader.FSortColumn) and (hoShowSortGlyphs in FHeader.FOptions); + WrapCaption := coWrapCaption in FOptions; + + PaintRectangle := ATargetRect; + + // This path for text columns or advanced owner draw. + if (Style = vsText) or not OwnerDraw or AdvancedOwnerDraw then + begin + // See if the application wants to draw part of the header itself. + RequestedElements := []; + if AdvancedOwnerDraw then + begin + PaintInfo.Column := Items[AColumn]; + FHeader.Treeview.DoHeaderDrawQueryElements(PaintInfo, RequestedElements); + end; + + if ShowRightBorder or (AColumn < Count - 1) then + RightBorderFlag := BF_RIGHT + else + RightBorderFlag := 0; + + if hpeBackground in RequestedElements then + FHeader.Treeview.DoAdvancedHeaderDraw(PaintInfo, [hpeBackground]) + else + begin + if tsUseThemes in FHeader.Treeview.FStates then + begin + if IsDownIndex then + Details := ThemeServices.GetElementDetails(thHeaderItemPressed) + else + if IsHoverIndex then + Details := ThemeServices.GetElementDetails(thHeaderItemHot) + else + Details := ThemeServices.GetElementDetails(thHeaderItemNormal); + ThemeServices.DrawElement(TargetCanvas.Handle, Details, PaintRectangle, @PaintRectangle); + end + else + begin + if IsDownIndex then + DrawEdge(TargetCanvas.Handle, PaintRectangle, PressedButtonStyle, PressedButtonFlags) + else + // Plates have the special case of raising on mouse over. + if (FHeader.Style = hsPlates) and IsHoverIndex and + (coAllowClick in FOptions) and (coEnabled in FOptions) then + DrawEdge(TargetCanvas.Handle, PaintRectangle, RaisedButtonStyle, + RaisedButtonFlags or RightBorderFlag) + else + DrawEdge(TargetCanvas.Handle, PaintRectangle, NormalButtonStyle, + NormalButtonFlags or RightBorderFlag); + end; + end; + + PaintRectangle := ATargetRect; + + // calculate text and glyph position + InflateRect(PaintRectangle, -2, -2); + DrawFormat := DT_TOP or DT_NOPREFIX; + case CaptionAlignment of + taLeftJustify : DrawFormat := DrawFormat or DT_LEFT; + taRightJustify : DrawFormat := DrawFormat or DT_RIGHT; + taCenter : DrawFormat := DrawFormat or DT_CENTER; + end; + if UseRightToLeftReading then + DrawFormat := DrawFormat + DT_RTLREADING; + ComputeHeaderLayout(TargetCanvas.Handle, PaintRectangle, ShowHeaderGlyph, ShowSortGlyph, GlyphPos, + SortGlyphPos, SortGlyphSize, TextRectangle, DrawFormat); + + // Move glyph and text one pixel to the right and down to simulate a pressed button. + if IsDownIndex then + begin + OffsetRect(TextRectangle, 1, 1); + Inc(GlyphPos.X); + Inc(GlyphPos.Y); + Inc(SortGlyphPos.X); + Inc(SortGlyphPos.Y); + end; + + // Advanced owner draw allows to paint elements, which would normally not be painted (because of space + // limitations, empty captions etc.). + ActualElements := RequestedElements * [hpeHeaderGlyph, hpeSortGlyph, hpeDropMark, hpeText]; + + // main glyph + FHasImage := False; + if not (hpeHeaderGlyph in ActualElements) and ShowHeaderGlyph and + (not ShowSortGlyph or (FBidiMode <> bdLeftToRight) or (GlyphPos.X + Images.Width <= SortGlyphPos.X) ) then + begin + if not FCheckBox then + begin + ColImageInfo.Images := Images; + Images.Draw(TargetCanvas, GlyphPos.X, GlyphPos.Y, FImageIndex, IsEnabled); + end + else + begin + with Header.Treeview do + begin + ColImageInfo.Images := GetCheckImageListFor(CheckImageKind); + ColImageInfo.Index := GetCheckImage(nil, FCheckType, FCheckState, IsEnabled); + ColImageInfo.XPos := GlyphPos.X; + ColImageInfo.YPos := GlyphPos.Y; + PaintCheckImage(TargetCanvas, ColImageInfo, False); + end; + end; + + FHasImage := True; + with TWithSafeRect(FImageRect) do + begin + Left := GlyphPos.X; + Top := GlyphPos.Y; + Right := Left + ColImageInfo.Images.Width; + Bottom := Top + ColImageInfo.Images.Height; + end; + end; + + // caption + if WrapCaption then + ColCaptionText := FCaptionText + else + ColCaptionText := Text; + + if not (hpeText in ActualElements) and (Length(Text) > 0) then + DrawButtonText(TargetCanvas.Handle, ColCaptionText, TextRectangle, IsEnabled, + IsHoverIndex and (hoHotTrack in FHeader.FOptions) and + not (tsUseThemes in FHeader.Treeview.FStates), DrawFormat, WrapCaption); + + // sort glyph + if not (hpeSortGlyph in ActualElements) and ShowSortGlyph then + begin + if tsUseExplorerTheme in FHeader.Treeview.FStates then + begin + Pos.TopLeft := SortGlyphPos; + Pos.Right := Pos.Left + SortGlyphSize.cx; + Pos.Bottom := Pos.Top + SortGlyphSize.cy; + if FHeader.FSortDirection = sdAscending then + Glyph := thHeaderSortArrowSortedUp + else + Glyph := thHeaderSortArrowSortedDown; + Details := ThemeServices.GetElementDetails(Glyph); + ThemeServices.DrawElement(TargetCanvas.Handle, Details, Pos, @Pos); + end + else + begin + SortIndex := SortGlyphs[FHeader.FSortDirection, tsUseThemes in FHeader.Treeview.FStates]; + UtilityImages.Draw(TargetCanvas, SortGlyphPos.X, SortGlyphPos.Y, SortIndex); + end; + end; + + // Show an indication if this column is the current drop target in a header drag operation. + if not (hpeDropMark in ActualElements) and (DropMark <> dmmNone) then + begin + Y := (PaintRectangle.Top + PaintRectangle.Bottom - UtilityImages.Height) div 2; + if DropMark = dmmLeft then + UtilityImages.Draw(TargetCanvas, PaintRectangle.Left, Y, 0) + else + UtilityImages.Draw(TargetCanvas, PaintRectangle.Right - 16 , Y, 1); + end; + + if ActualElements <> [] then + begin + SavedDC := SaveDC(TargetCanvas.Handle); + FHeader.Treeview.DoAdvancedHeaderDraw(PaintInfo, ActualElements); + RestoreDC(TargetCanvas.Handle, SavedDC); + end; + end + else // Let application draw the header. + FHeader.Treeview.DoHeaderDraw(TargetCanvas, Items[AColumn], PaintRectangle, IsHoverIndex, IsDownIndex, + DropMark); + end; + end; + + //--------------- end local functions --------------------------------------- + +var + TargetRect: TRect; + MaxX: Integer; + +begin + if IsRectEmpty(R) then + Exit; + + // If both draw posibillities are specified then prefer the advanced way. + AdvancedOwnerDraw := (hoOwnerDraw in FHeader.FOptions) and Assigned(FHeader.Treeview.FOnAdvancedHeaderDraw) and + Assigned(FHeader.Treeview.FOnHeaderDrawQueryElements) and not (csDesigning in FHeader.Treeview.ComponentState); + OwnerDraw := (hoOwnerDraw in FHeader.FOptions) and Assigned(FHeader.Treeview.FOnHeaderDraw) and + not (csDesigning in FHeader.Treeview.ComponentState) and not AdvancedOwnerDraw; + + ZeroMemory(@PaintInfo, SizeOf(PaintInfo)); + PaintInfo.TargetCanvas := TargetCanvas; + + with PaintInfo, TargetCanvas do + begin + // Use shortcuts for the images and the font. + Images := FHeader.FImages; + Font := FHeader.FFont; + + PrepareButtonStyles; + + // At first, query the application which parts of the header it wants to draw on its own. + RequestedElements := []; + if AdvancedOwnerDraw then + begin + PaintRectangle := R; + Column := nil; + FHeader.Treeview.DoHeaderDrawQueryElements(PaintInfo, RequestedElements); + end; + + // Draw the background. + DrawBackground; + + // Now that we have drawn the background, we apply the header's dimensions to R. + R := Rect(Max(R.Left, 0), Max(R.Top, 0), Min(R.Right, TotalWidth), Min(R.Bottom, Header.Height)); + + // Determine where to stop. + MaxX := Target.X + R.Right - R.Left; + + // Determine the start column. + Run := ColumnFromPosition(Point(R.Left + RTLOffset, 0), False); + if Run <= NoColumn then + Exit; + + TargetRect.Top := Target.Y; + TargetRect.Bottom := Target.Y + R.Bottom - R.Top; + TargetRect.Left := Target.X - R.Left + Items[Run].FLeft + RTLOffset; + // TargetRect.Right will be set in the loop + + ShowRightBorder := (FHeader.Style = hsThickButtons) or not (hoAutoResize in FHeader.FOptions) or + (FHeader.Treeview.BevelKind = bkNone); + + // Now go for each button. + while (Run > NoColumn) and (TargetRect.Left < MaxX) do + begin + TargetRect.Right := TargetRect.Left + Items[Run].FWidth; + + // create a clipping rect to limit painting to button area + ClipCanvas(TargetCanvas, Rect(Max(TargetRect.Left, Target.X), Target.Y + R.Top, + Min(TargetRect.Right, MaxX), TargetRect.Bottom)); + + PaintColumnHeader(Run, TargetRect); + + SelectClipRgn(Handle, 0); + + TargetRect.Left := TargetRect.Right; + Run := GetNextVisibleColumn(Run) + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualTreeColumns.SaveToStream(const Stream: TStream); + +var + I: Integer; + +begin + I := Count; + Stream.WriteBuffer(I, SizeOf(I)); + if I > 0 then + begin + for I := 0 to Count - 1 do + TVirtualTreeColumn(Items[I]).SaveToStream(Stream); + + Stream.WriteBuffer(FPositionToIndex[0], Count * SizeOf(TColumnIndex)); + end; + + // Data introduced with header stream version 5. + Stream.WriteBuffer(DefaultWidth, SizeOf(DefaultWidth)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualTreeColumns.TotalWidth: Integer; + +var + LastColumn: TColumnIndex; + +begin + Result := 0; + if (Count > 0) and (Length(FPositionToIndex) > 0) then + begin + LastColumn := FPositionToIndex[Count - 1]; + if not (coVisible in Items[LastColumn].FOptions) then + LastColumn := GetPreviousVisibleColumn(LastColumn); + if LastColumn > NoColumn then + with Items[LastColumn] do + Result := FLeft + FWidth + end; +end; + +//----------------- TVTFixedAreaConstraints ---------------------------------------------------------------------------- + +constructor TVTFixedAreaConstraints.Create(AOwner: TVTHeader); + +begin + inherited Create; + + FHeader := AOwner; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTFixedAreaConstraints.SetConstraints(Index: Integer; Value: TVTConstraintPercent); + +begin + case Index of + 0: + if Value <> FMaxHeightPercent then + begin + FMaxHeightPercent := Value; + if (Value > 0) and (Value < FMinHeightPercent) then + FMinHeightPercent := Value; + Change; + end; + 1: + if Value <> FMaxWidthPercent then + begin + FMaxWidthPercent := Value; + if (Value > 0) and (Value < FMinWidthPercent) then + FMinWidthPercent := Value; + Change; + end; + 2: + if Value <> FMinHeightPercent then + begin + FMinHeightPercent := Value; + if (FMaxHeightPercent > 0) and (Value > FMaxHeightPercent) then + FMaxHeightPercent := Value; + Change; + end; + 3: + if Value <> FMinWidthPercent then + begin + FMinWidthPercent := Value; + if (FMaxWidthPercent > 0) and (Value > FMaxWidthPercent) then + FMaxWidthPercent := Value; + Change; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTFixedAreaConstraints.Change; + +begin + if Assigned(FOnChange) then + FOnChange(Self); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTFixedAreaConstraints.Assign(Source: TPersistent); + +begin + if Source is TVTFixedAreaConstraints then + begin + FMaxHeightPercent := TVTFixedAreaConstraints(Source).FMaxHeightPercent; + FMaxWidthPercent := TVTFixedAreaConstraints(Source).FMaxWidthPercent; + FMinHeightPercent := TVTFixedAreaConstraints(Source).FMinHeightPercent; + FMinWidthPercent := TVTFixedAreaConstraints(Source).FMinWidthPercent; + Change; + end + else + inherited; +end; + +//----------------- TVTHeader ----------------------------------------------------------------------------------------- + +constructor TVTHeader.Create(AOwner: TBaseVirtualTree); + +begin + inherited Create; + FOwner := AOwner; + FColumns := GetColumnsClass.Create(Self); + FHeight := 17; + FDefaultHeight := 17; + FMinHeight := 10; + FMaxHeight := 10000; + FFont := TFont.Create; + FFont.OnChange := FontChanged; + FParentFont := False; + FBackground := clBtnFace; + FOptions := [hoColumnResize, hoDrag, hoShowSortGlyphs]; + + FImageChangeLink := TChangeLink.Create; + FImageChangeLink.OnChange := ImageListChange; + + FSortColumn := NoColumn; + FSortDirection := sdAscending; + FMainColumn := NoColumn; + + FDragImage := TVTDragImage.Create(AOwner); + with FDragImage do + begin + Fade := False; + PostBlendBias := 0; + PreBlendBias := -50; + Transparency := 140; + end; + + FFixedAreaConstraints := TVTFixedAreaConstraints.Create(Self); + FFixedAreaConstraints.OnChange := FixedAreaConstraintsChanged; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TVTHeader.Destroy; + +begin + FDragImage.Free; + FFixedAreaConstraints.Free; + FImageChangeLink.Free; + FFont.Free; + FColumns.Clear; // TCollection's Clear method is not virtual, so we have to call our own Clear method manually. + FColumns.Free; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.FontChanged(Sender: TObject); + +begin + Invalidate(nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.GetMainColumn: TColumnIndex; + +begin + if FColumns.Count > 0 then + Result := FMainColumn + else + Result := NoColumn; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.GetUseColumns: Boolean; + +begin + Result := FColumns.Count > 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.IsFontStored: Boolean; + +begin + Result := not ParentFont; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetAutoSizeIndex(Value: TColumnIndex); + +begin + if FAutoSizeIndex <> Value then + begin + FAutoSizeIndex := Value; + if hoAutoResize in FOptions then + Columns.AdjustAutoSize(InvalidColumn); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetBackground(Value: TColor); + +begin + if FBackground <> Value then + begin + FBackground := Value; + Invalidate(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetColumns(Value: TVirtualTreeColumns); + +begin + FColumns.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetDefaultHeight(Value: Integer); + +begin + if Value < FMinHeight then + Value := FMinHeight; + if Value > FMaxHeight then + Value := FMaxHeight; + + if FHeight = FDefaultHeight then + SetHeight(Value); + FDefaultHeight := Value; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetFont(const Value: TFont); + +begin + FFont.Assign(Value); + FParentFont := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetHeight(Value: Integer); + +var + RelativeMaxHeight, + RelativeMinHeight, + EffectiveMaxHeight, + EffectiveMinHeight: Integer; + +begin + if not TreeView.HandleAllocated then + begin + FHeight := Value; + Include(FStates, hsNeedScaling); + end + else + begin + with FFixedAreaConstraints do + begin + RelativeMaxHeight := ((Treeview.ClientHeight + FHeight) * FMaxHeightPercent) div 100; + RelativeMinHeight := ((Treeview.ClientHeight + FHeight) * FMinHeightPercent) div 100; + + EffectiveMinHeight := IfThen(FMaxHeightPercent > 0, Min(RelativeMaxHeight, FMinHeight), FMinHeight); + EffectiveMaxHeight := IfThen(FMinHeightPercent > 0, Max(RelativeMinHeight, FMaxHeight), FMaxHeight); + + Value := Min(Max(Value, EffectiveMinHeight), EffectiveMaxHeight); + if FMinHeightPercent > 0 then + Value := Max(RelativeMinHeight, Value); + if FMaxHeightPercent > 0 then + Value := Min(RelativeMaxHeight, Value); + end; + + if FHeight <> Value then + begin + FHeight := Value; + if not (csLoading in Treeview.ComponentState) and not (hsScaling in FStates) then + RecalculateHeader; + Treeview.Invalidate; + UpdateWindow(Treeview.Handle); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetImages(const Value: TCustomImageList); + +begin + if FImages <> Value then + begin + if Assigned(FImages) then + begin + FImages.UnRegisterChanges(FImageChangeLink); + FImages.RemoveFreeNotification(FOwner); + end; + FImages := Value; + if Assigned(FImages) then + begin + FImages.RegisterChanges(FImageChangeLink); + FImages.FreeNotification(FOwner); + end; + if not (csLoading in Treeview.ComponentState) then + Invalidate(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetMainColumn(Value: TColumnIndex); + +begin + if csLoading in Treeview.ComponentState then + FMainColumn := Value + else + begin + if Value < 0 then + Value := 0; + if Value > FColumns.Count - 1 then + Value := FColumns.Count - 1; + if Value <> FMainColumn then + begin + FMainColumn := Value; + if not (csLoading in Treeview.ComponentState) then + begin + Treeview.MainColumnChanged; + if not (toExtendedFocus in Treeview.FOptions.FSelectionOptions) then + Treeview.FocusedColumn := FMainColumn; + Treeview.Invalidate; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetMaxHeight(Value: Integer); + +begin + if Value < FMinHeight then + Value := FMinHeight; + FMaxHeight := Value; + SetHeight(FHeight); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetMinHeight(Value: Integer); + +begin + if Value < 0 then + Value := 0; + if Value > FMaxHeight then + Value := FMaxHeight; + FMinHeight := Value; + SetHeight(FHeight); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetOptions(Value: TVTHeaderOptions); + +var + ToBeSet, + ToBeCleared: TVTHeaderOptions; + +begin + ToBeSet := Value - FOptions; + ToBeCleared := FOptions - Value; + FOptions := Value; + + if (hoAutoResize in (ToBeSet + ToBeCleared)) and (FColumns.Count > 0) then + begin + FColumns.AdjustAutoSize(InvalidColumn); + if Treeview.HandleAllocated then + begin + Treeview.UpdateHorizontalScrollBar(False); + if hoAutoResize in ToBeSet then + Treeview.Invalidate; + end; + end; + + if not (csLoading in Treeview.ComponentState) and Treeview.HandleAllocated then + begin + if hoVisible in (ToBeSet + ToBeCleared) then + RecalculateHeader; + Invalidate(nil); + Treeview.Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetParentFont(Value: Boolean); + +begin + if FParentFont <> Value then + begin + FParentFont := Value; + if FParentFont then + FFont.Assign(FOwner.Font); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetSortColumn(Value: TColumnIndex); + +begin + if csLoading in Treeview.ComponentState then + FSortColumn := Value + else + DoSetSortColumn(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetSortDirection(const Value: TSortDirection); + +begin + if Value <> FSortDirection then + begin + FSortDirection := Value; + Invalidate(nil); + if (toAutoSort in Treeview.FOptions.FAutoOptions) and (Treeview.FUpdateCount = 0) then + Treeview.SortTree(FSortColumn, FSortDirection, True); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.CanSplitterResize(P: TPoint): Boolean; + +begin + Result := hoHeightResize in FOptions; + DoCanSplitterResize(P, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SetStyle(Value: TVTHeaderStyle); + +begin + if FStyle <> Value then + begin + FStyle := Value; + if not (csLoading in Treeview.ComponentState) then + Invalidate(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.CanWriteColumns: Boolean; + +// descendants may override this to optionally prevent column writing (e.g. if they are build dynamically). + +begin + Result := True; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.ChangeScale(M, D: Integer); + +begin + FFont.Size := MulDiv(FFont.Size, M, D); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DetermineSplitterIndex(P: TPoint): Boolean; + +// Tries to find the index of that column whose right border corresponds to P. +// Result is True if column border was hit (with -3..+5 pixels tolerance). +// For continuous resizing the current track index and the column's left/right border are set. +// Note: The hit test is checking from right to left (or left to right in RTL mode) to make enlarging of zero-sized +// columns possible. + +var + I, + VisibleFixedWidth: Integer; + SplitPoint: Integer; + + //--------------- local function -------------------------------------------- + + function IsNearBy(IsFixedCol: Boolean; LeftTolerance, RightTolerance: Integer): Boolean; + + begin + if IsFixedCol then + Result := (P.X < SplitPoint + Treeview.FEffectiveOffsetX + RightTolerance) and (P.X > SplitPoint + Treeview.FEffectiveOffsetX - LeftTolerance) + else + Result := (P.X > VisibleFixedWidth) and (P.X < SplitPoint + RightTolerance) and (P.X > SplitPoint - LeftTolerance); + end; + + //--------------- end local function ---------------------------------------- + +begin + Result := False; + FColumns.FTrackIndex := NoColumn; + + VisibleFixedWidth := FColumns.GetVisibleFixedWidth; + + if FColumns.Count > 0 then + begin + if Treeview.UseRightToLeftAlignment then + begin + SplitPoint := -Treeview.FEffectiveOffsetX; + if Integer(Treeview.FRangeX) < Treeview.ClientWidth then + Inc(SplitPoint, Treeview.ClientWidth - Integer(Treeview.FRangeX)); + + for I := 0 to FColumns.Count - 1 do + with FColumns, Items[FPositionToIndex[I]] do + if coVisible in FOptions then + begin + if IsNearBy(coFixed in FOptions, 5, 3) then + begin + if CanSplitterResize(P, FPositionToIndex[I]) then + begin + Result := True; + FTrackIndex := FPositionToIndex[I]; + + // Keep the right border of this column. This and the current mouse position + // directly determine the current column width. + FTrackPoint.X := SplitPoint + IfThen(coFixed in FOptions, Treeview.FEffectiveOffsetX) + FWidth; + FTrackPoint.Y := P.Y; + Break; + end; + end; + Inc(SplitPoint, FWidth); + end; + end + else + begin + SplitPoint := -Treeview.FEffectiveOffsetX + Integer(Treeview.FRangeX); + + for I := FColumns.Count - 1 downto 0 do + with FColumns, Items[FPositionToIndex[I]] do + if coVisible in FOptions then + begin + if IsNearBy(coFixed in FOptions, 3, 5) then + begin + if CanSplitterResize(P, FPositionToIndex[I]) then + begin + Result := True; + FTrackIndex := FPositionToIndex[I]; + + // Keep the left border of this column. This and the current mouse position + // directly determine the current column width. + FTrackPoint.X := SplitPoint + IfThen(coFixed in FOptions, Treeview.FEffectiveOffsetX) - FWidth; + FTrackPoint.Y := P.Y; + Break; + end; + end; + Dec(SplitPoint, FWidth); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoAfterAutoFitColumn(Column: TColumnIndex); + +begin + if Assigned(TreeView.FOnAfterAutoFitColumn) then + TreeView.FOnAfterAutoFitColumn(Self, Column); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoAfterColumnWidthTracking(Column: TColumnIndex); + +// Tell the application that a column width tracking operation has been finished. + +begin + if Assigned(TreeView.FOnAfterColumnWidthTracking) then + TreeView.FOnAfterColumnWidthTracking(Self, Column); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoAfterHeightTracking; + +// Tell the application that a height tracking operation has been finished. + +begin + if Assigned(TreeView.FOnAfterHeaderHeightTracking) then + TreeView.FOnAfterHeaderHeightTracking(Self); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoBeforeAutoFitColumn(Column: TColumnIndex; SmartAutoFitType: TSmartAutoFitType): Boolean; + +// Query the application if we may autofit a column. + +begin + Result := True; + if Assigned(TreeView.FOnBeforeAutoFitColumn) then + TreeView.FOnBeforeAutoFitColumn(Self, Column, SmartAutoFitType, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoBeforeColumnWidthTracking(Column: TColumnIndex; Shift: TShiftState); + +// Tell the a application that a column width tracking operation may begin. + +begin + if Assigned(TreeView.FOnBeforeColumnWidthTracking) then + TreeView.FOnBeforeColumnWidthTracking(Self, Column, Shift); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoBeforeHeightTracking(Shift: TShiftState); + +// Tell the application that a height tracking operation may begin. + +begin + if Assigned(TreeView.FOnBeforeHeaderHeightTracking) then + TreeView.FOnBeforeHeaderHeightTracking(Self, Shift); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoCanSplitterResize(P: TPoint; var Allowed: Boolean); +begin + if Assigned(TreeView.FOnCanSplitterResizeHeader) then + TreeView.FOnCanSplitterResizeHeader(Self, P, Allowed); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoColumnWidthDblClickResize(Column: TColumnIndex; P: TPoint; Shift: TShiftState): Boolean; + +// Queries the application whether a double click on the column splitter should resize the column. + +begin + Result := True; + if Assigned(TreeView.FOnColumnWidthDblClickResize) then + TreeView.FOnColumnWidthDblClickResize(Self, Column, Shift, P, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoColumnWidthTracking(Column: TColumnIndex; Shift: TShiftState; var TrackPoint: TPoint; P: TPoint): Boolean; + +begin + Result := True; + if Assigned(TreeView.FOnColumnWidthTracking) then + TreeView.FOnColumnWidthTracking(Self, Column, Shift, TrackPoint, P, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoGetPopupMenu(Column: TColumnIndex; Position: TPoint): TPopupMenu; + +// Queries the application whether there is a column specific header popup menu. + +var + AskParent: Boolean; + +begin + Result := nil; + if Assigned(TreeView.FOnGetPopupMenu) then + TreeView.FOnGetPopupMenu(TreeView, nil, Column, Position, AskParent, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoHeightTracking(var P: TPoint; Shift: TShiftState): Boolean; + +begin + Result := True; + if Assigned(TreeView.FOnHeaderHeightTracking) then + TreeView.FOnHeaderHeightTracking(Self, P, Shift, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.DoHeightDblClickResize(var P: TPoint; Shift: TShiftState): Boolean; + +begin + Result := True; + if Assigned(TreeView.FOnHeaderHeightDblClickResize) then + TreeView.FOnHeaderHeightDblClickResize(Self, P, Shift, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DoSetSortColumn(Value: TColumnIndex); + +begin + if Value < NoColumn then + Value := NoColumn; + if Value > Columns.Count - 1 then + Value := Columns.Count - 1; + if FSortColumn <> Value then + begin + if FSortColumn > NoColumn then + Invalidate(Columns[FSortColumn]); + FSortColumn := Value; + if FSortColumn > NoColumn then + Invalidate(Columns[FSortColumn]); + if (toAutoSort in Treeview.FOptions.FAutoOptions) and (Treeview.FUpdateCount = 0) then + Treeview.SortTree(FSortColumn, FSortDirection, True); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.DragTo(P: TPoint); + +// Moves the drag image to a new position, which is determined from the passed point P and the previous +// mouse position. + +var + I, + NewTarget: Integer; + // optimized drag image move support + ClientP: TPoint; + Left, + Right: Integer; + NeedRepaint: Boolean; // True if the screen needs an update (changed drop target or drop side) + +begin + // Determine new drop target and which side of it is prefered. + ClientP := Treeview.ScreenToClient(P); + // Make coordinates relative to (0, 0) of the non-client area. + Inc(ClientP.Y, FHeight); + NewTarget := FColumns.ColumnFromPosition(ClientP); + NeedRepaint := (NewTarget <> InvalidColumn) and (NewTarget <> FColumns.FDropTarget); + if NewTarget >= 0 then + begin + FColumns.GetColumnBounds(NewTarget, Left, Right); + if (ClientP.X < ((Left + Right) div 2)) <> FColumns.FDropBefore then + begin + NeedRepaint := True; + FColumns.FDropBefore := not FColumns.FDropBefore; + end; + end; + + if NeedRepaint then + begin + // Invalidate columns which need a repaint. + if FColumns.FDropTarget > NoColumn then + begin + I := FColumns.FDropTarget; + FColumns.FDropTarget := NoColumn; + Invalidate(FColumns.Items[I]); + end; + if (NewTarget > NoColumn) and (NewTarget <> FColumns.FDropTarget) then + begin + Invalidate(FColumns.Items[NewTarget]); + FColumns.FDropTarget := NewTarget; + end; + end; + + FDragImage.DragTo(P, NeedRepaint); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.FixedAreaConstraintsChanged(Sender: TObject); + +// This method gets called when FFixedAreaConstraints is changed. + +begin + Include(FStates, hsNeedScaling); + if Treeview.HandleAllocated then + RescaleHeader; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.GetColumnsClass: TVirtualTreeColumnsClass; + +// Returns the class to be used for the actual column implementation. descendants may optionally override this and +// return their own class. + +begin + Result := TVirtualTreeColumns; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.GetOwner: TPersistent; + +begin + Result := FOwner; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.GetShiftState: TShiftState; + +begin + Result := []; + if GetKeyState(VK_SHIFT) < 0 then + Include(Result, ssShift); + if GetKeyState(VK_CONTROL) < 0 then + Include(Result, ssCtrl); + if GetKeyState(VK_MENU) < 0 then + Include(Result, ssAlt); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.HandleHeaderMouseMove(var Message: TWMMouseMove): Boolean; + +var + P: TPoint; + NextColumn, + I: TColumnIndex; + NewWidth: Integer; + +begin + Result := False; + with Message do + begin + P := Point(XPos, YPos); + if hsColumnWidthTrackPending in FStates then + begin + Treeview.StopTimer(HeaderTimer); + FStates := FStates - [hsColumnWidthTrackPending] + [hsColumnWidthTracking]; + HandleHeaderMouseMove := True; + Result := 0; + end + else + if hsHeightTrackPending in FStates then + begin + Treeview.StopTimer(HeaderTimer); + FStates := FStates - [hsHeightTrackPending] + [hsHeightTracking]; + HandleHeaderMouseMove := True; + Result := 0; + end + else + if hsColumnWidthTracking in FStates then + begin + if DoColumnWidthTracking(FColumns.FTrackIndex, GetShiftState, FTrackPoint, P) then + begin + if Treeview.UseRightToLeftAlignment then + begin + NewWidth := FTrackPoint.X - XPos; + NextColumn := FColumns.GetPreviousVisibleColumn(FColumns.FTrackIndex); + end + else + begin + NewWidth := XPos - FTrackPoint.X; + NextColumn := FColumns.GetNextVisibleColumn(FColumns.FTrackIndex); + end; + + // The autosized column cannot be resized using the mouse normally. Instead we resize the next + // visible column, so it look as we directly resize the autosized column. + if (hoAutoResize in FOptions) and (FColumns.FTrackIndex = FAutoSizeIndex) and + (NextColumn > NoColumn) and (coResizable in FColumns[NextColumn].FOptions) and + (FColumns[FColumns.FTrackIndex].FMinWidth < NewWidth) and + (FColumns[FColumns.FTrackIndex].FMaxWidth > NewWidth) then + FColumns[NextColumn].Width := FColumns[NextColumn].Width - NewWidth + + FColumns[FColumns.FTrackIndex].Width + else + FColumns[FColumns.FTrackIndex].Width := NewWidth; + end; + HandleHeaderMouseMove := True; + Result := 0; + end + else + if hsHeightTracking in FStates then + begin + if DoHeightTracking(P, GetShiftState) then + SetHeight(Integer(FHeight) + P.Y); + HandleHeaderMouseMove := True; + Result := 0; + end + else + begin + if hsDragPending in FStates then + begin + P := Treeview.ClientToScreen(P); + // start actual dragging if allowed + if (hoDrag in FOptions) and Treeview.DoHeaderDragging(FColumns.FDownIndex) then + begin + if ((Abs(FDragStart.X - P.X) > Mouse.DragThreshold) or + (Abs(FDragStart.Y - P.Y) > Mouse.DragThreshold)) then + begin + Treeview.StopTimer(HeaderTimer); + I := FColumns.FDownIndex; + FColumns.FDownIndex := NoColumn; + FColumns.FHoverIndex := NoColumn; + if I > NoColumn then + Invalidate(FColumns[I]); + PrepareDrag(P, FDragStart); + FStates := FStates - [hsDragPending] + [hsDragging]; + HandleHeaderMouseMove := True; + Result := 0; + end; + end; + end + else + if hsDragging in FStates then + begin + DragTo(Treeview.ClientToScreen(Point(XPos, YPos))); + HandleHeaderMouseMove := True; + Result := 0; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.HandleMessage(var Message: TMessage): Boolean; + +// The header gets here the opportunity to handle certain messages before they reach the tree. This is important +// because the tree needs to handle various non-client area messages for the header as well as some dragging/tracking +// events. +// By returning True the message will not be handled further, otherwise the message is then dispatched +// to the proper message handlers. + +var + P: TPoint; + R: TRect; + I: TColumnIndex; + OldPosition: Integer; + HitIndex: TColumnIndex; + NewCursor: HCURSOR; + Button: TMouseButton; + Menu: TPopupMenu; + IsInHeader, + IsHSplitterHit, + IsVSplitterHit: Boolean; + + //--------------- local function -------------------------------------------- + + function HSPlitterHit: Boolean; + + var + NextCol: TColumnIndex; + + begin + Result := (hoColumnResize in FOptions) and DetermineSplitterIndex(P); + if Result and not InHeader(P) then + begin + NextCol := FColumns.GetNextVisibleColumn(FColumns.FTrackIndex); + if not (coFixed in FColumns[FColumns.FTrackIndex].Options) or (NextCol <= NoColumn) or + (coFixed in FColumns[NextCol].Options) or (P.Y > Integer(Treeview.FRangeY)) then + Result := False; + end; + end; + + //--------------- end local function ---------------------------------------- + +begin + Result := False; + case Message.Msg of + WM_SIZE: + begin + if not (tsWindowCreating in FOwner.FStates) then + if (hoAutoResize in FOptions) and not (hsAutoSizing in FStates) then + begin + FColumns.AdjustAutoSize(InvalidColumn); + Invalidate(nil); + end + else + if not (hsScaling in FStates) then + begin + RescaleHeader; + Invalidate(nil); + end; + end; + CM_PARENTFONTCHANGED: + if FParentFont then + FFont.Assign(FOwner.Font); + CM_BIDIMODECHANGED: + for I := 0 to FColumns.Count - 1 do + if coParentBiDiMode in FColumns[I].FOptions then + FColumns[I].ParentBiDiModeChanged; + WM_NCMBUTTONDOWN: + begin + with TWMNCMButtonDown(Message) do + P := Treeview.ScreenToClient(Point(XCursor, YCursor)); + if InHeader(P) then + FOwner.DoHeaderMouseDown(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); + end; + WM_NCMBUTTONUP: + begin + with TWMNCMButtonUp(Message) do + P := FOwner.ScreenToClient(Point(XCursor, YCursor)); + if InHeader(P) then + begin + FColumns.HandleClick(P, mbMiddle, True, False); + FOwner.DoHeaderMouseUp(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); + FColumns.FDownIndex := NoColumn; + FColumns.FCheckBoxHit := False; + end; + end; + WM_LBUTTONDBLCLK, + WM_NCLBUTTONDBLCLK, + WM_NCMBUTTONDBLCLK, + WM_NCRBUTTONDBLCLK: + begin + if Message.Msg <> WM_LBUTTONDBLCLK then + with TWMNCLButtonDblClk(Message) do + P := FOwner.ScreenToClient(Point(XCursor, YCursor)) + else + with TWMLButtonDblClk(Message) do + P := Point(XPos, YPos); + + if (hoHeightDblClickResize in FOptions) and InHeaderSplitterArea(P) and (FDefaultHeight > 0) then + begin + if DoHeightDblClickResize(P, GetShiftState) and (FDefaultHeight > 0) then + SetHeight(FMinHeight); + Result := True; + end + else + if HSplitterHit and ((Message.Msg = WM_NCLBUTTONDBLCLK) or (Message.Msg = WM_LBUTTONDBLCLK)) and + (hoDblClickResize in FOptions) and (FColumns.FTrackIndex > NoColumn) then + begin + // If the click was on a splitter then resize column to smallest width. + if DoColumnWidthDblClickResize(FColumns.FTrackIndex, P, GetShiftState) then + AutoFitColumns(True, smaUseColumnOption, FColumns[FColumns.FTrackIndex].FPosition, + FColumns[FColumns.FTrackIndex].FPosition); + Message.Result := 0; + Result := True; + end + else + if InHeader(P) and (Message.Msg <> WM_LBUTTONDBLCLK) then + begin + case Message.Msg of + WM_NCMBUTTONDBLCLK: + Button := mbMiddle; + WM_NCRBUTTONDBLCLK: + Button := mbRight; + else + // WM_NCLBUTTONDBLCLK + Button := mbLeft; + end; + FColumns.HandleClick(P, Button, True, True); + end; + end; + // The "hot" area of the headers horizontal splitter is partly within the client area of the the tree, so we need + // to handle WM_LBUTTONDOWN here, too. + WM_LBUTTONDOWN, + WM_NCLBUTTONDOWN: + begin + if (csDesigning in Treeview.ComponentState) and (Message.Msg = WM_LBUTTONDOWN) then + Exit; + + Application.CancelHint; + + // make sure no auto scrolling is active... + Treeview.StopTimer(ScrollTimer); + Treeview.DoStateChange([], [tsScrollPending, tsScrolling]); + // ... pending editing is cancelled (actual editing remains active) + Treeview.StopTimer(EditTimer); + Treeview.DoStateChange([], [tsEditPending]); + + if Message.Msg = WM_LBUTTONDOWN then + // Coordinates are already client area based. + with TWMLButtonDown(Message) do + P := Point(XPos, YPos) + else + with TWMNCLButtonDown(Message) do + begin + // want the drag start point in screen coordinates + FDragStart := Point(XCursor, YCursor); + P := Treeview.ScreenToClient(FDragStart); + end; + + IsInHeader := InHeader(P); + IsVSplitterHit := InHeaderSplitterArea(P) and CanSplitterResize(P); + IsHSplitterHit := HSplitterHit; + + if IsVSplitterHit or IsHSplitterHit then + begin + FTrackStart := P; + FColumns.FHoverIndex := NoColumn; + if IsVSplitterHit then + begin + DoBeforeHeightTracking(GetShiftState); + Include(FStates, hsHeightTrackPending) + end + else + begin + DoBeforeColumnWidthTracking(FColumns.FTrackIndex, GetShiftState); + Include(FStates, hsColumnWidthTrackPending); + end; + + SetCapture(Treeview.Handle); + Result := True; + Message.Result := 0; + end + else + if IsInHeader then + begin + HitIndex := Columns.AdjustDownColumn(P); + if (hoDrag in FOptions) and (HitIndex > NoColumn) and (coDraggable in FColumns[HitIndex].FOptions) then + begin + // Show potential drag operation. + // Disabled columns do not start a drag operation because they can't be clicked. + Include(FStates, hsDragPending); + SetCapture(Treeview.Handle); + Result := True; + Message.Result := 0; + end; + end; + + // This is a good opportunity to notify the application. + if IsInHeader then + FOwner.DoHeaderMouseDown(mbLeft, GetShiftState, P.X, P.Y + Integer(FHeight)); + end; + WM_NCRBUTTONDOWN: + begin + with TWMNCRButtonDown(Message) do + P := FOwner.ScreenToClient(Point(XCursor, YCursor)); + if InHeader(P) then + FOwner.DoHeaderMouseDown(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); + end; + WM_NCRBUTTONUP: + if not (csDesigning in FOwner.ComponentState) then + with TWMNCRButtonUp(Message) do + begin + Application.CancelHint; + + P := FOwner.ScreenToClient(Point(XCursor, YCursor)); + if InHeader(P) then + begin + FColumns.HandleClick(P, mbRight, True, False); + FOwner.DoHeaderMouseUp(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); + FColumns.FDownIndex := NoColumn; + FColumns.FTrackIndex := NoColumn; + FColumns.FCheckBoxHit := False; + + Menu := FPopupMenu; + if not Assigned(Menu) then + Menu := DoGetPopupMenu(FColumns.ColumnFromPosition(Point(P.X, P.Y + Integer(FHeight))), P); + + // Trigger header popup if there's one. + if Assigned(Menu) then + begin + Treeview.StopTimer(ScrollTimer); + Treeview.StopTimer(HeaderTimer); + FColumns.FHoverIndex := NoColumn; + Treeview.DoStateChange([], [tsScrollPending, tsScrolling]); + Menu.PopupComponent := Treeview; + Menu.Popup(XCursor, YCursor); + HandleMessage := True; + end; + end; + end; + // When the tree window has an active mouse capture then we only get "client-area" messages. + WM_LBUTTONUP, + WM_NCLBUTTONUP: + begin + Application.CancelHint; + + if FStates <> [] then + begin + ReleaseCapture; + if hsDragging in FStates then + begin + // successfull dragging moves columns + with TWMLButtonUp(Message) do + P := Treeview.ClientToScreen(Point(XPos, YPos)); + GetWindowRect(Treeview.Handle, R); + with FColumns do + begin + FDragImage.EndDrag; + if (FDropTarget > -1) and (FDropTarget <> FDragIndex) and PtInRect(R, P) then + begin + OldPosition := FColumns[FDragIndex].Position; + if FColumns.FDropBefore then + begin + if FColumns[FDragIndex].Position < FColumns[FDropTarget].Position then + FColumns[FDragIndex].Position := Max(0, FColumns[FDropTarget].Position - 1) + else + FColumns[FDragIndex].Position := FColumns[FDropTarget].Position; + end + else + begin + if FColumns[FDragIndex].Position < FColumns[FDropTarget].Position then + FColumns[FDragIndex].Position := FColumns[FDropTarget].Position + else + FColumns[FDragIndex].Position := FColumns[FDropTarget].Position + 1; + end; + Treeview.DoHeaderDragged(FDragIndex, OldPosition); + end + else + Treeview.DoHeaderDraggedOut(FDragIndex, P); + FDropTarget := NoColumn; + end; + Invalidate(nil); + end; + Result := True; + Message.Result := 0; + end; + + case Message.Msg of + WM_LBUTTONUP: + with TWMLButtonUp(Message) do + begin + if FColumns.FDownIndex > NoColumn then + FColumns.HandleClick(Point(XPos, YPos), mbLeft, False, False); + if FStates <> [] then + FOwner.DoHeaderMouseUp(mbLeft, KeysToShiftState(Keys), XPos, YPos); + end; + WM_NCLBUTTONUP: + with TWMNCLButtonUp(Message) do + begin + P := FOwner.ScreenToClient(Point(XCursor, YCursor)); + FColumns.HandleClick(P, mbLeft, False, False); + FOwner.DoHeaderMouseUp(mbLeft, GetShiftState, P.X, P.Y + Integer(FHeight)); + end; + end; + + if FColumns.FTrackIndex > NoColumn then + begin + if hsColumnWidthTracking in FStates then + DoAfterColumnWidthTracking(FColumns.FTrackIndex); + Invalidate(Columns[FColumns.FTrackIndex]); + FColumns.FTrackIndex := NoColumn; + end; + if FColumns.FDownIndex > NoColumn then + begin + Invalidate(Columns[FColumns.FDownIndex]); + FColumns.FDownIndex := NoColumn; + end; + if hsHeightTracking in FStates then + DoAfterHeightTracking; + + FStates := FStates - [hsDragging, hsDragPending, + hsColumnWidthTracking, hsColumnWidthTrackPending, + hsHeightTracking, hsHeightTrackPending]; + end; + // hovering, mouse leave detection + WM_NCMOUSEMOVE: + with TWMNCMouseMove(Message), FColumns do + begin + P := Treeview.ScreenToClient(Point(XCursor, YCursor)); + Treeview.DoHeaderMouseMove(GetShiftState, P.X, P.Y + Integer(FHeight)); + if InHeader(P) and ((AdjustHoverColumn(P)) or ((FDownIndex >= 0) and (FHoverIndex <> FDownIndex))) then + begin + // We need a mouse leave detection from here for the non client area. The best solution available would be the + // TrackMouseEvent API. Unfortunately, it leaves Win95 totally and WinNT4 for non-client stuff out and + // currently I cannot ignore these systems. Hence I go the only other reliable way and use a timer + // (although, I don't like it...). + Treeview.StopTimer(HeaderTimer); + SetTimer(Treeview.Handle, HeaderTimer, 50, nil); + // use Delphi's internal hint handling for header hints too + if hoShowHint in FOptions then + begin + // client coordinates! + XCursor := P.x; + YCursor := P.y + Integer(FHeight); + Application.HintMouseMessage(Treeview, Message); + end; + end + end; + WM_TIMER: + if TWMTimer(Message).TimerID = HeaderTimer then + begin + // determine current mouse position to check if it left the window + GetCursorPos(P); + P := Treeview.ScreenToClient(P); + with FColumns do + begin + if not InHeader(P) or ((FDownIndex > NoColumn) and (FHoverIndex <> FDownIndex)) then + begin + Treeview.StopTimer(HeaderTimer); + FHoverIndex := NoColumn; + FClickIndex := NoColumn; + FDownIndex := NoColumn; + FCheckBoxHit := False; + Result := True; + Message.Result := 0; + Invalidate(nil); + end; + end; + end; + WM_MOUSEMOVE: // mouse capture and general message redirection + Result := HandleHeaderMouseMove(TWMMouseMove(Message)); + WM_SETCURSOR: + if not (csDesigning in FOwner.ComponentState) and (FStates = []) then + begin + // Retrieve last cursor position (GetMessagePos does not work here, I don't know why). + GetCursorPos(P); + + // Is the mouse in the header rectangle and near the splitters? + P := Treeview.ScreenToClient(P); + IsHSplitterHit := HSplitterHit; + IsVSplitterHit := InHeaderSplitterArea(P) and CanSplitterResize(P); + + if IsVSplitterHit or IsHSplitterHit then + begin + NewCursor := Screen.Cursors[Treeview.Cursor]; + if IsVSplitterHit and (hoHeightResize in FOptions) then + NewCursor := Screen.Cursors[crVertSplit] + else + if IsHSplitterHit then + NewCursor := Screen.Cursors[crHeaderSplit]; + + Treeview.DoGetHeaderCursor(NewCursor); + Result := NewCursor <> Screen.Cursors[crDefault]; + if Result then + begin + Windows.SetCursor(NewCursor); + Message.Result := 1; + end + end; + end + else + begin + Message.Result := 1; + Result := True; + end; + WM_KEYDOWN, + WM_KILLFOCUS: + if (Message.Msg = WM_KILLFOCUS) or + (TWMKeyDown(Message).CharCode = VK_ESCAPE) then + begin + if hsDragging in FStates then + begin + ReleaseCapture; + FDragImage.EndDrag; + Exclude(FStates, hsDragging); + FColumns.FDropTarget := NoColumn; + Invalidate(nil); + Result := True; + Message.Result := 0; + end + else + begin + if [hsColumnWidthTracking, hsHeightTracking] * FStates <> [] then + begin + ReleaseCapture; + if hsColumnWidthTracking in FStates then + DoAfterColumnWidthTracking(FColumns.FTrackIndex); + if hsHeightTracking in FStates then + DoAfterHeightTracking; + Result := True; + Message.Result := 0; + end; + + FStates := FStates - [hsColumnWidthTracking, hsColumnWidthTrackPending, + hsHeightTracking, hsHeightTrackPending]; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.ImageListChange(Sender: TObject); + +begin + if not (csDestroying in Treeview.ComponentState) then + Invalidate(nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.PrepareDrag(P, Start: TPoint); + +// Initializes dragging of the header, P is the current mouse postion and Start the initial mouse position. + +var + Image: TBitmap; + ImagePos: TPoint; + DragColumn: TVirtualTreeColumn; + RTLOffset: Integer; + +begin + // Determine initial position of drag image (screen coordinates). + FColumns.FDropTarget := NoColumn; + Start := Treeview.ScreenToClient(Start); + Inc(Start.Y, FHeight); + FColumns.FDragIndex := FColumns.ColumnFromPosition(Start); + DragColumn := FColumns[FColumns.FDragIndex]; + + Image := TBitmap.Create; + with Image do + try + PixelFormat := pf32Bit; + Width := DragColumn.Width; + Height := FHeight; + + // Erase the entire image with the color key value, for the case not everything + // in the image is covered by the header image. + Canvas.Brush.Color := clBtnFace; + Canvas.FillRect(Rect(0, 0, Width, Height)); + + if TreeView.UseRightToLeftAlignment then + RTLOffset := Treeview.ComputeRTLOffset + else + RTLOffset := 0; + with DragColumn do + FColumns.PaintHeader(Canvas, Rect(FLeft, 0, FLeft + Width, Height), Point(-RTLOffset, 0), RTLOffset); + + if Treeview.UseRightToLeftAlignment then + ImagePos := Treeview.ClientToScreen(Point(DragColumn.Left + Treeview.ComputeRTLOffset(True), 0)) + else + ImagePos := Treeview.ClientToScreen(Point(DragColumn.Left, 0)); + // Column rectangles are given in local window coordinates not client coordinates. + Dec(ImagePos.Y, FHeight); + + if hoRestrictDrag in FOptions then + FDragImage.MoveRestriction := dmrHorizontalOnly + else + FDragImage.MoveRestriction := dmrNone; + FDragImage.PrepareDrag(Image, ImagePos, P, nil); + FDragImage.ShowDragImage; + finally + Image.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.ReadColumns(Reader: TReader); + +begin + Include(FStates, hsLoading); + Columns.Clear; + Reader.ReadValue; + Reader.ReadCollection(Columns); + Exclude(FStates, hsLoading); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.RecalculateHeader; + +// Initiate a recalculation of the non-client area of the owner tree. + +begin + if Treeview.HandleAllocated then + begin + Treeview.UpdateHeaderRect; + SetWindowPos(Treeview.Handle, 0, 0, 0, 0, 0, SWP_FRAMECHANGED or SWP_NOMOVE or SWP_NOACTIVATE or SWP_NOOWNERZORDER or + SWP_NOSENDCHANGING or SWP_NOSIZE or SWP_NOZORDER); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.RescaleHeader; + +// Rescale the fixed elements (fixed columns, header itself) to FixedAreaConstraints. + +var + FixedWidth, + MaxFixedWidth, + MinFixedWidth: Integer; + + //--------------- local function -------------------------------------------- + + procedure ComputeConstraints; + + var + I: TColumnIndex; + + begin + with FColumns do + begin + I := GetFirstVisibleColumn; + while I > NoColumn do + begin + if (coFixed in FColumns[I].Options) and (FColumns[I].Width < FColumns[I].MinWidth) then + FColumns[I].FWidth := FColumns[I].FMinWidth; + I := GetNextVisibleColumn(I); + end; + FixedWidth := GetVisibleFixedWidth; + end; + + with FFixedAreaConstraints do + begin + MinFixedWidth := (TreeView.ClientWidth * FMinWidthPercent) div 100; + MaxFixedWidth := (TreeView.ClientWidth * FMaxWidthPercent) div 100; + end; + end; + + //----------- end local function -------------------------------------------- + +begin + if ([csLoading, csReading, csWriting, csDestroying] * Treeview.ComponentState = []) and not + (hsLoading in FStates) and Treeview.HandleAllocated then + begin + Include(FStates, hsScaling); + + SetHeight(FHeight); + RecalculateHeader; + + with FFixedAreaConstraints do + if (FMinHeightPercent > 0) or (FMaxHeightPercent > 0) then + begin + ComputeConstraints; + + with FColumns do + if (FMaxWidthPercent > 0) and (FixedWidth > MaxFixedWidth) then + ResizeColumns(MaxFixedWidth - FixedWidth, 0, Count - 1, [coVisible, coFixed]) + else + if (FMinWidthPercent > 0) and (FixedWidth < MinFixedWidth) then + ResizeColumns(MinFixedWidth - FixedWidth, 0, Count - 1, [coVisible, coFixed]); + + FColumns.UpdatePositions; + end; + + Exclude(FStates, hsScaling); + Exclude(FStates, hsNeedScaling); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.UpdateMainColumn; + +// Called once the load process of the owner tree is done. + +begin + if FMainColumn < 0 then + FMainColumn := 0; + if FMainColumn > FColumns.Count - 1 then + FMainColumn := FColumns.Count - 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.UpdateSpringColumns; + +var + I: TColumnIndex; + SpringCount: Integer; + Sign: Integer; + ChangeBy: Single; + Difference: Single; + NewAccumulator: Single; + +begin + with TreeView do + ChangeBy := FHeaderRect.Right - FHeaderRect.Left - FLastWidth; + if (hoAutoSpring in FOptions) and (FLastWidth <> 0) and (ChangeBy <> 0) then + begin + // Stay positive if downsizing the control. + if ChangeBy < 0 then + Sign := -1 + else + Sign := 1; + ChangeBy := Abs(ChangeBy); + // Count how many columns have spring enabled. + SpringCount := 0; + for I := 0 to FColumns.Count-1 do + if [coVisible, coAutoSpring] * FColumns[I].FOptions = [coVisible, coAutoSpring] then + Inc(SpringCount); + if SpringCount > 0 then + begin + // Calculate the size to add/sub to each columns. + Difference := ChangeBy / SpringCount; + // Adjust the column's size accumulators and resize if the result is >= 1. + for I := 0 to FColumns.Count - 1 do + if [coVisible, coAutoSpring] * FColumns[I].FOptions = [coVisible, coAutoSpring] then + begin + // Sum up rest changes from previous runs and the amount from this one and store it in the + // column. If there is at least one pixel difference then do a resize and reset the accumulator. + NewAccumulator := FColumns[I].FSpringRest + Difference; + // Set new width if at least one pixel size difference is reached. + if NewAccumulator >= 1 then + FColumns[I].SetWidth(FColumns[I].FWidth + (Trunc(NewAccumulator) * Sign)); + FColumns[I].FSpringRest := Frac(NewAccumulator); + + // Keep track of the size count. + ChangeBy := ChangeBy - Difference; + // Exit loop if resize count drops below freezing point. + if ChangeBy < 0 then + Break; + end; + end; + end; + with TreeView do + FLastWidth := FHeaderRect.Right - FHeaderRect.Left; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + // --- HACK WARNING! + // This type cast is a partial rewrite of the private section of TWriter. The purpose is to have access to + // the FPropPath member, which is otherwise not accessible. The reason why this access is needed is that + // with nested components this member contains unneeded property path information. These information prevent + // successful load of the stored properties later. + // In Classes.pas you can see that FPropPath is reset several times to '' to prevent this case for certain properies. + // Unfortunately, there is no clean way for us here to do the same. + {$hints off} + TWriterHack = class(TFiler) + private + FRootAncestor: TComponent; + FPropPath: string; + end; + {$hints on} + +procedure TVTHeader.WriteColumns(Writer: TWriter); + +// Write out the columns but take care for the case VT is a nested component. + +var + LastPropPath: String; + +begin + // Save last property path for restoration. + LastPropPath := TWriterHack(Writer).FPropPath; + try + // If VT is a nested component then this path contains the name of the parent component at this time + // (otherwise it is already empty). This path is then combined with the property name under which the tree + // is defined in the parent component. Unfortunately, the load code in Classes.pas does not consider this case + // is then unable to load this property. + TWriterHack(Writer).FPropPath := ''; + Writer.WriteCollection(Columns); + finally + TWriterHack(Writer).FPropPath := LastPropPath; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.AllowFocus(ColumnIndex: TColumnIndex): Boolean; +begin + Result := False; + if not FColumns.IsValidColumn(ColumnIndex) then exit; // Just in case. + + Result := (coAllowFocus in FColumns[ColumnIndex].Options); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.Assign(Source: TPersistent); + +begin + if Source is TVTHeader then + begin + AutoSizeIndex := TVTHeader(Source).AutoSizeIndex; + Background := TVTHeader(Source).Background; + Columns := TVTHeader(Source).Columns; + Font := TVTHeader(Source).Font; + FixedAreaConstraints.Assign(TVTHeader(Source).FixedAreaConstraints); + Height := TVTHeader(Source).Height; + Images := TVTHeader(Source).Images; + MainColumn := TVTHeader(Source).MainColumn; + Options := TVTHeader(Source).Options; + ParentFont := TVTHeader(Source).ParentFont; + PopupMenu := TVTHeader(Source).PopupMenu; + SortColumn := TVTHeader(Source).SortColumn; + SortDirection := TVTHeader(Source).SortDirection; + Style := TVTHeader(Source).Style; + + RescaleHeader; + end + else + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.AutoFitColumns(Animated: Boolean = True; SmartAutoFitType: TSmartAutoFitType = smaUseColumnOption; + RangeStartCol: Integer = NoColumn; RangeEndCol: Integer = NoColumn); + + //--------------- local functions ------------------------------------------- + + function GetUseSmartColumnWidth(ColumnIndex: TColumnIndex): Boolean; + + begin + Result := False; + case SmartAutoFitType of + smaAllColumns: + Result := True; + smaNoColumn: + Result := False; + smaUseColumnOption: + Result := coSmartResize in FColumns.Items[ColumnIndex].FOptions; + end; + end; + + //---------------------------------------------------------------------------- + + procedure DoAutoFitColumn(Column: TColumnIndex); + + begin + with FColumns do + if ([coResizable, coVisible] * Items[FPositionToIndex[Column]].FOptions = [coResizable, coVisible]) and + DoBeforeAutoFitColumn(FPositionToIndex[Column], SmartAutoFitType) and not TreeView.OperationCanceled then + begin + if Animated then + AnimatedResize(FPositionToIndex[Column], Treeview.GetMaxColumnWidth(FPositionToIndex[Column], + GetUseSmartColumnWidth(FPositionToIndex[Column]))) + else + FColumns[FPositionToIndex[Column]].Width := Treeview.GetMaxColumnWidth(FPositionToIndex[Column], + GetUseSmartColumnWidth(FPositionToIndex[Column])); + + DoAfterAutoFitColumn(FPositionToIndex[Column]); + end; + end; + + //--------------- end local functions ---------------------------------------- + +var + I: Integer; + StartCol, + EndCol: Integer; + +begin + StartCol := Max(NoColumn + 1, RangeStartCol); + + if RangeEndCol <= NoColumn then + EndCol := FColumns.Count - 1 + else + EndCol := Min(RangeEndCol, FColumns.Count - 1); + + if StartCol > EndCol then + Exit; // nothing to do + + TreeView.StartOperation(okAutoFitColumns); + try + if Assigned(TreeView.FOnBeforeAutoFitColumns) then + TreeView.FOnBeforeAutoFitColumns(Self, SmartAutoFitType); + + for I := StartCol to EndCol do + DoAutoFitColumn(I); + + if Assigned(TreeView.FOnAfterAutoFitColumns) then + TreeView.FOnAfterAutoFitColumns(Self); + + finally + Treeview.EndOperation(okAutoFitColumns); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.InHeader(P: TPoint): Boolean; + +// Determines whether the given point (client coordinates!) is within the header rectangle (non-client coordinates). + +var + R, RW: TRect; + +begin + R := Treeview.FHeaderRect; + + // Current position of the owner in screen coordinates. + GetWindowRect(Treeview.Handle, RW); + + // Convert to client coordinates. + MapWindowPoints(0, Treeview.Handle, RW, 2); + + // Consider the header within this rectangle. + OffsetRect(R, RW.Left, RW.Top); + Result := PtInRect(R, P); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.InHeaderSplitterArea(P: TPoint): Boolean; + +// Determines whether the given point (client coordinates!) hits the horizontal splitter area of the header. + +var + R, RW: TRect; + +begin + if (P.Y > 2) or (P.Y < -2) or not (hoVisible in FOptions) then + Result := False + else + begin + R := Treeview.FHeaderRect; + Inc(R.Bottom, 2); + + // Current position of the owner in screen coordinates. + GetWindowRect(Treeview.Handle, RW); + + // Convert to client coordinates. + MapWindowPoints(0, Treeview.Handle, RW, 2); + + // Consider the header within this rectangle. + OffsetRect(R, RW.Left, RW.Top); + Result := PtInRect(R, P); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.Invalidate(Column: TVirtualTreeColumn; ExpandToBorder: Boolean = False); + +// Because the header is in the non-client area of the tree it needs some special handling in order to initiate its +// repainting. +// If ExpandToBorder is True then not only the given column but everything or (depending on hoFullRepaintOnResize) just +// everything to its right (or left, in RTL mode) will be invalidated (useful for resizing). This makes only sense when +// a column is given. + +var + R, RW: TRect; + +begin + if (hoVisible in FOptions) and Treeview.HandleAllocated then + with Treeview do + begin + if Column = nil then + R := FHeaderRect + else + begin + R := Column.GetRect; + if not (coFixed in Column.Options) then + OffsetRect(R, -FEffectiveOffsetX, 0); + if UseRightToLeftAlignment then + OffsetRect(R, ComputeRTLOffset, 0); + if ExpandToBorder then + begin + if (hoFullRepaintOnResize in FHeader.FOptions) then + begin + R.Left := FHeaderRect.Left; + R.Right := FHeaderRect.Right; + end else + begin + if UseRightToLeftAlignment then + R.Left := FHeaderRect.Left + else + R.Right := FHeaderRect.Right; + end; + end; + end; + + // Current position of the owner in screen coordinates. + GetWindowRect(Handle, RW); + + // Consider the header within this rectangle. + OffsetRect(R, RW.Left, RW.Top); + + // Expressed in client coordinates (because RedrawWindow wants them so, they will actually become negative). + MapWindowPoints(0, Handle, R, 2); + RedrawWindow(Handle, @R, 0, RDW_FRAME or RDW_INVALIDATE or RDW_VALIDATE or RDW_NOINTERNALPAINT or + RDW_NOERASE or RDW_NOCHILDREN); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.LoadFromStream(const Stream: TStream); + +// restore the state of the header from the given stream + +var + Dummy, + Version: Integer; + S: AnsiString; + OldOptions: TVTHeaderOptions; + +begin + Include(FStates, hsLoading); + with Stream do + try + // Switch off all options which could influence loading the columns (they will be later set again). + OldOptions := FOptions; + FOptions := []; + + // Determine whether the stream contains data without a version number. + ReadBuffer(Dummy, SizeOf(Dummy)); + if Dummy > -1 then + begin + // Seek back to undo the read operation if this is an old stream format. + Seek(-SizeOf(Dummy), soFromCurrent); + Version := -1; + end + else // Read version number if this is a "versionized" format. + ReadBuffer(Version, SizeOf(Version)); + Columns.LoadFromStream(Stream, Version); + + ReadBuffer(Dummy, SizeOf(Dummy)); + AutoSizeIndex := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Background := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Height := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + FOptions := OldOptions; + Options := TVTHeaderOptions(Dummy); + // PopupMenu is neither saved nor restored + ReadBuffer(Dummy, SizeOf(Dummy)); + Style := TVTHeaderStyle(Dummy); + // TFont has no own save routine so we do it manually + with Font do + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + Color := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + Height := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + SetLength(S, Dummy); + ReadBuffer(PAnsiChar(S)^, Dummy); + if VTHeaderStreamVersion >= 4 then + {$ifdef COMPILER_12_UP} + Name := UTF8ToString(S) + {$else} + Name := UTF8Decode(S) + {$endif} + else + Name := S; + ReadBuffer(Dummy, SizeOf(Dummy)); + Pitch := TFontPitch(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + Style := TFontStyles(Byte(Dummy)); + end; + + // Read data introduced by stream version 1+. + if Version > 0 then + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + MainColumn := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + SortColumn := Dummy; + ReadBuffer(Dummy, SizeOf(Dummy)); + SortDirection := TSortDirection(Byte(Dummy)); + end; + + // Read data introduced by stream version 5+. + if Version > 4 then + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + ParentFont := Boolean(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + FMaxHeight := Integer(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + FMinHeight := Integer(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + FDefaultHeight := Integer(Dummy); + with FFixedAreaConstraints do + begin + ReadBuffer(Dummy, SizeOf(Dummy)); + FMaxHeightPercent := TVTConstraintPercent(Dummy); + ReadBuffer(Dummy, Sizeof(Dummy)); + FMaxWidthPercent := TVTConstraintPercent(Dummy); + ReadBuffer(Dummy, SizeOf(Dummy)); + FMinHeightPercent := TVTConstraintPercent(Dummy); + ReadBuffer(Dummy, Sizeof(Dummy)); + FMinWidthPercent := TVTConstraintPercent(Dummy); + end + end; + finally + Exclude(FStates, hsLoading); + Treeview.DoColumnResize(NoColumn); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTHeader.ResizeColumns(ChangeBy: Integer; RangeStartCol: TColumnIndex; RangeEndCol: TColumnIndex; + Options: TVTColumnOptions = [coVisible]): Integer; + +// Distribute the given width change to a range of columns. A 'fair' way is used to distribute ChangeBy to the columns, +// while ensuring that everything that can be distributed will be distributed. + +var + Start, + I: TColumnIndex; + ColCount, + ToGo, + Sign, + Rest, + MaxDelta, + Difference: Integer; + Constraints, + Widths: Array of Integer; + BonusPixel: Boolean; + + //--------------- local functions ------------------------------------------- + + function IsResizable (Column: TColumnIndex): Boolean; + + begin + if BonusPixel then + Result := Widths[Column - RangeStartCol] < Constraints[Column - RangeStartCol] + else + Result := Widths[Column - RangeStartCol] > Constraints[Column - RangeStartCol]; + end; + + //--------------------------------------------------------------------------- + + procedure IncDelta(Column: TColumnIndex); + + begin + if BonusPixel then + Inc(MaxDelta, FColumns[Column].MaxWidth - Widths[Column - RangeStartCol]) + else + Inc(MaxDelta, Widths[Column - RangeStartCol] - Constraints[Column - RangeStartCol]); + end; + + //--------------------------------------------------------------------------- + + function ChangeWidth(Column: TColumnIndex; Delta: Integer): Integer; + + begin + if Delta > 0 then + Delta := Min(Delta, Constraints[Column - RangeStartCol] - Widths[Column - RangeStartCol]) + else + Delta := Max(Delta, Constraints[Column - RangeStartCol] - Widths[Column - RangeStartCol]); + + Inc(Widths[Column - RangeStartCol], Delta); + Dec(ToGo, Abs(Delta)); + Result := Abs(Delta); + end; + + //--------------------------------------------------------------------------- + + function ReduceConstraints: Boolean; + + var + MaxWidth, + MaxReserveCol, + Column: TColumnIndex; + + begin + Result := True; + if not (hsScaling in FStates) or BonusPixel then + Exit; + + MaxWidth := 0; + MaxReserveCol := NoColumn; + for Column := RangeStartCol to RangeEndCol do + if (Options * FColumns[Column].FOptions = Options) and + (FColumns[Column].FWidth > MaxWidth) then + begin + MaxWidth := Widths[Column - RangeStartCol]; + MaxReserveCol := Column; + end; + + if (MaxReserveCol <= NoColumn) or (Constraints[MaxReserveCol - RangeStartCol] <= 10) then + Result := False + else + Dec(Constraints[MaxReserveCol - RangeStartCol], + Constraints[MaxReserveCol - RangeStartCol] div 10); + end; + + //----------- end local functions ------------------------------------------- + +begin + Result := 0; + if ChangeBy <> 0 then + begin + // Do some initialization here + BonusPixel := ChangeBy > 0; + Sign := IfThen(BonusPixel, 1, -1); + Start := IfThen(BonusPixel, RangeStartCol, RangeEndCol); + ToGo := Abs(ChangeBy); + SetLength(Widths, RangeEndCol - RangeStartCol + 1); + SetLength(Constraints, RangeEndCol - RangeStartCol + 1); + for I := RangeStartCol to RangeEndCol do + begin + Widths[I - RangeStartCol] := FColumns[I].FWidth; + Constraints[I - RangeStartCol] := IfThen(BonusPixel, FColumns[I].MaxWidth, FColumns[I].MinWidth); + end; + + repeat + repeat + MaxDelta := 0; + ColCount := 0; + for I := RangeStartCol to RangeEndCol do + if (Options * FColumns[I].FOptions = Options) and IsResizable(I) then + begin + Inc(ColCount); + IncDelta(I); + end; + if MaxDelta < Abs(ChangeBy) then + if not ReduceConstraints then + Break; + until (MaxDelta >= Abs(ChangeBy)) or not (hsScaling in FStates); + + if ColCount = 0 then + Break; + + ToGo := Min(ToGo, MaxDelta); + Difference := ToGo div ColCount; + Rest := ToGo mod ColCount; + + if Difference > 0 then + for I := RangeStartCol to RangeEndCol do + if (Options * FColumns[I].FOptions = Options) and IsResizable(I) then + ChangeWidth(I, Difference * Sign); + + // Now distribute Rest. + I := Start; + while Rest > 0 do + begin + if (Options * FColumns[I].FOptions = Options) and IsResizable(I) then + if FColumns[I].FBonusPixel <> BonusPixel then + begin + Dec(Rest, ChangeWidth(I, Sign)); + FColumns[I].FBonusPixel := BonusPixel; + end; + Inc(I, Sign); + if (BonusPixel and (I > RangeEndCol)) or (not BonusPixel and (I < RangeStartCol)) then + begin + for I := RangeStartCol to RangeEndCol do + if Options * FColumns[I].FOptions = Options then + FColumns[I].FBonusPixel := not FColumns[I].FBonusPixel; + I := Start; + end; + end; + until ToGo <= 0; + + // Now set the computed widths. We also compute the result here. + Include(FStates, hsResizing); + for I := RangeStartCol to RangeEndCol do + if (Options * FColumns[I].FOptions = Options) then + begin + Inc(Result, Widths[I - RangeStartCol] - FColumns[I].FWidth); + FColumns[I].SetWidth(Widths[I - RangeStartCol]); + end; + Exclude(FStates, hsResizing); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.RestoreColumns; + +// Restores all columns to their width which they had before they have been auto fitted. + +var + I: TColumnIndex; + +begin + with FColumns do + for I := Count - 1 downto 0 do + if [coResizable, coVisible] * Items[FPositionToIndex[I]].FOptions = [coResizable, coVisible] then + Items[I].RestoreLastWidth; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTHeader.SaveToStream(const Stream: TStream); + +// Saves the complete state of the header into the provided stream. + +var + Dummy: Integer; + Tmp: AnsiString; + +begin + with Stream do + begin + // In previous version of VT was no header stream version defined. + // For feature enhancements it is necessary, however, to know which stream + // format we are trying to load. + // In order to distict from non-version streams an indicator is inserted. + Dummy := -1; + WriteBuffer(Dummy, SizeOf(Dummy)); + // Write current stream version number, nothing more is required at the time being. + Dummy := VTHeaderStreamVersion; + WriteBuffer(Dummy, SizeOf(Dummy)); + + // Save columns in case they depend on certain options (like auto size). + Columns.SaveToStream(Stream); + + Dummy := FAutoSizeIndex; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := FBackground; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := FHeight; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FOptions); + WriteBuffer(Dummy, SizeOf(Dummy)); + // PopupMenu is neither saved nor restored + Dummy := Ord(FStyle); + WriteBuffer(Dummy, SizeOf(Dummy)); + // TFont has no own save routine so we do it manually + with Font do + begin + Dummy := Color; + WriteBuffer(Dummy, SizeOf(Dummy)); + + // Need only to write one: size or height, I decided to write height. + Dummy := Height; + WriteBuffer(Dummy, SizeOf(Dummy)); + Tmp := UTF8Encode(Name); + Dummy := Length(Tmp); + WriteBuffer(Dummy, SizeOf(Dummy)); + WriteBuffer(PAnsiChar(Tmp)^, Dummy); + Dummy := Ord(Pitch); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Byte(Style); + WriteBuffer(Dummy, SizeOf(Dummy)); + end; + + // Data introduced by stream version 1. + Dummy := FMainColumn; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := FSortColumn; + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Byte(FSortDirection); + WriteBuffer(Dummy, SizeOf(Dummy)); + + // Data introduced by stream version 5. + Dummy := Integer(ParentFont); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FMaxHeight); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FMinHeight); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FDefaultHeight); + WriteBuffer(Dummy, SizeOf(Dummy)); + with FFixedAreaConstraints do + begin + Dummy := Integer(FMaxHeightPercent); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FMaxWidthPercent); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FMinHeightPercent); + WriteBuffer(Dummy, SizeOf(Dummy)); + Dummy := Integer(FMinWidthPercent); + WriteBuffer(Dummy, SizeOf(Dummy)); + end + end; +end; + +//----------------- TScrollBarOptions ---------------------------------------------------------------------------------- + +constructor TScrollBarOptions.Create(AOwner: TBaseVirtualTree); + +begin + inherited Create; + + FOwner := AOwner; + FAlwaysVisible := False; + FScrollBarStyle := sbmRegular; + FScrollBars := ssBoth; + FIncrementX := 20; + FIncrementY := 20; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TScrollBarOptions.SetAlwaysVisible(Value: Boolean); + +begin + if FAlwaysVisible <> Value then + begin + FAlwaysVisible := Value; + if not (csLoading in FOwner.ComponentState) and FOwner.HandleAllocated then + FOwner.RecreateWnd; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TScrollBarOptions.SetScrollBars(Value: TScrollStyle); + +begin + if FScrollbars <> Value then + begin + FScrollBars := Value; + if not (csLoading in FOwner.ComponentState) and FOwner.HandleAllocated then + FOwner.RecreateWnd; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TScrollBarOptions.SetScrollBarStyle(Value: TScrollBarStyle); + +begin + if FScrollBarStyle <> Value then + begin + FScrollBarStyle := Value; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TScrollBarOptions.GetOwner: TPersistent; + +begin + Result := FOwner; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TScrollBarOptions.Assign(Source: TPersistent); + +begin + if Source is TScrollBarOptions then + begin + AlwaysVisible := TScrollBarOptions(Source).AlwaysVisible; + HorizontalIncrement := TScrollBarOptions(Source).HorizontalIncrement; + ScrollBars := TScrollBarOptions(Source).ScrollBars; + ScrollBarStyle := TScrollBarOptions(Source).ScrollBarStyle; + VerticalIncrement := TScrollBarOptions(Source).VerticalIncrement; + end + else + inherited; +end; + +//----------------- TVTColors ------------------------------------------------------------------------------------------ + +constructor TVTColors.Create(AOwner: TBaseVirtualTree); + +begin + FOwner := AOwner; + FColors[0] := clBtnShadow; // DisabledColor + FColors[1] := clHighlight; // DropMarkColor + FColors[2] := clHighLight; // DropTargetColor + FColors[3] := clHighLight; // FocusedSelectionColor + FColors[4] := clBtnFace; // GridLineColor + FColors[5] := clBtnShadow; // TreeLineColor + FColors[6] := clBtnFace; // UnfocusedSelectionColor + FColors[7] := clBtnFace; // BorderColor + FColors[8] := clWindowText; // HotColor + FColors[9] := clHighLight; // FocusedSelectionBorderColor + FColors[10] := clBtnFace; // UnfocusedSelectionBorderColor + FColors[11] := clHighlight; // DropTargetBorderColor + FColors[12] := clHighlight; // SelectionRectangleBlendColor + FColors[13] := clHighlight; // SelectionRectangleBorderColor + FColors[14] := clBtnShadow; // HeaderHotColor + FColors[15] := clHighlightText; // SelectionTextColor +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVTColors.GetColor(const Index: Integer): TColor; + +begin + Result := FColors[Index]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTColors.SetColor(const Index: Integer; const Value: TColor); + +begin + if FColors[Index] <> Value then + begin + FColors[Index] := Value; + if not (csLoading in FOwner.ComponentState) and FOwner.HandleAllocated then + begin + // Cause helper bitmap rebuild if the button color changed. + case Index of + 5: + begin + FOwner.PrepareBitmaps(True, False); + FOwner.Invalidate; + end; + 7: + RedrawWindow(FOwner.Handle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_NOERASE or RDW_NOCHILDREN) + else + FOwner.Invalidate; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTColors.Assign(Source: TPersistent); + +begin + if Source is TVTColors then + begin + FColors := TVTColors(Source).FColors; + if FOwner.FUpdateCount = 0 then + FOwner.Invalidate; + end + else + inherited; +end; + +//----------------- TClipboardFormats ---------------------------------------------------------------------------------- + +constructor TClipboardFormats.Create(AOwner: TBaseVirtualTree); + +begin + FOwner := AOwner; + Sorted := True; + Duplicates := dupIgnore; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TClipboardFormats.Add(const S: string): Integer; + +// Restrict additions to the clipbard formats to only those which are registered with the owner tree or one of its +// ancestors. + +var + Format: Word; + RegisteredClass: TVirtualTreeClass; + +begin + RegisteredClass := InternalClipboardFormats.FindFormat(S, Format); + if Assigned(RegisteredClass) and FOwner.ClassType.InheritsFrom(RegisteredClass) then + Result := inherited Add(S) + else + Result := -1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TClipboardFormats.Insert(Index: Integer; const S: string); + +// Restrict additions to the clipbard formats to only those which are registered with the owner tree or one of its +// ancestors. + +var + Format: Word; + RegisteredClass: TVirtualTreeClass; + +begin + RegisteredClass := InternalClipboardFormats.FindFormat(S, Format); + if Assigned(RegisteredClass) and FOwner.ClassType.InheritsFrom(RegisteredClass) then + inherited Insert(Index, S); +end; + +//----------------- TBaseVirtualTree ----------------------------------------------------------------------------------- + +constructor TBaseVirtualTree.Create(AOwner: TComponent); + +begin + if not Initialized then + InitializeGlobalStructures; + + inherited; + + ControlStyle := ControlStyle - [csSetCaption] + [csCaptureMouse, csOpaque, csReplicatable, csDisplayDragImage, + csReflector]; + FTotalInternalDataSize := 0; + FNodeDataSize := -1; + Width := 200; + Height := 100; + TabStop := True; + ParentColor := False; + FDefaultNodeHeight := 18; + FDragOperations := [doCopy, doMove]; + FHotCursor := crDefault; + FScrollBarOptions := TScrollBarOptions.Create(Self); + FFocusedColumn := NoColumn; + FDragImageKind := diComplete; + FLastSelectionLevel := -1; + FAnimationType := hatSystemDefault; + FSelectionBlendFactor := 128; + + FIndent := 18; + + FPlusBM := TBitmap.Create; + FHotPlusBM := TBitmap.Create; + FMinusBM := TBitmap.Create; + FHotMinusBM := TBitmap.Create; + + FBorderStyle := bsSingle; + FButtonStyle := bsRectangle; + FButtonFillMode := fmTreeColor; + + FHeader := GetHeaderClass.Create(Self); + + // we have an own double buffer handling + DoubleBuffered := False; + + FCheckImageKind := ckSystemDefault; + FCheckImages := LightCheckImages; + + FImageChangeLink := TChangeLink.Create; + FImageChangeLink.OnChange := ImageListChange; + FStateChangeLink := TChangeLink.Create; + FStateChangeLink.OnChange := ImageListChange; + FCustomCheckChangeLink := TChangeLink.Create; + FCustomCheckChangeLink.OnChange := ImageListChange; + + FAutoExpandDelay := 1000; + FAutoScrollDelay := 1000; + FAutoScrollInterval := 1; + + FBackground := TPicture.Create; + + FDefaultPasteMode := amAddChildLast; + FMargin := 4; + FTextMargin := 4; + FDragType := dtOLE; + FDragHeight := 350; + FDragWidth := 200; + + FColors := TVTColors.Create(Self); + FEditDelay := 1000; + + FDragImage := TVTDragImage.Create(Self); + with FDragImage do + begin + Fade := True; + PostBlendBias := 0; + PreBlendBias := 0; + Transparency := 200; + end; + + SetLength(FSingletonNodeArray, 1); + FAnimationDuration := 200; + FSearchTimeout := 1000; + FSearchStart := ssFocusedNode; + FNodeAlignment := naProportional; + FLineStyle := lsDotted; + FIncrementalSearch := isNone; + FClipboardFormats := TClipboardFormats.Create(Self); + FOptions := GetOptionsClass.Create(Self); + + AddThreadReference; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TBaseVirtualTree.Destroy; + +begin + Exclude(FOptions.FMiscOptions, toReadOnly); + ReleaseThreadReference(Self); + StopWheelPanning; + CancelEditNode; + + // Just in case it didn't happen already release the edit link. + FEditLink := nil; + FClipboardFormats.Free; + // Clear will also free the drag manager if it is still alive. + Clear; + FDragImage.Free; + FColors.Free; + FBackground.Free; + FImageChangeLink.Free; + FStateChangeLink.Free; + FCustomCheckChangeLink.Free; + FScrollBarOptions.Free; + + // The window handle must be destroyed before the header is freed because it is needed in WM_NCDESTROY. + if HandleAllocated then + DestroyWindowHandle; + FOptions.Free; // WM_NCDESTROY accesses FOptions + FHeader.Free; + FHeader := nil; + + FreeMem(FRoot); + + FPlusBM.Free; + FHotPlusBM.Free; + FMinusBM.Free; + FHotMinusBM.Free; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustCoordinatesByIndent(var PaintInfo: TVTPaintInfo; Indent: Integer); + +// During painting of the main column some coordinates must be adjusted due to the tree lines. +// The offset resulting from the tree lines and indentation level is given in Indent. + +var + Offset: Integer; + +begin + with PaintInfo do + begin + Offset := Indent * Integer(FIndent); + if BidiMode = bdLeftToRight then + begin + Inc(ContentRect.Left, Offset); + Inc(ImageInfo[iiNormal].XPos, Offset); + Inc(ImageInfo[iiState].XPos, Offset); + Inc(ImageInfo[iiCheck].XPos, Offset); + end + else + begin + Dec(ContentRect.Right, Offset); + Dec(ImageInfo[iiNormal].XPos, Offset); + Dec(ImageInfo[iiState].XPos, Offset); + Dec(ImageInfo[iiCheck].XPos, Offset); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustTotalCount(Node: PVirtualNode; Value: Integer; relative: Boolean = False); + +// Sets a node's total count to the given value and recursively adjusts the parent's total count +// (actually, the adjustment is done iteratively to avoid function call overheads). + +var + Difference: Integer; + Run: PVirtualNode; + +begin + if relative then + Difference := Value + else + Difference := Value - Integer(Node.TotalCount); + if Difference <> 0 then + begin + Run := Node; + // Root node has as parent the tree view. + while Assigned(Run) and (Run <> Pointer(Self)) do + begin + Inc(Integer(Run.TotalCount), Difference); + Run := Run.Parent; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustTotalHeight(Node: PVirtualNode; Value: Integer; relative: Boolean = False); + +// Sets a node's total height to the given value and recursively adjusts the parent's total height. + +var + Difference: Integer; + Run: PVirtualNode; + +begin + if relative then + Difference := Value + else + Difference := Value - Integer(Node.TotalHeight); + if Difference <> 0 then + begin + Run := Node; + repeat + Inc(Integer(Run.TotalHeight), Difference); + // If the node is not visible or the parent node is not expanded or we are already at the top + // then nothing more remains to do. + if not (vsVisible in Run.States) or (Run = FRoot) or + (Run.Parent = nil) or not (vsExpanded in Run.Parent.States) then + Break; + + Run := Run.Parent; + until False; + end; + + UpdateVerticalRange; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CalculateCacheEntryCount: Integer; + +// Calculates the size of the position cache. + +begin + if FVisibleCount > 1 then + Result := Ceil(FVisibleCount / CacheThreshold) + else + Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CalculateVerticalAlignments(ShowImages, ShowStateImages: Boolean; Node: PVirtualNode; + var VAlign, VButtonAlign: Integer); + +// Calculates the vertical alignment of the given node and its associated expand/collapse button during +// a node paint cycle depending on the required node alignment style. + +begin + // For absolute alignment the calculation is trivial. + case FNodeAlignment of + naFromTop: + VAlign := Node.Align; + naFromBottom: + VAlign := Integer(NodeHeight[Node]) - Node.Align; + else // naProportional + // Consider button and line alignment, but make sure neither the image nor the button (whichever is taller) + // go out of the entire node height (100% means bottom alignment to the node's bounds). + if ShowImages or ShowStateImages then + begin + if ShowImages then + VAlign := FImages.Height + else + VAlign := FStateImages.Height; + VAlign := MulDiv((Integer(NodeHeight[Node]) - VAlign), Node.Align, 100) + VAlign div 2; + end + else + if toShowButtons in FOptions.FPaintOptions then + VAlign := MulDiv((Integer(NodeHeight[Node]) - FPlusBM.Height), Node.Align, 100) + FPlusBM.Height div 2 + else + VAlign := MulDiv(Integer(Node.NodeHeight), Node.Align, 100); + end; + + VButtonAlign := VAlign - FPlusBM.Height div 2; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ChangeCheckState(Node: PVirtualNode; Value: TCheckState): Boolean; + +// Sets the check state of the node according to the given value and the node's check type. +// If the check state must be propagated to the parent nodes and one of them refuses to change then +// nothing happens and False is returned, otherwise True. + +var + Run: PVirtualNode; + UncheckedCount, + MixedCheckCount, + CheckedCount: Cardinal; + +begin + Result := not (vsChecking in Node.States); + with Node^ do + if Result then + begin + Include(States, vsChecking); + if not (vsInitialized in States) then + InitNode(Node); + + // Indicate that we are going to propagate check states up and down the hierarchy. + if FCheckPropagationCount = 0 then // WL, 05.02.2004: Do not enter tsCheckPropagation more than once + DoStateChange([tsCheckPropagation]); + Inc(FCheckPropagationCount); // WL, 05.02.2004 + // Do actions which are associated with the given check state. + case CheckType of + // Check state change with additional consequences for check states of the children. + ctTriStateCheckBox: + begin + // Propagate state down to the children. + if toAutoTristateTracking in FOptions.FAutoOptions then + case Value of + csUncheckedNormal: + if Node.ChildCount > 0 then + begin + Run := FirstChild; + CheckedCount := 0; + MixedCheckCount := 0; + UncheckedCount := 0; + while Assigned(Run) do + begin + if Run.CheckType in [ctCheckBox, ctTriStateCheckBox] then + begin + SetCheckState(Run, csUncheckedNormal); + // Check if the new child state was set successfully, otherwise we have to adjust the + // node's new check state accordingly. + case Run.CheckState of + csCheckedNormal: + Inc(CheckedCount); + csMixedNormal: + Inc(MixedCheckCount); + csUncheckedNormal: + Inc(UncheckedCount); + end; + end; + Run := Run.NextSibling; + end; + + // If there is still a mixed state child node checkbox then this node must be mixed checked too. + if MixedCheckCount > 0 then + Value := csMixedNormal + else + // If nodes are normally checked child nodes then the unchecked count determines what + // to set for the node itself. + if CheckedCount > 0 then + if UncheckedCount > 0 then + Value := csMixedNormal + else + Value := csCheckedNormal; + end; + csCheckedNormal: + if Node.ChildCount > 0 then + begin + Run := FirstChild; + CheckedCount := 0; + MixedCheckCount := 0; + UncheckedCount := 0; + while Assigned(Run) do + begin + if Run.CheckType in [ctCheckBox, ctTriStateCheckBox] then + begin + SetCheckState(Run, csCheckedNormal); + // Check if the new child state was set successfully, otherwise we have to adjust the + // node's new check state accordingly. + case Run.CheckState of + csCheckedNormal: + Inc(CheckedCount); + csMixedNormal: + Inc(MixedCheckCount); + csUncheckedNormal: + Inc(UncheckedCount); + end; + end; + Run := Run.NextSibling; + end; + + // If there is still a mixed state child node checkbox then this node must be mixed checked too. + if MixedCheckCount > 0 then + Value := csMixedNormal + else + // If nodes are normally checked child nodes then the unchecked count determines what + // to set for the node itself. + if CheckedCount > 0 then + if UncheckedCount > 0 then + Value := csMixedNormal + else + Value := csCheckedNormal; + end; + end; + end; + // radio button check state change + ctRadioButton: + if Value = csCheckedNormal then + begin + Value := csCheckedNormal; + // Make sure only this node is checked. + Run := Parent.FirstChild; + while Assigned(Run) do + begin + if Run.CheckType = ctRadioButton then + Run.CheckState := csUncheckedNormal; + Run := Run.NextSibling; + end; + Invalidate; + end; + end; + + if Result then + CheckState := Value // Set new check state + else + CheckState := UnpressedState[CheckState]; // Reset dynamic check state. + + // Propagate state up to the parent. + if not (vsInitialized in Parent.States) then + InitNode(Parent); + if (toAutoTristateTracking in FOptions.FAutoOptions) and ([vsChecking, vsDisabled] * Parent.States = []) and + (CheckType in [ctCheckBox, ctTriStateCheckBox]) and (Parent <> FRoot) and + (Parent.CheckType = ctTriStateCheckBox) then + Result := CheckParentCheckState(Node, Value) + else + Result := True; + + InvalidateNode(Node); + Exclude(States, vsChecking); + + Dec(FCheckPropagationCount); // WL, 05.02.2004 + if FCheckPropagationCount = 0 then // WL, 05.02.2004: Allow state change event after all check operations finished + DoStateChange([], [tsCheckPropagation]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CollectSelectedNodesLTR(MainColumn, NodeLeft, NodeRight: Integer; Alignment: TAlignment; + OldRect, NewRect: TRect): Boolean; + +// Helper routine used when a draw selection takes place. This version handles left-to-right directionality. +// In the process of adding or removing nodes the current selection is modified which requires to pack it after +// the function returns. Another side effect of this method is that a temporary list of nodes will be created +// (see also InternalCacheNode) which must be inserted into the current selection by the caller. + +var + Run, + NextNode: PVirtualNode; + TextRight, + TextLeft, + CheckOffset, + CurrentTop, + CurrentRight, + NextTop, + NextColumn, + NodeWidth, + Dummy: Integer; + MinY, MaxY: Integer; + ImageOffset, + StateImageOffset: Integer; + IsInOldRect, + IsInNewRect: Boolean; + + // quick check variables for various parameters + WithCheck, + WithImages, + WithStateImages, + DoSwitch, + AutoSpan: Boolean; + SimpleSelection: Boolean; + +begin + // A priori nothing changes. + Result := False; + + // Determine minimum and maximum vertical coordinates to limit iteration to. + MinY := Min(OldRect.Top, NewRect.Top); + MaxY := Max(OldRect.Bottom, NewRect.Bottom); + + // Initialize short hand variables to speed up tests below. + DoSwitch := ssCtrl in FDrawSelShiftState; + WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); + // Don't check the events here as descendant trees might have overriden the DoGetImageIndex method. + WithImages := Assigned(FImages); + if WithImages then + ImageOffset := FImages.Width + 2 + else + ImageOffset := 0; + WithStateImages := Assigned(FStateImages); + if WithStateImages then + StateImageOffset := FStateImages.Width + 2 + else + StateImageOffset := 0; + if WithCheck then + CheckOffset := FCheckImages.Width + 2 + else + CheckOffset := 0; + AutoSpan := FHeader.UseColumns and (toAutoSpanColumns in FOptions.FAutoOptions); + SimpleSelection := toSimpleDrawSelection in FOptions.FSelectionOptions; + // This is the node to start with. + Run := GetNodeAt(0, MinY, False, CurrentTop); + + if Assigned(Run) then + begin + // The initial minimal left border is determined by the identation level of the node and is dynamically adjusted. + if toShowRoot in FOptions.FPaintOptions then + Inc(NodeLeft, Integer((GetNodeLevel(Run) + 1) * FIndent) + FMargin) else + Inc(NodeLeft, Integer(GetNodeLevel(Run) * FIndent) + FMargin); + + // ----- main loop + // Change selection depending on the node's rectangle being in the selection rectangle or not, but + // touch only those nodes which overlap either the old selection rectangle or the new one but not both. + repeat + // Collect offsets for check, normal and state images. + TextLeft := NodeLeft; + if WithCheck and (Run.CheckType <> ctNone) then + Inc(TextLeft, CheckOffset); + if WithImages and HasImage(Run, ikNormal, MainColumn) then + Inc(TextLeft, ImageOffset); + if WithStateImages and HasImage(Run, ikState, MainColumn) then + Inc(TextLeft, StateImageOffset); + // Ensure the node's height is determined. + MeasureItemHeight(Canvas, Run); + + NextTop := CurrentTop + Integer(NodeHeight[Run]); + + // Simple selection allows to draw the selection rectangle anywhere. No intersection with node captions is + // required. Only top and bottom bounds of the rectangle matter. + if SimpleSelection then + begin + IsInOldRect := (NextTop > OldRect.Top) and (CurrentTop < OldRect.Bottom); + IsInNewRect := (NextTop > NewRect.Top) and (CurrentTop < NewRect.Bottom); + end + else + begin + // The right column border might be extended if column spanning is enabled. + if AutoSpan then + begin + with FHeader.FColumns do + begin + NextColumn := MainColumn; + repeat + Dummy := GetNextVisibleColumn(NextColumn); + if (Dummy = InvalidColumn) or not ColumnIsEmpty(Run, Dummy) or + (Items[Dummy].BidiMode <> bdLeftToRight) then + Break; + NextColumn := Dummy; + until False; + if NextColumn = MainColumn then + CurrentRight := NodeRight + else + GetColumnBounds(NextColumn, Dummy, CurrentRight); + end; + end + else + CurrentRight := NodeRight; + // Check if we need the node's width. This is the case when the node is not left aligned or the + // left border of the selection rectangle is to the right of the left node border. + if (TextLeft < OldRect.Left) or (TextLeft < NewRect.Left) or (Alignment <> taLeftJustify) then + begin + NodeWidth := DoGetNodeWidth(Run, MainColumn); + if NodeWidth >= (CurrentRight - TextLeft) then + TextRight := CurrentRight + else + case Alignment of + taLeftJustify: + TextRight := TextLeft + NodeWidth; + taCenter: + begin + TextLeft := (TextLeft + CurrentRight - NodeWidth) div 2; + TextRight := TextLeft + NodeWidth; + end; + else + // taRightJustify + TextRight := CurrentRight; + TextLeft := TextRight - NodeWidth; + end; + end + else + TextRight := CurrentRight; + + // Now determine whether we need to change the state. + IsInOldRect := (OldRect.Left <= TextRight) and (OldRect.Right >= TextLeft) and + (NextTop > OldRect.Top) and (CurrentTop < OldRect.Bottom); + IsInNewRect := (NewRect.Left <= TextRight) and (NewRect.Right >= TextLeft) and + (NextTop > NewRect.Top) and (CurrentTop < NewRect.Bottom); + end; + + if IsInOldRect xor IsInNewRect then + begin + Result := True; + if DoSwitch then + begin + if vsSelected in Run.States then + InternalRemoveFromSelection(Run) + else + InternalCacheNode(Run); + end + else + begin + if IsInNewRect then + InternalCacheNode(Run) + else + InternalRemoveFromSelection(Run); + end; + end; + CurrentTop := NextTop; + // Get next visible node and update left node position. + NextNode := GetNextVisibleNoInit(Run, True); + if NextNode = nil then + Break; + Inc(NodeLeft, CountLevelDifference(Run, NextNode) * Integer(FIndent)); + Run := NextNode; + until CurrentTop > MaxY; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CollectSelectedNodesRTL(MainColumn, NodeLeft, NodeRight: Integer; Alignment: TAlignment; + OldRect, NewRect: TRect): Boolean; + +// Helper routine used when a draw selection takes place. This version handles right-to-left directionality. +// See also comments in CollectSelectedNodesLTR. + +var + Run, + NextNode: PVirtualNode; + TextRight, + TextLeft, + CheckOffset, + CurrentTop, + CurrentLeft, + NextTop, + NextColumn, + NodeWidth, + Dummy: Integer; + MinY, MaxY: Integer; + ImageOffset, + StateImageOffset: Integer; + IsInOldRect, + IsInNewRect: Boolean; + + // quick check variables for various parameters + WithCheck, + WithImages, + WithStateImages, + DoSwitch, + AutoSpan: Boolean; + SimpleSelection: Boolean; + +begin + // A priori nothing changes. + Result := False; + // Switch the alignment to the opposite value in RTL context. + ChangeBiDiModeAlignment(Alignment); + + // Determine minimum and maximum vertical coordinates to limit iteration to. + MinY := Min(OldRect.Top, NewRect.Top); + MaxY := Max(OldRect.Bottom, NewRect.Bottom); + + // Initialize short hand variables to speed up tests below. + DoSwitch := ssCtrl in FDrawSelShiftState; + WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); + // Don't check the events here as descendant trees might have overriden the DoGetImageIndex method. + WithImages := Assigned(FImages); + if WithImages then + ImageOffset := FImages.Width + 2 + else + ImageOffset := 0; + WithStateImages := Assigned(FStateImages); + if WithStateImages then + StateImageOffset := FStateImages.Width + 2 + else + StateImageOffset := 0; + if WithCheck then + CheckOffset := FCheckImages.Width + 2 + else + CheckOffset := 0; + AutoSpan := FHeader.UseColumns and (toAutoSpanColumns in FOptions.FAutoOptions); + SimpleSelection := toSimpleDrawSelection in FOptions.FSelectionOptions; + // This is the node to start with. + Run := GetNodeAt(0, MinY, False, CurrentTop); + + if Assigned(Run) then + begin + // The initial minimal left border is determined by the identation level of the node and is dynamically adjusted. + if toShowRoot in FOptions.FPaintOptions then + Dec(NodeRight, Integer((GetNodeLevel(Run) + 1) * FIndent) + FMargin) else + Dec(NodeRight, Integer(GetNodeLevel(Run) * FIndent) + FMargin); + + // ----- main loop + // Change selection depending on the node's rectangle being in the selection rectangle or not, but + // touch only those nodes which overlap either the old selection rectangle or the new one but not both. + repeat + // Collect offsets for check, normal and state images. + TextRight := NodeRight; + if WithCheck and (Run.CheckType <> ctNone) then + Dec(TextRight, CheckOffset); + if WithImages and HasImage(Run, ikNormal, MainColumn) then + Dec(TextRight, ImageOffset); + if WithStateImages and HasImage(Run, ikState, MainColumn) then + Dec(TextRight, StateImageOffset); + // Ensure the node's height is determined. + MeasureItemHeight(Canvas, Run); + + NextTop := CurrentTop + Integer(NodeHeight[Run]); + + // Simple selection allows to draw the selection rectangle anywhere. No intersection with node captions is + // required. Only top and bottom bounds of the rectangle matter. + if SimpleSelection then + begin + IsInOldRect := (NextTop > OldRect.Top) and (CurrentTop < OldRect.Bottom); + IsInNewRect := (NextTop > NewRect.Top) and (CurrentTop < NewRect.Bottom); + end + else + begin // The left column border might be extended if column spanning is enabled. + if AutoSpan then + begin + NextColumn := MainColumn; + repeat + Dummy := FHeader.FColumns.GetPreviousVisibleColumn(NextColumn); + if (Dummy = InvalidColumn) or not ColumnIsEmpty(Run, Dummy) or + (FHeader.FColumns[Dummy].BiDiMode = bdLeftToRight) then + Break; + NextColumn := Dummy; + until False; + if NextColumn = MainColumn then + CurrentLeft := NodeLeft + else + FHeader.FColumns.GetColumnBounds(NextColumn, CurrentLeft, Dummy); + end + else + CurrentLeft := NodeLeft; + // Check if we need the node's width. This is the case when the node is not left aligned (in RTL context this // means actually right aligned) or the right border of the selection rectangle is to the left + // of the right node border. + if (TextRight > OldRect.Right) or (TextRight > NewRect.Right) or (Alignment <> taRightJustify) then + begin + NodeWidth := DoGetNodeWidth(Run, MainColumn); + if NodeWidth >= (TextRight - CurrentLeft) then + TextLeft := CurrentLeft + else + case Alignment of + taLeftJustify: + begin + TextLeft := CurrentLeft; + TextRight := TextLeft + NodeWidth; + end; + taCenter: + begin + TextLeft := (TextRight + CurrentLeft - NodeWidth) div 2; + TextRight := TextLeft + NodeWidth; + end; + else + // taRightJustify + TextLeft := TextRight - NodeWidth; + end; + end + else + TextLeft := CurrentLeft; + + // Now determine whether we need to change the state. + IsInOldRect := (OldRect.Right >= TextLeft) and (OldRect.Left <= TextRight) and + (NextTop > OldRect.Top) and (CurrentTop < OldRect.Bottom); + IsInNewRect := (NewRect.Right >= TextLeft) and (NewRect.Left <= TextRight) and + (NextTop > NewRect.Top) and (CurrentTop < NewRect.Bottom); + end; + + if IsInOldRect xor IsInNewRect then + begin + Result := True; + if DoSwitch then + begin + if vsSelected in Run.States then + InternalRemoveFromSelection(Run) + else + InternalCacheNode(Run); + end + else + begin + if IsInNewRect then + InternalCacheNode(Run) + else + InternalRemoveFromSelection(Run); + end; + end; + CurrentTop := NextTop; + // Get next visible node and update left node position. + NextNode := GetNextVisibleNoInit(Run, True); + if NextNode = nil then + Break; + Dec(NodeRight, CountLevelDifference(Run, NextNode) * Integer(FIndent)); + Run := NextNode; + until CurrentTop > MaxY; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ClearNodeBackground(const PaintInfo: TVTPaintInfo; UseBackground, Floating: Boolean; + R: TRect); + +// Erases a node's background depending on what the application decides to do. +// UseBackground determines whether or not to use the background picture, while Floating indicates +// that R is given in coordinates of the small node bitmap or the superordinated target bitmap used in PaintTree. + +var + BackColor: TColor; + EraseAction: TItemEraseAction; + Offset: TPoint; + +begin + with PaintInfo do + begin + EraseAction := eaDefault; + BackColor := Color; + if Floating then + begin + Offset := Point(-FEffectiveOffsetX, R.Top); + OffsetRect(R, 0, -Offset.Y); + end + else + Offset := Point(0, 0); + + DoBeforeItemErase(Canvas, Node, R, Backcolor, EraseAction); + + with Canvas do + begin + case EraseAction of + eaNone: + ; + eaColor: + begin + // User has given a new background color. + Brush.Color := BackColor; + FillRect(R); + end; + else // eaDefault + if UseBackground then + begin + if toStaticBackground in TreeOptions.PaintOptions then + StaticBackground(FBackground.Bitmap, Canvas, Offset, R) + else + TileBackground(FBackground.Bitmap, Canvas, Offset, R); + end + else + begin + if (poDrawSelection in PaintOptions) and (toFullRowSelect in FOptions.FSelectionOptions) and + (vsSelected in Node.States) and not (toUseBlendedSelection in FOptions.PaintOptions) and not + (tsUseExplorerTheme in FStates) then + begin + if toShowHorzGridLines in FOptions.PaintOptions then + Dec(R.Bottom); + if Focused or (toPopupMode in FOptions.FPaintOptions) then + begin + Brush.Color := FColors.FocusedSelectionColor; + Pen.Color := FColors.FocusedSelectionBorderColor; + end + else + begin + Brush.Color := FColors.UnfocusedSelectionColor; + Pen.Color := FColors.UnfocusedSelectionBorderColor; + end; + + with TWithSafeRect(R) do + RoundRect(Left, Top, Right, Bottom, FSelectionCurveRadius, FSelectionCurveRadius); + end + else + begin + Brush.Color := Color; + FillRect(R); + end; + end; + end; + DoAfterItemErase(Canvas, Node, R); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CompareNodePositions(Node1, Node2: PVirtualNode; ConsiderChildrenAbove: Boolean = False): Integer; + +// Tries hard and smart to quickly determine whether Node1's structural position is before Node2's position. +// If ConsiderChildrenAbove is True, the nodes will be compared with their visual order in mind. +// Returns 0 if Node1 = Node2, < 0 if Node1 is located before Node2 else > 0. + +var + Run1, + Run2: PVirtualNode; + Level1, + Level2: Cardinal; + +begin + Assert(Assigned(Node1) and Assigned(Node2), 'Nodes must never be nil.'); + + if Node1 = Node2 then + Result := 0 + else + begin + if HasAsParent(Node1, Node2) then + Result := IfThen(ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions), -1, 1) + else + if HasAsParent(Node2, Node1) then + Result := IfThen(ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions), 1, -1) + else + begin + // the given nodes are neither equal nor are they parents of each other, so go up to FRoot + // for each node and compare the child indices of the top level parents + // Note: neither Node1 nor Node2 can be FRoot at this point as this (a bit strange) circumstance would + // be caught by the previous code. + + // start lookup at the same level + Level1 := GetNodeLevel(Node1); + Level2 := GetNodeLevel(Node2); + Run1 := Node1; + while Level1 > Level2 do + begin + Run1 := Run1.Parent; + Dec(Level1); + end; + Run2 := Node2; + while Level2 > Level1 do + begin + Run2 := Run2.Parent; + Dec(Level2); + end; + + // now go up until we find a common parent node (loop will safely stop at FRoot if the nodes + // don't share a common parent) + while Run1.Parent <> Run2.Parent do + begin + Run1 := Run1.Parent; + Run2 := Run2.Parent; + end; + Result := Integer(Run1.Index) - Integer(Run2.Index); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DrawLineImage(const PaintInfo: TVTPaintInfo; X, Y, H, VAlign: Integer; Style: TVTLineType; + Reverse: Boolean); + +// Draws (depending on Style) one of the 5 line types of the tree. +// If Reverse is True then a right-to-left column is being drawn, hence horizontal lines must be mirrored. +// X and Y describe the left upper corner of the line image rectangle, while H denotes its height (and width). + +var + HalfWidth, + TargetX: Integer; + +begin + HalfWidth := Round(FIndent / 2); + if Reverse then + TargetX := 0 + else + TargetX := FIndent; + + with PaintInfo.Canvas do + begin + case Style of + ltBottomRight: + begin + DrawDottedVLine(PaintInfo, Y + VAlign, Y + H, X + HalfWidth); + DrawDottedHLine(PaintInfo, X + HalfWidth, X + TargetX, Y + VAlign); + end; + ltTopDown: + DrawDottedVLine(PaintInfo, Y, Y + H, X + HalfWidth); + ltTopDownRight: + begin + DrawDottedVLine(PaintInfo, Y, Y + H, X + HalfWidth); + DrawDottedHLine(PaintInfo, X + HalfWidth, X + TargetX, Y + VAlign); + end; + ltRight: + DrawDottedHLine(PaintInfo, X + HalfWidth, X + TargetX, Y + VAlign); + ltTopRight: + begin + DrawDottedVLine(PaintInfo, Y, Y + VAlign, X + HalfWidth); + DrawDottedHLine(PaintInfo, X + HalfWidth, X + TargetX, Y + VAlign); + end; + ltLeft: // left can also mean right for RTL context + if Reverse then + DrawDottedVLine(PaintInfo, Y, Y + H, X + Integer(FIndent)) + else + DrawDottedVLine(PaintInfo, Y, Y + H, X); + ltLeftBottom: + if Reverse then + begin + DrawDottedVLine(PaintInfo, Y, Y + H, X + Integer(FIndent)); + DrawDottedHLine(PaintInfo, X, X + Integer(FIndent), Y + H); + end + else + begin + DrawDottedVLine(PaintInfo, Y, Y + H, X); + DrawDottedHLine(PaintInfo, X, X + Integer(FIndent), Y + H); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.FindInPositionCache(Node: PVirtualNode; var CurrentPos: Cardinal): PVirtualNode; + +// Looks through the position cache and returns the node whose top position is the largest one which is smaller or equal +// to the position of the given node. + +var + L, H, I: Integer; + +begin + L := 0; + H := High(FPositionCache); + while L <= H do + begin + I := (L + H) shr 1; + if CompareNodePositions(FPositionCache[I].Node, Node) <= 0 then + L := I + 1 + else + H := I - 1; + end; + if L = 0 then // High(FPositionCache) = -1 + begin + Result := nil; + CurrentPos := 0; + end + else + begin + Result := FPositionCache[L - 1].Node; + CurrentPos := FPositionCache[L - 1].AbsoluteTop; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.FindInPositionCache(Position: Cardinal; var CurrentPos: Cardinal): PVirtualNode; + +// Looks through the position cache and returns the node whose top position is the largest one which is smaller or equal +// to the given vertical position. +// The returned node does not necessarily occupy the given position but is the nearest one to start +// iterating from to approach the real node for a given position. CurrentPos receives the actual position of the found +// node which is needed for further iteration. + +var + L, H, I: Integer; + +begin + L := 0; + H := High(FPositionCache); + while L <= H do + begin + I := (L + H) shr 1; + if FPositionCache[I].AbsoluteTop <= Position then + L := I + 1 + else + H := I - 1; + end; + if L = 0 then // High(FPositionCache) = -1 + begin + Result := nil; + CurrentPos := 0; + end + else + begin + Result := FPositionCache[L - 1].Node; + CurrentPos := FPositionCache[L - 1].AbsoluteTop; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FixupTotalCount(Node: PVirtualNode); + +// Called after loading a subtree from stream. The child count in each node is already set but not +// their total count. + +var + Child: PVirtualNode; + +begin + // Initial total count is set to one on node creation. + Child := Node.FirstChild; + while Assigned(Child) do + begin + FixupTotalCount(Child); + Inc(Node.TotalCount, Child.TotalCount); + Child := Child.NextSibling; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FixupTotalHeight(Node: PVirtualNode); + +// Called after loading a subtree from stream. The individual height of each node is set already, +// but their total height needs an adjustment depending on their visibility state. + +var + Child: PVirtualNode; + +begin + // Initial total height is set to the node height on load. + Child := Node.FirstChild; + + if vsExpanded in Node.States then + begin + while Assigned(Child) do + begin + FixupTotalHeight(Child); + if vsVisible in Child.States then + Inc(Node.TotalHeight, Child.TotalHeight); + Child := Child.NextSibling; + end; + end + else + begin + // The node is collapsed, so just update the total height of its child nodes. + while Assigned(Child) do + begin + FixupTotalHeight(Child); + Child := Child.NextSibling; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetBottomNode: PVirtualNode; + +begin + Result := GetNodeAt(0, ClientHeight - 1); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetCheckedCount: Integer; + +var + Node: PVirtualNode; + +begin + Result := 0; + Node := GetFirstChecked; + while Assigned(Node) do begin + Inc(Result); + Node := GetNextChecked(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetCheckState(Node: PVirtualNode): TCheckState; + +begin + Result := Node.CheckState; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetCheckType(Node: PVirtualNode): TCheckType; + +begin + Result := Node.CheckType; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetChildCount(Node: PVirtualNode): Cardinal; + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.ChildCount + else + Result := Node.ChildCount; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetChildrenInitialized(Node: PVirtualNode): Boolean; + +begin + Result := not (vsHasChildren in Node.States) or (Node.ChildCount > 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetCutCopyCount: Integer; + +var + Node: PVirtualNode; + +begin + Result := 0; + Node := GetFirstCutCopy; + while Assigned(Node) do begin + Inc(Result); + Node := GetNextCutCopy(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetDisabled(Node: PVirtualNode): Boolean; + +begin + Result := Assigned(Node) and (vsDisabled in Node.States); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetDragManager: IVTDragManager; + +// Returns the internal drag manager interface. If this does not yet exist then it is created here. + +begin + if FDragManager = nil then + begin + FDragManager := DoCreateDragManager; + if FDragManager = nil then + FDragManager := TVTDragManager.Create(Self); + end; + + Result := FDragManager; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetExpanded(Node: PVirtualNode): Boolean; + +begin + if Assigned(Node) then + Result := vsExpanded in Node.States + else + Result := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFiltered(Node: PVirtualNode): Boolean; + +begin + Result := vsFiltered in Node.States; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFullyVisible(Node: PVirtualNode): Boolean; + +// Determines whether the given node has the visibility flag set as well as all its parents are expanded. + +begin + Assert(Assigned(Node), 'Invalid parameter.'); + Result := vsVisible in Node.States; + if Result and (Node <> FRoot) then + Result := VisiblePath[Node]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetHasChildren(Node: PVirtualNode): Boolean; + +begin + if Assigned(Node) then + Result := vsHasChildren in Node.States + else + Result := vsHasChildren in FRoot.States; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetMultiline(Node: PVirtualNode): Boolean; + +begin + Result := Assigned(Node) and (Node <> FRoot) and (vsMultiline in Node.States); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeHeight(Node: PVirtualNode): Cardinal; + +begin + if Assigned(Node) and (Node <> FRoot) then + begin + if (toVariableNodeHeight in FOptions.FMiscOptions) and not (vsDeleting in Node.States) then + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + + // Ensure the node's height is determined. + MeasureItemHeight(Canvas, Node); + end; + Result := Node.NodeHeight + end + else + Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeParent(Node: PVirtualNode): PVirtualNode; + +begin + if Assigned(Node) and (Node.Parent <> FRoot) then + Result := Node.Parent + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetOffsetXY: TPoint; + +begin + Result := Point(FOffsetX, FOffsetY); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetRootNodeCount: Cardinal; + +begin + Result := FRoot.ChildCount; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetSelected(Node: PVirtualNode): Boolean; + +begin + Result := Assigned(Node) and (vsSelected in Node.States); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetTopNode: PVirtualNode; + +var + Dummy: Integer; + +begin + Result := GetNodeAt(0, 0, True, Dummy); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetTotalCount: Cardinal; + +begin + Inc(FUpdateCount); + try + ValidateNode(FRoot, True); + finally + Dec(FUpdateCount); + end; + // The root node itself doesn't count as node. + Result := FRoot.TotalCount - 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetVerticalAlignment(Node: PVirtualNode): Byte; + +begin + Result := Node.Align; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetVisible(Node: PVirtualNode): Boolean; + +// Determines if the given node is marked as being visible. + +begin + if Node = nil then + Node := FRoot; + + if not (vsInitialized in Node.States) then + InitNode(Node); + + Result := vsVisible in Node.States; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetVisiblePath(Node: PVirtualNode): Boolean; + +// Determines if all parents of the given node are expanded and have the visibility flag set. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameters.'); + + // FRoot is always expanded + repeat + Node := Node.Parent; + until (Node = FRoot) or not (vsExpanded in Node.States) or not (vsVisible in Node.States); + + Result := Node = FRoot; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleClickSelection(LastFocused, NewNode: PVirtualNode; Shift: TShiftState; + DragPending: Boolean); + +// Handles multi-selection with mouse click. + +begin + // Ctrl key down + if ssCtrl in Shift then + begin + if ssShift in Shift then + begin + SelectNodes(FRangeAnchor, NewNode, True); + end + else + begin + if not (toSiblingSelectConstraint in FOptions.SelectionOptions) then + FRangeAnchor := NewNode; + // Delay selection change if a drag operation is pending. + // Otherwise switch selection state here. + if DragPending then + DoStateChange([tsToggleFocusedSelection]) + else + if vsSelected in NewNode.States then + RemoveFromSelection(NewNode) + else + AddToSelection(NewNode); + end; + Update;//Invalidate didn't update owner drawn selections + end + else + // Shift key down + if ssShift in Shift then + begin + if FRangeAnchor = nil then + FRangeAnchor := FRoot.FirstChild; + + // select node range + if Assigned(FRangeAnchor) then + begin + SelectNodes(FRangeAnchor, NewNode, False); + Invalidate; + end; + end + else + begin + // any other case + if not (vsSelected in NewNode.States) then + begin + AddToSelection(NewNode); + InvalidateNode(NewNode); + end; + // assign new reference item + FRangeAnchor := NewNode; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HandleDrawSelection(X, Y: Integer): Boolean; + +// Handles multi-selection with a focus rectangle. +// Result is True if something changed in selection. + +var + OldRect, + NewRect: TRect; + MainColumn: TColumnIndex; + MaxValue: Integer; + + // limits of a node and its text + NodeLeft, + NodeRight: Integer; + + // alignment and directionality + CurrentBidiMode: TBidiMode; + CurrentAlignment: TAlignment; + +begin + Result := False; + + // Selection changes are only done if the user drew a selection rectangle large + // enough to exceed the threshold. + if (FRoot.TotalCount > 1) and (tsDrawSelecting in FStates) then + begin + // Effective handling of node selection is done by using two rectangles stored in FSelectRec. + OldRect := OrderRect(FLastSelRect); + NewRect := OrderRect(FNewSelRect); + ClearTempCache; + + MainColumn := FHeader.MainColumn; + + // Alignment and bidi mode determine where the node text is located within a node. + if MainColumn <= NoColumn then + begin + CurrentBidiMode := BidiMode; + CurrentAlignment := Alignment; + end + else + begin + CurrentBidiMode := FHeader.FColumns[MainColumn].BidiMode; + CurrentAlignment := FHeader.FColumns[MainColumn].Alignment; + end; + + // Determine initial left border of first node (take column reordering into account). + if FHeader.UseColumns then + begin + // The mouse coordinates don't include any horizontal scrolling hence take this also + // out from the returned column position. + NodeLeft := FHeader.FColumns[MainColumn].Left - FEffectiveOffsetX; + NodeRight := NodeLeft + FHeader.FColumns[MainColumn].Width; + end + else + begin + NodeLeft := 0; + NodeRight := ClientWidth; + end; + if CurrentBidiMode = bdLeftToRight then + Result := CollectSelectedNodesLTR(MainColumn, NodeLeft, NodeRight, CurrentAlignment, OldRect, NewRect) + else + Result := CollectSelectedNodesRTL(MainColumn, NodeLeft, NodeRight, CurrentAlignment, OldRect, NewRect); + end; + + if Result then + begin + // Do some housekeeping if there was a change. + MaxValue := PackArray(FSelection, FSelectionCount); + if MaxValue > -1 then + begin + FSelectionCount := MaxValue; + SetLength(FSelection, FSelectionCount); + end; + if FTempNodeCount > 0 then + begin + AddToSelection(FTempNodeCache, FTempNodeCount); + ClearTempCache; + end; + + Change(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HasVisibleNextSibling(Node: PVirtualNode): Boolean; + +// Helper method to determine if the given node has a visible next sibling. This is needed to +// draw correct tree lines. + +begin + // Check if there is a sibling at all. + Result := Assigned(Node.NextSibling); + + if Result then + begin + repeat + Node := Node.NextSibling; + Result := IsEffectivelyVisible[Node]; + until Result or (Node.NextSibling = nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HasVisiblePreviousSibling(Node: PVirtualNode): Boolean; + +// Helper method to determine if the given node has a visible previous sibling. This is needed to +// draw correct tree lines. + +begin + // Check if there is a sibling at all. + Result := Assigned(Node.PrevSibling); + + if Result then + begin + repeat + Node := Node.PrevSibling; + Result := IsEffectivelyVisible[Node]; + until Result or (Node.PrevSibling = nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ImageListChange(Sender: TObject); + +begin + if not (csDestroying in ComponentState) then + Invalidate; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InitializeFirstColumnValues(var PaintInfo: TVTPaintInfo); + +// Determines initial index, position and cell size of the first visible column. + +begin + PaintInfo.Column := FHeader.FColumns.GetFirstVisibleColumn; + with FHeader.FColumns, PaintInfo do + begin + if Column > NoColumn then + begin + CellRect.Right := CellRect.Left + Items[Column].Width; + Position := Items[Column].Position; + end + else + Position := 0; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InitRootNode(OldSize: Cardinal = 0); + +// Reinitializes the root node. + +var + NewSize: Cardinal; + +begin + NewSize := TreeNodeSize + FTotalInternalDataSize; + if FRoot = nil then + FRoot := AllocMem(NewSize) + else + begin + ReallocMem(FRoot, NewSize); + ZeroMemory(PByte(FRoot) + OldSize, NewSize - OldSize); + end; + + with FRoot^ do + begin + // Indication that this node is the root node. + PrevSibling := FRoot; + NextSibling := FRoot; + Parent := Pointer(Self); + States := [vsInitialized, vsExpanded, vsHasChildren, vsVisible]; + TotalHeight := FDefaultNodeHeight; + TotalCount := 1; + TotalHeight := FDefaultNodeHeight; + NodeHeight := FDefaultNodeHeight; + Align := 50; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InterruptValidation; + +var + WasValidating: Boolean; + +begin + DoStateChange([tsStopValidation], [tsUseCache]); + + // Check the worker thread existance. It might already be gone (usually on destruction of the last tree). + if Assigned(WorkerThread) then + begin + WasValidating := (tsValidating in FStates); + WorkerThread.RemoveTree(Self); + if WasValidating then + DoStateChange([tsValidationNeeded]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.IsFirstVisibleChild(Parent, Node: PVirtualNode): Boolean; + +// Helper method to check if Node is the same as the first visible child of Parent. + +var + Run: PVirtualNode; + +begin + // Find first visible child. + Run := Parent.FirstChild; + while Assigned(Run) and not IsEffectivelyVisible[Run] do + Run := Run.NextSibling; + + Result := Assigned(Run) and (Run = Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.IsLastVisibleChild(Parent, Node: PVirtualNode): Boolean; + +// Helper method to check if Node is the same as the last visible child of Parent. + +var + Run: PVirtualNode; + +begin + // Find last visible child. + Run := Parent.LastChild; + while Assigned(Run) and not IsEffectivelyVisible[Run] do + Run := Run.PrevSibling; + + Result := Assigned(Run) and (Run = Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.MakeNewNode: PVirtualNode; + +var + Size: Cardinal; + +begin + Size := TreeNodeSize; + if not (csDesigning in ComponentState) then + begin + // Make sure FNodeDataSize is valid. + if FNodeDataSize = -1 then + ValidateNodeDataSize(FNodeDataSize); + + // Take record alignment into account. + Inc(Size, FNodeDataSize); + end; + + Result := AllocMem(Size + FTotalInternalDataSize); + + // Fill in some default values. + with Result^ do + begin + TotalCount := 1; + TotalHeight := FDefaultNodeHeight; + NodeHeight := FDefaultNodeHeight; + States := [vsVisible]; + Align := 50; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.PackArray({*}const TheArray: TNodeArray; Count: Integer): Integer; assembler; +// *This is an optimization to get as near as possible with the PUREPASCAL code without the +// compiler generating a _DynArrayAddRef call. We still modify the array's content via pointers. + +// Removes all entries from the selection array which are no longer in use. The selection array must be sorted for this +// algo to work. Values which must be removed are marked with bit 0 (LSB) set. This little trick works because memory +// is always allocated DWORD aligned. Since the selection array must be sorted while determining the entries to be +// removed it is much more efficient to increment the entry in question instead of setting it to nil (which would break +// the ordered appearance of the list). +// +// On enter EAX contains self reference, EDX the address to TheArray and ECX Count +// The returned value is the number of remaining entries in the array, so the caller can reallocate (shorten) +// the selection array if needed or -1 if nothing needs to be changed. + +{$ifdef CPUX64} +var + Source, Dest: ^PVirtualNode; + ConstOne: NativeInt; +begin + Source := Pointer(TheArray); + ConstOne := 1; + Result := 0; + // Do the fastest scan possible to find the first entry + while (Count <> 0) and {not Odd(NativeInt(Source^))} (NativeInt(Source^) and ConstOne = 0) do + begin + Inc(Result); + Inc(Source); + Dec(Count); + end; + + if Count <> 0 then + begin + Dest := Source; + repeat + // Skip odd entries + if {not Odd(NativeInt(Source^))} NativeInt(Source^) and ConstOne = 0 then + begin + Dest^ := Source^; + Inc(Result); + Inc(Dest); + end; + Inc(Source); // Point to the next entry + Dec(Count); + until Count = 0; + end; +end; +{$else} +asm + PUSH EBX + PUSH EDI + PUSH ESI + MOV ESI, EDX + MOV EDX, -1 + JCXZ @@Finish // Empty list? + INC EDX // init remaining entries counter + MOV EDI, ESI // source and destination point to the list memory + MOV EBX, 1 // use a register instead of immediate operant to check against +@@PreScan: + TEST [ESI], EBX // do the fastest scan possible to find the first entry + // which must be removed + JNZ @@DoMainLoop + INC EDX + ADD ESI, 4 + DEC ECX + JNZ @@PreScan + JMP @@Finish + +@@DoMainLoop: + MOV EDI, ESI +@@MainLoop: + TEST [ESI], EBX // odd entry? + JNE @@Skip // yes, so skip this one + MOVSD // else move the entry to new location + INC EDX // count the moved entries + DEC ECX + JNZ @@MainLoop // do it until all entries are processed + JMP @@Finish + +@@Skip: + ADD ESI, 4 // point to the next entry + DEC ECX + JNZ @@MainLoop // do it until all entries are processed +@@Finish: + MOV EAX, EDX // prepare return value + POP ESI + POP EDI + POP EBX +end; +{$endif CPUX64} + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean); + +// initializes the contents of the internal bitmaps + +const + LineBitsDotted: array [0..8] of Word = ($55, $AA, $55, $AA, $55, $AA, $55, $AA, $55); + LineBitsSolid: array [0..7] of Word = (0, 0, 0, 0, 0, 0, 0, 0); + +var + PatternBitmap: HBITMAP; + Bits: Pointer; + Size: TSize; + Theme: HTHEME; + R: TRect; + + //--------------- local function -------------------------------------------- + + procedure FillBitmap (ABitmap: TBitmap); + begin + with ABitmap, Canvas do + begin + Width := Size.cx; + Height := Size.cy; + + if IsWinVistaOrAbove and (tsUseThemes in FStates) and (toUseExplorerTheme in FOptions.FPaintOptions) then + begin + if (FHeader.MainColumn > NoColumn) and not (coParentColor in FHeader.FColumns[FHeader.MainColumn].Options) then + Brush.Color := FHeader.FColumns[FHeader.MainColumn].Color + else + Brush.Color := Self.Color; + end + else + Brush.Color := clFuchsia; + + Transparent := True; + TransparentColor := Brush.Color; + + FillRect(Rect(0, 0, Width, Height)); + end; + end; + + //--------------- end local function ---------------------------------------- + +begin + Size.cx := 9; + Size.cy := 9; + + if tsUseThemes in FStates then + begin + R := Rect(0, 0, 100, 100); + Theme := OpenThemeData(Handle, 'TREEVIEW'); + GetThemePartSize(Theme, FPlusBM.Canvas.Handle, TVP_GLYPH, GLPS_OPENED, @R, TS_TRUE, Size); + end + else + Theme := 0; + + if NeedButtons then + begin + with FMinusBM, Canvas do + begin + // box is always of odd size + FillBitmap(FMinusBM); + FillBitmap(FHotMinusBM); + if not (tsUseExplorerTheme in FStates) then + begin + if FButtonStyle = bsTriangle then + begin + Brush.Color := clBlack; + Pen.Color := clBlack; + Polygon([Point(0, 2), Point(8, 2), Point(4, 6)]); + end + else + begin + // Button style is rectangular. Now ButtonFillMode determines how to fill the interior. + if FButtonFillMode in [fmTreeColor, fmWindowColor, fmTransparent] then + begin + case FButtonFillMode of + fmTreeColor: + Brush.Color := Self.Color; + fmWindowColor: + Brush.Color := clWindow; + end; + Pen.Color := FColors.TreeLineColor; + Rectangle(0, 0, Width, Height); + Pen.Color := Self.Font.Color; + MoveTo(2, Width div 2); + LineTo(Width - 2 , Width div 2); + end + else + FMinusBM.Handle := LoadBitmap(HInstance, 'VT_XPBUTTONMINUS'); + FHotMinusBM.Canvas.Draw(0, 0, FMinusBM); + end; + end; + end; + + with FPlusBM, Canvas do + begin + FillBitmap(FPlusBM); + FillBitmap(FHotPlusBM); + if not (tsUseExplorerTheme in FStates) then + begin + if FButtonStyle = bsTriangle then + begin + Brush.Color := clBlack; + Pen.Color := clBlack; + Polygon([Point(2, 0), Point(6, 4), Point(2, 8)]); + end + else + begin + // Button style is rectangular. Now ButtonFillMode determines how to fill the interior. + if FButtonFillMode in [fmTreeColor, fmWindowColor, fmTransparent] then + begin + case FButtonFillMode of + fmTreeColor: + Brush.Color := Self.Color; + fmWindowColor: + Brush.Color := clWindow; + end; + + Pen.Color := FColors.TreeLineColor; + Rectangle(0, 0, Width, Height); + Pen.Color := Self.Font.Color; + MoveTo(2, Width div 2); + LineTo(Width - 2 , Width div 2); + MoveTo(Width div 2, 2); + LineTo(Width div 2, Width - 2); + end + else + FPlusBM.Handle := LoadBitmap(HInstance, 'VT_XPBUTTONPLUS'); + FHotPlusBM.Canvas.Draw(0, 0, FPlusBM); + end; + end; + end; + + // Overwrite glyph images if theme is active. + if tsUseThemes in FStates then + begin + R := Rect(0, 0, Size.cx, Size.cy); + DrawThemeBackground(Theme, FPlusBM.Canvas.Handle, TVP_GLYPH, GLPS_CLOSED, R, nil); + DrawThemeBackground(Theme, FMinusBM.Canvas.Handle, TVP_GLYPH, GLPS_OPENED, R, nil); + if tsUseExplorerTheme in FStates then + begin + DrawThemeBackground(Theme, FHotPlusBM.Canvas.Handle, TVP_HOTGLYPH, GLPS_CLOSED, R, nil); + DrawThemeBackground(Theme, FHotMinusBM.Canvas.Handle, TVP_HOTGLYPH, GLPS_OPENED, R, nil); + end + else + begin + FHotPlusBM.Canvas.Draw(0, 0, FPlusBM); + FHotMinusBM.Canvas.Draw(0, 0, FMinusBM); + end; + end; + end; + + if NeedLines then + begin + if FDottedBrush <> 0 then + DeleteObject(FDottedBrush); + + case FLineStyle of + lsDotted: + Bits := @LineBitsDotted; + lsSolid: + Bits := @LineBitsSolid; + else // lsCustomStyle + Bits := @LineBitsDotted; + DoGetLineStyle(Bits); + end; + PatternBitmap := CreateBitmap(8, 8, 1, 1, Bits); + FDottedBrush := CreatePatternBrush(PatternBitmap); + DeleteObject(PatternBitmap); + end; + + if tsUseThemes in FStates then + CloseThemeData(Theme); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + TOldVTOption = (voAcceptOLEDrop, voAnimatedToggle, voAutoDropExpand, voAutoExpand, voAutoScroll, + voAutoSort, voAutoSpanColumns, voAutoTristateTracking, voCheckSupport, voDisableDrawSelection, voEditable, + voExtendedFocus, voFullRowSelect, voGridExtensions, voHideFocusRect, voHideSelection, voHotTrack, voInitOnSave, + voLevelSelectConstraint, voMiddleClickSelect, voMultiSelect, voRightClickSelect, voPopupMode, voShowBackground, + voShowButtons, voShowDropmark, voShowHorzGridLines, voShowRoot, voShowTreeLines, voShowVertGridLines, + voSiblingSelectConstraint, voToggleOnDblClick); + +const + OptionMap: array[TOldVTOption] of Integer = ( + Ord(toAcceptOLEDrop), Ord(toAnimatedToggle), Ord(toAutoDropExpand), Ord(toAutoExpand), Ord(toAutoScroll), + Ord(toAutoSort), Ord(toAutoSpanColumns), Ord(toAutoTristateTracking), Ord(toCheckSupport), Ord(toDisableDrawSelection), + Ord(toEditable), Ord(toExtendedFocus), Ord(toFullRowSelect), Ord(toGridExtensions), Ord(toHideFocusRect), + Ord(toHideSelection), Ord(toHotTrack), Ord(toInitOnSave), Ord(toLevelSelectConstraint), Ord(toMiddleClickSelect), + Ord(toMultiSelect), Ord(toRightClickSelect), Ord(toPopupMode), Ord(toShowBackground), + Ord(toShowButtons), Ord(toShowDropmark), Ord(toShowHorzGridLines), Ord(toShowRoot), Ord(toShowTreeLines), + Ord(toShowVertGridLines), Ord(toSiblingSelectConstraint), Ord(toToggleOnDblClick) + ); + +procedure TBaseVirtualTree.ReadOldOptions(Reader: TReader); + +// Migration helper routine to silently convert forms containing the old tree options member into the new +// sub-options structure. + +var + OldOption: TOldVTOption; + EnumName: string; + +begin + // If we are at design time currently then let the designer know we changed something. + UpdateDesigner; + + // It should never happen at this place that there is something different than the old set. + if Reader.ReadValue = vaSet then + begin + // Remove all default values set by the constructor. + FOptions.AnimationOptions := []; + FOptions.AutoOptions := []; + FOptions.MiscOptions := []; + FOptions.PaintOptions := []; + FOptions.SelectionOptions := []; + + while True do + begin + // Sets are stored with their members as simple strings. Read them one by one and map them to the new option + // in the correct sub-option set. + EnumName := Reader.ReadStr; + if EnumName = '' then + Break; + OldOption := TOldVTOption(GetEnumValue(TypeInfo(TOldVTOption), EnumName)); + case OldOption of + voAcceptOLEDrop, voCheckSupport, voEditable, voGridExtensions, voInitOnSave, voToggleOnDblClick: + FOptions.MiscOptions := FOptions.FMiscOptions + [TVTMiscOption(OptionMap[OldOption])]; + voAnimatedToggle: + FOptions.AnimationOptions := FOptions.FAnimationOptions + [TVTAnimationOption(OptionMap[OldOption])]; + voAutoDropExpand, voAutoExpand, voAutoScroll, voAutoSort, voAutoSpanColumns, voAutoTristateTracking: + FOptions.AutoOptions := FOptions.FAutoOptions + [TVTAutoOption(OptionMap[OldOption])]; + voDisableDrawSelection, voExtendedFocus, voFullRowSelect, voLevelSelectConstraint, + voMiddleClickSelect, voMultiSelect, voRightClickSelect, voSiblingSelectConstraint: + FOptions.SelectionOptions := FOptions.FSelectionOptions + [TVTSelectionOption(OptionMap[OldOption])]; + voHideFocusRect, voHideSelection, voHotTrack, voPopupMode, voShowBackground, voShowButtons, + voShowDropmark, voShowHorzGridLines, voShowRoot, voShowTreeLines, voShowVertGridLines: + FOptions.PaintOptions := FOptions.FPaintOptions + [TVTPaintOption(OptionMap[OldOption])]; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetAlignment(const Value: TAlignment); + +begin + if FAlignment <> Value then + begin + FAlignment := Value; + if not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetAnimationDuration(const Value: Cardinal); + +begin + FAnimationDuration := Value; + if FAnimationDuration = 0 then + Exclude(FOptions.FAnimationOptions, toAnimatedToggle) + else + Include(FOptions.FAnimationOptions, toAnimatedToggle); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetBackground(const Value: TPicture); + +begin + FBackground.Assign(Value); + Invalidate; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetBackgroundOffset(const Index, Value: Integer); + +begin + case Index of + 0: + if FBackgroundOffsetX <> Value then + begin + FBackgroundOffsetX := Value; + Invalidate; + end; + 1: + if FBackgroundOffsetY <> Value then + begin + FBackgroundOffsetY := Value; + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetBorderStyle(Value: TBorderStyle); + +begin + if FBorderStyle <> Value then + begin + FBorderStyle := Value; + RecreateWnd; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetBottomNode(Node: PVirtualNode); + +var + Run: PVirtualNode; + R: TRect; + +begin + if Assigned(Node) then + begin + // make sure all parents of the node are expanded + Run := Node.Parent; + while Run <> FRoot do + begin + if not (vsExpanded in Run.States) then + ToggleNode(Run); + Run := Run.Parent; + end; + R := GetDisplayRect(Node, FHeader.MainColumn, True); + DoSetOffsetXY(Point(FOffsetX, FOffsetY + ClientHeight - R.Top - Integer(NodeHeight[Node])), + [suoRepaintScrollbars, suoUpdateNCArea]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetBottomSpace(const Value: Cardinal); + +begin + if FBottomSpace <> Value then + begin + FBottomSpace := Value; + UpdateVerticalScrollbar(True); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetButtonFillMode(const Value: TVTButtonFillMode); + +begin + if FButtonFillMode <> Value then + begin + FButtonFillMode := Value; + if not (csLoading in ComponentState) then + begin + PrepareBitmaps(True, False); + if HandleAllocated then + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetButtonStyle(const Value: TVTButtonStyle); + +begin + if FButtonStyle <> Value then + begin + FButtonStyle := Value; + if not (csLoading in ComponentState) then + begin + PrepareBitmaps(True, False); + if HandleAllocated then + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetCheckImageKind(Value: TCheckImageKind); + +begin + if FCheckImageKind <> Value then + begin + FCheckImageKind := Value; + FCheckImages := GetCheckImageListFor(Value); + if not Assigned(FCheckImages) then + FCheckImages := FCustomCheckImages; + if HandleAllocated and (FUpdateCount = 0) and not (csLoading in ComponentState) then + InvalidateRect(Handle, nil, False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetCheckState(Node: PVirtualNode; Value: TCheckState); + +begin + if (Node.CheckState <> Value) and not (vsDisabled in Node.States) and DoChecking(Node, Value) then + DoCheckClick(Node, Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetCheckType(Node: PVirtualNode; Value: TCheckType); + +begin + if (Node.CheckType <> Value) and not (toReadOnly in FOptions.FMiscOptions) then + begin + Node.CheckType := Value; + Node.CheckState := csUncheckedNormal; + // For check boxes with tri-state check box parents we have to initialize differently. + if (toAutoTriStateTracking in FOptions.FAutoOptions) and (Value in [ctCheckBox, ctTriStateCheckBox]) and + (Node.Parent <> FRoot) then + begin + if not (vsInitialized in Node.Parent.States) then + InitNode(Node.Parent); + if (Node.Parent.CheckType = ctTriStateCheckBox) and + (Node.Parent.CheckState in [csUncheckedNormal, csCheckedNormal]) then + CheckState[Node] := Node.Parent.CheckState; + end; + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetChildCount(Node: PVirtualNode; NewChildCount: Cardinal); + +// Changes a node's child structure to accomodate the new child count. This is used to add or delete +// child nodes to/from the end of the node's child list. To insert or delete a specific node a separate +// routine is used. + +var + Remaining: Cardinal; + Index: Cardinal; + Child: PVirtualNode; + Count: Integer; + NewHeight: Integer; + +begin + if not (toReadOnly in FOptions.FMiscOptions) then + begin + if Node = nil then + Node := FRoot; + + if NewChildCount = 0 then + DeleteChildren(Node) + else + begin + // If nothing changed then do nothing. + if NewChildCount <> Node.ChildCount then + begin + InterruptValidation; + NewHeight := 0; + + if NewChildCount > Node.ChildCount then + begin + Remaining := NewChildCount - Node.ChildCount; + Count := Remaining; + + // New nodes to add. + if Assigned(Node.LastChild) then + Index := Node.LastChild.Index + 1 + else + begin + Index := 0; + Include(Node.States, vsHasChildren); + end; + Node.States := Node.States - [vsAllChildrenHidden, vsHeightMeasured]; + + // New nodes are by default always visible, so we don't need to check the visibility. + while Remaining > 0 do + begin + Child := MakeNewNode; + Child.Index := Index; + Child.PrevSibling := Node.LastChild; + if Assigned(Node.LastChild) then + Node.LastChild.NextSibling := Child; + Child.Parent := Node; + Node.LastChild := Child; + if Node.FirstChild = nil then + Node.FirstChild := Child; + Dec(Remaining); + Inc(Index); + + // The actual node height will later be computed once it is clear + // whether this node has a variable node height or not. + Inc(NewHeight, Child.NodeHeight); + end; + + if vsExpanded in Node.States then + begin + AdjustTotalHeight(Node, NewHeight, True); + if FullyVisible[Node] then + Inc(Integer(FVisibleCount), Count); + end; + + AdjustTotalCount(Node, Count, True); + Node.ChildCount := NewChildCount; + if (FUpdateCount = 0) and (toAutoSort in FOptions.FAutoOptions) and (FHeader.FSortColumn > InvalidColumn) then + Sort(Node, FHeader.FSortColumn, FHeader.FSortDirection, True); + + InvalidateCache; + end + else + begin + // Nodes have to be deleted. + Remaining := Node.ChildCount - NewChildCount; + while Remaining > 0 do + begin + DeleteNode(Node.LastChild); + Dec(Remaining); + end; + end; + + if FUpdateCount = 0 then + begin + ValidateCache; + UpdateScrollBars(True); + Invalidate; + end; + + if Node = FRoot then + StructureChange(nil, crChildAdded) + else + StructureChange(Node, crChildAdded); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetClipboardFormats(const Value: TClipboardFormats); + +var + I: Integer; + +begin + // Add string by string instead doing an Assign or AddStrings because the list may return -1 for + // invalid entries which cause trouble for the standard implementation. + FClipboardFormats.Clear; + for I := 0 to Value.Count - 1 do + FClipboardFormats.Add(Value[I]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetColors(const Value: TVTColors); + +begin + FColors.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetCustomCheckImages(const Value: TCustomImageList); + +begin + if FCustomCheckImages <> Value then + begin + if Assigned(FCustomCheckImages) then + begin + FCustomCheckImages.UnRegisterChanges(FCustomCheckChangeLink); + FCustomCheckImages.RemoveFreeNotification(Self); + // Reset the internal check image list reference too, if necessary. + if FCheckImages = FCustomCheckImages then + FCheckImages := nil; + end; + FCustomCheckImages := Value; + if Assigned(FCustomCheckImages) then + begin + FCustomCheckImages.RegisterChanges(FCustomCheckChangeLink); + FCustomCheckImages.FreeNotification(Self); + end; + // Check if currently custom check images are active. + if FCheckImageKind = ckCustom then + FCheckImages := Value; + if not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetDefaultNodeHeight(Value: Cardinal); + +begin + if Value = 0 then + Value := 18; + if FDefaultNodeHeight <> Value then + begin + DoStateChange([tsNeedScale]); + Inc(Integer(FRoot.TotalHeight), Integer(Value) - Integer(FDefaultNodeHeight)); + Inc(SmallInt(FRoot.NodeHeight), Integer(Value) - Integer(FDefaultNodeHeight)); + FDefaultNodeHeight := Value; + InvalidateCache; + if (FUpdateCount = 0) and HandleAllocated and not (csLoading in ComponentState) then + begin + ValidateCache; + UpdateScrollBars(True); + ScrollIntoView(FFocusedNode, toCenterScrollIntoView in FOptions.SelectionOptions, True); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetDisabled(Node: PVirtualNode; Value: Boolean); + +begin + if Assigned(Node) and (Value xor (vsDisabled in Node.States)) then + begin + if Value then + Include(Node.States, vsDisabled) + else + Exclude(Node.States, vsDisabled); + + if FUpdateCount = 0 then + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetEmptyListMessage(const Value: UnicodeString); + +begin + if Value <> EmptyListMessage then + begin + FEmptyListMessage := Value; + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetExpanded(Node: PVirtualNode; Value: Boolean); + +begin + if Assigned(Node) and (Node <> FRoot) and (Value xor (vsExpanded in Node.States)) then + ToggleNode(Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetFocusedColumn(Value: TColumnIndex); + +begin + if (FFocusedColumn <> Value) and + DoFocusChanging(FFocusedNode, FFocusedNode, FFocusedColumn, Value) then + begin + CancelEditNode; + InvalidateColumn(FFocusedColumn); + InvalidateColumn(Value); + FFocusedColumn := Value; + if Assigned(FFocusedNode) and not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions) then + begin + if ScrollIntoView(FFocusedNode, toCenterScrollIntoView in FOptions.SelectionOptions, True) then + InvalidateNode(FFocusedNode); + end; + + if Assigned(FDropTargetNode) then + InvalidateNode(FDropTargetNode); + + DoFocusChange(FFocusedNode, FFocusedColumn); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetFocusedNode(Value: PVirtualNode); + +var + WasDifferent: Boolean; + +begin + WasDifferent := Value <> FFocusedNode; + DoFocusNode(Value, True); + // Do change event only if there was actually a change. + if WasDifferent and (FFocusedNode = Value) then + DoFocusChange(FFocusedNode, FFocusedColumn); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetFullyVisible(Node: PVirtualNode; Value: Boolean); + +// This method ensures that a node is visible and all its parent nodes are expanded and also visible +// if Value is True. Otherwise the visibility flag of the node is reset but the expand state +// of the parent nodes stays untouched. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter'); + + IsVisible[Node] := Value; + if Value then + begin + repeat + Node := Node.Parent; + if Node = FRoot then + Break; + if not (vsExpanded in Node.States) then + ToggleNode(Node); + if not (vsVisible in Node.States) then + IsVisible[Node] := True; + until False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetHasChildren(Node: PVirtualNode; Value: Boolean); + +begin + if Assigned(Node) and not (toReadOnly in FOptions.FMiscOptions) then + begin + if Value then + Include(Node.States, vsHasChildren) + else + begin + Exclude(Node.States, vsHasChildren); + DeleteChildren(Node); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetHeader(const Value: TVTHeader); + +begin + FHeader.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetFiltered(Node: PVirtualNode; Value: Boolean); + +// Sets the 'filtered' flag of the given node according to Value and updates all dependent states. + +var + NeedUpdate: Boolean; + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + // Initialize the node if necessary as this might change the filtered state. + if not (vsInitialized in Node.States) then + InitNode(Node); + + if Value <> (vsFiltered in Node.States) then + begin + InterruptValidation; + NeedUpdate := False; + if Value then + begin + Include(Node.States, vsFiltered); + if not (toShowFilteredNodes in FOptions.FPaintOptions) then + begin + AdjustTotalHeight(Node, -Integer(NodeHeight[Node]), True); + if FullyVisible[Node] then + begin + Dec(FVisibleCount); + NeedUpdate := True; + end; + end; + + if FUpdateCount = 0 then + DetermineHiddenChildrenFlag(Node.Parent) + else + Include(FStates, tsUpdateHiddenChildrenNeeded); + end + else + begin + Exclude(Node.States, vsFiltered); + if not (toShowFilteredNodes in FOptions.FPaintOptions) then + begin + AdjustTotalHeight(Node, Integer(NodeHeight[Node]), True); + if FullyVisible[Node] then + begin + Inc(FVisibleCount); + NeedUpdate := True; + end; + end; + + if vsVisible in Node.States then + // Update the hidden children flag of the parent. + // Since this node is now visible we simply have to remove the flag. + Exclude(Node.Parent.States, vsAllChildrenHidden); + end; + + InvalidateCache; + if NeedUpdate and (FUpdateCount = 0) then + begin + ValidateCache; + UpdateScrollBars(True); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- +procedure TBaseVirtualTree.SetImages(const Value: TCustomImageList); + +begin + if FImages <> Value then + begin + if Assigned(FImages) then + begin + FImages.UnRegisterChanges(FImageChangeLink); + FImages.RemoveFreeNotification(Self); + end; + FImages := Value; + if Assigned(FImages) then + begin + FImages.RegisterChanges(FImageChangeLink); + FImages.FreeNotification(Self); + end; + if not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetIndent(Value: Cardinal); + +begin + if FIndent <> Value then + begin + FIndent := Value; + if not (csLoading in ComponentState) and (FUpdateCount = 0) and HandleAllocated then + begin + UpdateScrollBars(True); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetLineMode(const Value: TVTLineMode); + +begin + if FLineMode <> Value then + begin + FLineMode := Value; + if HandleAllocated and not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetLineStyle(const Value: TVTLineStyle); + +begin + if FLineStyle <> Value then + begin + FLineStyle := Value; + if not (csLoading in ComponentState) then + begin + PrepareBitmaps(False, True); + if HandleAllocated then + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetMargin(Value: Integer); + +begin + if FMargin <> Value then + begin + FMargin := Value; + if HandleAllocated and not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetMultiline(Node: PVirtualNode; const Value: Boolean); + +begin + if Assigned(Node) and (Node <> FRoot) then + if Value <> (vsMultiline in Node.States) then + begin + if Value then + Include(Node.States, vsMultiline) + else + Exclude(Node.States, vsMultiline); + + if FUpdateCount = 0 then + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetNodeAlignment(const Value: TVTNodeAlignment); + +begin + if FNodeAlignment <> Value then + begin + FNodeAlignment := Value; + if HandleAllocated and not (csReading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetNodeDataSize(Value: Integer); + +var + LastRootCount: Cardinal; + +begin + if Value < -1 then + Value := -1; + if FNodeDataSize <> Value then + begin + FNodeDataSize := Value; + if not (csLoading in ComponentState) and not (csDesigning in ComponentState) then + begin + LastRootCount := FRoot.ChildCount; + Clear; + SetRootNodeCount(LastRootCount); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetNodeHeight(Node: PVirtualNode; Value: Cardinal); + +var + Difference: Integer; + +begin + if Assigned(Node) and (Node <> FRoot) and (Node.NodeHeight <> Value) and not (toReadOnly in FOptions.FMiscOptions) then + begin + Difference := Integer(Value) - Integer(Node.NodeHeight); + Node.NodeHeight := Value; + + // If the node is effectively filtered out, nothing else has to be done, as it is not visible anyway. + if not IsEffectivelyFiltered[Node] then + begin + AdjustTotalHeight(Node, Difference, True); + + // If an edit operation is currently active then update the editors boundaries as well. + UpdateEditBounds; + + // Stay away from touching the node cache while it is being validated. + if not (tsValidating in FStates) and FullyVisible[Node] and not IsEffectivelyFiltered[Node] then + begin + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + InvalidateToBottom(Node); + UpdateScrollBars(True); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetNodeParent(Node: PVirtualNode; const Value: PVirtualNode); + +begin + if Assigned(Node) and Assigned(Value) and (Node.Parent <> Value) then + MoveTo(Node, Value, amAddChildLast, False); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetOffsetX(const Value: Integer); + +begin + DoSetOffsetXY(Point(Value, FOffsetY), DefaultScrollUpdateFlags); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetOffsetXY(const Value: TPoint); + +begin + DoSetOffsetXY(Value, DefaultScrollUpdateFlags); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetOffsetY(const Value: Integer); + +begin + DoSetOffsetXY(Point(FOffsetX, Value), DefaultScrollUpdateFlags); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetOptions(const Value: TCustomVirtualTreeOptions); + +begin + FOptions.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetRootNodeCount(Value: Cardinal); + +begin + // Don't set the root node count until all other properties (in particular the OnInitNode event) have been set. + if csLoading in ComponentState then + begin + FRoot.ChildCount := Value; + DoStateChange([tsNeedRootCountUpdate]); + end + else + if FRoot.ChildCount <> Value then + begin + BeginUpdate; + InterruptValidation; + SetChildCount(FRoot, Value); + EndUpdate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetScrollBarOptions(Value: TScrollBarOptions); + +begin + FScrollBarOptions.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetSearchOption(const Value: TVTIncrementalSearch); + +begin + if FIncrementalSearch <> Value then + begin + FIncrementalSearch := Value; + if FIncrementalSearch = isNone then + begin + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetSelected(Node: PVirtualNode; Value: Boolean); + +begin + if not FSelectionLocked and Assigned(Node) and (Node <> FRoot) and (Value xor (vsSelected in Node.States)) then + begin + if Value then + begin + if FSelectionCount = 0 then + FRangeAnchor := Node + else + if not (toMultiSelect in FOptions.FSelectionOptions) then + ClearSelection; + + AddToSelection(Node); + + // Make sure there is a valid column selected (if there are columns at all). + if ((FFocusedColumn < 0) or not (coVisible in FHeader.Columns[FFocusedColumn].Options)) and + (FHeader.MainColumn > NoColumn) then + if ([coVisible, coAllowFocus] * FHeader.Columns[FHeader.MainColumn].Options = [coVisible, coAllowFocus]) then + FFocusedColumn := FHeader.MainColumn + else + FFocusedColumn := FHeader.Columns.GetFirstVisibleColumn(True); + if FRangeAnchor = nil then + FRangeAnchor := Node; + end + else + begin + RemoveFromSelection(Node); + if FSelectionCount = 0 then + ResetRangeAnchor; + end; + if FullyVisible[Node] and not IsEffectivelyFiltered[Node] then + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetSelectionCurveRadius(const Value: Cardinal); + +begin + if FSelectionCurveRadius <> Value then + begin + FSelectionCurveRadius := Value; + if HandleAllocated and not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetStateImages(const Value: TCustomImageList); + +begin + if FStateImages <> Value then + begin + if Assigned(FStateImages) then + begin + FStateImages.UnRegisterChanges(FStateChangeLink); + FStateImages.RemoveFreeNotification(Self); + end; + FStateImages := Value; + if Assigned(FStateImages) then + begin + FStateImages.RegisterChanges(FStateChangeLink); + FStateImages.FreeNotification(Self); + end; + if HandleAllocated and not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetTextMargin(Value: Integer); + +begin + if FTextMargin <> Value then + begin + FTextMargin := Value; + if not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetTopNode(Node: PVirtualNode); + +var + R: TRect; + Run: PVirtualNode; + +begin + if Assigned(Node) then + begin + // make sure all parents of the node are expanded + Run := Node.Parent; + while Run <> FRoot do + begin + if not (vsExpanded in Run.States) then + ToggleNode(Run); + Run := Run.Parent; + end; + R := GetDisplayRect(Node, FHeader.MainColumn, True); + SetOffsetY(FOffsetY - R.Top); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetUpdateState(Updating: Boolean); + +begin + // The check for visibility is necessary otherwise the tree is automatically shown when + // updating is allowed. As this happens internally the VCL does not get notified and + // still assumes the control is hidden. This results in weird "cannot focus invisible control" errors. + if Visible and HandleAllocated and (FUpdateCount = 0) then + SendMessage(Handle, WM_SETREDRAW, Ord(not Updating), 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetVerticalAlignment(Node: PVirtualNode; Value: Byte); + +begin + if Value > 100 then + Value := 100; + if Node.Align <> Value then + begin + Node.Align := Value; + if FullyVisible[Node] and not IsEffectivelyFiltered[Node] then + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetVisible(Node: PVirtualNode; Value: Boolean); + +// Sets the visibility style of the given node according to Value. + +var + NeedUpdate: Boolean; + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + if Value <> (vsVisible in Node.States) then + begin + InterruptValidation; + NeedUpdate := False; + if Value then + begin + Include(Node.States, vsVisible); + if vsExpanded in Node.Parent.States then + AdjustTotalHeight(Node.Parent, Node.TotalHeight, True); + if VisiblePath[Node] then + begin + Inc(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + NeedUpdate := True; + end; + + // Update the hidden children flag of the parent. + // Since this node is now visible we simply have to remove the flag. + if not IsEffectivelyFiltered[Node] then + Exclude(Node.Parent.States, vsAllChildrenHidden); + end + else + begin + if vsExpanded in Node.Parent.States then + AdjustTotalHeight(Node.Parent, -Integer(Node.TotalHeight), True); + if VisiblePath[Node] then + begin + Dec(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + NeedUpdate := True; + end; + Exclude(Node.States, vsVisible); + + if FUpdateCount = 0 then + DetermineHiddenChildrenFlag(Node.Parent) + else + Include(FStates, tsUpdateHiddenChildrenNeeded) + end; + + InvalidateCache; + if NeedUpdate and (FUpdateCount = 0) then + begin + ValidateCache; + UpdateScrollBars(True); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetVisiblePath(Node: PVirtualNode; Value: Boolean); + +// If Value is True then all parent nodes of Node are expanded. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + if Value then + begin + repeat + Node := Node.Parent; + if Node = FRoot then + Break; + if not (vsExpanded in Node.States) then + ToggleNode(Node); + until False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.StaticBackground(Source: TBitmap; Target: TCanvas; OffsetPosition: TPoint; R: TRect); + +// Draws the given source graphic so that it stays static in the given rectangle which is relative to the target bitmap. +// The graphic is aligned so that it always starts at the upper left corner of the target canvas. +// Offset gives the position of the target window as a possible superordinated surface. + +const + DST = $00AA0029; // Ternary Raster Operation - Destination unchanged + +var + PicRect: TRect; + AreaRect: TRect; + DrawRect: TRect; + +begin + // clear background + Target.Brush.Color := Color; + Target.FillRect(R); + + // Picture rect in relation to client viewscreen. + PicRect := Rect(FBackgroundOffsetX, FBackgroundOffsetY, FBackgroundOffsetX + Source.Width, FBackgroundOffsetY + Source.Height); + + // Area to be draw in relation to client viewscreen. + AreaRect := Rect(OffsetPosition.X + R.Left, OffsetPosition.Y + R.Top, OffsetPosition.X + R.Right, OffsetPosition.Y + R.Bottom); + + // If picture falls in AreaRect, return intersection (DrawRect). + if IntersectRect(DrawRect, PicRect, AreaRect) then + begin + // Draw portion of image which falls in canvas area. + if Source.Transparent then + begin + // Leave transparent area as destination unchanged (DST), copy non-transparent areas to canvas (SRCCOPY). + MaskBlt(Target.Handle, DrawRect.Left - OffsetPosition.X, DrawRect.Top - OffsetPosition.Y, (DrawRect.Right - OffsetPosition.X) - (DrawRect.Left - OffsetPosition.X), + (DrawRect.Bottom - OffsetPosition.Y) - (DrawRect.Top - OffsetPosition.Y), Source.Canvas.Handle, DrawRect.Left - PicRect.Left, DrawRect.Top - PicRect.Top, + Source.MaskHandle, DrawRect.Left - PicRect.Left, DrawRect.Top - PicRect.Top, MakeROP4(DST, SRCCOPY)); + end + else + begin + // copy image to destination + BitBlt(Target.Handle, DrawRect.Left - OffsetPosition.X, DrawRect.Top - OffsetPosition.Y, (DrawRect.Right - OffsetPosition.X) - (DrawRect.Left - OffsetPosition.X), + (DrawRect.Bottom - OffsetPosition.Y) - (DrawRect.Top - OffsetPosition.Y) + R.Top, Source.Canvas.Handle, DrawRect.Left - PicRect.Left, DrawRect.Top - PicRect.Top, + SRCCOPY); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.StopTimer(ID: Integer); + +begin + if HandleAllocated then + KillTimer(Handle, ID); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.TileBackground(Source: TBitmap; Target: TCanvas; Offset: TPoint; R: TRect); + +// Draws the given source graphic so that it tiles into the given rectangle which is relative to the target bitmap. +// The graphic is aligned so that it always starts at the upper left corner of the target canvas. +// Offset gives the position of the target window in an possible superordinated surface. + +var + SourceX, + SourceY, + TargetX, + + DeltaY: Integer; + +begin + with Target do + begin + SourceY := (R.Top + Offset.Y + FBackgroundOffsetY) mod Source.Height; + // Always wrap the source coordinates into positive range. + if SourceY < 0 then + SourceY := Source.Height + SourceY; + + // Tile image vertically until target rect is filled. + while R.Top < R.Bottom do + begin + SourceX := (R.Left + Offset.X + FBackgroundOffsetX) mod Source.Width; + // always wrap the source coordinates into positive range + if SourceX < 0 then + SourceX := Source.Width + SourceX; + + TargetX := R.Left; + // height of strip to draw + DeltaY := Min(R.Bottom - R.Top, Source.Height - SourceY); + + // tile the image horizontally + while TargetX < R.Right do + begin + BitBlt(Handle, TargetX, R.Top, Min(R.Right - TargetX, Source.Width - SourceX), DeltaY, + Source.Canvas.Handle, SourceX, SourceY, SRCCOPY); + Inc(TargetX, Source.Width - SourceX); + SourceX := 0; + end; + Inc(R.Top, Source.Height - SourceY); + SourceY := 0; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ToggleCallback(Step, StepSize: Integer; Data: Pointer): Boolean; + +var + Column: TColumnIndex; + Run: TRect; + SecondaryStepSize: Integer; + + //--------------- local functions ------------------------------------------- + + procedure EraseLine; + + var + LocalBrush: HBRUSH; + + begin + with TToggleAnimationData(Data^), FHeader.FColumns do + begin + // Iterate through all columns and erase background in their local color. + // LocalBrush is a brush in the color of the particular column. + Column := GetFirstVisibleColumn; + while (Column > InvalidColumn) and (Run.Left < ClientWidth) do + begin + GetColumnBounds(Column, Run.Left, Run.Right); + if coParentColor in Items[Column].FOptions then + FillRect(DC, Run, Brush) + else + begin + LocalBrush := CreateSolidBrush(ColorToRGB(Items[Column].Color)); + FillRect(DC, Run, LocalBrush); + DeleteObject(LocalBrush); + end; + Column := GetNextVisibleColumn(Column); + end; + end; + end; + + //--------------------------------------------------------------------------- + + procedure DoScrollUp(DC: HDC; Brush: HBRUSH; Area: TRect; Steps: Integer); + + begin + ScrollDC(DC, 0, -Steps, Area, Area, 0, nil); + + if Step = 0 then + if not FHeader.UseColumns then + FillRect(DC, Rect(Area.Left, Area.Bottom - Steps - 1, Area.Right, Area.Bottom), Brush) + else + begin + Run := Rect(Area.Left, Area.Bottom - Steps - 1, Area.Right, Area.Bottom); + EraseLine; + end; + end; + + //--------------------------------------------------------------------------- + + procedure DoScrollDown(DC: HDC; Brush: HBRUSH; Area: TRect; Steps: Integer); + + begin + ScrollDC(DC, 0, Steps, Area, Area, 0, nil); + + if Step = 0 then + if not FHeader.UseColumns then + FillRect(DC, Rect(Area.Left, Area.Top, Area.Right, Area.Top + Steps + 1), Brush) + else + begin + Run := Rect(Area.Left, Area.Top, Area.Right, Area.Top + Steps + 1); + EraseLine; + end; + end; + + //--------------- end local functions --------------------------------------- + +begin + Result := True; + if StepSize > 0 then + begin + SecondaryStepSize := 0; + with TToggleAnimationData(Data^) do + begin + if Mode1 <> tamNoScroll then + begin + if Mode1 = tamScrollUp then + DoScrollUp(DC, Brush, R1, StepSize) + else + DoScrollDown(DC, Brush, R1, StepSize); + + if (Mode2 <> tamNoScroll) and (ScaleFactor > 0) then + begin + // As this routine is able to scroll two independent areas at once, the missing StepSize is + // computed in that case. To ensure the maximal accuracy the rounding error is accumulated. + SecondaryStepSize := Round((StepSize + MissedSteps) * ScaleFactor); + MissedSteps := MissedSteps + StepSize * ScaleFactor - SecondaryStepSize; + end; + end + else + SecondaryStepSize := StepSize; + + if Mode2 <> tamNoScroll then + if Mode2 = tamScrollUp then + DoScrollUp(DC, Brush, R2, SecondaryStepSize) + else + DoScrollDown(DC, Brush, R2, SecondaryStepSize); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMColorChange(var Message: TMessage); + +begin + if not (csLoading in ComponentState) then + begin + PrepareBitmaps(True, False); + if HandleAllocated then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMCtl3DChanged(var Message: TMessage); + +begin + inherited; + if FBorderStyle = bsSingle then + RecreateWnd; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMBiDiModeChanged(var Message: TMessage); + +begin + inherited; + + if UseRightToLeftAlignment then + FEffectiveOffsetX := Integer(FRangeX) - ClientWidth + FOffsetX + else + FEffectiveOffsetX := -FOffsetX; + if FEffectiveOffsetX < 0 then + FEffectiveOffsetX := 0; + + if toAutoBidiColumnOrdering in FOptions.FAutoOptions then + FHeader.FColumns.ReorderColumns(UseRightToLeftAlignment); + FHeader.Invalidate(nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMDenySubclassing(var Message: TMessage); + +// If a Windows XP Theme Manager component is used in the application it will try to subclass all controls which do not +// explicitly deny this. Virtual Treeview knows how to handle XP themes so it does not need subclassing. + +begin + Message.Result := 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMDrag(var Message: TCMDrag); + +var + S: TObject; + ShiftState: Integer; + P: TPoint; + Formats: TFormatArray; + Effect: Integer; + +begin + with Message, DragRec^ do + begin + S := Source; + Formats := nil; + + // Let the ancestor handle dock operations. + if S is TDragDockObject then + inherited + else + begin + // We need an extra check for the control drag object as there might be other objects not derived from + // this class (e.g. TActionDragObject). + if not (tsUserDragObject in FStates) and (S is TBaseDragControlObject) then + S := (S as TBaseDragControlObject).Control; + case DragMessage of + dmDragEnter, dmDragLeave, dmDragMove: + begin + if DragMessage = dmDragEnter then + DoStateChange([tsVCLDragging]); + if DragMessage = dmDragLeave then + DoStateChange([tsVCLDragFinished], [tsVCLDragging]); + + if DragMessage = dmDragMove then + with ScreenToClient(Pos) do + DoAutoScroll(X, Y); + + ShiftState := 0; + // Alt key will be queried by the KeysToShiftState function in DragOver. + if GetKeyState(VK_SHIFT) < 0 then + ShiftState := ShiftState or MK_SHIFT; + if GetKeyState(VK_CONTROL) < 0 then + ShiftState := ShiftState or MK_CONTROL; + + // Allowed drop effects are simulated for VCL dd. + Effect := DROPEFFECT_MOVE or DROPEFFECT_COPY; + DragOver(S, ShiftState, TDragState(DragMessage), Pos, Effect); + FLastVCLDragTarget := FDropTargetNode; + FVCLDragEffect := Effect; + if (DragMessage = dmDragLeave) and Assigned(FDropTargetNode) then + begin + InvalidateNode(FDropTargetNode); + FDropTargetNode := nil; + end; + Result := LRESULT(Effect); + end; + dmDragDrop: + begin + ShiftState := 0; + // Alt key will be queried by the KeysToShiftState function in DragOver + if GetKeyState(VK_SHIFT) < 0 then + ShiftState := ShiftState or MK_SHIFT; + if GetKeyState(VK_CONTROL) < 0 then + ShiftState := ShiftState or MK_CONTROL; + + // allowed drop effects are simulated for VCL dd, + // replace target node with cached node from other VCL dd messages + if Assigned(FDropTargetNode) then + InvalidateNode(FDropTargetNode); + FDropTargetNode := FLastVCLDragTarget; + P := Point(Pos.X, Pos.Y); + P := ScreenToClient(P); + try + DoDragDrop(S, nil, Formats, KeysToShiftState(ShiftState), P, FVCLDragEffect, FLastDropMode); + finally + if Assigned(FDropTargetNode) then + begin + InvalidateNode(FDropTargetNode); + FDropTargetNode := nil; + end; + end; + end; + dmFindTarget: + begin + Result := LRESULT(ControlAtPos(ScreenToClient(Pos), False)); + if Result = 0 then + Result := LRESULT(Self); + + // This is a reliable place to check whether VCL drag has + // really begun. + if tsVCLDragPending in FStates then + DoStateChange([tsVCLDragging], [tsVCLDragPending, tsEditPending, tsClearPending]); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMEnabledChanged(var Message: TMessage); + +begin + inherited; + + // Need to invalidate the non-client area as well, since the header must be redrawn too. + if csDesigning in ComponentState then + RedrawWindow(Handle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_NOERASE or RDW_NOCHILDREN); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMFontChanged(var Message: TMessage); + +var + HeaderMessage: TMessage; + +begin + inherited; + + if not (csLoading in ComponentState) then + begin + PrepareBitmaps(True, False); + if HandleAllocated then + Invalidate; + end; + + HeaderMessage.Msg := CM_PARENTFONTCHANGED; + HeaderMessage.WParam := 0; + HeaderMessage.LParam := 0; + HeaderMessage.Result := 0; + FHeader.HandleMessage(HeaderMessage); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMHintShow(var Message: TCMHintShow); + +// Determines hint message (tooltip) and out-of-hint rect. +// Note: A special handling is needed here because we cannot pass wide strings back to the caller. +// I had to introduce the hint data record anyway so we can use this to pass the hint string. +// We still need to set a dummy hint string in the message to make the VCL showing the hint window. + +var + NodeRect: TRect; + SpanColumn, + Dummy, + ColLeft, + ColRight: Integer; + HitInfo: THitInfo; + ShowOwnHint: Boolean; + IsFocusedOrEditing: Boolean; + ParentForm: TCustomForm; + BottomRightCellContentMargin: TPoint; + +begin + with Message do + begin + Result := 1; + + if PtInRect(FLastHintRect, HintInfo.CursorPos) then + Exit; + + // Determine node for which to show hint/tooltip. + with HintInfo^ do + GetHitTestInfoAt(CursorPos.X, CursorPos.Y, True, HitInfo); + + // Make sure a hint is only shown if the tree or at least its parent form is active. + // Active editing is ok too as long as we don't want the hint for the current edit node. + if IsEditing then + IsFocusedOrEditing := HitInfo.HitNode <> FFocusedNode + else + begin + IsFocusedOrEditing := Focused; + ParentForm := GetParentForm(Self); + if Assigned(ParentForm) then + IsFocusedOrEditing := ParentForm.Focused or Application.Active; + end; + + if (GetCapture = 0) and ShowHint and not (Dragging or IsMouseSelecting) and ([tsScrolling] * FStates = []) and + (FHeader.States = []) and IsFocusedOrEditing then + begin + with HintInfo^ do + begin + Result := 0; + ShowOwnHint := False; + // Assign a dummy string otherwise the VCL will not show the hint window. + HintStr := ' '; + + // First check whether there is a header hint to show. + if FHeader.UseColumns and (hoShowHint in FHeader.FOptions) and FHeader.InHeader(CursorPos) then + begin + CursorRect := FHeaderRect; + // Convert the cursor rectangle into real client coordinates. + OffsetRect(CursorRect, 0, -Integer(FHeader.FHeight)); + HitInfo.HitColumn := FHeader.FColumns.GetColumnAndBounds(CursorPos, CursorRect.Left, CursorRect.Right); + // align the vertical hint position on the bottom bound of the header, but + // avoid overlapping of mouse cursor and hint + HintPos.Y := Max(HintPos.Y, ClientToScreen(Point(0, CursorRect.Bottom)).Y); + // Note: the test for the left mouse button in ControlState might cause problems whenever the VCL does not + // realize when the button is released. This, for instance, happens when doing OLE drag'n drop and + // cancel this with ESC. + if (HitInfo.HitColumn > -1) and not (csLButtonDown in ControlState) then + begin + FHintData.DefaultHint := FHeader.FColumns[HitInfo.HitColumn].FHint; + if FHintData.DefaultHint <> '' then + ShowOwnHint := True + else + Result := 1; + end + else + Result := 1; + end + else + begin + // Default mode is handled as would the tree be a usual VCL control (no own hint window necessary). + if FHintMode = hmDefault then + HintStr := GetShortHint(Hint) + else + begin + if Assigned(HitInfo.HitNode) and (HitInfo.HitColumn > InvalidColumn) then + begin + // A draw tree should only display a hint when at least its OnGetHintSize + // event handler is assigned. + if Self is TCustomVirtualDrawTree then + begin + FHintData.HintRect := Rect(0, 0, 0, 0); + with Self as TCustomVirtualDrawTree do + DoGetHintSize(HitInfo.HitNode, HitInfo.HitColumn, FHintData.HintRect); + ShowOwnHint := not IsRectEmpty(FHintData.HintRect); + end + else + // For string trees a decision about showing the hint or not is based + // on the hint string (if it is empty then no hint is shown). + ShowOwnHint := True; + + if ShowOwnHint then + begin + if HitInfo.HitColumn > NoColumn then + begin + FHeader.FColumns.GetColumnBounds(HitInfo.HitColumn, ColLeft, ColRight); + // The right column border might be extended if column spanning is enabled. + if toAutoSpanColumns in FOptions.FAutoOptions then + begin + SpanColumn := HitInfo.HitColumn; + repeat + Dummy := FHeader.FColumns.GetNextVisibleColumn(SpanColumn); + if (Dummy = InvalidColumn) or not ColumnIsEmpty(HitInfo.HitNode, Dummy) then + Break; + SpanColumn := Dummy; + until False; + if SpanColumn <> HitInfo.HitColumn then + FHeader.FColumns.GetColumnBounds(SpanColumn, Dummy, ColRight); + end; + end + else + begin + ColLeft := 0; + ColRight := ClientWidth; + end; + + FHintData.DefaultHint := ''; + if FHintMode <> hmTooltip then + begin + // Node specific hint text. + CursorRect := GetDisplayRect(HitInfo.HitNode, HitInfo.HitColumn, False); + CursorRect.Left := ColLeft; + CursorRect.Right := ColRight; + // Align the vertical hint position on the bottom bound of the node, but + // avoid overlapping of mouse cursor and hint. + HintPos.Y := Max(HintPos.Y, ClientToScreen(CursorRect.BottomRight).Y) + 2; + end + else + begin + // Tool tip to show. This means the full caption of the node must be displayed. + if vsMultiline in HitInfo.HitNode.States then + begin + if hiOnItemLabel in HitInfo.HitPositions then + begin + ShowOwnHint := True; + NodeRect := GetDisplayRect(HitInfo.HitNode, HitInfo.HitColumn, True, False); + end; + end + else + begin + NodeRect := GetDisplayRect(HitInfo.HitNode, HitInfo.HitColumn, True, True, True); + BottomRightCellContentMargin := DoGetCellContentMargin(HitInfo.HitNode, HitInfo.HitColumn, ccmtBottomRightOnly); + + ShowOwnHint := (HitInfo.HitColumn > InvalidColumn) and PtInRect(NodeRect, CursorPos) and + (CursorPos.X <= ColRight) and (CursorPos.X >= ColLeft) and + ( + // Show hint also if the node text is partially out of the client area. + // "ColRight - 1", since the right column border is not part of this cell. + ( (NodeRect.Right + BottomRightCellContentMargin.X) > Min(ColRight - 1, ClientWidth) ) or + (NodeRect.Left < Max(ColLeft, 0)) or + ( (NodeRect.Bottom + BottomRightCellContentMargin.Y) > ClientHeight ) or + (NodeRect.Top < 0) + ); + end; + + if ShowOwnHint then + begin + // Node specific hint text given will be retrieved when needed. + FHintData.DefaultHint := ''; + HintPos := ClientToScreen(Point(NodeRect.Left, NodeRect.Top)); + CursorRect := NodeRect; + end + else + // nothing to show + Result := 1; + end; + end + else + Result := 1; // Avoid hint if this is a draw tree returning an empty hint rectangle. + end + else + begin + // No node so fall back to control's hint (if indicated) or show nothing. + if FHintMode = hmHintAndDefault then + begin + FHintData.DefaultHint := GetShortHint(Hint); + if Length(FHintData.DefaultHint) = 0 then + Result := 1 + else + ShowOwnHint := True; + end + else + Result := 1; + end; + end; + end; + + // Set our own hint window class and prepare structure to be passed to the hint window. + if ShowOwnHint and (Result = 0) then + begin + HintWindowClass := GetHintWindowClass; + + FHintData.Tree := Self; + FHintData.Column := HitInfo.HitColumn; + FHintData.Node := HitInfo.HitNode; + FLastHintRect := CursorRect; + HintData := @FHintData; + end + else + FLastHintRect := Rect(0, 0, 0, 0); + end; + + // Remind that a hint is about to show. + if Result = 0 then + DoStateChange([tsHint]) + else + DoStateChange([], [tsHint]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMHintShowPause(var Message: TCMHintShowPause); + +// Tells the application that the tree (and only the tree) does not want a delayed tool tip. +// Normal hints / header hints use the default delay (except for the first time). + +var + P: TPoint; + +begin + // A little workaround is needed here to make the application class using the correct hint window class. + // Once the application gets ShowHint set to true (which is the case when we want to show hints in the tree) then + // an internal hint window will be created which is not our own class (because we don't set an application wide + // hint window class but only one for the tree). Unfortunately, this default hint window class will prevent + // hints for the non-client area to show up (e.g. for the header) by calling CancelHint whenever certain messages + // arrive. By setting the hint show pause to 0 if our hint class was not used recently we make sure + // that the hint timer (in Forms.pas) is not used and our class is created immediately. + if FHintWindowDestroyed then + begin + GetCursorPos(P); + // Check if the mouse is in the header or tool tips are enabled, which must be shown without delay anyway. + if FHeader.UseColumns and (hoShowHint in FHeader.FOptions) and FHeader.InHeader(ScreenToClient(P)) or + (FHintMode = hmToolTip) then + Message.Pause^ := 0 + end + else + if FHintMode = hmToolTip then + Message.Pause^ := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMMouseLeave(var Message: TMessage); + +var + LeaveStates: TVirtualTreeStates; + +begin + // Reset the last used hint rectangle in case the mouse enters the window within the bounds + if Assigned(FHintData.Tree) then + FHintData.Tree.FLastHintRect := Rect(0, 0, 0, 0); + + LeaveStates := [tsHint]; + if [tsWheelPanning, tsWheelScrolling] * FStates = [] then + begin + StopTimer(ScrollTimer); + LeaveStates := LeaveStates + [tsScrollPending, tsScrolling]; + end; + DoStateChange([], LeaveStates); + if Assigned(FCurrentHotNode) then + begin + DoHotChange(FCurrentHotNode, nil); + if (toHotTrack in FOptions.PaintOptions) or (toCheckSupport in FOptions.FMiscOptions) then + InvalidateNode(FCurrentHotNode); + FCurrentHotNode := nil; + end; + + if Assigned(Header) then + begin + Header.FColumns.FDownIndex := NoColumn; + Header.FColumns.FHoverIndex := NoColumn; + Header.FColumns.FCheckBoxHit := False; + end; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMMouseWheel(var Message: TCMMouseWheel); + +var + ScrollAmount: Integer; + ScrollLines: DWORD; + RTLFactor: Integer; + WheelFactor: Double; + +begin + StopWheelPanning; + + inherited; + + if Message.Result = 0 then + begin + with Message do + begin + Result := 1; + WheelFactor := WheelDelta / WHEEL_DELTA; + if (FRangeY > Cardinal(ClientHeight)) and (not (ssShift in ShiftState)) then + begin + // Scroll vertically if there's something to scroll... + if ssCtrl in ShiftState then + ScrollAmount := Trunc(WheelFactor * ClientHeight) + else + begin + SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @ScrollLines, 0); + if ScrollLines = WHEEL_PAGESCROLL then + ScrollAmount := Trunc(WheelFactor * ClientHeight) + else + ScrollAmount := Trunc(WheelFactor * ScrollLines * FDefaultNodeHeight); + end; + SetOffsetY(FOffsetY + ScrollAmount); + end + else + begin + // ...else scroll horizontally if there's something to scroll. + if UseRightToLeftAlignment then + RTLFactor := -1 + else + RTLFactor := 1; + + if ssCtrl in ShiftState then + ScrollAmount := Trunc(WheelFactor * (ClientWidth - FHeader.Columns.GetVisibleFixedWidth)) + else + begin + SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @ScrollLines, 0); + ScrollAmount := Trunc(WheelFactor * ScrollLines * FHeader.Columns.GetScrollWidth); + end; + SetOffsetX(FOffsetX + RTLFactor * ScrollAmount); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CMSysColorChange(var Message: TMessage); + +begin + inherited; + + ConvertImageList(LightCheckImages, 'VT_CHECK_LIGHT'); + ConvertImageList(DarkCheckImages, 'VT_CHECK_DARK'); + ConvertImageList(LightTickImages, 'VT_TICK_LIGHT'); + ConvertImageList(DarkTickImages, 'VT_TICK_DARK'); + ConvertImageList(FlatImages, 'VT_FLAT'); + ConvertImageList(UtilityImages, 'VT_UTILITIES'); + // XP images do not need to be converted. + // System check images do not need to be converted. + Message.Msg := WM_SYSCOLORCHANGE; + DefaultHandler(Message); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.TVMGetItem(var Message: TMessage); + +// Screen reader support function. The method returns information about a particular node. + +const + StateMask = TVIS_STATEIMAGEMASK or TVIS_OVERLAYMASK or TVIS_EXPANDED or TVIS_DROPHILITED or TVIS_CUT or + TVIS_SELECTED or TVIS_FOCUSED; + +var + Item: PTVItemEx; + Node: PVirtualNode; + Ghosted: Boolean; + ImageIndex: Integer; + R: TRect; + Text: UnicodeString; + {$ifndef UNICODE} + ANSIText: ANSIString; + {$endif} + +begin + // We can only return valid data if a nodes reference is given. + Item := Pointer(Message.LParam); + Message.Result := Ord(((Item.mask and TVIF_HANDLE) <> 0) and Assigned(Item.hItem)); + if Message.Result = 1 then + begin + Node := Pointer(Item.hItem); + // Child count requested? + if (Item.mask and TVIF_CHILDREN) <> 0 then + Item.cChildren := Node.ChildCount; + // Index for normal image requested? + if (Item.mask and TVIF_IMAGE) <> 0 then + begin + Item.iImage := -1; + DoGetImageIndex(Node, ikNormal, -1, Ghosted, Item.iImage); + end; + // Index for selected image requested? + if (Item.mask and TVIF_SELECTEDIMAGE) <> 0 then + begin + Item.iSelectedImage := -1; + DoGetImageIndex(Node, ikSelected, -1, Ghosted, Item.iSelectedImage); + end; + // State info requested? + if (Item.mask and TVIF_STATE) <> 0 then + begin + // Everything, which is possible is returned. + Item.stateMask := StateMask; + Item.state := 0; + if Node = FFocusedNode then + Item.state := Item.state or TVIS_FOCUSED; + if vsSelected in Node.States then + Item.state := Item.state or TVIS_SELECTED; + if vsCutOrCopy in Node.States then + Item.state := Item.state or TVIS_CUT; + if Node = FDropTargetNode then + Item.state := Item.state or TVIS_DROPHILITED; + if vsExpanded in Node.States then + Item.state := Item.state or TVIS_EXPANDED; + + // Construct state image and overlay image indices. They are one based, btw. + // and zero means there is no image. + ImageIndex := -1; + DoGetImageIndex(Node, ikState, -1, Ghosted, ImageIndex); + Item.state := Item.state or Byte(IndexToStateImageMask(ImageIndex + 1)); + ImageIndex := -1; + DoGetImageIndex(Node, ikOverlay, -1, Ghosted, ImageIndex); + Item.state := Item.state or Byte(IndexToOverlayMask(ImageIndex + 1)); + end; + // Node caption requested? + if (Item.mask and TVIF_TEXT) <> 0 then + begin + GetTextInfo(Node, -1, Font, R, Text); + + {$ifdef UNICODE} + StrLCopy(Item.pszText, PWideChar(Text), Item.cchTextMax - 1); + Item.pszText[Length(Text)] := #0; + {$else} + // Convert the Unicode implicitely to ANSI using the current locale. + ANSIText := Text; + StrLCopy(Item.pszText, PChar(ANSIText), Item.cchTextMax - 1); + Item.pszText[Length(ANSIText)] := #0; + {$endif} + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.TVMGetItemRect(var Message: TMessage); + +// Screen read support function. This method returns a node's display rectangle. + +var + TextOnly: Boolean; + Node: PVirtualNode; + +begin + // The lparam member is used two-way. On enter it contains a pointer to the item (node). + // On exit it is to be considered as pointer to a rectangle structure. + Node := Pointer(Pointer(Message.LParam)^); + Message.Result := Ord(IsVisible[Node]); + if Message.Result <> 0 then + begin + TextOnly := Message.WParam <> 0; + PRect(Message.LParam)^ := GetDisplayRect(Node, -1, TextOnly); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.TVMGetNextItem(var Message: TMessage); + +// Screen read support function. This method returns a node depending on the requested case. + +var + Node: PVirtualNode; + +begin + // Start with a nil result. + Message.Result := 0; + Node := Pointer(Message.LParam); + case Message.WParam of + TVGN_CARET: + Message.Result := LRESULT(FFocusedNode); + TVGN_CHILD: + if Assigned(Node) then + Message.Result := LRESULT(GetFirstChild(Node)); + TVGN_DROPHILITE: + Message.Result := LRESULT(FDropTargetNode); + TVGN_FIRSTVISIBLE: + Message.Result := LRESULT(GetFirstVisible(nil, True)); + TVGN_LASTVISIBLE: + Message.Result := LRESULT(GetLastVisible(nil, True)); + TVGN_NEXT: + if Assigned(Node) then + Message.Result := LRESULT(GetNextSibling(Node)); + TVGN_NEXTVISIBLE: + if Assigned(Node) then + Message.Result := LRESULT(GetNextVisible(Node, True)); + TVGN_PARENT: + if Assigned(Node) and (Node <> FRoot) and (Node.Parent <> FRoot) then + Message.Result := LRESULT(Node.Parent); + TVGN_PREVIOUS: + if Assigned(Node) then + Message.Result := LRESULT(GetPreviousSibling(Node)); + TVGN_PREVIOUSVISIBLE: + if Assigned(Node) then + Message.Result := LRESULT(GetPreviousVisible(Node, True)); + TVGN_ROOT: + Message.Result := LRESULT(GetFirst); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMCancelMode(var Message: TWMCancelMode); + +begin + // Clear any transient state. + StopTimer(ExpandTimer); + StopTimer(EditTimer); + StopTimer(HeaderTimer); + StopTimer(ScrollTimer); + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + + DoStateChange([], [tsClearPending, tsEditPending, tsOLEDragPending, tsVCLDragPending, tsDrawSelecting, + tsDrawSelPending, tsIncrementalSearching]); + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMChangeState(var Message: TMessage); + +var + EnterStates, + LeaveStates: TVirtualTreeStates; + +begin + EnterStates := []; + if csStopValidation in TChangeStates(Byte(Message.WParam)) then + Include(EnterStates, tsStopValidation); + if csUseCache in TChangeStates(Byte(Message.WParam)) then + Include(EnterStates, tsUseCache); + if csValidating in TChangeStates(Byte(Message.WParam)) then + Include(EnterStates, tsValidating); + if csValidationNeeded in TChangeStates(Byte(Message.WParam)) then + Include(EnterStates, tsValidationNeeded); + + LeaveStates := []; + if csStopValidation in TChangeStates(Byte(Message.LParam)) then + Include(LeaveStates, tsStopValidation); + if csUseCache in TChangeStates(Byte(Message.LParam)) then + Include(LeaveStates, tsUseCache); + if csValidating in TChangeStates(Byte(Message.LParam)) then + Include(LeaveStates, tsValidating); + if csValidationNeeded in TChangeStates(Byte(Message.LParam)) then + Include(LeaveStates, tsValidationNeeded); + + DoStateChange(EnterStates, LeaveStates); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMChar(var Message: TWMChar); + +begin + if tsIncrementalSearchPending in FStates then + begin + HandleIncrementalSearch(Message.CharCode); + DoStateChange([], [tsIncrementalSearchPending]); + end; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMContextMenu(var Message: TWMContextMenu); + +// This method is called when a popup menu is about to be displayed. +// We have to cancel some pending states here to avoid interferences. + +begin + DoStateChange([], [tsClearPending, tsEditPending, tsOLEDragPending, tsVCLDragPending]); + + if not (tsPopupMenuShown in FStates) then + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMCopy(var Message: TWMCopy); + +begin + CopyToClipboard; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMCut(var Message: TWMCut); + +begin + CutToClipboard; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMEnable(var Message: TWMEnable); + +begin + inherited; + RedrawWindow(Handle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_NOERASE or RDW_NOCHILDREN); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMEraseBkgnd(var Message: TWMEraseBkgnd); + +begin + Message.Result := 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMGetDlgCode(var Message: TWMGetDlgCode); + +begin + Message.Result := DLGC_WANTCHARS or DLGC_WANTARROWS; + if FWantTabs then + Message.Result := Message.Result or DLGC_WANTTAB; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMGetObject(var Message: TMessage); + +begin + if GetAccessibilityFactory <> nil then + begin + // Create the IAccessibles for the tree view and tree view items, if necessary. + if FAccessible = nil then + FAccessible := GetAccessibilityFactory.CreateIAccessible(Self); + if FAccessibleItem = nil then + FAccessibleItem := GetAccessibilityFactory.CreateIAccessible(Self); + if Cardinal(Message.LParam) = OBJID_CLIENT then + if Assigned(Accessible) then + Message.Result := LresultFromObject(IID_IAccessible, Message.WParam, FAccessible) + else + Message.Result := 0; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMHScroll(var Message: TWMHScroll); + + //--------------- local functions ------------------------------------------- + + function GetRealScrollPosition: Integer; + + var + SI: TScrollInfo; + Code: Integer; + + begin + SI.cbSize := SizeOf(TScrollInfo); + SI.fMask := SIF_TRACKPOS; + Code := SB_HORZ; + GetScrollInfo(Handle, Code, SI); + Result := SI.nTrackPos; + end; + + //--------------- end local functions --------------------------------------- + +var + RTLFactor: Integer; + +begin + if UseRightToLeftAlignment then + RTLFactor := -1 + else + RTLFactor := 1; + + case Message.ScrollCode of + SB_BOTTOM: + SetOffsetX(-Integer(FRangeX)); + SB_ENDSCROLL: + begin + DoStateChange([], [tsThumbTracking]); + // avoiding to adjust the vertical scroll position while tracking makes it much smoother + // but we need to adjust the final position here then + UpdateHorizontalScrollBar(False); + end; + SB_LINELEFT: + SetOffsetX(FOffsetX + RTLFactor * FScrollBarOptions.FIncrementX); + SB_LINERIGHT: + SetOffsetX(FOffsetX - RTLFactor * FScrollBarOptions.FIncrementX); + SB_PAGELEFT: + SetOffsetX(FOffsetX + RTLFactor * (ClientWidth - FHeader.Columns.GetVisibleFixedWidth)); + SB_PAGERIGHT: + SetOffsetX(FOffsetX - RTLFactor * (ClientWidth - FHeader.Columns.GetVisibleFixedWidth)); + SB_THUMBPOSITION, + SB_THUMBTRACK: + begin + DoStateChange([tsThumbTracking]); + if UseRightToLeftAlignment then + SetOffsetX(-Integer(FRangeX) + ClientWidth + GetRealScrollPosition) + else + SetOffsetX(-GetRealScrollPosition); + end; + SB_TOP: + SetOffsetX(0); + end; + + Message.Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMKeyDown(var Message: TWMKeyDown); + +// Keyboard event handling for node focus, selection, node specific popup menus and help invokation. +// For a detailed description of every action done here read the help. + +var + Shift: TShiftState; + Node, Temp, + LastFocused: PVirtualNode; + Offset: Integer; + ClearPending, + NeedInvalidate, + DoRangeSelect, + HandleMultiSelect: Boolean; + Context: Integer; + ParentControl: TWinControl; + R: TRect; + NewCheckState: TCheckState; + TempColumn, + NewColumn: TColumnIndex; + ActAsGrid: Boolean; + ForceSelection: Boolean; + NewWidth, + NewHeight: Integer; + RTLFactor: Integer; + + // for tabulator handling + GetStartColumn: function(ConsiderAllowFocus: Boolean = False): TColumnIndex of object; + GetNextColumn: function(Column: TColumnIndex; ConsiderAllowFocus: Boolean = False): TColumnIndex of object; + GetNextNode: TGetNextNodeProc; + + KeyState: TKeyboardState; + Buffer: array[0..1] of AnsiChar; + +begin + // Make form key preview work and let application modify the key if it wants this. + inherited; + + with Message do + begin + Shift := KeyDataToShiftState(KeyData); + // Ask the application if the default key handling is desired. + if DoKeyAction(CharCode, Shift) then + begin + if (tsKeyCheckPending in FStates) and (CharCode <> VK_SPACE) then + begin + DoStateChange([], [tskeyCheckPending]); + FCheckNode.CheckState := UnpressedState[FCheckNode.CheckState]; + RepaintNode(FCheckNode); + FCheckNode := nil; + end; + + if CharCode in [VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_BACK, VK_TAB] then + begin + HandleMultiSelect := (ssShift in Shift) and (toMultiSelect in FOptions.FSelectionOptions) and not IsEditing; + + // Flag to avoid range selection in case of single node advance. + DoRangeSelect := (CharCode in [VK_HOME, VK_END, VK_PRIOR, VK_NEXT]) and HandleMultiSelect and not IsEditing; + + NeedInvalidate := DoRangeSelect or (FSelectionCount > 1); + ActAsGrid := toGridExtensions in FOptions.FMiscOptions; + ClearPending := (Shift = []) or (ActAsGrid and not (ssShift in Shift)) or + not (toMultiSelect in FOptions.FSelectionOptions) or (CharCode in [VK_TAB, VK_BACK]); + + // Keep old focused node for range selection. Use a default node if none was focused until now. + LastFocused := FFocusedNode; + if (LastFocused = nil) and (Shift <> []) then + LastFocused := GetFirstVisible(nil, True); + + // Set an initial range anchor if there is not yet one. + if FRangeAnchor = nil then + FRangeAnchor := GetFirstSelected; + if FRangeAnchor = nil then + FRangeAnchor := GetFirst; + + if UseRightToLeftAlignment then + RTLFactor := -1 + else + RTLFactor := 1; + + // Determine new focused node. + case CharCode of + VK_HOME, VK_END: + begin + if (CharCode = VK_END) xor UseRightToLeftAlignment then + begin + GetStartColumn := FHeader.FColumns.GetLastVisibleColumn; + GetNextColumn := FHeader.FColumns.GetPreviousVisibleColumn; + GetNextNode := GetPreviousVisible; + Node := GetLastVisible(nil, True); + end + else + begin + GetStartColumn := FHeader.FColumns.GetFirstVisibleColumn; + GetNextColumn := FHeader.FColumns.GetNextVisibleColumn; + GetNextNode := GetNextVisible; + Node := GetFirstVisible(nil, True); + end; + + // Advance to next/previous visible column. + if FHeader.UseColumns then + NewColumn := GetStartColumn + else + NewColumn := NoColumn; + // Find a column for the new/current node which can be focused. + // Make the 'DoFocusChanging' for finding a valid column + // identifiable from the 'DoFocusChanging' raised later on by + // "FocusedNode := Node;" + while (NewColumn > NoColumn) and not DoFocusChanging(FFocusedNode, FFocusedNode, FFocusedColumn, NewColumn) do + NewColumn := GetNextColumn(NewColumn); + if NewColumn > InvalidColumn then + begin + if (Shift = [ssCtrl]) and not ActAsGrid then + begin + ScrollIntoView(Node, toCenterScrollIntoView in FOptions.SelectionOptions, + not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions)); + if (CharCode = VK_HOME) and not UseRightToLeftAlignment then + SetOffsetX(0) + else + SetOffsetX(-MaxInt); + end + else + begin + if not ActAsGrid or (ssCtrl in Shift) then + FocusedNode := Node; + if ActAsGrid and not (toFullRowSelect in FOptions.FSelectionOptions) then + FocusedColumn := NewColumn; + end; + end; + end; + VK_PRIOR: + if Shift = [ssCtrl, ssShift] then + SetOffsetX(FOffsetX + ClientWidth) + else + if [ssShift, ssAlt] = Shift then + begin + if FFocusedColumn <= NoColumn then + NewColumn := FHeader.FColumns.GetFirstVisibleColumn + else + begin + Offset := FHeader.FColumns.GetVisibleFixedWidth; + NewColumn := FFocusedColumn; + while True do + begin + TempColumn := FHeader.FColumns.GetPreviousVisibleColumn(NewColumn); + NewWidth := FHeader.FColumns[NewColumn].Width; + if (TempColumn <= NoColumn) or + (Offset + NewWidth >= ClientWidth) or + (coFixed in FHeader.FColumns[TempColumn].FOptions) then + Break; + NewColumn := TempColumn; + Inc(Offset, NewWidth); + end; + end; + SetFocusedColumn(NewColumn); + end + else + if ssCtrl in Shift then + SetOffsetY(FOffsetY + ClientHeight) + else + begin + Offset := 0; + // If there's no focused node then just take the very first visible one. + if FFocusedNode = nil then + Node := GetFirstVisible(nil, True) + else + begin + // Go up as many nodes as comprise together a size of ClientHeight. + Node := FFocusedNode; + while True do + begin + Temp := GetPreviousVisible(Node, True); + NewHeight := NodeHeight[Node]; + if (Temp = nil) or (Offset + NewHeight >= ClientHeight) then + Break; + Node := Temp; + Inc(Offset, NodeHeight[Node]); + end; + end; + FocusedNode := Node; + end; + VK_NEXT: + if Shift = [ssCtrl, ssShift] then + SetOffsetX(FOffsetX - ClientWidth) + else + if [ssShift, ssAlt] = Shift then + begin + if FFocusedColumn <= NoColumn then + NewColumn := FHeader.FColumns.GetFirstVisibleColumn + else + begin + Offset := FHeader.FColumns.GetVisibleFixedWidth; + NewColumn := FFocusedColumn; + while True do + begin + TempColumn := FHeader.FColumns.GetNextVisibleColumn(NewColumn); + NewWidth := FHeader.FColumns[NewColumn].Width; + if (TempColumn <= NoColumn) or + (Offset + NewWidth >= ClientWidth) or + (coFixed in FHeader.FColumns[TempColumn].FOptions) then + Break; + NewColumn := TempColumn; + Inc(Offset, NewWidth); + end; + end; + SetFocusedColumn(NewColumn); + end + else + if ssCtrl in Shift then + SetOffsetY(FOffsetY - ClientHeight) + else + begin + Offset := 0; + // If there's no focused node then just take the very last one. + if FFocusedNode = nil then + Node := GetLastVisible(nil, True) + else + begin + // Go up as many nodes as comprise together a size of ClientHeight. + Node := FFocusedNode; + while True do + begin + Temp := GetNextVisible(Node, True); + NewHeight := NodeHeight[Node]; + if (Temp = nil) or (Offset + NewHeight >= ClientHeight) then + Break; + Node := Temp; + Inc(Offset, NewHeight); + end; + end; + FocusedNode := Node; + end; + VK_UP: + begin + // scrolling without selection change + if ssCtrl in Shift then + SetOffsetY(FOffsetY + Integer(FDefaultNodeHeight)) + else + begin + if FFocusedNode = nil then + Node := GetLastVisible(nil, True) + else + Node := GetPreviousVisible(FFocusedNode, True); + + if Assigned(Node) then + begin + EndEditNode; + if HandleMultiSelect and (CompareNodePositions(LastFocused, FRangeAnchor) > 0) and + Assigned(FFocusedNode) then + RemoveFromSelection(FFocusedNode); + if FFocusedColumn <= NoColumn then + FFocusedColumn := FHeader.MainColumn; + FocusedNode := Node; + end + else + if Assigned(FFocusedNode) then + InvalidateNode(FFocusedNode); + end; + end; + VK_DOWN: + begin + // scrolling without selection change + if ssCtrl in Shift then + SetOffsetY(FOffsetY - Integer(FDefaultNodeHeight)) + else + begin + if FFocusedNode = nil then + Node := GetFirstVisible(nil, True) + else + Node := GetNextVisible(FFocusedNode, True); + + if Assigned(Node) then + begin + EndEditNode; + if HandleMultiSelect and (CompareNodePositions(LastFocused, FRangeAnchor) < 0) and + Assigned(FFocusedNode) then + RemoveFromSelection(FFocusedNode); + if FFocusedColumn <= NoColumn then + FFocusedColumn := FHeader.MainColumn; + FocusedNode := Node; + end + else + if Assigned(FFocusedNode) then + InvalidateNode(FFocusedNode); + end; + end; + VK_LEFT: + begin + // special handling + if ssCtrl in Shift then + SetOffsetX(FOffsetX + RTLFactor * FHeader.Columns.GetScrollWidth) + else + begin + // other special cases + Context := NoColumn; + if (toExtendedFocus in FOptions.FSelectionOptions) and (toGridExtensions in FOptions.FMiscOptions) then + begin + Context := FHeader.Columns.GetPreviousVisibleColumn(FFocusedColumn, True); + if Context > -1 then + FocusedColumn := Context + end + else + if Assigned(FFocusedNode) and (vsExpanded in FFocusedNode.States) and + (Shift = []) and (vsHasChildren in FFocusedNode.States) then + ToggleNode(FFocusedNode) + else + begin + if FFocusedNode = nil then + FocusedNode := GetFirstVisible(nil, True) + else + begin + if FFocusedNode.Parent <> FRoot then + Node := FFocusedNode.Parent + else + Node := nil; + if Assigned(Node) then + begin + if HandleMultiSelect then + begin + // and a third special case + if FFocusedNode.Index > 0 then + DoRangeSelect := True + else + if CompareNodePositions(Node, FRangeAnchor) > 0 then + RemoveFromSelection(FFocusedNode); + end; + FocusedNode := Node; + end; + end; + end; + end; + end; + VK_RIGHT: + begin + // special handling + if ssCtrl in Shift then + SetOffsetX(FOffsetX - RTLFactor * FHeader.Columns.GetScrollWidth) + else + begin + // other special cases + Context := NoColumn; + if (toExtendedFocus in FOptions.FSelectionOptions) and (toGridExtensions in FOptions.FMiscOptions) then + begin + Context := FHeader.Columns.GetNextVisibleColumn(FFocusedColumn, True); + if Context > -1 then + FocusedColumn := Context; + end + else + if Assigned(FFocusedNode) and not (vsExpanded in FFocusedNode.States) and + (Shift = []) and (vsHasChildren in FFocusedNode.States) then + ToggleNode(FFocusedNode) + else + begin + if FFocusedNode = nil then + FocusedNode := GetFirstVisible(nil, True) + else + begin + Node := GetFirstVisibleChild(FFocusedNode); + if Assigned(Node) then + begin + if HandleMultiSelect and (CompareNodePositions(Node, FRangeAnchor) < 0) then + RemoveFromSelection(FFocusedNode); + FocusedNode := Node; + end; + end; + end; + end; + end; + VK_BACK: + if tsIncrementalSearching in FStates then + DoStateChange([tsIncrementalSearchPending]) + else + if Assigned(FFocusedNode) and (FFocusedNode.Parent <> FRoot) then + FocusedNode := FocusedNode.Parent; + VK_TAB: + if (toExtendedFocus in FOptions.FSelectionOptions) and FHeader.UseColumns then + begin + // In order to avoid duplicating source code just to change the direction + // we use function variables. + if ssShift in Shift then + begin + GetStartColumn := FHeader.FColumns.GetLastVisibleColumn; + GetNextColumn := FHeader.FColumns.GetPreviousVisibleColumn; + GetNextNode := GetPreviousVisible; + end + else + begin + GetStartColumn := FHeader.FColumns.GetFirstVisibleColumn; + GetNextColumn := FHeader.FColumns.GetNextVisibleColumn; + GetNextNode := GetNextVisible; + end; + + // Advance to next/previous visible column/node. + Node := FFocusedNode; + NewColumn := GetNextColumn(FFocusedColumn, True); + repeat + // Find a column for the current node which can be focused. + while (NewColumn > NoColumn) and not DoFocusChanging(FFocusedNode, Node, FFocusedColumn, NewColumn) do + NewColumn := GetNextColumn(NewColumn, True); + + if NewColumn > NoColumn then + begin + // Set new node and column in one go. + SetFocusedNodeAndColumn(Node, NewColumn); + Break; + end; + + // No next column was accepted for the current node. So advance to next node and try again. + Node := GetNextNode(Node); + NewColumn := GetStartColumn; + until Node = nil; + end; + end; + + // Clear old selection if required but take care to select the new focused node if it was not selected before. + ForceSelection := False; + if ClearPending and ((LastFocused <> FFocusedNode) or (FSelectionCount <> 1)) then + begin + ClearSelection; + ForceSelection := True; + end; + + // Determine new selection anchor. + if Shift = [] then + begin + FRangeAnchor := FFocusedNode; + FLastSelectionLevel := GetNodeLevel(FFocusedNode); + end; + + if Assigned(FFocusedNode) then + begin + // Finally change the selection for a specific range of nodes. + if DoRangeSelect then + ToggleSelection(LastFocused, FFocusedNode); + + // Make sure the new focused node is also selected. + if (LastFocused <> FFocusedNode) or ForceSelection then + AddToSelection(FFocusedNode); + end; + + // If a repaint is needed then paint the entire tree because of the ClearSelection call, + if NeedInvalidate then + Invalidate; + end + else + begin + // Second chance for keys not directly concerned with selection changes. + + // For +, -, /, * keys on the main keyboard (not numpad) there is no virtual key code defined. + // We have to do special processing to get them working too. + GetKeyboardState(KeyState); + // Avoid conversion to control characters. We have captured the control key state already in Shift. + KeyState[VK_CONTROL] := 0; + if ToASCII(Message.CharCode, (Message.KeyData shr 16) and 7, KeyState, @Buffer, 0) > 0 then + begin + case Buffer[0] of + '*': + CharCode := VK_MULTIPLY; + '+': + CharCode := VK_ADD; + '/': + CharCode := VK_DIVIDE; + '-': + CharCode := VK_SUBTRACT; + end; + end; + + // According to http://www.it-faq.pl/mskb/99/337.HTM there is a problem with ToASCII when used in conjunction + // with dead chars. The article recommends to call ToASCII twice to restore a deleted flag in the key message + // structure under certain circumstances. It turned out it is best to always call ToASCII twice. + ToASCII(Message.CharCode, (Message.KeyData shr 16) and 7, KeyState, @Buffer, 0); + + case CharCode of + VK_F2: + if (Shift = []) and Assigned(FFocusedNode) and CanEdit(FFocusedNode, FFocusedColumn) then + begin + FEditColumn := FFocusedColumn; + DoEdit; + end; + VK_ADD: + if not (tsIncrementalSearching in FStates) then + begin + if ssCtrl in Shift then + if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then + FullExpand + else + FHeader.AutoFitColumns + else + if Assigned(FFocusedNode) and not (vsExpanded in FFocusedNode.States) then + ToggleNode(FFocusedNode); + end + else + DoStateChange([tsIncrementalSearchPending]); + VK_SUBTRACT: + if not (tsIncrementalSearching in FStates) then + begin + if ssCtrl in Shift then + if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then + FullCollapse + else + FHeader.RestoreColumns + else + if Assigned(FFocusedNode) and (vsExpanded in FFocusedNode.States) then + ToggleNode(FFocusedNode); + end + else + DoStateChange([tsIncrementalSearchPending]); + VK_MULTIPLY: + if not (tsIncrementalSearching in FStates) then + begin + if Assigned(FFocusedNode) then + FullExpand(FFocusedNode); + end + else + DoStateChange([tsIncrementalSearchPending]); + VK_DIVIDE: + if not (tsIncrementalSearching in FStates) then + begin + if Assigned(FFocusedNode) then + FullCollapse(FFocusedNode); + end + else + DoStateChange([tsIncrementalSearchPending]); + VK_ESCAPE: // cancel actions currently in progress + begin + if IsMouseSelecting then + begin + DoStateChange([], [tsDrawSelecting, tsDrawSelPending]); + Invalidate; + end + else + if IsEditing then + CancelEditNode; + end; + VK_SPACE: + if (toCheckSupport in FOptions.FMiscOptions) and Assigned(FFocusedNode) and + (FFocusedNode.CheckType <> ctNone) then + begin + if (FStates * [tsKeyCheckPending, tsMouseCheckPending] = []) and Assigned(FFocusedNode) and + not (vsDisabled in FFocusedNode.States) then + begin + with FFocusedNode^ do + NewCheckState := DetermineNextCheckState(CheckType, CheckState); + if DoChecking(FFocusedNode, NewCheckState) then + begin + DoStateChange([tsKeyCheckPending]); + FCheckNode := FFocusedNode; + FPendingCheckState := NewCheckState; + FCheckNode.CheckState := PressedState[FCheckNode.CheckState]; + RepaintNode(FCheckNode); + end; + end; + end + else + DoStateChange([tsIncrementalSearchPending]); + VK_F1: + if Assigned(FOnGetHelpContext) then + begin + Context := 0; + if Assigned(FFocusedNode) then + begin + Node := FFocusedNode; + // Traverse the tree structure up to the root. + repeat + FOnGetHelpContext(Self, Node, IfThen(FFocusedColumn > NoColumn, FFocusedColumn, 0), Context); + Node := Node.Parent; + until (Node = FRoot) or (Context <> 0); + end; + + // If no help context could be found try the tree's one or its parent's contexts. + ParentControl := Self; + while Assigned(ParentControl) and (Context = 0) do + begin + Context := ParentControl.HelpContext; + ParentControl := ParentControl.Parent; + end; + if Context <> 0 then + Application.HelpContext(Context); + end; + VK_APPS: + if Assigned(FFocusedNode) then + begin + R := GetDisplayRect(FFocusedNode, FFocusedColumn, True); + Offset := DoGetNodeWidth(FFocusedNode, FFocusedColumn); + if FFocusedColumn >= 0 then + begin + if Offset > FHeader.Columns[FFocusedColumn].Width then + Offset := FHeader.Columns[FFocusedColumn].Width; + end + else + begin + if Offset > ClientWidth then + Offset := ClientWidth; + end; + DoPopupMenu(FFocusedNode, FFocusedColumn, Point(R.Left + Offset div 2, (R.Top + R.Bottom) div 2)); + end; + Ord('a'), Ord('A'): + if ssCtrl in Shift then + SelectAll(True) + else + DoStateChange([tsIncrementalSearchPending]); + else + begin + // Use the key for incremental search. + // Since we are dealing with Unicode all the time there should be a more sophisticated way + // of checking for valid characters for incremental search. + // This is available but would require to include a significant amount of Unicode character + // properties, so we stick with the simple space check. + if (Shift * [ssCtrl, ssAlt] = []) and (CharCode >= 32) then + DoStateChange([tsIncrementalSearchPending]); + end; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMKeyUp(var Message: TWMKeyUp); + +begin + inherited; + + case Message.CharCode of + VK_SPACE: + if tsKeyCheckPending in FStates then + begin + DoStateChange([], [tskeyCheckPending]); + if FCheckNode = FFocusedNode then + DoCheckClick(FCheckNode, FPendingCheckState); + InvalidateNode(FCheckNode); + FCheckNode := nil; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMKillFocus(var Msg: TWMKillFocus); + +var + Form: TCustomForm; + Control: TWinControl; + Pos: TSmallPoint; + Unknown: IUnknown; + +begin + inherited; + + // Remove hint if shown currently. + Application.CancelHint; + + // Stop wheel panning if active. + StopWheelPanning; + + // Don't let any timer continue if the tree is no longer the active control (except change timers). + StopTimer(ExpandTimer); + StopTimer(EditTimer); + StopTimer(HeaderTimer); + StopTimer(ScrollTimer); + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + + DoStateChange([], [tsScrollPending, tsScrolling, tsEditPending, tsLeftButtonDown, tsRightButtonDown, + tsMiddleButtonDown, tsOLEDragPending, tsVCLDragPending, tsIncrementalSearching, tsNodeHeightTrackPending, + tsNodeHeightTracking]); + + if (FSelectionCount > 0) or not (toGhostedIfUnfocused in FOptions.FPaintOptions) then + Invalidate + else + if Assigned(FFocusedNode) then + InvalidateNode(FFocusedNode); + + // Workaround for wrapped non-VCL controls (like TWebBrowser), which do not use VCL mechanisms and + // leave the ActiveControl property in the wrong state, which causes trouble when the control is refocused. + Form := GetParentForm(Self); + if Assigned(Form) and (Form.ActiveControl = Self) then + begin + Cardinal(Pos) := GetMessagePos; + Control := FindVCLWindow(SmallPointToPoint(Pos)); + // Every control derived from TOleControl has potentially the focus problem. In order to avoid including + // the OleCtrls unit (which will, among others, include Variants), which would allow to test for the TOleControl + // class, the IOleClientSite interface is used for the test, which is supported by TOleControl and a good indicator. + if Assigned(Control) and Control.GetInterface(IOleClientSite, Unknown) then + Form.ActiveControl := nil; + + // For other classes the active control should not be modified. Otherwise you need two clicks to select it. + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMLButtonDblClk(var Message: TWMLButtonDblClk); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsLeftDblClick]); + inherited; + + // get information about the hit + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDblClick(Message, HitInfo); + DoStateChange([], [tsLeftDblClick]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMLButtonDown(var Message: TWMLButtonDown); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsLeftButtonDown]); + inherited; + + // get information about the hit + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDown(Message, HitInfo); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMLButtonUp(var Message: TWMLButtonUp); + +var + HitInfo: THitInfo; + +begin + DoStateChange([], [tsLeftButtonDown, tsNodeHeightTracking, tsNodeHeightTrackPending]); + + // get information about the hit + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseUp(Message, HitInfo); + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMMButtonDblClk(var Message: TWMMButtonDblClk); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsMiddleDblClick]); + inherited; + + // get information about the hit + if toMiddleClickSelect in FOptions.FSelectionOptions then + begin + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDblClick(Message, HitInfo); + end; + DoStateChange([], [tsMiddleDblClick]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMMButtonDown(var Message: TWMMButtonDown); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsMiddleButtonDown]); + + if FHeader.FStates = [] then + begin + inherited; + + // Start wheel panning or scrolling if not already active, allowed and scrolling is useful at all. + if (toWheelPanning in FOptions.FMiscOptions) and ([tsWheelScrolling, tsWheelPanning] * FStates = []) and + ((Integer(FRangeX) > ClientWidth) or (Integer(FRangeY) > ClientHeight)) then + begin + FLastClickPos := SmallPointToPoint(Message.Pos); + StartWheelPanning(FLastClickPos); + end + else + begin + StopWheelPanning; + + // Get information about the hit. + if toMiddleClickSelect in FOptions.FSelectionOptions then + begin + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDown(Message, HitInfo); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMMButtonUp(var Message: TWMMButtonUp); + +var + HitInfo: THitInfo; + +begin + DoStateChange([], [tsMiddleButtonDown]); + + // If wheel panning/scrolling is active and the mouse has not yet been moved then the user starts wheel auto scrolling. + // Indicate this by removing the panning flag. Otherwise (the mouse has moved meanwhile) stop panning. + if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then + begin + if tsWheelScrolling in FStates then + DoStateChange([], [tsWheelPanning]) + else + StopWheelPanning; + end + else + if FHeader.FStates = [] then + begin + inherited; + + // get information about the hit + if toMiddleClickSelect in FOptions.FSelectionOptions then + begin + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseUp(Message, HitInfo); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMNCCalcSize(var Message: TWMNCCalcSize); + +begin + inherited; + + with FHeader do + if hoVisible in FHeader.FOptions then + with Message.CalcSize_Params^ do + Inc(rgrc[0].Top, FHeight); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMNCDestroy(var Message: TWMNCDestroy); + +// Used to release a reference of the drag manager. This is the only reliable way we get notified about +// window destruction, because of the automatic release of a window if its parent window is freed. + +begin + InterruptValidation; + + StopTimer(ChangeTimer); + StopTimer(StructureChangeTimer); + + if not (csDesigning in ComponentState) and (toAcceptOLEDrop in FOptions.FMiscOptions) then + RevokeDragDrop(Handle); + + // Clean up other stuff. + DeleteObject(FDottedBrush); + FDottedBrush := 0; + if tsInAnimation in FStates then + FHintWindowDestroyed := True; // Stop any pending animation. + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMNCHitTest(var Message: TWMNCHitTest); + +begin + inherited; + if not (csDesigning in ComponentState) and (hoVisible in FHeader.FOptions) and + FHeader.InHeader(ScreenToClient(SmallPointToPoint(Message.Pos))) then + Message.Result := HTBORDER; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMNCPaint(var Message: TRealWMNCPaint); + +var + DC: HDC; + R: TRect; + Flags: DWORD; + ExStyle: Integer; + TempRgn: HRGN; + BorderWidth, + BorderHeight: Integer; + +begin + if tsUseThemes in FStates then + begin + // If theming is enabled and the client edge border is set for the window then prevent the default window proc + // from painting the old border to avoid flickering. + ExStyle := GetWindowLong(Handle, GWL_EXSTYLE); + if (ExStyle and WS_EX_CLIENTEDGE) <> 0 then + begin + GetWindowRect(Handle, R); + // Determine width of the client edge. + BorderWidth := GetSystemMetrics(SM_CXEDGE); + BorderHeight := GetSystemMetrics(SM_CYEDGE); + InflateRect(R, -BorderWidth, -BorderHeight); + TempRgn := CreateRectRgnIndirect(R); + // Exclude the border from the message region if there is one. Otherwise just use the inflated + // window area region. + if Message.Rgn <> 1 then + CombineRgn(TempRgn, Message.Rgn, TempRgn, RGN_AND); + DefWindowProc(Handle, Message.Msg, WPARAM(TempRgn), 0); + DeleteObject(TempRgn); + end + else + DefaultHandler(Message); + end + else + DefaultHandler(Message); + + Flags := DCX_CACHE or DCX_CLIPSIBLINGS or DCX_WINDOW or DCX_VALIDATE; + + if ((Message.Rgn {$ifdef CPUX64}shr 32{$endif}) = 1) then // fixes issue #235 + DC := GetDCEx(Handle, 0, Flags) + else + DC := GetDCEx(Handle, Message.Rgn, Flags or DCX_INTERSECTRGN); + + if DC <> 0 then + begin + if hoVisible in FHeader.FOptions then + begin + R := FHeaderRect; + FHeader.FColumns.PaintHeader(DC, R, -FEffectiveOffsetX); + end; + OriginalWMNCPaint(DC); + ReleaseDC(Handle, DC); + end; + if tsUseThemes in FStates then + ThemeServices.PaintBorder(Self, False); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMPaint(var Message: TWMPaint); + +begin + if tsVCLDragging in FStates then + ImageList_DragShowNolock(False); + if csPaintCopy in ControlState then + FUpdateRect := ClientRect + else + GetUpdateRect(Handle, FUpdateRect, True); + + inherited; + + if tsVCLDragging in FStates then + ImageList_DragShowNolock(True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMPaste(var Message: TWMPaste); + +begin + PasteFromClipboard; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMPrint(var Message: TWMPrint); + +// This message is sent to request that the tree draws itself to a given device context. This includes not only +// the client area but also the non-client area (header!). + +begin + // Draw only if the window is visible or visibility is not required. + if ((Message.Flags and PRF_CHECKVISIBLE) = 0) or IsWindowVisible(Handle) then + Header.Columns.PaintHeader(Message.DC, FHeaderRect, -FEffectiveOffsetX); + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMPrintClient(var Message: TWMPrintClient); + +var + Window: TRect; + Target: TPoint; + Canvas: TCanvas; + +begin + // Draw only if the window is visible or visibility is not required. + if ((Message.Flags and PRF_CHECKVISIBLE) = 0) or IsWindowVisible(Handle) then + begin + // Determine area of the entire tree to be displayed in the control. + Window := ClientRect; + Target := Window.TopLeft; + + // The Window rectangle is given in client coordinates. We have to convert it into + // a sliding window of the tree image. + OffsetRect(Window, FEffectiveOffsetX, -FOffsetY); + + Canvas := TCanvas.Create; + try + Canvas.Handle := Message.DC; + PaintTree(Canvas, Window, Target, [poBackground, poDrawFocusRect, poDrawDropMark, poDrawSelection, poGridLines]); + finally + Canvas.Handle := 0; + Canvas.Free; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMRButtonDblClk(var Message: TWMRButtonDblClk); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsRightDblClick]); + inherited; + + // get information about the hit + if toMiddleClickSelect in FOptions.FSelectionOptions then + begin + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDblClick(Message, HitInfo); + end; + DoStateChange([], [tsRightDblClick]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMRButtonDown(var Message: TWMRButtonDown); + +var + HitInfo: THitInfo; + +begin + DoStateChange([tsRightButtonDown]); + + if FHeader.FStates = [] then + begin + inherited; + + // get information about the hit + if toRightClickSelect in FOptions.FSelectionOptions then + begin + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + HandleMouseDown(Message, HitInfo); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMRButtonUp(var Message: TWMRButtonUp); + +// handle right click selection and node specific popup menu + +var + HitInfo: THitInfo; + +begin + DoStateChange([], [tsPopupMenuShown, tsRightButtonDown]); + + if FHeader.FStates = [] then + begin + Application.CancelHint; + + if IsMouseSelecting and Assigned(PopupMenu) then + begin + // Reset selection state already here, before the inherited handler opens the default menu. + DoStateChange([], [tsDrawSelecting, tsDrawSelPending]); + Invalidate; + end; + + inherited; + + // get information about the hit + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + + if toRightClickSelect in FOptions.FSelectionOptions then + HandleMouseUp(Message, HitInfo); + + if not Assigned(PopupMenu) then + DoPopupMenu(HitInfo.HitNode, HitInfo.HitColumn, Point(Message.XPos, Message.YPos)); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMSetCursor(var Message: TWMSetCursor); + +// Sets the hot node mouse cursor for the tree. Cursor changes for the header are handled in Header.HandleMessage. + +var + NewCursor: TCursor; + HitInfo: THitInfo; + P: TPoint; + Node: PVirtualNode; + +begin + with Message do + begin + if (CursorWnd = Handle) and not (csDesigning in ComponentState) and + ([tsWheelPanning, tsWheelScrolling] * FStates = []) then + begin + if not FHeader.HandleMessage(TMessage(Message)) then + begin + // Apply own cursors only if there is no global cursor set. + if Screen.Cursor = crDefault then + begin + NewCursor := crDefault; + if (toNodeHeightResize in FOptions.FMiscOptions) then + begin + GetCursorPos(P); + P := ScreenToClient(P); + GetHitTestInfoAt(P.X, P.Y, True, HitInfo); + if (hiOnItem in HitInfo.HitPositions) and + ([hiUpperSplitter, hiLowerSplitter] * HitInfo.HitPositions <> []) then + begin + if hiUpperSplitter in HitInfo.HitPositions then + Node := GetPreviousVisible(HitInfo.HitNode, True) + else + Node := HitInfo.HitNode; + + if CanSplitterResizeNode(P, Node, HitInfo.HitColumn) then + NewCursor := crVertSplit; + end; + end; + + if (NewCursor = crDefault) then + if (toHotTrack in FOptions.PaintOptions) and Assigned(FCurrentHotNode) and (FHotCursor <> crDefault) then + NewCursor := FHotCursor + else + NewCursor := Cursor; + + DoGetCursor(NewCursor); + Windows.SetCursor(Screen.Cursors[NewCursor]); + Message.Result := 1; + end + else + inherited; + end; + end + else + inherited; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMSetFocus(var Msg: TWMSetFocus); + +begin + inherited; + if (FSelectionCount > 0) or not (toGhostedIfUnfocused in FOptions.FPaintOptions) then + Invalidate; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMSize(var Message: TWMSize); + +begin + inherited; + + // Need to update scroll bars here. This will cause a recursion because of the change of the client area + // when changing a scrollbar. Usually this is no problem since with the second level recursion no change of the + // window size happens (the same values for the scrollbars are set, which shouldn't cause a window size change). + // Appearently, this applies not to all systems, however. + if HandleAllocated and ([tsSizing, tsWindowCreating] * FStates = []) and (ClientHeight > 0) then + try + DoStateChange([tsSizing]); + // This call will invalidate the entire non-client area which needs recalculation on resize. + FHeader.RescaleHeader; + FHeader.UpdateSpringColumns; + UpdateScrollBars(True); + + if (tsEditing in FStates) and not FHeader.UseColumns then + UpdateEditBounds; + finally + DoStateChange([], [tsSizing]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMThemeChanged(var Message: TMessage); + +begin + inherited; + + if ThemeServices.ThemesEnabled and (toThemeAware in TreeOptions.PaintOptions) then + DoStateChange([tsUseThemes]) + else + DoStateChange([], [tsUseThemes]); + RedrawWindow(Handle, nil, 0, RDW_INVALIDATE or RDW_VALIDATE or RDW_FRAME); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMTimer(var Message: TWMTimer); + +// centralized timer handling happens here + +begin + with Message do + begin + case TimerID of + ExpandTimer: + DoDragExpand; + EditTimer: + DoEdit; + ScrollTimer: + begin + if tsScrollPending in FStates then + begin + Application.CancelHint; + // Scroll delay has elapsed, set to normal scroll interval now. + SetTimer(Handle, ScrollTimer, FAutoScrollInterval, nil); + DoStateChange([tsScrolling], [tsScrollPending]); + end; + DoTimerScroll; + end; + ChangeTimer: + DoChange(FLastChangedNode); + StructureChangeTimer: + DoStructureChange(FLastStructureChangeNode, FLastStructureChangeReason); + SearchTimer: + begin + // When this event triggers then the user did not pressed any key for the specified timeout period. + // Hence incremental searching is stopped. + DoStateChange([], [tsIncrementalSearching]); + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WMVScroll(var Message: TWMVScroll); + + //--------------- local functions ------------------------------------------- + + function GetRealScrollPosition: Integer; + + var + SI: TScrollInfo; + Code: Integer; + + begin + SI.cbSize := SizeOf(TScrollInfo); + SI.fMask := SIF_TRACKPOS; + Code := SB_VERT; + GetScrollInfo(Handle, Code, SI); + Result := SI.nTrackPos; + end; + + //--------------- end local functions --------------------------------------- + +begin + case Message.ScrollCode of + SB_BOTTOM: + SetOffsetY(-Integer(FRoot.TotalHeight)); + SB_ENDSCROLL: + begin + DoStateChange([], [tsThumbTracking]); + // Avoiding to adjust the horizontal scroll position while tracking makes scrolling much smoother + // but we need to adjust the final position here then. + UpdateScrollBars(True); + // Really weird invalidation needed here (and I do it only because it happens so rarely), because + // when showing the horizontal scrollbar while scrolling down using the down arrow button, + // the button will be repainted on mouse up (at the wrong place in the far right lower corner)... + RedrawWindow(Handle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_NOERASE or RDW_NOCHILDREN); + end; + SB_LINEUP: + SetOffsetY(FOffsetY + FScrollBarOptions.FIncrementY); + SB_LINEDOWN: + SetOffsetY(FOffsetY - FScrollBarOptions.FIncrementY); + SB_PAGEUP: + SetOffsetY(FOffsetY + ClientHeight); + SB_PAGEDOWN: + SetOffsetY(FOffsetY - ClientHeight); + + SB_THUMBPOSITION, + SB_THUMBTRACK: + begin + DoStateChange([tsThumbTracking]); + SetOffsetY(-GetRealScrollPosition); + end; + SB_TOP: + SetOffsetY(0); + end; + Message.Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AddToSelection(Node: PVirtualNode); + +var + Changed: Boolean; + +begin + if not FSelectionLocked then + begin + Assert(Assigned(Node), 'Node must not be nil!'); + FSingletonNodeArray[0] := Node; + Changed := InternalAddToSelection(FSingletonNodeArray, 1, False); + if Changed then + begin + InvalidateNode(Node); + Change(Node); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AddToSelection(const NewItems: TNodeArray; NewLength: Integer; ForceInsert: Boolean = False); + +// Adds the given items all at once into the current selection array. NewLength is the amount of +// nodes to add (necessary to allow NewItems to be larger than the actual used entries). +// ForceInsert is True if nodes must be inserted without consideration of level select constraint or +// already set selected flags (e.g. when loading from stream). +// Note: In the case ForceInsert is True the caller is responsible for making sure the new nodes aren't already in the +// selection array! + +var + Changed: Boolean; + +begin + Changed := InternalAddToSelection(NewItems, NewLength, ForceInsert); + if Changed then + begin + if NewLength = 1 then + begin + InvalidateNode(NewItems[0]); + Change(NewItems[0]); + end + else + begin + Invalidate; + Change(nil); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustImageBorder(Images: TCustomImageList; BidiMode: TBidiMode; VAlign: Integer; var R: TRect; + var ImageInfo: TVTImageInfo); + +// Depending on the width of the image list as well as the given bidi mode R must be adjusted. + +begin + if BidiMode = bdLeftToRight then + begin + ImageInfo.XPos := R.Left; + Inc(R.Left, Images.Width + 2); + end + else + begin + ImageInfo.XPos := R.Right - Images.Width; + Dec(R.Right, Images.Width + 2); + end; + ImageInfo.YPos := R.Top + VAlign - Images.Height div 2; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); + +// Used in descendants to modify the paint rectangle of the current column while painting a certain node. + +begin + // Since cells are always drawn from left to right the next column index is independent of the + // bidi mode, but not the column borders, which might change depending on the cell's content. + NextNonEmpty := FHeader.FColumns.GetNextVisibleColumn(PaintInfo.Column); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdjustPanningCursor(X, Y: Integer); + +// Triggered by a mouse move when wheel panning/scrolling is active. +// Loads the proper cursor which indicates into which direction scrolling is done. + +var + Name: string; + NewCursor: HCURSOR; + ScrollHorizontal, + ScrollVertical: Boolean; + +begin + ScrollHorizontal := Integer(FRangeX) > ClientWidth; + ScrollVertical := Integer(FRangeY) > ClientHeight; + + if (Abs(X - FLastClickPos.X) < 8) and (Abs(Y - FLastClickPos.Y) < 8) then + begin + // Mouse is in the neutral zone. + if ScrollHorizontal then + begin + if ScrollVertical then + Name := 'VT_MOVEALL' + else + Name := 'VT_MOVEEW' + end + else + Name := 'VT_MOVENS'; + end + else + begin + // One of 8 directions applies: north, north-east, east, south-east, south, south-west, west and north-west. + // Check also if scrolling in the particular direction is possible. + if ScrollVertical and ScrollHorizontal then + begin + // All directions allowed. + if X - FlastClickPos.X < -8 then + begin + // Left hand side. + if Y - FLastClickPos.Y < -8 then + Name := 'VT_MOVENW' + else + if Y - FLastClickPos.Y > 8 then + Name := 'VT_MOVESW' + else + Name := 'VT_MOVEW'; + end + else + if X - FLastClickPos.X > 8 then + begin + // Right hand side. + if Y - FLastClickPos.Y < -8 then + Name := 'VT_MOVENE' + else + if Y - FLastClickPos.Y > 8 then + Name := 'VT_MOVESE' + else + Name := 'VT_MOVEE'; + end + else + begin + // Up or down. + if Y < FLastClickPos.Y then + Name := 'VT_MOVEN' + else + Name := 'VT_MOVES'; + end; + end + else + if ScrollHorizontal then + begin + // Only horizontal movement allowed. + if X < FlastClickPos.X then + Name := 'VT_MOVEW' + else + Name := 'VT_MOVEE'; + end + else + begin + // Only vertical movement allowed. + if Y < FlastClickPos.Y then + Name := 'VT_MOVEN' + else + Name := 'VT_MOVES'; + end; + end; + + // Now load the cursor and apply it. + NewCursor := LoadCursor(HInstance, PChar(Name)); + if FPanningCursor <> NewCursor then + begin + DeleteObject(FPanningCursor); + FPanningCursor := NewCursor; + Windows.SetCursor(FPanningCursor); + end + else + DeleteObject(NewCursor); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AdviseChangeEvent(StructureChange: Boolean; Node: PVirtualNode; Reason: TChangeReason); + +// Used to register a delayed change event. If StructureChange is False then we have a selection change event (without +// a specific reason) otherwise it is a structure change. + +begin + if StructureChange then + begin + if tsStructureChangePending in FStates then + StopTimer(StructureChangeTimer) + else + DoStateChange([tsStructureChangePending]); + + FLastStructureChangeNode := Node; + if FLastStructureChangeReason = crIgnore then + FLastStructureChangeReason := Reason + else + if Reason <> crIgnore then + FLastStructureChangeReason := crAccumulated; + end + else + begin + if tsChangePending in FStates then + StopTimer(ChangeTimer) + else + DoStateChange([tsChangePending]); + + FLastChangedNode := Node; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.AllocateInternalDataArea(Size: Cardinal): Cardinal; + +// Simple registration method to be called by each descendant to claim their internal data area. +// Result is the offset from the begin of the node to the internal data area of the calling tree class. + +begin + Assert((FRoot = nil) or (FRoot.ChildCount = 0), 'Internal data allocation must be done before any node is created.'); + + Result := TreeNodeSize + FTotalInternalDataSize; + Inc(FTotalInternalDataSize, (Size + (SizeOf(Pointer) - 1)) and not (SizeOf(Pointer) - 1)); + InitRootNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Animate(Steps, Duration: Cardinal; Callback: TVTAnimationCallback; Data: Pointer); + +// This method does the calculation part of an animation as used for node toggling and hint animations. +// Steps is the maximum amount of animation steps to do and Duration determines the milliseconds the animation +// has to run. Callback is a task specific method which is called in the loop for every step and Data is simply +// something to pass on to the callback. +// The callback is called with the current step, the current step size and the Data parameter. Since the step amount +// as well as the step size are possibly adjusted during the animation, it is impossible to determine if the current +// step is the last step, even if the original step amount is known. To solve this problem the callback will be +// called after the loop has finished with a step size of 0 indicating so to execute any post processing. + +var + StepSize, + RemainingTime, + RemainingSteps, + NextTimeStep, + CurrentStep, + StartTime, + CurrentTime: Cardinal; + +begin + if not (tsInAnimation in FStates) and (Duration > 0) then + begin + DoStateChange([tsInAnimation]); + try + RemainingTime := Duration; + RemainingSteps := Steps; + + // Determine the initial step size which is either 1 if the needed steps are less than the number of + // steps possible given by the duration or > 1 otherwise. + StepSize := Round(Max(1, RemainingSteps / Duration)); + RemainingSteps := RemainingSteps div StepSize; + CurrentStep := 0; + + while (RemainingSteps > 0) and (RemainingTime > 0) and not Application.Terminated do + begin + StartTime := timeGetTime; + NextTimeStep := StartTime + RemainingTime div RemainingSteps; + if not Callback(CurrentStep, StepSize, Data) then + Break; + + // Keep duration for this step for rest calculation. + CurrentTime := timeGetTime; + // Wait until the calculated time has been reached. + while CurrentTime < NextTimeStep do + CurrentTime := timeGetTime; + + // Subtract the time this step really needed. + if RemainingTime >= CurrentTime - StartTime then + begin + Dec(RemainingTime, CurrentTime - StartTime); + Dec(RemainingSteps); + end + else + begin + RemainingTime := 0; + RemainingSteps := 0; + end; + // If the remaining time per step is less than one time step then we have to decrease the + // step count and increase the step size. + if (RemainingSteps > 0) and ((RemainingTime div RemainingSteps) < 1) then + begin + repeat + Inc(StepSize); + RemainingSteps := RemainingTime div StepSize; + until (RemainingSteps <= 0) or ((RemainingTime div RemainingSteps) >= 1); + end; + CurrentStep := Cardinal(Steps) - RemainingSteps; + end; + + if not Application.Terminated then + Callback(0, 0, Data); + finally + DoStateChange([], [tsCancelHintAnimation, tsInAnimation]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.StartOperation(OperationKind: TVTOperationKind); + +// Called to indicate that a long-running operation has been started. + +begin + Inc(FOperationCount); + DoStartOperation(OperationKind); + if FOperationCount = 1 then + FOperationCanceled := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CalculateSelectionRect(X, Y: Integer): Boolean; + +// Recalculates old and new selection rectangle given that X, Y are new mouse coordinates. +// Returns True if there was a change since the last call. + +var + MaxValue: Integer; + +begin + if tsDrawSelecting in FStates then + FLastSelRect := FNewSelRect; + FNewSelRect.BottomRight := Point(X + FEffectiveOffsetX, Y - FOffsetY); + if FNewSelRect.Right < 0 then + FNewSelRect.Right := 0; + if FNewSelRect.Bottom < 0 then + FNewSelRect.Bottom := 0; + MaxValue := ClientWidth; + if FRangeX > Cardinal(MaxValue) then + MaxValue := FRangeX; + if FNewSelRect.Right > MaxValue then + FNewSelRect.Right := MaxValue; + MaxValue := ClientHeight; + if FRangeY > Cardinal(MaxValue) then + MaxValue := FRangeY; + if FNewSelRect.Bottom > MaxValue then + FNewSelRect.Bottom := MaxValue; + + Result := not CompareMem(@FLastSelRect, @FNewSelRect, SizeOf(FNewSelRect)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CanAutoScroll: Boolean; + +// Determines if auto scrolling is currently allowed. + +var + IsDropTarget: Boolean; + IsDrawSelecting: Boolean; + IsWheelPanning: Boolean; + +begin + // Don't scroll the client area if the header is currently doing tracking or dragging. + // Do auto scroll only if there is a draw selection in progress or the tree is the current drop target or + // wheel panning/scrolling is active. + IsDropTarget := Assigned(FDragManager) and DragManager.IsDropTarget; + IsDrawSelecting := [tsDrawSelPending, tsDrawSelecting] * FStates <> []; + IsWheelPanning := [tsWheelPanning, tsWheelScrolling] * FStates <> []; + Result := ((toAutoScroll in FOptions.FAutoOptions) or IsWheelPanning) and + (FHeader.FStates = []) and (IsDrawSelecting or IsDropTarget or (tsVCLDragging in FStates) or IsWheelPanning); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CanShowDragImage: Boolean; + +// Determines whether a drag image should be shown. + +begin + Result := FDragImageKind <> diNoImage; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex): Boolean; + +begin + Result := (toNodeHeightResize in FOptions.FMiscOptions) and Assigned(Node) and (Node <> FRoot) and + (Column > NoColumn) and (coFixed in FHeader.FColumns[Column].FOptions); + DoCanSplitterResizeNode(P, Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Change(Node: PVirtualNode); + +begin + AdviseChangeEvent(False, Node, crIgnore); + + if FUpdateCount = 0 then + begin + if (FChangeDelay > 0) and not (tsSynchMode in FStates) then + SetTimer(Handle, ChangeTimer, FChangeDelay, nil) + else + DoChange(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ChangeScale(M, D: Integer); + +var + DoScale: Boolean; + +begin + inherited; + + if (M <> D) and (toAutoChangeScale in FOptions.FAutoOptions) then + begin + if (csLoading in ComponentState) then + DoScale := tsNeedScale in FStates + else + DoScale := True; + if DoScale then + begin + FDefaultNodeHeight := MulDiv(FDefaultNodeHeight, M, D); + FHeader.ChangeScale(M, D); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CheckParentCheckState(Node: PVirtualNode; NewCheckState: TCheckState): Boolean; + +// Checks all siblings of node to determine which check state Node's parent must get. + +var + CheckCount, + BoxCount: Cardinal; + PartialCheck: Boolean; + Run: PVirtualNode; + +begin + CheckCount := 0; + BoxCount := 0; + PartialCheck := False; + Run := Node.Parent.FirstChild; + while Assigned(Run) do + begin + if Run = Node then + begin + // The given node cannot be checked because it does not yet have its new check state (as this depends + // on the outcome of this method). Instead NewCheckState is used as this contains the new state the node + // will get if this method returns True. + if Run.CheckType in [ctCheckBox, ctTriStateCheckBox] then + begin + Inc(BoxCount); + if NewCheckState in [csCheckedNormal, csCheckedPressed] then + Inc(CheckCount); + PartialCheck := PartialCheck or (NewCheckState = csMixedNormal); + end; + end + else + if Run.CheckType in [ctCheckBox, ctTriStateCheckBox] then + begin + Inc(BoxCount); + if Run.CheckState in [csCheckedNormal, csCheckedPressed] then + Inc(CheckCount); + PartialCheck := PartialCheck or (Run.CheckState = csMixedNormal); + end; + Run := Run.NextSibling; + end; + + if (CheckCount = 0) and not PartialCheck then + NewCheckState := csUncheckedNormal + else + if CheckCount < BoxCount then + NewCheckState := csMixedNormal + else + NewCheckState := csCheckedNormal; + + Node := Node.Parent; + Result := DoChecking(Node, NewCheckState); + if Result then + begin + DoCheckClick(Node, NewCheckState); + // Recursively adjust parent of parent. + with Node^ do + begin + if not (vsInitialized in Parent.States) then + InitNode(Parent); + if ([vsChecking, vsDisabled] * Parent.States = []) and (Parent <> FRoot) and + (Parent.CheckType = ctTriStateCheckBox) then + Result := CheckParentCheckState(Node, NewCheckState); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ClearTempCache; + +// make sure the temporary node cache is in a reliable state + +begin + FTempNodeCache := nil; + FTempNodeCount := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; + +// Returns True if the given column is to be considered as being empty. This will usually be determined by +// descendants as the base tree implementation has not enough information to decide. + +begin + Result := True; + if Assigned(FOnGetCellIsEmpty) then + FOnGetCellIsEmpty(Self, Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ComputeRTLOffset(ExcludeScrollbar: Boolean): Integer; + +// Computes the horizontal offset needed when all columns are automatically right aligned (in RTL bidi mode). +// ExcludeScrollbar determines if the left-hand vertical scrollbar is to be included (if visible) or not. + +var + HeaderWidth: Integer; + ScrollbarVisible: Boolean; +begin + ScrollbarVisible := (Integer(FRangeY) > ClientHeight) and (ScrollbarOptions.Scrollbars in [ssVertical, ssBoth]); + if ScrollbarVisible then + Result := GetSystemMetrics(SM_CXVSCROLL) + else + Result := 0; + + // Make everything right aligned. + HeaderWidth := FHeaderRect.Right - FHeaderRect.Left; + if Integer(FRangeX) + Result <= HeaderWidth then + Result := HeaderWidth - Integer(FRangeX); + // Otherwise take only left-hand vertical scrollbar into account. + + if ScrollbarVisible and ExcludeScrollbar then + Dec(Result, GetSystemMetrics(SM_CXVSCROLL)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CountLevelDifference(Node1, Node2: PVirtualNode): Integer; + +// This method counts how many indentation levels the given nodes are apart. If both nodes have the same parent then the +// difference is 0 otherwise the result is basically GetNodeLevel(Node2) - GetNodeLevel(Node1), but with sign. +// If the result is negative then Node2 is less intended than Node1. + +var + Level1, Level2: Integer; + +begin + Assert(Assigned(Node1) and Assigned(Node2), 'Both nodes must be Assigned.'); + + Level1 := 0; + while Node1.Parent <> FRoot do + begin + Inc(Level1); + Node1 := Node1.Parent; + end; + + Level2 := 0; + while Node2.Parent <> FRoot do + begin + Inc(Level2); + Node2 := Node2.Parent; + end; + + Result := Level2 - Level1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CountVisibleChildren(Node: PVirtualNode): Cardinal; + +// Returns the number of visible child nodes of the given node. + +begin + Result := 0; + + // The node's direct children... + if vsExpanded in Node.States then + begin + // ...and their children. + Node := Node.FirstChild; + while Assigned(Node) do + begin + if vsVisible in Node.States then + Inc(Result, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + Node := Node.NextSibling; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CreateParams(var Params: TCreateParams); + +const + ScrollBar: array[TScrollStyle] of Cardinal = (0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL or WS_VSCROLL); + +begin + inherited CreateParams(Params); + + with Params do + begin + Style := Style or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or ScrollBar[ScrollBarOptions.FScrollBars]; + if toFullRepaintOnResize in FOptions.FMiscOptions then + WindowClass.style := WindowClass.style or CS_HREDRAW or CS_VREDRAW + else + WindowClass.style := WindowClass.style and not (CS_HREDRAW or CS_VREDRAW); + if FBorderStyle = bsSingle then + begin + if Ctl3D then + begin + ExStyle := ExStyle or WS_EX_CLIENTEDGE; + Style := Style and not WS_BORDER; + end + else + Style := Style or WS_BORDER; + end + else + Style := Style and not WS_BORDER; + + AddBiDiModeExStyle(ExStyle); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CreateWnd; + +// Initializes data which depends on a valid window handle. + +begin + DoStateChange([tsWindowCreating]); + inherited; + DoStateChange([], [tsWindowCreating]); + + if ThemeServices.ThemesEnabled and (toThemeAware in TreeOptions.PaintOptions) then + begin + DoStateChange([tsUseThemes]); + if (toUseExplorerTheme in FOptions.FPaintOptions) and IsWinVistaOrAbove then + begin + DoStateChange([tsUseExplorerTheme]); + SetWindowTheme(Handle, 'explorer', nil); + end + else + DoStateChange([], [tsUseExplorerTheme]); + end + else + DoStateChange([], [tsUseThemes, tsUseExplorerTheme]); + + // Because of the special recursion and update stopper when creating the window (or resizing it) + // we have to manually trigger the auto size calculation here. + if hsNeedScaling in FHeader.FStates then + FHeader.RescaleHeader; + if hoAutoResize in FHeader.FOptions then + FHeader.FColumns.AdjustAutoSize(InvalidColumn); + + PrepareBitmaps(True, True); + + // Register tree as OLE drop target. + if not (csDesigning in ComponentState) and (toAcceptOLEDrop in FOptions.FMiscOptions) then + RegisterDragDrop(Handle, DragManager as IDropTarget); + + UpdateScrollBars(True); + UpdateHeaderRect; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DefineProperties(Filer: TFiler); + +// There were heavy changes in some properties during development of VT. This method helps to make migration easier +// by reading old properties manually and put them into the new properties as appropriate. +// Note: these old properties are never written again and silently disappear. +// June 2002: Meanwhile another task is done here too: working around the problem that TCollection is not streamed +// correctly when using Visual Form Inheritance (VFI). + +var + StoreIt: Boolean; + +begin + inherited; + + // The header can prevent writing columns altogether. + if FHeader.CanWriteColumns then + begin + // Check if we inherit from an ancestor form (Visual Form Inheritance). + StoreIt := Filer.Ancestor = nil; + // If there is an ancestor then save columns only if they are different to the base set. + if not StoreIt then + StoreIt := not FHeader.Columns.Equals(TBaseVirtualTree(Filer.Ancestor).FHeader.Columns); + end + else + StoreIt := False; + + Filer.DefineProperty('Columns', FHeader.ReadColumns, FHeader.WriteColumns, StoreIt); + Filer.DefineProperty('Options', ReadOldOptions, nil, False); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DetermineDropMode(const P: TPoint; var HitInfo: THitInfo; var NodeRect: TRect): TDropMode; + +// Determine the DropMode. + +var + ImageHit: Boolean; + LabelHit: Boolean; + ItemHit: Boolean; + +begin + ImageHit := HitInfo.HitPositions * [hiOnNormalIcon, hiOnStateIcon] <> []; + LabelHit := hiOnItemLabel in HitInfo.HitPositions; + ItemHit := ((hiOnItem in HitInfo.HitPositions) and ((toFullRowDrag in FOptions.FMiscOptions) or + (toFullRowSelect in FOptions.FSelectionOptions))); + // In report mode only direct hits of the node captions/images in the main column are accepted as hits. + if (toReportMode in FOptions.FMiscOptions) and not (ItemHit or ((LabelHit or ImageHit) and + (HitInfo.HitColumn = FHeader.MainColumn))) then + HitInfo.HitNode := nil; + + if Assigned(HitInfo.HitNode) then + begin + if ItemHit or LabelHit or ImageHit or not (toShowDropmark in FOptions.FPaintOptions) then + Result := dmOnNode + else + if ((NodeRect.Top + NodeRect.Bottom) div 2) > P.Y then + Result := dmAbove + else + Result := dmBelow; + end + else + Result := dmNowhere; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DetermineHiddenChildrenFlag(Node: PVirtualNode); + +// Update the hidden children flag of the given node. + +var + Run: PVirtualNode; + +begin + if Node.ChildCount = 0 then + begin + if vsHasChildren in Node.States then + Exclude(Node.States, vsAllChildrenHidden) + else + Include(Node.States, vsAllChildrenHidden); + end + else + begin + // Iterate through all siblings and stop when one visible is found. + Run := Node.FirstChild; + while Assigned(Run) and not IsEffectivelyVisible[Run] do + Run := Run.NextSibling; + if Assigned(Run) then + Exclude(Node.States, vsAllChildrenHidden) + else + Include(Node.States, vsAllChildrenHidden); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DetermineHiddenChildrenFlagAllNodes; + +var + Run: PVirtualNode; + +begin + Run := GetFirstNoInit(False); + while Assigned(Run) do + begin + DetermineHiddenChildrenFlag(Run); + Run := GetNextNoInit(Run); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DetermineHitPositionLTR(var HitInfo: THitInfo; Offset, Right: Integer; + Alignment: TAlignment); + +// This method determines the hit position within a node with left-to-right orientation. + +var + MainColumnHit: Boolean; + Run: PVirtualNode; + Indent, + TextWidth, + ImageOffset: Integer; + +begin + MainColumnHit := HitInfo.HitColumn = FHeader.MainColumn; + Indent := 0; + + // If columns are not used or the main column is hit then the tree indentation must be considered too. + if MainColumnHit then + begin + if toFixedIndent in FOptions.FPaintOptions then + Indent := FIndent + else + begin + Run := HitInfo.HitNode; + while (Run.Parent <> FRoot) do + begin + Inc(Indent, FIndent); + Run := Run.Parent; + end; + if toShowRoot in FOptions.FPaintOptions then + Inc(Indent, FIndent); + end; + end; + + if Offset < Indent then + begin + // Position is to the left of calculated indentation which can only happen for the main column. + // Check whether it corresponds to a button/checkbox. + if (toShowButtons in FOptions.FPaintOptions) and (vsHasChildren in HitInfo.HitNode.States) then + begin + // Position of button is interpreted very generously to avoid forcing the user + // to click exactly into the 9x9 pixels area. The entire node height and one full + // indentation level is accepted as button hit. + if Offset >= Indent - Integer(FIndent) then + Include(HitInfo.HitPositions, hiOnItemButton); + if Offset >= Indent - FPlusBM.Width then + Include(HitInfo.HitPositions, hiOnItemButtonExact); + end; + // no button hit so position is on indent + if HitInfo.HitPositions = [] then + Include(HitInfo.HitPositions, hiOnItemIndent); + end + else + begin + // The next hit positions can be: + // - on the check box + // - on the state image + // - on the normal image + // - to the left of the text area + // - on the label or + // - to the right of the text area + // (in this order). + + // In report mode no hit other than in the main column is possible. + if MainColumnHit or not (toReportMode in FOptions.FMiscOptions) then + begin + ImageOffset := Indent + FMargin; + + // Check support is only available for the main column. + if MainColumnHit and (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages) and + (HitInfo.HitNode.CheckType <> ctNone) then + Inc(ImageOffset, FCheckImages.Width + 2); + + if MainColumnHit and (Offset < ImageOffset) then + begin + HitInfo.HitPositions := [hiOnItem]; + if (HitInfo.HitNode.CheckType <> ctNone) then + Include(HitInfo.HitPositions, hiOnItemCheckBox); + end + else + begin + if Assigned(FStateImages) and HasImage(HitInfo.HitNode, ikState, HitInfo.HitColumn) then + Inc(ImageOffset, FStateImages.Width + 2); + if Offset < ImageOffset then + Include(HitInfo.HitPositions, hiOnStateIcon) + else + begin + if Assigned(FImages) and HasImage(HitInfo.HitNode, ikNormal, HitInfo.HitColumn) then + Inc(ImageOffset, FImages.Width + 2); + if Offset < ImageOffset then + Include(HitInfo.HitPositions, hiOnNormalIcon) + else + begin + // ImageOffset contains now the left border of the node label area. This is used to calculate the + // correct alignment in the column. + TextWidth := DoGetNodeWidth(HitInfo.HitNode, HitInfo.HitColumn); + + // Check if the text can be aligned at all. This is only possible if there is enough room + // in the remaining text rectangle. + if TextWidth > Right - ImageOffset then + Include(HitInfo.HitPositions, hiOnItemLabel) + else + begin + case Alignment of + taCenter: + begin + Indent := (ImageOffset + Right - TextWidth) div 2; + if Offset < Indent then + Include(HitInfo.HitPositions, hiOnItemLeft) + else + if Offset < Indent + TextWidth then + Include(HitInfo.HitPositions, hiOnItemLabel) + else + Include(HitInfo.HitPositions, hiOnItemRight) + end; + taRightJustify: + begin + Indent := Right - TextWidth; + if Offset < Indent then + Include(HitInfo.HitPositions, hiOnItemLeft) + else + Include(HitInfo.HitPositions, hiOnItemLabel); + end; + else // taLeftJustify + if Offset < ImageOffset + TextWidth then + Include(HitInfo.HitPositions, hiOnItemLabel) + else + Include(HitInfo.HitPositions, hiOnItemRight); + end; + end; + end; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DetermineHitPositionRTL(var HitInfo: THitInfo; Offset, Right: Integer; Alignment: TAlignment); + +// This method determines the hit position within a node with right-to-left orientation. + +var + MainColumnHit: Boolean; + Run: PVirtualNode; + Indent, + TextWidth, + ImageOffset: Integer; + +begin + MainColumnHit := HitInfo.HitColumn = FHeader.MainColumn; + + // If columns are not used or the main column is hit then the tree indentation must be considered too. + if MainColumnHit then + begin + if toFixedIndent in FOptions.FPaintOptions then + Dec(Right, FIndent) + else + begin + Run := HitInfo.HitNode; + while (Run.Parent <> FRoot) do + begin + Dec(Right, FIndent); + Run := Run.Parent; + end; + if toShowRoot in FOptions.FPaintOptions then + Dec(Right, FIndent); + end; + end; + + if Offset >= Right then + begin + // Position is to the right of calculated indentation which can only happen for the main column. + // Check whether it corresponds to a button/checkbox. + if (toShowButtons in FOptions.FPaintOptions) and (vsHasChildren in HitInfo.HitNode.States) then + begin + // Position of button is interpreted very generously to avoid forcing the user + // to click exactly into the 9x9 pixels area. The entire node height and one full + // indentation level is accepted as button hit. + if Offset <= Right + Integer(FIndent) then + Include(HitInfo.HitPositions, hiOnItemButton); + if Offset <= Right + FPlusBM.Width then + Include(HitInfo.HitPositions, hiOnItemButtonExact); + end; + // no button hit so position is on indent + if HitInfo.HitPositions = [] then + Include(HitInfo.HitPositions, hiOnItemIndent); + end + else + begin + // The next hit positions can be: + // - on the check box + // - on the state image + // - on the normal image + // - to the left of the text area + // - on the label or + // - to the right of the text area + // (in this order). + + // In report mode no hit other than in the main column is possible. + if MainColumnHit or not (toReportMode in FOptions.FMiscOptions) then + begin + ImageOffset := Right - FMargin; + + // Check support is only available for the main column. + if MainColumnHit and (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages) and + (HitInfo.HitNode.CheckType <> ctNone) then + Dec(ImageOffset, FCheckImages.Width + 2); + + if MainColumnHit and (Offset > ImageOffset) then + begin + HitInfo.HitPositions := [hiOnItem]; + if (HitInfo.HitNode.CheckType <> ctNone) then + Include(HitInfo.HitPositions, hiOnItemCheckBox); + end + else + begin + if Assigned(FStateImages) and HasImage(HitInfo.HitNode, ikState, HitInfo.HitColumn) then + Dec(ImageOffset, FStateImages.Width + 2); + if Offset > ImageOffset then + Include(HitInfo.HitPositions, hiOnStateIcon) + else + begin + if Assigned(FImages) and HasImage(HitInfo.HitNode, ikNormal, HitInfo.HitColumn) then + Dec(ImageOffset, FImages.Width + 2); + if Offset > ImageOffset then + Include(HitInfo.HitPositions, hiOnNormalIcon) + else + begin + // ImageOffset contains now the right border of the node label area. This is used to calculate the + // correct alignment in the column. + TextWidth := DoGetNodeWidth(HitInfo.HitNode, HitInfo.HitColumn); + + // Check if the text can be aligned at all. This is only possible if there is enough room + // in the remaining text rectangle. + if TextWidth > ImageOffset then + Include(HitInfo.HitPositions, hiOnItemLabel) + else + begin + // Consider bidi mode here. In RTL context does left alignment actually mean right alignment + // and vice versa. + ChangeBiDiModeAlignment(Alignment); + + case Alignment of + taCenter: + begin + Indent := (ImageOffset - TextWidth) div 2; + if Offset < Indent then + Include(HitInfo.HitPositions, hiOnItemLeft) + else + if Offset < Indent + TextWidth then + Include(HitInfo.HitPositions, hiOnItemLabel) + else + Include(HitInfo.HitPositions, hiOnItemRight) + end; + taRightJustify: + begin + Indent := ImageOffset - TextWidth; + if Offset < Indent then + Include(HitInfo.HitPositions, hiOnItemLeft) + else + Include(HitInfo.HitPositions, hiOnItemLabel); + end; + else // taLeftJustify + if Offset > TextWidth then + Include(HitInfo.HitPositions, hiOnItemRight) + else + Include(HitInfo.HitPositions, hiOnItemLabel); + end; + end; + end; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DetermineLineImageAndSelectLevel(Node: PVirtualNode; var LineImage: TLineImage): Integer; + +// This method is used during paint cycles and initializes an array of line type IDs. These IDs are used to paint +// the tree lines in front of the given node. +// Additionally an initial count of selected parents is determined and returned which is used for specific painting. + +var + X: Integer; + Indent: Integer; + Run: PVirtualNode; + +begin + Result := 0; + if toShowRoot in FOptions.FPaintOptions then + X := 1 + else + X := 0; + Run := Node; + // Determine indentation level of top node. + while Run.Parent <> FRoot do + begin + Inc(X); + Run := Run.Parent; + // Count selected nodes (FRoot is never selected). + if vsSelected in Run.States then + Inc(Result); + end; + + // Set initial size of line index array, this will automatically initialized all entries to ltNone. + SetLength(LineImage, X); + Indent := X - 1; + + // Only use lines if requested. + if (toShowTreeLines in FOptions.FPaintOptions) and + (not (toHideTreeLinesIfThemed in FOptions.FPaintOptions) or not (tsUseThemes in FStates)) then + begin + if toChildrenAbove in FOptions.FPaintOptions then + begin + Dec(X); + if not HasVisiblePreviousSibling(Node) then + begin + if (Node.Parent <> FRoot) or HasVisibleNextSibling(Node) then + LineImage[X] := ltBottomRight + else + LineImage[X] := ltRight; + end + else + if (Node.Parent = FRoot) and (not HasVisibleNextSibling(Node)) then + LineImage[X] := ltTopRight + else + LineImage[X] := ltTopDownRight; + + // Now go up to the root to determine the rest. + Run := Node.Parent; + while Run <> FRoot do + begin + Dec(X); + if HasVisiblePreviousSibling(Run) then + LineImage[X] := ltTopDown + else + LineImage[X] := ltNone; + + Run := Run.Parent; + end; + end + else + begin + // Start over parent traversal if necessary. + Run := Node; + + if Run.Parent <> FRoot then + begin + // The very last image (the one immediately before the item label) is different. + if HasVisibleNextSibling(Run) then + LineImage[X - 1] := ltTopDownRight + else + LineImage[X - 1] := ltTopRight; + Run := Run.Parent; + + // Now go up all parents. + repeat + if Run.Parent = FRoot then + Break; + Dec(X); + if HasVisibleNextSibling(Run) then + LineImage[X - 1] := ltTopDown + else + LineImage[X - 1] := ltNone; + Run := Run.Parent; + until False; + end; + + // Prepare root level. Run points at this stage to a top level node. + if (toShowRoot in FOptions.FPaintOptions) and ((toShowTreeLines in FOptions.FPaintOptions) and + (not (toHideTreeLinesIfThemed in FOptions.FPaintOptions) or not (tsUseThemes in FStates))) then + begin + // Is the top node a root node? + if Run = Node then + begin + // First child gets the bottom-right bitmap if it isn't also the only child. + if IsFirstVisibleChild(FRoot, Run) then + // Is it the only child? + if IsLastVisibleChild(FRoot, Run) then + LineImage[0] := ltRight + else + LineImage[0] := ltBottomRight + else + // real last child + if IsLastVisibleChild(FRoot, Run) then + LineImage[0] := ltTopRight + else + LineImage[0] := ltTopDownRight; + end + else + begin + // No, top node is not a top level node. So we need different painting. + if HasVisibleNextSibling(Run) then + LineImage[0] := ltTopDown + else + LineImage[0] := ltNone; + end; + end; + end; + end; + + if (tsUseExplorerTheme in FStates) and HasChildren[Node] and (Indent >= 0) then + LineImage[Indent] := ltNone; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DetermineNextCheckState(CheckType: TCheckType; CheckState: TCheckState): TCheckState; + +// Determines the next check state in case the user click the check image or pressed the space key. + +begin + case CheckType of + ctTriStateCheckBox, + ctCheckBox: + if CheckState = csCheckedNormal then + Result := csUncheckedNormal + else + Result := csCheckedNormal; + ctRadioButton: + Result := csCheckedNormal; + ctButton: + Result := csUncheckedNormal; + else + Result := csMixedNormal; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DetermineScrollDirections(X, Y: Integer): TScrollDirections; + +// Determines which direction the client area must be scrolled depending on the given position. + +begin + Result:= []; + + if CanAutoScroll then + begin + // Calculation for wheel panning/scrolling is a bit different to normal auto scroll. + if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then + begin + if (X - FLastClickPos.X) < -8 then + Include(Result, sdLeft); + if (X - FLastClickPos.X) > 8 then + Include(Result, sdRight); + + if (Y - FLastClickPos.Y) < -8 then + Include(Result, sdUp); + if (Y - FLastClickPos.Y) > 8 then + Include(Result, sdDown); + end + else + begin + if (X < Integer(FDefaultNodeHeight)) and (FEffectiveOffsetX <> 0) then + Include(Result, sdLeft); + if (ClientWidth + FEffectiveOffsetX < Integer(FRangeX)) and (X > ClientWidth - Integer(FDefaultNodeHeight)) then + Include(Result, sdRight); + + if (Y < Integer(FDefaultNodeHeight)) and (FOffsetY <> 0) then + Include(Result, sdUp); + if (ClientHeight - FOffsetY < Integer(FRangeY)) and (Y > ClientHeight - Integer(FDefaultNodeHeight)) then + Include(Result, sdDown); + + // Since scrolling during dragging is not handled via the timer we do a check here whether the auto + // scroll timeout already has elapsed or not. + if (Result <> []) and + ((Assigned(FDragManager) and DragManager.IsDropTarget) or + (FindDragTarget(Point(X, Y), False) = Self)) then + begin + if FDragScrollStart = 0 then + FDragScrollStart := timeGetTime; + // Reset any scroll direction to avoid scroll in the case the user is dragging and the auto scroll time has not + // yet elapsed. + if ((timeGetTime - FDragScrollStart) < FAutoScrollDelay) then + Result := []; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAdvancedHeaderDraw(var PaintInfo: THeaderPaintInfo; const Elements: THeaderPaintElements); + +begin + if Assigned(FOnAdvancedHeaderDraw) then + FOnAdvancedHeaderDraw(FHeader, PaintInfo, Elements); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAfterCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; CellRect: TRect); + +begin + if Assigned(FOnAfterCellPaint) then + FOnAfterCellPaint(Self, Canvas, Node, Column, CellRect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAfterItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); + +begin + if Assigned(FOnAfterItemErase) then + FOnAfterItemErase(Self, Canvas, Node, ItemRect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAfterItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect); + +begin + if Assigned(FOnAfterItemPaint) then + FOnAfterItemPaint(Self, Canvas, Node, ItemRect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAfterPaint(Canvas: TCanvas); + +begin + if Assigned(FOnAfterPaint) then + FOnAfterPaint(Self, Canvas); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoAutoScroll(X, Y: Integer); + +begin + FScrollDirections := DetermineScrollDirections(X, Y); + + if FStates * [tsWheelPanning, tsWheelScrolling] = [] then + begin + if FScrollDirections = [] then + begin + if ((FStates * [tsScrollPending, tsScrolling]) <> []) then + begin + StopTimer(ScrollTimer); + DoStateChange([], [tsScrollPending, tsScrolling]); + end; + end + else + begin + // start auto scroll if not yet done + if (FStates * [tsScrollPending, tsScrolling]) = [] then + begin + DoStateChange([tsScrollPending]); + SetTimer(Handle, ScrollTimer, FAutoScrollDelay, nil); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoBeforeDrag(Node: PVirtualNode; Column: TColumnIndex): Boolean; + +begin + Result := False; + if Assigned(FOnDragAllowed) then + FOnDragAllowed(Self, Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoBeforeCellPaint(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect); + +var + UpdateRect: TRect; + +begin + if Assigned(FOnBeforeCellPaint) then + begin + if CellPaintMode = cpmGetContentMargin then + begin + // Prevent drawing if we are only about to get the margin. As this also clears the update rect we need to save it. + GetUpdateRect(Handle, UpdateRect, False); + SetUpdateState(True); + end; + + FOnBeforeCellPaint(Self, Canvas, Node, Column, CellPaintMode, CellRect, ContentRect); + + if CellPaintMode = cpmGetContentMargin then + begin + SetUpdateState(False); + InvalidateRect(Handle, @UpdateRect, False); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoBeforeItemErase(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect; var Color: TColor; + var EraseAction: TItemEraseAction); + +begin + if Assigned(FOnBeforeItemErase) then + FOnBeforeItemErase(Self, Canvas, Node, ItemRect, Color, EraseAction); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoBeforeItemPaint(Canvas: TCanvas; Node: PVirtualNode; ItemRect: TRect): Boolean; + +begin + // By default custom draw will not be used, so the tree handles drawing the node. + Result := False; + if Assigned(FOnBeforeItemPaint) then + FOnBeforeItemPaint(Self, Canvas, Node, ItemRect, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoBeforePaint(Canvas: TCanvas); + +begin + if Assigned(FOnBeforePaint) then + FOnBeforePaint(Self, Canvas); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCancelEdit: Boolean; + +// Called when the current edit action or a pending edit must be cancelled. + +begin + StopTimer(EditTimer); + DoStateChange([], [tsEditPending]); + Result := (tsEditing in FStates) and FEditLink.CancelEdit; + if Result then + begin + DoStateChange([], [tsEditing]); + if Assigned(FOnEditCancelled) then + FOnEditCancelled(Self, FEditColumn); + if not (csDestroying in ComponentState) then + FEditLink := nil; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoCanEdit(Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean); + +begin + if Assigned(FOnEditing) then + FOnEditing(Self, Node, Column, Allowed); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoCanSplitterResizeNode(P: TPoint; Node: PVirtualNode; Column: TColumnIndex; + var Allowed: Boolean); + +begin + if Assigned(FOnCanSplitterResizeNode) then + FOnCanSplitterResizeNode(Self, P, Node, Column, Allowed); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoChange(Node: PVirtualNode); + +begin + StopTimer(ChangeTimer); + if Assigned(FOnChange) then + FOnChange(Self, Node); + + // This is a good place to reset the cached node. This is the same as the node passed in here. + // This is necessary to allow descendants to override this method and get the node then. + DoStateChange([], [tsChangePending]); + FLastChangedNode := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoCheckClick(Node: PVirtualNode; NewCheckState: TCheckState); + +begin + if ChangeCheckState(Node, NewCheckState) then + DoChecked(Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoChecked(Node: PVirtualNode); + +begin + if Assigned(FOnChecked) then + FOnChecked(Self, Node); + if Assigned(FAccessibleItem) then + NotifyWinEvent(EVENT_OBJECT_STATECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoChecking(Node: PVirtualNode; var NewCheckState: TCheckState): Boolean; + +// Determines if a node is allowed to change its check state to NewCheckState. + +begin + if toReadOnly in FOptions.FMiscOptions then + Result := False + else + begin + Result := True; + if Assigned(FOnChecking) then + FOnChecking(Self, Node, NewCheckState, Result); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoCollapsed(Node: PVirtualNode); + +begin + if Assigned(FOnCollapsed) then + FOnCollapsed(Self, Node); + + if Assigned(FAccessibleItem) then + NotifyWinEvent(EVENT_OBJECT_STATECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCollapsing(Node: PVirtualNode): Boolean; + +begin + Result := True; + if Assigned(FOnCollapsing) then + FOnCollapsing(Self, Node, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoColumnClick(Column: TColumnIndex; Shift: TShiftState); + +begin + if Assigned(FOnColumnClick) then + FOnColumnClick(Self, Column, Shift); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoColumnDblClick(Column: TColumnIndex; Shift: TShiftState); + +begin + if Assigned(FOnColumnDblClick) then + FOnColumnDblClick(Self, Column, Shift); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoColumnResize(Column: TColumnIndex); + +var + R: TRect; + Run: PVirtualNode; + +begin + if not (csLoading in ComponentState) and HandleAllocated then + begin + // Reset all vsHeightMeasured flags if we are in multiline mode. + Run := GetFirstInitialized; + while Assigned(Run) do + begin + if vsMultiline in Run.States then + Exclude(Run.States, vsHeightMeasured); + Run := GetNextInitialized(Run); + end; + + UpdateHorizontalScrollBar(True); + if Column > NoColumn then + begin + // Invalidate client area from the current column all to the right (or left in RTL mode). + R := ClientRect; + if not (toAutoSpanColumns in FOptions.FAutoOptions) then + if UseRightToLeftAlignment then + R.Right := FHeader.Columns[Column].Left + FHeader.Columns[Column].Width + ComputeRTLOffset + else + R.Left := FHeader.Columns[Column].Left; + InvalidateRect(Handle, @R, False); + FHeader.Invalidate(FHeader.Columns[Column], True); + end; + if [hsColumnWidthTracking, hsResizing] * FHeader.States = [hsColumnWidthTracking] then + UpdateWindow(Handle); + + if not (tsUpdating in FStates) then + UpdateDesigner; // design time only + + if Assigned(FOnColumnResize) and not (hsResizing in FHeader.States) then + FOnColumnResize(FHeader, Column); + + // If the tree is currently in edit state then notify edit link. + if tsEditing in FStates then + UpdateEditBounds; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCompare(Node1, Node2: PVirtualNode; Column: TColumnIndex): Integer; + +begin + Result := 0; + if Assigned(FOnCompareNodes) then + FOnCompareNodes(Self, Node1, Node2, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCreateDataObject: IDataObject; + +begin + Result := nil; + if Assigned(FOnCreateDataObject) then + FOnCreateDataObject(Self, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCreateDragManager: IVTDragManager; + +begin + Result := nil; + if Assigned(FOnCreateDragManager) then + FOnCreateDragManager(Self, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; + +begin + Result := nil; + if Assigned(FOnCreateEditor) then + FOnCreateEditor(Self, Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoDragging(P: TPoint); + +// Initiates finally the drag'n drop operation and returns after DD is finished. + + //--------------- local function -------------------------------------------- + + function GetDragOperations: Integer; + + begin + if FDragOperations = [] then + Result := DROPEFFECT_COPY or DROPEFFECT_MOVE or DROPEFFECT_LINK + else + begin + Result := 0; + if doCopy in FDragOperations then + Result := Result or DROPEFFECT_COPY; + if doLink in FDragOperations then + Result := Result or DROPEFFECT_LINK; + if doMove in FDragOperations then + Result := Result or DROPEFFECT_MOVE; + end; + end; + + //--------------- end local function ---------------------------------------- + +var + DragEffect, + AllowedEffects: Integer; + DragObject: TDragObject; + + DataObject: IDataObject; + +begin + DataObject := nil; + // Dragging is dragging, nothing else. + DoCancelEdit; + + if Assigned(FCurrentHotNode) then + begin + InvalidateNode(FCurrentHotNode); + FCurrentHotNode := nil; + end; + // Select the focused node if not already done. + if Assigned(FFocusedNode) and not (vsSelected in FFocusedNode.States) then + begin + InternalAddToSelection(FFocusedNode, False); + InvalidateNode(FFocusedNode); + end; + + UpdateWindow(Handle); + + // Keep a list of all currently selected nodes as this list might change, + // but we have probably to delete currently selected nodes. + FDragSelection := GetSortedSelection(True); + try + DoStateChange([tsOLEDragging], [tsOLEDragPending, tsClearPending]); + + // An application might create a drag object like used during VCL dd. This is not required for OLE dd but + // required as parameter. + DragObject := nil; + DoStartDrag(DragObject); + DragObject.Free; + + DataObject := DragManager.DataObject; + PrepareDragImage(P, DataObject); + + FLastDropMode := dmOnNode; + // Don't forget to initialize the result. It might never be touched. + DragEffect := DROPEFFECT_NONE; + AllowedEffects := GetDragOperations; + try + DragAndDrop(AllowedEffects, DataObject, DragEffect); + DragManager.ForceDragLeave; + finally + GetCursorPos(P); + P := ScreenToClient(P); + DoEndDrag(Self, P.X, P.Y); + + FDragImage.EndDrag; + + // Finish the operation. + if (DragEffect = DROPEFFECT_MOVE) and (toAutoDeleteMovedNodes in TreeOptions.AutoOptions) then + begin + // The operation was a move so delete the previously selected nodes. + DeleteSelectedNodes; + end; + + DoStateChange([], [tsOLEDragging]); + end; + finally + FDragSelection := nil; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoDragExpand; + +var + SourceTree: TBaseVirtualTree; + +begin + StopTimer(ExpandTimer); + if Assigned(FDropTargetNode) and (vsHasChildren in FDropTargetNode.States) and + not (vsExpanded in FDropTargetNode.States) then + begin + if Assigned(FDragManager) then + SourceTree := DragManager.DragSource + else + SourceTree := nil; + + if not DragManager.DropTargetHelperSupported and Assigned(SourceTree) then + SourceTree.FDragImage.HideDragImage; + ToggleNode(FDropTargetNode); + UpdateWindow(Handle); + if not DragManager.DropTargetHelperSupported and Assigned(SourceTree) then + SourceTree.FDragImage.ShowDragImage; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoDragOver(Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode; + var Effect: Integer): Boolean; + +begin + Result := False; + if Assigned(FOnDragOver) then + FOnDragOver(Self, Source, Shift, State, Pt, Mode, Effect, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoDragDrop(Source: TObject; DataObject: IDataObject; Formats: TFormatArray; + Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode); + +begin + if Assigned(FOnDragDrop) then + FOnDragDrop(Self, Source, DataObject, Formats, Shift, Pt, Effect, Mode); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoBeforeDrawLineImage(Node: PVirtualNode; Level: Integer; var XPos: Integer); + +begin + if Assigned(FOnBeforeDrawLineImage) then + FOnBeforeDrawLineImage(Self, Node, Level, XPos); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoEdit; + +begin + Application.CancelHint; + StopTimer(ScrollTimer); + StopTimer(EditTimer); + DoStateChange([], [tsEditPending]); + if Assigned(FFocusedNode) and not (vsDisabled in FFocusedNode.States) and + not (toReadOnly in FOptions.FMiscOptions) and (FEditLink = nil) then + begin + FEditLink := DoCreateEditor(FFocusedNode, FEditColumn); + if Assigned(FEditLink) then + begin + DoStateChange([tsEditing], [tsDrawSelecting, tsDrawSelPending, tsToggleFocusedSelection, tsOLEDragPending, + tsOLEDragging, tsClearPending, tsDrawSelPending, tsScrollPending, tsScrolling, tsMouseCheckPending]); + ScrollIntoView(FFocusedNode, toCenterScrollIntoView in FOptions.SelectionOptions, + not (toDisableAutoscrollOnEdit in FOptions.AutoOptions)); + if FEditLink.PrepareEdit(Self, FFocusedNode, FEditColumn) then + begin + UpdateEditBounds; + // Node needs repaint because the selection rectangle and static text must disappear. + InvalidateNode(FFocusedNode); + if not FEditLink.BeginEdit then + DoStateChange([], [tsEditing]); + end + else + DoStateChange([], [tsEditing]); + if not (tsEditing in FStates) then + FEditLink := nil; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoEndDrag(Target: TObject; X, Y: Integer); + +// Does some housekeeping for VCL drag'n drop; + +begin + inherited; + + DragFinished; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoEndEdit: Boolean; + +begin + StopTimer(EditTimer); + Result := (tsEditing in FStates) and FEditLink.EndEdit; + if Result then + begin + DoStateChange([], [tsEditing]); + FEditLink := nil; + if Assigned(FOnEdited) then + FOnEdited(Self, FFocusedNode, FEditColumn); + end; + DoStateChange([], [tsEditPending]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoEndOperation(OperationKind: TVTOperationKind); + +begin + if Assigned(FOnEndOperation) then + FOnEndOperation(Self, OperationKind); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoExpanded(Node: PVirtualNode); + +begin + if Assigned(FOnExpanded) then + FOnExpanded(Self, Node); + + if Assigned(FAccessibleItem) then + NotifyWinEvent(EVENT_OBJECT_STATECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoExpanding(Node: PVirtualNode): Boolean; + +begin + Result := True; + if Assigned(FOnExpanding) then + FOnExpanding(Self, Node, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoFocusChange(Node: PVirtualNode; Column: TColumnIndex); + +begin + if Assigned(FOnFocusChanged) then + FOnFocusChanged(Self, Node, Column); + + if Assigned(FAccessibleItem) then + begin + NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); + NotifyWinEvent(EVENT_OBJECT_NAMECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); + NotifyWinEvent(EVENT_OBJECT_VALUECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); + NotifyWinEvent(EVENT_OBJECT_STATECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); + NotifyWinEvent(EVENT_OBJECT_SELECTION, Handle, OBJID_CLIENT, CHILDID_SELF); + NotifyWinEvent(EVENT_OBJECT_FOCUS, Handle, OBJID_CLIENT, CHILDID_SELF); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoFocusChanging(OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex): Boolean; + +begin + Result := (OldColumn = NewColumn) or FHeader.AllowFocus(NewColumn); + if Assigned(FOnFocusChanging) then + FOnFocusChanging(Self, OldNode, NewNode, OldColumn, NewColumn, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoFocusNode(Node: PVirtualNode; Ask: Boolean); + +begin + if not (tsEditing in FStates) or EndEditNode then + begin + if Node = FRoot then + Node := nil; + if (FFocusedNode <> Node) and (not Ask or DoFocusChanging(FFocusedNode, Node, FFocusedColumn, FFocusedColumn)) then + begin + if Assigned(FFocusedNode) then + begin + // Do automatic collapsing of last focused node if enabled. This is however only done if + // old and new focused node have a common parent node. + if (toAutoExpand in FOptions.FAutoOptions) and Assigned(Node) and (Node.Parent = FFocusedNode.Parent) and + (vsExpanded in FFocusedNode.States) then + ToggleNode(FFocusedNode) + else + InvalidateNode(FFocusedNode); + end; + FFocusedNode := Node; + end; + + // Have to scroll the node into view, even it is the same node as before. + if Assigned(FFocusedNode) then + begin + // Make sure a valid column is set if columns are used and no column has currently the focus. + if FHeader.UseColumns and (not FHeader.FColumns.IsValidColumn(FFocusedColumn)) then + FFocusedColumn := FHeader.MainColumn; + // Do automatic expansion of the newly focused node if enabled. + if (toAutoExpand in FOptions.FAutoOptions) and not (vsExpanded in FFocusedNode.States) then + ToggleNode(FFocusedNode); + InvalidateNode(FFocusedNode); + if (FUpdateCount = 0) and not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions) then + ScrollIntoView(FFocusedNode, (toCenterScrollIntoView in FOptions.SelectionOptions) and + (MouseButtonDown * FStates = []), not (toFullRowSelect in FOptions.SelectionOptions) ); + end; + + // Reset range anchor if necessary. + if FSelectionCount = 0 then + ResetRangeAnchor; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoFreeNode(Node: PVirtualNode); + +begin + if Node = FLastChangedNode then + FLastChangedNode := nil; + if Node = FCurrentHotNode then + FCurrentHotNode := nil; + if Node = FDropTargetNode then + FDropTargetNode := nil; + if Node = FLastStructureChangeNode then + FLastStructureChangeNode := nil; + if Assigned(FOnFreeNode) and ([vsInitialized, vsInitialUserData] * Node.States <> []) then + FOnFreeNode(Self, Node); + FreeMem(Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +// These constants are defined in the platform SDK for W2K/XP, but not yet in Delphi. +const + SPI_GETTOOLTIPANIMATION = $1016; + SPI_GETTOOLTIPFADE = $1018; + +function TBaseVirtualTree.DoGetAnimationType: THintAnimationType; + +// Determines (depending on the properties settings and the system) which hint +// animation type is to be used. + +var + Animation: BOOL; + +begin + Result := FAnimationType; + if Result = hatSystemDefault then + begin + SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, @Animation, 0); + if not Animation then + Result := hatNone + else + begin + SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, @Animation, 0); + if Animation then + Result := hatFade + else + Result := hatSlide; + end; + end; + + // Check availability of MMX if fading is requested. + if not MMXAvailable and (Result = hatFade) then + Result := hatSlide; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex; + CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; + +// Determines the margins of the content rectangle caused by DoBeforeCellPaint. +// Note that shrinking the content rectangle results in positive margins whereas enlarging the content rectangle results +// in negative margins. + +var + CellRect, + ContentRect: TRect; + +begin + Result := Point(0, 0); + + if Assigned(FOnBeforeCellPaint) then // Otherwise DoBeforeCellPaint has no effect. + begin + if Canvas = nil then + Canvas := Self.Canvas; + + // Determine then node's cell rectangle and content rectangle before calling DoBeforeCellPaint. + CellRect := GetDisplayRect(Node, Column, True); + ContentRect := CellRect; + DoBeforeCellPaint(Canvas, Node, Column, cpmGetContentMargin, CellRect, ContentRect); + + // Calculate the changes caused by DoBeforeCellPaint. + case CellContentMarginType of + ccmtAllSides: + // Calculate the width difference and high difference. + Result := Point((CellRect.Right - CellRect.Left) - (ContentRect.Right - ContentRect.Left), + (CellRect.Bottom - CellRect.Top) - (ContentRect.Bottom - ContentRect.Top)); + ccmtTopLeftOnly: + // Calculate the left margin and top margin only. + Result := Point(ContentRect.Left - CellRect.Left, ContentRect.Top - CellRect.Top); + ccmtBottomRightOnly: + // Calculate the right margin and bottom margin only. + Result := Point(CellRect.Right - ContentRect.Right, CellRect.Bottom - ContentRect.Bottom); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoGetCursor(var Cursor: TCursor); + +begin + if Assigned(FOnGetCursor) then + FOnGetCursor(Self, Cursor); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoGetHeaderCursor(var Cursor: HCURSOR); + +begin + if Assigned(FOnGetHeaderCursor) then + FOnGetHeaderCursor(FHeader, Cursor); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetImageIndex(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var Ghosted: Boolean; var Index: Integer): TCustomImageList; + +// Queries the application/descendant about certain image properties for a node. +// Returns a custom image list if given by the callee, otherwise nil. + +begin + Result := nil; + + // First try the enhanced event to allow for custom image lists. + if Assigned(FOnGetImageEx) then + FOnGetImageEx(Self, Node, Kind, Column, Ghosted, Index, Result) + else + if Assigned(FOnGetImage) then + FOnGetImage(Self, Node, Kind, Column, Ghosted, Index); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoGetImageText(Node: PVirtualNode; Kind: TVTImageKind; + Column: TColumnIndex; var ImageText: UnicodeString); + +// Queries the application/descendant about alternative image text for a node. + +begin + if Assigned(FOnGetImageText) then + FOnGetImageText(Self, Node, Kind, Column, ImageText); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoGetLineStyle(var Bits: Pointer); + +begin + if Assigned(FOnGetLineStyle) then + FOnGetLineStyle(Self, Bits); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; + +begin + Result := Hint; + LineBreakStyle := hlbDefault; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; + +begin + Result := Hint; + LineBreakStyle := hlbDefault; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; + +begin + Result := 0; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoGetPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint): TPopupMenu; + +// Queries the application whether there is a node specific popup menu. + +var + Run: PVirtualNode; + AskParent: Boolean; + +begin + Result := nil; + if Assigned(FOnGetPopupMenu) then + begin + Run := Node; + + if Assigned(Run) then + begin + AskParent := True; + repeat + FOnGetPopupMenu(Self, Run, Column, Position, AskParent, Result); + Run := Run.Parent; + until (Run = FRoot) or Assigned(Result) or not AskParent; + end + else + FOnGetPopupMenu(Self, nil, -1, Position, AskParent, Result); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoGetUserClipboardFormats(var Formats: TFormatEtcArray); + +begin + if Assigned(FOnGetUserClipboardFormats) then + FOnGetUserClipboardFormats(Self, Formats); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderClick(HitInfo: TVTHeaderHitInfo); + +begin + if Assigned(FOnHeaderClick) then + FOnHeaderClick(FHeader, HitInfo); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderDblClick(HitInfo: TVTHeaderHitInfo); + +begin + if Assigned(FOnHeaderDblClick) then + FOnHeaderDblClick(FHeader, HitInfo); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderDragged(Column: TColumnIndex; OldPosition: TColumnPosition); + +begin + if Assigned(FOnHeaderDragged) then + FOnHeaderDragged(FHeader, Column, OldPosition); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderDraggedOut(Column: TColumnIndex; DropPosition: TPoint); + +begin + if Assigned(FOnHeaderDraggedOut) then + FOnHeaderDraggedOut(FHeader, Column, DropPosition); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoHeaderDragging(Column: TColumnIndex): Boolean; + +begin + Result := True; + if Assigned(FOnHeaderDragging) then + FOnHeaderDragging(FHeader, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderDraw(Canvas: TCanvas; Column: TVirtualTreeColumn; R: TRect; Hover, Pressed: Boolean; + DropMark: TVTDropMarkMode); + +begin + if Assigned(FOnHeaderDraw) then + FOnHeaderDraw(FHeader, Canvas, Column, R, Hover, Pressed, DropMark); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderDrawQueryElements(var PaintInfo: THeaderPaintInfo; var Elements: THeaderPaintElements); + +begin + if Assigned(FOnHeaderDrawQueryElements) then + FOnHeaderDrawQueryElements(FHeader, PaintInfo, Elements); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + +begin + if Assigned(FOnHeaderMouseDown) then + FOnHeaderMouseDown(FHeader, Button, Shift, X, Y); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderMouseMove(Shift: TShiftState; X, Y: Integer); + +begin + if Assigned(FOnHeaderMouseMove) then + FOnHeaderMouseMove(FHeader, Shift, X, Y); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHeaderMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + +begin + if Assigned(FOnHeaderMouseUp) then + FOnHeaderMouseUp(FHeader, Button, Shift, X, Y); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoHotChange(Old, New: PVirtualNode); + +begin + if Assigned(FOnHotChange) then + FOnHotChange(Self, Old, New); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; + +begin + Result := 0; + if Assigned(FOnIncrementalSearch) then + FOnIncrementalSearch(Self, Node, Text, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoInitChildren(Node: PVirtualNode; var ChildCount: Cardinal); + +begin + if Assigned(FOnInitChildren) then + FOnInitChildren(Self, Node, ChildCount); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoInitNode(Parent, Node: PVirtualNode; var InitStates: TVirtualNodeInitStates); + +begin + if Assigned(FOnInitNode) then + FOnInitNode(Self, Parent, Node, InitStates); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoKeyAction(var CharCode: Word; var Shift: TShiftState): Boolean; + +begin + Result := True; + if Assigned(FOnKeyAction) then + FOnKeyAction(Self, CharCode, Shift, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoLoadUserData(Node: PVirtualNode; Stream: TStream); + +begin + if Assigned(FOnLoadNode) then + if Node = FRoot then + FOnLoadNode(Self, nil, Stream) + else + FOnLoadNode(Self, Node, Stream); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoMeasureItem(TargetCanvas: TCanvas; Node: PVirtualNode; var NodeHeight: Integer); + +begin + if Assigned(FOnMeasureItem) then + FOnMeasureItem(Self, TargetCanvas, Node, NodeHeight); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoNodeCopied(Node: PVirtualNode); + +begin + if Assigned(FOnNodeCopied) then + FOnNodeCopied(Self, Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoNodeCopying(Node, NewParent: PVirtualNode): Boolean; + +begin + Result := True; + if Assigned(FOnNodeCopying) then + FOnNodeCopying(Self, Node, NewParent, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoNodeClick(const HitInfo: THitInfo); + +begin + if Assigned(FOnNodeClick) then + FOnNodeClick(Self, HitInfo); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoNodeDblClick(const HitInfo: THitInfo); + +begin + if Assigned(FOnNodeDblClick) then + FOnNodeDblClick(Self, HitInfo); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoNodeHeightDblClickResize(Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState; + P: TPoint): Boolean; + +begin + Result := True; + if Assigned(FOnNodeHeightDblClickResize) then + FOnNodeHeightDblClickResize(Self, Node, Column, Shift, P, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoNodeHeightTracking(Node: PVirtualNode; Column: TColumnIndex; Shift: TShiftState; + var TrackPoint: TPoint; P: TPoint): Boolean; + +begin + Result := True; + if Assigned(FOnNodeHeightTracking) then + FOnNodeHeightTracking(Self, Node, Column, Shift, TrackPoint, P, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoNodeMoved(Node: PVirtualNode); + +begin + if Assigned(FOnNodeMoved) then + FOnNodeMoved(Self, Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoNodeMoving(Node, NewParent: PVirtualNode): Boolean; + +begin + Result := True; + if Assigned(FOnNodeMoving) then + FOnNodeMoving(Self, Node, NewParent, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoPaintBackground(Canvas: TCanvas; R: TRect): Boolean; + +begin + Result := False; + if Assigned(FOnPaintBackground) then + FOnPaintBackground(Self, Canvas, R, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoPaintDropMark(Canvas: TCanvas; Node: PVirtualNode; R: TRect); + +// draws the drop mark into the given rectangle +// Note: Changed properties of the given canvas should be reset to their previous values. + +var + SaveBrushColor: TColor; + SavePenStyle: TPenStyle; + +begin + if FLastDropMode in [dmAbove, dmBelow] then + with Canvas do + begin + SavePenStyle := Pen.Style; + Pen.Style := psClear; + SaveBrushColor := Brush.Color; + Brush.Color := FColors.DropMarkColor; + + if FLastDropMode = dmAbove then + begin + Polygon([Point(R.Left + 2, R.Top), + Point(R.Right - 2, R.Top), + Point(R.Right - 2, R.Top + 6), + Point(R.Right - 6, R.Top + 2), + Point(R.Left + 6 , R.Top + 2), + Point(R.Left + 2, R.Top + 6) + ]); + end + else + Polygon([Point(R.Left + 2, R.Bottom - 1), + Point(R.Right - 2, R.Bottom - 1), + Point(R.Right - 2, R.Bottom - 8), + Point(R.Right - 7, R.Bottom - 3), + Point(R.Left + 7 , R.Bottom - 3), + Point(R.Left + 2, R.Bottom - 8) + ]); + Brush.Color := SaveBrushColor; + Pen.Style := SavePenStyle; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoPaintNode(var PaintInfo: TVTPaintInfo); + +begin +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Position: TPoint); + +// Support for node dependent popup menus. + +var + Menu: TPopupMenu; + +begin + Menu := DoGetPopupMenu(Node, Column, Position); + + if Assigned(Menu) then + begin + DoStateChange([tsPopupMenuShown]); + StopTimer(EditTimer); + Menu.PopupComponent := Self; + with ClientToScreen(Position) do + Menu.Popup(X, Y); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoRenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; + ForClipboard: Boolean): HRESULT; + +begin + Result := E_FAIL; + if Assigned(FOnRenderOLEData) then + FOnRenderOLEData(Self, FormatEtcIn, Medium, ForClipboard, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoReset(Node: PVirtualNode); + +begin + if Assigned(FOnResetNode) then + FOnResetNode(Self, Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoSaveUserData(Node: PVirtualNode; Stream: TStream); + +begin + if Assigned(FOnSaveNode) then + if Node = FRoot then + FOnSaveNode(Self, nil, Stream) + else + FOnSaveNode(Self, Node, Stream); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoScroll(DeltaX, DeltaY: Integer); + +begin + if Assigned(FOnScroll) then + FOnScroll(Self, DeltaX, DeltaY); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoSetOffsetXY(Value: TPoint; Options: TScrollUpdateOptions; ClipRect: PRect = nil): Boolean; + +// Actual offset setter used to scroll the client area, update scroll bars and invalidating the header (all optional). +// Returns True if the offset really changed otherwise False is returned. + +var + DeltaX: Integer; + DeltaY: Integer; + DWPStructure: HDWP; + I: Integer; + P: TPoint; + R: TRect; + +begin + // Range check, order is important here. + if Value.X < (ClientWidth - Integer(FRangeX)) then + Value.X := ClientWidth - Integer(FRangeX); + if Value.X > 0 then + Value.X := 0; + DeltaX := Value.X - FOffsetX; + if UseRightToLeftAlignment then + DeltaX := -DeltaX; + if Value.Y < (ClientHeight - Integer(FRangeY)) then + Value.Y := ClientHeight - Integer(FRangeY); + if Value.Y > 0 then + Value.Y := 0; + DeltaY := Value.Y - FOffsetY; + + Result := (DeltaX <> 0) or (DeltaY <> 0); + if Result then + begin + FOffsetX := Value.X; + FOffsetY := Value.Y; + Result := True; + + Application.CancelHint; + if FUpdateCount = 0 then + begin + // The drag image from VCL controls need special consideration. + if tsVCLDragging in FStates then + ImageList_DragShowNolock(False); + + if (suoScrollClientArea in Options) and not (tsToggling in FStates) then + begin + // Have to invalidate the entire window if there's a background. + if (toShowBackground in FOptions.FPaintOptions) and (FBackground.Graphic is TBitmap) then + begin + // Since we don't use ScrollWindow here we have to move all client windows ourselves. + DWPStructure := BeginDeferWindowPos(ControlCount); + for I := 0 to ControlCount - 1 do + if Controls[I] is TWinControl then + begin + with Controls[I] as TWinControl do + DWPStructure := DeferWindowPos(DWPStructure, Handle, 0, Left + DeltaX, Top + DeltaY, 0, 0, + SWP_NOZORDER or SWP_NOACTIVATE or SWP_NOSIZE); + if DWPStructure = 0 then + Break; + end; + if DWPStructure <> 0 then + EndDeferWindowPos(DWPStructure); + InvalidateRect(Handle, nil, False); + end + else + begin + if (DeltaX <> 0) and (Header.Columns.GetVisibleFixedWidth > 0) then + begin + // When fixed columns exists we have to scroll separately horizontally and vertically. + // Horizontally is scroll only the client area not occupied by fixed columns and + // vertically entire client area (or clipping area if one exists). + R := ClientRect; + R.Left := Header.Columns.GetVisibleFixedWidth; + + ScrollWindow(Handle, DeltaX, 0, @R, @R); + if DeltaY <> 0 then + ScrollWindow(Handle, 0, DeltaY, ClipRect, ClipRect); + end + else + ScrollWindow(Handle, DeltaX, DeltaY, ClipRect, ClipRect); + end; + end; + + if suoUpdateNCArea in Options then + begin + if DeltaX <> 0 then + begin + if (suoRepaintHeader in Options) and (hoVisible in FHeader.FOptions) then + FHeader.Invalidate(nil); + if not (tsSizing in FStates) and (FScrollBarOptions.ScrollBars in [ssHorizontal, ssBoth]) then + UpdateHorizontalScrollBar(suoRepaintScrollbars in Options); + end; + + if (DeltaY <> 0) and ([tsThumbTracking, tsSizing] * FStates = []) then + begin + UpdateVerticalScrollBar(suoRepaintScrollbars in Options); + if not (FHeader.UseColumns or IsMouseSelecting) and + (FScrollBarOptions.ScrollBars in [ssHorizontal, ssBoth]) then + UpdateHorizontalScrollBar(suoRepaintScrollbars in Options); + end; + end; + + if tsVCLDragging in FStates then + ImageList_DragShowNolock(True); + end; + + // Finally update "hot" node if hot tracking is activated + GetCursorPos(P); + P := ScreenToClient(P); + if PtInRect(ClientRect, P) then + HandleHotTrack(P.X, P.Y); + + DoScroll(DeltaX, DeltaY); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoShowScrollbar(Bar: Integer; Show: Boolean); + +begin + ShowScrollBar(Handle, Bar, Show); + if Assigned(FOnShowScrollbar) then + FOnShowScrollbar(Self, Bar, Show); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoStartDrag(var DragObject: TDragObject); + +begin + inherited; + + // Check if the application created an own drag object. This is needed to pass the correct source in + // OnDragOver and OnDragDrop. + if Assigned(DragObject) then + DoStateChange([tsUserDragObject]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoStartOperation(OperationKind: TVTOperationKind); + +begin + if Assigned(FOnStartOperation) then + FOnStartOperation(Self, OperationKind); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoStateChange(Enter: TVirtualTreeStates; Leave: TVirtualTreeStates = []); + +var + ActualEnter, + ActualLeave: TVirtualTreeStates; + +begin + if Assigned(FOnStateChange) then + begin + ActualEnter := Enter - FStates; + ActualLeave := FStates * Leave; + if (ActualEnter + ActualLeave) <> [] then + FOnStateChange(Self, Enter, Leave); + end; + FStates := FStates + Enter - Leave; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoStructureChange(Node: PVirtualNode; Reason: TChangeReason); + +begin + StopTimer(StructureChangeTimer); + if Assigned(FOnStructureChange) then + FOnStructureChange(Self, Node, Reason); + + // This is a good place to reset the cached node and reason. These are the same as the values passed in here. + // This is necessary to allow descendants to override this method and get them. + DoStateChange([], [tsStructureChangePending]); + FLastStructureChangeNode := nil; + FLastStructureChangeReason := crIgnore; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoTimerScroll; + +var + P, + ClientP: TPoint; + InRect, + Panning: Boolean; + R, + ClipRect: TRect; + DeltaX, + DeltaY: Integer; + +begin + GetCursorPos(P); + R := ClientRect; + ClipRect := R; + MapWindowPoints(Handle, 0, R, 2); + InRect := PtInRect(R, P); + ClientP := ScreenToClient(P); + Panning := [tsWheelPanning, tsWheelScrolling] * FStates <> []; + + if IsMouseSelecting or InRect or Panning then + begin + DeltaX := 0; + DeltaY := 0; + if sdUp in FScrollDirections then + begin + if Panning then + DeltaY := FLastClickPos.Y - ClientP.Y - 8 + else + if InRect then + DeltaY := Min(FScrollBarOptions.FIncrementY, ClientHeight) + else + DeltaY := Min(FScrollBarOptions.FIncrementY, ClientHeight) * Abs(R.Top - P.Y); + if FOffsetY = 0 then + Exclude(FScrollDirections, sdUp); + end; + + if sdDown in FScrollDirections then + begin + if Panning then + DeltaY := FLastClickPos.Y - ClientP.Y + 8 + else + if InRect then + DeltaY := -Min(FScrollBarOptions.FIncrementY, ClientHeight) + else + DeltaY := -Min(FScrollBarOptions.FIncrementY, ClientHeight) * Abs(P.Y - R.Bottom); + if (ClientHeight - FOffsetY) = Integer(FRangeY) then + Exclude(FScrollDirections, sdDown); + end; + + if sdLeft in FScrollDirections then + begin + if Panning then + DeltaX := FLastClickPos.X - ClientP.X - 8 + else + if InRect then + DeltaX := FScrollBarOptions.FIncrementX + else + DeltaX := FScrollBarOptions.FIncrementX * Abs(R.Left - P.X); + if FEffectiveOffsetX = 0 then + Exclude(FScrollDirections, sdleft); + end; + + if sdRight in FScrollDirections then + begin + if Panning then + DeltaX := FLastClickPos.X - ClientP.X + 8 + else + if InRect then + DeltaX := -FScrollBarOptions.FIncrementX + else + DeltaX := -FScrollBarOptions.FIncrementX * Abs(P.X - R.Right); + + if (ClientWidth + FEffectiveOffsetX) = Integer(FRangeX) then + Exclude(FScrollDirections, sdRight); + end; + + if UseRightToLeftAlignment then + DeltaX := - DeltaX; + + if IsMouseSelecting then + begin + // In order to avoid scrolling the area which needs a repaint due to the changed selection rectangle + // we limit the scroll area explicitely. + OffsetRect(ClipRect, DeltaX, DeltaY); + DoSetOffsetXY(Point(FOffsetX + DeltaX, FOffsetY + DeltaY), DefaultScrollUpdateFlags, @ClipRect); + // When selecting with the mouse then either update only the parts of the window which have been uncovered + // by the scroll operation if no change in the selection happend or invalidate and redraw the entire + // client area otherwise (to avoid the time consuming task of determining the display rectangles of every + // changed node). + if CalculateSelectionRect(ClientP.X, ClientP.Y) and HandleDrawSelection(ClientP.X, ClientP.Y) then + InvalidateRect(Handle, nil, False) + else + begin + // The selection did not change so invalidate only the part of the window which really needs an update. + // 1) Invalidate the parts uncovered by the scroll operation. Add another offset range, we have to + // scroll only one stripe but have to update two. + OffsetRect(ClipRect, DeltaX, DeltaY); + SubtractRect(ClipRect, ClientRect, ClipRect); + InvalidateRect(Handle, @ClipRect, False); + + // 2) Invalidate the selection rectangles. + UnionRect(ClipRect, OrderRect(FNewSelRect), OrderRect(FLastSelRect)); + OffsetRect(ClipRect, FOffsetX, FOffsetY); + InvalidateRect(Handle, @ClipRect, False); + end; + end + else + begin + // Scroll only if there is no drag'n drop in progress. Drag'n drop scrolling is handled in DragOver. + if ((FDragManager = nil) or not DragManager.IsDropTarget) and ((DeltaX <> 0) or (DeltaY <> 0)) then + DoSetOffsetXY(Point(FOffsetX + DeltaX, FOffsetY + DeltaY), DefaultScrollUpdateFlags, nil); + end; + UpdateWindow(Handle); + + if (FScrollDirections = []) and ([tsWheelPanning, tsWheelScrolling] * FStates = []) then + begin + StopTimer(ScrollTimer); + DoStateChange([], [tsScrollPending, tsScrolling]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DoUpdating(State: TVTUpdateState); + +begin + if Assigned(FOnUpdating) then + FOnUpdating(Self, State); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DoValidateCache: Boolean; + +// This method fills the cache, which is used to speed up searching for nodes. +// The strategy is simple: Take the current number of visible nodes and distribute evenly a number of marks +// (which are stored in FPositionCache) so that iterating through the tree doesn't cost too much time. +// If there are less than 'CacheThreshold' nodes in the tree then the cache remains empty. +// Result is True if the cache was filled without interruption, otherwise False. +// Note: You can adjust the maximum number of nodes between two cache entries by changing CacheThreshold. + +var + EntryCount, + CurrentTop, + Index: Cardinal; + CurrentNode, + Temp: PVirtualNode; + +begin + EntryCount := 0; + if not (tsStopValidation in FStates) then + begin + if FStartIndex = 0 then + FPositionCache := nil; + + if FVisibleCount > CacheThreshold then + begin + EntryCount := CalculateCacheEntryCount; + SetLength(FPositionCache, EntryCount); + if FStartIndex > EntryCount then + FStartIndex := EntryCount; + + // Optimize validation by starting with FStartIndex if set. + if (FStartIndex > 0) and Assigned(FPositionCache[FStartIndex - 1].Node) then + begin + // Index is the current entry in FPositionCache. + Index := FStartIndex - 1; + // Running term for absolute top value. + CurrentTop := FPositionCache[Index].AbsoluteTop; + // Running node pointer. + CurrentNode := FPositionCache[Index].Node; + end + else + begin + // Index is the current entry in FPositionCache. + Index := 0; + // Running term for absolute top value. + CurrentTop := 0; + // Running node pointer. + CurrentNode := GetFirstVisibleNoInit(nil, True); + end; + + // EntryCount serves as counter for processed nodes here. This value can always start at 0 as + // the validation either starts also at index 0 or an index which is always a multiple of CacheThreshold + // and EntryCount is only used with modulo CacheThreshold. + EntryCount := 0; + if Assigned(CurrentNode) then + begin + while not (tsStopValidation in FStates) do + begin + if (EntryCount mod CacheThreshold) = 0 then + begin + // New cache entry to set up. + with FPositionCache[Index] do + begin + Node := CurrentNode; + AbsoluteTop := CurrentTop; + end; + Inc(Index); + end; + + Inc(CurrentTop, NodeHeight[CurrentNode]); + // Advance to next visible node. + Temp := GetNextVisibleNoInit(CurrentNode, True); + // If there is no further node or the cache is full then stop the loop. + if (Temp = nil) or (Integer(Index) = Length(FPositionCache)) then + Break; + + CurrentNode := Temp; + Inc(EntryCount); + end; + end; + // Finalize the position cache so no nil entry remains there. + if not (tsStopValidation in FStates) and (Integer(Index) <= High(FPositionCache)) then + begin + SetLength(FPositionCache, Index + 1); + with FPositionCache[Index] do + begin + Node := CurrentNode; + AbsoluteTop := CurrentTop; + end; + end; + end; + end; + + Result := (EntryCount > 0) and not (tsStopValidation in FStates); + + // In variable node height mode it might have happend that some or all of the nodes have been adjusted in their + // height. During validation updates of the scrollbars is disabled so let's do this here. + if Result and (toVariableNodeHeight in FOptions.FMiscOptions) then + UpdateScrollbars(True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DragAndDrop(AllowedEffects: Integer; + DataObject: IDataObject; var DragEffect: Integer); + +begin + ActiveX.DoDragDrop(DataObject, DragManager as IDropSource, AllowedEffects, DragEffect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DragCanceled; + +// Does some housekeeping for VCL drag'n drop; + +begin + inherited; + + DragFinished; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DragDrop(const DataObject: IDataObject; KeyState: Integer; Pt: TPoint; + var Effect: Integer): HResult; + +var + Shift: TShiftState; + EnumFormat: IEnumFormatEtc; + Fetched: Integer; + OLEFormat: TFormatEtc; + Formats: TFormatArray; + +begin + StopTimer(ExpandTimer); + StopTimer(ScrollTimer); + DoStateChange([], [tsScrollPending, tsScrolling]); + Formats := nil; + + // Ask explicitly again whether the action is allowed. Otherwise we may accept a drop which is intentionally not + // allowed but cannot be prevented by the application because when the tree was scrolling while dropping + // no DragOver event is created by the OLE subsystem. + Result := DragOver(DragManager.DragSource, KeyState, dsDragMove, Pt, Effect); + try + if (Result <> NOERROR) or ((Effect and not DROPEFFECT_SCROLL) = DROPEFFECT_NONE) then + Result := E_FAIL + else + begin + try + Shift := KeysToShiftState(KeyState); + if tsLeftButtonDown in FStates then + Include(Shift, ssLeft); + if tsMiddleButtonDown in FStates then + Include(Shift, ssMiddle); + if tsRightButtonDown in FStates then + Include(Shift, ssRight); + Pt := ScreenToClient(Pt); + // Determine which formats we can get and pass them along with the data object to the drop handler. + Result := DataObject.EnumFormatEtc(DATADIR_GET, EnumFormat); + if Failed(Result) then + Abort; + Result := EnumFormat.Reset; + if Failed(Result) then + Abort; + // create a list of available formats + while EnumFormat.Next(1, OLEFormat, @Fetched) = S_OK do + begin + SetLength(Formats, Length(Formats) + 1); + Formats[High(Formats)] := OLEFormat.cfFormat; + end; + DoDragDrop(DragManager.DragSource, DataObject, Formats, Shift, Pt, Effect, FLastDropMode); + except + // An unhandled exception here leaks memory. + Application.HandleException(Self); + Result := E_UNEXPECTED; + end; + end; + finally + if Assigned(FDropTargetNode) then + begin + InvalidateNode(FDropTargetNode); + FDropTargetNode := nil; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DragEnter(KeyState: Integer; Pt: TPoint; var Effect: Integer): HResult; + +// callback routine for the drop target interface + +var + Shift: TShiftState; + Accept: Boolean; + R: TRect; + HitInfo: THitInfo; + +begin + try + // Determine acceptance of drag operation and reset scroll start time. + FDragScrollStart := 0; + + Shift := KeysToShiftState(KeyState); + if tsLeftButtonDown in FStates then + Include(Shift, ssLeft); + if tsMiddleButtonDown in FStates then + Include(Shift, ssMiddle); + if tsRightButtonDown in FStates then + Include(Shift, ssRight); + Pt := ScreenToClient(Pt); + Effect := SuggestDropEffect(DragManager.DragSource, Shift, Pt, Effect); + Accept := DoDragOver(DragManager.DragSource, Shift, dsDragEnter, Pt, FLastDropMode, Effect); + if not Accept then + Effect := DROPEFFECT_NONE + else + begin + // Set initial drop target node and drop mode. + GetHitTestInfoAt(Pt.X, Pt.Y, True, HitInfo); + if Assigned(HitInfo.HitNode) then + begin + FDropTargetNode := HitInfo.HitNode; + R := GetDisplayRect(HitInfo.HitNode, FHeader.MainColumn, False); + if (hiOnItemLabel in HitInfo.HitPositions) or ((hiOnItem in HitInfo.HitPositions) and + ((toFullRowDrag in FOptions.FMiscOptions) or (toFullRowSelect in FOptions.FSelectionOptions)))then + FLastDropMode := dmOnNode + else + if ((R.Top + R.Bottom) div 2) > Pt.Y then + FLastDropMode := dmAbove + else + FLastDropMode := dmBelow; + end + else + FLastDropMode := dmNowhere; + end; + + // If the drag source is a virtual tree then we know how to control the drag image + // and can show it even if the source is not the target tree. + // This is only necessary if we cannot use the drag image helper interfaces. + if not DragManager.DropTargetHelperSupported and Assigned(DragManager.DragSource) then + DragManager.DragSource.FDragImage.ShowDragImage; + Result := NOERROR; + except + Result := E_UNEXPECTED; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DragFinished; + +// Called by DragCancelled or EndDrag to make up for the still missing mouse button up messages. +// These are important for such important things like popup menus. + +var + P: TPoint; + +begin + if [tsOLEDragging, tsVCLDragPending, tsVCLDragging, tsVCLDragFinished] * FStates = [] then + Exit; + + DoStateChange([], [tsVCLDragPending, tsVCLDragging, tsUserDragObject, tsVCLDragFinished]); + + GetCursorPos(P); + P := ScreenToClient(P); + if tsRightButtonDown in FStates then + Perform(WM_RBUTTONUP, 0, LPARAM(Longint(PointToSmallPoint(P)))) + else + if tsMiddleButtonDown in FStates then + Perform(WM_MBUTTONUP, 0, LPARAM(Longint(PointToSmallPoint(P)))) + else + Perform(WM_LBUTTONUP, 0, LPARAM(Longint(PointToSmallPoint(P)))); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DragLeave; + +var + Effect: Integer; + +begin + StopTimer(ExpandTimer); + + if not DragManager.DropTargetHelperSupported and Assigned(DragManager.DragSource) then + DragManager.DragSource.FDragImage.HideDragImage; + + if Assigned(FDropTargetNode) then + begin + InvalidateNode(FDropTargetNode); + FDropTargetNode := nil; + end; + UpdateWindow(Handle); + + Effect := 0; + DoDragOver(nil, [], dsDragLeave, Point(0, 0), FLastDropMode, Effect); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.DragOver(Source: TObject; KeyState: Integer; DragState: TDragState; Pt: TPoint; + var Effect: LongInt): HResult; + +// callback routine for the drop target interface + +var + Shift: TShiftState; + Accept, + DragImageWillMove, + WindowScrolled: Boolean; + OldR, R: TRect; + NewDropMode: TDropMode; + HitInfo: THitInfo; + DragPos: TPoint; + Tree: TBaseVirtualTree; + LastNode: PVirtualNode; + DeltaX, + DeltaY: Integer; + ScrollOptions: TScrollUpdateOptions; + +begin + if not DragManager.DropTargetHelperSupported and (Source is TBaseVirtualTree) then + begin + Tree := Source as TBaseVirtualTree; + ScrollOptions := [suoUpdateNCArea]; + end + else + begin + Tree := nil; + ScrollOptions := DefaultScrollUpdateFlags; + end; + + try + DragPos := Pt; + Pt := ScreenToClient(Pt); + + // Check if we have to scroll the client area. + FScrollDirections := DetermineScrollDirections(Pt.X, Pt.Y); + DeltaX := 0; + DeltaY := 0; + if FScrollDirections <> [] then + begin + // Determine amount to scroll. + if sdUp in FScrollDirections then + begin + DeltaY := Min(FScrollBarOptions.FIncrementY, ClientHeight); + if FOffsetY = 0 then + Exclude(FScrollDirections, sdUp); + end; + if sdDown in FScrollDirections then + begin + DeltaY := -Min(FScrollBarOptions.FIncrementY, ClientHeight); + if (ClientHeight - FOffsetY) = Integer(FRangeY) then + Exclude(FScrollDirections, sdDown); + end; + if sdLeft in FScrollDirections then + begin + DeltaX := FScrollBarOptions.FIncrementX; + if FEffectiveOffsetX = 0 then + Exclude(FScrollDirections, sdleft); + end; + if sdRight in FScrollDirections then + begin + DeltaX := -FScrollBarOptions.FIncrementX; + if (ClientWidth + FEffectiveOffsetX) = Integer(FRangeX) then + Exclude(FScrollDirections, sdRight); + end; + WindowScrolled := DoSetOffsetXY(Point(FOffsetX + DeltaX, FOffsetY + DeltaY), ScrollOptions, nil); + end + else + WindowScrolled := False; + + // Determine acceptance of drag operation as well as drag target. + Shift := KeysToShiftState(KeyState); + if tsLeftButtonDown in FStates then + Include(Shift, ssLeft); + if tsMiddleButtonDown in FStates then + Include(Shift, ssMiddle); + if tsRightButtonDown in FStates then + Include(Shift, ssRight); + + GetHitTestInfoAt(Pt.X, Pt.Y, True, HitInfo); + if Assigned(HitInfo.HitNode) then + R := GetDisplayRect(HitInfo.HitNode, NoColumn, False) + else + R := Rect(0, 0, 0, 0); + NewDropMode := DetermineDropMode(Pt, HitInfo, R); + + if Assigned(Tree) then + DragImageWillMove := Tree.FDragImage.WillMove(DragPos) + else + DragImageWillMove := False; + + if (HitInfo.HitNode <> FDropTargetNode) or (FLastDropMode <> NewDropMode) then + begin + // Something in the tree will change. This requires to update the screen and/or the drag image. + FLastDropMode := NewDropMode; + if HitInfo.HitNode <> FDropTargetNode then + begin + StopTimer(ExpandTimer); + // The last target node is needed for the rectangle determination but must already be set for + // the recapture call, hence it must be stored somewhere. + LastNode := FDropTargetNode; + FDropTargetNode := HitInfo.HitNode; + // In order to show a selection rectangle a column must be focused. + if FFocusedColumn <= NoColumn then + FFocusedColumn := FHeader.MainColumn; + + if Assigned(LastNode) and Assigned(FDropTargetNode) then + begin + // Optimize the case that the selection moved between two nodes. + OldR := GetDisplayRect(LastNode, NoColumn, False); + UnionRect(R, R, OldR); + if Assigned(Tree) then + begin + if WindowScrolled then + UpdateWindowAndDragImage(Tree, ClientRect, True, not DragImageWillMove) + else + UpdateWindowAndDragImage(Tree, R, False, not DragImageWillMove); + end + else + InvalidateRect(Handle, @R, False); + end + else + begin + if Assigned(LastNode) then + begin + // Repaint last target node. + OldR := GetDisplayRect(LastNode, NoColumn, False); + if Assigned(Tree) then + begin + if WindowScrolled then + UpdateWindowAndDragImage(Tree, ClientRect, WindowScrolled, not DragImageWillMove) + else + UpdateWindowAndDragImage(Tree, OldR, False, not DragImageWillMove); + end + else + InvalidateRect(Handle, @OldR, False); + end + else + begin + if Assigned(Tree) then + begin + if WindowScrolled then + UpdateWindowAndDragImage(Tree, ClientRect, WindowScrolled, not DragImageWillMove) + else + UpdateWindowAndDragImage(Tree, R, False, not DragImageWillMove); + end + else + InvalidateRect(Handle, @R, False); + end; + end; + + // Start auto expand timer if necessary. + if (toAutoDropExpand in FOptions.FAutoOptions) and Assigned(FDropTargetNode) and + (vsHasChildren in FDropTargetNode.States) then + SetTimer(Handle, ExpandTimer, FAutoExpandDelay, nil); + end + else + begin + // Only the drop mark position changed so invalidate the current drop target node. + if Assigned(Tree) then + begin + if WindowScrolled then + UpdateWindowAndDragImage(Tree, ClientRect, WindowScrolled, not DragImageWillMove) + else + UpdateWindowAndDragImage(Tree, R, False, not DragImageWillMove); + end + else + InvalidateRect(Handle, @R, False); + end; + end + else + begin + // No change in the current drop target or drop mode. This might still mean horizontal or vertical scrolling. + if Assigned(Tree) and ((DeltaX <> 0) or (DeltaY <> 0)) then + UpdateWindowAndDragImage(Tree, ClientRect, WindowScrolled, not DragImageWillMove); + end; + + Update; + + if Assigned(Tree) and DragImageWillMove then + Tree.FDragImage.DragTo(DragPos, False); + + Effect := SuggestDropEffect(Source, Shift, Pt, Effect); + Accept := DoDragOver(Source, Shift, DragState, Pt, FLastDropMode, Effect); + if not Accept then + Effect := DROPEFFECT_NONE; + if WindowScrolled then + Effect := Effect or Integer(DROPEFFECT_SCROLL); + Result := NOERROR; + except + Result := E_UNEXPECTED; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DrawDottedHLine(const PaintInfo: TVTPaintInfo; Left, Right, Top: Integer); + +// Draws a horizontal line with alternating pixels (this style is not supported for pens under Win9x). + +var + R: TRect; + +begin + with PaintInfo, Canvas do + begin + Brush.Color := Color; + R := Rect(Min(Left, Right), Top, Max(Left, Right) + 1, Top + 1); + Windows.FillRect(Handle, R, FDottedBrush); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DrawDottedVLine(const PaintInfo: TVTPaintInfo; Top, Bottom, Left: Integer); + +// Draws a horizontal line with alternating pixels (this style is not supported for pens under Win9x). + +var + R: TRect; + +begin + with PaintInfo, Canvas do + begin + Brush.Color := Color; + R := Rect(Left, Min(Top, Bottom), Left + 1, Max(Top, Bottom) + 1); + Windows.FillRect(Handle, R, FDottedBrush); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.EndOperation(OperationKind: TVTOperationKind); + +// Called to indicate that a long-running operation has finished. + +begin + Assert(FOperationCount > 0, 'EndOperation must not be called when no operation in progress.'); + Dec(FOperationCount); + DoEndOperation(OperationKind); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.FindNodeInSelection(P: PVirtualNode; var Index: Integer; LowBound, + HighBound: Integer): Boolean; + +// Search routine to find a specific node in the selection array. +// LowBound and HighBound determine the range in which to search the node. +// Either value can be -1 to denote the maximum range otherwise LowBound must be less or equal HighBound. + +var + L, H, + I: Integer; + +begin + Result := False; + L := 0; + if LowBound >= 0 then + L := LowBound; + H := FSelectionCount - 1; + if HighBound >= 0 then + H := HighBound; + while L <= H do + begin + I := (L + H) shr 1; + if PAnsiChar(FSelection[I]) < PAnsiChar(P) then + L := I + 1 + else + begin + H := I - 1; + if FSelection[I] = P then + begin + Result := True; + L := I; + end; + end; + end; + Index := L; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FinishChunkHeader(Stream: TStream; StartPos, EndPos: Integer); + +// used while streaming out a node to finally write out the size of the chunk + +var + Size: Integer; + +begin + // seek back to the second entry in the chunk header + Stream.Position := StartPos + SizeOf(Size); + // determine size of chunk without the chunk header + Size := EndPos - StartPos - SizeOf(TChunkHeader); + // write the size... + Stream.Write(Size, SizeOf(Size)); + // ... and seek to the last endposition + Stream.Position := EndPos; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FontChanged(AFont: TObject); + +// Little helper function for font changes (as they are not tracked in TBitmap/TCanvas.OnChange). + +begin + FFontChanged := True; + FOldFontChange(AFont); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetBorderDimensions: TSize; + +// Returns the overall width of the current window border, depending on border styles. +// Note: these numbers represent the system's standards not special properties, which can be set for TWinControl +// (e.g. bevels, border width). + +var + Styles: Integer; + +begin + Result.cx := 0; + Result.cy := 0; + + Styles := GetWindowLong(Handle, GWL_STYLE); + if (Styles and WS_BORDER) <> 0 then + begin + Dec(Result.cx); + Dec(Result.cy); + end; + if (Styles and WS_THICKFRAME) <> 0 then + begin + Dec(Result.cx, GetSystemMetrics(SM_CXFIXEDFRAME)); + Dec(Result.cy, GetSystemMetrics(SM_CYFIXEDFRAME)); + end; + Styles := GetWindowLong(Handle, GWL_EXSTYLE); + if (Styles and WS_EX_CLIENTEDGE) <> 0 then + begin + Dec(Result.cx, GetSystemMetrics(SM_CXEDGE)); + Dec(Result.cy, GetSystemMetrics(SM_CYEDGE)); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetCheckImage(Node: PVirtualNode; ImgCheckType: TCheckType = ctNone; ImgCheckState: + TCheckState = csUncheckedNormal; ImgEnabled: Boolean = True): Integer; + +// Determines the index into the check image list for the given node depending on the check type +// and enabled state. + +const + // Four dimensional array consisting of image indices for the check type, the check state, the enabled state and the + // hot state. + CheckStateToCheckImage: array[ctCheckBox..ctButton, csUncheckedNormal..csMixedPressed, Boolean, Boolean] of Integer = ( + // ctCheckBox, ctTriStateCheckBox + ( + // csUncheckedNormal (disabled [not hot, hot], enabled [not hot, hot]) + ((ckCheckUncheckedDisabled, ckCheckUncheckedDisabled), (ckCheckUncheckedNormal, ckCheckUncheckedHot)), + // csUncheckedPressed (disabled [not hot, hot], enabled [not hot, hot]) + ((ckCheckUncheckedDisabled, ckCheckUncheckedDisabled), (ckCheckUncheckedPressed, ckCheckUncheckedPressed)), + // csCheckedNormal + ((ckCheckCheckedDisabled, ckCheckCheckedDisabled), (ckCheckCheckedNormal, ckCheckCheckedHot)), + // csCheckedPressed + ((ckCheckCheckedDisabled, ckCheckCheckedDisabled), (ckCheckCheckedPressed, ckCheckCheckedPressed)), + // csMixedNormal + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedNormal, ckCheckMixedHot)), + // csMixedPressed + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedPressed, ckCheckMixedPressed)) + ), + // ctRadioButton + ( + // csUncheckedNormal (disabled [not hot, hot], enabled [not hot, hot]) + ((ckRadioUncheckedDisabled, ckRadioUncheckedDisabled), (ckRadioUncheckedNormal, ckRadioUncheckedHot)), + // csUncheckedPressed (disabled [not hot, hot], enabled [not hot, hot]) + ((ckRadioUncheckedDisabled, ckRadioUncheckedDisabled), (ckRadioUncheckedPressed, ckRadioUncheckedPressed)), + // csCheckedNormal + ((ckRadioCheckedDisabled, ckRadioCheckedDisabled), (ckRadioCheckedNormal, ckRadioCheckedHot)), + // csCheckedPressed + ((ckRadioCheckedDisabled, ckRadioCheckedDisabled), (ckRadioCheckedPressed, ckRadioCheckedPressed)), + // csMixedNormal (should never appear with ctRadioButton) + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedNormal, ckCheckMixedHot)), + // csMixedPressed (should never appear with ctRadioButton) + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedPressed, ckCheckMixedPressed)) + ), + // ctButton + ( + // csUncheckedNormal (disabled [not hot, hot], enabled [not hot, hot]) + ((ckButtonDisabled, ckButtonDisabled), (ckButtonNormal, ckButtonHot)), + // csUncheckedPressed (disabled [not hot, hot], enabled [not hot, hot]) + ((ckButtonDisabled, ckButtonDisabled), (ckButtonPressed, ckButtonPressed)), + // csCheckedNormal + ((ckButtonDisabled, ckButtonDisabled), (ckButtonNormal, ckButtonHot)), + // csCheckedPressed + ((ckButtonDisabled, ckButtonDisabled), (ckButtonPressed, ckButtonPressed)), + // csMixedNormal (should never appear with ctButton) + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedNormal, ckCheckMixedHot)), + // csMixedPressed (should never appear with ctButton) + ((ckCheckMixedDisabled, ckCheckMixedDisabled), (ckCheckMixedPressed, ckCheckMixedPressed)) + ) + ); + +var + IsHot: Boolean; + +begin + if Assigned(Node) then + begin + ImgCheckType := Node.CheckType; + ImgCheckState := Node.CheckState; + ImgEnabled := not (vsDisabled in Node.States) and Enabled; + IsHot := Node = FCurrentHotNode; + end + else + IsHot := False; + + if ImgCheckType = ctTriStateCheckBox then + ImgCheckType := ctCheckBox; + + if ImgCheckType = ctNone then + Result := -1 + else + Result := CheckStateToCheckImage[ImgCheckType, ImgCheckState, ImgEnabled, IsHot]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +class function TBaseVirtualTree.GetCheckImageListFor(Kind: TCheckImageKind): TCustomImageList; + +begin + case Kind of + ckDarkCheck: + Result := DarkCheckImages; + ckLightTick: + Result := LightTickImages; + ckDarkTick: + Result := DarkTickImages; + ckLightCheck: + Result := LightCheckImages; + ckFlat: + Result := FlatImages; + ckXP: + Result := XPImages; + ckSystemDefault: + Result := SystemCheckImages; + ckSystemFlat: + Result := SystemFlatCheckImages; + else + Result := nil; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetColumnClass: TVirtualTreeColumnClass; + +begin + Result := TVirtualTreeColumn; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetHeaderClass: TVTHeaderClass; + +begin + Result := TVTHeader; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetHintWindowClass: THintWindowClass; + +// Returns the default hint window class used for the tree. Descendants can override it to use their own classes. + +begin + Result := TVirtualTreeHintWindow; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.GetImageIndex(var Info: TVTPaintInfo; Kind: TVTImageKind; InfoIndex: TVTImageInfoIndex; + DefaultImages: TCustomImageList); + +// Retrieves the image index and an eventual customized image list for drawing. + +var + CustomImages: TCustomImageList; + +begin + with Info do + begin + ImageInfo[InfoIndex].Index := -1; + ImageInfo[InfoIndex].Ghosted := False; + + CustomImages := DoGetImageIndex(Node, Kind, Column, ImageInfo[InfoIndex].Ghosted, ImageInfo[InfoIndex].Index); + if Assigned(CustomImages) then + ImageInfo[InfoIndex].Images := CustomImages + else + ImageInfo[InfoIndex].Images := DefaultImages; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetMaxRightExtend: Cardinal; + +// Determines the maximum with of the currently visible part of the tree, depending on the length +// of the node texts. This method is used for determining the horizontal scroll range if no columns are used. + +var + Node, + NextNode: PVirtualNode; + TopPosition: Integer; + NodeLeft, + CurrentWidth: Integer; + WithCheck: Boolean; + CheckOffset: Integer; + +begin + Node := GetNodeAt(0, 0, True, TopPosition); + Result := 0; + if toShowRoot in FOptions.FPaintOptions then + NodeLeft := (GetNodeLevel(Node) + 1) * FIndent + else + NodeLeft := GetNodeLevel(Node) * FIndent; + + if Assigned(FStateImages) then + Inc(NodeLeft, FStateImages.Width + 2); + if Assigned(FImages) then + Inc(NodeLeft, FImages.Width + 2); + WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); + if WithCheck then + CheckOffset := FCheckImages.Width + 2 + else + CheckOffset := 0; + + while Assigned(Node) do + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + + if WithCheck and (Node.CheckType <> ctNone) then + Inc(NodeLeft, CheckOffset); + CurrentWidth := DoGetNodeWidth(Node, NoColumn); + if Integer(Result) < (NodeLeft + CurrentWidth) then + Result := NodeLeft + CurrentWidth; + Inc(TopPosition, NodeHeight[Node]); + if TopPosition > Height then + Break; + + if WithCheck and (Node.CheckType <> ctNone) then + Dec(NodeLeft, CheckOffset); + + // Get next visible node and update left node position. + NextNode := GetNextVisible(Node, True); + if NextNode = nil then + Break; + Inc(NodeLeft, CountLevelDifference(Node, NextNode) * Integer(FIndent)); + Node := NextNode; + end; + + Inc(Result, FMargin); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.GetNativeClipboardFormats(var Formats: TFormatEtcArray); + +// Returns the supported clipboard formats of the tree. + +begin + InternalClipboardFormats.EnumerateFormats(TVirtualTreeClass(ClassType), Formats, FClipboardFormats); + // Ask application/descendants for self defined formats. + DoGetUserClipboardFormats(Formats); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetOperationCanceled; + +begin + Result := FOperationCanceled and (FOperationCount > 0); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetOptionsClass: TTreeOptionsClass; + +begin + Result := TCustomVirtualTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetTreeFromDataObject(const DataObject: IDataObject): TBaseVirtualTree; + +// Returns the owner/sender of the given data object by means of a special clipboard format +// or nil if the sender is in another process or no virtual tree at all. + +var + Medium: TStgMedium; + Data: PVTReference; + +begin + Result := nil; + if Assigned(DataObject) then + begin + StandardOLEFormat.cfFormat := CF_VTREFERENCE; + if DataObject.GetData(StandardOLEFormat, Medium) = S_OK then + begin + Data := GlobalLock(Medium.hGlobal); + if Assigned(Data) then + begin + if Data.Process = GetCurrentProcessID then + Result := Data.Tree; + GlobalUnlock(Medium.hGlobal); + end; + ReleaseStgMedium(Medium); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleHotTrack(X, Y: Integer); + +// Updates the current "hot" node. + +var + HitInfo: THitInfo; + CheckPositions: THitPositions; + ButtonIsHit, + DoInvalidate: Boolean; + +begin + DoInvalidate := False; + // Get information about the hit. + GetHitTestInfoAt(X, Y, True, HitInfo); + + // Only make the new node being "hot" if its label is hit or full row selection is enabled. + CheckPositions := [hiOnItemLabel, hiOnItemCheckbox]; + + // If running under Windows Vista using the explorer theme hitting the buttons makes the node hot, too. + if tsUseExplorerTheme in FStates then + Include(CheckPositions, hiOnItemButtonExact); + + if (CheckPositions * HitInfo.HitPositions = []) and not (toFullRowSelect in FOptions.FSelectionOptions) then + HitInfo.HitNode := nil; + if (HitInfo.HitNode <> FCurrentHotNode) or (HitInfo.HitColumn <> FCurrentHotColumn) then + begin + DoInvalidate := (toHotTrack in FOptions.PaintOptions) or (toCheckSupport in FOptions.FMiscOptions); + DoHotChange(FCurrentHotNode, HitInfo.HitNode); + if Assigned(FCurrentHotNode) and DoInvalidate then + InvalidateNode(FCurrentHotNode); + FCurrentHotNode := HitInfo.HitNode; + FCurrentHotColumn := HitInfo.HitColumn; + end; + + ButtonIsHit := (hiOnItemButtonExact in HitInfo.HitPositions) and (toHotTrack in FOptions.FPaintOptions); + if Assigned(FCurrentHotNode) and ((FHotNodeButtonHit <> ButtonIsHit) or DoInvalidate) then + begin + FHotNodeButtonHit := ButtonIsHit and (toHotTrack in FOptions.FPaintOptions); + InvalidateNode(FCurrentHotNode); + end + else + if not Assigned(FCurrentHotNode) then + FHotNodeButtonHit := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleIncrementalSearch(CharCode: Word); + +var + Run, Stop: PVirtualNode; + GetNextNode: TGetNextNodeProc; + NewSearchText: UnicodeString; + SingleLetter, + PreviousSearch: Boolean; // True if VK_BACK was sent. + SearchDirection: TVTSearchDirection; + + //--------------- local functions ------------------------------------------- + + procedure SetupNavigation; + + // If the search buffer is empty then we start searching with the next node after the last one, otherwise + // we continue with the last one. Node navigation function is set up too here, to avoid frequent checks. + + var + FindNextNode: Boolean; + + begin + FindNextNode := (Length(FSearchBuffer) = 0) or (Run = nil) or SingleLetter or PreviousSearch; + case FIncrementalSearch of + isVisibleOnly: + if SearchDirection = sdForward then + begin + GetNextNode := GetNextVisible; + if FindNextNode then + begin + if Run = nil then + Run := GetFirstVisible(nil, True) + else + begin + Run := GetNextVisible(Run, True); + // Do wrap around. + if Run = nil then + Run := GetFirstVisible(nil, True); + end; + end; + end + else + begin + GetNextNode := GetPreviousVisible; + if FindNextNode then + begin + if Run = nil then + Run := GetLastVisible(nil, True) + else + begin + Run := GetPreviousVisible(Run, True); + // Do wrap around. + if Run = nil then + Run := GetLastVisible(nil, True); + end; + end; + end; + isInitializedOnly: + if SearchDirection = sdForward then + begin + GetNextNode := GetNextNoInit; + if FindNextNode then + begin + if Run = nil then + Run := GetFirstNoInit + else + begin + Run := GetNextNoInit(Run); + // Do wrap around. + if Run = nil then + Run := GetFirstNoInit; + end; + end; + end + else + begin + GetNextNode := GetPreviousNoInit; + if FindNextNode then + begin + if Run = nil then + Run := GetLastNoInit + else + begin + Run := GetPreviousNoInit(Run); + // Do wrap around. + if Run = nil then + Run := GetLastNoInit; + end; + end; + end; + else + // isAll + if SearchDirection = sdForward then + begin + GetNextNode := GetNext; + if FindNextNode then + begin + if Run = nil then + Run := GetFirst + else + begin + Run := GetNext(Run); + // Do wrap around. + if Run = nil then + Run := GetFirst; + end; + end; + end + else + begin + GetNextNode := GetPrevious; + if FindNextNode then + begin + if Run = nil then + Run := GetLast + else + begin + Run := GetPrevious(Run); + // Do wrap around. + if Run = nil then + Run := GetLast; + end; + end; + end; + end; + end; + + //--------------------------------------------------------------------------- + + function CodePageFromLocale(Language: LCID): Integer; + + // Determines the code page for a given locale. + // Unfortunately there is no easier way than this, currently. + + var + Buf: array[0..6] of Char; + + begin + GetLocaleInfo(Language, LOCALE_IDEFAULTANSICODEPAGE, Buf, 6); + Result := StrToIntDef(Buf, GetACP); + end; + + //--------------------------------------------------------------------------- + + function KeyUnicode(C: Char): WideChar; + + // Converts the given character into its corresponding Unicode character + // depending on the active keyboard layout. + + begin + MultiByteToWideChar(CodePageFromLocale(GetKeyboardLayout(0) and $FFFF), + MB_USEGLYPHCHARS, @C, 1, @Result, 1); + end; + + //--------------- end local functions --------------------------------------- + +var + FoundMatch: Boolean; + NewChar: WideChar; + +begin + StopTimer(SearchTimer); + + if FIncrementalSearch <> isNone then + begin + if CharCode <> 0 then + begin + DoStateChange([tsIncrementalSearching]); + + // Convert the given virtual key code into a Unicode character based on the current locale. + NewChar := KeyUnicode(Char(CharCode)); + PreviousSearch := NewChar = WideChar(VK_BACK); + // We cannot do a search with an empty search buffer. + if not PreviousSearch or (FSearchBuffer <> '') then + begin + // Determine which method to use to advance nodes and the start node to search from. + case FSearchStart of + ssAlwaysStartOver: + Run := nil; + ssFocusedNode: + Run := FFocusedNode; + else // ssLastHit + Run := FLastSearchNode; + end; + + // Make sure the start node corresponds to the search criterion. + if Assigned(Run) then + begin + case FIncrementalSearch of + isInitializedOnly: + if not (vsInitialized in Run.States) then + Run := nil; + isVisibleOnly: + if not FullyVisible[Run] or IsEffectivelyFiltered[Run] then + Run := nil; + end; + end; + Stop := Run; + + // VK_BACK temporarily changes search direction to opposite mode. + if PreviousSearch then + begin + if SearchDirection = sdBackward then + SearchDirection := sdForward + else + SearchDirection := sdBackward + end + else + SearchDirection := FSearchDirection; + // The "single letter mode" is used to advance quickly from node to node when pressing the same key several times. + SingleLetter := (Length(FSearchBuffer) = 1) and not PreviousSearch and (FSearchBuffer[1] = NewChar); + // However if the current hit (if there is one) would fit also with a repeated character then + // don't use single letter mode. + if SingleLetter and (DoIncrementalSearch(Run, FSearchBuffer + NewChar) = 0) then + SingleLetter := False; + SetupNavigation; + FoundMatch := False; + + if Assigned(Run) then + begin + if SingleLetter then + NewSearchText := FSearchBuffer + else + if PreviousSearch then + begin + SetLength(FSearchBuffer, Length(FSearchBuffer) - 1); + NewSearchText := FSearchBuffer; + end + else + NewSearchText := FSearchBuffer + NewChar; + + repeat + if DoIncrementalSearch(Run, NewSearchText) = 0 then + begin + FoundMatch := True; + Break; + end; + + // Advance to next node if we have not found a match. + Run := GetNextNode(Run); + // Do wrap around start or end of tree. + if (Run <> Stop) and (Run = nil) then + SetupNavigation; + until Run = Stop; + end; + + if FoundMatch then + begin + ClearSelection; + FSearchBuffer := NewSearchText; + FLastSearchNode := Run; + FocusedNode := Run; + Selected[Run] := True; + FLastSearchNode := Run; + end + else + // Play an acoustic signal if nothing could be found but don't beep if only the currently + // focused node matches. + if Assigned(Run) and (DoIncrementalSearch(Run, NewSearchText) <> 0) then + Beep; + end; + end; + + // Restart search timeout interval. + SetTimer(Handle, SearchTimer, FSearchTimeout, nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleMouseDblClick(var Message: TWMMouse; const HitInfo: THitInfo); + +var + NewCheckState: TCheckState; + Node: PVirtualNode; + MayEdit: Boolean; + +begin + MayEdit := not (tsEditing in FStates) and (toEditOnDblClick in FOptions.FMiscOptions); + if tsEditPending in FStates then + begin + StopTimer(EditTimer); + DoStateChange([], [tsEditPending]); + end; + + if not (tsEditing in FStates) or DoEndEdit then + begin + if HitInfo.HitColumn = FHeader.FColumns.FClickIndex then + DoColumnDblClick(HitInfo.HitColumn, KeysToShiftState(Message.Keys)); + + if HitInfo.HitNode <> nil then + DoNodeDblClick(HitInfo); + + Node := nil; + if (hiOnItem in HitInfo.HitPositions) and (hitInfo.HitColumn > NoColumn) and + (coFixed in FHeader.FColumns[HitInfo.HitColumn].FOptions) then + begin + if hiUpperSplitter in HitInfo.HitPositions then + Node := GetPreviousVisible(HitInfo.HitNode, True) + else + if hiLowerSplitter in HitInfo.HitPositions then + Node := HitInfo.HitNode + end; + + if Assigned(Node) and (Node <> FRoot) and (toNodeHeightDblClickResize in FOptions.FMiscOptions) then + begin + if DoNodeHeightDblClickResize(Node, HitInfo.HitColumn, KeysToShiftState(Message.Keys), Point(Message.XPos, Message.YPos)) then + begin + SetNodeHeight(Node, FDefaultNodeHeight); + UpdateWindow(Handle); + MayEdit := False; + end; + end + else + if hiOnItemCheckBox in HitInfo.HitPositions then + begin + if (FStates * [tsMouseCheckPending, tsKeyCheckPending] = []) and not (vsDisabled in HitInfo.HitNode.States) then + begin + with HitInfo.HitNode^ do + NewCheckState := DetermineNextCheckState(CheckType, CheckState); + if (ssLeft in KeysToShiftState(Message.Keys)) and DoChecking(HitInfo.HitNode, NewCheckState) then + begin + DoStateChange([tsMouseCheckPending]); + FCheckNode := HitInfo.HitNode; + FPendingCheckState := NewCheckState; + FCheckNode.CheckState := PressedState[FCheckNode.CheckState]; + InvalidateNode(HitInfo.HitNode); + MayEdit := False; + end; + end; + end + else + begin + if hiOnItemButton in HitInfo.HitPositions then + begin + ToggleNode(HitInfo.HitNode); + MayEdit := False; + end + else + begin + if toToggleOnDblClick in FOptions.FMiscOptions then + begin + if ((([hiOnItemButton, hiOnItemLabel, hiOnNormalIcon, hiOnStateIcon] * HitInfo.HitPositions) <> []) or + ((toFullRowSelect in FOptions.FSelectionOptions) and Assigned(HitInfo.HitNode))) then + begin + ToggleNode(HitInfo.HitNode); + MayEdit := False; + end; + end; + end; + end; + end; + + if MayEdit and Assigned(FFocusedNode) and (FFocusedNode = HitInfo.HitNode) and + (FFocusedColumn = HitInfo.HitColumn) and CanEdit(FFocusedNode, HitInfo.HitColumn) then + begin + DoStateChange([tsEditPending]); + FEditColumn := FFocusedcolumn; + SetTimer(Handle, EditTimer, FEditDelay, nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleMouseDown(var Message: TWMMouse; var HitInfo: THitInfo); + +// centralized mouse button down handling + +var + LastFocused: PVirtualNode; + Column: TColumnIndex; + ShiftState: TShiftState; + + // helper variables to shorten boolean equations/expressions + AutoDrag, // automatic (or allowed) drag start + IsHit, // the node's caption or images are hit + IsCellHit, // for grid extension or full row select (but not check box, button) + IsAnyHit, // either IsHit or IsCellHit + IsHeightTracking, // height tracking + MultiSelect, // multiselection is enabled + ShiftEmpty, // ShiftState = [] + NodeSelected: Boolean; // the new node (if any) is selected + NewColumn: Boolean; // column changed + NewNode: Boolean; // Node changed. + NeedChange: Boolean; // change event is required for selection change + CanClear: Boolean; + NewCheckState: TCheckState; + AltPressed: Boolean; // Pressing the Alt key enables special processing for selection. + FullRowDrag: Boolean; // Start dragging anywhere within a node's bound. + NodeRect: TRect; + +begin + if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then + begin + StopWheelPanning; + Exit; + end; + + if tsEditPending in FStates then + begin + StopTimer(EditTimer); + DoStateChange([], [tsEditPending]); + end; + + if not (tsEditing in FStates) or DoEndEdit then + begin + // Focus change. Don't use the SetFocus method as this does not work for MDI windows. + if not Focused and CanFocus then + begin + Windows.SetFocus(Handle); + // Repeat the hit test as an OnExit event might got triggered that could modify the tree. + GetHitTestInfoAt(Message.XPos, Message.YPos, True, HitInfo); + end; + + // Keep clicked column in case the application needs it. + FHeader.FColumns.FClickIndex := HitInfo.HitColumn; + + // Change column only if we have hit the node label. + if (hiOnItemLabel in HitInfo.HitPositions) or + (toFullRowSelect in FOptions.FSelectionOptions) or + (toGridExtensions in FOptions.FMiscOptions) then + begin + NewColumn := FFocusedColumn <> HitInfo.HitColumn; + if toExtendedFocus in FOptions.FSelectionOptions then + Column := HitInfo.HitColumn + else + Column := FHeader.MainColumn; + end + else + begin + NewColumn := False; + Column := FFocusedColumn; + end; + + if NewColumn and + (not FHeader.AllowFocus(Column)) then + begin + NewColumn := False; + Column := FFocusedColumn; + end; + + NewNode := FFocusedNode <> HitInfo.HitNode; + + // Translate keys and filter out shift and control key. + ShiftState := KeysToShiftState(Message.Keys) * [ssShift, ssCtrl, ssAlt]; + if ssAlt in ShiftState then + begin + AltPressed := True; + // Remove the Alt key from the shift state. It is not meaningful there. + Exclude(ShiftState, ssAlt); + end + else + AltPressed := False; + + // Various combinations determine what states the tree enters now. + // We initialize shorthand variables to avoid the following expressions getting too large + // and to avoid repeative expensive checks. + IsHit := not AltPressed and not (toSimpleDrawSelection in FOptions.FSelectionOptions) and + ((hiOnItemLabel in HitInfo.HitPositions) or (hiOnNormalIcon in HitInfo.HitPositions)); + IsCellHit := not AltPressed and not IsHit and Assigned(HitInfo.HitNode) and + ([hiOnItemButton, hiOnItemCheckBox] * HitInfo.HitPositions = []) and + ((toFullRowSelect in FOptions.FSelectionOptions) or + ((toGridExtensions in FOptions.FMiscOptions) and (HitInfo.HitColumn > NoColumn))); + IsAnyHit := IsHit or IsCellHit; + MultiSelect := toMultiSelect in FOptions.FSelectionOptions; + ShiftEmpty := ShiftState = []; + NodeSelected := IsAnyHit and (vsSelected in HitInfo.HitNode.States); + FullRowDrag := toFullRowDrag in FOptions.FMiscOptions; + IsHeightTracking := (Message.Msg = WM_LBUTTONDOWN) and + (hiOnItem in HitInfo.HitPositions) and + ([hiUpperSplitter, hiLowerSplitter] * HitInfo.HitPositions <> []); + + // Dragging might be started in the inherited handler manually (which is discouraged for stability reasons) + // the test for manual mode is done below (after the focused node is set). + AutoDrag := ((DragMode = dmAutomatic) or Dragging) and (not IsCellHit or FullRowDrag); + + // Query the application to learn if dragging may start now (if set to dmManual). + if Assigned(HitInfo.HitNode) and not AutoDrag and (DragMode = dmManual) then + AutoDrag := DoBeforeDrag(HitInfo.HitNode, Column) and (not IsCellHit or FullRowDrag); + + // handle node height tracking + if IsHeightTracking then + begin + if hiUpperSplitter in HitInfo.HitPositions then + FHeightTrackNode := GetPreviousVisible(HitInfo.HitNode, True) + else + FHeightTrackNode := HitInfo.HitNode; + + if CanSplitterResizeNode(Point(Message.XPos, Message.YPos), FHeightTrackNode, HitInfo.HitColumn) then + begin + FHeightTrackColumn := HitInfo.HitColumn; + NodeRect := GetDisplayRect(FHeightTrackNode, FHeightTrackColumn, False); + FHeightTrackPoint := Point(NodeRect.Left, NodeRect.Top); + DoStateChange([tsNodeHeightTrackPending]); + Exit; + end; + end; + + // handle button clicks + if (hiOnItemButton in HitInfo.HitPositions) and (vsHasChildren in HitInfo.HitNode.States) then + begin + ToggleNode(HitInfo.HitNode); + Exit; + end; + + // check event + if hiOnItemCheckBox in HitInfo.HitPositions then + begin + if (FStates * [tsMouseCheckPending, tsKeyCheckPending] = []) and not (vsDisabled in HitInfo.HitNode.States) then + begin + with HitInfo.HitNode^ do + NewCheckState := DetermineNextCheckState(CheckType, CheckState); + if (ssLeft in KeysToShiftState(Message.Keys)) and DoChecking(HitInfo.HitNode, NewCheckState) then + begin + DoStateChange([tsMouseCheckPending]); + FCheckNode := HitInfo.HitNode; + FPendingCheckState := NewCheckState; + FCheckNode.CheckState := PressedState[FCheckNode.CheckState]; + InvalidateNode(HitInfo.HitNode); + end; + end; + Exit; + end; + + // Keep this node's level in case we need it for constraint selection. + if (FRoot.ChildCount > 0) and ShiftEmpty or (FSelectionCount = 0) then + if Assigned(HitInfo.HitNode) then + FLastSelectionLevel := GetNodeLevel(HitInfo.HitNode) + else + FLastSelectionLevel := GetNodeLevel(GetLastVisibleNoInit(nil, True)); + + // pending clearance + if MultiSelect and ShiftEmpty and not (hiOnItemCheckbox in HitInfo.HitPositions) and IsAnyHit and AutoDrag and + NodeSelected and not FSelectionLocked then + DoStateChange([tsClearPending]); + + // immediate clearance + // Determine for the right mouse button if there is a popup menu. In this case and if drag'n drop is pending + // the current selection has to stay as it is. + with HitInfo, Message do + CanClear := not AutoDrag and + (not (tsRightButtonDown in FStates) or not HasPopupMenu(HitNode, HitColumn, Point(XPos, YPos))); + + // User starts a selection with a selection rectangle. + if not (toDisableDrawSelection in FOptions.FSelectionOptions) and not (IsHit or FullRowDrag) and MultiSelect then + begin + SetCapture(Handle); + DoStateChange([tsDrawSelPending]); + FDrawSelShiftState := ShiftState; + FNewSelRect := Rect(Message.XPos + FEffectiveOffsetX, Message.YPos - FOffsetY, Message.XPos + FEffectiveOffsetX, + Message.YPos - FOffsetY); + FLastSelRect := Rect(0, 0, 0, 0); + end; + + if not FSelectionLocked and ((not (IsAnyHit or FullRowDrag) and MultiSelect and ShiftEmpty) or + (IsAnyHit and (not NodeSelected or (NodeSelected and CanClear)) and (ShiftEmpty or not MultiSelect))) then + begin + Assert(not (tsClearPending in FStates), 'Pending and direct clearance are mutual exclusive!'); + + // If the currently hit node was already selected then we have to reselect it again after clearing the current + // selection, but without a change event if it is the only selected node. + // The same applies if the Alt key is pressed, which allows to start drawing the selection rectangle also + // on node captions and images. Here the previous selection state does not matter, though. + if NodeSelected or (AltPressed and Assigned(HitInfo.HitNode) and (HitInfo.HitColumn = FHeader.MainColumn)) then + begin + NeedChange := FSelectionCount > 1; + InternalClearSelection; + InternalAddToSelection(HitInfo.HitNode, True); + if NeedChange then + begin + Invalidate; + Change(nil); + end; + end + else + ClearSelection; + end; + + // pending node edit + if Focused and + ((hiOnItemLabel in HitInfo.HitPositions) or ((toGridExtensions in FOptions.FMiscOptions) and + (hiOnItem in HitInfo.HitPositions))) and NodeSelected and not NewColumn and ShiftEmpty then + DoStateChange([tsEditPending]); + + if not (toDisableDrawSelection in FOptions.FSelectionOptions) and not (IsHit or FullRowDrag) and MultiSelect then + begin + // The original code here was moved up to fix issue #187. + // In order not to break the semantics of this procedure, we are leaving these if statements here + if not IsCellHit then + Exit; + end; + + // Keep current mouse position. + FLastClickPos := Point(Message.XPos, Message.YPos); + + // Handle selection and node focus change. + if (IsHit or IsCellHit) and + DoFocusChanging(FFocusedNode, HitInfo.HitNode, FFocusedColumn, Column) then + begin + if NewColumn then + begin + InvalidateColumn(FFocusedColumn); + InvalidateColumn(Column); + FFocusedColumn := Column; + end; + if DragKind = dkDock then + begin + StopTimer(ScrollTimer); + DoStateChange([], [tsScrollPending, tsScrolling]); + end; + // Get the currently focused node to make multiple multi-selection blocks possible. + LastFocused := FFocusedNode; + if NewNode then + DoFocusNode(HitInfo.HitNode, False); + + if MultiSelect and not ShiftEmpty then + HandleClickSelection(LastFocused, HitInfo.HitNode, ShiftState, AutoDrag) + else + begin + if ShiftEmpty then + FRangeAnchor := HitInfo.HitNode; + + // If the hit node is not yet selected then do it now. + if not NodeSelected then + AddToSelection(HitInfo.HitNode); + end; + + if NewNode or NewColumn then + begin + ScrollIntoView(FFocusedNode, toCenterScrollIntoView in FOptions.SelectionOptions, + not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions) and not (toFullRowSelect in FOptions.SelectionOptions)); + DoFocusChange(FFocusedNode, FFocusedColumn); + end; + end; + + // Drag'n drop initiation + // If we lost focus in the interim the button states would be cleared in WM_KILLFOCUS. + if AutoDrag and IsAnyHit and (FStates * [tsLeftButtonDown, tsRightButtonDown, tsMiddleButtonDown] <> []) then + BeginDrag(False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.HandleMouseUp(var Message: TWMMouse; const HitInfo: THitInfo); + +// Counterpart to the mouse down handler. + +var + ReselectFocusedNode: Boolean; + +begin + ReleaseCapture; + + if not (tsVCLDragPending in FStates) then + begin + // reset pending or persistent states + if IsMouseSelecting then + begin + DoStateChange([], [tsDrawSelecting, tsDrawSelPending, tsToggleFocusedSelection]); + Invalidate; + end; + + if tsClearPending in FStates then + begin + ReselectFocusedNode := Assigned(FFocusedNode) and (vsSelected in FFocusedNode.States); + ClearSelection; + if ReselectFocusedNode then + AddToSelection(FFocusedNode); + end; + + if (tsToggleFocusedSelection in FStates) and (HitInfo.HitNode = FFocusedNode) and Assigned(HitInfo.HitNode) then //Prevent AV when dereferencing HitInfo.HitNode below, see bug #100 + begin + if vsSelected in HitInfo.HitNode.States then + RemoveFromSelection(HitInfo.HitNode) + else + AddToSelection(HitInfo.HitNode); + InvalidateNode(HitInfo.HitNode); + end; + + DoStateChange([], [tsOLEDragPending, tsOLEDragging, tsClearPending, tsDrawSelPending, tsToggleFocusedSelection, + tsScrollPending, tsScrolling]); + StopTimer(ScrollTimer); + + if tsMouseCheckPending in FStates then + begin + DoStateChange([], [tsMouseCheckPending]); + // Is the mouse still over the same node? + if (HitInfo.HitNode = FCheckNode) and (hiOnItem in HitInfo.HitPositions) then + DoCheckClick(FCheckNode, FPendingCheckState) + else + FCheckNode.CheckState := UnpressedState[FCheckNode.CheckState]; + InvalidateNode(FCheckNode); + FCheckNode := nil; + end; + + if (FHeader.FColumns.FClickIndex > NoColumn) and (FHeader.FColumns.FClickIndex = HitInfo.HitColumn) then + DoColumnClick(HitInfo.HitColumn, KeysToShiftState(Message.Keys)); + + if HitInfo.HitNode <> nil then + DoNodeClick(HitInfo); + + // handle a pending edit event + if tsEditPending in FStates then + begin + // Is the mouse still over the same node? + if (HitInfo.HitNode = FFocusedNode) and (hiOnItem in HitInfo.HitPositions) and + (toEditOnClick in FOptions.FMiscOptions) and CanEdit(FFocusedNode, HitInfo.HitColumn) then + begin + FEditColumn := FFocusedColumn; + SetTimer(Handle, EditTimer, FEditDelay, nil); + end + else + DoStateChange([], [tsEditPending]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HasImage(Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex): Boolean; + +// Determines whether the given node has got an image of the given kind in the given column. +// Returns True if so, otherwise False. +// The given node will be implicitly initialized if needed. + +var + Ghosted: Boolean; + Index: Integer; + +begin + if not (vsInitialized in Node.States) then + InitNode(Node); + + Index := -1; + Ghosted := False; + DoGetImageIndex(Node, Kind, Column, Ghosted, Index); + Result := Index > -1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HasPopupMenu(Node: PVirtualNode; Column: TColumnIndex; Pos: TPoint): Boolean; + +// Determines whether the tree got a popup menu, either in its PopupMenu property, via the OnGetPopupMenu event or +// through inheritance. The latter case must be checked by the descendant which must override this method. + +begin + Result := Assigned(PopupMenu) or Assigned(DoGetPopupMenu(Node, Column, Pos)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InitChildren(Node: PVirtualNode); + +// Initiates the initialization of the child number of the given node. + +var + Count: Cardinal; + +begin + if Assigned(Node) and (Node <> FRoot) and (vsHasChildren in Node.States) then + begin + Count := Node.ChildCount; + DoInitChildren(Node, Count); + if Count = 0 then + begin + // Remove any child node which is already there. + DeleteChildren(Node); + Exclude(Node.States, vsHasChildren); + end + else + SetChildCount(Node, Count); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InitNode(Node: PVirtualNode); + +// Initiates the initialization of the given node to allow the application to load needed data for it. + +var + InitStates: TVirtualNodeInitStates; + +begin + with Node^ do + begin + InitStates := []; + if vsInitialized in States then + Include(InitStates, ivsReInit); + Include(States, vsInitialized); + if Parent = FRoot then + DoInitNode(nil, Node, InitStates) + else + DoInitNode(Parent, Node, InitStates); + if ivsDisabled in InitStates then + Include(States, vsDisabled); + if ivsHasChildren in InitStates then + Include(States, vsHasChildren); + if ivsSelected in InitStates then + begin + FSingletonNodeArray[0] := Node; + InternalAddToSelection(FSingletonNodeArray, 1, False); + end; + if ivsMultiline in InitStates then + Include(States, vsMultiline); + if ivsFiltered in InitStates then + begin + Include(States, vsFiltered); + if not (toShowFilteredNodes in FOptions.FPaintOptions) then + begin + AdjustTotalHeight(Node, -NodeHeight, True); + if FullyVisible[Node] then + Dec(FVisibleCount); + UpdateScrollBars(True); + end; + end; + + // Expanded may already be set (when called from ReinitNode) or be set in DoInitNode, allow both. + if (vsExpanded in Node.States) xor (ivsExpanded in InitStates) then + begin + // Expand node if not yet done (this will automatically initialize child nodes). + if ivsExpanded in InitStates then + ToggleNode(Node) + else + // If the node already was expanded then explicitly trigger child initialization. + if vsHasChildren in Node.States then + InitChildren(Node); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalAddFromStream(Stream: TStream; Version: Integer; Node: PVirtualNode); + +// Loads all details for Node (including its children) from the given stream. +// Because the new nodes might be selected this method also fixes the selection array. + +var + Stop: PVirtualNode; + Index: Integer; + LastTotalHeight: Cardinal; + WasFullyVisible: Boolean; + +begin + Assert(Node <> FRoot, 'The root node cannot be loaded from stream.'); + + // Keep the current total height value of Node as it has already been applied + // but might change in the load and fixup code. We have to adjust that afterwards. + LastTotalHeight := Node.TotalHeight; + WasFullyVisible := FullyVisible[Node] and not IsEffectivelyFiltered[Node]; + + // Read in the new nodes. + ReadNode(Stream, Version, Node); + + // One time update of node-internal states and the global visibility counter. + // This is located here to ease and speed up the loading process. + FixupTotalCount(Node); + AdjustTotalCount(Node.Parent, Node.TotalCount - 1, True); // -1 because Node itself was already set. + FixupTotalHeight(Node); + AdjustTotalHeight(Node.Parent, Node.TotalHeight - LastTotalHeight, True); + + // New nodes are always visible, so the visible node count has been increased already. + // If Node is now invisible we have to take back this increment and don't need to add any visible child node. + if not FullyVisible[Node] or IsEffectivelyFiltered[Node] then + begin + if WasFullyVisible then + Dec(FVisibleCount); + end + else + // It can never happen that the node is now fully visible but was not before as this would require + // that the visibility state of one of its parents has changed, which cannot happen during loading. + Inc(FVisibleCount, CountVisibleChildren(Node)); + + // Fix selection array. + ClearTempCache; + if Node = FRoot then + Stop := nil + else + Stop := Node.NextSibling; + + if toMultiSelect in FOptions.FSelectionOptions then + begin + // Add all nodes which were selected before to the current selection (unless they are already there). + while Node <> Stop do + begin + if (vsSelected in Node.States) and not FindNodeInSelection(Node, Index, 0, High(FSelection)) then + InternalCacheNode(Node); + Node := GetNextNoInit(Node); + end; + if FTempNodeCount > 0 then + AddToSelection(FTempNodeCache, FTempNodeCount, True); + ClearTempCache; + end + else // No further selected nodes allowed so delete the corresponding flag in all new nodes. + while Node <> Stop do + begin + Exclude(Node.States, vsSelected); + Node := GetNextNoInit(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InternalAddToSelection(Node: PVirtualNode; ForceInsert: Boolean): Boolean; + +begin + Assert(Assigned(Node), 'Node must not be nil!'); + FSingletonNodeArray[0] := Node; + Result := InternalAddToSelection(FSingletonNodeArray, 1, ForceInsert); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InternalAddToSelection(const NewItems: TNodeArray; NewLength: Integer; + ForceInsert: Boolean): Boolean; + +// Internal version of method AddToSelection which does not trigger OnChange events + +var + I, J: Integer; + CurrentEnd: Integer; + Constrained, + SiblingConstrained: Boolean; + +begin + // The idea behind this code is to use a kind of reverse merge sort. QuickSort is quite fast + // and would do the job here too but has a serious problem with already sorted lists like FSelection. + + // 1) Remove already selected items, mark all other as being selected. + if ForceInsert then + begin + for I := 0 to NewLength - 1 do + begin + Include(NewItems[I].States, vsSelected); + if Assigned(FOnAddToSelection) then + FOnAddToSelection(Self, NewItems[I]); + end; + end + else + begin + Constrained := toLevelSelectConstraint in FOptions.FSelectionOptions; + if Constrained and (FLastSelectionLevel = -1) then + FLastSelectionLevel := GetNodeLevel(NewItems[0]); + SiblingConstrained := toSiblingSelectConstraint in FOptions.FSelectionOptions; + if SiblingConstrained and (FRangeAnchor = nil) then + FRangeAnchor := NewItems[0]; + + for I := 0 to NewLength - 1 do + if ([vsSelected, vsDisabled] * NewItems[I].States <> []) or + (Constrained and (Cardinal(FLastSelectionLevel) <> GetNodeLevel(NewItems[I]))) or + (SiblingConstrained and (FRangeAnchor.Parent <> NewItems[I].Parent)) then + Inc(PAnsiChar(NewItems[I])) + else + begin + Include(NewItems[I].States, vsSelected); + if Assigned(FOnAddToSelection) then + FOnAddToSelection(Self, NewItems[I]); + end; + end; + + I := PackArray(NewItems, NewLength); + if I > -1 then + NewLength := I; + + Result := NewLength > 0; + if Result then + begin + // 2) Sort the new item list so we can easily traverse it. + if NewLength > 1 then + QuickSort(NewItems, 0, NewLength - 1); + // 3) Make room in FSelection for the new items. + if FSelectionCount + NewLength >= Length(FSelection) then + SetLength(FSelection, FSelectionCount + NewLength); + + // 4) Merge in new items + J := NewLength - 1; + CurrentEnd := FSelectionCount - 1; + + while J >= 0 do + begin + // First insert all new entries which are greater than the greatest entry in the old list. + // If the current end marker is < 0 then there's nothing more to move in the selection + // array and only the remaining new items must be inserted. + if CurrentEnd >= 0 then + begin + while (J >= 0) and (PAnsiChar(NewItems[J]) > PAnsiChar(FSelection[CurrentEnd])) do + begin + FSelection[CurrentEnd + J + 1] := NewItems[J]; + Dec(J); + end; + // early out if nothing more needs to be copied + if J < 0 then + Break; + end + else + begin + // insert remaining new entries at position 0 + Move(NewItems[0], FSelection[0], (J + 1) * SizeOf(Pointer)); + // nothing more to do so exit main loop + Break; + end; + + // find the last entry in the remaining selection list which is smaller then the largest + // entry in the remaining new items list + FindNodeInSelection(NewItems[J], I, 0, CurrentEnd); + Dec(I); + // move all entries which are greater than the greatest entry in the new items list up + // so the remaining gap travels down to where new items must be inserted + Move(FSelection[I + 1], FSelection[I + J + 2], (CurrentEnd - I) * SizeOf(Pointer)); + CurrentEnd := I; + end; + + Inc(FSelectionCount, NewLength); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalCacheNode(Node: PVirtualNode); + +// Adds the given node to the temporary node cache (used when collecting possibly large amounts of nodes). + +var + Len: Cardinal; + +begin + Len := Length(FTempNodeCache); + if FTempNodeCount = Len then + begin + if Len < 100 then + Len := 100 + else + Len := Len + Len div 10; + SetLength(FTempNodeCache, Len); + end; + FTempNodeCache[FTempNodeCount] := Node; + Inc(FTempNodeCount); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalClearSelection; + +var + Count: Integer; + +begin + // It is possible that there are invalid node references in the selection array + // if the tree update is locked and changes in the structure were made. + // Handle this potentially dangerous situation by packing the selection array explicitely. + if FUpdateCount > 0 then + begin + Count := PackArray(FSelection, FSelectionCount); + if Count > -1 then + begin + FSelectionCount := Count; + SetLength(FSelection, FSelectionCount); + end; + end; + + while FSelectionCount > 0 do + begin + Dec(FSelectionCount); + Exclude(FSelection[FSelectionCount].States, vsSelected); + if Assigned(FOnRemoveFromSelection) then + FOnRemoveFromSelection(Self, FSelection[FSelectionCount]); + end; + ResetRangeAnchor; + FSelection := nil; + DoStateChange([], [tsClearPending]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalConnectNode(Node, Destination: PVirtualNode; Target: TBaseVirtualTree; + Mode: TVTNodeAttachMode); + +// Connects Node with Destination depending on Mode. +// No error checking takes place. Node as well as Destination must be valid. Node must never be a root node and +// Destination must not be a root node if Mode is amInsertBefore or amInsertAfter. + +var + Run: PVirtualNode; + +begin + // Keep in mind that the destination node might belong to another tree. + with Target do + begin + case Mode of + amInsertBefore: + begin + Node.PrevSibling := Destination.PrevSibling; + Destination.PrevSibling := Node; + Node.NextSibling := Destination; + Node.Parent := Destination.Parent; + Node.Index := Destination.Index; + if Node.PrevSibling = nil then + Node.Parent.FirstChild := Node + else + Node.PrevSibling.NextSibling := Node; + + // reindex all following nodes + Run := Destination; + while Assigned(Run) do + begin + Inc(Run.Index); + Run := Run.NextSibling; + end; + + Inc(Destination.Parent.ChildCount); + Include(Destination.Parent.States, vsHasChildren); + AdjustTotalCount(Destination.Parent, Node.TotalCount, True); + + // Add the new node's height only if its parent is expanded. + if FullyVisible[Node] then + begin + AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True); + Inc(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + end; + end; + amInsertAfter: + begin + Node.NextSibling := Destination.NextSibling; + Destination.NextSibling := Node; + Node.PrevSibling := Destination; + Node.Parent := Destination.Parent; + if Node.NextSibling = nil then + Node.Parent.LastChild := Node + else + Node.NextSibling.PrevSibling := Node; + Node.Index := Destination.Index; + + // reindex all following nodes + Run := Node; + while Assigned(Run) do + begin + Inc(Run.Index); + Run := Run.NextSibling; + end; + + Inc(Destination.Parent.ChildCount); + Include(Destination.Parent.States, vsHasChildren); + AdjustTotalCount(Destination.Parent, Node.TotalCount, True); + + // Add the new node's height only if its parent is expanded. + if FullyVisible[Node] then + begin + AdjustTotalHeight(Destination.Parent, Node.TotalHeight, True); + Inc(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + end; + end; + amAddChildFirst: + begin + if Assigned(Destination.FirstChild) then + begin + // If there's a first child then there must also be a last child. + Destination.FirstChild.PrevSibling := Node; + Node.NextSibling := Destination.FirstChild; + Destination.FirstChild := Node; + end + else + begin + // First child node at this location. + Destination.FirstChild := Node; + Destination.LastChild := Node; + Node.NextSibling := nil; + end; + Node.PrevSibling := nil; + Node.Parent := Destination; + Node.Index := 0; + // reindex all following nodes + Run := Node.NextSibling; + while Assigned(Run) do + begin + Inc(Run.Index); + Run := Run.NextSibling; + end; + + Inc(Destination.ChildCount); + Include(Destination.States, vsHasChildren); + AdjustTotalCount(Destination, Node.TotalCount, True); + // Add the new node's height only if its parent is expanded. + if FullyVisible[Node] then + begin + AdjustTotalHeight(Destination, Node.TotalHeight, True); + Inc(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + end; + end; + amAddChildLast: + begin + if Assigned(Destination.LastChild) then + begin + // If there's a last child then there must also be a first child. + Destination.LastChild.NextSibling := Node; + Node.PrevSibling := Destination.LastChild; + Destination.LastChild := Node; + end + else + begin + // first child node at this location + Destination.FirstChild := Node; + Destination.LastChild := Node; + Node.PrevSibling := nil; + end; + Node.NextSibling := nil; + Node.Parent := Destination; + if Assigned(Node.PrevSibling) then + Node.Index := Node.PrevSibling.Index + 1 + else + Node.Index := 0; + Inc(Destination.ChildCount); + Include(Destination.States, vsHasChildren); + AdjustTotalCount(Destination, Node.TotalCount, True); + // Add the new node's height only if its parent is expanded. + if FullyVisible[Node] then + begin + AdjustTotalHeight(Destination, Node.TotalHeight, True); + Inc(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + end; + end; + else + // amNoWhere: do nothing + end; + + // Remove temporary states. + Node.States := Node.States - [vsChecking, vsCutOrCopy, vsDeleting, vsClearing]; + + // Update the hidden children flag of the parent. + if (Mode <> amNoWhere) and (Node.Parent <> FRoot) then + begin + // If we have added a visible node then simply remove the all-children-hidden flag. + if IsEffectivelyVisible[Node] then + Exclude(Node.Parent.States, vsAllChildrenHidden) + else + // If we have added an invisible node and this is the only child node then + // make sure the all-children-hidden flag is in a determined state. + // If there were child nodes before then no action is needed. + if Node.Parent.ChildCount = 1 then + Include(Node.Parent.States, vsAllChildrenHidden); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InternalData(Node: PVirtualNode): Pointer; + +begin + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalDisconnectNode(Node: PVirtualNode; KeepFocus: Boolean; Reindex: Boolean = True); + +// Disconnects the given node from its parent and siblings. The node's pointer are not reset so they can still be used +// after return from this method (probably a very short time only!). +// If KeepFocus is True then the focused node is not reset. This is useful if the given node is reconnected to the tree +// immediately after return of this method and should stay being the focused node if it was it before. +// Note: Node must not be nil or the root node. + +var + Parent, + Run: PVirtualNode; + Index: Integer; + AdjustHeight: Boolean; + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Node must neither be nil nor the root node.'); + + if (Node = FFocusedNode) and not KeepFocus then + begin + DoFocusNode(nil, False); + DoFocusChange(FFocusedNode, FFocusedColumn); + end; + + if Node = FRangeAnchor then + ResetRangeAnchor; + + // Update the hidden children flag of the parent. + if (Node.Parent <> FRoot) and not (vsClearing in Node.Parent.States) then + if FUpdateCount = 0 then + DetermineHiddenChildrenFlag(Node.Parent) + else + Include(FStates, tsUpdateHiddenChildrenNeeded); + + if not (vsDeleting in Node.States) then + begin + // Some states are only temporary so take them out. + Node.States := Node.States - [vsChecking]; + Parent := Node.Parent; + Dec(Parent.ChildCount); + AdjustHeight := (vsExpanded in Parent.States) and (vsVisible in Node.States); + if Parent.ChildCount = 0 then + begin + Parent.States := Parent.States - [vsAllChildrenHidden, vsHasChildren]; + if (Parent <> FRoot) and (vsExpanded in Parent.States) then + Exclude(Parent.States, vsExpanded); + end; + AdjustTotalCount(Parent, -Integer(Node.TotalCount), True); + if AdjustHeight then + AdjustTotalHeight(Parent, -Integer(Node.TotalHeight), True); + if FullyVisible[Node] then + Dec(FVisibleCount, CountVisibleChildren(Node) + Cardinal(IfThen(IsEffectivelyVisible[Node], 1))); + + if Assigned(Node.PrevSibling) then + Node.PrevSibling.NextSibling := Node.NextSibling + else + Parent.FirstChild := Node.NextSibling; + + if Assigned(Node.NextSibling) then + begin + Node.NextSibling.PrevSibling := Node.PrevSibling; + // Reindex all following nodes. + if Reindex then + begin + Run := Node.NextSibling; + Index := Node.Index; + while Assigned(Run) do + begin + Run.Index := Index; + Inc(Index); + Run := Run.NextSibling; + end; + end; + end + else + Parent.LastChild := Node.PrevSibling; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InternalRemoveFromSelection(Node: PVirtualNode); + +// Special version to mark a node to be no longer in the current selection. PackArray must +// be used to remove finally those entries. + +var + Index: Integer; + +begin + // Because pointers are always DWORD aligned we can simply increment all those + // which we want to have removed (see also PackArray) and still have the + // order in the list preserved. + if FindNodeInSelection(Node, Index, -1, -1) then + begin + Exclude(Node.States, vsSelected); + Inc(PAnsiChar(FSelection[Index])); + if Assigned(FOnRemoveFromSelection) then + FOnRemoveFromSelection(Self, Node); + AdviseChangeEvent(False, Node, crIgnore); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InvalidateCache; + +// Marks the cache as invalid. + +begin + DoStateChange([tsValidationNeeded], [tsUseCache]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MarkCutCopyNodes; + +// Sets the vsCutOrCopy style in every currently selected but not disabled node to indicate it is +// now part of a clipboard operation. + +var + Nodes: TNodeArray; + I: Integer; + +begin + Nodes := nil; + if FSelectionCount > 0 then + begin + // need the current selection sorted to exclude selected nodes which are children, grandchildren etc. of + // already selected nodes + Nodes := GetSortedSelection(False); + for I := 0 to High(Nodes) do + with Nodes[I]^ do + if not (vsDisabled in States) then + Include(States, vsCutOrCopy); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Loaded; + +var + LastRootCount: Cardinal; + IsReadOnly: Boolean; + +begin + inherited; + + // If a root node count has been set during load of the tree then update its child structure now + // as this hasn't been done yet in this case. + if (tsNeedRootCountUpdate in FStates) and (FRoot.ChildCount > 0) then + begin + DoStateChange([], [tsNeedRootCountUpdate]); + IsReadOnly := toReadOnly in FOptions.FMiscOptions; + Exclude(FOptions.FMiscOptions, toReadOnly); + LastRootCount := FRoot.ChildCount; + FRoot.ChildCount := 0; + BeginUpdate; + SetChildCount(FRoot, LastRootCount); + EndUpdate; + if IsReadOnly then + Include(FOptions.FMiscOptions, toReadOnly); + end; + + // Prevent the object inspector at design time from marking the header as being modified + // when auto resize is enabled. + Updating; + try + FHeader.UpdateMainColumn; + FHeader.FColumns.FixPositions; + if toAutoBidiColumnOrdering in FOptions.FAutoOptions then + FHeader.FColumns.ReorderColumns(UseRightToLeftAlignment); + FHeader.RecalculateHeader; + if hoAutoResize in FHeader.FOptions then + FHeader.FColumns.AdjustAutoSize(InvalidColumn, True); + finally + Updated; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MainColumnChanged; + +begin + DoCancelEdit; + + if Assigned(FAccessibleItem) then + NotifyWinEvent(EVENT_OBJECT_NAMECHANGE, Handle, OBJID_CLIENT, CHILDID_SELF); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MouseMove(Shift: TShiftState; X, Y: Integer); + +var + R: TRect; + +begin + if tsNodeHeightTrackPending in FStates then + begin + // Remove hint if shown currently. + Application.CancelHint; + + // Stop wheel panning if active. + StopWheelPanning; + + // Stop timers + StopTimer(ExpandTimer); + StopTimer(EditTimer); + StopTimer(HeaderTimer); + StopTimer(ScrollTimer); + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + + DoStateChange([tsNodeHeightTracking], [tsScrollPending, tsScrolling, tsEditPending, tsOLEDragPending, tsVCLDragPending, + tsIncrementalSearching, tsNodeHeightTrackPending]); + end; + + if tsDrawSelPending in FStates then + begin + // Remove current selection in case the user clicked somewhere in the window (but not a node) + // and moved the mouse. + if CalculateSelectionRect(X, Y) then + begin + InvalidateRect(Handle, @FNewSelRect, False); + UpdateWindow(Handle); + if (Abs(FNewSelRect.Right - FNewSelRect.Left) > Mouse.DragThreshold) or + (Abs(FNewSelRect.Bottom - FNewSelRect.Top) > Mouse.DragThreshold) then + begin + if tsClearPending in FStates then + begin + DoStateChange([], [tsClearPending]); + ClearSelection; + end; + DoStateChange([tsDrawSelecting], [tsDrawSelPending]); + + // Reset to main column for multiselection. + FocusedColumn := FHeader.MainColumn; + + // The current rectangle may already include some node captions. Handle this. + if HandleDrawSelection(X, Y) then + InvalidateRect(Handle, nil, False); + end; + end; + end + else + begin + if tsNodeHeightTracking in FStates then + begin + // Handle height tracking. + if DoNodeHeightTracking(FHeightTrackNode, FHeightTrackColumn, FHeader.GetShiftState, + FHeightTrackPoint, Point(X, Y)) then + begin + // Avoid negative (or zero) node heights. + if FHeightTrackPoint.Y >= Y then + Y := FHeightTrackPoint.Y + 1; + SetNodeHeight(FHeightTrackNode, Y - FHeightTrackPoint.Y); + UpdateWindow(Handle); + Exit; + end; + end; + + // If both wheel panning and auto scrolling are pending then the user moved the mouse while holding down the + // middle mouse button. This means panning is being used, hence remove the wheel scroll flag. + if [tsWheelPanning, tsWheelScrolling] * FStates = [tsWheelPanning, tsWheelScrolling] then + begin + if ((Abs(FLastClickPos.X - X) >= Mouse.DragThreshold) or (Abs(FLastClickPos.Y - Y) >= Mouse.DragThreshold)) then + DoStateChange([], [tsWheelScrolling]); + end; + + // Really start dragging if the mouse has been moved more than the threshold. + if (tsOLEDragPending in FStates) and ((Abs(FLastClickPos.X - X) >= FDragThreshold) or + (Abs(FLastClickPos.Y - Y) >= FDragThreshold)) then + DoDragging(FLastClickPos) + else + begin + if CanAutoScroll then + DoAutoScroll(X, Y); + if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then + AdjustPanningCursor(X, Y); + if not IsMouseSelecting then + begin + HandleHotTrack(X, Y); + inherited MouseMove(Shift, X, Y); + end + else + begin + // Handle draw selection if required, but don't do the work twice if the + // auto scrolling code already cares about the selection. + if not (tsScrolling in FStates) and CalculateSelectionRect(X, Y) then + begin + // If something in the selection changed then invalidate the entire + // tree instead trying to figure out the display rects of all changed nodes. + if HandleDrawSelection(X, Y) then + InvalidateRect(Handle, nil, False) + else + begin + UnionRect(R, OrderRect(FNewSelRect), OrderRect(FLastSelRect)); + OffsetRect(R, -FEffectiveOffsetX, FOffsetY); + InvalidateRect(Handle, @R, False); + end; + UpdateWindow(Handle); + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Notification(AComponent: TComponent; Operation: TOperation); + +begin + if (AComponent <> Self) and (Operation = opRemove) then + begin + // Check for components linked to the tree. + if AComponent = FImages then + begin + Images := nil; + if not (csDestroying in ComponentState) then + Invalidate; + end + else + if AComponent = FStateImages then + begin + StateImages := nil; + if not (csDestroying in ComponentState) then + Invalidate; + end + else + if AComponent = FCustomCheckImages then + begin + CustomCheckImages := nil; + FCheckImageKind := ckSystemDefault; + if not (csDestroying in ComponentState) then + Invalidate; + end + else + if AComponent = PopupMenu then + PopupMenu := nil + else + // Check for components linked to the header. + if Assigned(FHeader) then + begin + if AComponent = FHeader.FImages then + FHeader.Images := nil + else + if AComponent = FHeader.PopupMenu then + FHeader.PopupMenu := nil; + end; + end; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.OriginalWMNCPaint(DC: HDC); + +// Unfortunately, the painting for the non-client area in TControl is not always correct and does also not consider +// existing clipping regions, so it has been modified here to take this into account. + +const + InnerStyles: array[TBevelCut] of Integer = (0, BDR_SUNKENINNER, BDR_RAISEDINNER, 0); + OuterStyles: array[TBevelCut] of Integer = (0, BDR_SUNKENOUTER, BDR_RAISEDOUTER, 0); + EdgeStyles: array[TBevelKind] of Integer = (0, 0, BF_SOFT, BF_FLAT); + Ctl3DStyles: array[Boolean] of Integer = (BF_MONO, 0); + +var + RC, RW: TRect; + EdgeSize: Integer; + Size: TSize; + +begin + if (BevelKind <> bkNone) or (BorderWidth > 0) then + begin + RC := Rect(0, 0, Width, Height); + Size := GetBorderDimensions; + InflateRect(RC, Size.cx, Size.cy); + + RW := RC; + + if BevelKind <> bkNone then + begin + DrawEdge(DC, RC, InnerStyles[BevelInner] or OuterStyles[BevelOuter], Byte(BevelEdges) or EdgeStyles[BevelKind] or + Ctl3DStyles[Ctl3D]); + + EdgeSize := 0; + if BevelInner <> bvNone then + Inc(EdgeSize, BevelWidth); + if BevelOuter <> bvNone then + Inc(EdgeSize, BevelWidth); + with TWithSafeRect(RC) do + begin + if beLeft in BevelEdges then + Inc(Left, EdgeSize); + if beTop in BevelEdges then + Inc(Top, EdgeSize); + if beRight in BevelEdges then + Dec(Right, EdgeSize); + if beBottom in BevelEdges then + Dec(Bottom, EdgeSize); + end; + end; + + // Repaint only the part in the original clipping region and not yet drawn parts. + IntersectClipRect(DC, RC.Left, RC.Top, RC.Right, RC.Bottom); + + // Determine inner rectangle to exclude (RC corresponds then to the client area). + InflateRect(RC, -BorderWidth, -BorderWidth); + + // Remove the inner rectangle. + ExcludeClipRect(DC, RC.Left, RC.Top, RC.Right, RC.Bottom); + + // Erase parts not drawn. + Brush.Color := FColors.BorderColor; + Windows.FillRect(DC, RW, Brush.Handle); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Paint; + +// Window paint routine. Used when the tree window needs to be updated. + +var + Window: TRect; + Target: TPoint; + Temp: Integer; + Options: TVTInternalPaintOptions; + RTLOffset: Integer; + +begin + Options := [poBackground, poColumnColor, poDrawFocusRect, poDrawDropMark, poDrawSelection, poGridLines]; + if UseRightToLeftAlignment and FHeader.UseColumns then + RTLOffset := ComputeRTLOffset(True) + else + RTLOffset := 0; + + // The update rect has already been filled in WMPaint, as it is the window's update rect, which gets + // reset when BeginPaint is called (in the ancestor). + // The difference to the DC's clipbox is that it is also valid with internal paint operations used + // e.g. by the Explorer while dragging, but show window content while dragging is disabled. + if not IsRectEmpty(FUpdateRect) then + begin + Temp := Header.Columns.GetVisibleFixedWidth; + if Temp = 0 then + begin + Window := FUpdateRect; + Target := Window.TopLeft; + + // The clipping rectangle is given in client coordinates of the window. We have to convert it into + // a sliding window of the tree image. + OffsetRect(Window, FEffectiveOffsetX - RTLOffset, -FOffsetY); + PaintTree(Canvas, Window, Target, Options); + end + else + begin + // First part, fixed columns + Window := ClientRect; + Window.Right := Temp; + Target := Window.TopLeft; + + OffsetRect(Window, -RTLOffset, -FOffsetY); + PaintTree(Canvas, Window, Target, Options); + + // Second part, other columns + Window := GetClientRect; + + if Temp > Window.Right then + Exit; + + Window.Left := Temp; + Target := Window.TopLeft; + + OffsetRect(Window, FEffectiveOffsetX - RTLOffset, -FOffsetY); + PaintTree(Canvas, Window, Target, Options); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PaintCheckImage(Canvas: TCanvas; const ImageInfo: TVTImageInfo; Selected: Boolean); + +var + ForegroundColor: COLORREF; + R: TRect; + Details: TThemedElementDetails; + +begin + with ImageInfo do + begin + if (tsUseThemes in FStates) and (FCheckImageKind = ckSystemDefault) then + begin + R := Rect(XPos - 1, YPos, XPos + 16, YPos + 16); + Details.Element := teButton; + case Index of + 0..8: // radio buttons + begin + Details.Part := BP_RADIOBUTTON; + Details.State := Index; + end; + 9..20: // check boxes + begin + Details.Part := BP_CHECKBOX; + Details.State := Index - 8; + end; + 21..24: // buttons + begin + Details.Part := BP_PUSHBUTTON; + Details.State := Index - 20; + end; + else + Details.Part := 0; + Details.State := 0; + end; + ThemeServices.DrawElement(Canvas.Handle, Details, R); + if Index in [21..24] then + UtilityImages.Draw(Canvas, XPos - 1, YPos, 4); + end + else + with FCheckImages do + begin + if Selected and not Ghosted then + begin + if Focused or (toPopupMode in FOptions.FPaintOptions) then + ForegroundColor := ColorToRGB(FColors.FocusedSelectionColor) + else + ForegroundColor := ColorToRGB(FColors.UnfocusedSelectionColor); + end + else + ForegroundColor := GetRGBColor(BlendColor); + + ImageList_DrawEx(Handle, Index, Canvas.Handle, XPos, YPos, 0, 0, GetRGBColor(BkColor), ForegroundColor, + ILD_TRANSPARENT); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + TCustomImageListCast = class(TCustomImageList); + +procedure TBaseVirtualTree.PaintImage(var PaintInfo: TVTPaintInfo; ImageInfoIndex: TVTImageInfoIndex; DoOverlay: Boolean); + +const + Style: array[TImageType] of Cardinal = (0, ILD_MASK); + +var + ExtraStyle: Cardinal; + CutNode: Boolean; + PaintFocused: Boolean; + DrawEnabled: Boolean; + +begin + with PaintInfo do + begin + CutNode := (vsCutOrCopy in Node.States) and (tsCutPending in FStates); + PaintFocused := Focused or (toGhostedIfUnfocused in FOptions.FPaintOptions); + + // Since the overlay image must be specified together with the image to draw + // it is meaningfull to retrieve it in advance. + if DoOverlay then + GetImageIndex(PaintInfo, ikOverlay, iiOverlay, Images) + else + PaintInfo.ImageInfo[iiOverlay].Index := -1; + + DrawEnabled := not (vsDisabled in Node.States) and Enabled; + with ImageInfo[ImageInfoIndex] do + begin + if (vsSelected in Node.States) and not (Ghosted or CutNode) then + begin + if PaintFocused or (toPopupMode in FOptions.FPaintOptions) then + Images.BlendColor := FColors.FocusedSelectionColor + else + Images.BlendColor := FColors.UnfocusedSelectionColor; + end + else + Images.BlendColor := Color; + + // If the user returned an index >= 15 then we cannot use the built-in overlay image drawing. + // Instead we do it manually. + if (ImageInfo[iiOverlay].Index > -1) and (ImageInfo[iiOverlay].Index < 15) then + ExtraStyle := ILD_TRANSPARENT or ILD_OVERLAYMASK and IndexToOverlayMask(ImageInfo[iiOverlay].Index + 1) + else + ExtraStyle := ILD_TRANSPARENT; + + // Blend image if enabled and the tree has the focus (or ghosted images must be drawn also if unfocused) ... + if (toUseBlendedImages in FOptions.FPaintOptions) and PaintFocused + // ... and the image is ghosted... + and (Ghosted or + // ... or it is not the check image and the node is selected (but selection is not for the entire row)... + ((vsSelected in Node.States) and + not (toFullRowSelect in FOptions.FSelectionOptions) and + not (toGridExtensions in FOptions.FMiscOptions)) or + // ... or the node must be shown in cut mode. + CutNode) then + ExtraStyle := ExtraStyle or ILD_BLEND50; + + if (vsSelected in Node.States) and not Ghosted then + Images.BlendColor := clDefault; + + TCustomImageListCast(Images).DoDraw(Index, Canvas, XPos, YPos, Style[Images.ImageType] or ExtraStyle, DrawEnabled); + + // Now, draw the overlay. This circumnavigates limitations in the overlay mask index (it has to be 4 bits in size, + // anything larger will be truncated by the ILD_OVERLAYMASK). + // However this will only be done if the overlay image index is > 15, to avoid breaking code that relies + // on overlay image indices (e.g. when using system image lists). + if PaintInfo.ImageInfo[iiOverlay].Index >= 15 then + // Note: XPos and YPos are those of the normal images. + TCustomImageListCast(ImageInfo[iiOverlay].Images).DoDraw(ImageInfo[iiOverlay].Index, Canvas, XPos, YPos, + Style[ImageInfo[iiOverlay].Images.ImageType] or ExtraStyle, DrawEnabled); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; const R: TRect; + ButtonX, ButtonY: Integer; BidiMode: TBiDiMode); + +var + Bitmap: TBitmap; + XPos: Integer; + IsHot: Boolean; + Theme: HTHEME; + Glyph: Integer; + State: Integer; + Pos: TRect; + +begin + IsHot := (toHotTrack in FOptions.FPaintOptions) and (FCurrentHotNode = Node) and FHotNodeButtonHit; + + if vsExpanded in Node.States then + begin + if IsHot then + Bitmap := FHotMinusBM + else + Bitmap := FMinusBM; + end + else + begin + if IsHot then + Bitmap := FHotPlusBM + else + Bitmap := FPlusBM; + end; + + // Draw the node's plus/minus button according to the directionality. + if BidiMode = bdLeftToRight then + XPos := R.Left + ButtonX + else + XPos := R.Right - ButtonX - Bitmap.Width; + + if tsUseExplorerTheme in FStates then + begin + Glyph := IfThen(IsHot, TVP_HOTGLYPH, TVP_GLYPH); + State := IfThen(vsExpanded in Node.States, GLPS_OPENED, GLPS_CLOSED); + Pos := Rect(XPos, R.Top + ButtonY, XPos + Bitmap.Width, R.Top + ButtonY + Bitmap.Height); + Theme := OpenThemeData(Handle, 'TREEVIEW'); + DrawThemeBackground(Theme, Canvas.Handle, Glyph, State, Pos, nil); + CloseThemeData(Theme); + end + else + // Need to draw this masked. + Canvas.Draw(XPos, R.Top + ButtonY, Bitmap); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PaintTreeLines(const PaintInfo: TVTPaintInfo; VAlignment, IndentSize: Integer; + LineImage: TLineImage); + +var + I: Integer; + XPos, + Offset: Integer; + NewStyles: TLineImage; + +begin + NewStyles := nil; + + with PaintInfo do + begin + if BidiMode = bdLeftToRight then + begin + XPos := CellRect.Left; + Offset := FIndent; + end + else + begin + Offset := -Integer(FIndent); + XPos := CellRect.Right + Offset; + end; + + case FLineMode of + lmBands: + if poGridLines in PaintInfo.PaintOptions then + begin + // Convert the line images in correct bands. + SetLength(NewStyles, Length(LineImage)); + for I := IndentSize - 1 downto 0 do + begin + if (vsExpanded in Node.States) and not (vsAllChildrenHidden in Node.States) then + NewStyles[I] := ltLeft + else + case LineImage[I] of + ltRight, + ltBottomRight, + ltTopDownRight, + ltTopRight: + NewStyles[I] := ltLeftBottom; + ltNone: + // Have to take over the image to the right of this one. A no line entry can never appear as + // last entry so I don't need an end check here. + if LineImage[I + 1] in [ltNone, ltTopRight] then + NewStyles[I] := NewStyles[I + 1] + else + NewStyles[I] := ltLeft; + ltTopDown: + // Have to check the image to the right of this one. A top down line can never appear as + // last entry so I don't need an end check here. + if LineImage[I + 1] in [ltNone, ltTopRight] then + NewStyles[I] := NewStyles[I + 1] + else + NewStyles[I] := ltLeft; + end; + end; + + PaintInfo.Canvas.Font.Color := FColors.GridLineColor; + for I := 0 to IndentSize - 1 do + begin + DoBeforeDrawLineImage(PaintInfo.Node, I + Ord(not (toShowRoot in TreeOptions.PaintOptions)), XPos); + DrawLineImage(PaintInfo, XPos, CellRect.Top, NodeHeight[Node] - 1, VAlignment, NewStyles[I], + BidiMode <> bdLeftToRight); + Inc(XPos, Offset); + end; + end; + else // lmNormal + PaintInfo.Canvas.Font.Color := FColors.TreeLineColor; + for I := 0 to IndentSize - 1 do + begin + DoBeforeDrawLineImage(PaintInfo.Node, I + Ord(not (toShowRoot in TreeOptions.PaintOptions)), XPos); + DrawLineImage(PaintInfo, XPos, CellRect.Top, NodeHeight[Node], VAlignment, LineImage[I], + BidiMode <> bdLeftToRight); + Inc(XPos, Offset); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PaintSelectionRectangle(Target: TCanvas; WindowOrgX: Integer; const SelectionRect: TRect; + TargetRect: TRect); + +// Helper routine to draw a selection rectangle in the mode determined by DrawSelectionMode. + +var + BlendRect: TRect; + TextColorBackup, + BackColorBackup: COLORREF; // used to restore forground and background colors when drawing a selection rectangle + +begin + if ((FDrawSelectionMode = smDottedRectangle) and not (tsUseThemes in FStates)) or + not MMXAvailable then + begin + // Classical selection rectangle using dotted borderlines. + TextColorBackup := GetTextColor(Target.Handle); + SetTextColor(Target.Handle, $FFFFFF); + BackColorBackup := GetBkColor(Target.Handle); + SetBkColor(Target.Handle, 0); + Target.DrawFocusRect(SelectionRect); + SetTextColor(Target.Handle, TextColorBackup); + SetBkColor(Target.Handle, BackColorBackup); + end + else + begin + // Modern alpha blended style. + OffsetRect(TargetRect, WindowOrgX, 0); + if IntersectRect(BlendRect, OrderRect(SelectionRect), TargetRect) then + begin + OffsetRect(BlendRect, -WindowOrgX, 0); + AlphaBlend(0, Target.Handle, BlendRect, Point(0, 0), bmConstantAlphaAndColor, FSelectionBlendFactor, + ColorToRGB(FColors.SelectionRectangleBlendColor)); + + Target.Brush.Color := FColors.SelectionRectangleBorderColor; + Target.FrameRect(SelectionRect); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PanningWindowProc(var Message: TMessage); + +var + PS: TPaintStruct; + Canvas: TCanvas; + +begin + if Message.Msg = WM_PAINT then + begin + BeginPaint(FPanningWindow, PS); + Canvas := TCanvas.Create; + Canvas.Handle := PS.hdc; + try + Canvas.Draw(0, 0, FPanningImage); + finally + Canvas.Handle := 0; + Canvas.Free; + EndPaint(FPanningWindow, PS); + end; + Message.Result := 0; + end + else + with Message do + Result := DefWindowProc(FPanningWindow, Msg, wParam, lParam); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX, MaxWidth: Integer); + +// This method is called immediately before a cell's content is drawn und is responsible to paint selection colors etc. + +var + TextColorBackup, + BackColorBackup: COLORREF; + FocusRect, + InnerRect: TRect; + RowRect: TRect; + Theme: HTHEME; + {$ifndef COMPILER_11_UP} + const + TREIS_HOTSELECTED = 6; + {$endif COMPILER_11_UP} + + //--------------- local functions ------------------------------------------- + + procedure AlphaBlendSelection(Color: TColor); + + var + R: TRect; + + begin + // Take into account any window offset and size limitations in the target bitmap, as this is only as large + // as necessary and might not cover the whole node. For normal painting this does not matter (because of + // clipping) but for the MMX code there is no such check and it will crash badly when bitmap boundaries are + // crossed. + R := InnerRect; + OffsetRect(R, -WindowOrgX, 0); + if R.Left < 0 then + R.Left := 0; + if R.Right > MaxWidth then + R.Right := MaxWidth; + AlphaBlend(0, PaintInfo.Canvas.Handle, R, Point(0, 0), bmConstantAlphaAndColor, + FSelectionBlendFactor, ColorToRGB(Color)); + end; + + //--------------------------------------------------------------------------- + + procedure DrawBackground(State: Integer); + begin + with PaintInfo do + if (toGridExtensions in FOptions.FMiscOptions) or (toFullRowSelect in FOptions.FSelectionOptions) then + DrawThemeBackground(Theme, Canvas.Handle, TVP_TREEITEM, State, RowRect, @CellRect) + else + DrawThemeBackground(Theme, Canvas.Handle, TVP_TREEITEM, State, InnerRect, nil); + end; + + //--------------- end local functions --------------------------------------- + +begin + if tsUseExplorerTheme in FStates then + begin + Theme := OpenThemeData(Handle, 'TREEVIEW');//TODO: Use 'Explorer::TreeView' instead? If so, search for similar calls + RowRect := Rect(0, PaintInfo.CellRect.Top, Max(FRangeX, ClientWidth), PaintInfo.CellRect.Bottom); + if toShowVertGridLines in FOptions.PaintOptions then + Dec(RowRect.Right); + end; + + with PaintInfo, Canvas do + begin + // Fill cell background if its color differs from tree background. + with FHeader.FColumns do + if poColumnColor in PaintOptions then + begin + Brush.Color := Items[Column].Color; + FillRect(CellRect); + end; + + // Let the application customize the cell background and the content rectangle. + DoBeforeCellPaint(Canvas, Node, Column, cpmPaint, CellRect, ContentRect); + + InnerRect := ContentRect; + + // The selection rectangle depends on alignment. + if not (toGridExtensions in FOptions.FMiscOptions) then + begin + case Alignment of + taLeftJustify: + with TWithSafeRect(InnerRect) do + if Left + NodeWidth < Right then + Right := Left + NodeWidth; + taCenter: + with TWithSafeRect(InnerRect) do + if (Right - Left) > NodeWidth then + begin + Left := (Left + Right - NodeWidth) div 2; + Right := Left + NodeWidth; + end; + taRightJustify: + with TWithSafeRect(InnerRect) do + if (Right - Left) > NodeWidth then + Left := Right - NodeWidth; + end; + end; + + if (Column = FFocusedColumn) or (toFullRowSelect in FOptions.FSelectionOptions) then + begin + // Fill the selection rectangle. + if poDrawSelection in PaintOptions then + begin + if Node = FDropTargetNode then + begin + if (FLastDropMode = dmOnNode) or (vsSelected in Node.States) then + begin + Brush.Color := FColors.DropTargetColor; + Pen.Color := FColors.DropTargetBorderColor; + + if (toGridExtensions in FOptions.FMiscOptions) or + (toFullRowSelect in FOptions.FSelectionOptions) then + InnerRect := CellRect; + if not IsRectEmpty(InnerRect) then + if tsUseExplorerTheme in FStates then + DrawBackground(TREIS_SELECTED) + else + if MMXAvailable and (toUseBlendedSelection in FOptions.PaintOptions) then + AlphaBlendSelection(Brush.Color) + else + with TWithSafeRect(InnerRect) do + RoundRect(Left, Top, Right, Bottom, FSelectionCurveRadius, FSelectionCurveRadius); + end + else + begin + Brush.Style := bsClear; + end; + end + else + if vsSelected in Node.States then + begin + if Focused or (toPopupMode in FOptions.FPaintOptions) then + begin + Brush.Color := FColors.FocusedSelectionColor; + Pen.Color := FColors.FocusedSelectionBorderColor; + end + else + begin + Brush.Color := FColors.UnfocusedSelectionColor; + Pen.Color := FColors.UnfocusedSelectionBorderColor; + end; + + if (toGridExtensions in FOptions.FMiscOptions) or (toFullRowSelect in FOptions.FSelectionOptions) then + InnerRect := CellRect; + if not IsRectEmpty(InnerRect) then + if tsUseExplorerTheme in FStates then + begin + // If the node is also hot, its background will be drawn later. + if not (toHotTrack in FOptions.FPaintOptions) or (Node <> FCurrentHotNode) or + ((Column <> FCurrentHotColumn) and not (toFullRowSelect in FOptions.FSelectionOptions)) then + DrawBackground(IfThen(Self.Focused, TREIS_SELECTED, TREIS_SELECTEDNOTFOCUS)); + end + else + if MMXAvailable and (toUseBlendedSelection in FOptions.PaintOptions) then + AlphaBlendSelection(Brush.Color) + else + with TWithSafeRect(InnerRect) do + RoundRect(Left, Top, Right, Bottom, FSelectionCurveRadius, FSelectionCurveRadius); + end; + end; + end; + + if (tsUseExplorerTheme in FStates) and (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) and + ((Column = FCurrentHotColumn) or (toFullRowSelect in FOptions.FSelectionOptions)) then + DrawBackground(IfThen((vsSelected in Node.States) and not (toAlwaysHideSelection in FOptions.FPaintOptions), + TREIS_HOTSELECTED, TREIS_HOT)); + + if (Column = FFocusedColumn) or (toFullRowSelect in FOptions.FSelectionOptions) then + begin + // draw focus rect + if (poDrawFocusRect in PaintOptions) and + (Focused or (toPopupMode in FOptions.FPaintOptions)) and (FFocusedNode = Node) and + ( (Column = FFocusedColumn) or + (not (toExtendedFocus in FOptions.FSelectionOptions) and + (toFullRowSelect in FOptions.FSelectionOptions) and + (tsUseExplorerTheme in FStates) ) ) then + begin + TextColorBackup := GetTextColor(Handle); + SetTextColor(Handle, $FFFFFF); + BackColorBackup := GetBkColor(Handle); + SetBkColor(Handle, 0); + + if not (toExtendedFocus in FOptions.FSelectionOptions) and (toFullRowSelect in FOptions.FSelectionOptions) and + (tsUseExplorerTheme in FStates) then + FocusRect := RowRect + else + if toGridExtensions in FOptions.FMiscOptions then + FocusRect := CellRect + else + FocusRect := InnerRect; + + if tsUseExplorerTheme in FStates then + InflateRect(FocusRect, -1, -1); + + Windows.DrawFocusRect(Handle, FocusRect); + SetTextColor(Handle, TextColorBackup); + SetBkColor(Handle, BackColorBackup); + end; + end; + end; + + if tsUseExplorerTheme in FStates then + CloseThemeData(Theme); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ReadChunk(Stream: TStream; Version: Integer; Node: PVirtualNode; ChunkType, + ChunkSize: Integer): Boolean; + +// Called while loading a tree structure, Node is already valid (allocated) at this point. +// The function handles the base and user chunks, any other chunk is marked as being unknown (result becomes False) +// and skipped. descendants may handle them by overriding this method. +// Returns True if the chunk could be handled, otherwise False. + +var + ChunkBody: TBaseChunkBody; + Run: PVirtualNode; + LastPosition: Integer; + +begin + case ChunkType of + BaseChunk: + begin + // Load base chunk's body (chunk header has already been consumed). + if Version > 1 then + Stream.Read(ChunkBody, SizeOf(ChunkBody)) + else + begin + with ChunkBody do + begin + // In version prior to 2 there was a smaller chunk body. Hence we have to read it entry by entry now. + Stream.Read(ChildCount, SizeOf(ChildCount)); + Stream.Read(NodeHeight, SizeOf(NodeHeight)); + // TVirtualNodeStates was a byte sized type in version 1. + States := []; + Stream.Read(States, SizeOf(Byte)); + // vsVisible is now in the place where vsSelected was before, but every node was visible in the old version + // so we need to fix this too. + if vsVisible in States then + Include(States, vsSelected) + else + Include(States, vsVisible); + Stream.Read(Align, SizeOf(Align)); + Stream.Read(CheckState, SizeOf(CheckState)); + Stream.Read(CheckType, SizeOf(CheckType)); + end; + end; + + with Node^ do + begin + // Set states first, in case the node is invisible. + States := ChunkBody.States; + NodeHeight := ChunkBody.NodeHeight; + TotalHeight := NodeHeight; + Align := ChunkBody.Align; + CheckState := ChunkBody.CheckState; + CheckType := ChunkBody.CheckType; + ChildCount := ChunkBody.ChildCount; + + // Create and read child nodes. + while ChunkBody.ChildCount > 0 do + begin + Run := MakeNewNode; + + Run.PrevSibling := Node.LastChild; + if Assigned(Run.PrevSibling) then + Run.Index := Run.PrevSibling.Index + 1; + if Assigned(Node.LastChild) then + Node.LastChild.NextSibling := Run + else + Node.FirstChild := Run; + Node.LastChild := Run; + Run.Parent := Node; + + ReadNode(Stream, Version, Run); + Dec(ChunkBody.ChildCount); + end; + end; + Result := True; + end; + UserChunk: + if ChunkSize > 0 then + begin + // need to know whether the data was read + LastPosition := Stream.Position; + DoLoadUserData(Node, Stream); + // compare stream position to learn whether the data was read + Result := Stream.Position > LastPosition; + // Improve stability by advancing the stream to the chunk's real end if + // the application did not read what has been written. + if not Result or (Stream.Position <> (LastPosition + ChunkSize)) then + Stream.Position := LastPosition + ChunkSize; + end + else + Result := True; + else + // unknown chunk, skip it + Stream.Position := Stream.Position + ChunkSize; + Result := False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ReadNode(Stream: TStream; Version: Integer; Node: PVirtualNode); + +// Reads the anchor chunk of each node and initiates reading the sub chunks for this node + +var + Header: TChunkHeader; + EndPosition: Integer; + +begin + with Stream do + begin + // Read anchor chunk of the node. + Stream.Read(Header, SizeOf(Header)); + if Header.ChunkType = NodeChunk then + begin + EndPosition := Stream.Position + Header.ChunkSize; + // Read all subchunks until the indicated chunk end position is reached in the stream. + while Position < EndPosition do + begin + // Read new chunk header. + Stream.Read(Header, SizeOf(Header)); + ReadChunk(Stream, Version, Node, Header.ChunkType, Header.ChunkSize); + end; + // If the last chunk does not end at the given end position then there is something wrong. + if Position <> EndPosition then + ShowError(SCorruptStream2, hcTFCorruptStream2); + end + else + ShowError(SCorruptStream1, hcTFCorruptStream1); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.RedirectFontChangeEvent(Canvas: TCanvas); + +begin + if @Canvas.Font.OnChange <> @FOldFontChange then + begin + FOldFontChange := Canvas.Font.OnChange; + Canvas.Font.OnChange := FontChanged; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.RemoveFromSelection(Node: PVirtualNode); + +var + Index: Integer; + +begin + if not FSelectionLocked then + begin + Assert(Assigned(Node), 'Node must not be nil!'); + if vsSelected in Node.States then + begin + Exclude(Node.States, vsSelected); + if FindNodeInSelection(Node, Index, -1, -1) and (Index < FSelectionCount - 1) then + Move(FSelection[Index + 1], FSelection[Index], (FSelectionCount - Index - 1) * SizeOf(Pointer)); + if FSelectionCount > 0 then + Dec(FSelectionCount); + SetLength(FSelection, FSelectionCount); + + if FSelectionCount = 0 then + ResetRangeAnchor; + + if Assigned(FOnRemoveFromSelection) then + FOnRemoveFromSelection(Self, Node); + Change(Node); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.RenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; + ForClipboard: Boolean): HResult; + +// Returns a memory expression of all currently selected nodes in the Medium structure. +// Note: The memory requirement of this method might be very high. This depends however on the requested storage format. +// For HGlobal (a global memory block) we need to render first all nodes to local memory and copy this then to +// the global memory in Medium. This is necessary because we have first to determine how much +// memory is needed before we can allocate it. Hence for a short moment we need twice the space as used by the +// nodes alone (plus the amount the nodes need in the tree anyway)! +// With IStream this does not happen. We directly stream out the nodes and pass the constructed stream along. + + //--------------- local function -------------------------------------------- + + procedure WriteNodes(Stream: TStream); + + var + Selection: TNodeArray; + I: Integer; + + begin + if ForClipboard then + Selection := GetSortedCutCopySet(True) + else + Selection := GetSortedSelection(True); + for I := 0 to High(Selection) do + WriteNode(Stream, Selection[I]); + end; + + //--------------- end local function ---------------------------------------- + +var + Data: PCardinal; + ResPointer: Pointer; + ResSize: Integer; + OLEStream: IStream; + VCLStream: TStream; + +begin + ZeroMemory (@Medium, SizeOf(Medium)); + + // We can render the native clipboard format in two different storage media. + if (FormatEtcIn.cfFormat = CF_VIRTUALTREE) and (FormatEtcIn.tymed and (TYMED_HGLOBAL or TYMED_ISTREAM) <> 0) then + begin + VCLStream := nil; + try + Medium.unkForRelease := nil; + // Return data in one of the supported storage formats, prefer IStream. + if FormatEtcIn.tymed and TYMED_ISTREAM <> 0 then + begin + // Create an IStream on a memory handle (here it is 0 which indicates to implicitely allocated a handle). + // Do not use TStreamAdapter as it is not compatible with OLE (when flushing the clipboard OLE wants the HGlobal + // back which is not supported by TStreamAdapater). + CreateStreamOnHGlobal(0, True, OLEStream); + VCLStream := TOLEStream.Create(OLEStream); + WriteNodes(VCLStream); + // Rewind stream. + VCLStream.Position := 0; + Medium.tymed := TYMED_ISTREAM; + IUnknown(Medium.stm) := OLEStream; + Result := S_OK; + end + else + begin + VCLStream := TMemoryStream.Create; + WriteNodes(VCLStream); + ResPointer := TMemoryStream(VCLStream).Memory; + ResSize := VCLStream.Position; + + // Allocate memory to hold the string. + if ResSize > 0 then + begin + Medium.hGlobal := GlobalAlloc(GHND or GMEM_SHARE, ResSize + SizeOf(Cardinal)); + Data := GlobalLock(Medium.hGlobal); + // Store the size of the data too, for easy retrival. + Data^ := ResSize; + Inc(Data); + Move(ResPointer^, Data^, ResSize); + GlobalUnlock(Medium.hGlobal); + Medium.tymed := TYMED_HGLOBAL; + + Result := S_OK; + end + else + Result := E_FAIL; + end; + finally + // We can free the VCL stream here since it was either a pure memory stream or only a wrapper around + // the OLEStream which exists independently. + VCLStream.Free; + end; + end + else // Ask application descendants to render self defined formats. + Result := DoRenderOLEData(FormatEtcIn, Medium, ForClipboard); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ResetRangeAnchor; + +// Called when there is no selected node anymore and the selection range anchor needs a new value. + +begin + FRangeAnchor := FFocusedNode; + FLastSelectionLevel := -1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.RestoreFontChangeEvent(Canvas: TCanvas); + +begin + Canvas.Font.OnChange := FOldFontChange; + FOldFontChange := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SelectNodes(StartNode, EndNode: PVirtualNode; AddOnly: Boolean); + +// Selects a range of nodes and unselects all other eventually selected nodes which are not in this range if +// AddOnly is False. +// EndNode must be visible while StartNode does not necessarily as in the case where the last focused node is the start +// node but it is a child of a node which has been collapsed previously. In this case the first visible parent node +// is used as start node. StartNode can be nil in which case the very first node in the tree is used. + +var + NodeFrom, + NodeTo, + LastAnchor: PVirtualNode; + Index: Integer; + +begin + Assert(Assigned(EndNode), 'EndNode must not be nil!'); + if not FSelectionLocked then + begin + ClearTempCache; + if StartNode = nil then + StartNode := GetFirstVisibleNoInit(nil, True) + else + if not FullyVisible[StartNode] then + begin + StartNode := GetPreviousVisible(StartNode, True); + if StartNode = nil then + StartNode := GetFirstVisibleNoInit(nil, True) + end; + + if CompareNodePositions(StartNode, EndNode, True) < 0 then + begin + NodeFrom := StartNode; + NodeTo := EndNode; + end + else + begin + NodeFrom := EndNode; + NodeTo := StartNode; + end; + + // The range anchor will be reset by the following call. + LastAnchor := FRangeAnchor; + if not AddOnly then + InternalClearSelection; + + while NodeFrom <> NodeTo do + begin + InternalCacheNode(NodeFrom); + NodeFrom := GetNextVisible(NodeFrom, True); + end; + // select last node too + InternalCacheNode(NodeFrom); + // now add them all in "one" step + AddToSelection(FTempNodeCache, FTempNodeCount); + ClearTempCache; + if Assigned(LastAnchor) and FindNodeInSelection(LastAnchor, Index, -1, -1) then + FRangeAnchor := LastAnchor; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SetFocusedNodeAndColumn(Node: PVirtualNode; Column: TColumnIndex); + +var + OldColumn: TColumnIndex; + WasDifferent: Boolean; + +begin + if not FHeader.AllowFocus(Column) then + Column := FFocusedColumn; + + WasDifferent := (Node <> FFocusedNode) or (Column <> FFocusedColumn); + + OldColumn := FFocusedColumn; + FFocusedColumn := Column; + + DoFocusNode(Node, True); + + // Check if the change was accepted. + if FFocusedNode = Node then + begin + CancelEditNode; + if WasDifferent then + DoFocusChange(FFocusedNode, FFocusedColumn); + end + else + // If the user did not accept the new cell to focus then set also the focused column back + // to its original state. + FFocusedColumn := OldColumn; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SkipNode(Stream: TStream); + +// Skips the data for the next node in the given stream (including the child nodes). + +var + Header: TChunkHeader; + +begin + with Stream do + begin + // read achor chunk of the node + Stream.Read(Header, SizeOf(Header)); + if Header.ChunkType = NodeChunk then + Stream.Position := Stream.Position + Header.ChunkSize + else + ShowError(SCorruptStream1, hcTFCorruptStream1); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +var + PanningWindowClass: TWndClass = ( + style: 0; + lpfnWndProc: @DefWindowProc; + cbClsExtra: 0; + cbWndExtra: 0; + hInstance: 0; + hIcon: 0; + hCursor: 0; + hbrBackground: 0; + lpszMenuName: nil; + lpszClassName: 'VTPanningWindow' + ); + +procedure TBaseVirtualTree.StartWheelPanning(Position: TPoint); + +// Called when wheel panning should start. A little helper window is created to indicate the reference position, +// which determines in which direction and how far wheel panning/scrolling will happen. + + //--------------- local function -------------------------------------------- + + function CreateClipRegion: HRGN; + + // In order to avoid doing all the transparent drawing ourselves we use a + // window region for the wheel window. + // Since we only work on a very small image (32x32 pixels) this is acceptable. + + var + Start, X, Y: Integer; + Temp: HRGN; + + begin + Assert(not FPanningImage.Empty, 'Invalid wheel panning image.'); + + // Create an initial region on which we operate. + Result := CreateRectRgn(0, 0, 0, 0); + with FPanningImage, Canvas do + begin + for Y := 0 to Height - 1 do + begin + Start := -1; + for X := 0 to Width - 1 do + begin + // Start a new span if we found a non-transparent pixel and no span is currently started. + if (Start = -1) and (Pixels[X, Y] <> clFuchsia) then + Start := X + else + if (Start > -1) and (Pixels[X, Y] = clFuchsia) then + begin + // A non-transparent span is finished. Add it to the result region. + Temp := CreateRectRgn(Start, Y, X, Y + 1); + CombineRgn(Result, Result, Temp, RGN_OR); + DeleteObject(Temp); + Start := -1; + end; + end; + // If there is an open span then add this also to the result region. + if Start > -1 then + begin + Temp := CreateRectRgn(Start, Y, Width, Y + 1); + CombineRgn(Result, Result, Temp, RGN_OR); + DeleteObject(Temp); + end; + end; + end; + // The resulting region is used as window region so we must not delete it. + // Windows will own it after the assignment below. + end; + + //--------------- end local function ---------------------------------------- + +var + TempClass: TWndClass; + ClassRegistered: Boolean; + ImageName: string; + Pt: TPoint; + +begin + // Set both panning and scrolling flag. One will be removed shortly depending on whether the middle mouse button is + // released before the mouse is moved or vice versa. The first case is referred to as wheel scrolling while the + // latter is called wheel panning. + StopTimer(ScrollTimer); + DoStateChange([tsWheelPanning, tsWheelScrolling]); + + // Register the helper window class. + PanningWindowClass.hInstance := HInstance; + ClassRegistered := GetClassInfo(HInstance, PanningWindowClass.lpszClassName, TempClass); + if not ClassRegistered or (TempClass.lpfnWndProc <> @DefWindowProc) then + begin + if ClassRegistered then + Windows.UnregisterClass(PanningWindowClass.lpszClassName, HInstance); + Windows.RegisterClass(PanningWindowClass); + end; + // Create the helper window and show it at the given position without activating it. + Pt := ClientToScreen(Position); + FPanningWindow := CreateWindowEx(WS_EX_TOOLWINDOW, PanningWindowClass.lpszClassName, nil, WS_POPUP, Pt.X - 16, Pt.Y - 16, + 32, 32, Handle, 0, HInstance, nil); + + FPanningImage := TBitmap.Create; + if Integer(FRangeX) > ClientWidth then + begin + if Integer(FRangeY) > ClientHeight then + ImageName := 'VT_MOVEALL' + else + ImageName := 'VT_MOVEEW' + end + else + ImageName := 'VT_MOVENS'; + FPanningImage.LoadFromResourceName(HInstance, ImageName); + SetWindowRgn(FPanningWindow, CreateClipRegion, False); + + {$ifdef CPUX64} + SetWindowLongPtr(FPanningWindow, GWLP_WNDPROC, LONG_PTR(Classes.MakeObjectInstance(PanningWindowProc))); + {$else} + SetWindowLong(FPanningWindow, GWL_WNDPROC, Longint(Classes.MakeObjectInstance(PanningWindowProc))); + {$endif CPUX64} + ShowWindow(FPanningWindow, SW_SHOWNOACTIVATE); + + // Setup the panscroll timer and capture all mouse input. + SetFocus; + SetCapture(Handle); + SetTimer(Handle, ScrollTimer, 20, nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.StopWheelPanning; + +// Stops panning if currently active and destroys the helper window. + +var + Instance: Pointer; + +begin + if [tsWheelPanning, tsWheelScrolling] * FStates <> [] then + begin + // Release the mouse capture and stop the panscroll timer. + StopTimer(ScrollTimer); + ReleaseCapture; + DoStateChange([], [tsWheelPanning, tsWheelScrolling]); + + // Destroy the helper window. + {$ifdef CPUX64} + Instance := Pointer(GetWindowLongPtr(FPanningWindow, GWLP_WNDPROC)); + {$else} + Instance := Pointer(GetWindowLong(FPanningWindow, GWL_WNDPROC)); + {$endif CPUX64} + DestroyWindow(FPanningWindow); + if Instance <> @DefWindowProc then + Classes.FreeObjectInstance(Instance); + FPanningWindow := 0; + FPanningImage.Free; + FPanningImage := nil; + DeleteObject(FPanningCursor); + FPanningCursor := 0; + Windows.SetCursor(Screen.Cursors[Cursor]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.StructureChange(Node: PVirtualNode; Reason: TChangeReason); + +begin + AdviseChangeEvent(True, Node, Reason); + + if FUpdateCount = 0 then + begin + if (FChangeDelay > 0) and not (tsSynchMode in FStates) then + SetTimer(Handle, StructureChangeTimer, FChangeDelay, nil) + else + DoStructureChange(Node, Reason); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.SuggestDropEffect(Source: TObject; Shift: TShiftState; Pt: TPoint; + AllowedEffects: Integer): Integer; + +// determines the drop action to take if the drag'n drop operation ends on this tree +// Note: Source can be any Delphi object not just a virtual tree + +begin + Result := AllowedEffects; + + // prefer MOVE if source and target are the same control, otherwise whatever is allowed as initial value + if Assigned(Source) and (Source = Self) then + if (AllowedEffects and DROPEFFECT_MOVE) <> 0 then + Result := DROPEFFECT_MOVE + else // no change + else + // drag between different applicatons + if (AllowedEffects and DROPEFFECT_COPY) <> 0 then + Result := DROPEFFECT_COPY; + + // consider modifier keys and what is allowed at the moment, if none of the following conditions apply then + // the initial value just set is used + if ssCtrl in Shift then + begin + // copy or link + if ssShift in Shift then + begin + // link + if (AllowedEffects and DROPEFFECT_LINK) <> 0 then + Result := DROPEFFECT_LINK; + end + else + begin + // copy + if (AllowedEffects and DROPEFFECT_COPY) <> 0 then + Result := DROPEFFECT_COPY; + end; + end + else + begin + // move, link or default + if ssShift in Shift then + begin + // move + if (AllowedEffects and DROPEFFECT_MOVE) <> 0 then + Result := DROPEFFECT_MOVE; + end + else + begin + // link or default + if ssAlt in Shift then + begin + // link + if (AllowedEffects and DROPEFFECT_LINK) <> 0 then + Result := DROPEFFECT_LINK; + end; + // else default + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ToggleSelection(StartNode, EndNode: PVirtualNode); + +// Switchs the selection state of a range of nodes. +// Note: This method is specifically designed to help selecting ranges with the keyboard and considers therefore +// the range anchor. + +var + NodeFrom, + NodeTo: PVirtualNode; + NewSize: Integer; + Position: Integer; + +begin + if not FSelectionLocked then + begin + Assert(Assigned(EndNode), 'EndNode must not be nil!'); + if StartNode = nil then + StartNode := FRoot.FirstChild + else + if not FullyVisible[StartNode] then + StartNode := GetPreviousVisible(StartNode, True); + + Position := CompareNodePositions(StartNode, EndNode); + // nothing to do if start and end node are the same + if Position <> 0 then + begin + if Position < 0 then + begin + NodeFrom := StartNode; + NodeTo := EndNode; + end + else + begin + NodeFrom := EndNode; + NodeTo := StartNode; + end; + + ClearTempCache; + + // 1) toggle the start node if it is before the range anchor + if CompareNodePositions(NodeFrom, FRangeAnchor) < 0 then + if not (vsSelected in NodeFrom.States) then + InternalCacheNode(NodeFrom) + else + InternalRemoveFromSelection(NodeFrom); + + // 2) toggle all nodes within the range + NodeFrom := GetNextVisible(NodeFrom, True); + while NodeFrom <> NodeTo do + begin + if not (vsSelected in NodeFrom.States) then + InternalCacheNode(NodeFrom) + else + InternalRemoveFromSelection(NodeFrom); + NodeFrom := GetNextVisible(NodeFrom, True); + end; + + // 3) toggle end node if it is after the range anchor + if CompareNodePositions(NodeFrom, FRangeAnchor) > 0 then + if not (vsSelected in NodeFrom.States) then + InternalCacheNode(NodeFrom) + else + InternalRemoveFromSelection(NodeFrom); + + // Do some housekeeping if there was a change. + NewSize := PackArray(FSelection, FSelectionCount); + if NewSize > -1 then + begin + FSelectionCount := NewSize; + SetLength(FSelection, FSelectionCount); + end; + // If the range went over the anchor then we need to reselect it. + if not (vsSelected in FRangeAnchor.States) then + InternalCacheNode(FRangeAnchor); + if FTempNodeCount > 0 then + AddToSelection(FTempNodeCache, FTempNodeCount); + ClearTempCache; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UnselectNodes(StartNode, EndNode: PVirtualNode); + +// Deselects a range of nodes. +// EndNode must be visible while StartNode must not as in the case where the last focused node is the start node +// but it is a child of a node which has been collapsed previously. In this case the first visible parent node +// is used as start node. StartNode can be nil in which case the very first node in the tree is used. + +var + NodeFrom, + NodeTo: PVirtualNode; + NewSize: Integer; + +begin + if not FSelectionLocked then + begin + Assert(Assigned(EndNode), 'EndNode must not be nil!'); + + if StartNode = nil then + StartNode := FRoot.FirstChild + else + if not FullyVisible[StartNode] then + begin + StartNode := GetPreviousVisible(StartNode, True); + if StartNode = nil then + StartNode := FRoot.FirstChild + end; + + if CompareNodePositions(StartNode, EndNode) < 0 then + begin + NodeFrom := StartNode; + NodeTo := EndNode; + end + else + begin + NodeFrom := EndNode; + NodeTo := StartNode; + end; + + while NodeFrom <> NodeTo do + begin + InternalRemoveFromSelection(NodeFrom); + NodeFrom := GetNextVisible(NodeFrom, True); + end; + // Deselect last node too. + InternalRemoveFromSelection(NodeFrom); + + // Do some housekeeping. + NewSize := PackArray(FSelection, FSelectionCount); + if NewSize > -1 then + begin + FSelectionCount := NewSize; + SetLength(FSelection, FSelectionCount); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateColumnCheckState(Col: TVirtualTreeColumn); + +begin + Col.CheckState := DetermineNextCheckState(Col.CheckType, Col.CheckState); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateDesigner; + +var + ParentForm: TCustomForm; + +begin + if (csDesigning in ComponentState) and not (csUpdating in ComponentState) then + begin + ParentForm := GetParentForm(Self); + if Assigned(ParentForm) and Assigned(ParentForm.Designer) then + ParentForm.Designer.Modified; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateHeaderRect; + +// Calculates the rectangle the header occupies in non-client area. +// These coordinates are in window rectangle. + +var + OffsetX, + OffsetY: Integer; + EdgeSize: Integer; + Size: TSize; + +begin + FHeaderRect := Rect(0, 0, Width, Height); + + // Consider borders... + Size := GetBorderDimensions; + InflateRect(FHeaderRect, Size.cx, Size.cy); + + // ... and bevels. + OffsetX := BorderWidth; + OffsetY := BorderWidth; + if BevelKind <> bkNone then + begin + EdgeSize := 0; + if BevelInner <> bvNone then + Inc(EdgeSize, BevelWidth); + if BevelOuter <> bvNone then + Inc(EdgeSize, BevelWidth); + if beLeft in BevelEdges then + Inc(OffsetX, EdgeSize); + if beTop in BevelEdges then + Inc(OffsetY, EdgeSize); + end; + + InflateRect(FHeaderRect, -OffsetX, -OffsetY); + + if hoVisible in FHeader.FOptions then + begin + if FHeaderRect.Left <= FHeaderRect.Right then + FHeaderRect.Bottom := FHeaderRect.Top + Integer(FHeader.FHeight) + else + FHeaderRect := Rect(0, 0, 0, 0); + end + else + FHeaderRect.Bottom := FHeaderRect.Top; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateEditBounds; + +// Used to update the bounds of the current node editor if editing is currently active. + +var + R: TRect; + Dummy: Integer; + CurrentAlignment: TAlignment; + CurrentBidiMode: TBidiMode; + +begin + if (tsEditing in FStates) and Assigned(FFocusedNode) then + begin + if vsMultiline in FFocusedNode.States then + R := GetDisplayRect(FFocusedNode, FEditColumn, True, False) + else + R := GetDisplayRect(FFocusedNode, FEditColumn, True, True); + if (toGridExtensions in FOptions.FMiscOptions) then + begin + // Adjust edit bounds depending on alignment and bidi mode. + if FEditColumn <= NoColumn then + begin + CurrentAlignment := Alignment; + CurrentBidiMode := BiDiMode; + end + else + begin + CurrentAlignment := FHeader.Columns[FEditColumn].FAlignment; + CurrentBidiMode := FHeader.Columns[FEditColumn].FBidiMode; + end; + // Consider bidi mode here. In RTL context does left alignment actually mean right alignment and vice versa. + if CurrentBidiMode <> bdLeftToRight then + ChangeBiDiModeAlignment(CurrentAlignment); + if CurrentAlignment = taLeftJustify then + FHeader.Columns.GetColumnBounds(FEditColumn, Dummy, R.Right) + else + FHeader.Columns.GetColumnBounds(FEditColumn, R.Left, Dummy); + end; + if toShowHorzGridLines in TreeOptions.PaintOptions then + Dec(R.Bottom); + FEditLink.SetBounds(R); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +const + ScrollMasks: array[Boolean] of Cardinal = (0, SIF_DISABLENOSCROLL); + +const // Region identifiers for GetRandomRgn + CLIPRGN = 1; + METARGN = 2; + APIRGN = 3; + SYSRGN = 4; + +function GetRandomRgn(DC: HDC; Rgn: HRGN; iNum: Integer): Integer; stdcall; external 'GDI32.DLL'; + +procedure TBaseVirtualTree.UpdateWindowAndDragImage(const Tree: TBaseVirtualTree; TreeRect: TRect; UpdateNCArea, + ReshowDragImage: Boolean); + +// Method to repaint part of the window area which is not covered by the drag image and to initiate a recapture +// of the drag image. +// Note: This method must only be called during a drag operation and the tree passed in is the one managing the current +// drag image (so it is the actual drag source). + +var + DragRegion, // the region representing the drag image + UpdateRegion, // the unclipped region within the tree to be updated + NCRegion: HRGN; // the region representing the non-client area of the tree + DragRect, + NCRect: TRect; + RedrawFlags: Cardinal; + + VisibleTreeRegion: HRGN; + + DC: HDC; + +begin + if IntersectRect(TreeRect, TreeRect, ClientRect) then + begin + // Retrieve the visible region of the window. This is important to avoid overpainting parts of other windows + // which overlap this one. + VisibleTreeRegion := CreateRectRgn(0, 0, 1, 1); + DC := GetDCEx(Handle, 0, DCX_CACHE or DCX_WINDOW or DCX_CLIPSIBLINGS or DCX_CLIPCHILDREN); + GetRandomRgn(DC, VisibleTreeRegion, SYSRGN); + ReleaseDC(Handle, DC); + + // The drag image will figure out itself what part of the rectangle can be recaptured. + // Recapturing is not done by taking a snapshot of the screen, but by letting the tree draw itself + // into the back bitmap of the drag image. So the order here is unimportant. + Tree.FDragImage.RecaptureBackground(Self, TreeRect, VisibleTreeRegion, UpdateNCArea, ReshowDragImage); + + // Calculate the screen area not covered by the drag image and which needs an update. + DragRect := Tree.FDragImage.GetDragImageRect; + MapWindowPoints(0, Handle, DragRect, 2); + DragRegion := CreateRectRgnIndirect(DragRect); + + // Start with non-client area if requested. + if UpdateNCArea then + begin + // Compute the part of the non-client area which must be updated. + + // Determine the outer rectangle of the entire tree window. + GetWindowRect(Handle, NCRect); + // Express the tree window rectangle in client coordinates (because RedrawWindow wants them so). + MapWindowPoints(0, Handle, NCRect, 2); + NCRegion := CreateRectRgnIndirect(NCRect); + // Determine client rect in screen coordinates and create another region for it. + UpdateRegion := CreateRectRgnIndirect(ClientRect); + // Create a region which only contains the NC part by subtracting out the client area. + CombineRgn(NCRegion, NCRegion, UpdateRegion, RGN_DIFF); + // Subtract also out what is hidden by the drag image. + CombineRgn(NCRegion, NCRegion, DragRegion, RGN_DIFF); + RedrawWindow(Handle, nil, NCRegion, RDW_FRAME or RDW_NOERASE or RDW_NOCHILDREN or RDW_INVALIDATE or RDW_VALIDATE or + RDW_UPDATENOW); + DeleteObject(NCRegion); + DeleteObject(UpdateRegion); + end; + + UpdateRegion := CreateRectRgnIndirect(TreeRect); + RedrawFlags := RDW_INVALIDATE or RDW_VALIDATE or RDW_UPDATENOW or RDW_NOERASE or RDW_NOCHILDREN; + // Remove the part of the update region which is covered by the drag image. + CombineRgn(UpdateRegion, UpdateRegion, DragRegion, RGN_DIFF); + RedrawWindow(Handle, nil, UpdateRegion, RedrawFlags); + DeleteObject(UpdateRegion); + DeleteObject(DragRegion); + DeleteObject(VisibleTreeRegion); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ValidateCache; + +// Starts cache validation if not already done by adding this instance to the worker thread's waiter list +// (if not already there) and signalling the thread it can start validating. + +begin + // Wait for thread to stop validation if it is currently validating this tree's cache. + InterruptValidation; + + FStartIndex := 0; + if tsValidationNeeded in FStates then + begin + // Tell the thread this tree needs actually something to do. + WorkerThread.AddTree(Self); + SetEvent(WorkEvent); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ValidateNodeDataSize(var Size: Integer); + +begin + Size := 0; + if Assigned(FOnGetNodeDataSize) then + FOnGetNodeDataSize(Self, Size); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +//PROFILE-NO +procedure TBaseVirtualTree.WndProc(var Message: TMessage); + +var + Handled: Boolean; + +begin + Handled := False; + + // Try the header whether it needs to take this message. + if Assigned(FHeader) and (FHeader.FStates <> []) then + Handled := FHeader.HandleMessage(Message); + if not Handled then + begin + // For auto drag mode, let tree handle itself, instead of TControl. + if not (csDesigning in ComponentState) and + ((Message.Msg = WM_LBUTTONDOWN) or (Message.Msg = WM_LBUTTONDBLCLK)) then + begin + if (DragMode = dmAutomatic) and (DragKind = dkDrag) then + begin + if IsControlMouseMsg(TWMMouse(Message)) then + Handled := True; + if not Handled then + begin + ControlState := ControlState + [csLButtonDown]; + Dispatch(Message); // overrides TControl's BeginDrag + Handled := True; + end; + end; + end; + + if not Handled and Assigned(FHeader) then + Handled := FHeader.HandleMessage(Message); + + if not Handled then + begin + if (Message.Msg in [WM_NCLBUTTONDOWN, WM_NCRBUTTONDOWN, WM_NCMBUTTONDOWN]) and not Focused and CanFocus then + SetFocus; + inherited; + end; + end; +end; +//PROFILE-YES + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WriteChunks(Stream: TStream; Node: PVirtualNode); + +// Writes the core chunks for Node into the stream. +// Note: descendants can optionally override this method to add other node specific chunks. +// Keep in mind that this method is also called for the root node. Using this fact in descendants you can +// create a kind of "global" chunks not directly bound to a specific node. + +var + Header: TChunkHeader; + LastPosition, + ChunkSize: Integer; + Chunk: TBaseChunk; + Run: PVirtualNode; + +begin + with Stream do + begin + // 1. The base chunk... + LastPosition := Position; + Chunk.Header.ChunkType := BaseChunk; + with Node^, Chunk do + begin + Body.ChildCount := ChildCount; + Body.NodeHeight := NodeHeight; + // Some states are only temporary so take them out as they make no sense at the new location. + Body.States := States - [vsChecking, vsCutOrCopy, vsDeleting, vsInitialUserData, vsHeightMeasured]; + Body.Align := Align; + Body.CheckState := CheckState; + Body.CheckType := CheckType; + Body.Reserved := 0; + end; + // write the base chunk + Write(Chunk, SizeOf(Chunk)); + + // 2. ... directly followed by the child node chunks (actually they are child chunks of + // the base chunk) + if vsInitialized in Node.States then + begin + Run := Node.FirstChild; + while Assigned(Run) do + begin + WriteNode(Stream, Run); + Run := Run.NextSibling; + end; + end; + + FinishChunkHeader(Stream, LastPosition, Position); + + // 3. write user data + LastPosition := Position; + Header.ChunkType := UserChunk; + Write(Header, SizeOf(Header)); + DoSaveUserData(Node, Stream); + // check if the application actually wrote data + ChunkSize := Position - LastPosition - SizeOf(TChunkHeader); + // seek back to start of chunk if nothing has been written + if ChunkSize = 0 then + begin + Position := LastPosition; + Size := Size - SizeOf(Header); + end + else + FinishChunkHeader(Stream, LastPosition, Position); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.WriteNode(Stream: TStream; Node: PVirtualNode); + +// Writes the "cover" chunk for Node to Stream and initiates writing child nodes and chunks. + +var + LastPosition: Integer; + Header: TChunkHeader; + +begin + // Initialize the node first if necessary and wanted. + if toInitOnSave in FOptions.FMiscOptions then + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + if (vsHasChildren in Node.States) and (Node.ChildCount = 0) then + InitChildren(Node); + end; + + with Stream do + begin + LastPosition := Position; + // Emit the anchor chunk. + Header.ChunkType := NodeChunk; + Write(Header, SizeOf(Header)); + // Write other chunks to stream taking their size into this chunk's size. + WriteChunks(Stream, Node); + + // Update chunk size. + FinishChunkHeader(Stream, LastPosition, Position); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.AbsoluteIndex(Node: PVirtualNode): Cardinal; + +begin + Result := 0; + while Assigned(Node) and (Node <> FRoot) do + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + if Assigned(Node.PrevSibling) then + begin + // if there's a previous sibling then add its total count to the result + Node := Node.PrevSibling; + Inc(Result, Node.TotalCount); + end + else + begin + Node := Node.Parent; + if Node <> FRoot then + Inc(Result); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.AddChild(Parent: PVirtualNode; UserData: Pointer = nil): PVirtualNode; + +// Adds a new node to the given parent node. This is simply done by increasing the child count of the +// parent node. If Parent is nil then the new node is added as (last) top level node. +// UserData can be used to set the first 4 bytes of the user data area to an initial value which can be used +// in OnInitNode and will also cause to trigger the OnFreeNode event (if <> nil) even if the node is not yet +// "officially" initialized. +// AddChild is a compatibility method and will implicitly validate the parent node. This is however +// against the virtual paradigm and hence I dissuade from its usage. + +var + NodeData: ^Pointer; + +begin + if not (toReadOnly in FOptions.FMiscOptions) then + begin + CancelEditNode; + + if Parent = nil then + Parent := FRoot; + if not (vsInitialized in Parent.States) then + InitNode(Parent); + + // Locally stop updates of the tree in order to avoid usage of the new node before it is correctly set up. + // If the update count was 0 on enter then there will be a correct update at the end of this method. + Inc(FUpdateCount); + try + SetChildCount(Parent, Parent.ChildCount + 1); + // Update the hidden children flag of the parent. Nodes are added as being visible by default. + Exclude(Parent.States, vsAllChildrenHidden); + finally + Dec(FUpdateCount); + end; + Result := Parent.LastChild; + + // Check if there is initial user data and there is also enough user data space allocated. + if Assigned(UserData) then + if FNodeDataSize >= SizeOf(Pointer) then + begin + NodeData := Pointer(PByte(@Result.Data) + FTotalInternalDataSize); + NodeData^ := UserData; + Include(Result.States, vsInitialUserData); + end + else + ShowError(SCannotSetUserData, hcTFCannotSetUserData); + + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + if tsStructureChangePending in FStates then + begin + if Parent = FRoot then + StructureChange(nil, crChildAdded) + else + StructureChange(Parent, crChildAdded); + end; + + if (toAutoSort in FOptions.FAutoOptions) and (FHeader.FSortColumn > InvalidColumn) then + Sort(Parent, FHeader.FSortColumn, FHeader.FSortDirection, True); + + InvalidateToBottom(Parent); + UpdateScrollbars(True); + end; + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AddFromStream(Stream: TStream; TargetNode: PVirtualNode); + +// loads nodes from the given stream and adds them to TargetNode +// the current content is not cleared before the load process starts (see also LoadFromStream) + +var + ThisID: TMagicID; + Version, + Count: Cardinal; + Node: PVirtualNode; + +begin + if not (toReadOnly in FOptions.FMiscOptions) then + begin + // check first whether this is a stream we can read + Stream.ReadBuffer(ThisID, SizeOf(TMagicID)); + if (ThisID[0] = MagicID[0]) and + (ThisID[1] = MagicID[1]) and + (ThisID[2] = MagicID[2]) and + (ThisID[5] = MagicID[5]) then + begin + Version := Word(ThisID[3]); + if Version <= VTTreeStreamVersion then + begin + BeginUpdate; + try + if Version < 2 then + Count := MaxInt + else + Stream.ReadBuffer(Count, SizeOf(Count)); + + while (Stream.Position < Stream.Size) and (Count > 0) do + begin + Dec(Count); + Node := MakeNewNode; + InternalConnectNode(Node, TargetNode, Self, amAddChildLast); + InternalAddFromStream(Stream, Version, Node); + end; + if TargetNode = FRoot then + DoNodeCopied(nil) + else + DoNodeCopied(TargetNode); + finally + EndUpdate; + end; + end + else + ShowError(SWrongStreamVersion, hcTFWrongStreamVersion); + end + else + ShowError(SWrongStreamVersion, hcTFWrongStreamVersion); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.AfterConstruction; + +begin + inherited; + + if FRoot = nil then + InitRootNode; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Assign(Source: TPersistent); + +begin + if (Source is TBaseVirtualTree) and not (toReadOnly in FOptions.FMiscOptions) then + with Source as TBaseVirtualTree do + begin + Self.Align := Align; + Self.Anchors := Anchors; + Self.AutoScrollDelay := AutoScrollDelay; + Self.AutoScrollInterval := AutoScrollInterval; + Self.AutoSize := AutoSize; + Self.Background := Background; + Self.BevelEdges := BevelEdges; + Self.BevelInner := BevelInner; + Self.BevelKind := BevelKind; + Self.BevelOuter := BevelOuter; + Self.BevelWidth := BevelWidth; + Self.BiDiMode := BiDiMode; + Self.BorderStyle := BorderStyle; + Self.BorderWidth := BorderWidth; + Self.ChangeDelay := ChangeDelay; + Self.CheckImageKind := CheckImageKind; + Self.Color := Color; + Self.Colors.Assign(Colors); + Self.Constraints.Assign(Constraints); + Self.Ctl3D := Ctl3D; + Self.DefaultNodeHeight := DefaultNodeHeight; + Self.DefaultPasteMode := DefaultPasteMode; + Self.DragCursor := DragCursor; + Self.DragImageKind := DragImageKind; + Self.DragKind := DragKind; + Self.DragMode := DragMode; + Self.Enabled := Enabled; + Self.Font := Font; + Self.Header := Header; + Self.HintAnimation := HintAnimation; + Self.HintMode := HintMode; + Self.HotCursor := HotCursor; + Self.Images := Images; + Self.ImeMode := ImeMode; + Self.ImeName := ImeName; + Self.Indent := Indent; + Self.Margin := Margin; + Self.NodeAlignment := NodeAlignment; + Self.NodeDataSize := NodeDataSize; + Self.TreeOptions := TreeOptions; + Self.ParentBiDiMode := ParentBiDiMode; + Self.ParentColor := ParentColor; + Self.ParentCtl3D := ParentCtl3D; + Self.ParentFont := ParentFont; + Self.ParentShowHint := ParentShowHint; + Self.PopupMenu := PopupMenu; + Self.RootNodeCount := RootNodeCount; + Self.ScrollBarOptions := ScrollBarOptions; + Self.ShowHint := ShowHint; + Self.StateImages := StateImages; + Self.TabOrder := TabOrder; + Self.TabStop := TabStop; + Self.Visible := Visible; + Self.SelectionCurveRadius := SelectionCurveRadius; + Self.SelectionBlendFactor := SelectionBlendFactor; + Self.EmptyListMessage := EmptyListMessage; + end + else + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.BeginDrag(Immediate: Boolean; Threshold: Integer); + +// Reintroduced method to allow to start OLE drag'n drop as well as VCL drag'n drop. + +begin + if FDragType = dtVCL then + begin + DoStateChange([tsVCLDragPending]); + inherited; + end + else + if (FStates * [tsOLEDragPending, tsOLEDragging]) = [] then + begin + // Drag start position has already been recorded in WMMouseDown. + if Threshold < 0 then + FDragThreshold := Mouse.DragThreshold + else + FDragThreshold := Threshold; + if Immediate then + DoDragging(FLastClickPos) + else + DoStateChange([tsOLEDragPending]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.BeginSynch; + +// Starts the synchronous update mode (if not already active). + +begin + if not (csDestroying in ComponentState) then + begin + if FSynchUpdateCount = 0 then + begin + DoUpdating(usBeginSynch); + + // Stop all timers... + StopTimer(ChangeTimer); + StopTimer(StructureChangeTimer); + StopTimer(ExpandTimer); + StopTimer(EditTimer); + StopTimer(HeaderTimer); + StopTimer(ScrollTimer); + StopTimer(SearchTimer); + FSearchBuffer := ''; + FLastSearchNode := nil; + DoStateChange([], [tsEditPending, tsScrollPending, tsScrolling, tsIncrementalSearching]); + + // ...and trigger pending update states. + if tsStructureChangePending in FStates then + DoStructureChange(FLastStructureChangeNode, FLastStructureChangeReason); + if tsChangePending in FStates then + DoChange(FLastChangedNode); + end + else + DoUpdating(usSynch); + end; + Inc(FSynchUpdateCount); + DoStateChange([tsSynchMode]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.BeginUpdate; + +begin + if not (csDestroying in ComponentState) then + begin + if FUpdateCount = 0 then + begin + DoUpdating(usBegin); + SetUpdateState(True); + end + else + DoUpdating(usUpdate); + end; + Inc(FUpdateCount); + DoStateChange([tsUpdating]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CancelCutOrCopy; + +// Resets nodes which are marked as being cut. + +var + Run: PVirtualNode; + +begin + if ([tsCutPending, tsCopyPending] * FStates) <> [] then + begin + Run := FRoot.FirstChild; + while Assigned(Run) do + begin + if vsCutOrCopy in Run.States then + Exclude(Run.States, vsCutOrCopy); + Run := GetNextNoInit(Run); + end; + end; + DoStateChange([], [tsCutPending, tsCopyPending]); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CancelEditNode: Boolean; + +// Called by the application or the current edit link to cancel the edit action. + +begin + if HandleAllocated and ([tsEditing, tsEditPending] * FStates <> []) then + Result := DoCancelEdit + else + Result := True; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CancelOperation; + +// Called by the application to cancel a long-running operation. + +begin + if FOperationCount > 0 then + FOperationCanceled := True; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CanEdit(Node: PVirtualNode; Column: TColumnIndex): Boolean; + +// Returns True if the given node can be edited. + +begin + Result := (toEditable in FOptions.FMiscOptions) and Enabled and not (toReadOnly in FOptions.FMiscOptions); + DoCanEdit(Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CanFocus: Boolean; + +var + Form: TCustomForm; + +begin + Result := inherited CanFocus; + + if Result and not (csDesigning in ComponentState) then + begin + Form := GetParentForm(Self); + Result := (Form = nil) or (Form.Enabled and Form.Visible); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Clear; + +begin + if not (toReadOnly in FOptions.FMiscOptions) or (csDestroying in ComponentState) then + begin + BeginUpdate; + try + InterruptValidation; + if IsEditing then + CancelEditNode; + + if ClipboardStates * FStates <> [] then + begin + OleSetClipBoard(nil); + DoStateChange([], ClipboardStates); + end; + ClearSelection; + FFocusedNode := nil; + FLastSelected := nil; + FCurrentHotNode := nil; + FDropTargetNode := nil; + FLastChangedNode := nil; + FRangeAnchor := nil; + FCheckNode := nil; + FLastVCLDragTarget := nil; + FLastSearchNode := nil; + DeleteChildren(FRoot, True); + FOffsetX := 0; + FOffsetY := 0; + + finally + EndUpdate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ClearChecked; + +var + Node: PVirtualNode; + +begin + Node := RootNode.FirstChild; + while Assigned(Node) do + begin + if Node.CheckState <> csUncheckedNormal then + CheckState[Node] := csUncheckedNormal; + Node := GetNextNoInit(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ClearSelection; + +var + Node: PVirtualNode; + Dummy: Integer; + R: TRect; + Counter: Integer; + +begin + if not FSelectionLocked and (FSelectionCount > 0) and not (csDestroying in ComponentState) then + begin + if (FUpdateCount = 0) and HandleAllocated and (FVisibleCount > 0) then + begin + // Iterate through nodes currently visible in the client area and invalidate them. + Node := GetNodeAt(0, 0, True, Dummy); + if Assigned(Node) then + R := GetDisplayRect(Node, NoColumn, False); + Counter := FSelectionCount; + + while Assigned(Node) do + begin + R.Bottom := R.Top + Integer(NodeHeight[Node]); + if vsSelected in Node.States then + begin + InvalidateRect(Handle, @R, False); + Dec(Counter); + // Only try as many nodes as are selected. + if Counter = 0 then + Break; + end; + R.Top := R.Bottom; + if R.Top > ClientHeight then + Break; + Node := GetNextVisibleNoInit(Node, True); + end; + end; + + InternalClearSelection; + Change(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CopyTo(Source: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean): PVirtualNode; + +// A simplified CopyTo method to allow to copy nodes to the root of another tree. + +begin + Result := CopyTo(Source, Tree.FRoot, Mode, ChildrenOnly); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CopyTo(Source, Target: PVirtualNode; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean): PVirtualNode; + +// Copies Source and all its child nodes to Target. +// Mode is used to specify further where to add the new node actually (as sibling of Target or as child of Target). +// Result is the newly created node to which source has been copied if ChildrenOnly is False or just contains Target +// in the other case. +// ChildrenOnly determines whether to copy also the source node or only its child nodes. + +var + TargetTree: TBaseVirtualTree; + Stream: TMemoryStream; + +begin + Assert(TreeFromNode(Source) = Self, 'The source tree must contain the source node.'); + + Result := nil; + if (Mode <> amNoWhere) and Assigned(Source) and (Source <> FRoot) then + begin + // Assume that an empty destination means the root in this (the source) tree. + if Target = nil then + begin + TargetTree := Self; + Target := FRoot; + Mode := amAddChildFirst; + end + else + TargetTree := TreeFromNode(Target); + + if not (toReadOnly in TargetTree.FOptions.FMiscOptions) then + begin + if Target = TargetTree.FRoot then + begin + case Mode of + amInsertBefore: + Mode := amAddChildFirst; + amInsertAfter: + Mode := amAddChildLast; + end; + end; + + Stream := TMemoryStream.Create; + try + // Write all nodes into a temprary stream depending on the ChildrenOnly flag. + if not ChildrenOnly then + WriteNode(Stream, Source) + else + begin + Source := Source.FirstChild; + while Assigned(Source) do + begin + WriteNode(Stream, Source); + Source := Source.NextSibling; + end; + end; + // Now load the serialized nodes into the target node (tree). + TargetTree.BeginUpdate; + try + Stream.Position := 0; + while Stream.Position < Stream.Size do + begin + Result := TargetTree.MakeNewNode; + InternalConnectNode(Result, Target, TargetTree, Mode); + TargetTree.InternalAddFromStream(Stream, VTTreeStreamVersion, Result); + if not DoNodeCopying(Result, Target) then + begin + TargetTree.DeleteNode(Result); + Result := nil; + end + else + DoNodeCopied(Result); + end; + if ChildrenOnly then + Result := Target; + finally + TargetTree.EndUpdate; + end; + finally + Stream.Free; + end; + + with TargetTree do + begin + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + UpdateScrollBars(True); + Invalidate; + end; + StructureChange(Source, crNodeCopied); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CopyToClipBoard; + +var + DataObject: IDataObject; + +begin + if FSelectionCount > 0 then + begin + DataObject := TVTDataObject.Create(Self, True) as IDataObject; + if OleSetClipBoard(DataObject) = S_OK then + begin + MarkCutCopyNodes; + DoStateChange([tsCopyPending]); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.CutToClipBoard; + +var + DataObject: IDataObject; + +begin + if (FSelectionCount > 0) and not (toReadOnly in FOptions.FMiscOptions) then + begin + DataObject := TVTDataObject.Create(Self, True) as IDataObject; + if OleSetClipBoard(DataObject) = S_OK then + begin + MarkCutCopyNodes; + DoStateChange([tsCutPending], [tsCopyPending]); + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DeleteChildren(Node: PVirtualNode; ResetHasChildren: Boolean = False); + +// Removes all children and their children from memory without changing the vsHasChildren style by default. + +var + Run, + Mark: PVirtualNode; + LastTop, + LastLeft, + NewSize: Integer; + ParentVisible: Boolean; + +begin + if Assigned(Node) and (Node.ChildCount > 0) and not (toReadOnly in FOptions.FMiscOptions) then + begin + Assert(not (tsIterating in FStates), 'Deleting nodes during tree iteration leads to invalid pointers.'); + + // The code below uses some flags for speed improvements which may cause invalid pointers if updates of + // the tree happen. Hence switch updates off until we have finished the operation. + Inc(FUpdateCount); + try + InterruptValidation; + LastLeft := -FEffectiveOffsetX; + LastTop := FOffsetY; + + // Make a local copy of the visibility state of this node to speed up + // adjusting the visible nodes count. + ParentVisible := Node = FRoot; + if not ParentVisible then + ParentVisible := FullyVisible[Node] and (vsExpanded in Node.States); + + // Show that we are clearing the child list, to avoid registering structure change events. + Include(Node.States, vsClearing); + Run := Node.LastChild; + while Assigned(Run) do + begin + if ParentVisible and IsEffectivelyVisible[Run] then + Dec(FVisibleCount); + + Include(Run.States, vsDeleting); + Mark := Run; + Run := Run.PrevSibling; + // Important, to avoid exchange of invalid pointers while disconnecting the node. + if Assigned(Run) then + Run.NextSibling := nil; + DeleteNode(Mark); + end; + Exclude(Node.States, vsClearing); + if ResetHasChildren then + Exclude(Node.States, vsHasChildren); + if Node <> FRoot then + Exclude(Node.States, vsExpanded); + Node.ChildCount := 0; + if (Node = FRoot) or (vsDeleting in Node.States) then + begin + Node.TotalHeight := FDefaultNodeHeight + NodeHeight[Node]; + Node.TotalCount := 1; + end + else + begin + AdjustTotalHeight(Node, NodeHeight[Node]); + AdjustTotalCount(Node, 1); + end; + Node.FirstChild := nil; + Node.LastChild := nil; + finally + Dec(FUpdateCount); + end; + + InvalidateCache; + if FUpdateCount = 0 then + begin + NewSize := PackArray(FSelection, FSelectionCount); + if NewSize > -1 then + begin + FSelectionCount := NewSize; + SetLength(FSelection, FSelectionCount); + end; + + ValidateCache; + UpdateScrollbars(True); + // Invalidate entire tree if it scrolled e.g. to make the last node also the + // bottom node in the treeview. + if (LastLeft <> FOffsetX) or (LastTop <> FOffsetY) then + Invalidate + else + InvalidateToBottom(Node); + end; + StructureChange(Node, crChildDeleted); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DeleteNode(Node: PVirtualNode; Reindex: Boolean = True); + +var + LastTop, + LastLeft: Integer; + LastParent: PVirtualNode; + WasInSynchMode: Boolean; + ParentClearing: Boolean; + +begin + if Assigned(Node) and (Node <> FRoot) and not (toReadOnly in FOptions.FMiscOptions) then + begin + Assert(not (tsIterating in FStates), 'Deleting nodes during tree iteration leads to invalid pointers.'); + + // Determine parent node for structure change notification. + ParentClearing := vsClearing in Node.Parent.States; + LastParent := Node.Parent; + + if not ParentClearing then + begin + if LastParent = FRoot then + StructureChange(nil, crChildDeleted) + else + StructureChange(LastParent, crChildDeleted); + end; + + LastLeft := -FEffectiveOffsetX; + LastTop := FOffsetY; + + if vsSelected in Node.States then + begin + if FUpdateCount = 0 then + begin + // Go temporarily into sync mode to avoid a delayed change event for the node + // when unselecting. + WasInSynchMode := tsSynchMode in FStates; + Include(FStates, tsSynchMode); + RemoveFromSelection(Node); + if not WasInSynchMode then + Exclude(FStates, tsSynchMode); + InvalidateToBottom(LastParent); + end + else + InternalRemoveFromSelection(Node); + end + else + InvalidateToBottom(LastParent); + + if tsHint in FStates then + begin + Application.CancelHint; + DoStateChange([], [tsHint]); + end; + + if not ParentClearing then + InterruptValidation; + + DeleteChildren(Node); + InternalDisconnectNode(Node, False, Reindex); + DoFreeNode(Node); + + if not ParentClearing then + begin + DetermineHiddenChildrenFlag(LastParent); + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + UpdateScrollbars(True); + // Invalidate entire tree if it scrolled e.g. to make the last node also the + // bottom node in the treeview. + if (LastLeft <> FOffsetX) or (LastTop <> FOffsetY) then + Invalidate; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.DeleteSelectedNodes; + +// Deletes all currently selected nodes (including their child nodes). + +var + Nodes: TNodeArray; + I: Integer; + LevelChange: Boolean; + +begin + Nodes := nil; + if (FSelectionCount > 0) and not (toReadOnly in FOptions.FMiscOptions) then + begin + BeginUpdate; + try + Nodes := GetSortedSelection(True); + for I := High(Nodes) downto 1 do + begin + LevelChange := Nodes[I].Parent <> Nodes[I - 1].Parent; + DeleteNode(Nodes[I], LevelChange); + end; + DeleteNode(Nodes[0]); + finally + EndUpdate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.Dragging: Boolean; + +begin + // Check for both OLE drag'n drop as well as VCL drag'n drop. + Result := ([tsOLEDragPending, tsOLEDragging] * FStates <> []) or inherited Dragging; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.EditNode(Node: PVirtualNode; Column: TColumnIndex): Boolean; + +// Application triggered edit event for the given node. +// Returns True if the tree started editing otherwise False. + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + Assert((Column > InvalidColumn) and (Column < FHeader.Columns.Count), + 'Column must be a valid column index (-1 if no header is shown).'); + + Result := tsEditing in FStates; + // If the tree is already editing then we don't disrupt this. + if not Result and not (toReadOnly in FOptions.FMiscOptions) then + begin + FocusedNode := Node; + if Assigned(FFocusedNode) and (Node = FFocusedNode) and CanEdit(FFocusedNode, Column) then + begin + FEditColumn := Column; + if not (vsInitialized in Node.States) then + InitNode(Node); + DoEdit; + Result := tsEditing in FStates; + end + else + Result := False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.EndEditNode: Boolean; + +// Called to finish a current edit action or stop the edit timer if an edit operation is pending. + +begin + if [tsEditing, tsEditPending] * FStates <> [] then + Result := DoEndEdit + else + Result := True; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.EndSynch; + +begin + if FSynchUpdateCount > 0 then + Dec(FSynchUpdateCount); + + if not (csDestroying in ComponentState) then + begin + if FSynchUpdateCount = 0 then + begin + DoStateChange([], [tsSynchMode]); + DoUpdating(usEndSynch); + end + else + DoUpdating(usSynch); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.EndUpdate; + +var + NewSize: Integer; + +begin + if FUpdateCount > 0 then + Dec(FUpdateCount); + + if not (csDestroying in ComponentState) then + begin + if (FUpdateCount = 0) and (tsUpdating in FStates) then + begin + if tsUpdateHiddenChildrenNeeded in FStates then + begin + DetermineHiddenChildrenFlagAllNodes; + Exclude(FStates, tsUpdateHiddenChildrenNeeded); + end; + + DoStateChange([], [tsUpdating]); + + NewSize := PackArray(FSelection, FSelectionCount); + if NewSize > -1 then + begin + FSelectionCount := NewSize; + SetLength(FSelection, FSelectionCount); + end; + + InvalidateCache; + ValidateCache; + if HandleAllocated then + UpdateScrollBars(False); + + if tsStructureChangePending in FStates then + DoStructureChange(FLastStructureChangeNode, FLastStructureChangeReason); + try + if tsChangePending in FStates then + DoChange(FLastChangedNode); + finally + if toAutoSort in FOptions.FAutoOptions then + SortTree(FHeader.FSortColumn, FHeader.FSortDirection, True); + + SetUpdateState(False); + if HandleAllocated then + Invalidate; + UpdateDesigner; + end; + end; + + if FUpdateCount = 0 then + DoUpdating(usEnd) + else + DoUpdating(usUpdate); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ExecuteAction(Action: TBasicAction): Boolean; + +// Some support for standard actions. + +begin + Result := inherited ExecuteAction(Action); + + if not Result then + begin + Result := Action is TEditSelectAll; + if Result then + SelectAll(False) + else + begin + Result := Action is TEditCopy; + if Result then + CopyToClipboard + else + if not (toReadOnly in FOptions.FMiscOptions) then + begin + Result := Action is TEditCut; + if Result then + CutToClipBoard + else + begin + Result := Action is TEditPaste; + if Result then + PasteFromClipboard + else + begin + Result := Action is TEditDelete; + if Result then + DeleteSelectedNodes + end; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FinishCutOrCopy; + +// Deletes nodes which are marked as being cutted. + +var + Run: PVirtualNode; + +begin + if tsCutPending in FStates then + begin + Run := FRoot.FirstChild; + while Assigned(Run) do + begin + if vsCutOrCopy in Run.States then + DeleteNode(Run); + Run := GetNextNoInit(Run); + end; + DoStateChange([], [tsCutPending]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FlushClipboard; + +// Used to render the data which is currently on the clipboard (finishes delayed rendering). + +begin + if ClipboardStates * FStates <> [] then + begin + DoStateChange([tsClipboardFlushing]); + OleFlushClipboard; + CancelCutOrCopy; + DoStateChange([], [tsClipboardFlushing]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FullCollapse(Node: PVirtualNode = nil); + +// This routine collapses all expanded nodes in the subtree given by Node or the whole tree if Node is FRoot or nil. +// Only nodes which are expanded will be collapsed. This excludes uninitialized nodes but nodes marked as visible +// will still be collapsed if they are expanded. + +var + Stop: PVirtualNode; + +begin + if FRoot.TotalCount > 1 then + begin + if Node = FRoot then + Node := nil; + + DoStateChange([tsCollapsing]); + BeginUpdate; + try + Stop := Node; + Node := GetLastVisibleNoInit(Node, True); + + if Assigned(Node) then + begin + repeat + if [vsHasChildren, vsExpanded] * Node.States = [vsHasChildren, vsExpanded] then + ToggleNode(Node); + Node := GetPreviousNoInit(Node, True); + until Node = Stop; + + // Collapse the start node too. + if Assigned(Node) and ([vsHasChildren, vsExpanded] * Node.States = [vsHasChildren, vsExpanded]) then + ToggleNode(Node); + end; + finally + EndUpdate; + DoStateChange([], [tsCollapsing]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.FullExpand(Node: PVirtualNode = nil); + +// This routine expands all collapsed nodes in the subtree given by Node or the whole tree if Node is FRoot or nil. +// All nodes on the way down are initialized so this procedure might take a long time. +// Since all nodes are validated, the tree cannot make use of optimatizations. Hence it is counter productive and you +// should consider avoiding its use. + +var + Stop: PVirtualNode; + +begin + if FRoot.TotalCount > 1 then + begin + DoStateChange([tsExpanding]); + BeginUpdate; + try + if Node = nil then + begin + Node := FRoot.FirstChild; + Stop := nil; + end + else + begin + Stop := Node.NextSibling; + if Stop = nil then + begin + Stop := Node; + repeat + Stop := Stop.Parent; + until (Stop = FRoot) or Assigned(Stop.NextSibling); + if Stop = FRoot then + Stop := nil + else + Stop := Stop.NextSibling; + end; + end; + + // Initialize the start node. Others will be initialized in GetNext. + if not (vsInitialized in Node.States) then + InitNode(Node); + + repeat + if not (vsExpanded in Node.States) then + ToggleNode(Node); + Node := GetNext(Node); + until Node = Stop; + finally + EndUpdate; + DoStateChange([], [tsExpanding]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetControlsAlignment: TAlignment; + +begin + Result := FAlignment; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetDisplayRect(Node: PVirtualNode; Column: TColumnIndex; TextOnly: Boolean; + Unclipped: Boolean = False; ApplyCellContentMargin: Boolean = False): TRect; + +// Determines the client coordinates the given node covers, depending on scrolling, expand state etc. +// If the given node cannot be found (because one of its parents is collapsed or it is invisible) then an empty +// rectangle is returned. +// If TextOnly is True then only the text bounds are returned, that is, the resulting rectangle's left and right border +// are updated according to bidi mode, alignment and text width of the node. +// If Unclipped is True (which only makes sense if also TextOnly is True) then the calculated text rectangle is +// not clipped if the text does not entirely fit into the text space. This is special handling needed for hints. +// If ApplyCellContentMargin is True (which only makes sense if also TextOnly is True) then the calculated text +// rectangle respects the cell content margin. +// If Column is -1 then the entire client width is used before determining the node's width otherwise the bounds of the +// particular column are used. +// Note: Column must be a valid column and is used independent of whether the header is visible or not. + +var + Temp: PVirtualNode; + Offset: Cardinal; + Indent, + TextWidth: Integer; + MainColumnHit: Boolean; + CurrentBidiMode: TBidiMode; + CurrentAlignment: TAlignment; + MaxUnclippedHeight: Integer; + TM: TTextMetric; + ExtraVerticalMargin: Integer; + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + Assert(Node <> FRoot, 'Node must not be the hidden root node.'); + + MainColumnHit := (Column + 1) in [0, FHeader.MainColumn + 1]; + if not (vsInitialized in Node.States) then + InitNode(Node); + + Result := Rect(0, 0, 0, 0); + + // Check whether the node is visible (determine indentation level btw.). + if not IsEffectivelyVisible[Node] then + Exit; + Temp := Node; + Indent := 0; + while Temp <> FRoot do + begin + if not (vsVisible in Temp.States) or not (vsExpanded in Temp.Parent.States) then + Exit; + Temp := Temp.Parent; + if MainColumnHit and (Temp <> FRoot) then + Inc(Indent, FIndent); + end; + + // Here we know the node is visible. + Offset := 0; + if tsUseCache in FStates then + begin + // If we can use the position cache then do a binary search to find a cached node which is as close as possible + // to the current node. Iterate then through all following and visible nodes and sum up their heights. + Temp := FindInPositionCache(Node, Offset); + while Assigned(Temp) and (Temp <> Node) do + begin + Inc(Offset, NodeHeight[Temp]); + Temp := GetNextVisibleNoInit(Temp, True); + end; + end + else + begin + // If the cache is not available then go straight through all nodes up to the root and sum up their heights. + Temp := Node; + repeat + Temp := GetPreviousVisibleNoInit(Temp, True); + if Temp = nil then + Break; + Inc(Offset, NodeHeight[Temp]); + until False; + end; + + Result := Rect(0, Offset, Max(FRangeX, ClientWidth), Offset + NodeHeight[Node]); + + // Limit left and right bounds to the given column (if any) and move bounds according to current scroll state. + if Column > NoColumn then + begin + FHeader.FColumns.GetColumnBounds(Column, Result.Left, Result.Right); + // The right column border is not part of this cell. + Dec(Result.Right); + OffsetRect(Result, 0, FOffsetY); + end + else + OffsetRect(Result, -FEffectiveOffsetX, FOffsetY); + + // Limit left and right bounds further if only the text area is required. + if TextOnly then + begin + // Start with the offset of the text in the column and consider the indentation level too. + Offset := FMargin + Indent; + // If the text of a node is involved then we have to consider directionality and alignment too. + if Column <= NoColumn then + begin + CurrentBidiMode := BidiMode; + CurrentAlignment := Alignment; + end + else + begin + CurrentBidiMode := FHeader.FColumns[Column].BidiMode; + CurrentAlignment := FHeader.FColumns[Column].Alignment; + end; + + if MainColumnHit then + begin + if toShowRoot in FOptions.FPaintOptions then + Inc(Offset, FIndent); + if (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages) and (Node.CheckType <> ctNone) then + Inc(Offset, FCheckImages.Width + 2); + end; + // Consider associated images. + if Assigned(FStateImages) and HasImage(Node, ikState, Column) then + Inc(Offset, FStateImages.Width + 2); + if Assigned(FImages) and HasImage(Node, ikNormal, Column) then + Inc(Offset, FImages.Width + 2); + + // Offset contains now the distance from the left or right border of the rectangle (depending on bidi mode). + // Now consider the alignment too and calculate the final result. + if CurrentBidiMode = bdLeftToRight then + begin + Inc(Result.Left, Offset); + // Left-to-right reading does not need any special adjustment of the alignment. + end + else + begin + Dec(Result.Right, Offset); + + // Consider bidi mode here. In RTL context does left alignment actually mean right alignment and vice versa. + ChangeBiDiModeAlignment(CurrentAlignment); + end; + + TextWidth := DoGetNodeWidth(Node, Column); + + // Keep cell height before applying cell content margin in order to increase cell height if text does not fit + // and Unclipped it true (see below). + MaxUnclippedHeight := Result.Bottom - Result.Top; + + if ApplyCellContentMargin then + DoBeforeCellPaint(Self.Canvas, Node, Column, cpmGetContentMargin, Result, Result); + + if Unclipped then + begin + // The caller requested the text coordinates unclipped. This means they must be calculated so as would + // there be enough space, regardless of column bounds etc. + // The layout still depends on the available space too, because this determines the position + // of the unclipped text rectangle. + if Result.Right - Result.Left < TextWidth - 1 then + if CurrentBidiMode = bdLeftToRight then + CurrentAlignment := taLeftJustify + else + CurrentAlignment := taRightJustify; + + // Increase cell height (up to MaxUnclippedHeight determined above) if text does not fit. + GetTextMetrics(Self.Canvas.Handle, TM); + ExtraVerticalMargin := Math.Min(TM.tmHeight, MaxUnclippedHeight) - (Result.Bottom - Result.Top); + if ExtraVerticalMargin > 0 then + InflateRect(Result, 0, (ExtraVerticalMargin + 1) div 2); + + case CurrentAlignment of + taCenter: + begin + Result.Left := (Result.Left + Result.Right - TextWidth) div 2; + Result.Right := Result.Left + TextWidth; + end; + taRightJustify: + Result.Left := Result.Right - TextWidth; + else // taLeftJustify + Result.Right := Result.Left + TextWidth - 1; + end; + end + else + // Modify rectangle only if the text fits entirely into the given room. + if Result.Right - Result.Left > TextWidth then + case CurrentAlignment of + taCenter: + begin + Result.Left := (Result.Left + Result.Right - TextWidth) div 2; + Result.Right := Result.Left + TextWidth; + end; + taRightJustify: + Result.Left := Result.Right - TextWidth; + else // taLeftJustify + Result.Right := Result.Left + TextWidth; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetEffectivelyFiltered(Node: PVirtualNode): Boolean; + +// Checks if a node is effectively filtered out. This depends on the nodes state and the paint options. + +begin + if Assigned(Node) then + Result := (vsFiltered in Node.States) and not (toShowFilteredNodes in FOptions.FPaintOptions) + else + Result := False; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetEffectivelyVisible(Node: PVirtualNode): Boolean; + +begin + Result := (vsVisible in Node.States) and not IsEffectivelyFiltered[Node]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirst(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node in the tree while optionally considering toChildrenAbove. + +begin + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + if vsHasChildren in FRoot.States then + begin + Result := FRoot; + + // Child nodes are the first choice if possible. + if Assigned(Result.FirstChild) then + begin + while Assigned(Result.FirstChild) do + begin + Result := Result.FirstChild; + if not (vsInitialized in Result.States) then + InitNode(Result); + + if (vsHasChildren in Result.States) and (Result.ChildCount = 0) then + InitChildren(Result); + end; + end + else + Result := nil; + end + else + Result := nil; + end + else + Result := FRoot.FirstChild; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstChecked(State: TCheckState = csCheckedNormal; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node in the tree with the given check state. + +begin + Result := GetNextChecked(nil, State, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstChild(Node: PVirtualNode): PVirtualNode; + +// Returns the first child of the given node. The result node is initialized before exit. + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.FirstChild + else + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + if vsHasChildren in Node.States then + begin + if Node.ChildCount = 0 then + InitChildren(Node); + Result := Node.FirstChild; + end + else + Result := nil; + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstCutCopy(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node in the tree which is currently marked for a clipboard operation. +// See also GetNextCutCopy for comments on initialization. + +begin + Result := GetNextCutCopy(nil, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstInitialized(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node which is already initialized. + +begin + Result := GetFirstNoInit(ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + Result := GetNextInitialized(Result, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstLeaf: PVirtualNode; + +// Returns the first node in the tree which has currently no children. +// The result is initialized if necessary. + +begin + Result := GetNextLeaf(nil); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstLevel(NodeLevel: Cardinal): PVirtualNode; + +// Returns the first node in the tree on a specific level. +// The result is initialized if necessary. + +begin + Result := GetFirstNoInit(True); + while Assigned(Result) and (GetNodeLevel(Result) <> NodeLevel) do + Result := GetNextNoInit(Result, True); + + if Assigned(Result) and (GetNodeLevel(Result) <> NodeLevel) then // i.e. there is no node with the desired level in the tree + Result := nil; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstNoInit(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node in the tree while optionally considering toChildrenAbove. +// No initialization is performed. + +begin + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + if vsHasChildren in FRoot.States then + begin + Result := FRoot; + + // Child nodes are the first choice if possible. + if Assigned(Result.FirstChild) then + begin + while Assigned(Result.FirstChild) do + Result := Result.FirstChild; + end + else + Result := nil; + end + else + Result := nil; + end + else + Result := FRoot.FirstChild; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstSelected(ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the first node in the current selection while optionally considering toChildrenAbove. + +begin + Result := GetNextSelected(nil, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the first visible node in the tree while optionally considering toChildrenAbove. +// If necessary nodes are initialized on demand. + +begin + Result := Node; + if not Assigned(Result) then + Result := FRoot; + + if vsHasChildren in Result.States then + begin + if Result.ChildCount = 0 then + InitChildren(Result); + + // Child nodes are the first choice if possible. + if Assigned(Result.FirstChild) then + begin + Result := GetFirstChild(Result); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + // Search the first visible sibling. + while Assigned(Result.NextSibling) and not (vsVisible in Result.States) do + begin + Result := Result.NextSibling; + // Init node on demand as this might change the visibility. + if not (vsInitialized in Result.States) then + InitNode(Result); + end; + + // If there a no visible siblings take the parent. + if not (vsVisible in Result.States) then + begin + Result := Result.Parent; + if Result = FRoot then + Result := nil; + Break; + end + else + begin + if (vsHasChildren in Result.States) and (Result.ChildCount = 0) then + InitChildren(Result); + if (not Assigned(Result.FirstChild)) or (not (vsExpanded in Result.States)) then + Break; + end; + + Result := Result.FirstChild; + if not (vsInitialized in Result.States) then + InitNode(Result); + until False; + end + else + begin + // If there are no children or the first child is not visible then search the sibling nodes or traverse parents. + if not (vsVisible in Result.States) then + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + // The visible state can be removed during initialization so init the node first. + if not (vsInitialized in Result.States) then + InitNode(Result); + if vsVisible in Result.States then + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + end + else + Result := nil; + end + else + Result := nil; + + if Assigned(Result) and not IncludeFiltered and IsEffectivelyFiltered[Result] then + Result := GetNextVisible(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstVisibleChild(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the first visible child node of Node. If necessary nodes are initialized on demand. + +begin + if Node = nil then + Node := FRoot; + Result := GetFirstChild(Node); + + if Assigned(Result) and (not (vsVisible in Result.States) or + (not IncludeFiltered and IsEffectivelyFiltered[Node])) then + Result := GetNextVisibleSibling(Result, IncludeFiltered); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstVisibleChildNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the first visible child node of Node. + +begin + if Node = nil then + Node := FRoot; + Result := Node.FirstChild; + if Assigned(Result) and (not (vsVisible in Result.States) or + (not IncludeFiltered and IsEffectivelyFiltered[Node])) then + Result := GetNextVisibleSiblingNoInit(Result, IncludeFiltered); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetFirstVisibleNoInit(Node: PVirtualNode = nil; + ConsiderChildrenAbove: Boolean = True; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the first visible node in the tree or given subtree while optionally considering toChildrenAbove. +// No initialization is performed. + +begin + Result := Node; + if not Assigned(Result) then + Result := FRoot; + + if vsHasChildren in Result.States then + begin + // Child nodes are the first choice if possible. + if Assigned(Result.FirstChild) then + begin + Result := Result.FirstChild; + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + // Search the first visible sibling. + while Assigned(Result.NextSibling) and not (vsVisible in Result.States) do + Result := Result.NextSibling; + + // If there a no visible siblings take the parent. + if not (vsVisible in Result.States) then + begin + Result := Result.Parent; + if Result = FRoot then + Result := nil; + Break; + end + else + if (not Assigned(Result.FirstChild)) or (not (vsExpanded in Result.States))then + Break; + + Result := Result.FirstChild; + until False; + end + else + begin + // If there are no children or the first child is not visible then search the sibling nodes or traverse parents. + if not (vsVisible in Result.States) then + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + if vsVisible in Result.States then + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + end + else + Result := nil; + end + else + Result := nil; + + if Assigned(Result) and not IncludeFiltered and IsEffectivelyFiltered[Result] then + Result := GetNextVisibleNoInit(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.GetHitTestInfoAt(X, Y: Integer; Relative: Boolean; var HitInfo: THitInfo); + +// Determines the node that occupies the specified point or nil if there's none. The parameter Relative determines +// whether to consider X and Y as being client coordinates (if True) or as being absolute tree coordinates. +// HitInfo is filled with flags describing the hit further. + +var + ColLeft, + ColRight: Integer; + NodeTop: Integer; + InitialColumn, + NextColumn: TColumnIndex; + CurrentBidiMode: TBidiMode; + CurrentAlignment: TAlignment; + NodeRect: TRect; + +begin + HitInfo.HitNode := nil; + HitInfo.HitPositions := []; + HitInfo.HitColumn := NoColumn; + + // Determine if point lies in the tree's client area. + if X < 0 then + Include(HitInfo.HitPositions, hiToLeft) + else + if X > Max(FRangeX, ClientWidth) then + Include(HitInfo.HitPositions, hiToRight); + + if Y < 0 then + Include(HitInfo.HitPositions, hiAbove) + else + if Y > Max(FRangeY, ClientHeight) then + Include(HitInfo.HitPositions, hiBelow); + + // Convert position into absolute coordinate if necessary. + if Relative then + begin + if X > Header.Columns.GetVisibleFixedWidth then + Inc(X, FEffectiveOffsetX); + Inc(Y, -FOffsetY); + end; + + // If the point is in the tree area then check the nodes. + if HitInfo.HitPositions = [] then + begin + HitInfo.HitNode := GetNodeAt(X, Y, False, NodeTop); + if HitInfo.HitNode = nil then + Include(HitInfo.HitPositions, hiNowhere) + else + begin + // At this point we need some info about the node, so it must be initialized. + if not (vsInitialized in HitInfo.HitNode.States) then + InitNode(HitInfo.HitNode); + + if FHeader.UseColumns then + begin + HitInfo.HitColumn := FHeader.Columns.GetColumnAndBounds(Point(X, Y), ColLeft, ColRight, False); + // If auto column spanning is enabled then look for the last non empty column. + if toAutoSpanColumns in FOptions.FAutoOptions then + begin + InitialColumn := HitInfo.HitColumn; + // Search to the left of the hit column for empty columns. + while (HitInfo.HitColumn > NoColumn) and ColumnIsEmpty(HitInfo.HitNode, HitInfo.HitColumn) do + begin + NextColumn := FHeader.FColumns.GetPreviousVisibleColumn(HitInfo.HitColumn); + if NextColumn = InvalidColumn then + Break; + HitInfo.HitColumn := NextColumn; + Dec(ColLeft, FHeader.FColumns[NextColumn].Width); + end; + // Search to the right of the hit column for empty columns. + repeat + InitialColumn := FHeader.FColumns.GetNextVisibleColumn(InitialColumn); + if (InitialColumn = InvalidColumn) or not ColumnIsEmpty(HitInfo.HitNode, InitialColumn) then + Break; + Inc(ColRight, FHeader.FColumns[InitialColumn].Width); + until False; + end; + // Make the X position and the right border relative to the start of the column. + Dec(X, ColLeft); + Dec(ColRight, ColLeft); + end + else + begin + HitInfo.HitColumn := NoColumn; + ColRight := Max(FRangeX, ClientWidth); + end; + ColLeft := 0; + + if HitInfo.HitColumn = InvalidColumn then + Include(HitInfo.HitPositions, hiNowhere) + else + begin + // From now on X is in "column" coordinates (relative to the left column border). + HitInfo.HitPositions := [hiOnItem]; + + // Avoid getting the display rect if this is not necessary. + if toNodeHeightResize in FOptions.FMiscOptions then + begin + NodeRect := GetDisplayRect(HitInfo.HitNode, HitInfo.HitColumn, False); + if Y <= (NodeRect.Top - FOffsetY + 1) then + Include(HitInfo.HitPositions, hiUpperSplitter) + else + if Y >= (NodeRect.Bottom - FOffsetY - 3) then + Include(HitInfo.HitPositions, hiLowerSplitter); + end; + + if HitInfo.HitColumn <= NoColumn then + begin + CurrentBidiMode := BidiMode; + CurrentAlignment := Alignment; + end + else + begin + CurrentBidiMode := FHeader.FColumns[HitInfo.HitColumn].BidiMode; + CurrentAlignment := FHeader.FColumns[HitInfo.HitColumn].Alignment; + end; + + if CurrentBidiMode = bdLeftToRight then + DetermineHitPositionLTR(HitInfo, X, ColRight, CurrentAlignment) + else + DetermineHitPositionRTL(HitInfo, X, ColRight, CurrentAlignment); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLast(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the very last node in the tree branch given by Node and initializes the nodes all the way down including the +// result. toChildrenAbove is optionally considered. By using Node = nil the very last node in the tree is returned. + +var + Next: PVirtualNode; + +begin + Result := GetLastChild(Node); + if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then + while Assigned(Result) do + begin + // Test if there is a next last child. If not keep the node from the last run. + // Otherwise use the next last child. + Next := GetLastChild(Result); + if Next = nil then + Break; + Result := Next; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastInitialized(Node: PVirtualNode = nil; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the very last initialized child node in the tree branch given by Node. + +begin + Result := GetLastNoInit(Node, ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + Result := GetPreviousInitialized(Result, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastNoInit(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the very last node in the tree branch given by Node without initialization. + +var + Next: PVirtualNode; + +begin + Result := GetLastChildNoInit(Node); + if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then + while Assigned(Result) do + begin + // Test if there is a next last child. If not keep the node from the last run. + // Otherwise use the next last child. + Next := GetLastChildNoInit(Result); + if Next = nil then + Break; + Result := Next; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastChild(Node: PVirtualNode): PVirtualNode; + +// Determines the last child of the given node and initializes it if there is one. + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.LastChild + else + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + if vsHasChildren in Node.States then + begin + if Node.ChildCount = 0 then + InitChildren(Node); + Result := Node.LastChild; + end + else + Result := nil; + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastChildNoInit(Node: PVirtualNode): PVirtualNode; + +// Determines the last child of the given node but does not initialize it. + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.LastChild + else + begin + if vsHasChildren in Node.States then + Result := Node.LastChild + else + Result := nil; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastVisible(Node: PVirtualNode = nil; ConsiderChildrenAbove: Boolean = True; + IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the very last visible node in the tree while optionally considering toChildrenAbove. +// The nodes are intialized all the way down including the result node. + +var + Next: PVirtualNode; + +begin + Result := GetLastVisibleChild(Node, IncludeFiltered); + if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then + while Assigned(Result) do + begin + // Test if there is a next last visible child. If not keep the node from the last run. + // Otherwise use the next last visible child. + Next := GetLastVisibleChild(Result, IncludeFiltered); + if Next = nil then + Break; + Result := Next; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastVisibleChild(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Determines the last visible child of the given node and initializes it if necessary. + +begin + if (Node = nil) or (Node = FRoot) then + Result := GetLastChild(FRoot) + else + if FullyVisible[Node] and (vsExpanded in Node.States) then + Result := GetLastChild(Node) + else + Result := nil; + + if Assigned(Result) and (not (vsVisible in Result.States) or + (not IncludeFiltered and IsEffectivelyFiltered[Node])) then + Result := GetPreviousVisibleSibling(Result, IncludeFiltered); + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastVisibleChildNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Determines the last visible child of the given node without initialization. + +begin + if (Node = nil) or (Node = FRoot) then + Result := GetLastChildNoInit(FRoot) + else + if FullyVisible[Node] and (vsExpanded in Node.States) then + Result := GetLastChildNoInit(Node) + else + Result := nil; + + if Assigned(Result) and (not (vsVisible in Result.States) or + (not IncludeFiltered and IsEffectivelyFiltered[Node])) then + Result := GetPreviousVisibleSiblingNoInit(Result, IncludeFiltered); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetLastVisibleNoInit(Node: PVirtualNode = nil; + ConsiderChildrenAbove: Boolean = True; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the very last visible node in the tree while optionally considering toChildrenAbove. +// No initialization is performed. + +var + Next: PVirtualNode; + +begin + Result := GetLastVisibleChildNoInit(Node, IncludeFiltered); + if not ConsiderChildrenAbove or not (toChildrenAbove in FOptions.FPaintOptions) then + while Assigned(Result) do + begin + // Test if there is a next last visible child. If not keep the node from the last run. + // Otherwise use the next last visible child. + Next := GetLastVisibleChildNoInit(Result, IncludeFiltered); + if Next = nil then + Break; + Result := Next; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetMaxColumnWidth(Column: TColumnIndex; UseSmartColumnWidth: Boolean = False): Integer; + +// This method determines the width of the largest node in the given column. +// If UseSmartColumnWidth is True then only the visible nodes which are in view will be considered +// Note: If UseSmartColumnWidth is False then every visible node in the tree will be initialized contradicting so +// the virtual paradigm. + +var + Run, + LastNode, + NextNode: PVirtualNode; + NodeLeft, + TextLeft, + CurrentWidth: Integer; + WithCheck, + WithImages, + WithStateImages: Boolean; + CheckOffset, + ImageOffset, + StateImageOffset: Integer; + +begin + if OperationCanceled then + begin + // Behave non-destructive. + Result := FHeader.FColumns[Column].Width; + Exit; + end + else + Result := 0; + + StartOperation(okGetMaxColumnWidth); + try + if Assigned(FOnBeforeGetMaxColumnWidth) then + FOnBeforeGetMaxColumnWidth(FHeader, Column, UseSmartColumnWidth); + + // Don't check the event here as descendant trees might have overriden the DoGetImageIndex method. + WithImages := Assigned(FImages); + if WithImages then + ImageOffset := FImages.Width + 2 + else + ImageOffset := 0; + WithStateImages := Assigned(FStateImages); + if WithStateImages then + StateImageOffset := FStateImages.Width + 2 + else + StateImageOffset := 0; + if Assigned(FCheckImages) then + CheckOffset := FCheckImages.Width + 2 + else + CheckOffset := 0; + + if UseSmartColumnWidth then // Get first visible node which is in view. + Run := GetTopNode + else + Run := GetFirstVisible(nil, True); + + if Column = FHeader.MainColumn then + begin + if toFixedIndent in FOptions.FPaintOptions then + NodeLeft := FIndent + else + begin + if toShowRoot in FOptions.FPaintOptions then + NodeLeft := Integer((GetNodeLevel(Run) + 1) * FIndent) + else + NodeLeft := Integer(GetNodeLevel(Run) * FIndent); + end; + + WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); + end + else + begin + NodeLeft := 0; + WithCheck := False; + end; + + // Consider node margin at the left of the nodes. + Inc(NodeLeft, FMargin); + + // Decide where to stop. + if UseSmartColumnWidth then + LastNode := GetNextVisible(BottomNode) + else + LastNode := nil; + + while Assigned(Run) and not OperationCanceled do + begin + TextLeft := NodeLeft; + if WithCheck and (Run.CheckType <> ctNone) then + Inc(TextLeft, CheckOffset); + if WithImages and HasImage(Run, ikNormal, Column) then + Inc(TextLeft, ImageOffset); + if WithStateImages and HasImage(Run, ikState, Column) then + Inc(TextLeft, StateImageOffset); + + CurrentWidth := DoGetNodeWidth(Run, Column); + Inc(CurrentWidth, DoGetCellContentMargin(Run, Column).X); + + if Result < (TextLeft + CurrentWidth) then + Result := TextLeft + CurrentWidth; + + // Get next visible node and update left node position if needed. + NextNode := GetNextVisible(Run, True); + if NextNode = LastNode then + Break; + if (Column = Header.MainColumn) and not (toFixedIndent in FOptions.FPaintOptions) then + Inc(NodeLeft, CountLevelDifference(Run, NextNode) * Integer(FIndent)); + Run := NextNode; + end; + if toShowVertGridLines in FOptions.FPaintOptions then + Inc(Result); + + if Assigned(FOnAfterGetMaxColumnWidth) then + FOnAfterGetMaxColumnWidth(FHeader, Column, Result); + + finally + EndOperation(okGetMaxColumnWidth); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNext(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns next node in tree while optionally considering toChildrenAbove. The Result will be initialized if needed. + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + // If this node has no siblings use the parent. + if not Assigned(Result.NextSibling) then + begin + Result := Result.Parent; + if Result = FRoot then + begin + Result := nil; + end; + end + else + begin + // There is at least one sibling so take it. + Result := Result.NextSibling; + + // Has this node got children? Initialize them if necessary. + if (vsHasChildren in Result.States) and (Result.ChildCount = 0) then + InitChildren(Result); + + // Now take a look at the children. + while Assigned(Result.FirstChild) do + begin + Result := Result.FirstChild; + if (vsHasChildren in Result.States) and (Result.ChildCount = 0) then + InitChildren(Result); + end; + end; + end + else + begin + // Has this node got children? + if vsHasChildren in Result.States then + begin + // Yes, there are child nodes. Initialize them if necessary. + if Result.ChildCount = 0 then + InitChildren(Result); + end; + + // if there is no child node try siblings + if Assigned(Result.FirstChild) then + Result := Result.FirstChild + else + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +begin + if (Node = nil) or (Node = FRoot) then + Result := GetFirstNoInit(ConsiderChildrenAbove) + else + Result := GetNextNoInit(Node, ConsiderChildrenAbove); + + while Assigned(Result) and (Result.CheckState <> State) do + Result := GetNextNoInit(Result, ConsiderChildrenAbove); + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextChecked(Node: PVirtualNode; ConsiderChildrenAbove: Boolean): PVirtualNode; +begin + Result := Self.GetNextChecked(Node, csCheckedNormal, ConsiderChildrenAbove); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextCutCopy(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the next node in the tree which is currently marked for a clipboard operation. Since only visible nodes can +// be marked (or they are hidden after they have been marked) it is not necessary to initialize nodes to check for +// child nodes. The result, however, is initialized if necessary. + +begin + if ClipboardStates * FStates <> [] then + begin + if (Node = nil) or (Node = FRoot) then + Result := GetFirstNoInit(ConsiderChildrenAbove) + else + Result := GetNextNoInit(Node, ConsiderChildrenAbove); + while Assigned(Result) and not (vsCutOrCopy in Result.States) do + Result := GetNextNoInit(Result, ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextInitialized(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the next node in tree which is initialized. + +begin + Result := Node; + repeat + Result := GetNextNoInit(Result, ConsiderChildrenAbove); + until (Result = nil) or (vsInitialized in Result.States); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextLeaf(Node: PVirtualNode): PVirtualNode; + +// Returns the next node in the tree which has currently no children. +// The result is initialized if necessary. + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.FirstChild + else + Result := GetNext(Node); + while Assigned(Result) and (vsHasChildren in Result.States) do + Result := GetNext(Result); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextLevel(Node: PVirtualNode; NodeLevel: Cardinal): PVirtualNode; + +// Returns the next node in the tree on a specific level. +// The result is initialized if necessary. + +var + StartNodeLevel: Cardinal; + +begin + Result := nil; + + if Assigned(Node) and (Node <> FRoot) then + begin + StartNodeLevel := GetNodeLevel(Node); + + if StartNodeLevel < NodeLevel then + begin + Result := GetNext(Node); + if Assigned(Result) and (GetNodeLevel(Result) <> NodeLevel) then + Result := GetNextLevel(Result, NodeLevel); + end + else + if StartNodeLevel = NodeLevel then + begin + Result := Node.NextSibling; + if not Assigned(Result) then // i.e. start node was a last sibling + begin + Result := Node.Parent; + if Assigned(Result) then + begin + // go to next anchestor of the start node which has a next sibling (if exists) + while Assigned(Result) and not Assigned(Result.NextSibling) do + Result := Result.Parent; + if Assigned(Result) then + Result := GetNextLevel(Result.NextSibling, NodeLevel); + end; + end; + end + else + // i.e. StartNodeLevel > NodeLevel + Result := GetNextLevel(Node.Parent, NodeLevel); + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean): PVirtualNode; + +// Optimized version of GetNext performing no initialization, but optionally considering toChildrenAbove. + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + // If this node has no siblings use the parent. + if not Assigned(Result.NextSibling) then + begin + Result := Result.Parent; + if Result = FRoot then + begin + Result := nil; + end; + end + else + begin + // There is at least one sibling so take it. + Result := Result.NextSibling; + + // Now take a look at the children. + while Assigned(Result.FirstChild) do + begin + Result := Result.FirstChild; + end; + end; + end + else + begin + // If there is no child node try siblings. + if Assigned(Result.FirstChild) then + Result := Result.FirstChild + else + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextSelected(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the next node in the tree which is currently selected. Since children of unitialized nodes cannot be +// in the current selection (because they simply do not exist yet) it is not necessary to initialize nodes here. +// The result however is initialized if necessary. + +begin + if FSelectionCount > 0 then + begin + if (Node = nil) or (Node = FRoot) then + Result := GetFirstNoInit(ConsiderChildrenAbove) + else + Result := GetNextNoInit(Node, ConsiderChildrenAbove); + while Assigned(Result) and not (vsSelected in Result.States) do + Result := GetNextNoInit(Result, ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextSibling(Node: PVirtualNode): PVirtualNode; + +// Returns the next sibling of Node and initializes it if necessary. + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + Result := Result.NextSibling; + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + +// Returns next node in tree, with regard to Node, which is visible. +// Nodes which need an initialization (including the result) are initialized. +// toChildrenAbove is optionally considered which is the default here. + +var + ForceSearch: Boolean; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + repeat + // If the given node is not visible then look for a parent node which is visible, otherwise we will + // likely go unnecessarily through a whole bunch of invisible nodes. + if not FullyVisible[Result] then + Result := GetVisibleParent(Result, True); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + // If there a no siblings anymore, go up one level. + if not Assigned(Result.NextSibling) then + begin + Result := Result.Parent; + if Result = FRoot then + begin + Result := nil; + Break; + end; + + if not (vsInitialized in Result.States) then + InitNode(Result); + if vsVisible in Result.States then + Break; + end + else + begin + // There is at least one sibling so take it. + Result := Result.NextSibling; + if not (vsInitialized in Result.States) then + InitNode(Result); + if not (vsVisible in Result.States) then + Continue; + + // Now take a look at the children. + // As the children are initialized while toggling, we don't need to do this here. + while (vsExpanded in Result.States) and Assigned(Result.FirstChild) do + begin + Result := Result.FirstChild; + if not (vsInitialized in Result.States) then + InitNode(Result); + if not (vsVisible in Result.States) then + Break; + end; + + // If we found a visible node we don't need to search any longer. + if vsVisible in Result.States then + Break; + end; + until False; + end + else + begin + // Has this node got children? + if [vsHasChildren, vsExpanded] * Result.States = [vsHasChildren, vsExpanded] then + begin + // Yes, there are child nodes. Initialize them if necessary. + if Result.ChildCount = 0 then + InitChildren(Result); + end; + + // Child nodes are the first choice if possible. + if (vsExpanded in Result.States) and Assigned(Result.FirstChild) then + begin + Result := GetFirstChild(Result); + ForceSearch := False; + end + else + ForceSearch := True; + + // If there are no children or the first child is not visible then search the sibling nodes or traverse parents. + if Assigned(Result) and (ForceSearch or not (vsVisible in Result.States)) then + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + if not (vsInitialized in Result.States) then + InitNode(Result); + if vsVisible in Result.States then + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + until not Assigned(Result) or IsEffectivelyVisible[Result]; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextVisibleNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + +// Returns the next node in tree, with regard to Node, which is visible. +// toChildrenAbove is optionally considered (which is the default). No initialization is done. + +var + ForceSearch: Boolean; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + repeat + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + // If there a no siblings anymore, go up one level. + if not Assigned(Result.NextSibling) then + begin + Result := Result.Parent; + if Result = FRoot then + begin + Result := nil; + Break; + end; + if vsVisible in Result.States then + Break; + end + else + begin + // There is at least one sibling so take it. + Result := Result.NextSibling; + if not (vsVisible in Result.States) then + Continue; + + // Now take a look at the children. + while (vsExpanded in Result.States) and Assigned(Result.FirstChild) do + begin + Result := Result.FirstChild; + if not (vsVisible in Result.States) then + Break; + end; + + // If we found a visible node we don't need to search any longer. + if vsVisible in Result.States then + Break; + end; + until False; + end + else + begin + // If the given node is not visible then look for a parent node which is visible, otherwise we will + // likely go unnecessarily through a whole bunch of invisible nodes. + if not FullyVisible[Result] then + Result := GetVisibleParent(Result, True); + + // Child nodes are the first choice if possible. + if (vsExpanded in Result.States) and Assigned(Result.FirstChild) then + begin + Result := Result.FirstChild; + ForceSearch := False; + end + else + ForceSearch := True; + + // If there are no children or the first child is not visible then search the sibling nodes or traverse parents. + if ForceSearch or not (vsVisible in Result.States) then + begin + repeat + // Is there a next sibling? + if Assigned(Result.NextSibling) then + begin + Result := Result.NextSibling; + if vsVisible in Result.States then + Break; + end + else + begin + // No sibling anymore, so use the parent's next sibling. + if Result.Parent <> FRoot then + Result := Result.Parent + else + begin + // There are no further nodes to examine, hence there is no further visible node. + Result := nil; + Break; + end; + end; + until False; + end; + end; + until not Assigned(Result) or IsEffectivelyVisible[Result]; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextVisibleSibling(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the next visible sibling after Node. Initialization is done implicitly. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + Result := Node; + repeat + Result := GetNextSibling(Result); + until not Assigned(Result) or ((vsVisible in Result.States) and + (IncludeFiltered or not IsEffectivelyFiltered[Result])); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNextVisibleSiblingNoInit(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the next visible sibling after Node. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + Result := Node; + repeat + Result := Result.NextSibling; + until not Assigned(Result) or ((vsVisible in Result.States) and + (IncludeFiltered or not IsEffectivelyFiltered[Result])); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeAt(X, Y: Integer): PVirtualNode; + +// Overloaded variant of GetNodeAt to easy life of application developers which do not need to have the exact +// top position returned and always use client coordinates. + +var + Dummy: Integer; + +begin + Result := GetNodeAt(X, Y, True, Dummy); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeAt(X, Y: Integer; Relative: Boolean; var NodeTop: Integer): PVirtualNode; + +// This method returns the node that occupies the specified point, or nil if there's none. +// If Releative is True then X and Y are given in client coordinates otherwise they are considered as being +// absolute values into the virtual tree image (regardless of the current offsets in the tree window). +// NodeTop gets the absolute or relative top position of the node returned or is untouched if no node +// could be found. + +var + AbsolutePos, + CurrentPos: Cardinal; + +begin + if Y < 0 then + Y := 0; + + AbsolutePos := Y; + if Relative then + Inc(AbsolutePos, -FOffsetY); + + // CurrentPos tracks a running term of the current position to test for. + // It corresponds always to the top position of the currently considered node. + CurrentPos := 0; + + // If the cache is available then use it. + if tsUseCache in FStates then + Result := FindInPositionCache(AbsolutePos, CurrentPos) + else + Result := GetFirstVisibleNoInit(nil, True); + + // Determine node, of which position and height corresponds to the scroll position most closely. + while Assigned(Result) and (Result <> FRoot) do + begin + if AbsolutePos < (CurrentPos + NodeHeight[Result]) then + Break; + Inc(CurrentPos, NodeHeight[Result]); + Result := GetNextVisibleNoInit(Result, True); + end; + + if Result = FRoot then + Result := nil; + + // Since the given vertical position is likely not the same as the top position + // of the found node this top position is returned. + if Assigned(Result) then + begin + NodeTop := CurrentPos; + if Relative then + Inc(NodeTop, FOffsetY); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeData(Node: PVirtualNode): Pointer; + +// Returns the address of the user defined data area in the node. + +begin + Assert(FNodeDataSize > 0, 'NodeDataSize not initialized.'); + + if (FNodeDataSize <= 0) or (Node = nil) or (Node = FRoot) then + Result := nil + else + Result := PByte(@Node.Data) + FTotalInternalDataSize; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetNodeLevel(Node: PVirtualNode): Cardinal; + +// returns the level of the given node + +var + Run: PVirtualNode; + +begin + Result := 0; + if Assigned(Node) and (Node <> FRoot) then + begin + Run := Node.Parent; + while Run <> FRoot do + begin + Run := Run.Parent; + Inc(Result); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPrevious(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns previous node in tree. If ConsiderChildrenAbove is True the function considers +// whether toChildrenAbove is currently set, otherwise the result will always be the previous +// node in top-down order regardless of the current PaintOptions. +// The Result will be initialized if needed. + +var + Run: PVirtualNode; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + // Has this node got children? Initialize them if necessary. + if (vsHasChildren in Result.States) and (Result.ChildCount = 0) then + InitChildren(Result); + + // If there is a last child, take it; if not try the previous sibling. + if Assigned(Result.LastChild) then + Result := Result.LastChild + else + if Assigned(Result.PrevSibling) then + Result := Result.PrevSibling + else + begin + // If neither a last child nor a previous sibling exist, go the tree upwards and + // look, wether one of the parent nodes have a previous sibling. If not the result + // will ne nil. + repeat + Result := Result.Parent; + Run := nil; + if Result <> FRoot then + Run := Result.PrevSibling + else + Result := nil; + until Assigned(Run) or (Result = nil); + + if Assigned(Run) then + Result := Run; + end; + end + else + begin + // Is there a previous sibling? + if Assigned(Node.PrevSibling) then + begin + // Go down and find the last child node. + Result := GetLast(Node.PrevSibling); + if Result = nil then + Result := Node.PrevSibling; + end + else + // no previous sibling so the parent of the node is the previous visible node + if Node.Parent <> FRoot then + Result := Node.Parent + else + Result := nil; + end; + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousChecked(Node: PVirtualNode; State: TCheckState = csCheckedNormal; + ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +begin + if (Node = nil) or (Node = FRoot) then + Result := GetLastNoInit(nil, ConsiderChildrenAbove) + else + Result := GetPreviousNoInit(Node, ConsiderChildrenAbove); + + while Assigned(Result) and (Result.CheckState <> State) do + Result := GetPreviousNoInit(Result, ConsiderChildrenAbove); + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousCutCopy(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the previous node in the tree which is currently marked for a clipboard operation. Since only visible nodes can +// be marked (or they are hidden after they have been marked) it is not necessary to initialize nodes to check for +// child nodes. The result, however, is initialized if necessary. + +begin + if ClipboardStates * FStates <> [] then + begin + if (Node = nil) or (Node = FRoot) then + Result := GetLastNoInit(nil, ConsiderChildrenAbove) + else + Result := GetPreviousNoInit(Node, ConsiderChildrenAbove); + while Assigned(Result) and not (vsCutOrCopy in Result.States) do + Result := GetPreviousNoInit(Result, ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousInitialized(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the previous node in tree which is initialized. + +begin + Result := Node; + repeat + Result := GetPreviousNoInit(Result, ConsiderChildrenAbove); + until (Result = nil) or (vsInitialized in Result.States); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousLeaf(Node: PVirtualNode): PVirtualNode; + +// Returns the previous node in the tree which has currently no children. +// The result is initialized if necessary. + +begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.LastChild + else + Result := GetPrevious(Node); + while Assigned(Result) and (vsHasChildren in Result.States) do + Result := GetPrevious(Result); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousLevel(Node: PVirtualNode; NodeLevel: Cardinal): PVirtualNode; + +// Returns the previous node in the tree on a specific level. +// The result is initialized if necessary. + +var + StartNodeLevel: Cardinal; + Run: PVirtualNode; + +begin + Result := nil; + + if Assigned(Node) and (Node <> FRoot) then + begin + StartNodeLevel := GetNodeLevel(Node); + + if StartNodeLevel < NodeLevel then + begin + Result := Node.PrevSibling; + if Assigned(Result) then + begin + // go to last descendant of previous sibling with desired node level (if exists) + Run := Result; + while Assigned(Run) and (GetNodeLevel(Run) < NodeLevel) do + begin + Result := Run; + Run := GetLastChild(Run); + end; + if Assigned(Run) and (GetNodeLevel(Run) = NodeLevel) then + Result := Run + else + begin + if Assigned(Result.PrevSibling) then + Result := GetPreviousLevel(Result, NodeLevel) + else + if Assigned(Result) and (Result.Parent <> FRoot) then + Result := GetPreviousLevel(Result.Parent, NodeLevel) + else + Result := nil; + end; + end + else + Result := GetPreviousLevel(Node.Parent, NodeLevel); + end + else + if StartNodeLevel = NodeLevel then + begin + Result := Node.PrevSibling; + if not Assigned(Result) then // i.e. start node was a first sibling + begin + Result := Node.Parent; + if Assigned(Result) then + Result := GetPreviousLevel(Result, NodeLevel); + end; + end + else // i.e. StartNodeLevel > NodeLevel + Result := GetPreviousLevel(Node.Parent, NodeLevel); + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousNoInit(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns previous node in tree, optionally considering toChildrenAbove. No initialization is performed. + +var + Run: PVirtualNode; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + // If there is a last child, take it; if not try the previous sibling. + if Assigned(Result.LastChild) then + Result := Result.LastChild + else + if Assigned(Result.PrevSibling) then + Result := Result.PrevSibling + else + begin + // If neither a last child nor a previous sibling exist, go the tree upwards and + // look, wether one of the parent nodes have a previous sibling. If not the result + // will ne nil. + repeat + Result := Result.Parent; + Run := nil; + if Result <> FRoot then + Run := Result.PrevSibling + else + Result := nil; + until Assigned(Run) or (Result = nil); + + if Assigned(Run) then + Result := Run; + end; + end + else + begin + // Is there a previous sibling? + if Assigned(Node.PrevSibling) then + begin + // Go down and find the last child node. + Result := GetLastNoInit(Node.PrevSibling); + if Result = nil then + Result := Node.PrevSibling; + end + else + // No previous sibling so the parent of the node is the previous node. + if Node.Parent <> FRoot then + Result := Node.Parent + else + Result := nil + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousSelected(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = False): PVirtualNode; + +// Returns the previous node in the tree which is currently selected. Since children of unitialized nodes cannot be +// in the current selection (because they simply do not exist yet) it is not necessary to initialize nodes here. +// The result however is initialized if necessary. + +begin + if FSelectionCount > 0 then + begin + if (Node = nil) or (Node = FRoot) then + Result := FRoot.LastChild + else + Result := GetPreviousNoInit(Node, ConsiderChildrenAbove); + while Assigned(Result) and not (vsSelected in Result.States) do + Result := GetPreviousNoInit(Result, ConsiderChildrenAbove); + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousSibling(Node: PVirtualNode): PVirtualNode; + +// Get next sibling of Node, initialize it if necessary. + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + Result := Result.PrevSibling; + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousVisible(Node: PVirtualNode; ConsiderChildrenAbove: Boolean = True): PVirtualNode; + +// Returns the previous node in tree, with regard to Node, which is visible. +// Nodes which need an initialization (including the result) are initialized. +// toChildrenAbove is optionally considered which is the default here. + +var + Marker: PVirtualNode; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + repeat + // If the given node is not visible then look for a parent node which is visible and use its last visible + // child or the parent node (if there is no visible child) as result. + if not FullyVisible[Result] then + begin + Result := GetVisibleParent(Result, True); + if Result = FRoot then + Result := nil; + Marker := GetLastVisible(Result, True); + if Assigned(Marker) then + Result := Marker; + end + else + begin + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + if Assigned(Result.LastChild) and (vsExpanded in Result.States) then + begin + Result := Result.LastChild; + if not (vsInitialized in Result.States) then + InitNode(Result); + + if vsVisible in Result.States then + Break; + end + else + if Assigned(Result.PrevSibling) then + begin + if not (vsInitialized in Result.PrevSibling.States) then + InitNode(Result.PrevSibling); + + if vsVisible in Result.PrevSibling.States then + begin + Result := Result.PrevSibling; + Break; + end; + end + else + begin + Marker := nil; + repeat + Result := Result.Parent; + if Result <> FRoot then + Marker := GetPreviousVisibleSibling(Result, True) + else + Result := nil; + until Assigned(Marker) or (Result = nil); + if Assigned(Marker) then + Result := Marker; + + Break; + end; + until False; + end + else + begin + repeat + // Is there a previous sibling node? + if Assigned(Result.PrevSibling) then + begin + Result := Result.PrevSibling; + // Initialize the new node and check its visibility. + if not (vsInitialized in Result.States) then + InitNode(Result); + if vsVisible in Result.States then + begin + // If there are visible child nodes then use the last one. + Marker := GetLastVisible(Result, True, True); + if Assigned(Marker) then + Result := Marker; + Break; + end; + end + else + begin + // No previous sibling there so the parent node is the nearest previous node. + Result := Result.Parent; + if Result = FRoot then + Result := nil; + Break; + end; + until False; + end; + + if Assigned(Result) and not (vsInitialized in Result.States) then + InitNode(Result); + end; + until not Assigned(Result) or IsEffectivelyVisible[Result]; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousVisibleNoInit(Node: PVirtualNode; + ConsiderChildrenAbove: Boolean = True): PVirtualNode; + +// Returns the previous node in tree, with regard to Node, which is visible. +// toChildrenAbove is optionally considered which is the default here. + +var + Marker: PVirtualNode; + +begin + Result := Node; + if Assigned(Result) then + begin + Assert(Result <> FRoot, 'Node must not be the hidden root node.'); + + repeat + // If the given node is not visible then look for a parent node which is visible and use its last visible + // child or the parent node (if there is no visible child) as result. + if not FullyVisible[Result] then + begin + Result := GetVisibleParent(Result, True); + if Result = FRoot then + Result := nil; + Marker := GetLastVisibleNoInit(Result, True); + if Assigned(Marker) then + Result := Marker; + end + else + begin + if ConsiderChildrenAbove and (toChildrenAbove in FOptions.FPaintOptions) then + begin + repeat + // Is the current node expanded and has children? + if (vsExpanded in Result.States) and Assigned(Result.LastChild) then + begin + Result := Result.LastChild; + if vsVisible in Result.States then + Break; + end + else + if Assigned(Result.PrevSibling) then + begin + // No children anymore, so take the previous sibling. + if vsVisible in Result.PrevSibling.States then + begin + Result := Result.PrevSibling; + Break; + end; + end + else + begin + // No children and no previous siblings, so walk up the tree and look wether + // a parent has a previous visible sibling. If that is the case take it, + // otherwise there is no previous visible node. + Marker := nil; + repeat + Result := Result.Parent; + if Result <> FRoot then + Marker := GetPreviousVisibleSiblingNoInit(Result, True) + else + Result := nil; + until Assigned(Marker) or (Result = nil); + if Assigned(Marker) then + Result := Marker; + Break; + end; + until False; + end + else + begin + repeat + // Is there a previous sibling node? + if Assigned(Result.PrevSibling) then + begin + Result := Result.PrevSibling; + if vsVisible in Result.States then + begin + // If there are visible child nodes then use the last one. + Marker := GetLastVisibleNoInit(Result, True, True); + if Assigned(Marker) then + Result := Marker; + Break; + end; + end + else + begin + // No previous sibling there so the parent node is the nearest previous node. + Result := Result.Parent; + if Result = FRoot then + Result := nil; + Break; + end; + until False; + end; + end; + until not Assigned(Result) or IsEffectivelyVisible[Result]; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousVisibleSibling(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the previous visible sibling before Node. Initialization is done implicitly. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + Result := Node; + repeat + Result := GetPreviousSibling(Result); + until not Assigned(Result) or ((vsVisible in Result.States) and + (IncludeFiltered or not IsEffectivelyFiltered[Result])); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetPreviousVisibleSiblingNoInit(Node: PVirtualNode; + IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the previous visible sibling before Node. + +begin + Assert(Assigned(Node) and (Node <> FRoot), 'Invalid parameter.'); + + Result := Node; + repeat + Result := Result.PrevSibling; + until not Assigned(Result) or ((vsVisible in Result.States) and + (IncludeFiltered or not IsEffectivelyFiltered[Result])); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.Nodes(ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for all nodes + +begin + Result.FMode := vneAll; + Result.FTree := Self; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CheckedNodes(State: TCheckState; ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for all checked nodes + +begin + Result.FMode := vneChecked; + Result.FTree := Self; + Result.FState := State; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ChildNodes(Node: PVirtualNode): TVTVirtualNodeEnumeration; + +// Enumeration for child nodes + +begin + Result.FMode := vneChild; + Result.FTree := Self; + Result.FNode := Node; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.CutCopyNodes(ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for cut copy node + +begin + Result.FMode := vneCutCopy; + Result.FTree := Self; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InitializedNodes(ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for initialized nodes + +begin + Result.FMode := vneInitialized; + Result.FTree := Self; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.LeafNodes: TVTVirtualNodeEnumeration; + +// Enumeration for leaf nodes + +begin + Result.FMode := vneLeaf; + Result.FTree := Self; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.LevelNodes(NodeLevel: Cardinal): TVTVirtualNodeEnumeration; + +// Enumeration for level nodes + +begin + Result.FMode := vneLevel; + Result.FTree := Self; + Result.FNodeLevel := NodeLevel; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.NoInitNodes(ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for no init nodes +begin + Result.FMode := vneNoInit; + Result.FTree := Self; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.SelectedNodes(ConsiderChildrenAbove: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for selected nodes + +begin + Result.FMode := vneSelected; + Result.FTree := Self; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.VisibleNodes(Node: PVirtualNode; ConsiderChildrenAbove: Boolean; + IncludeFiltered: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for visible nodes + +begin + Result.FMode := vneVisible; + Result.FTree := Self; + Result.FNode := Node; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; + Result.FIncludeFiltered := IncludeFiltered; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.VisibleChildNodes(Node: PVirtualNode; IncludeFiltered: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for visible child nodes + +begin + Result.FMode := vneVisibleChild; + Result.FTree := Self; + Result.FNode := Node; + Result.FIncludeFiltered := IncludeFiltered; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.VisibleChildNoInitNodes(Node: PVirtualNode; IncludeFiltered: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for visible child no init nodes + +begin + Result.FMode := vneVisibleNoInitChild; + Result.FTree := Self; + Result.FNode := Node; + Result.FIncludeFiltered := IncludeFiltered; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.VisibleNoInitNodes(Node: PVirtualNode; ConsiderChildrenAbove: Boolean; + IncludeFiltered: Boolean): TVTVirtualNodeEnumeration; + +// Enumeration for visible no init nodes + +begin + Result.FMode := vneVisibleNoInit; + Result.FTree := Self; + Result.FNode := Node; + Result.FConsiderChildrenAbove := ConsiderChildrenAbove; + Result.FIncludeFiltered := IncludeFiltered; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetSortedCutCopySet(Resolve: Boolean): TNodeArray; + +// Same as GetSortedSelection but with nodes marked as being part in the current cut/copy set (e.g. for clipboard). + +var + Run: PVirtualNode; + Counter: Cardinal; + + //--------------- local function -------------------------------------------- + + procedure IncludeThisNode(Node: PVirtualNode); + + // adds the given node to the result + + var + Len: Cardinal; + + begin + Len := Length(Result); + if Counter = Len then + begin + if Len < 100 then + Len := 100 + else + Len := Len + Len div 10; + SetLength(Result, Len); + end; + Result[Counter] := Node; + Inc(Counter); + end; + + //--------------- end local function ---------------------------------------- + +begin + Run := FRoot.FirstChild; + Counter := 0; + if Resolve then + begin + // Resolving is actually easy: just find the first cutted node in logical order + // and then never go deeper in level than this node as long as there's a sibling node. + // Restart the search for a cutted node (at any level) if there are no further siblings. + while Assigned(Run) do + begin + if vsCutOrCopy in Run.States then + begin + IncludeThisNode(Run); + if Assigned(Run.NextSibling) then + Run := Run.NextSibling + else + begin + // If there are no further siblings then go up one or more levels until a node is + // found or all nodes have been processed. Although we consider here only initialized + // nodes we don't need to make any special checks as only initialized nodes can also be selected. + repeat + Run := Run.Parent; + until (Run = FRoot) or Assigned(Run.NextSibling); + if Run = FRoot then + Break + else + Run := Run.NextSibling; + end; + end + else + Run := GetNextNoInit(Run); + end; + end + else + while Assigned(Run) do + begin + if vsCutOrCopy in Run.States then + IncludeThisNode(Run); + Run := GetNextNoInit(Run); + end; + + // set the resulting array to its real length + SetLength(Result, Counter); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetSortedSelection(Resolve: Boolean): TNodeArray; + +// Returns a list of selected nodes sorted in logical order, that is, as they appear in the tree. +// If Resolve is True then nodes which are children of other selected nodes are not put into the new array. +// This feature is in particuar important when doing drag'n drop as in this case all selected node plus their children +// need to be considered. A selected node which is child (grand child etc.) of another selected node is then +// automatically included and doesn't need to be explicitely mentioned in the returned selection array. +// +// Note: The caller is responsible for freeing the array. Allocation is done here. Usually, though, freeing the array +// doesn't need additional attention as it is automatically freed by Delphi when it gets out of scope. + +var + Run: PVirtualNode; + Counter: Cardinal; + +begin + SetLength(Result, FSelectionCount); + if FSelectionCount > 0 then + begin + Run := FRoot.FirstChild; + Counter := 0; + if Resolve then + begin + // Resolving is actually easy: just find the first selected node in logical order + // and then never go deeper in level than this node as long as there's a sibling node. + // Restart the search for a selected node (at any level) if there are no further siblings. + while Assigned(Run) do + begin + if vsSelected in Run.States then + begin + Result[Counter] := Run; + Inc(Counter); + if Assigned(Run.NextSibling) then + Run := Run.NextSibling + else + begin + // If there are no further siblings then go up one or more levels until a node is + // found or all nodes have been processed. Although we consider here only initialized + // nodes we don't need to make any special checks as only initialized nodes can also be selected. + repeat + Run := Run.Parent; + until (Run = FRoot) or Assigned(Run.NextSibling); + if Run = FRoot then + Break + else + Run := Run.NextSibling; + end; + end + else + Run := GetNextNoInit(Run); + end; + end + else + while Assigned(Run) do + begin + if vsSelected in Run.States then + begin + Result[Counter] := Run; + Inc(Counter); + end; + Run := GetNextNoInit(Run); + end; + + // Since we may have skipped some nodes the result array is likely to be smaller than the + // selection array, hence shorten the result to true length. + if Integer(Counter) < Length(Result) then + SetLength(Result, Counter); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; + var Text: UnicodeString); + +// Generic base method for editors, hint windows etc. to get some info about a node. + +begin + R := Rect(0, 0, 0, 0); + Text := ''; + AFont.Assign(Font); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetTreeRect: TRect; + +// Returns the true size of the tree in pixels. This size is at least ClientHeight x ClientWidth and depends on +// the expand state, header size etc. +// Note: if no columns are used then the width of the tree is determined by the largest node which is currently in the +// client area. This might however not be the largest node in the entire tree. + +begin + Result := Rect(0, 0, Max(FRangeX, ClientWidth), Max(FRangeY, ClientHeight)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.GetVisibleParent(Node: PVirtualNode; IncludeFiltered: Boolean = False): PVirtualNode; + +// Returns the first (nearest) parent node of Node which is visible. +// This method is one of the seldom cases where the hidden root node could be returned. + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + Assert(Node <> FRoot, 'Node must not be the hidden root node.'); + + Result := Node.Parent; + while (Result <> FRoot) and (not FullyVisible[Result] or (not IncludeFiltered and IsEffectivelyFiltered[Result])) do + Result := Result.Parent; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.HasAsParent(Node, PotentialParent: PVirtualNode): Boolean; + +// Determines whether Node has got PotentialParent as one of its parents. + +var + Run: PVirtualNode; + +begin + Result := Assigned(Node) and Assigned(PotentialParent) and (Node <> PotentialParent); + if Result then + begin + Run := Node; + while (Run <> FRoot) and (Run <> PotentialParent) do + Run := Run.Parent; + Result := Run = PotentialParent; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InsertNode(Node: PVirtualNode; Mode: TVTNodeAttachMode; UserData: Pointer = nil): PVirtualNode; + +// Adds a new node relative to Node. The final position is determined by Mode. +// UserData can be used to set the first 4 bytes of the user data area to an initial value which can be used +// in OnInitNode and will also cause to trigger the OnFreeNode event (if <> nil) even if the node is not yet +// "officially" initialized. +// InsertNode is a compatibility method and will implicitly validate the given node if the new node +// is to be added as child node. This is however against the virtual paradigm and hence I dissuade from its usage. + +var + NodeData: ^Pointer; + +begin + if Mode <> amNoWhere then + begin + CancelEditNode; + + if Node = nil then + Node := FRoot; + // we need a new node... + Result := MakeNewNode; + // avoid erronous attach modes + if Node = FRoot then + begin + case Mode of + amInsertBefore: + Mode := amAddChildFirst; + amInsertAfter: + Mode := amAddChildLast; + end; + end; + + // Validate given node in case the new node becomes its child. + if (Mode in [amAddChildFirst, amAddChildLast]) and not (vsInitialized in Node.States) then + InitNode(Node); + InternalConnectNode(Result, Node, Self, Mode); + + // Check if there is initial user data and there is also enough user data space allocated. + if Assigned(UserData) then + if FNodeDataSize >= 4 then + begin + NodeData := Pointer(PByte(@Result.Data) + FTotalInternalDataSize); + NodeData^ := UserData; + Include(Result.States, vsInitialUserData); + end + else + ShowError(SCannotSetUserData, hcTFCannotSetUserData); + + if FUpdateCount = 0 then + begin + // If auto sort is enabled then sort the node or its parent (depending on the insert mode). + if (toAutoSort in FOptions.FAutoOptions) and (FHeader.FSortColumn > InvalidColumn) then + case Mode of + amInsertBefore, + amInsertAfter: + // Here no initialization is necessary because *if* a node has already got children then it + // must also be initialized. + // Note: Node can never be FRoot at this point. + Sort(Node.Parent, FHeader.FSortColumn, FHeader.FSortDirection, True); + amAddChildFirst, + amAddChildLast: + Sort(Node, FHeader.FSortColumn, FHeader.FSortDirection, True); + end; + + UpdateScrollbars(True); + if Mode = amInsertBefore then + InvalidateToBottom(Result) + else + InvalidateToBottom(Node); + end; + StructureChange(Result, crNodeAdded); + end + else + Result := nil; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InvalidateChildren(Node: PVirtualNode; Recursive: Boolean); + +// Invalidates Node and its immediate children. +// If Recursive is True then all grandchildren are invalidated as well. +// The node itself is initialized if necessary and its child nodes are created (and initialized too if +// Recursive is True). + +var + Run: PVirtualNode; + +begin + if Assigned(Node) then + begin + if not (vsInitialized in Node.States) then + InitNode(Node); + InvalidateNode(Node); + if (vsHasChildren in Node.States) and (Node.ChildCount = 0) then + InitChildren(Node); + Run := Node.FirstChild; + end + else + Run := FRoot.FirstChild; + + while Assigned(Run) do + begin + InvalidateNode(Run); + if Recursive then + InvalidateChildren(Run, True); + Run := Run.NextSibling; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InvalidateColumn(Column: TColumnIndex); + +// Invalidates the client area part of a column. + +var + R: TRect; + +begin + if (FUpdateCount = 0) and HandleAllocated and FHeader.FColumns.IsValidColumn(Column) then + begin + R := ClientRect; + FHeader.Columns.GetColumnBounds(Column, R.Left, R.Right); + InvalidateRect(Handle, @R, False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.InvalidateNode(Node: PVirtualNode): TRect; + +// Initiates repaint of the given node and returns the just invalidated rectangle. + +begin + if (FUpdateCount = 0) and HandleAllocated then + begin + Result := GetDisplayRect(Node, NoColumn, False); + InvalidateRect(Handle, @Result, False); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InvalidateToBottom(Node: PVirtualNode); + +// Initiates repaint of client area starting at given node. If this node is not visible or not yet initialized +// then nothing happens. + +var + R: TRect; + +begin + if (FUpdateCount = 0) and HandleAllocated then + begin + if (Node = nil) or (Node = FRoot) then + Invalidate + else + if (vsInitialized in Node.States) and IsEffectivelyVisible[Node] then + begin + R := GetDisplayRect(Node, -1, False); + if R.Top < ClientHeight then + begin + if (toChildrenAbove in FOptions.FPaintOptions) and (vsExpanded in Node.States) then + Dec(R.Top, Node.TotalHeight + NodeHeight[Node]); + R.Bottom := ClientHeight; + InvalidateRect(Handle, @R, False); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.InvertSelection(VisibleOnly: Boolean); + +// Inverts the current selection (so nodes which are selected become unselected and vice versa). +// If VisibleOnly is True then only visible nodes are considered. + +var + Run: PVirtualNode; + NewSize: Integer; + NextFunction: TGetNextNodeProc; + TriggerChange: Boolean; + +begin + if not FSelectionLocked and (toMultiSelect in FOptions.FSelectionOptions) then + begin + Run := FRoot.FirstChild; + ClearTempCache; + if VisibleOnly then + NextFunction := GetNextVisibleNoInit + else + NextFunction := GetNextNoInit; + while Assigned(Run) do + begin + if vsSelected in Run.States then + InternalRemoveFromSelection(Run) + else + InternalCacheNode(Run); + Run := NextFunction(Run); + end; + + // do some housekeeping + // Need to trigger the OnChange event from here if nodes were only deleted but not added. + TriggerChange := False; + NewSize := PackArray(FSelection, FSelectionCount); + if NewSize > -1 then + begin + FSelectionCount := NewSize; + SetLength(FSelection, FSelectionCount); + TriggerChange := True; + end; + if FTempNodeCount > 0 then + begin + AddToSelection(FTempNodeCache, FTempNodeCount); + ClearTempCache; + TriggerChange := False; + end; + Invalidate; + if TriggerChange then + Change(nil); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.IsEditing: Boolean; + +begin + Result := tsEditing in FStates; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.IsMouseSelecting: Boolean; + +begin + Result := (tsDrawSelPending in FStates) or (tsDrawSelecting in FStates); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer; + Filter: TVirtualNodeStates = []; DoInit: Boolean = False; ChildNodesOnly: Boolean = False): PVirtualNode; + +// Iterates through the all children and grandchildren etc. of Node (or the entire tree if Node = nil) +// and calls for each node the provided callback method (which must not be empty). +// Filter determines which nodes to consider (an empty set denotes all nodes). +// If DoInit is True then nodes which aren't initialized yet will be initialized. +// Note: During execution of the callback the application can set Abort to True. In this case the iteration is stopped +// and the last accessed node (the one on which the callback set Abort to True) is returned to the caller. +// Otherwise (no abort) nil is returned. + +var + Stop: PVirtualNode; + Abort: Boolean; + GetNextNode: TGetNextNodeProc; + WasIterating: Boolean; + +begin + Assert(Node <> FRoot, 'Node must not be the hidden root node.'); + + WasIterating := tsIterating in FStates; + DoStateChange([tsIterating]); + try + // prepare function to be used when advancing + if DoInit then + GetNextNode := GetNext + else + GetNextNode := GetNextNoInit; + + Abort := False; + if Node = nil then + Stop := nil + else + begin + if not (vsInitialized in Node.States) and DoInit then + InitNode(Node); + + // The stopper does not need to be initialized since it is not taken into the enumeration. + Stop := Node.NextSibling; + if Stop = nil then + begin + Stop := Node; + repeat + Stop := Stop.Parent; + until (Stop = FRoot) or Assigned(Stop.NextSibling); + if Stop = FRoot then + Stop := nil + else + Stop := Stop.NextSibling; + end; + end; + + // Use first node if we start with the root. + if Node = nil then + Node := GetFirstNoInit; + + if Assigned(Node) then + begin + if not (vsInitialized in Node.States) and DoInit then + InitNode(Node); + + // Skip given node if only the child nodes are requested. + if ChildNodesOnly then + begin + if Node.ChildCount = 0 then + Node := nil + else + Node := GetNextNode(Node); + end; + + if Filter = [] then + begin + // unfiltered loop + while Assigned(Node) and (Node <> Stop) do + begin + Callback(Self, Node, Data, Abort); + if Abort then + Break; + Node := GetNextNode(Node); + end; + end + else + begin + // filtered loop + while Assigned(Node) and (Node <> Stop) do + begin + if Node.States * Filter = Filter then + Callback(Self, Node, Data, Abort); + if Abort then + Break; + Node := GetNextNode(Node) + end; + end; + end; + + if Abort then + Result := Node + else + Result := nil; + finally + if not WasIterating then + DoStateChange([], [tsIterating]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.LoadFromFile(const FileName: TFileName); + +var + FileStream: TFileStream; + +begin + FileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + LoadFromStream(FileStream); + finally + FileStream.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.LoadFromStream(Stream: TStream); + +// Clears the current content of the tree and loads a new structure from the given stream. + +var + ThisID: TMagicID; + Version, + Count: Cardinal; + Node: PVirtualNode; + +begin + if not (toReadOnly in FOptions.FMiscOptions) then + begin + Clear; + // Check first whether this is a stream we can read. + if Stream.Read(ThisID, SizeOf(TMagicID)) < SizeOf(TMagicID) then + ShowError(SStreamTooSmall, hcTFStreamTooSmall); + + if (ThisID[0] = MagicID[0]) and + (ThisID[1] = MagicID[1]) and + (ThisID[2] = MagicID[2]) and + (ThisID[5] = MagicID[5]) then + begin + Version := Word(ThisID[3]); + if Version <= VTTreeStreamVersion then + begin + BeginUpdate; + try + if Version < 2 then + Count := MaxInt + else + Stream.ReadBuffer(Count, SizeOf(Count)); + + while (Stream.Position < Stream.Size) and (Count > 0) do + begin + Dec(Count); + Node := MakeNewNode; + InternalConnectNode(Node, FRoot, Self, amAddChildLast); + InternalAddFromStream(Stream, Version, Node); + end; + DoNodeCopied(nil); + if Assigned(FOnLoadTree) then + FOnLoadTree(Self, Stream); + finally + EndUpdate; + end; + end + else + ShowError(SWrongStreamVersion, hcTFWrongStreamVersion); + end + else + ShowError(SWrongStreamFormat, hcTFWrongStreamFormat); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MeasureItemHeight(const Canvas: TCanvas; Node: PVirtualNode); + +// If the height of the given node has not yet been measured then do it now. + +var + NewNodeHeight: Integer; + +begin + if not (vsHeightMeasured in Node.States) then + begin + Include(Node.States, vsHeightMeasured); + NewNodeHeight := Node.NodeHeight; + DoMeasureItem(Canvas, Node, NewNodeHeight); + if NewNodeHeight <> Node.NodeHeight then + SetNodeHeight(Node, NewNodeHeight); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MoveTo(Node: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode; + ChildrenOnly: Boolean); + +// A simplified method to allow to move nodes to the root of another tree. + +begin + MoveTo(Node, Tree.FRoot, Mode, ChildrenOnly); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.MoveTo(Source, Target: PVirtualNode; Mode: TVTNodeAttachMode; ChildrenOnly: Boolean); + +// Moves the given node (and all its children) to Target. Source must belong to the tree instance which calls this +// MoveTo method. Mode determines how to connect Source to Target. +// This method might involve a change of the tree if Target belongs to a different tree than Source. + +var + TargetTree: TBaseVirtualTree; + Allowed: Boolean; + NewNode: PVirtualNode; + Stream: TMemoryStream; + +begin + Assert(TreeFromNode(Source) = Self, 'The source tree must contain the source node.'); + + // When moving nodes then source and target must not be the same node unless only the source's children are + // moved and they are inserted before or after the node itself. + Allowed := (Source <> Target) or ((Mode in [amInsertBefore, amInsertAfter]) and ChildrenOnly); + + if Allowed and (Mode <> amNoWhere) and Assigned(Source) and (Source <> FRoot) and + not (toReadOnly in FOptions.FMiscOptions) then + begin + // Assume that an empty destination means the root in this (the source) tree. + if Target = nil then + begin + TargetTree := Self; + Target := FRoot; + Mode := amAddChildFirst; + end + else + TargetTree := TreeFromNode(Target); + + if Target = TargetTree.FRoot then + begin + case Mode of + amInsertBefore: + Mode := amAddChildFirst; + amInsertAfter: + Mode := amAddChildLast; + end; + end; + + // Make sure the target node is initialized. + if not (vsInitialized in Target.States) then + TargetTree.InitNode(Target) + else + if (vsHasChildren in Target.States) and (Target.ChildCount = 0) then + TargetTree.InitChildren(Target); + + if TargetTree = Self then + begin + // Simple case: move node(s) within the same tree. + if Target = FRoot then + Allowed := DoNodeMoving(Source, nil) + else + Allowed := DoNodeMoving(Source, Target); + if Allowed then + begin + // Check first that Source is not added as new child to a target node which + // is already a child of Source. + // Consider the case Source and Target are the same node, but only child nodes are moved. + if (Source <> Target) and HasAsParent(Target, Source) then + ShowError(SWrongMoveError, hcTFWrongMoveError); + + if not ChildrenOnly then + begin + // Disconnect from old location. + InternalDisconnectNode(Source, True); + // Connect to new location. + InternalConnectNode(Source, Target, Self, Mode); + DoNodeMoved(Source); + end + else + begin + // Only child nodes should be moved. Insertion order depends on move mode. + if Mode = amAddChildFirst then + begin + Source := Source.LastChild; + while Assigned(Source) do + begin + NewNode := Source.PrevSibling; + // Disconnect from old location. + InternalDisconnectNode(Source, True, False); + // Connect to new location. + InternalConnectNode(Source, Target, Self, Mode); + DoNodeMoved(Source); + Source := NewNode; + end; + end + else + begin + Source := Source.FirstChild; + while Assigned(Source) do + begin + NewNode := Source.NextSibling; + // Disconnect from old location. + InternalDisconnectNode(Source, True, False); + // Connect to new location. + InternalConnectNode(Source, Target, Self, Mode); + DoNodeMoved(Source); + Source := NewNode; + end; + end; + end; + end; + end + else + begin + // Difficult case: move node(s) to another tree. + // In opposition to node copying we ask only once if moving is allowed because + // we cannot take back a move once done. + if Target = TargetTree.FRoot then + Allowed := DoNodeMoving(Source, nil) + else + Allowed := DoNodeMoving(Source, Target); + + if Allowed then + begin + Stream := TMemoryStream.Create; + try + // Write all nodes into a temporary stream depending on the ChildrenOnly flag. + if not ChildrenOnly then + WriteNode(Stream, Source) + else + begin + Source := Source.FirstChild; + while Assigned(Source) do + begin + WriteNode(Stream, Source); + Source := Source.NextSibling; + end; + end; + // Now load the serialized nodes into the target node (tree). + TargetTree.BeginUpdate; + try + Stream.Position := 0; + while Stream.Position < Stream.Size do + begin + NewNode := TargetTree.MakeNewNode; + InternalConnectNode(NewNode, Target, TargetTree, Mode); + TargetTree.InternalAddFromStream(Stream, VTTreeStreamVersion, NewNode); + DoNodeMoved(NewNode); + end; + finally + TargetTree.EndUpdate; + end; + finally + Stream.Free; + end; + // finally delete original nodes + BeginUpdate; + try + if ChildrenOnly then + DeleteChildren(Source) + else + DeleteNode(Source); + finally + EndUpdate; + end; + end; + end; + + InvalidateCache; + if (FUpdateCount = 0) and Allowed then + begin + ValidateCache; + UpdateScrollBars(True); + Invalidate; + if TargetTree <> Self then + TargetTree.Invalidate; + end; + StructureChange(Source, crNodeMoved); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PaintTree(TargetCanvas: TCanvas; Window: TRect; Target: TPoint; + PaintOptions: TVTInternalPaintOptions; PixelFormat: TPixelFormat); + +// This is the core paint routine of the tree. It is responsible for maintaining the paint cycles per node as well +// as coordinating drawing of the various parts of the tree image. +// TargetCanvas is the canvas to which to draw the tree image. This is usually the tree window itself but could well +// be a bitmap or printer canvas. +// Window determines which part of the entire tree image to draw. The full size of the virtual image is determined +// by GetTreeRect. +// Target is the position in TargetCanvas where to draw the tree part specified by Window. +// PaintOptions determines what of the tree to draw. For different tasks usually different parts need to be drawn, with +// a full image in the window, selected only nodes for a drag image etc. + +const + ImageKind: array[Boolean] of TVTImageKind = (ikNormal, ikSelected); + +var + DrawSelectionRect, + UseBackground, + ShowImages, + ShowStateImages, + ShowCheckImages, + UseColumns, + IsMainColumn: Boolean; + + VAlign, + IndentSize, + ButtonX, + ButtonY: Integer; + LineImage: TLineImage; + PaintInfo: TVTPaintInfo; // all necessary information about a node to pass to the paint routines + + R, // the area of an entire node in its local coordinate + TargetRect, // the area of a node (part) in the target canvas + SelectionRect, // ordered rectangle used for drawing the selection focus rect + ClipRect: TRect; // area to which the canvas will be clipped when painting a node's content + NextColumn: TColumnIndex; + BaseOffset: Integer; // top position of the top node to draw given in absolute tree coordinates + NodeBitmap: TBitmap; // small buffer to draw flicker free + MaximumRight, // maximum horizontal target position + MaximumBottom: Integer; // maximum vertical target position + SelectLevel: Integer; // > 0 if current node is selected or child/grandchild etc. of a selected node + FirstColumn: TColumnIndex; // index of first column which is at least partially visible in the given window + + SavedTargetDC: Integer; + PaintWidth: Integer; + CurrentNodeHeight: Integer; + +begin + if not (tsPainting in FStates) then + begin + DoStateChange([tsPainting]); + try + DoBeforePaint(TargetCanvas); + + if poUnbuffered in PaintOptions then + SavedTargetDC := SaveDC(TargetCanvas.Handle) + else + SavedTargetDC := 0; + + // Prepare paint info structure. + ZeroMemory(@PaintInfo, SizeOf(PaintInfo)); + + PaintWidth := Window.Right - Window.Left; + + if not (poUnbuffered in PaintOptions) then + begin + // Create small bitmaps and initialize default values. + // The bitmaps are used to paint one node at a time and to draw the result to the target (e.g. screen) in one step, + // to prevent flickering. + NodeBitmap := TBitmap.Create; + // For alpha blending we need the 32 bit pixel format. For other targets there might be a need for a certain + // pixel format (e.g. printing). + if MMXAvailable and ((FDrawSelectionMode = smBlendedRectangle) or (tsUseThemes in FStates) or + (toUseBlendedSelection in FOptions.PaintOptions)) then + NodeBitmap.PixelFormat := pf32Bit + else + NodeBitmap.PixelFormat := PixelFormat; + + NodeBitmap.Width := PaintWidth; + + // Make sure the buffer bitmap and target bitmap use the same transformation mode. + SetMapMode(NodeBitmap.Canvas.Handle, GetMapMode(TargetCanvas.Handle)); + PaintInfo.Canvas := NodeBitmap.Canvas; + end + else + begin + PaintInfo.Canvas := TargetCanvas; + NodeBitmap := nil; + end; + + // Lock the canvas to avoid that it gets freed on the way. + PaintInfo.Canvas.Lock; + try + // Prepare the current selection rectangle once. The corner points are absolute tree coordinates. + SelectionRect := OrderRect(FNewSelRect); + DrawSelectionRect := IsMouseSelecting and not IsRectEmpty(SelectionRect); + + // R represents an entire node (all columns), but is a bit unprecise when it comes to + // trees without any column defined, because FRangeX only represents the maximum width of all + // nodes in the client area (not all defined nodes). There might be, however, wider nodes somewhere. Without full + // validation I cannot better determine the width, though. By using at least the control's width it is ensured + // that the tree is fully displayed on screen. + R := Rect(0, 0, Max(FRangeX, ClientWidth), 0); + + // For quick checks some intermediate variables are used. + UseBackground := (toShowBackground in FOptions.FPaintOptions) and (FBackground.Graphic is TBitmap) and + (poBackground in PaintOptions); + ShowImages := Assigned(FImages); + ShowStateImages := Assigned(FStateImages); + ShowCheckImages := Assigned(FCheckImages) and (toCheckSupport in FOptions.FMiscOptions); + UseColumns := FHeader.UseColumns; + + // Adjust paint options to tree settings. Hide selection if told so or the tree is unfocused. + if (toAlwaysHideSelection in FOptions.FPaintOptions) or + (not Focused and (toHideSelection in FOptions.FPaintOptions)) then + Exclude(PaintOptions, poDrawSelection); + if toHideFocusRect in FOptions.FPaintOptions then + Exclude(PaintOptions, poDrawFocusRect); + + // Determine node to start drawing with. + BaseOffset := 0; + PaintInfo.Node := GetNodeAt(0, Window.Top, False, BaseOffset); + if PaintInfo.Node = nil then + BaseOffset := Window.Top; + + // Transform selection rectangle into node bitmap coordinates. + if DrawSelectionRect then + OffsetRect(SelectionRect, 0, -BaseOffset); + + // The target rectangle holds the coordinates of the exact area to blit in target canvas coordinates. + // It is usually smaller than an entire node and wanders while the paint loop advances. + MaximumRight := Target.X + (Window.Right - Window.Left); + MaximumBottom := Target.Y + (Window.Bottom - Window.Top); + + TargetRect := Rect(Target.X, Target.Y - (Window.Top - BaseOffset), MaximumRight, 0); + TargetRect.Bottom := TargetRect.Top; + + // This marker gets the index of the first column which is visible in the given window. + // This is needed for column based background colors. + FirstColumn := InvalidColumn; + + if Assigned(PaintInfo.Node) then + begin + ButtonX := Round((Integer(FIndent) - FPlusBM.Width) / 2); + + // ----- main node paint loop + while Assigned(PaintInfo.Node) do + begin + // Determine LineImage, SelectionLevel and IndentSize + SelectLevel := DetermineLineImageAndSelectLevel(PaintInfo.Node, LineImage); + IndentSize := Length(LineImage); + if not (toFixedIndent in FOptions.FPaintOptions) then + ButtonX := (IndentSize - 1) * Integer(FIndent) + Round((Integer(FIndent) - FPlusBM.Width) / 2); + + // Initialize node if not already done. + if not (vsInitialized in PaintInfo.Node.States) then + InitNode(PaintInfo.Node); + if (vsSelected in PaintInfo.Node.States) and not (toChildrenAbove in FOptions.FPaintOptions) then + Inc(SelectLevel); + + // Ensure the node's height is determined. + MeasureItemHeight(PaintInfo.Canvas, PaintInfo.Node); + + // Adjust the brush origin for dotted lines depending on the current source position. + // It is applied some lines later, as the canvas might get reallocated, when changing the node bitmap. + PaintInfo.BrushOrigin := Point(Window.Left and 1, BaseOffset and 1); + Inc(BaseOffset, PaintInfo.Node.NodeHeight); + + TargetRect.Bottom := TargetRect.Top + PaintInfo.Node.NodeHeight; + + // If poSelectedOnly is active then do the following stuff only for selected nodes or nodes + // which are children of selected nodes. + if (SelectLevel > 0) or not (poSelectedOnly in PaintOptions) then + begin + if not (poUnbuffered in PaintOptions) then + begin + // Adjust height of temporary node bitmap. + with NodeBitmap do + begin + if Height <> PaintInfo.Node.NodeHeight then + begin + // Avoid that the VCL copies the bitmap while changing its height. + Height := 0; + Height := PaintInfo.Node.NodeHeight; + SetCanvasOrigin(Canvas, Window.Left, 0); + end; + end; + end + else + begin + SetCanvasOrigin(PaintInfo.Canvas, -TargetRect.Left + Window.Left, -TargetRect.Top); + ClipCanvas(PaintInfo.Canvas, Rect(TargetRect.Left, TargetRect.Top, TargetRect.Right, + Min(TargetRect.Bottom, MaximumBottom))) + end; + + // Set the origin of the canvas' brush. This depends on the node heights. + with PaintInfo do + SetBrushOrigin(Canvas, BrushOrigin.X, BrushOrigin.Y); + + CurrentNodeHeight := PaintInfo.Node.NodeHeight; + R.Bottom := CurrentNodeHeight; + + CalculateVerticalAlignments(ShowImages, ShowStateImages, PaintInfo.Node, VAlign, ButtonY); + + // Let application decide whether the node should normally be drawn or by the application itself. + if not DoBeforeItemPaint(PaintInfo.Canvas, PaintInfo.Node, R) then + begin + // Init paint options for the background painting. + PaintInfo.PaintOptions := PaintOptions; + + // The node background can contain a single color, a bitmap or can be drawn by the application. + ClearNodeBackground(PaintInfo, UseBackground, True, Rect(Window.Left, TargetRect.Top, Window.Right, + TargetRect.Bottom)); + + // Prepare column, position and node clipping rectangle. + PaintInfo.CellRect := R; + if UseColumns then + InitializeFirstColumnValues(PaintInfo); + + // Now go through all visible columns (there's still one run if columns aren't used). + with FHeader.FColumns do + begin + while ((PaintInfo.Column > InvalidColumn) or not UseColumns) + and (PaintInfo.CellRect.Left < Window.Right) do + begin + if UseColumns then + begin + PaintInfo.Column := FPositionToIndex[PaintInfo.Position]; + if FirstColumn = InvalidColumn then + FirstColumn := PaintInfo.Column; + PaintInfo.BidiMode := Items[PaintInfo.Column].FBiDiMode; + PaintInfo.Alignment := Items[PaintInfo.Column].FAlignment; + end + else + begin + PaintInfo.Column := NoColumn; + PaintInfo.BidiMode := BidiMode; + PaintInfo.Alignment := FAlignment; + end; + + PaintInfo.PaintOptions := PaintOptions; + with PaintInfo do + begin + if (tsEditing in FStates) and (Node = FFocusedNode) and + ((Column = FEditColumn) or not UseColumns) then + Exclude(PaintOptions, poDrawSelection); + if not UseColumns or + ((vsSelected in Node.States) and (toFullRowSelect in FOptions.FSelectionOptions) and + (poDrawSelection in PaintOptions)) or + (coParentColor in Items[PaintInfo.Column].Options) then + Exclude(PaintOptions, poColumnColor); + end; + IsMainColumn := PaintInfo.Column = FHeader.MainColumn; + + // Consider bidi mode here. In RTL context means left alignment actually right alignment and vice versa. + if PaintInfo.BidiMode <> bdLeftToRight then + ChangeBiDiModeAlignment(PaintInfo.Alignment); + + // Paint the current cell if it is marked as being visible or columns aren't used and + // if this cell belongs to the main column if only the main column should be drawn. + if (not UseColumns or (coVisible in Items[PaintInfo.Column].FOptions)) and + (not (poMainOnly in PaintOptions) or IsMainColumn) then + begin + AdjustPaintCellRect(PaintInfo, NextColumn); + + // Paint the cell only if it is in the current window. + if PaintInfo.CellRect.Right > Window.Left then + begin + with PaintInfo do + begin + // Fill in remaining values in the paint info structure. + NodeWidth := DoGetNodeWidth(Node, Column, Canvas); + // Not the entire cell is covered by text. Hence we need a running rectangle to follow up. + ContentRect := CellRect; + // Set up the distance from column border (margin). + if BidiMode <> bdLeftToRight then + Dec(ContentRect.Right, FMargin) + else + Inc(ContentRect.Left, FMargin); + + if ShowCheckImages and IsMainColumn then + begin + ImageInfo[iiCheck].Index := GetCheckImage(Node); + if ImageInfo[iiCheck].Index > -1 then + begin + AdjustImageBorder(FCheckImages, BidiMode, VAlign, ContentRect, ImageInfo[iiCheck]); + ImageInfo[iiCheck].Ghosted := False; + end; + end + else + ImageInfo[iiCheck].Index := -1; + if ShowStateImages then + begin + GetImageIndex(PaintInfo, ikState, iiState, FStateImages); + if ImageInfo[iiState].Index > -1 then + AdjustImageBorder(FStateImages, BidiMode, VAlign, ContentRect, ImageInfo[iiState]); + end + else + ImageInfo[iiState].Index := -1; + if ShowImages then + begin + GetImageIndex(PaintInfo, ImageKind[vsSelected in Node.States], iiNormal, FImages); + if ImageInfo[iiNormal].Index > -1 then + AdjustImageBorder(FImages, BidiMode, VAlign, ContentRect, ImageInfo[iiNormal]); + end + else + ImageInfo[iiNormal].Index := -1; + + // Take the space for the tree lines into account. + if IsMainColumn then + AdjustCoordinatesByIndent(PaintInfo, IfThen(toFixedIndent in FOptions.FPaintOptions, 1, IndentSize)); + + if UseColumns then + begin + ClipRect := CellRect; + if poUnbuffered in PaintOptions then + begin + ClipRect.Left := Max(ClipRect.Left, Window.Left); + ClipRect.Right := Min(ClipRect.Right, Window.Right); + ClipRect.Top := Max(ClipRect.Top, Window.Top - (BaseOffset - CurrentNodeHeight)); + ClipRect.Bottom := ClipRect.Bottom - Max(TargetRect.Bottom - MaximumBottom, 0); + end; + ClipCanvas(Canvas, ClipRect); + end; + + // Paint the horizontal grid line. + if (poGridLines in PaintOptions) and (toShowHorzGridLines in FOptions.FPaintOptions) then + begin + Canvas.Font.Color := FColors.GridLineColor; + if IsMainColumn and (FLineMode = lmBands) then + begin + if BidiMode = bdLeftToRight then + begin + DrawDottedHLine(PaintInfo, CellRect.Left + IfThen(toFixedIndent in FOptions.FPaintOptions, 1, IndentSize) * Integer(FIndent), CellRect.Right - 1, + CellRect.Bottom - 1); + end + else + begin + DrawDottedHLine(PaintInfo, CellRect.Left, CellRect.Right - IfThen(toFixedIndent in FOptions.FPaintOptions, 1, IndentSize) * Integer(FIndent) - 1, + CellRect.Bottom - 1); + end; + end + else + DrawDottedHLine(PaintInfo, CellRect.Left, CellRect.Right, CellRect.Bottom - 1); + Dec(CellRect.Bottom); + Dec(ContentRect.Bottom); + end; + + if UseColumns then + begin + // Paint vertical grid line. + // Don't draw if this is the last column and the header is in autosize mode. + if (poGridLines in PaintOptions) and (toShowVertGridLines in FOptions.FPaintOptions) and + (not (hoAutoResize in FHeader.FOptions) or (Position < TColumnPosition(Count - 1))) then + begin + if (BidiMode = bdLeftToRight) or not ColumnIsEmpty(Node, Column) then + begin + Canvas.Font.Color := FColors.GridLineColor; + DrawDottedVLine(PaintInfo, CellRect.Top, CellRect.Bottom, CellRect.Right - 1); + end; + Dec(CellRect.Right); + Dec(ContentRect.Right); + end; + end; + + // Prepare background and focus rect for the current cell. + PrepareCell(PaintInfo, Window.Left, PaintWidth); + + // Some parts are only drawn for the main column. + if IsMainColumn then + begin + if (toShowTreeLines in FOptions.FPaintOptions) and + (not (toHideTreeLinesIfThemed in FOptions.FPaintOptions) or + not (tsUseThemes in FStates)) then + PaintTreeLines(PaintInfo, VAlign, IfThen(toFixedIndent in FOptions.FPaintOptions, 1, + IndentSize), LineImage); + // Show node button if allowed, if there child nodes and at least one of the child + // nodes is visible or auto button hiding is disabled. + if (toShowButtons in FOptions.FPaintOptions) and (vsHasChildren in Node.States) and + not ((vsAllChildrenHidden in Node.States) and + (toAutoHideButtons in TreeOptions.FAutoOptions)) then + PaintNodeButton(Canvas, Node, Column, CellRect, ButtonX, ButtonY, BidiMode); + + if ImageInfo[iiCheck].Index > -1 then + PaintCheckImage(Canvas, PaintInfo.ImageInfo[iiCheck], vsSelected in PaintInfo.Node.States); + end; + + if ImageInfo[iiState].Index > -1 then + PaintImage(PaintInfo, iiState, False); + if ImageInfo[iiNormal].Index > -1 then + PaintImage(PaintInfo, iiNormal, True); + + // Now let descendants or applications draw whatever they want, + // but don't draw the node if it is currently being edited. + if not ((tsEditing in FStates) and (Node = FFocusedNode) and + ((Column = FEditColumn) or not UseColumns)) then + DoPaintNode(PaintInfo); + + DoAfterCellPaint(Canvas, Node, Column, CellRect); + end; + end; + + // leave after first run if columns aren't used + if not UseColumns then + Break; + end + else + NextColumn := GetNextVisibleColumn(PaintInfo.Column); + + SelectClipRgn(PaintInfo.Canvas.Handle, 0); + // Stop column loop if there are no further columns in the given window. + if (PaintInfo.CellRect.Left >= Window.Right) or (NextColumn = InvalidColumn) then + Break; + + // Move on to next column which might not be the one immediately following the current one + // because of auto span feature. + PaintInfo.Position := Items[NextColumn].Position; + + // Move clip rectangle and continue. + if coVisible in Items[NextColumn].FOptions then + with PaintInfo do + begin + Items[NextColumn].GetAbsoluteBounds(CellRect.Left, CellRect.Right); + CellRect.Bottom := Node.NodeHeight; + ContentRect.Bottom := Node.NodeHeight; + end; + end; + end; + + // This node is finished, notify descendants/application. + with PaintInfo do + begin + DoAfterItemPaint(Canvas, Node, R); + + // Final touch for this node: mark it if it is the current drop target node. + if (Node = FDropTargetNode) and (toShowDropmark in FOptions.FPaintOptions) and + (poDrawDropMark in PaintOptions) then + DoPaintDropMark(Canvas, Node, R); + end; + end; + + with PaintInfo.Canvas do + begin + if DrawSelectionRect then + begin + PaintSelectionRectangle(PaintInfo.Canvas, Window.Left, SelectionRect, Rect(0, 0, PaintWidth, + CurrentNodeHeight)); + end; + + // Put the constructed node image onto the target canvas. + if not (poUnbuffered in PaintOptions) then + with TWithSafeRect(TargetRect), NodeBitmap do + BitBlt(TargetCanvas.Handle, Left, Top, Width, Height, Canvas.Handle, Window.Left, 0, SRCCOPY); + end; + end; + + Inc(TargetRect.Top, PaintInfo.Node.NodeHeight); + if TargetRect.Top >= MaximumBottom then + Break; + + // Keep selection rectangle coordinates in sync. + if DrawSelectionRect then + OffsetRect(SelectionRect, 0, -PaintInfo.Node.NodeHeight); + + // Advance to next visible node. + PaintInfo.Node := GetNextVisible(PaintInfo.Node, True); + end; + end; + + // Erase rest of window not covered by a node. + if TargetRect.Top < MaximumBottom then + begin + // Keep the horizontal target position to determine the selection rectangle offset later (if necessary). + BaseOffset := Target.X; + Target := TargetRect.TopLeft; + R := Rect(TargetRect.Left, 0, TargetRect.Left, MaximumBottom - Target.Y); + TargetRect := Rect(0, 0, MaximumRight - Target.X, MaximumBottom - Target.Y); + + if not (poUnbuffered in PaintOptions) then + begin + // Avoid unnecessary copying of bitmap content. This will destroy the DC handle too. + NodeBitmap.Height := 0; + NodeBitmap.PixelFormat := pf32Bit; + NodeBitmap.Width := TargetRect.Right - TargetRect.Left; + NodeBitmap.Height := TargetRect.Bottom - TargetRect.Top; + end; + + // Call back application/descendants whether they want to erase this area. + SetCanvasOrigin(PaintInfo.Canvas, Target.X, 0); + if not DoPaintBackground(PaintInfo.Canvas, TargetRect) then + begin + if UseBackground then + begin + SetCanvasOrigin(PaintInfo.Canvas, 0, 0); + if toStaticBackground in TreeOptions.PaintOptions then + StaticBackground(FBackground.Bitmap, PaintInfo.Canvas, Target, TargetRect) + else + TileBackground(FBackground.Bitmap, PaintInfo.Canvas, Target, TargetRect); + end + else + begin + // Consider here also colors of the columns. + if UseColumns then + begin + with FHeader.FColumns do + begin + // If there is no content in the tree then the first column has not yet been determined. + if FirstColumn = InvalidColumn then + begin + FirstColumn := GetFirstVisibleColumn; + repeat + if FirstColumn <> InvalidColumn then + begin + R.Left := Items[FirstColumn].Left; + R.Right := R.Left + Items[FirstColumn].FWidth; + if R.Right > TargetRect.Left then + Break; + FirstColumn := GetNextVisibleColumn(FirstColumn); + end; + until FirstColumn = InvalidColumn; + end + else + begin + R.Left := Items[FirstColumn].Left; + R.Right := R.Left + Items[FirstColumn].FWidth; + end; + + PaintInfo.Canvas.Font.Color := FColors.GridLineColor; + while (FirstColumn <> InvalidColumn) and (R.Left < TargetRect.Right + Target.X) do + begin + if (poGridLines in PaintOptions) and + (toFullVertGridLines in FOptions.FPaintOptions) and + (toShowVertGridLines in FOptions.FPaintOptions) and + (not (hoAutoResize in FHeader.FOptions) or (Cardinal(FirstColumn) < TColumnPosition(Count - 1))) then + begin + DrawDottedVLine(PaintInfo, R.Top, R.Bottom, R.Right - 1); + Dec(R.Right); + end; + + if not (coParentColor in Items[FirstColumn].FOptions) then + PaintInfo.Canvas.Brush.Color := Items[FirstColumn].FColor + else + PaintInfo.Canvas.Brush.Color := Color; + + PaintInfo.Canvas.FillRect(R); + FirstColumn := GetNextVisibleColumn(FirstColumn); + if FirstColumn <> InvalidColumn then + begin + R.Left := Items[FirstColumn].Left; + R.Right := R.Left + Items[FirstColumn].FWidth; + end; + end; + + // Erase also the part of the tree not covert by a column. + if R.Right < TargetRect.Right + Target.X then + begin + R.Left := R.Right; + R.Right := TargetRect.Right + Target.X; + // Prevent erasing the last vertical grid line. + if (poGridLines in PaintOptions) and + (toFullVertGridLines in FOptions.FPaintOptions) and (toShowVertGridLines in FOptions.FPaintOptions) and + (not (hoAutoResize in FHeader.FOptions)) then + Inc(R.Left); + PaintInfo.Canvas.Brush.Color := Color; + PaintInfo.Canvas.FillRect(R); + end; + end; + SetCanvasOrigin(PaintInfo.Canvas, 0, 0); + end + else + begin + // No columns nor bitmap background. Simply erase it with the tree color. + SetCanvasOrigin(PaintInfo.Canvas, 0, 0); + PaintInfo.Canvas.Brush.Color := Color; + PaintInfo.Canvas.FillRect(TargetRect); + end; + end; + end; + SetCanvasOrigin(PaintInfo.Canvas, 0, 0); + + if DrawSelectionRect then + begin + R := OrderRect(FNewSelRect); + // Remap the selection rectangle to the current window of the tree. + // Since Target has been used for other tasks BaseOffset got the left extent of the target position here. + OffsetRect(R, -Target.X + BaseOffset - Window.Left, -Target.Y + FOffsetY); + SetBrushOrigin(PaintInfo.Canvas, 0, Target.X and 1); + PaintSelectionRectangle(PaintInfo.Canvas, 0, R, TargetRect); + end; + + if not (poUnBuffered in PaintOptions) then + with Target, NodeBitmap do + BitBlt(TargetCanvas.Handle, X, Y, Width, Height, Canvas.Handle, 0, 0, SRCCOPY); + end; + finally + PaintInfo.Canvas.Unlock; + if poUnbuffered in PaintOptions then + RestoreDC(TargetCanvas.Handle, SavedTargetDC) + else + NodeBitmap.Free; + end; + + if (ChildCount[nil] = 0) and (FEmptyListMessage <> '') then + begin + // output a message if no items are to display + Canvas.Font := Self.Font; + SetBkMode(TargetCanvas.Handle, TRANSPARENT); + R.Left := TargetRect.Left + 3; + R.Top := TargetRect.Top + 2; + R.Right := Max(TargetRect.Right, Window.Right) -2; // TargetRect.Right is very small when the window is moved out of the Dektop on the left + R.Bottom := TargetRect.Bottom -2; + TargetCanvas.Font.Color := clGrayText; + {$if CompilerVersion >= 20} + TargetCanvas.TextRect(R, FEmptyListMessage, [tfNoClip, tfLeft]); + {$else} + TextOutW(TargetCanvas.Handle, 2 - Window.Left, 2 - Window.Top, PWideChar(FEmptyListMessage), Length(FEmptyListMessage)); + {$ifend} + end; + + DoAfterPaint(TargetCanvas); + finally + DoStateChange([], [tsPainting]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.PasteFromClipboard: Boolean; + +// Reads what is currently on the clipboard into the tree (if the format is supported). +// Note: If the application wants to have text or special formats to be inserted then it must implement +// its own code (OLE). Here only the native tree format is accepted. + +var + Data: IDataObject; + Source: TBaseVirtualTree; + +begin + Result := False; + if not (toReadOnly in FOptions.FMiscOptions) then + begin + if OleGetClipboard(Data) <> S_OK then + ShowError(SClipboardFailed, hcTFClipboardFailed) + else + try + // Try to get the source tree of the operation to optimize the operation. + Source := GetTreeFromDataObject(Data); + Result := ProcessOLEData(Source, Data, FFocusedNode, FDefaultPasteMode, Assigned(Source) and + (tsCutPending in Source.FStates)); + if Assigned(Source) then + if Source <> Self then + Source.FinishCutOrCopy + else + DoStateChange([], [tsCutPending]); + finally + Data := nil; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.PrepareDragImage(Hotspot: TPoint; const DataObject: IDataObject); + +// Initiates an image drag operation. Hotspot is the position of the mouse in client coordinates. + +var + PaintOptions: TVTInternalPaintOptions; + TreeRect, + PaintRect: TRect; + LocalSpot, + ImagePos, + PaintTarget: TPoint; + Image: TBitmap; + +begin + if CanShowDragImage then + begin + // Determine the drag rectangle which is a square around the hot spot. Operate in virtual tree space. + LocalSpot := HotSpot; + Dec(LocalSpot.X, -FEffectiveOffsetX); + Dec(LocalSpot.Y, FOffsetY); + TreeRect := Rect(LocalSpot.X - FDragWidth div 2, LocalSpot.Y - FDragHeight div 2, LocalSpot.X + FDragWidth div 2, + LocalSpot.Y + FDragHeight div 2); + + // Check that we have a valid rectangle. + PaintRect := TreeRect; + with TWithSafeRect(TreeRect) do + begin + if Left < 0 then + begin + PaintTarget.X := -Left; + PaintRect.Left := 0; + end + else + PaintTarget.X := 0; + if Top < 0 then + begin + PaintTarget.Y := -Top; + PaintRect.Top := 0; + end + else + PaintTarget.Y := 0; + end; + + Image := TBitmap.Create; + with Image do + try + PixelFormat := pf32Bit; + Width := TreeRect.Right - TreeRect.Left; + Height := TreeRect.Bottom - TreeRect.Top; + // Erase the entire image with the color key value, for the case not everything + // in the image is covered by the tree image. + Canvas.Brush.Color := Color; + Canvas.FillRect(Rect(0, 0, Width, Height)); + + PaintOptions := [poDrawSelection, poSelectedOnly]; + if FDragImageKind = diMainColumnOnly then + Include(PaintOptions, poMainOnly); + PaintTree(Image.Canvas, PaintRect, PaintTarget, PaintOptions); + + // Once we have got the drag image we can convert all necessary coordinates into screen space. + OffsetRect(TreeRect, -FEffectiveOffsetX, FOffsetY); + ImagePos := ClientToScreen(TreeRect.TopLeft); + HotSpot := ClientToScreen(HotSpot); + + FDragImage.ColorKey := Color; + FDragImage.PrepareDrag(Image, ImagePos, HotSpot, DataObject); + finally + Image.Free; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Print(Printer: TPrinter; PrintHeader: Boolean); + +var + SaveTreeFont: TFont; // Remembers the tree's current font. + SaveHeaderFont: TFont; // Remembers the header's current font. + ImgRect, // Describes the dimensions of Image. + TreeRect, // The total VTree dimensions. + DestRect, // Dimensions of PrinterImage. + SrcRect: TRect; // Clip dimensions from Image -> PrinterImage + P: TPoint; // Used by PaintTree. + Options: TVTInternalPaintOptions; // Used by PaintTree. + Image, // Complete Tree is drawn to this image. + PrinterImage: TBitmap; // This is the image that gets printed. + SaveColor: TColor; // Remembers the VTree Color. + pTxtHeight, // Height of font in the TPrinter.Canvas + vTxtHeight, // Height of font in the VTree Canvas + vPageWidth, + vPageHeight, // Printer height in VTree resolution + xPageNum, yPageNum, // # of pages (except the occasional last one) + xPage, yPage: Integer; // Loop counter + Scale: Extended; // Scale factor between Printer Canvas and VTree Canvas + LogFont: TLogFont; + +begin + if Assigned(Printer) then + begin + BeginUpdate; + + // Grid lines are the only parts which are desirable when printing. + Options := [poGridLines]; + + // Remember the tree font. + SaveTreeFont := TFont.Create; + SaveTreeFont.Assign(Font); + // Create a new font for printing which does not use clear type output (but is antialiased, if possible) + // and which has the highest possible quality. + GetObject(Font.Handle, SizeOf(TLogFont), @LogFont); + LogFont.lfQuality := ANTIALIASED_QUALITY; + Font.Handle := CreateFontIndirect(LogFont); + + // Create an image that will hold the complete VTree + Image := TBitmap.Create; + Image.PixelFormat := pf32Bit; + PrinterImage := nil; + try + TreeRect := GetTreeRect; + + Image.Width := TreeRect.Right - TreeRect.Left; + P := Point(0, 0); + if (hoVisible in FHeader.Options) and PrintHeader then + begin + Inc(TreeRect.Bottom, FHeader.Height); + Inc(P.Y, FHeader.Height); + end; + Image.Height := TreeRect.Bottom - TreeRect.Top; + + ImgRect.Left := 0; + ImgRect.Top := 0; + ImgRect.Right := Image.Width; + + // Force the background to white color during the rendering. + SaveColor := Color; + Color := clWhite; + // Print header if it is visible. + if (hoVisible in FHeader.Options) and PrintHeader then + begin + SaveHeaderFont := TFont.Create; + try + SaveHeaderFont.Assign(FHeader.Font); + // Create a new font for printing which does not use clear type output (but is antialiased, if possible) + // and which has the highest possible quality. + GetObject(FHeader.Font.Handle, SizeOf(TLogFont), @LogFont); + LogFont.lfQuality := ANTIALIASED_QUALITY; + FHeader.Font.Handle := CreateFontIndirect(LogFont); + ImgRect.Bottom := FHeader.Height; + FHeader.FColumns.PaintHeader(Image.Canvas.Handle, ImgRect, 0); + FHeader.Font := SaveHeaderFont; + finally + SaveHeaderFont.Free; + end; + end; + // The image's height is already adjusted for the header if it is visible. + ImgRect.Bottom := Image.Height; + + PaintTree(Image.Canvas, ImgRect, P, Options, pf32Bit); + Color := SaveColor; + + // Activate the printer + Printer.BeginDoc; + Printer.Canvas.Font := Font; + + // Now we can calculate the scaling : + pTxtHeight := Printer.Canvas.TextHeight('Tj'); + vTxtHeight := Canvas.TextHeight('Tj'); + + Scale := pTxtHeight / vTxtHeight; + + // Create an Image that has the same dimensions as the printer canvas but + // scaled to the VTree resolution: + PrinterImage := TBitmap.Create; + + vPageHeight := Round(Printer.PageHeight / Scale); + vPageWidth := Round(Printer.PageWidth / Scale); + + // We do a minumum of one page. + xPageNum := Trunc(Image.Width / vPageWidth); + yPageNum := Trunc(Image.Height / vPageHeight); + + PrinterImage.Width := vPageWidth; + PrinterImage.Height := vPageHeight; + + // Split vertically: + for yPage := 0 to yPageNum do + begin + DestRect.Left := 0; + DestRect.Top := 0; + DestRect.Right := PrinterImage.Width; + DestRect.Bottom := PrinterImage.Height; + + // Split horizontally: + for xPage := 0 to xPageNum do + begin + SrcRect.Left := vPageWidth * xPage; + SrcRect.Top := vPageHeight * yPage; + SrcRect.Right := vPageWidth * xPage + PrinterImage.Width; + SrcRect.Bottom := SrcRect.Top + vPageHeight; + + // Clear the image + PrinterImage.Canvas.Brush.Color := clWhite; + PrinterImage.Canvas.FillRect(Rect(0, 0, PrinterImage.Width, PrinterImage.Height)); + PrinterImage.Canvas.CopyRect(DestRect, Image.Canvas, SrcRect); + PrtStretchDrawDIB(Printer.Canvas, Rect(0, 0, Printer.PageWidth, Printer.PageHeight - 1), PrinterImage); + if xPage <> xPageNum then + Printer.NewPage; + end; + if yPage <> yPageNum then + Printer.NewPage; + end; + + // Restore tree font. + Font := SaveTreeFont; + SaveTreeFont.Free; + Printer.EndDoc; + finally + PrinterImage.Free; + Image.Free; + EndUpdate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ProcessDrop(DataObject: IDataObject; TargetNode: PVirtualNode; var Effect: Integer; + Mode: TVTNodeAttachMode): Boolean; + +// Recreates the (sub) tree structure serialized into memory and provided by DataObject. The new nodes are attached to +// the passed node or FRoot if TargetNode is nil. +// Returns True on success, i.e. the CF_VIRTUALTREE format is supported by the data object and the structure could be +// recreated, otherwise False. + +var + Source: TBaseVirtualTree; + +begin + Result := False; + if Mode = amNoWhere then + Effect := DROPEFFECT_NONE + else + begin + BeginUpdate; + // try to get the source tree of the operation + Source := GetTreeFromDataObject(DataObject); + if Assigned(Source) then + Source.BeginUpdate; + try + try + // Before adding the new nodes try to optimize the operation if source and target tree reside in + // the same application and operation is a move. + if ((Effect and DROPEFFECT_MOVE) <> 0) and Assigned(Source) then + begin + // If both copy and move are specified then prefer a copy because this is not destructing. + Result := ProcessOLEData(Source, DataObject, TargetNode, Mode, (Effect and DROPEFFECT_COPY) = 0); + // Since we made an optimized move or a copy there's no reason to act further after DoDragging returns. + Effect := DROPEFFECT_NONE; + end + else + // Act only if move or copy operation is requested. + if (Effect and (DROPEFFECT_MOVE or DROPEFFECT_COPY)) <> 0 then + Result := ProcessOLEData(Source, DataObject, TargetNode, Mode, False) + else + Result := False; + except + Effect := DROPEFFECT_NONE; + end; + finally + if Assigned(Source) then + Source.EndUpdate; + EndUpdate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + // needed to handle OLE global memory objects + TOLEMemoryStream = class(TCustomMemoryStream) + public + function Write(const Buffer; Count: Integer): Longint; override; + end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TOLEMemoryStream.Write(const Buffer; Count: Integer): Integer; + +begin + raise EStreamError.CreateRes(PResStringRec(@SCantWriteResourceStreamError)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ProcessOLEData(Source: TBaseVirtualTree; DataObject: IDataObject; TargetNode: PVirtualNode; + Mode: TVTNodeAttachMode; Optimized: Boolean): Boolean; + +// Recreates the (sub) tree structure serialized into memory and provided by DataObject. The new nodes are attached to +// the passed node or FRoot if TargetNode is nil according to Mode. Optimized can be set to True if the entire operation +// happens within the same process (i.e. sender and receiver of the OLE operation are located in the same process). +// Optimize = True makes only sense if the operation to carry out is a move hence it is also the indication of the +// operation to be done here. Source is the source of the OLE data and only of use (and usually assigned) when +// an OLE operation takes place in the same application. +// Returns True on success, i.e. the CF_VIRTUALTREE format is supported by the data object and the structure could be +// recreated, otherwise False. + +var + Medium: TStgMedium; + Stream: TStream; + Data: Pointer; + Node: PVirtualNode; + Nodes: TNodeArray; + I: Integer; + Res: HRESULT; + ChangeReason: TChangeReason; + +begin + Nodes := nil; + // Check the data format available by the data object. + with StandardOLEFormat do + begin + // Read best format. + cfFormat := CF_VIRTUALTREE; + end; + Result := DataObject.QueryGetData(StandardOLEFormat) = S_OK; + if Result and not (toReadOnly in FOptions.FMiscOptions) then + begin + BeginUpdate; + Result := False; + try + if TargetNode = nil then + TargetNode := FRoot; + if TargetNode = FRoot then + begin + case Mode of + amInsertBefore: + Mode := amAddChildFirst; + amInsertAfter: + Mode := amAddChildLast; + end; + end; + + // Optimized means source is known and in the same process so we can access its pointers, which avoids duplicating + // the data while doing a serialization. Can only be used with cut'n paste and drag'n drop with move effect. + if Optimized then + begin + if tsOLEDragging in Source.FStates then + Nodes := Source.FDragSelection + else + Nodes := Source.GetSortedCutCopySet(True); + + if Mode in [amInsertBefore,amAddChildLast] then + begin + for I := 0 to High(Nodes) do + if not HasAsParent(TargetNode, Nodes[I]) then + Source.MoveTo(Nodes[I], TargetNode, Mode, False); + end + else + begin + for I := High(Nodes) downto 0 do + if not HasAsParent(TargetNode, Nodes[I]) then + Source.MoveTo(Nodes[I], TargetNode, Mode, False); + end; + Result := True; + end + else + begin + if Source = Self then + ChangeReason := crNodeCopied + else + ChangeReason := crNodeAdded; + Res := DataObject.GetData(StandardOLEFormat, Medium); + if Res = S_OK then + begin + case Medium.tymed of + TYMED_ISTREAM, // IStream interface + TYMED_HGLOBAL: // global memory block + begin + Stream := nil; + if Medium.tymed = TYMED_ISTREAM then + Stream := TOLEStream.Create(IUnknown(Medium.stm) as IStream) + else + begin + Data := GlobalLock(Medium.hGlobal); + if Assigned(Data) then + begin + // Get the total size of data to retrieve. + I := PCardinal(Data)^; + Inc(PCardinal(Data)); + Stream := TOLEMemoryStream.Create; + TOLEMemoryStream(Stream).SetPointer(Data, I); + end; + end; + + if Assigned(Stream) then + try + while Stream.Position < Stream.Size do + begin + Node := MakeNewNode; + InternalConnectNode(Node, TargetNode, Self, Mode); + InternalAddFromStream(Stream, VTTreeStreamVersion, Node); + // This seems a bit strange because of the callback for granting to add the node + // which actually comes after the node has been added. The reason is that the node must + // contain valid data otherwise I don't see how the application can make a funded decision. + if not DoNodeCopying(Node, TargetNode) then + DeleteNode(Node) + else + DoNodeCopied(Node); + StructureChange(Node, ChangeReason); + + // In order to maintain the same node order when restoring nodes in the case of amInsertAfter + // we have to move the reference node continously. Othwise we would end up with reversed node order. + if Mode = amInsertAfter then + TargetNode := Node; + end; + Result := True; + finally + Stream.Free; + if Medium.tymed = TYMED_HGLOBAL then + GlobalUnlock(Medium.hGlobal); + end; + end; + end; + ReleaseStgMedium(Medium); + end; + end; + finally + EndUpdate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ReinitChildren(Node: PVirtualNode; Recursive: Boolean); + +// Forces all child nodes of Node to be reinitialized. +// If Recursive is True then also the grandchildren are reinitialized. + +var + Run: PVirtualNode; + +begin + if Assigned(Node) then + begin + InitChildren(Node); + Run := Node.FirstChild; + end + else + begin + InitChildren(FRoot); + Run := FRoot.FirstChild; + end; + + while Assigned(Run) do + begin + ReinitNode(Run, Recursive); + Run := Run.NextSibling; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ReinitNode(Node: PVirtualNode; Recursive: Boolean); + +// Forces the given node and all its children (if recursive is True) to be initialized again without +// modifying any data in the nodes nor deleting children (unless the application requests a different amount). + +begin + if Assigned(Node) and (Node <> FRoot) then + begin + // Remove dynamic styles. + Node.States := Node.States - [vsChecking, vsCutOrCopy, vsDeleting, vsHeightMeasured]; + InitNode(Node); + end; + + if Recursive then + ReinitChildren(Node, True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.RepaintNode(Node: PVirtualNode); + +// Causes an immediate repaint of the given node. + +var + R: Trect; + +begin + if Assigned(Node) and (Node <> FRoot) then + begin + R := GetDisplayRect(Node, -1, False); + RedrawWindow(Handle, @R, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_NOERASE or RDW_VALIDATE or RDW_NOCHILDREN); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ResetNode(Node: PVirtualNode); + +// Deletes all children of the given node and marks it as being uninitialized. + +begin + DoCancelEdit; + if (Node = nil) or (Node = FRoot) then + Clear + else + begin + DoReset(Node); + DeleteChildren(Node); + // Remove initialized and other dynamic styles, keep persistent styles. + Node.States := Node.States - [vsInitialized, vsChecking, vsCutOrCopy, vsDeleting, vsHasChildren, vsExpanded, + vsHeightMeasured]; + InvalidateNode(Node); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SaveToFile(const FileName: TFileName); + +// Saves the entire content of the tree into a file (see further notes in SaveToStream). + +var + FileStream: TFileStream; + +begin + FileStream := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(FileStream); + finally + FileStream.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SaveToStream(Stream: TStream; Node: PVirtualNode = nil); + +// Saves Node and all its children to Stream. If Node is nil then all top level nodes will be stored. +// Note: You should be careful about assuming what is actually saved. The problem here is that we are dealing with +// virtual data. The tree can so not know what it has to save. The only fact we reliably know is the tree's +// structure. To be flexible for future enhancements as well as unknown content (unknown to the tree class which +// is saving/loading the stream) a chunk based approach is used here. Every tree class handles only those +// chunks which are not handled by an anchestor class and are known by the class. +// +// The base tree class saves only the structure of the tree along with application provided data. descendants may +// optionally add their own chunks to store additional information. See: WriteChunks. + +var + Count: Cardinal; + +begin + Stream.Write(MagicID, SizeOf(MagicID)); + if Node = nil then + begin + // Keep number of top level nodes for easy restauration. + Count := FRoot.ChildCount; + Stream.WriteBuffer(Count, SizeOf(Count)); + + // Save entire tree here. + Node := FRoot.FirstChild; + while Assigned(Node) do + begin + WriteNode(Stream, Node); + Node := Node.NextSibling; + end; + end + else + begin + Count := 1; + Stream.WriteBuffer(Count, SizeOf(Count)); + WriteNode(Stream, Node); + end; + if Assigned(FOnSaveTree) then + FOnSaveTree(Self, Stream); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ScrollIntoView(Node: PVirtualNode; Center: Boolean; Horizontally: Boolean = False): Boolean; + +// Scrolls the tree so that the given node is in the client area and returns True if the tree really has been +// scrolled (e.g. to avoid further updates) else returns False. If extened focus is enabled then the tree will also +// be horizontally scrolled if needed. +// Note: All collapsed parents of the node are expanded. + +var + R: TRect; + Run: PVirtualNode; + UseColumns, + HScrollBarVisible: Boolean; + ScrolledVertically, + ScrolledHorizontally: Boolean; + +begin + ScrolledVertically := False; + ScrolledHorizontally := False; + + if Assigned(Node) and (Node <> FRoot) then + begin + // Make sure all parents of the node are expanded. + Run := Node.Parent; + while Run <> FRoot do + begin + if not (vsExpanded in Run.States) then + ToggleNode(Run); + Run := Run.Parent; + end; + UseColumns := FHeader.UseColumns; + if UseColumns and FHeader.FColumns.IsValidColumn(FFocusedColumn) then + R := GetDisplayRect(Node, FFocusedColumn, not (toGridExtensions in FOptions.FMiscOptions)) + else + R := GetDisplayRect(Node, NoColumn, not (toGridExtensions in FOptions.FMiscOptions)); + + // The returned rectangle can never be empty after the expand code above. + // 1) scroll vertically + if R.Top < 0 then + begin + if Center then + SetOffsetY(FOffsetY - R.Top + ClientHeight div 2) + else + SetOffsetY(FOffsetY - R.Top); + ScrolledVertically := True; + end + else + if (R.Bottom > ClientHeight) or Center then + begin + HScrollBarVisible := (ScrollBarOptions.ScrollBars in [ssBoth, ssHorizontal]) and + (ScrollBarOptions.AlwaysVisible or (Integer(FRangeX) > ClientWidth)); + if Center then + SetOffsetY(FOffsetY - R.Bottom + ClientHeight div 2) + else + SetOffsetY(FOffsetY - R.Bottom + ClientHeight); + // When scrolling up and the horizontal scroll appears because of the operation + // then we have to move up the node the horizontal scrollbar's height too + // in order to avoid that the scroll bar hides the node which we wanted to have in view. + if not UseColumns and not HScrollBarVisible and (Integer(FRangeX) > ClientWidth) then + SetOffsetY(FOffsetY - GetSystemMetrics(SM_CYHSCROLL)); + ScrolledVertically := True; + end; + + if Horizontally then + // 2) scroll horizontally + ScrolledHorizontally := ScrollIntoView(FFocusedColumn, Center); + + end; + + Result := ScrolledVertically or ScrolledHorizontally; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.ScrollIntoView(Column: TColumnIndex; Center: Boolean): Boolean; + +// Scrolls the columns so that the given column is in the client area and returns True if the columns really have been +// scrolled (e.g. to avoid further updates) else returns False. + +var + ColumnLeft, + ColumnRight: Integer; + NewOffset: Integer; + +begin + Result := False; + + if not FHeader.UseColumns then exit; + if not FHeader.Columns.IsValidColumn(Column) then exit; // Just in case. + + ColumnLeft := Header.Columns.Items[Column].Left; + ColumnRight := ColumnLeft + Header.Columns.Items[Column].Width; + + NewOffset := FEffectiveOffsetX; + if Center then + begin + NewOffset := FEffectiveOffsetX + ColumnLeft - (Header.Columns.GetVisibleFixedWidth div 2) - (ClientWidth div 2) + ((ColumnRight - ColumnLeft) div 2); + if NewOffset <> FEffectiveOffsetX then + begin + if UseRightToLeftAlignment then + SetOffsetX(-Integer(FRangeX) + ClientWidth + NewOffset) + else + SetOffsetX(-NewOffset); + end; + Result := True; + end + else + begin + if ColumnRight > ClientWidth then + NewOffset := FEffectiveOffsetX + (ColumnRight - ClientWidth) + else if ColumnLeft < Header.Columns.GetVisibleFixedWidth then + NewOffset := FEffectiveOffsetX - (Header.Columns.GetVisibleFixedWidth - ColumnLeft); + if NewOffset <> FEffectiveOffsetX then + begin + if UseRightToLeftAlignment then + SetOffsetX(-Integer(FRangeX) + ClientWidth + NewOffset) + else + SetOffsetX(-NewOffset); + end; + Result := True; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SelectAll(VisibleOnly: Boolean); + +// Select all nodes in the tree. +// If VisibleOnly is True then only visible nodes are selected. + +var + Run: PVirtualNode; + NextFunction: TGetNextNodeProc; + +begin + if not FSelectionLocked and (toMultiSelect in FOptions.FSelectionOptions) then + begin + ClearTempCache; + if VisibleOnly then + begin + Run := GetFirstVisible(nil, True); + NextFunction := GetNextVisible; + end + else + begin + Run := GetFirst; + NextFunction := GetNext; + end; + + while Assigned(Run) do + begin + if not(vsSelected in Run.States) then + InternalCacheNode(Run); + Run := NextFunction(Run); + end; + if FTempNodeCount > 0 then + AddToSelection(FTempNodeCache, FTempNodeCount); + ClearTempCache; + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.Sort(Node: PVirtualNode; Column: TColumnIndex; Direction: TSortDirection; DoInit: Boolean = True); + +// Sorts the given node. The application is queried about how to sort via the OnCompareNodes event. +// Column is simply passed to the the compare function so the application can also sort in a particular column. +// In order to free the application from taking care about the sort direction the parameter Direction is used. +// This way the application can always sort in increasing order, while this method reorders nodes according to this flag. + + //--------------- local functions ------------------------------------------- + + function MergeAscending(A, B: PVirtualNode): PVirtualNode; + + // Merges A and B (which both must be sorted via Compare) into one list. + + var + Dummy: TVirtualNode; + CompareResult: Integer; + begin + // This avoids checking for Result = nil in the loops. + Result := @Dummy; + while Assigned(A) and Assigned(B) do + begin + if OperationCanceled then + CompareResult := 0 + else + CompareResult := DoCompare(A, B, Column); + + if CompareResult <= 0 then + begin + Result.NextSibling := A; + Result := A; + A := A.NextSibling; + end + else + begin + Result.NextSibling := B; + Result := B; + B := B.NextSibling; + end; + end; + + // Just append the list which is not nil (or set end of result list to nil if both lists are nil). + if Assigned(A) then + Result.NextSibling := A + else + Result.NextSibling := B; + // return start of the new merged list + Result := Dummy.NextSibling; + end; + + //--------------------------------------------------------------------------- + + function MergeDescending(A, B: PVirtualNode): PVirtualNode; + + // Merges A and B (which both must be sorted via Compare) into one list. + + var + Dummy: TVirtualNode; + CompareResult: Integer; + + begin + // this avoids checking for Result = nil in the loops + Result := @Dummy; + while Assigned(A) and Assigned(B) do + begin + if OperationCanceled then + CompareResult := 0 + else + CompareResult := DoCompare(A, B, Column); + + if CompareResult >= 0 then + begin + Result.NextSibling := A; + Result := A; + A := A.NextSibling; + end + else + begin + Result.NextSibling := B; + Result := B; + B := B.NextSibling; + end; + end; + + // Just append the list which is not nil (or set end of result list to nil if both lists are nil). + if Assigned(A) then + Result.NextSibling := A + else + Result.NextSibling := B; + // Return start of the newly merged list. + Result := Dummy.NextSibling; + end; + + //--------------------------------------------------------------------------- + + function MergeSortAscending(var Node: PVirtualNode; N: Cardinal): PVirtualNode; + + // Sorts the list of nodes given by Node (which must not be nil). + + var + A, B: PVirtualNode; + + begin + if N > 1 then + begin + A := MergeSortAscending(Node, N div 2); + B := MergeSortAscending(Node, (N + 1) div 2); + Result := MergeAscending(A, B); + end + else + begin + Result := Node; + Node := Node.NextSibling; + Result.NextSibling := nil; + end; + end; + + //--------------------------------------------------------------------------- + + function MergeSortDescending(var Node: PVirtualNode; N: Cardinal): PVirtualNode; + + // Sorts the list of nodes given by Node (which must not be nil). + + var + A, B: PVirtualNode; + + begin + if N > 1 then + begin + A := MergeSortDescending(Node, N div 2); + B := MergeSortDescending(Node, (N + 1) div 2); + Result := MergeDescending(A, B); + end + else + begin + Result := Node; + Node := Node.NextSibling; + Result.NextSibling := nil; + end; + end; + + //--------------- end local functions --------------------------------------- + +var + Run: PVirtualNode; + Index: Cardinal; + +begin + InterruptValidation; + if tsEditPending in FStates then + begin + StopTimer(EditTimer); + DoStateChange([], [tsEditPending]); + end; + + if not (tsEditing in FStates) or DoEndEdit then + begin + if Node = nil then + Node := FRoot; + if vsHasChildren in Node.States then + begin + if (Node.ChildCount = 0) and DoInit then + InitChildren(Node); + // Make sure the children are valid, so they can be sorted at all. + if DoInit and (Node.ChildCount > 0) then + ValidateChildren(Node, False); + // Child count might have changed. + if Node.ChildCount > 1 then + begin + StartOperation(okSortNode); + try + // Sort the linked list, check direction flag only once. + if Direction = sdAscending then + Node.FirstChild := MergeSortAscending(Node.FirstChild, Node.ChildCount) + else + Node.FirstChild := MergeSortDescending(Node.FirstChild, Node.ChildCount); + finally + EndOperation(okSortNode); + end; + // Consolidate the child list finally. + Run := Node.FirstChild; + Run.PrevSibling := nil; + Index := 0; + repeat + Run.Index := Index; + Inc(Index); + if Run.NextSibling = nil then + Break; + Run.NextSibling.PrevSibling := Run; + Run := Run.NextSibling; + until False; + Node.LastChild := Run; + + InvalidateCache; + end; + if FUpdateCount = 0 then + begin + ValidateCache; + Invalidate; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.SortTree(Column: TColumnIndex; Direction: TSortDirection; DoInit: Boolean = True); + + //--------------- local function -------------------------------------------- + + procedure DoSort(Node: PVirtualNode); + + // Recursively sorts Node and its child nodes. + + var + Run: PVirtualNode; + + begin + Sort(Node, Column, Direction, DoInit); + + Run := Node.FirstChild; + while Assigned(Run) and not FOperationCanceled do + begin + if DoInit and not (vsInitialized in Run.States) then + InitNode(Run); + if vsInitialized in Run.States then + DoSort(Run); + Run := Run.NextSibling; + end; + end; + + //--------------- end local function ---------------------------------------- + +begin + // Instead of wrapping the sort using BeginUpdate/EndUpdate simply the update counter + // is modified. Otherwise the EndUpdate call will recurse here. + Inc(FUpdateCount); + try + if Column > InvalidColumn then + begin + StartOperation(okSortTree); + try + DoSort(FRoot); + finally + EndOperation(okSortTree); + end; + end; + InvalidateCache; + finally + if FUpdateCount > 0 then + Dec(FUpdateCount); + if FUpdateCount = 0 then + begin + ValidateCache; + Invalidate; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ToggleNode(Node: PVirtualNode); + +// Changes a node's expand state to the opposite state. + +var + Child, + FirstVisible: PVirtualNode; + HeightDelta, + StepsR1, + StepsR2, + Steps: Integer; + TogglingTree, + ChildrenInView, + NeedFullInvalidate, + NeedUpdate, + NodeInView, + PosHoldable, + TotalFit: Boolean; + ToggleData: TToggleAnimationData; + + //--------------- local function -------------------------------------------- + + procedure PrepareAnimation; + + // Prepares ToggleData. + + var + R: TRect; + S: Integer; + M: TToggleAnimationMode; + + begin + with ToggleData do + begin + Window := Handle; + DC := GetDC(Handle); + Self.Brush.Color := Color; + Brush := Self.Brush.Handle; + + if (Mode1 <> tamNoScroll) and (Mode2 <> tamNoScroll) then + begin + if StepsR1 < StepsR2 then + begin + // As the primary rectangle is always R1 we will get a much smoother + // animation if R1 is the one that will be scrolled more. + R := R2; + R2 := R1; + R1 := R; + + M := Mode2; + Mode2 := Mode1; + Mode1 := M; + + S := StepsR2; + StepsR2 := StepsR1; + StepsR1 := S; + end; + ScaleFactor := StepsR2 / StepsR1; + MissedSteps := 0; + end; + + if Mode1 <> tamNoScroll then + Steps := StepsR1 + else + Steps := StepsR2; + end; + end; + + //--------------- end local function ---------------------------------------- + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + + TogglingTree := tsToggling in FStates; + ChildrenInView := False; + HeightDelta := 0; + NeedFullInvalidate := False; + NeedUpdate := False; + NodeInView := False; + PosHoldable := False; + TotalFit := False; + + // We don't need to switch the expand state if the node is being deleted otherwise some + // updates (e.g. visible node count) are done twice with disasterous results). + if [vsDeleting, vsToggling] * Node.States = [] then + begin + try + DoStateChange([tsToggling]); + Include(Node.States, vsToggling); + + if vsExpanded in Node.States then + begin + if DoCollapsing(Node) then + begin + NeedUpdate := True; + + // Calculate the height delta right now as we need it for toChildrenAbove anyway. + HeightDelta := -Integer(Node.TotalHeight) + Integer(NodeHeight[Node]); + if (FUpdateCount = 0) and (toAnimatedToggle in FOptions.FAnimationOptions) and not + (tsCollapsing in FStates) then + begin + Application.CancelHint; + UpdateWindow(Handle); + + // animated collapsing + with ToggleData do + begin + // Determine the animation behaviour and rectangle. If toChildrenAbove is set, the behaviour is depending + // on the position of the node to be collapsed. + R1 := GetDisplayRect(Node, NoColumn, False); + Mode2 := tamNoScroll; + if toChildrenAbove in FOptions.FPaintOptions then + begin + PosHoldable := (FOffsetY + (Integer(Node.TotalHeight) - Integer(NodeHeight[Node]))) <= 0; + NodeInView := R1.Top < ClientHeight; + + StepsR1 := 0; + if NodeInView then + begin + if PosHoldable or not (toAdvancedAnimatedToggle in FOptions.FAnimationOptions) then + begin + // Scroll the child nodes down. + Mode1 := tamScrollDown; + R1.Bottom := R1.Top; + R1.Top := 0; + StepsR1 := Min(R1.Bottom - R1.Top + 1, Integer(Node.TotalHeight) - Integer(NodeHeight[Node])); + end + else + begin + // The position cannot be kept. So scroll the node up to its future position. + Mode1 := tamScrollUp; + R1.Top := Max(0, R1.Top + HeightDelta); + R1.Bottom := ClientHeight; + StepsR1 := FOffsetY - HeightDelta; + end; + end; + end + else + begin + if (Integer(FRangeY) + FOffsetY - R1.Bottom + HeightDelta >= ClientHeight - R1.Bottom) or + (Integer(FRangeY) <= ClientHeight) or (FOffsetY = 0) or not + (toAdvancedAnimatedToggle in FOptions.FAnimationOptions) then + begin + // Do a simple scroll up over the child nodes. + Mode1 := tamScrollUp; + Inc(R1.Top, NodeHeight[Node]); + R1.Bottom := ClientHeight; + StepsR1 := Min(R1.Bottom - R1.Top + 1, -HeightDelta); + end + else + begin + // Scroll the node down to its future position. As FOffsetY will change we need to invalidate the + // whole tree. + Mode1 := tamScrollDown; + StepsR1 := Min(-FOffsetY, ClientHeight - Integer(FRangeY) -FOffsetY - HeightDelta); + R1.Top := 0; + R1.Bottom := Min(ClientHeight, R1.Bottom + Steps); + NeedFullInvalidate := True; + end; + end; + + // No animation necessary if the node is below the current client height. + if R1.Top < ClientHeight then + begin + PrepareAnimation; + try + Animate(Steps, FAnimationDuration, ToggleCallback, @ToggleData); + finally + ReleaseDC(Window, DC); + end; + end; + end; + end; + + // collapse the node + AdjustTotalHeight(Node, IfThen(IsEffectivelyFiltered[Node], 0, NodeHeight[Node])); + if FullyVisible[Node] then + Dec(FVisibleCount, CountVisibleChildren(Node)); + Exclude(Node.States, vsExpanded); + DoCollapsed(Node); + + // Remove child nodes now, if enabled. + if (toAutoFreeOnCollapse in FOptions.FAutoOptions) and (Node.ChildCount > 0) then + begin + DeleteChildren(Node); + Include(Node.States, vsHasChildren); + end; + end; + end + else + if DoExpanding(Node) then + begin + NeedUpdate := True; + // expand the node, need to adjust the height + if not (vsInitialized in Node.States) then + InitNode(Node); + if (vsHasChildren in Node.States) and (Node.ChildCount = 0) then + InitChildren(Node); + + // Avoid setting the vsExpanded style if there are no child nodes. + if Node.ChildCount > 0 then + begin + // Iterate through the child nodes without initializing them. We have to determine the entire height. + Child := Node.FirstChild; + repeat + if vsVisible in Child.States then + begin + // Ensure the item height is measured + MeasureItemHeight(Canvas, Child); + + Inc(HeightDelta, Child.TotalHeight); + end; + Child := Child.NextSibling; + until Child = nil; + + // Getting the display rectangle is already done here as it is needed for toChildrenAbove in any case. + if (toChildrenAbove in FOptions.FPaintOptions) or (FUpdateCount = 0) then + begin + with ToggleData do + begin + R1 := GetDisplayRect(Node, NoColumn, False); + Mode2 := tamNoScroll; + TotalFit := HeightDelta + Integer(NodeHeight[Node]) <= ClientHeight; + + if toChildrenAbove in FOptions.FPaintOptions then + begin + // The main goal with toChildrenAbove being set is to keep the nodes visual position so the user does + // not get confused. Therefore we need to scroll the view when the expanding is done. + PosHoldable := TotalFit and (Integer(FRangeY) - ClientHeight >= 0) ; + ChildrenInView := (R1.Top - HeightDelta) >= 0; + NodeInView := R1.Bottom <= ClientHeight; + end + else + begin + PosHoldable := TotalFit; + ChildrenInView := R1.Bottom + HeightDelta <= ClientHeight; + end; + + R1.Bottom := ClientHeight; + end; + end; + + if FUpdateCount = 0 then + begin + // Do animated expanding if enabled. + if (ToggleData.R1.Top < ClientHeight) and ([tsPainting, tsExpanding] * FStates = []) and + (toAnimatedToggle in FOptions.FAnimationOptions)then + begin + Application.CancelHint; + UpdateWindow(Handle); + // animated expanding + with ToggleData do + begin + if toChildrenAbove in FOptions.FPaintOptions then + begin + // At first check if we hold the position, which is the most common case. + if not (toAdvancedAnimatedToggle in FOptions.FAnimationOptions) or + (PosHoldable and ( (NodeInView and ChildrenInView) or not + (toAutoScrollOnExpand in FOptions.FAutoOptions) )) then + begin + Mode1 := tamScrollUp; + R1 := Rect(R1.Left, 0, R1.Right, R1.Top); + StepsR1 := Min(HeightDelta, R1.Bottom); + end + else + begin + // If we will not hold the node's visual position we mostly scroll in both directions. + Mode1 := tamScrollDown; + Mode2 := tamScrollUp; + R2 := Rect(R1.Left, 0, R1.Right, R1.Top); + if not (toAutoScrollOnExpand in FOptions.FAutoOptions) then + begin + // If we shall not or cannot scroll to the desired extent we calculate the new position (with + // max FOffsetY applied) and animate it that way. + StepsR1 := -FOffsetY - Max(Integer(FRangeY) + HeightDelta - ClientHeight, 0) + HeightDelta; + if (Integer(FRangeY) + HeightDelta - ClientHeight) <= 0 then + Mode2 := tamNoScroll + else + StepsR2 := Min(Integer(FRangeY) + HeightDelta - ClientHeight, R2.Bottom); + end + else + begin + if TotalFit and NodeInView and (Integer(FRangeY) + HeightDelta > ClientHeight) then + begin + // If the whole subtree will fit into the client area and the node is currently fully visible, + // the first child will be made the top node if possible. + if HeightDelta >= R1.Top then + StepsR1 := Abs(R1.Top - HeightDelta) + else + StepsR1 := ClientHeight - Integer(FRangeY); + end + else + if Integer(FRangeY) + HeightDelta <= ClientHeight then + begin + // We cannot make the first child the top node as we cannot scroll to that extent, + // so we do a simple scroll down. + Mode2 := tamNoScroll; + StepsR1 := HeightDelta; + end + else + // If the subtree does not fit into the client area at once, the expanded node will + // be made the bottom node. + StepsR1 := ClientHeight - R1.Top - Integer(NodeHeight[Node]); + + if Mode2 <> tamNoScroll then + begin + if StepsR1 > 0 then + StepsR2 := Min(R1.Top, HeightDelta - StepsR1) + else + begin + // If the node is already at the bottom scrolling is needed. + Mode1 := tamNoScroll; + StepsR2 := Min(HeightDelta, R1.Bottom); + end; + end; + end; + end; + end + else + begin + // toChildrenAbove is not set. + if (PosHoldable and ChildrenInView) or not (toAutoScrollOnExpand in FOptions.FAutoOptions) or not + (toAdvancedAnimatedToggle in FOptions.FAnimationOptions) or (R1.Top <= 0) then + begin + // If the node will stay at its visual position, do a simple down-scroll. + Mode1 := tamScrollDown; + Inc(R1.Top, NodeHeight[Node]); + StepsR1 := Min(R1.Bottom - R1.Top, HeightDelta); + end + else + begin + // We will not hold the nodes visual position so perform a double scroll. + Mode1 := tamScrollUp; + Mode2 := tamScrollDown; + + R1.Bottom := R1.Top + Integer(NodeHeight[Node]) + 1; + R1.Top := 0; + R2 := Rect(R1.Left, R1.Bottom, R1.Right, ClientHeight); + + StepsR1 := Min(HeightDelta - (ClientHeight - R2.Top), R1.Bottom - Integer(NodeHeight[Node])); + StepsR2 := ClientHeight - R2.Top; + end; + end; + + if ClientHeight >= R1.Top then + begin + PrepareAnimation; + try + Animate(Steps, FAnimationDuration, ToggleCallback, @ToggleData); + finally + ReleaseDC(Window, DC); + end; + end; + end; + end; + end; + + Include(Node.States, vsExpanded); + AdjustTotalHeight(Node, HeightDelta, True); + if FullyVisible[Node] then + Inc(FVisibleCount, CountVisibleChildren(Node)); + + DoExpanded(Node); + end; + end; + + if NeedUpdate then + begin + InvalidateCache; + if FUpdateCount = 0 then + begin + ValidateCache; + if Node.ChildCount > 0 then + begin + UpdateRanges; + + if [tsPainting, tsExpanding] * FStates = [] then + begin + if (vsExpanded in Node.States) and ((toAutoScrollOnExpand in FOptions.FAutoOptions) or + (toChildrenAbove in FOptions.FPaintOptions)) then + begin + if toChildrenAbove in FOptions.FPaintOptions then + begin + NeedFullInvalidate := True; + if (PosHoldable and ChildrenInView and NodeInView) or not + (toAutoScrollOnExpand in FOptions.FAutoOptions) then + SetOffsetY(FOffsetY - Integer(HeightDelta)) + else + if TotalFit and NodeInView then + begin + FirstVisible := GetFirstVisible(Node, True); + if Assigned(FirstVisible) then // otherwise there is no visible child at all + SetOffsetY(FOffsetY - GetDisplayRect(FirstVisible, NoColumn, False).Top) + end else + BottomNode := Node; + end + else + begin + // Scroll as much child nodes into view as possible if the node has been expanded. + if PosHoldable then + NeedFullInvalidate := ScrollIntoView(GetLastVisible(Node, True), False) + else + begin + TopNode := Node; + NeedFullInvalidate := True; + end; + end; + end + else + begin + // If we have collapsed the node or toAutoScrollOnExpand is not set, we try to keep the nodes + // visual position. + if toChildrenAbove in FOptions.FPaintOptions then + SetOffsetY(FOffsetY - Integer(HeightDelta)); + NeedFullInvalidate := True; + end; + end; + + UpdateScrollbars(True); + + // Check for automatically scrolled tree. + if NeedFullInvalidate then + Invalidate + else + InvalidateToBottom(Node); + end + else + InvalidateNode(Node); + end + else + UpdateRanges; + end; + + finally + Exclude(Node.States, vsToggling); + if not TogglingTree then + DoStateChange([], [tsToggling]); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.UpdateAction(Action: TBasicAction): Boolean; + +// Support for standard actions. + +begin + if not Focused then + Result := inherited UpdateAction(Action) + else + begin + Result := (Action is TEditCut) or (Action is TEditCopy) or (Action is TEditDelete); + + if Result then + TAction(Action).Enabled := (FSelectionCount > 0) and ((Action is TEditDelete) or (FClipboardFormats.Count > 0)) + else + begin + Result := Action is TEditPaste; + if Result then + TAction(Action).Enabled := True + else + begin + Result := Action is TEditSelectAll; + if Result then + TAction(Action).Enabled := (toMultiSelect in FOptions.FSelectionOptions) and (FVisibleCount > 0) + else + Result := inherited UpdateAction(Action); + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateHorizontalRange; + +begin + if FHeader.UseColumns then + FRangeX := FHeader.FColumns.TotalWidth + else + FRangeX := GetMaxRightExtend; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateHorizontalScrollBar(DoRepaint: Boolean); + +var + ScrollInfo: TScrollInfo; + +begin + UpdateHorizontalRange; + + if tsUpdating in FStates then + exit; + + // Adjust effect scroll offset depending on bidi mode. + if UseRightToLeftAlignment then + FEffectiveOffsetX := Integer(FRangeX) - ClientWidth + FOffsetX + else + FEffectiveOffsetX := -FOffsetX; + + if FScrollBarOptions.ScrollBars in [ssHorizontal, ssBoth] then + begin + ZeroMemory (@ScrollInfo, SizeOf(ScrollInfo)); + ScrollInfo.cbSize := SizeOf(ScrollInfo); + ScrollInfo.fMask := SIF_ALL; + GetScrollInfo(Handle, SB_HORZ, ScrollInfo); + + if (Integer(FRangeX) > ClientWidth) or FScrollBarOptions.AlwaysVisible then + begin + DoShowScrollBar(SB_HORZ, True); + + ScrollInfo.nMin := 0; + ScrollInfo.nMax := FRangeX; + ScrollInfo.nPos := FEffectiveOffsetX; + ScrollInfo.nPage := Max(0, ClientWidth + 1); + + ScrollInfo.fMask := SIF_ALL or ScrollMasks[FScrollBarOptions.AlwaysVisible]; + SetScrollInfo(Handle, SB_HORZ, ScrollInfo, DoRepaint); + end + else + begin + ScrollInfo.nMin := 0; + ScrollInfo.nMax := 0; + ScrollInfo.nPos := 0; + ScrollInfo.nPage := 0; + DoShowScrollBar(SB_HORZ, False); + SetScrollInfo(Handle, SB_HORZ, ScrollInfo, False); + end; + + // Since the position is automatically changed if it doesn't meet the range + // we better read the current position back to stay synchronized. + FEffectiveOffsetX := GetScrollPos(Handle, SB_HORZ); + if UseRightToLeftAlignment then + SetOffsetX(-Integer(FRangeX) + ClientWidth + FEffectiveOffsetX) + else + SetOffsetX(-FEffectiveOffsetX); + end + else + begin + DoShowScrollBar(SB_HORZ, False); + + // Reset the current horizontal offset to account for window resize etc. + SetOffsetX(FOffsetX); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateRanges; + +begin + UpdateVerticalRange; + UpdateHorizontalRange; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateScrollBars(DoRepaint: Boolean); + +// adjusts scrollbars to reflect current size and paint offset of the tree + +begin + if HandleAllocated then + begin + UpdateVerticalScrollBar(DoRepaint); + UpdateHorizontalScrollBar(DoRepaint); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateVerticalRange; + +begin + // Total node height includes the height of the invisible root node. + if FRoot.TotalHeight < FDefaultNodeHeight then + FRoot.TotalHeight := FDefaultNodeHeight; + FRangeY := FRoot.TotalHeight - FRoot.NodeHeight + FBottomSpace; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.UpdateVerticalScrollBar(DoRepaint: Boolean); + +var + ScrollInfo: TScrollInfo; + +begin + UpdateVerticalRange; + + if tsUpdating in FStates then + exit; + + if FScrollBarOptions.ScrollBars in [ssVertical, ssBoth] then + begin + ScrollInfo.cbSize := SizeOf(ScrollInfo); + ScrollInfo.fMask := SIF_ALL; + GetScrollInfo(Handle, SB_VERT, ScrollInfo); + + if (Integer(FRangeY) > ClientHeight) or FScrollBarOptions.AlwaysVisible then + begin + DoShowScrollBar(SB_VERT, True); + + ScrollInfo.nMin := 0; + ScrollInfo.nMax := FRangeY; + ScrollInfo.nPos := -FOffsetY; + ScrollInfo.nPage := Max(0, ClientHeight + 1); + + ScrollInfo.fMask := SIF_ALL or ScrollMasks[FScrollBarOptions.AlwaysVisible]; + SetScrollInfo(Handle, SB_VERT, ScrollInfo, DoRepaint); + end + else + begin + ScrollInfo.nMin := 0; + ScrollInfo.nMax := 0; + ScrollInfo.nPos := 0; + ScrollInfo.nPage := 0; + DoShowScrollBar(SB_VERT, False); + SetScrollInfo(Handle, SB_VERT, ScrollInfo, False); + end; + + // Since the position is automatically changed if it doesn't meet the range + // we better read the current position back to stay synchronized. + SetOffsetY(-GetScrollPos(Handle, SB_VERT)); + end + else + begin + DoShowScrollbar(SB_VERT, False); + + // Reset the current vertical offset to account for window resize etc. + SetOffsetY(FOffsetY); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TBaseVirtualTree.UseRightToLeftReading: Boolean; + +// The tree can handle right-to-left reading also on non-middle-east systems, so we cannot use the same function as +// it is implemented in TControl. + +begin + Result := BiDiMode <> bdLeftToRight; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ValidateChildren(Node: PVirtualNode; Recursive: Boolean); + +// Ensures that the children of the given node (and all their children, if Recursive is True) are initialized. +// Node must already be initialized + +var + Child: PVirtualNode; + +begin + if Node = nil then + Node := FRoot; + + if (vsHasChildren in Node.States) and (Node.ChildCount = 0) then + InitChildren(Node); + Child := Node.FirstChild; + while Assigned(Child) do + begin + ValidateNode(Child, Recursive); + Child := Child.NextSibling; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TBaseVirtualTree.ValidateNode(Node: PVirtualNode; Recursive: Boolean); + +// Ensures that the given node (and all its children, if Recursive is True) are initialized. + +var + Child: PVirtualNode; + +begin + if Node = nil then + Node := FRoot + else + if not (vsInitialized in Node.States) then + InitNode(Node); + + if Recursive then + begin + if (vsHasChildren in Node.States) and (Node.ChildCount = 0) then + InitChildren(Node); + Child := Node.FirstChild; + while Assigned(Child) do + begin + ValidateNode(Child, recursive); + Child := Child.NextSibling; + end; + end; +end; + +//----------------- TCustomStringTreeOptions --------------------------------------------------------------------------- + +constructor TCustomStringTreeOptions.Create(AOwner: TBaseVirtualTree); + +begin + inherited; + + FStringOptions := DefaultStringOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomStringTreeOptions.SetStringOptions(const Value: TVTStringOptions); + +var + ChangedOptions: TVTStringOptions; + +begin + if FStringOptions <> Value then + begin + // Exclusive ORing to get all entries wich are in either set but not in both. + ChangedOptions := FStringOptions + Value - (FStringOptions * Value); + FStringOptions := Value; + with FOwner do + if (toShowStaticText in ChangedOptions) and not (csLoading in ComponentState) and HandleAllocated then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomStringTreeOptions.AssignTo(Dest: TPersistent); + +begin + if Dest is TCustomStringTreeOptions then + begin + with Dest as TCustomStringTreeOptions do + StringOptions := Self.StringOptions; + end; + + // Let ancestors assign their options to the destination class. + inherited; +end; + +//----------------- TVTEdit -------------------------------------------------------------------------------------------- + +// Implementation of a generic node caption editor. + +constructor TVTEdit.Create(Link: TStringEditLink); + +begin + inherited Create(nil); + ShowHint := False; + ParentShowHint := False; + // This assignment increases the reference count for the interface. + FRefLink := Link; + // This reference is used to access the link. + FLink := Link; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.CMAutoAdjust(var Message: TMessage); + +begin + AutoAdjustSize; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.CMExit(var Message: TMessage); + +begin + if Assigned(FLink) and not FLink.FStopping then + with FLink, FTree do + begin + if (toAutoAcceptEditChange in TreeOptions.StringOptions) then + DoEndEdit + else + DoCancelEdit; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.CMRelease(var Message: TMessage); + +begin + Free; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.CNCommand(var Message: TWMCommand); + +begin + if Assigned(FLink) and Assigned(FLink.FTree) and (Message.NotifyCode = EN_UPDATE) and + not (vsMultiline in FLink.FNode.States) then + // Instead directly calling AutoAdjustSize it is necessary on Win9x/Me to decouple this notification message + // and eventual resizing. Hence we use a message to accomplish that. + AutoAdjustSize() +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.WMChar(var Message: TWMChar); + +begin + if not (Message.CharCode in [VK_ESCAPE, VK_TAB]) then + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.WMDestroy(var Message: TWMDestroy); + +begin + // If editing stopped by other means than accept or cancel then we have to do default processing for + // pending changes. + if Assigned(FLink) and not FLink.FStopping then + begin + with FLink, FTree do + begin + if (toAutoAcceptEditChange in TreeOptions.StringOptions) and Modified then + Text[FNode, FColumn] := FEdit.Text; + end; + FLink := nil; + FRefLink := nil; + end; + + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.WMGetDlgCode(var Message: TWMGetDlgCode); + +begin + inherited; + + Message.Result := Message.Result or DLGC_WANTALLKEYS or DLGC_WANTTAB or DLGC_WANTARROWS; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.WMKeyDown(var Message: TWMKeyDown); + +// Handles some control keys. + +var + Shift: TShiftState; + EndEdit: Boolean; + Tree: TBaseVirtualTree; + NextNode: PVirtualNode; +begin + Tree := FLink.FTree; + case Message.CharCode of + VK_ESCAPE: + begin + Tree.DoCancelEdit; + Tree.SetFocus; + end; + VK_RETURN: + begin + EndEdit := not (vsMultiline in FLink.FNode.States); + if not EndEdit then + begin + // If a multiline node is being edited the finish editing only if Ctrl+Enter was pressed, + // otherwise allow to insert line breaks into the text. + Shift := KeyDataToShiftState(Message.KeyData); + EndEdit := ssCtrl in Shift; + end; + if EndEdit then + begin + Tree := FLink.FTree; + FLink.FTree.InvalidateNode(FLink.FNode); + FLink.FTree.DoEndEdit; + Tree.SetFocus; + end; + end; + VK_UP: + begin + if not (vsMultiline in FLink.FNode.States) then + Message.CharCode := VK_LEFT; + inherited; + end; + VK_DOWN: + begin + if not (vsMultiline in FLink.FNode.States) then + Message.CharCode := VK_RIGHT; + inherited; + end; + VK_TAB: + begin + if Tree.IsEditing then begin + Tree.InvalidateNode(FLink.FNode); + NextNode := Tree.GetNextVisible(FLink.FNode, True); + Tree.EndEditNode; + Tree.FocusedNode := NextNode; + if Tree.CanEdit(Tree.FocusedNode, Tree.FocusedColumn) then + Tree.DoEdit; + end; + end; + else + inherited; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.AutoAdjustSize; + +// Changes the size of the edit to accomodate as much as possible of its text within its container window. +// NewChar describes the next character which will be added to the edit's text. + +var + DC: HDC; + Size: TSize; + LastFont: THandle; + +begin + if not (vsMultiline in FLink.FNode.States) then + begin + // avoid flicker + SendMessage(Handle, WM_SETREDRAW, 0, 0); + + DC := GetDC(Handle); + LastFont := SelectObject(DC, Font.Handle); + try + // Read needed space for the current text. + {$ifdef TntSupport} + GetTextExtentPoint32W(DC, PWideChar(Text), Length(Text), Size); + {$else} + GetTextExtentPoint32(DC, PChar(Text), Length(Text), Size); + {$endif TntSupport} + Inc(Size.cx, 2 * FLink.FTree.FTextMargin); + + // Repaint associated node if the edit becomes smaller. + if Size.cx < Width then + FLink.FTree.InvalidateNode(FLink.FNode); + + if FLink.FAlignment = taRightJustify then + FLink.SetBounds(Rect(Left + Width - Size.cx, Top, Left + Width, Top + Height)) + else + FLink.SetBounds(Rect(Left, Top, Left + Size.cx, Top + Height)); + finally + SelectObject(DC, LastFont); + ReleaseDC(Handle, DC); + SendMessage(Handle, WM_SETREDRAW, 1, 0); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.CreateParams(var Params: TCreateParams); + +begin + inherited; + + // Only with multiline style we can use the text formatting rectangle. + // This does not harm formatting as single line control, if we don't use word wrapping. + with Params do + begin + Style := Style or ES_MULTILINE; + if vsMultiline in FLink.FNode.States then + Style := Style and not (ES_AUTOHSCROLL or WS_HSCROLL) or WS_VSCROLL or ES_AUTOVSCROLL; + if tsUseThemes in FLink.FTree.FStates then + begin + Style := Style and not WS_BORDER; + ExStyle := ExStyle or WS_EX_CLIENTEDGE; + end + else + begin + Style := Style or WS_BORDER; + ExStyle := ExStyle and not WS_EX_CLIENTEDGE; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVTEdit.Release; + +begin + if HandleAllocated then + PostMessage(Handle, CM_RELEASE, 0, 0); +end; + +//----------------- TStringEditLink ------------------------------------------------------------------------------------ + +constructor TStringEditLink.Create; + +begin + inherited; + FEdit := TVTEdit.Create(Self); + with FEdit do + begin + Visible := False; + BorderStyle := bsSingle; + AutoSize := False; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +destructor TStringEditLink.Destroy; + +begin + FEdit.Release; + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TStringEditLink.BeginEdit: Boolean; + +// Notifies the edit link that editing can start now. descendants may cancel node edit +// by returning False. + +begin + Result := not FStopping; + if Result then + begin + FEdit.Show; + FEdit.SelectAll; + FEdit.SetFocus; + FEdit.AutoAdjustSize; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TStringEditLink.SetEdit(const Value: TVTEdit); + +begin + if Assigned(FEdit) then + FEdit.Free; + FEdit := Value; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TStringEditLink.CancelEdit: Boolean; + +begin + Result := not FStopping; + if Result then + begin + FStopping := True; + FEdit.Hide; + FTree.CancelEditNode; + FEdit.FLink := nil; + FEdit.FRefLink := nil; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TStringEditLink.EndEdit: Boolean; + +begin + Result := not FStopping; + if Result then + try + FStopping := True; + if FEdit.Modified then + FTree.Text[FNode, FColumn] := FEdit.Text; + FEdit.Hide; + FEdit.FLink := nil; + FEdit.FRefLink := nil; + except + FStopping := False; + raise; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TStringEditLink.GetBounds: TRect; + +begin + Result := FEdit.BoundsRect; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TStringEditLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; + +// Retrieves the true text bounds from the owner tree. + +var + Text: UnicodeString; + +begin + Result := Tree is TCustomVirtualStringTree; + if Result then + begin + FTree := Tree as TCustomVirtualStringTree; + FNode := Node; + FColumn := Column; + // Initial size, font and text of the node. + FTree.GetTextInfo(Node, Column, FEdit.Font, FTextBounds, Text); + FEdit.Font.Color := clWindowText; + FEdit.Parent := Tree; + FEdit.RecreateWnd; + FEdit.HandleNeeded; + FEdit.Text := Text; + + if Column <= NoColumn then + begin + FEdit.BidiMode := FTree.BidiMode; + FAlignment := FTree.Alignment; + end + else + begin + FEdit.BidiMode := FTree.Header.Columns[Column].BidiMode; + FAlignment := FTree.Header.Columns[Column].Alignment; + end; + + if FEdit.BidiMode <> bdLeftToRight then + ChangeBidiModeAlignment(FAlignment); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TStringEditLink.ProcessMessage(var Message: TMessage); + +begin + FEdit.WindowProc(Message); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TStringEditLink.SetBounds(R: TRect); + +// Sets the outer bounds of the edit control and the actual edit area in the control. + +var + lOffset: Integer; + +begin + if not FStopping then + begin + // Set the edit's bounds but make sure there's a minimum width and the right border does not + // extend beyond the parent's left/right border. + if R.Left < 0 then + R.Left := 0; + if R.Right - R.Left < 30 then + begin + if FAlignment = taRightJustify then + R.Left := R.Right - 30 + else + R.Right := R.Left + 30; + end; + if R.Right > FTree.ClientWidth then + R.Right := FTree.ClientWidth; + FEdit.BoundsRect := R; + + // The selected text shall exclude the text margins and be centered vertically. + // We have to take out the two pixel border of the edit control as well as a one pixel "edit border" the + // control leaves around the (selected) text. + R := FEdit.ClientRect; + lOffset := 2; + if tsUseThemes in FTree.FStates then + Inc(lOffset); + InflateRect(R, -FTree.FTextMargin + lOffset, lOffset); + if not (vsMultiline in FNode.States) then + OffsetRect(R, 0, FTextBounds.Top - FEdit.Top); + + SendMessage(FEdit.Handle, EM_SETRECTNP, 0, LPARAM(@R)); + end; +end; + +//----------------- TCustomVirtualString ------------------------------------------------------------------------------- + +constructor TCustomVirtualStringTree.Create(AOwner: TComponent); + +begin + inherited; + + FDefaultText := 'Node'; + FInternalDataOffset := AllocateInternalDataArea(SizeOf(Cardinal)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.GetRenderStartValues(Source: TVSTTextSourceType; var Node: PVirtualNode; + var NextNodeProc: TGetNextNodeProc); + +begin + case Source of + tstInitialized: + begin + Node := GetFirstInitialized; + NextNodeProc := GetNextInitialized; + end; + tstSelected: + begin + Node := GetFirstSelected; + NextNodeProc := GetNextSelected; + end; + tstCutCopySet: + begin + Node := GetFirstCutCopy; + NextNodeProc := GetNextCutCopy; + end; + tstVisible: + begin + Node := GetFirstVisible(nil, True); + NextNodeProc := GetNextVisible; + end; + tstChecked: + begin + Node := GetFirstChecked; + NextNodeProc := GetNextChecked; + end; + else // tstAll + Node := GetFirst; + NextNodeProc := GetNext; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.GetDataFromGrid(const AStrings: TStringList; + const IncludeHeading: Boolean); +var + LColIndex : Integer; + LStartIndex : Integer; + LAddString : String; + LCellText : String; + LChildNode : PVirtualNode; +begin + { Start from the First column. } + LStartIndex := 0; + + { Do it for Header first } + if IncludeHeading then + begin + LAddString := EmptyStr; + for LColIndex := LStartIndex to Pred(Header.Columns.Count) do + begin + if (LColIndex > LStartIndex) then + LAddString := LAddString + ','; + LAddString := LAddString + AnsiQuotedStr(Header.Columns.Items[LColIndex].Text, '"'); + end;//for + AStrings.Add(LAddString); + end;//if + + { Loop thru the virtual tree for Data } + LChildNode := GetFirst; + while Assigned(LChildNode) do + begin + LAddString := EmptyStr; + + { Read for each column and then populate the text } + for LColIndex := LStartIndex to Pred(Header.Columns.Count) do + begin + LCellText := Text[LChildNode, LColIndex]; + if (LCellText = EmptyStr) then + LCellText := ' '; + if (LColIndex > LStartIndex) then + LAddString := LAddString + ','; + LAddString := LAddString + AnsiQuotedStr(LCellText, '"'); + end;//for - Header.Columns.Count + + AStrings.Add(LAddString); + LChildNode := LChildNode.NextSibling; + end;//while Assigned(LChildNode); +end; + +function TCustomVirtualStringTree.GetImageText(Node: PVirtualNode; + Kind: TVTImageKind; Column: TColumnIndex): UnicodeString; +begin + Assert(Assigned(Node), 'Node must not be nil.'); + + if not (vsInitialized in Node.States) then + InitNode(Node); + Result := ''; + + DoGetImageText(Node, Kind, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.GetOptions: TCustomStringTreeOptions; + +begin + Result := FOptions as TCustomStringTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.GetText(Node: PVirtualNode; Column: TColumnIndex): UnicodeString; + +begin + Assert(Assigned(Node), 'Node must not be nil.'); + + if not (vsInitialized in Node.States) then + InitNode(Node); + Result := FDefaultText; + + DoGetText(Node, Column, ttNormal, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.InitializeTextProperties(var PaintInfo: TVTPaintInfo); + +// Initializes default values for customization in PaintNormalText. + +begin + with PaintInfo do + begin + // Set default font values first. + Canvas.Font := Font; + + if (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) then + begin + if not (tsUseExplorerTheme in FStates) then + begin + Canvas.Font.Style := Canvas.Font.Style + [fsUnderline]; + Canvas.Font.Color := FColors.HotColor; + end; + end; + + // Change the font color only if the node also is drawn in selected style. + if poDrawSelection in PaintOptions then + begin + if (Column = FFocusedColumn) or (toFullRowSelect in FOptions.FSelectionOptions) then + begin + if Node = FDropTargetNode then + begin + if ((FLastDropMode = dmOnNode) or (vsSelected in Node.States)) and not + (tsUseExplorerTheme in FStates) then + Canvas.Font.Color := FColors.SelectionTextColor; + end + else + if vsSelected in Node.States then + begin + if (Focused or (toPopupMode in FOptions.FPaintOptions)) and not + (tsUseExplorerTheme in FStates) then + Canvas.Font.Color := FColors.SelectionTextColor; + end; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.PaintNormalText(var PaintInfo: TVTPaintInfo; TextOutFlags: Integer; + Text: UnicodeString); + +// This method is responsible for painting the given text to target canvas (under consideration of the given rectangles). +// The text drawn here is considered as the normal text in a node. +// Note: NodeWidth is the actual width of the text to be drawn. This does not necessarily correspond to the width of +// the node rectangle. The clipping rectangle comprises the entire node (including tree lines, buttons etc.). + +var + TripleWidth: Integer; + R: TRect; + DrawFormat: Cardinal; + Size: TSize; + +begin + InitializeTextProperties(PaintInfo); + with PaintInfo do + begin + R := ContentRect; + Canvas.TextFlags := 0; + + // Multiline nodes don't need special font handling or text manipulation. + // Note: multiline support requires the Unicode version of DrawText, which is able to do word breaking. + // The emulation in this unit does not support this so we have to use the OS version. However + // DrawTextW is only available on NT/2000/XP and up. Hence there is only partial multiline support + // for 9x/Me. + if vsMultiline in Node.States then + begin + InflateRect(R, -FTextMargin, 0); + DoPaintText(Node, Canvas, Column, ttNormal); + // Disabled node color overrides all other variants. + if (vsDisabled in Node.States) or not Enabled then + Canvas.Font.Color := FColors.DisabledColor; + + // The edit control flag will ensure that no partial line is displayed, that is, only lines + // which are (vertically) fully visible are drawn. + DrawFormat := DT_NOPREFIX or DT_WORDBREAK or DT_END_ELLIPSIS or DT_EDITCONTROL or AlignmentToDrawFlag[Alignment]; + if BidiMode <> bdLeftToRight then + DrawFormat := DrawFormat or DT_RTLREADING; + end + else + begin + InflateRect(R, -FTextMargin, 0); + FFontChanged := False; + TripleWidth := FEllipsisWidth; + DoPaintText(Node, Canvas, Column, ttNormal); + if FFontChanged then + begin + // If the font has been changed then the ellipsis width must be recalculated. + TripleWidth := 0; + // Recalculate also the width of the normal text. + GetTextExtentPoint32W(Canvas.Handle, PWideChar(Text), Length(Text), Size); + NodeWidth := Size.cx + 2 * FTextMargin; + end; + + // Disabled node color overrides all other variants. + if (vsDisabled in Node.States) or not Enabled then + Canvas.Font.Color := FColors.DisabledColor; + + DrawFormat := DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE; + if BidiMode <> bdLeftToRight then + DrawFormat := DrawFormat or DT_RTLREADING; + // Check if the text must be shortend. + if (Column > -1) and ((NodeWidth - 2 * FTextMargin) > R.Right - R.Left) then + begin + Text := DoShortenString(Canvas, Node, Column, Text, R.Right - R.Left, TripleWidth); + if Alignment = taRightJustify then + DrawFormat := DrawFormat or DT_RIGHT + else + DrawFormat := DrawFormat or DT_LEFT; + end + else + DrawFormat := DrawFormat or AlignmentToDrawFlag[Alignment]; + end; + + if Canvas.TextFlags and ETO_OPAQUE = 0 then + SetBkMode(Canvas.Handle, TRANSPARENT) + else + SetBkMode(Canvas.Handle, OPAQUE); + + DoTextDrawing(PaintInfo, Text, R, DrawFormat); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.PaintStaticText(const PaintInfo: TVTPaintInfo; TextOutFlags: Integer; + const Text: UnicodeString); + +// This method retrives and draws the static text bound to a particular node. + +var + R: TRect; + DrawFormat: Cardinal; + +begin + with PaintInfo do + begin + Canvas.Font := Font; + if toFullRowSelect in FOptions.FSelectionOptions then + begin + if Node = FDropTargetNode then + begin + if (FLastDropMode = dmOnNode) or (vsSelected in Node.States) then + Canvas.Font.Color := FColors.SelectionTextColor + else + Canvas.Font.Color := Font.Color; + end + else + if vsSelected in Node.States then + begin + if Focused or (toPopupMode in FOptions.FPaintOptions) then + Canvas.Font.Color := FColors.SelectionTextColor + else + Canvas.Font.Color := Font.Color; + end; + end; + + DrawFormat := DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE; + Canvas.TextFlags := 0; + DoPaintText(Node, Canvas, Column, ttStatic); + + // Disabled node color overrides all other variants. + if (vsDisabled in Node.States) or not Enabled then + Canvas.Font.Color := FColors.DisabledColor; + + R := ContentRect; + if Alignment = taRightJustify then + Dec(R.Right, NodeWidth + FTextMargin) + else + Inc(R.Left, NodeWidth + FTextMargin); + + if Canvas.TextFlags and ETO_OPAQUE = 0 then + SetBkMode(Canvas.Handle, TRANSPARENT) + else + SetBkMode(Canvas.Handle, OPAQUE); + Windows.DrawTextW(Canvas.Handle, PWideChar(Text), Length(Text), R, DrawFormat); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.ReadText(Reader: TReader); + +begin + case Reader.NextValue of + vaLString, vaString: + SetDefaultText(Reader.ReadString); + else + SetDefaultText(Reader.ReadWideString); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.SaveToCSVFile( + const FileNameWithPath: TFileName; const IncludeHeading: Boolean): Boolean; +var + LResultList : TStringList; +begin + Result := False; + if (FileNameWithPath = '') then Exit; + + LResultList := TStringList.Create; + try + { Get the data from grid. } + GetDataFromGrid(LResultList, IncludeHeading); + { Save File to Disk } + LResultList.SaveToFile(FileNameWithPath); + Result := True; + finally + FreeAndNil(LResultList); + end;//try-finally +end; + +procedure TCustomVirtualStringTree.SetDefaultText(const Value: UnicodeString); + +begin + if FDefaultText <> Value then + begin + FDefaultText := Value; + if not (csLoading in ComponentState) then + Invalidate; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.SetOptions(const Value: TCustomStringTreeOptions); + +begin + FOptions.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.SetText(Node: PVirtualNode; Column: TColumnIndex; const Value: UnicodeString); + +begin + DoNewText(Node, Column, Value); + InvalidateNode(Node); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.WriteText(Writer: TWriter); + +begin + Writer.WriteWideString(FDefaultText); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.WMSetFont(var Msg: TWMSetFont); + +// Whenever a new font is applied to the tree some default values are determined to avoid frequent +// determination of the same value. + +var + MemDC: HDC; + Run: PVirtualNode; + TM: TTextMetric; + Size: TSize; + Data: PInteger; + +begin + inherited; + + MemDC := CreateCompatibleDC(0); + try + SelectObject(MemDC, Msg.Font); + GetTextMetrics(MemDC, TM); + FTextHeight := TM.tmHeight; + + GetTextExtentPoint32W(MemDC, '...', 3, Size); + FEllipsisWidth := Size.cx; + finally + DeleteDC(MemDC); + end; + + // Have to reset all node widths. + Run := FRoot.FirstChild; + while Assigned(Run) do + begin + Data := InternalData(Run); + if Assigned(Data) then + Data^ := 0; + Run := GetNextNoInit(Run); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.AdjustPaintCellRect(var PaintInfo: TVTPaintInfo; var NextNonEmpty: TColumnIndex); + +// In the case a node spans several columns (if enabled) we need to determine how many columns. +// Note: the autospan feature can only be used with left-to-right layout. + +begin + if (toAutoSpanColumns in FOptions.FAutoOptions) and FHeader.UseColumns and (PaintInfo.BidiMode = bdLeftToRight) then + with FHeader.FColumns, PaintInfo do + begin + // Start with the directly following column. + NextNonEmpty := GetNextVisibleColumn(Column); + + // Auto spanning columns can only be used for left-to-right directionality because the tree is drawn + // from left to right. For RTL directionality it would be necessary to draw it from right to left. + // While this could be managed, it becomes impossible when directionality is mixed. + repeat + if (NextNonEmpty = InvalidColumn) or not ColumnIsEmpty(Node, NextNonEmpty) or + (Items[NextNonEmpty].BidiMode <> bdLeftToRight) then + Break; + Inc(CellRect.Right, Items[NextNonEmpty].Width); + NextNonEmpty := GetNextVisibleColumn(NextNonEmpty); + until False; + end + else + inherited; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.CalculateTextWidth(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + Text: UnicodeString): Integer; + +// Determines the width of the given text. + +begin + Result := 2 * FTextMargin; + if Length(Text) > 0 then + begin + Canvas.Font := Font; + DoPaintText(Node, Canvas, Column, ttNormal); + + Inc(Result, DoTextMeasuring(Canvas, Node, Column, Text).cx); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; + +// For hit tests it is necessary to consider cases where columns are empty and automatic column spanning is enabled. +// This method simply checks the given column's text and if this is empty then the column is considered as being empty. + +begin + Result := Length(Text[Node, Column]) = 0; + // If there is no text then let the ancestor decide if the column is to be considered as being empty + // (e.g. by asking the application). If there is text then the column is never be considered as being empty. + if Result then + Result := inherited ColumnIsEmpty(Node, Column); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DefineProperties(Filer: TFiler); + +begin + inherited; + + // Delphi still cannot handle wide strings properly while streaming + Filer.DefineProperty('WideDefaultText', ReadText, WriteText, FDefaultText <> 'Node'); + Filer.DefineProperty('StringOptions', ReadOldStringOptions, nil, False); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoCreateEditor(Node: PVirtualNode; Column: TColumnIndex): IVTEditLink; + +begin + Result := inherited DoCreateEditor(Node, Column); + // Enable generic label editing support if the application does not have own editors. + if Result = nil then + Result := TStringEditLink.Create; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoGetNodeHint(Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; + +begin + Result := inherited DoGetNodeHint(Node, Column, LineBreakStyle); + if Assigned(FOnGetHint) then + FOnGetHint(Self, Node, Column, LineBreakStyle, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoGetNodeTooltip(Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle): UnicodeString; + +begin + Result := inherited DoGetNodeToolTip(Node, Column, LineBreakStyle); + if Assigned(FOnGetHint) then + FOnGetHint(Self, Node, Column, LineBreakStyle, Result) + else + Result := Text[Node, Column]; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; + +// Returns the text width of the given node in pixels. +// This width is stored in the node's data member to increase access speed. + +var + Data: PInteger; + +begin + if (Column > NoColumn) and (vsMultiline in Node.States) then + Result := FHeader.Columns[Column].Width + else + begin + if Canvas = nil then + Canvas := Self.Canvas; + + if Column = FHeader.MainColumn then + begin + // Primary column or no columns. + Data := InternalData(Node); + if Assigned(Data) then + begin + Result := Data^; + if Result = 0 then + begin + Data^ := CalculateTextWidth(Canvas, Node, Column, Text[Node, Column]); + Result := Data^; + end; + end + else + Result := 0; + end + else + // any other column + Result := CalculateTextWidth(Canvas, Node, Column, Text[Node, Column]); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DoGetText(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; + var Text: UnicodeString); + +begin + if Assigned(FOnGetText) then + FOnGetText(Self, Node, Column, TextType, Text); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoIncrementalSearch(Node: PVirtualNode; const Text: UnicodeString): Integer; + +// Since the string tree has access to node text it can do incremental search on its own. Use the event to +// override the default behavior. + +begin + Result := 0; + if Assigned(FOnIncrementalSearch) then + FOnIncrementalSearch(Self, Node, Text, Result) + else + // Default behavior is to match the search string with the start of the node text. + if Pos(Text, GetText(Node, FocusedColumn)) <> 1 then + Result := 1; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DoNewText(Node: PVirtualNode; Column: TColumnIndex; Text: UnicodeString); + +begin + if Assigned(FOnNewText) then + FOnNewText(Self, Node, Column, Text); + + // The width might have changed, so update the scrollbar. + if FUpdateCount = 0 then + UpdateHorizontalScrollBar(True); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DoPaintNode(var PaintInfo: TVTPaintInfo); + +// Main output routine to print the text of the given node using the space provided in PaintInfo.ContentRect. + +var + S: UnicodeString; + TextOutFlags: Integer; + +begin + // Set a new OnChange event for the canvas' font so we know if the application changes it in the callbacks. + // This long winded procedure is necessary because font changes (as well as brush and pen changes) are + // unfortunately not announced via the Canvas.OnChange event. + RedirectFontChangeEvent(PaintInfo.Canvas); + + // Determine main text direction as well as other text properties. + TextOutFlags := ETO_CLIPPED or RTLFlag[PaintInfo.BidiMode <> bdLeftToRight]; + S := Text[PaintInfo.Node, PaintInfo.Column]; + + // Paint the normal text first... + if Length(S) > 0 then + PaintNormalText(PaintInfo, TextOutFlags, S); + + // ... and afterwards the static text if not centered and the node is not multiline enabled. + if (Alignment <> taCenter) and not (vsMultiline in PaintInfo.Node.States) and (toShowStaticText in TreeOptions.FStringOptions) then + begin + S := ''; + with PaintInfo do + DoGetText(Node, Column, ttStatic, S); + if Length(S) > 0 then + PaintStaticText(PaintInfo, TextOutFlags, S); + end; + RestoreFontChangeEvent(PaintInfo.Canvas); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DoPaintText(Node: PVirtualNode; const Canvas: TCanvas; Column: TColumnIndex; + TextType: TVSTTextType); + +begin + if Assigned(FOnPaintText) then + FOnPaintText(Self, Canvas, Node, Column, TextType); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoShortenString(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + const S: UnicodeString; Width: Integer; EllipsisWidth: Integer = 0): UnicodeString; + +var + Done: Boolean; + +begin + Done := False; + if Assigned(FOnShortenString) then + FOnShortenString(Self, Canvas, Node, Column, S, Width, Result, Done); + if not Done then + Result := ShortenString(Canvas.Handle, S, Width, EllipsisWidth); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.DoTextDrawing(var PaintInfo: TVTPaintInfo; Text: UnicodeString; CellRect: TRect; + DrawFormat: Cardinal); + +var + DefaultDraw: Boolean; + +begin + DefaultDraw := True; + if Assigned(FOnDrawText) then + FOnDrawText(Self, PaintInfo.Canvas, PaintInfo.Node, PaintInfo.Column, Text, CellRect, DefaultDraw); + if DefaultDraw then + Windows.DrawTextW(PaintInfo.Canvas.Handle, PWideChar(Text), Length(Text), CellRect, DrawFormat); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.DoTextMeasuring(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + Text: UnicodeString): TSize; + +var + R: TRect; + DrawFormat: Integer; + +begin + GetTextExtentPoint32W(Canvas.Handle, PWideChar(Text), Length(Text), Result); + if vsMultiLine in Node.States then + begin + DrawFormat := DT_CALCRECT or DT_NOPREFIX or DT_WORDBREAK or DT_END_ELLIPSIS or DT_EDITCONTROL or AlignmentToDrawFlag[Alignment]; + if BidiMode <> bdLeftToRight then + DrawFormat := DrawFormat or DT_RTLREADING; + + R := Rect(0, 0, Result.cx, MaxInt); + Windows.DrawTextW(Canvas.Handle, PWideChar(Text), Length(Text), R, DrawFormat); + Result.cx := R.Right - R.Left; + end; + if Assigned(FOnMeasureTextWidth) then + FOnMeasureTextWidth(Self, Canvas, Node, Column, Text, Result.cx); + if Assigned(FOnMeasureTextHeight) then + FOnMeasureTextHeight(Self, Canvas, Node, Column, Text, Result.cy); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.GetOptionsClass: TTreeOptionsClass; + +begin + Result := TCustomStringTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.InternalData(Node: PVirtualNode): Pointer; + +begin + if (Node = FRoot) or (Node = nil) then + Result := nil + else + Result := PByte(Node) + FInternalDataOffset; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.MainColumnChanged; + +var + Run: PVirtualNode; + Data: PInteger; + +begin + inherited; + + // Have to reset all node widths. + Run := FRoot.FirstChild; + while Assigned(Run) do + begin + Data := InternalData(Run); + if Assigned(Data) then + Data^ := 0; + Run := GetNextNoInit(Run); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ReadChunk(Stream: TStream; Version: Integer; Node: PVirtualNode; ChunkType, + ChunkSize: Integer): Boolean; + +// read in the caption chunk if there is one + +var + NewText: UnicodeString; + +begin + case ChunkType of + CaptionChunk: + begin + NewText := ''; + if ChunkSize > 0 then + begin + SetLength(NewText, ChunkSize div 2); + Stream.Read(PWideChar(NewText)^, ChunkSize); + end; + // Do a new text event regardless of the caption content to allow removing the default string. + Text[Node, FHeader.MainColumn] := NewText; + Result := True; + end; + else + Result := inherited ReadChunk(Stream, Version, Node, ChunkType, ChunkSize); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +type + TOldVTStringOption = (soSaveCaptions, soShowStaticText); + +procedure TCustomVirtualStringTree.ReadOldStringOptions(Reader: TReader); + +// Migration helper routine to silently convert forms containing the old tree options member into the new +// sub-options structure. + +var + OldOption: TOldVTStringOption; + EnumName: string; + +begin + // If we are at design time currently then let the designer know we changed something. + UpdateDesigner; + + // It should never happen at this place that there is something different than the old set. + if Reader.ReadValue = vaSet then + with TreeOptions do + begin + // Remove all default values set by the constructor. + StringOptions := []; + + while True do + begin + // Sets are stored with their members as simple strings. Read them one by one and map them to the new option + // in the correct sub-option set. + EnumName := Reader.ReadStr; + if EnumName = '' then + Break; + OldOption := TOldVTStringOption(GetEnumValue(TypeInfo(TOldVTStringOption), EnumName)); + case OldOption of + soSaveCaptions: + StringOptions := FStringOptions + [toSaveCaptions]; + soShowStaticText: + StringOptions := FStringOptions + [toShowStaticText]; + end; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.RenderOLEData(const FormatEtcIn: TFormatEtc; out Medium: TStgMedium; + ForClipboard: Boolean): HResult; + +// Returns string expressions of all currently selected nodes in the Medium structure. + +begin + Result := inherited RenderOLEData(FormatEtcIn, Medium, ForClipboard); + if Failed(Result) then + try + if ForClipboard then + Medium.hGlobal := ContentToClipboard(FormatEtcIn.cfFormat, tstCutCopySet) + else + Medium.hGlobal := ContentToClipboard(FormatEtcIn.cfFormat, tstSelected); + + // Fill rest of the Medium structure if rendering went fine. + if Medium.hGlobal <> 0 then + begin + Medium.tymed := TYMED_HGLOBAL; + Medium.unkForRelease := nil; + + Result := S_OK; + end; + except + Result := E_FAIL; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.WriteChunks(Stream: TStream; Node: PVirtualNode); + +// Adds another sibling chunk for Node storing the label if the node is initialized. +// Note: If the application stores a node's caption in the node's data member (which will be quite common) and needs to +// store more node specific data then it should use the OnSaveNode event rather than the caption autosave function +// (take out soSaveCaption from StringOptions). Otherwise the caption is unnecessarily stored twice. + +var + Header: TChunkHeader; + S: UnicodeString; + Len: Integer; + +begin + inherited; + if (toSaveCaptions in TreeOptions.FStringOptions) and (Node <> FRoot) and + (vsInitialized in Node.States) then + with Stream do + begin + // Read the node's caption (primary column only). + S := Text[Node, FHeader.MainColumn]; + Len := 2 * Length(S); + if Len > 0 then + begin + // Write a new sub chunk. + Header.ChunkType := CaptionChunk; + Header.ChunkSize := Len; + Write(Header, SizeOf(Header)); + Write(PWideChar(S)^, Len); + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ComputeNodeHeight(Canvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; + S: UnicodeString): Integer; + +// Default node height calculation for multi line nodes. This method can be used by the application to delegate the +// computation to the string tree. +// Canvas is used to compute that value by using its current font settings. +// Node and Column describe the cell to be used for the computation. +// S is the string for which the height must be computed. If this string is empty the cell text is used instead. + +var + DrawFormat: Cardinal; + BidiMode: TBidiMode; + Alignment: TAlignment; + PaintInfo: TVTPaintInfo; + Dummy: TColumnIndex; + LineImage: TLineImage; +begin + if Length(S) = 0 then + S := Text[Node, Column]; + DrawFormat := DT_TOP or DT_NOPREFIX or DT_CALCRECT or DT_WORDBREAK; + if Column <= NoColumn then + begin + BidiMode := Self.BidiMode; + Alignment := Self.Alignment; + end + else + begin + BidiMode := Header.Columns[Column].BidiMode; + Alignment := Header.Columns[Column].Alignment; + end; + + if BidiMode <> bdLeftToRight then + ChangeBidiModeAlignment(Alignment); + + // Allow for autospanning. + PaintInfo.Node := Node; + PaintInfo.BidiMode := BidiMode; + PaintInfo.Column := Column; + PaintInfo.CellRect := Rect(0, 0, 0, 0); + if Column > NoColumn then + begin + PaintInfo.CellRect.Right := FHeader.Columns[Column].Width - FTextMargin; + PaintInfo.CellRect.Left := FTextMargin + FMargin; + if Column = Header.MainColumn then + begin + if toFixedIndent in FOptions.FPaintOptions then + SetLength(LineImage, 1) + else + DetermineLineImageAndSelectLevel(Node, LineImage); + Inc(PaintInfo.CellRect.Left, Length(LineImage) * Integer(Indent)); + end; + end + else + PaintInfo.CellRect.Right := ClientWidth; + AdjustPaintCellRect(PaintInfo, Dummy); + + if BidiMode <> bdLeftToRight then + DrawFormat := DrawFormat or DT_RIGHT or DT_RTLREADING + else + DrawFormat := DrawFormat or DT_LEFT; + Windows.DrawTextW(Canvas.Handle, PWideChar(S), Length(S), PaintInfo.CellRect, DrawFormat); + Result := PaintInfo.CellRect.Bottom - PaintInfo.CellRect.Top; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToClipboard(Format: Word; Source: TVSTTextSourceType): HGLOBAL; + +// This method constructs a shareable memory object filled with string data in the required format. Supported are: +// CF_TEXT - plain ANSI text (Unicode text is converted using the user's current locale) +// CF_UNICODETEXT - plain Unicode text +// CF_CSV - comma separated plain ANSI text +// CF_VRTF + CF_RTFNOOBS - rich text (plain ANSI) +// CF_HTML - HTML text encoded using UTF-8 +// +// Result is the handle to a globally allocated memory block which can directly be used for clipboard and drag'n drop +// transfers. The caller is responsible for freeing the memory. If for some reason the content could not be rendered +// the Result is 0. + + //--------------- local function -------------------------------------------- + + procedure MakeFragment(var HTML: AnsiString); + + // Helper routine to build a properly-formatted HTML fragment. + + const + Version = 'Version:1.0'#13#10; + StartHTML = 'StartHTML:'; + EndHTML = 'EndHTML:'; + StartFragment = 'StartFragment:'; + EndFragment = 'EndFragment:'; + DocType = ''; + HTMLIntro = '' + + ''; + HTMLExtro = ''; + NumberLengthAndCR = 10; + + // Let the compiler determine the description length. + DescriptionLength = Length(Version) + Length(StartHTML) + Length(EndHTML) + Length(StartFragment) + + Length(EndFragment) + 4 * NumberLengthAndCR; + + var + Description: AnsiString; + StartHTMLIndex, + EndHTMLIndex, + StartFragmentIndex, + EndFragmentIndex: Integer; + + begin + // The HTML clipboard format is defined by using byte positions in the entire block where HTML text and + // fragments start and end. These positions are written in a description. Unfortunately the positions depend on the + // length of the description but the description may change with varying positions. + // To solve this dilemma the offsets are converted into fixed length strings which makes it possible to know + // the description length in advance. + StartHTMLIndex := DescriptionLength; // position 0 after the description + StartFragmentIndex := StartHTMLIndex + Length(DocType) + Length(HTMLIntro); + EndFragmentIndex := StartFragmentIndex + Length(HTML); + EndHTMLIndex := EndFragmentIndex + Length(HTMLExtro); + + Description := Version + + SysUtils.Format('%s%.8d', [StartHTML, StartHTMLIndex]) + #13#10 + + SysUtils.Format('%s%.8d', [EndHTML, EndHTMLIndex]) + #13#10 + + SysUtils.Format('%s%.8d', [StartFragment, StartFragmentIndex]) + #13#10 + + SysUtils.Format('%s%.8d', [EndFragment, EndFragmentIndex]) + #13#10; + HTML := Description + DocType + HTMLIntro + HTML + HTMLExtro; + end; + + //--------------- end local function ---------------------------------------- + +var + Data: Pointer; + DataSize: Cardinal; + S: AnsiString; + WS: UnicodeString; + P: Pointer; + +begin + Result := 0; + case Format of + CF_TEXT: + begin + S := ContentToText(Source, #9) + #0; + Data := PAnsiChar(S); + DataSize := Length(S); + end; + CF_UNICODETEXT: + begin + WS := ContentToUnicode(Source, #9) + #0; + Data := PWideChar(WS); + DataSize := 2 * Length(WS); + end; + else + if Format = CF_CSV then + S := ContentToText(Source, AnsiChar ({$ifdef COMPILER_15_UP}FormatSettings.{$endif}ListSeparator)) + #0 + else + if (Format = CF_VRTF) or (Format = CF_VRTFNOOBJS) then + S := ContentToRTF(Source) + #0 + else + if Format = CF_HTML then + begin + S := ContentToHTML(Source); + // Build a valid HTML clipboard fragment. + MakeFragment(S); + S := S + #0; + end; + Data := PAnsiChar(S); + DataSize := Length(S); + end; + + if DataSize > 0 then + begin + Result := GlobalAlloc(GHND or GMEM_SHARE, DataSize); + P := GlobalLock(Result); + Move(Data^, P^, DataSize); + GlobalUnlock(Result); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToHTML(Source: TVSTTextSourceType; Caption: UnicodeString = ''): AnsiString; + +// Renders the current tree content (depending on Source) as HTML text encoded in UTF-8. +// If Caption is not empty then it is used to create and fill the header for the table built here. +// Based on ideas and code from Frank van den Bergh and Andreas Hörstemeier. + +type + UCS2 = Word; + UCS4 = Cardinal; + +const + MaximumUCS4: UCS4 = $7FFFFFFF; + ReplacementCharacter: UCS4 = $0000FFFD; + +var + Buffer: TBufferedAnsiString; + + //--------------- local functions ------------------------------------------- + + function ConvertSurrogate(S1, S2: UCS2): UCS4; + + // Converts a pair of high and low surrogate into the corresponding UCS4 character. + + const + SurrogateOffset = ($D800 shl 10) + $DC00 - $10000; + + begin + Result := Word(S1) shl 10 + Word(S2) - SurrogateOffset; + end; + + //--------------------------------------------------------------------------- + + function UTF16ToUTF8(const S: UnicodeString): AnsiString; + + // Converts the given Unicode text (which may contain surrogates) into + // the UTF-8 encoding used for the HTML clipboard format. + + const + FirstByteMark: array[0..6] of Byte = ($00, $00, $C0, $E0, $F0, $F8, $FC); + + var + Ch: UCS4; + I, J, T: Integer; + BytesToWrite: Cardinal; + + begin + if Length(S) = 0 then + Result := '' + else + begin + // Make room for the result. Assume worst case, there are only short texts to convert. + SetLength(Result, 6 * Length(S)); + T := 1; + I := 1; + while I <= Length(S) do + begin + Ch := UCS4(S[I]); + + // Is the character a surrogate? + if (Ch and $FFFFF800) = $D800 then + begin + Inc(I); + // Check the following char whether it forms a valid surrogate pair with the first character. + if (I <= Length(S)) and ((UCS4(S[I]) and $FFFFFC00) = $DC00) then + Ch := ConvertSurrogate(UCS2(Ch), UCS2(S[I])) + else // Skip invalid surrogate value. + Continue; + end; + + if Ch < $80 then + BytesToWrite := 1 + else + if Ch < $800 then + BytesToWrite := 2 + else + if Ch < $10000 then + BytesToWrite := 3 + else + if Ch < $200000 then + BytesToWrite := 4 + else + if Ch < $4000000 then + BytesToWrite := 5 + else + if Ch <= MaximumUCS4 then + BytesToWrite := 6 + else + begin + BytesToWrite := 2; + Ch := ReplacementCharacter; + end; + + for J := BytesToWrite downto 2 do + begin + Result[T + J - 1] := AnsiChar((Ch or $80) and $BF); + Ch := Ch shr 6; + end; + Result[T] := AnsiChar(Ch or FirstByteMark[BytesToWrite]); + Inc(T, BytesToWrite); + + Inc(I); + end; + SetLength(Result, T - 1); // set to actual length + end; + end; + + //--------------------------------------------------------------------------- + + procedure WriteColorAsHex(Color: TColor); + + var + WinColor: COLORREF; + I: Integer; + Component, + Value: Byte; + + begin + Buffer.Add('#'); + WinColor := ColorToRGB(Color); + I := 1; + while I <= 6 do + begin + Component := WinColor and $FF; + + Value := 48 + (Component shr 4); + if Value > $39 then + Inc(Value, 7); + Buffer.Add(AnsiChar(Value)); + Inc(I); + + Value := 48 + (Component and $F); + if Value > $39 then + Inc(Value, 7); + Buffer.Add(AnsiChar(Value)); + Inc(I); + + WinColor := WinColor shr 8; + end; + end; + + //--------------------------------------------------------------------------- + + procedure WriteStyle(Name: AnsiString; Font: TFont); + + // Creates a CSS style entry with the given name for the given font. + // If Name is empty then the entry is created as inline style. + + begin + if Length(Name) = 0 then + Buffer.Add(' style="{') + else + begin + Buffer.Add('.'); + Buffer.Add(Name); + Buffer.Add('{'); + end; + + Buffer.Add(Format('font-family: ''%s''; ', [Font.Name])); + if Font.Size < 0 then + Buffer.Add(Format('font-size: %dpx; ', [Font.Height])) + else + Buffer.Add(Format('font-size: %dpt; ', [Font.Size])); + + Buffer.Add(Format('font-style: %s; ', [IfThen(fsItalic in Font.Style, 'italic', 'normal')])); + Buffer.Add(Format('font-weight: %s; ', [IfThen(fsBold in Font.Style, 'bold', 'normal')])); + Buffer.Add(Format('text-decoration: %s; ', [IfThen(fsUnderline in Font.Style, 'underline', 'none')])); + + Buffer.Add('color: '); + WriteColorAsHex(Font.Color); + Buffer.Add(';}'); + if Length(Name) = 0 then + Buffer.Add('"'); + end; + + //--------------- end local functions --------------------------------------- + +var + I, J : Integer; + Level, MaxLevel: Cardinal; + AddHeader: AnsiString; + Save, Run: PVirtualNode; + GetNextNode: TGetNextNodeProc; + Text: UnicodeString; + + RenderColumns: Boolean; + Columns: TColumnsArray; + ColumnColors: array of AnsiString; + Index: Integer; + IndentWidth, + LineStyleText: AnsiString; + Alignment: TAlignment; + BidiMode: TBidiMode; + + CellPadding: AnsiString; + +begin + Buffer := TBufferedAnsiString.Create; + try + // For customization by the application or descendants we use again the redirected font change event. + RedirectFontChangeEvent(Canvas); + + CellPadding := Format('padding-left:%dpx;padding-right:%0:dpx;', [FMargin]); + + IndentWidth := IntToStr(FIndent); + AddHeader := ' '; + // Add title if adviced so by giving a caption. + if Length(Caption) > 0 then + AddHeader := AddHeader + 'caption="' + UTF16ToUTF8(Caption) + '"'; + if Borderstyle <> bsNone then + AddHeader := AddHeader + Format(' border="%d" frame=box', [BorderWidth + 1]); + + Buffer.Add(''); + + // Create HTML table based on the tree structure. To simplify formatting we use styles defined in a small CSS area. + Buffer.Add(''); + Buffer.AddNewLine; + + // General table properties. + Buffer.Add(''); + Buffer.AddNewLine; + + Columns := nil; + ColumnColors := nil; + RenderColumns := FHeader.UseColumns; + if RenderColumns then + begin + Columns := FHeader.FColumns.GetVisibleColumns; + SetLength(ColumnColors, Length(Columns)); + end; + + GetRenderStartValues(Source, Run, GetNextNode); + Save := Run; + + MaxLevel := 0; + // The table consists of visible columns and rows as used in the tree, but the main tree column is splitted + // into several HTML columns to accomodate the indentation. + while Assigned(Run) do + begin + if (CanExportNode(Run)) then + begin + Level := GetNodeLevel(Run); + if Level > MaxLevel then + MaxLevel := Level; + end; + Run := GetNextNode(Run); + end; + + if RenderColumns then + begin + if Assigned(FOnBeforeHeaderExport) then + FOnBeforeHeaderExport(Self, etHTML); + Buffer.Add(''); + Buffer.AddNewLine; + // Make the first row in the HTML table an image of the tree header. + for I := 0 to High(Columns) do + begin + if Assigned(FOnBeforeColumnExport) then + FOnBeforeColumnExport(Self, etHTML, Columns[I]); + Buffer.Add(''); + if Assigned(FOnAfterColumnExport) then + FOnAfterColumnExport(Self, etHTML, Columns[I]); + end; + Buffer.Add(''); + Buffer.AddNewLine; + if Assigned(FOnAfterHeaderExport) then + FOnAfterHeaderExport(self, etHTML); + end; + + // Now go through the tree. + Run := Save; + while Assigned(Run) do + begin + if ((not CanExportNode(Run)) or (Assigned(FonBeforeNodeExport) and (not FOnBeforeNodeExport(Self, etHTML, Run)))) then + begin + Run := GetNextNode(Run); + Continue; + end; + Level := GetNodeLevel(Run); + Buffer.Add(' '); + Buffer.AddNewLine; + + I := 0; + while (I < Length(Columns)) or not RenderColumns do + begin + if RenderColumns then + Index := Columns[I].Index + else + Index := NoColumn; + + if not RenderColumns or (coVisible in Columns[I].FOptions) then + begin + // Call back the application to know about font customization. + Canvas.Font := Font; + FFontChanged := False; + DoPaintText(Run, Canvas, Index, ttNormal); + + if Index = Header.MainColumn then + begin + // Create a cell for each indentation level. + if RenderColumns and not (coParentColor in Columns[I].FOptions) then + begin + for J := 1 to Level do + begin + Buffer.Add(''); + end; + end + else + begin + for J := 1 to Level do + if J = 1 then + begin + Buffer.Add(' '); + end + else + Buffer.Add(' '); + end; + end; + + if FFontChanged then + begin + Buffer.Add(' '); + end; + + if not RenderColumns then + Break; + Inc(I); + end; + if Assigned(FOnAfterNodeExport) then + FOnAfterNodeExport(Self, etHTML, Run); + Run := GetNextNode(Run); + Buffer.Add(' '); + Buffer.AddNewLine; + end; + Buffer.Add('
bdLeftToRight then + begin + ChangeBidiModeAlignment(Alignment); + Buffer.Add(' dir="rtl"'); + end; + + // Consider aligment. + case Alignment of + taRightJustify: + Buffer.Add(' align=right'); + taCenter: + Buffer.Add(' align=center'); + else + Buffer.Add(' align=left'); + end; + + Index := Columns[I].Index; + // Merge cells of the header emulation in the main column. + if (MaxLevel > 0) and (Index = Header.MainColumn) then + begin + Buffer.Add(' colspan="'); + Buffer.Add(IntToStr(MaxLevel + 1)); + Buffer.Add('"'); + end; + + // The color of the header is usually clBtnFace. + Buffer.Add(' bgcolor='); + WriteColorAsHex(clBtnFace); + + // Set column width in pixels. + Buffer.Add(' width="'); + Buffer.Add(IntToStr(Columns[I].Width)); + Buffer.Add('px">'); + + if Length(Columns[I].Text) > 0 then + Buffer.Add(UTF16ToUTF8(Columns[I].Text)); + Buffer.Add('
    bdLeftToRight then + begin + ChangeBidiModeAlignment(Alignment); + Buffer.Add(' dir="rtl"'); + end; + + // Consider aligment. + case Alignment of + taRightJustify: + Buffer.Add(' align=right'); + taCenter: + Buffer.Add(' align=center'); + else + Buffer.Add(' align=left'); + end; + // Merge cells in the main column. + if (MaxLevel > 0) and (Index = FHeader.MainColumn) and (Level < MaxLevel) then + begin + Buffer.Add(' colspan="'); + Buffer.Add(IntToStr(MaxLevel - Level + 1)); + Buffer.Add('"'); + end; + if RenderColumns and not (coParentColor in Columns[I].FOptions) then + begin + Buffer.Add(' bgcolor='); + WriteColorAsHex(Columns[I].Color); + end; + Buffer.Add('>'); + Text := Self.Text[Run, Index]; + if Length(Text) > 0 then + begin + Text := UTF16ToUTF8(Text); + Buffer.Add(Text); + end; + Buffer.Add('
'); + + RestoreFontChangeEvent(Canvas); + + Result := Buffer.AsString; + finally + Buffer.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.CanExportNode(Node: PVirtualNode ): Boolean; + +begin + Result := True; + case FOptions.ExportMode of + emChecked: + Result := Node.CheckState = csCheckedNormal; + emUnchecked: + Result := Node.CheckState = csUncheckedNormal; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToRTF(Source: TVSTTextSourceType): AnsiString; + +// Renders the current tree content (depending on Source) as RTF (rich text). +// Based on ideas and code from Frank van den Bergh and Andreas Hörstemeier. + +var + Fonts: TStringList; + Colors: TList; + CurrentFontIndex, + CurrentFontColor, + CurrentFontSize: Integer; + Buffer: TBufferedAnsiString; + + //--------------- local functions ------------------------------------------- + + procedure SelectFont(Font: string); + + var + I: Integer; + + begin + I := Fonts.IndexOf(Font); + if I > -1 then + begin + // Font has already been used + if I <> CurrentFontIndex then + begin + Buffer.Add('\f'); + Buffer.Add(IntToStr(I)); + CurrentFontIndex := I; + end; + end + else + begin + I := Fonts.Add(Font); + Buffer.Add('\f'); + Buffer.Add(IntToStr(I)); + CurrentFontIndex := I; + end; + end; + + //--------------------------------------------------------------------------- + + procedure SelectColor(Color: TColor); + + var + I: Integer; + + begin + I := Colors.IndexOf(Pointer(Color)); + if I > -1 then + begin + // Color has already been used + if I <> CurrentFontColor then + begin + Buffer.Add('\cf'); + Buffer.Add(IntToStr(I + 1)); + CurrentFontColor := I; + end; + end + else + begin + I := Colors.Add(Pointer(Color)); + Buffer.Add('\cf'); + Buffer.Add(IntToStr(I + 1)); + CurrentFontColor := I; + end; + end; + + //--------------------------------------------------------------------------- + + procedure TextPlusFont(Text: UnicodeString; Font: TFont); + + var + UseUnderline, + UseItalic, + UseBold: Boolean; + I: Integer; + + begin + if Length(Text) > 0 then + begin + UseUnderline := fsUnderline in Font.Style; + if UseUnderline then + Buffer.Add('\ul'); + UseItalic := fsItalic in Font.Style; + if UseItalic then + Buffer.Add('\i'); + UseBold := fsBold in Font.Style; + if UseBold then + Buffer.Add('\b'); + SelectFont(Font.Name); + SelectColor(Font.Color); + if Font.Size <> CurrentFontSize then + begin + // Font size must be given in half points. + Buffer.Add('\fs'); + Buffer.Add(IntToStr(2 * Font.Size)); + CurrentFontSize := Font.Size; + end; + // Use escape sequences to note Unicode text. + Buffer.Add(' '); + // Note: Unicode values > 32767 must be expressed as negative numbers. This is implicitly done + // by interpreting the wide chars (word values) as small integers. + for I := 1 to Length(Text) do + begin + if (Text[I] = WideLF) then + Buffer.Add( '{\par}' ) + else + if (Text[i] <> WideCR) then + begin + Buffer.Add(Format('\u%d\''3f', [SmallInt(Text[I])])); + Continue; + end; + end; + if UseUnderline then + Buffer.Add('\ul0'); + if UseItalic then + Buffer.Add('\i0'); + if UseBold then + Buffer.Add('\b0'); + end; + end; + + //--------------- end local functions --------------------------------------- + +var + Level, LastLevel: Integer; + I, J: Integer; + Save, Run: PVirtualNode; + GetNextNode: TGetNextNodeProc; + S, Tabs : AnsiString; + Text: UnicodeString; + Twips: Integer; + + RenderColumns: Boolean; + Columns: TColumnsArray; + Index: Integer; + Alignment: TAlignment; + BidiMode: TBidiMode; + LocaleBuffer: Array [0..1] of Char; + +begin + Buffer := TBufferedAnsiString.Create; + try + // For customization by the application or descendants we use again the redirected font change event. + RedirectFontChangeEvent(Canvas); + + Fonts := TStringList.Create; + Colors := TList.Create; + CurrentFontIndex := -1; + CurrentFontColor := -1; + CurrentFontSize := -1; + + Columns := nil; + Tabs := ''; + LastLevel := 0; + + RenderColumns := FHeader.UseColumns; + if RenderColumns then + Columns := FHeader.FColumns.GetVisibleColumns; + + GetRenderStartValues(Source, Run, GetNextNode); + Save := Run; + + // First make a table structure. The \rtf and other header stuff is included + // when the font and color tables are created. + Buffer.Add('\uc1\trowd\trgaph70'); + J := 0; + if RenderColumns then + begin + for I := 0 to High(Columns) do + begin + Inc(J, Columns[I].Width); + // This value must be expressed in twips (1 inch = 1440 twips). + Twips := Round(1440 * J / Screen.PixelsPerInch); + Buffer.Add('\cellx'); + Buffer.Add(IntToStr(Twips)); + end; + end + else + begin + Twips := Round(1440 * ClientWidth / Screen.PixelsPerInch); + Buffer.Add('\cellx'); + Buffer.Add(IntToStr(Twips)); + end; + + // Fill table header. + if RenderColumns then + begin + if Assigned(FOnBeforeHeaderExport) then + FonBeforeHeaderExport(Self, etRTF); + Buffer.Add('\pard\intbl'); + for I := 0 to High(Columns) do + begin + if Assigned(FOnBeforeColumnExport) then + FOnBeforeColumnExport(Self, etRTF, Columns[I]); + Alignment := Columns[I].CaptionAlignment; + BidiMode := Columns[I].BidiMode; + + // Alignment is not supported with older RTF formats, however it will be ignored. + if BidiMode <> bdLeftToRight then + ChangeBidiModeAlignment(Alignment); + case Alignment of + taLeftJustify: + Buffer.Add('\ql'); + taRightJustify: + Buffer.Add('\qr'); + taCenter: + Buffer.Add('\qc'); + end; + + TextPlusFont(Columns[I].Text, Header.Font); + Buffer.Add('\cell'); + if Assigned(FOnAfterColumnExport) then + FOnAfterColumnExport( self, etRTF, Columns[I] ); + end; + Buffer.Add('\row'); + if Assigned(FOnAfterHeaderExport) then + FOnAfterHeaderExport(Self, etRTF); + end; + + // Now write the contents. + Run := Save; + while Assigned(Run) do + begin + if ((not CanExportNode(Run)) or + (Assigned(FOnBeforeNodeExport) and (not FOnBeforeNodeExport(Self, etRTF, Run)))) then + begin + Run := GetNextNode(Run); + Continue; + end; + I := 0; + while not RenderColumns or (I < Length(Columns)) do + begin + if RenderColumns then + begin + Index := Columns[I].Index; + Alignment := Columns[I].Alignment; + BidiMode := Columns[I].BidiMode; + end + else + begin + Index := NoColumn; + Alignment := FAlignment; + BidiMode := Self.BidiMode; + end; + + if not RenderColumns or (coVisible in Columns[I].Options) then + begin + Text := Self.Text[Run, Index]; + Buffer.Add('\pard\intbl'); + + // Alignment is not supported with older RTF formats, however it will be ignored. + if BidiMode <> bdLeftToRight then + ChangeBidiModeAlignment(Alignment); + case Alignment of + taRightJustify: + Buffer.Add('\qr'); + taCenter: + Buffer.Add('\qc'); + end; + + // Call back the application to know about font customization. + Canvas.Font := Font; + FFontChanged := False; + DoPaintText(Run, Canvas, Index, ttNormal); + + if Index = Header.MainColumn then + begin + Level := GetNodeLevel(Run); + if Level <> LastLevel then + begin + LastLevel := Level; + Tabs := ''; + for J := 0 to Level - 1 do + Tabs := Tabs + '\tab'; + end; + if Level > 0 then + begin + Buffer.Add(Tabs); + Buffer.Add(' '); + TextPlusFont(Text, Canvas.Font); + Buffer.Add('\cell'); + end + else + begin + TextPlusFont(Text, Canvas.Font); + Buffer.Add('\cell'); + end; + end + else + begin + TextPlusFont(Text, Canvas.Font); + Buffer.Add('\cell'); + end; + end; + + if not RenderColumns then + Break; + Inc(I); + end; + Buffer.Add('\row'); + if (Assigned(FOnAfterNodeExport)) then + FOnAfterNodeExport(Self, etRTF, Run); + Run := GetNextNode(Run); + end; + + Buffer.Add('\pard\par'); + + // Build lists with fonts and colors. They have to be at the start of the document. + S := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl'; + for I := 0 to Fonts.Count - 1 do + S := S + Format('{\f%d %s;}', [I, Fonts[I]]); + S := S + '}'; + + S := S + '{\colortbl;'; + for I := 0 to Colors.Count - 1 do + begin + J := ColorToRGB(TColor(Colors[I])); + S := S + Format('\red%d\green%d\blue%d;', [J and $FF, (J shr 8) and $FF, (J shr 16) and $FF]); + end; + S := S + '}'; + if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, @LocaleBuffer, Length(LocaleBuffer)) <> 0) and (LocaleBuffer[0] = '0'{metric}) then + S := S + '\paperw16840\paperh11907'// This sets A4 landscape format + else + S := S + '\paperw15840\paperh12240';//[JAM:marder] This sets US Letter landscape format + // Make sure a small margin is used so that a lot of the table fits on a paper. This defines a margin of 0.5" + S := S + '\margl720\margr720\margt720\margb720'; + Result := S + Buffer.AsString + '}'; + Fonts.Free; + Colors.Free; + + RestoreFontChangeEvent(Canvas); + finally + Buffer.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.ContentToCustom(Source: TVSTTextSourceType); + +// Generic export procedure which polls the application at every stage of the export. + +var + I: Integer; + Save, Run: PVirtualNode; + GetNextNode: TGetNextNodeProc; + RenderColumns: Boolean; + Columns: TColumnsArray; + +begin + Columns := nil; + GetRenderStartValues(Source, Run, GetNextNode); + Save := Run; + + RenderColumns := FHeader.UseColumns and ( hoVisible in FHeader.Options ); + + if Assigned(FOnBeforeTreeExport) then + FOnBeforeTreeExport(Self, etCustom); + + // Fill table header. + if RenderColumns then + begin + if Assigned(FOnBeforeHeaderExport) then + FOnBeforeHeaderExport(Self, etCustom); + + Columns := FHeader.FColumns.GetVisibleColumns; + for I := 0 to High(Columns) do + begin + if Assigned(FOnBeforeColumnExport) then + FOnBeforeColumnExport(Self, etCustom, Columns[I]); + + if Assigned(FOnColumnExport) then + FOnColumnExport(Self, etCustom, Columns[I]); + + if Assigned(FOnAfterColumnExport) then + FOnAfterColumnExport(Self, etCustom, Columns[I]); + end; + + if Assigned(FOnAfterHeaderExport) then + FOnAfterHeaderExport(Self, etCustom); + end; + + // Now write the content. + Run := Save; + while Assigned(Run) do + begin + if CanExportNode(Run) then + begin + if Assigned(FOnBeforeNodeExport) then + FOnBeforeNodeExport(Self, etCustom, Run); + + if Assigned(FOnNodeExport) then + FOnNodeExport(Self, etCustom, Run); + + if Assigned(FOnAfterNodeExport) then + FOnAfterNodeExport(Self, etCustom, Run); + end; + + Run := GetNextNode(Run); + end; + + if Assigned(FOnAfterTreeExport) then + FOnAfterTreeExport(Self, etCustom); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToText(Source: TVSTTextSourceType; Separator: AnsiChar): AnsiString; + +begin + Result := ContentToText(Source, AnsiString(Separator)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToText(Source: TVSTTextSourceType; const Separator: AnsiString): AnsiString; + +// Renders the current tree content (depending on Source) as plain ANSI text. +// If an entry contains the separator char or double quotes then it is wrapped with double quotes +// and existing double quotes are duplicated. +// Note: Unicode strings are implicitely converted to ANSI strings based on the currently active user locale. + +var + RenderColumns: Boolean; + Tabs: AnsiString; + GetNextNode: TGetNextNodeProc; + Run, Save: PVirtualNode; + Level, MaxLevel: Cardinal; + Columns: TColumnsArray; + LastColumn: TVirtualTreeColumn; + Index, + I: Integer; + Text: AnsiString; + Buffer: TBufferedAnsiString; + +begin + Columns := nil; + Buffer := TBufferedAnsiString.Create; + try + RenderColumns := FHeader.UseColumns; + if RenderColumns then + Columns := FHeader.FColumns.GetVisibleColumns; + + GetRenderStartValues(Source, Run, GetNextNode); + Save := Run; + + // The text consists of visible groups representing the columns, which are separated by one or more separator + // characters. There are always MaxLevel separator chars in a line (main column only). Either before the caption + // to ident it or after the caption to make the following column aligned. + MaxLevel := 0; + while Assigned(Run) do + begin + Level := GetNodeLevel(Run); + If Level > MaxLevel then + MaxLevel := Level; + Run := GetNextNode(Run); + end; + + Tabs := DupeString(Separator, MaxLevel); + + // First line is always the header if used. + if RenderColumns then + begin + LastColumn := Columns[High(Columns)]; + for I := 0 to High(Columns) do + begin + Buffer.Add(Columns[I].Text); + if Columns[I] <> LastColumn then + begin + if Columns[I].Index = Header.MainColumn then + begin + Buffer.Add(Tabs); + Buffer.Add(Separator); + end + else + Buffer.Add(Separator); + end; + end; + Buffer.AddNewLine; + end + else + LastColumn := nil; + + Run := Save; + if RenderColumns then + begin + while Assigned(Run) do + begin + if (not CanExportNode(Run) or + (Assigned(FOnBeforeNodeExport) and (not FOnBeforeNodeExport(Self, etText, Run)))) then + begin + Run := GetNextNode(Run); + Continue; + end; + for I := 0 to High(Columns) do + begin + if coVisible in Columns[I].Options then + begin + Index := Columns[I].Index; + // This line implicitly converts the Unicode text to ANSI. + Text := Self.Text[Run, Index]; + if Index = Header.MainColumn then + begin + Level := GetNodeLevel(Run); + Buffer.Add(Copy(Tabs, 1, Integer(Level) * Length(Separator))); + // Wrap the text with quotation marks if it contains the separator character. + if (Pos(Separator, Text) > 0) or (Pos('"', Text) > 0) then + Buffer.Add(AnsiQuotedStr(Text, '"')) + else + Buffer.Add(Text); + Buffer.Add(Copy(Tabs, 1, Integer(MaxLevel - Level) * Length(Separator))); + end + else + if (Pos(Separator, Text) > 0) or (Pos('"', Text) > 0) then + Buffer.Add(AnsiQuotedStr(Text, '"')) + else + Buffer.Add(Text); + + if Columns[I] <> LastColumn then + Buffer.Add(Separator); + end; + end; + if Assigned(FOnAfterNodeExport) then + FOnAfterNodeExport(Self, etText, Run); + Run := GetNextNode(Run); + Buffer.AddNewLine; + end; + end + else + begin + while Assigned(Run) do + begin + if ((not CanExportNode(Run)) or + (Assigned(FOnBeforeNodeExport) and (not FOnBeforeNodeExport(Self, etText, Run)))) then + begin + Run := GetNextNode(Run); + Continue; + end; + // This line implicitly converts the Unicode text to ANSI. + Text := Self.Text[Run, NoColumn]; + Level := GetNodeLevel(Run); + Buffer.Add(Copy(Tabs, 1, Integer(Level) * Length(Separator))); + Buffer.Add(Text); + Buffer.AddNewLine; + + if Assigned(FOnAfterNodeExport) then + FonAfterNodeExport(Self, etText, Run); + Run := GetNextNode(Run); + end; + end; + + Result := Buffer.AsString; + finally + Buffer.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; Separator: WideChar): UnicodeString; + +begin + Result := ContentToUnicode(Source, UnicodeString(Separator)); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.ContentToUnicode(Source: TVSTTextSourceType; const Separator: UnicodeString): UnicodeString; + +// Renders the current tree content (depending on Source) as Unicode text. +// If an entry contains the separator char then it is wrapped with double quotation marks. +// Note: There is no QuotedStr function for Unicode in the VCL (like AnsiQuotedStr) so we have the limitation here +// that an entry must not contain double quotation marks, otherwise import into other programs might fail! + +const + WideCRLF: UnicodeString = #13#10; + +var + RenderColumns: Boolean; + Tabs: UnicodeString; + GetNextNode: TGetNextNodeProc; + Run, Save: PVirtualNode; + + Columns: TColumnsArray; + LastColumn: TVirtualTreeColumn; + Level, MaxLevel: Cardinal; + Index, + I: Integer; + Text: UnicodeString; + Buffer: TWideBufferedString; + +begin + Columns := nil; + + Buffer := TWideBufferedString.Create; + try + RenderColumns := FHeader.UseColumns; + if RenderColumns then + Columns := FHeader.FColumns.GetVisibleColumns; + + GetRenderStartValues(Source, Run, GetNextNode); + Save := Run; + + // The text consists of visible groups representing the columns, which are separated by one or more separator + // characters. There are always MaxLevel separator chars in a line (main column only). Either before the caption + // to ident it or after the caption to make the following column aligned. + MaxLevel := 0; + while Assigned(Run) do + begin + Level := GetNodeLevel(Run); + If Level > MaxLevel then + MaxLevel := Level; + Run := GetNextNode(Run); + end; + + Tabs := DupeString(Separator, MaxLevel); + + // First line is always the header if used. + if RenderColumns then + begin + LastColumn := Columns[High(Columns)]; + for I := 0 to High(Columns) do + begin + Buffer.Add(Columns[I].Text); + if Columns[I] <> LastColumn then + begin + if Columns[I].Index = Header.MainColumn then + begin + Buffer.Add(Tabs); + Buffer.Add(Separator); + end + else + Buffer.Add(Separator); + end; + end; + Buffer.AddNewLine; + end + else + LastColumn := nil; + + Run := Save; + if RenderColumns then + begin + while Assigned(Run) do + begin + for I := 0 to High(Columns) do + begin + if coVisible in Columns[I].Options then + begin + Index := Columns[I].Index; + Text := Self.Text[Run, Index]; + if Index = Header.MainColumn then + begin + Level := GetNodeLevel(Run); + Buffer.Add(Copy(Tabs, 1, Integer(Level) * Length(Separator))); + // Wrap the text with quotation marks if it contains the separator character. + if Pos(Separator, Text) > 0 then + begin + Buffer.Add('"'); + Buffer.Add(Text); + Buffer.Add('"'); + end + else + Buffer.Add(Text); + Buffer.Add(Copy(Tabs, 1, Integer(MaxLevel - Level) * Length(Separator))); + end + else + if Pos(Separator, Text) > 0 then + begin + Buffer.Add('"'); + Buffer.Add(Text); + Buffer.Add('"'); + end + else + Buffer.Add(Text); + + if Columns[I] <> LastColumn then + Buffer.Add(Separator); + end; + end; + Run := GetNextNode(Run); + Buffer.AddNewLine; + end; + end + else + begin + while Assigned(Run) do + begin + Text := Self.Text[Run, NoColumn]; + Level := GetNodeLevel(Run); + Buffer.Add(Copy(Tabs, 1, Integer(Level) * Length(Separator))); + Buffer.Add(Text); + Buffer.AddNewLine; + + Run := GetNextNode(Run); + end; + end; + Result := Buffer.AsString; + finally + Buffer.Free; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.GetTextInfo(Node: PVirtualNode; Column: TColumnIndex; const AFont: TFont; var R: TRect; + var Text: UnicodeString); + +// Returns the font, the text and its bounding rectangle to the caller. R is returned as the closest +// bounding rectangle around Text. + +var + NewHeight: Integer; + TM: TTextMetric; + +begin + // Get default font and initialize the other parameters. + inherited GetTextInfo(Node, Column, AFont, R, Text); + + Canvas.Font := AFont; + + FFontChanged := False; + RedirectFontChangeEvent(Canvas); + DoPaintText(Node, Canvas, Column, ttNormal); + if FFontChanged then + begin + AFont.Assign(Canvas.Font); + GetTextMetrics(Canvas.Handle, TM); + NewHeight := TM.tmHeight; + end + else // Otherwise the correct font is already there and we only need to set the correct height. + NewHeight := FTextHeight; + RestoreFontChangeEvent(Canvas); + + // Alignment to the actual text. + Text := Self.Text[Node, Column]; + R := GetDisplayRect(Node, Column, True, not (vsMultiline in Node.States)); + if toShowHorzGridLines in TreeOptions.PaintOptions then + Dec(R.Bottom); + InflateRect(R, 0, -(R.Bottom - R.Top - NewHeight) div 2); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.InvalidateNode(Node: PVirtualNode): TRect; + +var + Data: PInteger; + +begin + Result := inherited InvalidateNode(Node); + // Reset node width so changed text attributes are applied correctly. + if Assigned(Node) then + begin + Data := InternalData(Node); + if Assigned(Data) then + Data^ := 0; + // Reset height measured flag too to cause a re-issue of the OnMeasureItem event. + Exclude(Node.States, vsHeightMeasured); + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualStringTree.Path(Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; + Delimiter: WideChar): UnicodeString; + +// Constructs a string containing the node and all its parents. The last character in the returned path is always the +// given delimiter. + +var + S: UnicodeString; + +begin + if (Node = nil) or (Node = FRoot) then + Result := Delimiter + else + begin + Result := ''; + while Node <> FRoot do + begin + DoGetText(Node, Column, TextType, S); + Result := S + Delimiter + Result; + Node := Node.Parent; + end; + end; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualStringTree.ReinitNode(Node: PVirtualNode; Recursive: Boolean); + +var + Data: PInteger; + +begin + inherited; + // Reset node width so changed text attributes are applied correctly. + if Assigned(Node) and (Node <> FRoot) then + begin + Data := InternalData(Node); + if Assigned(Data) then + Data^ := 0; + // vsHeightMeasured is already removed in the base tree. + end; +end; + +//----------------- TVirtualStringTree --------------------------------------------------------------------------------- + +function TVirtualStringTree.GetOptions: TStringTreeOptions; + +begin + Result := FOptions as TStringTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualStringTree.SetOptions(const Value: TStringTreeOptions); + +begin + FOptions.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualStringTree.GetOptionsClass: TTreeOptionsClass; + +begin + Result := TStringTreeOptions; +end; + +//----------------- TCustomVirtualDrawTree ----------------------------------------------------------------------------- + +procedure TCustomVirtualDrawTree.DoDrawHint(Canvas: TCanvas; Node: PVirtualNode; R: TRect; Column: TColumnIndex); + +begin + if Assigned(FOnDrawHint) then + FOnDrawHint(Self, Canvas, Node, R, Column); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualDrawTree.DoGetCellContentMargin(Node: PVirtualNode; Column: TColumnIndex; + CellContentMarginType: TVTCellContentMarginType = ccmtAllSides; Canvas: TCanvas = nil): TPoint; + +begin + Result := Point(0, 0); + if Canvas = nil then + Canvas := Self.Canvas; + + if Assigned(FOnGetCellContentMargin) then + FOnGetCellContentMargin(Self, Canvas, Node, Column, CellContentMarginType, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualDrawTree.DoGetHintSize(Node: PVirtualNode; Column: TColumnIndex; var R: TRect); + +begin + if Assigned(FOnGetHintSize) then + FOnGetHintSize(Self, Node, Column, R); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TCustomVirtualDrawTree.DoGetNodeWidth(Node: PVirtualNode; Column: TColumnIndex; Canvas: TCanvas = nil): Integer; + +begin + Result := 2 * FTextMargin; + if Canvas = nil then + Canvas := Self.Canvas; + + if Assigned(FOnGetNodeWidth) then + FOnGetNodeWidth(Self, Canvas, Node, Column, Result); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TCustomVirtualDrawTree.DoPaintNode(var PaintInfo: TVTPaintInfo); + +begin + if Assigned(FOnDrawNode) then + FOnDrawNode(Self, PaintInfo); +end; + +//----------------- TVirtualDrawTree ----------------------------------------------------------------------------------- + +function TVirtualDrawTree.GetOptions: TVirtualTreeOptions; + +begin + Result := FOptions as TVirtualTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +procedure TVirtualDrawTree.SetOptions(const Value: TVirtualTreeOptions); + +begin + FOptions.Assign(Value); +end; + +//---------------------------------------------------------------------------------------------------------------------- + +function TVirtualDrawTree.GetOptionsClass: TTreeOptionsClass; + +begin + Result := TVirtualTreeOptions; +end; + +//---------------------------------------------------------------------------------------------------------------------- + +initialization + // Necessary for dynamic package loading. + Initialized := False; + NeedToUnitialize := False; + + // This watcher is used whenever a global structure could be modified by more than one thread. + Watcher := TCriticalSection.Create; +finalization + if Initialized then + FinalizeGlobalStructures; + + InternalClipboardFormats.Free; + InternalClipboardFormats := nil; + Watcher.Free; + Watcher := nil; + +end. diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VTConfig.inc b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VTConfig.inc new file mode 100644 index 0000000..0a317eb --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VTConfig.inc @@ -0,0 +1,15 @@ +// Configuration file for VirtualTrees.pas (see www.soft-gems.net). +// +// The content of this file is public domain. You may do with it whatever you like, provided the header stays fully intact +// in all version and derivative work. +// +// The original code is VTConfig.inc, released October 5, 2004. +// +// The initial developer of the original code is Mike Lischke (public@soft-gems.net, www.soft-gems.net). +//---------------------------------------------------------------------------------------------------------------------- + +{.$define ReverseFullExpandHotKey} // Used to define Ctrl+'+' instead of Ctrl+Shift+'+' for full expand (and similar for collapsing). + +{.$define TntSupport} // Added by Igor Afanasyev to support unicode-aware inplace editors. This implementation uses + // Troy Wolbrink's TNT controls, which can be found at: + // http://home.ccci.org/wolbrink/tnt/delphi_unicode_controls.htm. diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VirtualTrees.res b/LockBox3/unit-tests/dunit-m/external-libraries/VirtualTreeView/Source/VirtualTrees.res new file mode 100644 index 0000000000000000000000000000000000000000..812bc4bb184a9b64eaaed60376cad0c863120f90 GIT binary patch literal 51972 zcmeI532XHmWjpUNuXwRAo>!??c~xZOsz<6)g%@QesRY6h+ZcEWS(SYz z3n63zvDghmUKSF9crytQ62RbK8*EE9UbRbCyS3TYE?L&TOIHiJ@Aq||KKI;3_ewGX zo6+$(=j;CZJAM9NpYH$Z?$cMcEXzvd@cZ>aFlg(JGwB{|JSy#m<(DlnM$4_`)<=jW za;)d@SUM?{>mqNdmc?$RrfR{NpmprnF{C625D|VYIBRU8d|x)dZ2f^-FO#4vuEOrP z7`WpS35sLjiZAOY=8E?(vzEEy%D6v}uHszdY}kk9=cIk00_s7`begiZ`=>ela-?z` z<7hpzA zZ&K}C^^{6$sl!fIVOKSkxVprZ?oK9=e=dzQ0#&!|3zmt2>xS3{$FXzU%VqBT>})<5 zB3kvGwr)~QVH)O~_He{=T*h(rcK`IXH~FV;T8rcGYW%%L~DEiK^$Wx=rR1bM6ru548`?kA~x1E4L%7khtsSwt*HG;yGGd zaMBtG{gGoeRi0z&!}3bF$=`p?YIR6hbdn}E%C-SHi)|g-Ue+k);# z(OHVPam#SMC)Kjz)?3z+M9W&b+_IK0<)++g`?O^}e~INuT#_1h-6QLltVvE>x_0ey zIV3DPNfR4oE7!=il859Kx1LU0sujA0xjns|Lc7WD_pPQg#H*kYLOBMpq(U&OeUzJT z`_zZ;yUBO$jjQ{wxn`Lh5*D4LiH)+AYvfwVL-LY5r?>kYnG`)!lIKjWh1t7P3$eW zEnKRKX0a{2t2HFFB1+A7Z9(-MeQ11c{Z8}5%?<2(1zM5{xe%yeAXzm!SMvGdF*s%; z4fZ)n;rFSVsP?P%Az{(UCa+C-hs^7}aG8R<*cN8<nFt}Eh?yDkys@w*O>u&Z_%6c4qRw?xp`IrM(^+?<2QZaA*y z7~;>nTUh6p+pMZ@1LNR7G9F$%%XuWRm1}0P1-FI2QO;cCZNc^6l{-?qT$`$2t~iy$ zZJ@$VRae#1ZJ;|5?$4dBtRe^Jh$j@^`Mnpy@P@X9P=Dp6=`N43_vrcIiCjcl8&+N2 zoFDpLFve~h-|F!9!W_oV!SmEtDp2mWu*|wT` z)!J;`ZEdnXWqp$KX9y=-8?4(1>FtK)0Y5%M@K+SCsGM~ux|#=!><|!SWr_2xJ(Z6G zsj0L3_P%CuyHHCYIeDXkHb1#GnT-qCw&l&6vLav5$Qoy(>73Tt^%~)*ES_ zgOQ=n!}fo@k;Z=`WBPFeIZC}!lIL-QrTthZdZ%73ydTRg-F|E-IHVkmjOm9(`HLS) z;s^CXJ&)u~@2wxYUe5b@&|Z`uTCT-?6x1u)&z$@)^}$F}AB;5h$;i-pC96!&r+olB zUY>`Rfp!iJY;x7B#0>zTnmLlECCQ0KZqPiHXyhi%Q;D{WSuYJw8EJUR$e8s?3P$Rc zk^w(-+-V3wlsPpgVPOuBWLtu&3gDpyqc%v zGL^vsNrT_Wnf+LkoGfneLZ6phOFdo4eu+G$goG8>*;3t3`YCo?Lti{!C?z1{qfbz? zBae?hYkk`KN5)H=rShw7ag21KJh=-3M^e(?D;)Ea*9(`E!2(G$7BX_?F;Y@O!bFBsBcrFU6LKR1M~Yu$AU#bb&oAA)6O5ek-Eh71Iix&|l)i?DHS^P9|74H_6Zc7;(sdOa`ej{h}Lp><+aio2JeSzqclQ*bz zTP8{03%xC4`;olL#;N7HWIA8shb`ysM|`9)QcN5x!Hpm5j5PR-G|$0E^Bjz{%VC|7 z<~k!|`Z2pP(!%>eUs%c^!IlgPbo;SoOh0BfMp}43bbXxn^O)rrDW)H$J{W20gOR2_ z8ENX1k*m(Leb7~y%@}Fz#{d97Ia2N~aU(ybd1|eZMsLfQo+k)rg+v!hA=koYH9RF2B*jL!#pP=1(xuYkw$N%(Q9e=*2o!ocg;HZNZxz%lw77V zSRiTe8#%KdYov5!o1eU1%1xf%!bmd~GIFgH+u|5WKd}q&EMugPLTQ09(mz9!a-lJThL=d2?-| zq6Fawpo&NEL+OpZNL`)*nIIF|lAkS;WI|i)l#J~MpIMY2wv3n0K7!Mh2EUOJ{P5V% zBOtXO@$Tml+Yigqe%O)^2HFoLWBWmID?e-rPAP{(BMp8d!~LKD)N^o2W!B1e1_D1Xld{p8SV!Kp!{%2d~5jC z@U4+XZ=}&H8M}ROTiXvM@gvFhLrH_*$ocv)&-WjM#ik#l<|8R5UEVmT%3VpG!}+Ao zns)_|el+uviQ>+C`aW0pqkh@au2$zO5_NuS7D_sJ^?d^PP5gWvxInJ|W*nZ}1olWF9AB4wXY_Jk&lkKQhwy*8)gOgYlU5qO>FnA~pk;IJXG$R}5Uq${4y+_ z6e0B>w4S{G^-|+kXXS*BtKfxpnz>%yVttAX^k4P)z!|Uhb8u{7Ri4UNq zT1tjr^OI}UXAi#jEsQklK8&1s{YNt2<>cu&QY}FwZe;ZI^)iN&HKj(%oYw5uFb1xR ze7*VJW#o+Cy_~i2GN{~0xyqo}Ezft2e8O_uPg}~`YUQUbrBfy4V5IcIBwaoTUPx=? znaa`6%a*dXTKQp1gWt&5eo)fy!y0+;DL;$^r}D!{^wFOO&rN;bR+4%plceIud%Q-T znJD?q1HZk{k{K!a%>%!^&@!eUJU8WslK3H$rQ*kXy+%GkuPtY8O_jS8sH#`CjOB+s zH}ONu_iv3n^r7$@NiDJc&@z@ERJ+-%|8UmEZ_s?@tc~BKdCOTFKi@U-WV>AIm62q7 zgMJ=b#_|JuU9Xg!nRl0PAK_U?avv2pGJ3l6-TMwgu{sn0&93$GEsgUP}6+*rJV(LRZL#j^7u@M;FB-UMP@i85x<+PhKxP|Mv^G z4o!w#vhK{5YYi{i@j#(C>*CEicyLLo;8W7*jWl{KFO>C-&boN%Z%DaHKf^6Ioag%Z zgjK2lSjViT>PO2uP3cb~S5dMnT~fwHqSw;ApN*XHJ*^%T`8bl?C4YT^=+AR~d_wXD zy&l_^svj+WNPpUe-}n>TkN8OAqnPz#<$11;2cPo8NN_6rMxu}YJZ3jOT6jM;sNXyA zy9+JXZBoB?;CB~V#`I%$1lSr>1l5Fzc$ z$;WPA?)BETANuz&q}zUI8Ox7Zj*pym@gLKCrP?=q<;ahn=lXcEU1j^JBz~-u_HAS= zKUBFau8*JXdiizoVr7B-0!j1UFjBt`BFsz8cU`=>ZlU`nR79`gBUgp~ zjioKDjsG;OKt8SHC!MdG5xyTmg)$4{v6gaXlfNq!VKaYYsivdb>YwymfA_-@>vO+u zv9>+aVx2m5%JO=>R(5u_`Ws9~jvTR`d+s^w>8GEzo_gvj{uWcJ^^>3c#M-iDi*@tO zH(MJwZnQrB@sC@n_xr6|Z}nSGTUD07+iT@i^;uQz?bfee-30>q0}m-2X&hc1m3hS^ zbV=xvM8}F0F-bw6LLdcw3i=fEa#o{ETn0-DH&5Y4DP)=g7F7%+ zrVvO0OA1(2v4A5594X*P0Y?frR8fH=1q>-*NCATsT?#l-z>oq4FZc3uRz=8t^grUN zc%^he#l6$8QboK9O~Zaxqlk>Pvidbh|;)! z8fB9PhBPpwQ4aFhC>7;B8YE|VjFf?w`+33U1&5dWsYfd~C<8Azyn+MA)Z^wNFIc=_ z@dCoj4OJBYi`FuXr zj$eBIdDT9-yV}W2LL8DWl2hE`7P|xnF2CZ6D=r^!3`65i!g~`KxbmuH%a&brr2!Ng ze{WDYcNw^HiEIg1+kisj%FyGO$HjTf=F+{3!OI0rH-N6XT;)ofSRgLS?kn7Yx_P`; z1Zm=~asj%^Y%bj#f(nixSayZFicq%#WXDAr3l9ifceL@iG;;~6`-kFj#TA_3;*bJz z7nlOzx@TzIl@vQD#i0tsT|S}+luzjWL*n7(fhP8iXRvU}$F4u2ad}#y^(E-}*>Hj& z%pXo1_tzE1ZeJ$4#36tfcxLc(-f9JCN#OQ&`wGC3=gH=-G4AlZZ#>h50%(bgpF`s_ zU3W3+M{5fX*5s#iCX6OZZjC2%YV$KHv-Vb;c!M)xG*Rs5ntzn6 zA|}l>|An@X2r{B_Yl6kTWu>)cxdd*z+H?EzxXml9Ez9E2+`hshjNZBS_LV3-cdU&2 z;tK2bRn}I{D?AvW-bJ6BlSxE$jZ)}1Rngtz_| z32$2!uz%%1#?Av7ucaS+HT|Ftzq&u2z^mzpw4N}#lRuYlSrLC5SrNdCWpW1d=M$_u z5+tx?xd#l6{g#9!cdQcRcPx+Fl3?AL5WjVq=T0tM=^+Yoz;K~s4@fdZ&n09 zwtdLH=^f$t4;-+)*q=_|)r@q!AOP~0Rlv#rV#j~W!{1GQ;H%H>%}pvR3FLDee2i}&V0xMPGpq8*!Vc-kueFm`D)85Ye(kf zBge-dI^lafbDaH=+~FrPCmzWf-f?v5q0G@ovVGfD1=>3tm0w<&T~VG>&R&&OTAFjR zBB!h}x1y3W`n<}Dt*hc3Y&7TQzJZp$fu`Pm*?ank>Tq*!KYL66AZ_2V2ixShZ^Ab= zGB!3mG2$B^n^5S-#wW%`ML#|^x-}t?KWy`8*62eg#vjQXc_M4{$t>UFIX*D&$eMWc zn4BNU9KF+pADYdsJegBolU-h#TV4h1tkRQt<>kl9%d*QV@+zv)kf(zOQflezYw77} z?(G${fX9XYJ_6b)+<}c9`->eveWy3`s`Hz=^BOzz8oLO%cQiS5oyTj=?#w8{60bRb zHLZ>h?(DbxO3o4YFF$+QvEQ9_vZAB6rhBlqM|J{w*U{6xLv_8w2TJR;JuCzr&BRoW z9-H~`Rb}RzFW!6CGhh4Eu@`^YT3s?eHo}=O8uX+(PgV!YkL>!x_cuTIjW7ND>D@ng zx#6p?4RI!n20f`E_ICc?x$UhNp3XXUD6g=PGvQ~xb6dpxxxBWqxwQ6lYe(ns=-Bl1 zG-twS(1&DBbguXp+Fl@?IbC?Nyyzbh%q%(yI~A0c zWR+DEmR5)_C1nLgl_!ef+iE!3v47>jL507ksfRs4Q~1ITWx-c&zP;G-GX`uL8f~0; zuOAq#>KgR6_F_pXab{%@d*k3p#J#?Mgw(CSYjNz4RJLTFY0q!!ENG6f7q)a2w|1Ab z^=Nxo$RVZZfqC#1!=e}Nxnu7y?j84y$Z*oNp+Qe7Hcn+=&<82)c>I??f2;G&^8SXd zv5ARE&Vt3q}15f4o$hRNDvMB5Xy4!`$h)G zhWdNXHgq&qb0&-?9REVwgC9~l)7%shKl*UWviXW`iS(!@CPrzt(2lfs(Xja@g4=uC zqsJv-YD{`BbjGH}#)o`kG<9K!3F*4rwKBjzT$@>5nORbD!s|U=?9D7L%r5dC_m)Cj z$GoM|-72eOIOaTJMohGKdM3JoYs!MJbU>4UyMMyCb!2jMVw8>{WHT1`m<3#aa3>BUH8SXuPRJvX0@zHwR;wmUtx@Gjme4`I$`rtIj9`4O5FUu<}Ei5m|E3LM^ z9$!>ilT%WW<1NFT6D8Gj5gA}Q_KaIqpGx{yt^I>9?0UoQWvRX*uCYhNZ~dDUzDL0y zZj2@h{)qNb@c(J|-tavfKP=HaJjM=dIXi0-op8h8Xid*xiHooPPg?62o@;9w9C3EB zH_?WH5e(QJzB+ueIqURUH(z1za93e-r?<5m%8J5Q*oSl1Jot)1-_v(*80c;bAqO2r zPbxM}WjOH6_SBRw{%m*anbz*<>35u~2%|wyDmIS2xum-DXV6DK zD!j4l8=)uF$((?LAA)MB@mA&RV?K>DVKm|R7uuddAN{B(_(=^J7%IM!j)f4EYR0;A zHA44_=1c!-Y|PD9pI`2IC~IVRbaZNb1cHJY^!SUgX1Ry6M}ynD1tZaw$}cX-^%iA% zON6hAin6@kY{JEisw&;{SBwXxQ7D2U(9lK0?+^5^dio#%cmImnrx8IQ9(bPcSigva zf`C5h8-l^0+|jW~X3U(Y#=H|FS;%&BViZfy<5oNrr}~Nvej(z=j*q+hOK@opL)X&k zg0howU-x*v9UsS<%CeJmv@*S=^bfPjOWor^rrm%ISura7(;IvKyywlAcJH-Ef{KI* zN5mhIPom(DXdeZCMEfZC!^sK_&m{yuEYULJW7n+38FJ8@!(+9*L#1tj{?%9i(8kVu zl-`Z`b2V{1iuk zeSKGtO@CA%><&5T02)~6RPRu^i?6=@;#u~Vp;7iwdq`|>L>oAKb)=#t=X85v zQzz6EVvnYzxvR9LyJQBw3bA)n);#!X`^Lob!@H&?C)}Ligwd0VjZ@i}TK~=;D@!U* zy)!lGnCSo-^rT`Fu-}-NvHRsbuQwuJp(oXyKU3?>R)ys3j*^OvJAaLzVc_jA-F($= zR_dKFnh5xfzYAo~)H<_O8Zb1q_vm506V^&nv2pMdfQtqP2mAQtLjQ2@@X+w^Fw6ym zNq=jME)*lBp!qAl>pgOKqPu^9ONIvr#eR6SZ**wVH!(FfIygT3c=n`w{)h0<;dv39 zfin%JbbBWi8+ZO1KmDb@{oQ|e_=>RZUxnef{aqk?z6LVEuA$Pia`=j{R+5U1gP#C= z)zQ^`wyU$fyQ{0WyQi<89R{Pz)z1Xbm<;#a{VTrv|Kv!2XGd38M+cX5^!4`j_V)}7 z_Kpk=jSe#@#CXcxe(7Hw^A;b=_ns&yI9!l-q@dt=DU9E1QPKs$G2b%#j`#DT+O**o5#^6#IyL6~$gt);#zsb<=f42mUc+(HK3|oaUpUm;5i);;20f|R1nf6mw}024vT`yb_OH;B>dt?z z{VNAQvsGVseVfBqgwaI6Z~R>#`}y^+TF!PhpKWhyJKNUT(b**|)Ya3|)!#QT*grHl zEd3ML{15$s`}YkswY0W0x7MFMd-mM9w)S=ykEy@Gp5B3>p@&b5xWD&df4H#V?Yz8< z+?=-y^54!YfV+-*3)qhoc%d?8v)%nMxQIppLBUk)5Eo-BiHb&(SdV)=NPn-frMq#cQe5`74j|W)`@pfJ@P&0Fij}{gI9-7TBtc1RV!HUb7$a3SC@vQU@WxgGzZRp{H zrf`&WvHrT7$+y;?{?}aJHy!*D`6>$ji1tzNN3@TEKO$d+=To%!{euW zh8_O-_pDwRiK`;+-4m0fV&m9n*0dEgb}|DdycB6a+1^_jsek2kr6LCA!B_wO-COtm z-+NimJ~`nFAuBZKNyWzDpa1ur&;9I|uf32_+IFf0f})qjFpx80H0Vji#rsleq z=BAdG=5sAjP-{B`)YaMD-Pt$TJ22wrE57~RvuB{T=~PX9-I<2E+NQ?l*4D%*#EPm-Tjj?&19WqwINwuoep&;56rv?cA^C ztIaU5(dH;&D%w6&#{NqB0mq*C^OJRrHD~Io&(xi6Y&g~2)Y#Sv19x=xdLE5q+)8KB zJ>S0dL)JZe2W#u=YU=81>l@BAH8i%jwzQw??&`B1jfZr9et6v7Ut+yMdSTw-oczN% z1qXBUkK|+n{&0RF9WDA-M~X^V(%{Db%Dw{vQhg~>U;is4hSJTq4*rOI z5(R%m`zZJ$+DE}3k*~t>!z%snO!v*a_r5cIZfvq~VASEC7jlHJxGLgKR-|I%*k{%X zUzMNjJ=xJ)Im2Gn5n((Sk)|BwJoqZ>)n}i+dt-g+37R&&5!yKP!dP|WsB`rvITJ>Mo>XjH_Rl_@a`VwcZ$eGzmpdT3VaVwzjpOlUB?& zFzDth`X}Gt)m2qnU3sdu_Vk(4b#KmHnT3D;|T>AqV!|whGOlVVg}(nrSIH@iYtNiH!(Sh1tZS%i zZfb6Aqqo@A-IZqM>%dL-@s4PN9dC{ zPl2^hhw^hXa*NWlbJJ<>x%squ$m;FfLWYOO3*@7rdpxyse>%e`)#PPWfZft%Mo7Y1 zPan+5pL-QopDwGaEvu?7uRe8>@Tt0*hBNe_SZ`L<+R}Ko%Z&&8|GazPpI_^Ob-(xK zxgWjR^TW6L*nhOI|K2x;?m5u^Yu^&M!QaTXY~NFFhw)z~>hp&doiX=RKTL zdLX~xSYd^GJqF(kz^~BCkWlY1ZCkH=IDoH64OuUGQRBbsi67tmJmW8>Jb|JN`5`sHJLz4dPvHM|vRe`#<2ru)C5?O~yX{yoks z+rRPKFK=S#m$&CXs&d}qOc)J%r&_uL=pX*}*Y5w-E@rE~@KOh7!f2w{|Mr`=F!X!# z)j#atyOT3vG&9*lS@g1IxxO7>tvbK|TcN%>QYnXY(@oJtI_!p23=XKJD(6@*6;Y zKUpSYltc4oZ&fx%yvbs7qyZ^Q6yrk!8PeD2}zRp!edF{sbVo27ko zei8O_&7Wx{C~G#mOhC=|FUb__dGYxl-SN;r{M`@!*HX@e(L~8@q3xMHW-g2A_u2e@ z5S$B*XRi4JiMcGM-<{tNMk&n2q{R~W&shTUcd-5k|1bP{WbohA+GxpNF5b-lWPOWu zGk?AK7UG{5bG3#3t*y(^%HgqQ{##oWCwA|9_P+2Py@mFuxBRb1a$ZS4@pAfc_P-oB zw)0>ndP%EoYAvZblV4GjTV9=0R&~rwz0)qb=poF z7#Y!copbr=20M*U|MH78y^oG|^$(nCYO~WOr=}*~dB@(TrY5GQhDOKiw2;pXIx1<= z{FD1jIe!8D|A#%9^KH~$DPj3b+-7r^vBiJD?y)|?pWt3k@;aW@m6qgpBZuE_@{|A9{Wfw4 z&kHlxCV3_DkN?I`<#n~nOaDLdCa>84PkcD0B`P2O_Xigylg}re`_JrGH~%B}B~kN; z^#6hf) + public + procedure SetLiveService( Idx: integer; const LiveService: IInterface); + function Clone: TServiceList; + end; + public + FAffinity: TServiceAffinity; + FMembers: TServiceList; + FActiveIndex: integer; + FisPooled: boolean; + FMakeCollection: TCooperativeCollectionFactory; + FAddToCollection: TAddToCollectionProc; + FCollectionName: string; + procedure Create; + procedure Free; + function isEmpty: boolean; + end; + +IServiceProviderInternal = interface + ['{FD2CF9F3-477D-4505-8E74-3C866B1611F9}'] + function Internal_Acquire( const Svc: TGUID; const Client: IInterface; + out Intf; const Config: string; + const SecondaryProvider: IServiceProvider; + SecondaryIsOverride: boolean): boolean; + + function GnAcquire( const ServiceIID: TGUID; const Client: IInterface; + out Intf; const Config: string; + const InjectionOverride: IServiceProvider): boolean; + + function GetServices: TDictionary; + end; + +TServiceProvider = class( TInterfacedObject, IServiceProvider, IServiceProviderInternal) + private // IServiceProvider + function GetServiceAffinity( const ServiceIID: TGUID; const Config: string): TServiceAffinity; + function GetActiveArrayMemberCookie( const ServiceIID: TGUID; const Config: string): integer; + procedure SetActiveArrayMemberByCookie( const ServiceIID: TGUID; const Config: string; Cookie: integer); + function GetActiveArrayMemberName( const ServiceIID: TGUID; const Config: string): string; + procedure SetActiveArrayMemberByName( const ServiceIID: TGUID; const Config, Name: string); + function GetNameByCookie( Cookie: integer): string; + function GetIsPooled( const ServiceIID: TGUID; const Config: string): boolean; + procedure SetIsPooled( const ServiceIID: TGUID; const Config: string; Value: boolean); + function Gn: TGenericServiceProvider; + function GetGroupCount( const ServiceIID: TGUID; const Config: string): integer; + function GetCookies( const ServiceIID: TGUID; const Config: string): TIntegers; + function GetCookieByName( const ServiceIID: TGUID; const Config, Name: string): integer; + function GetCookieOfLiveService( const ServiceIID: TGUID; const Service: IInterface; const Config: string): integer; + function GetCookiesOfServiceClass( Registrant: TClass): TIntegers; + procedure SetCompetitiveAffinity( const ServiceIID: TGUID; const Config: string); + procedure SetCooperativeAffinity( const ServiceIID: TGUID; + const CollectionName, Config: string; + MakeCollection: TCooperativeCollectionFactory; + AddToCollection: TAddToCollectionProc); + function RegisterLiveService( const ServiceIID: TGUID; const Service: IInterface; + const Config: string = ''; const SelectionArrayMemberName: string = ''): integer; + function RegisterFlyweightService( const ServiceIID: TGUID; Factory: TServiceFactory; + const Config: string = ''; const SelectionArrayMemberName: string = ''): integer; + {$if CompilerVersion < 22} + function RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): integer; + {$else} + function RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): TIntegers; + {$ifend} + procedure DeregisterServiceByCookie( Cookie: integer); + procedure DeregisterServicesByCookie( const Cookies: TIntegers); + procedure DeregisterLiveServiceByName( const ServiceIID: TGUID; const Config: string = ''; const SelectionArrayMemberName: string = ''); + procedure DeregisterServicesOfClass( Registrant: TClass); + function Acquire( const ServiceIID: TGUID; const Client: IInterface; out Intf; const Config: string = ''; const InjectionOverride: IServiceProvider = nil): boolean; + function Clone: IServiceProvider; + procedure Merge( const Source: IServiceProvider); + procedure ShutDown; + + strict private + function AcquireOneService( const Client: IInterface; const SecondaryProvider: IServiceProvider; + const Config: string; const Svc: TGUID; + out Intf1; const Value1: RService; var isInception: boolean): boolean; + + private // IServiceProviderInternal + function Internal_Acquire( const Svc: TGUID; const Client: IInterface; + out Intf; const Config: string; + const SecondaryProvider: IServiceProvider; + SecondaryIsOverride: boolean): boolean; + function IServiceProviderInternal.GnAcquire = Acquire; + + function Internal_GetServices: TDictionary; + function IServiceProviderInternal.GetServices = Internal_GetServices; + + private + procedure OnServiceNotify( Sender: TObject; + const Item: RGroupOfServices; Action: TCollectionNotification); + constructor CreateAsClone( Source: TServiceProvider); + constructor BaseCreate; + function FindKey( Cookie: Integer; out Key: RServiceKey; out Idx: integer): boolean; + procedure RemoveGroup( const Key: RServiceKey); + function NextCookie: integer; + + private type TServiceProc = reference to function ( + const ServiceIID: TGUID; const Config, Id: string; + RegCls: TClass; ConstructorMethod: TRttiMethod): integer; + + function ParseServiceClass( + Registrant: TClass; const ServiceIID: TGUID; + ParseAction: TServiceProc; + var Cookies: TIntegers): integer; + + private + FGn: TGenericServiceProvider; + FServices: TDictionary; + FdoFreeGroupOnRemoval: boolean; + FNextCookie: integer; + FRtti: TRttiContext; + + public + constructor Create; + destructor Destroy; override; + end; + +implementation + + + + + + + + + + + + + + + + + + +uses SysUtils, TypInfo, Generics.Defaults; + +type +TSBDUnit_BaseAttributeClass = class of TSBDUnit_BaseAttribute; +TSuiteInjector = class; +IInjectableMember = interface + ['{EB594A82-EAAE-4555-BAA0-33F86E6B5D8D}'] + function IsInjectable: boolean; + function AsRttiMember: TRttiMember; + function MemberType: TRttiType; + procedure SetValue( const Inject: TValue); + end; + +TInjectableMember = class( TInterfacedObject, IInjectableMember) + protected + FOwner: TSuiteInjector; + + function IsInjectable: boolean; virtual; abstract; + function AsRttiMember: TRttiMember; virtual; abstract; + function MemberType: TRttiType; virtual; abstract; + procedure SetValue( const Inject: TValue); virtual; abstract; + public + constructor Create( Owner1: TSuiteInjector); + end; + +ISuiteInjector = interface + ['{72088119-43E6-4273-928B-0C84E0F84791}'] + procedure Inject( const Provider: IServiceProvider); + end; + +TSuiteInjector = class( TInterfacedObject, ISuiteInjector) + public + FInjectionSubject: TObject; + FServiceType : TRttiType; + FClient: IInterface; + FInjectionsClient: IInterface; + FInjectionOverride: IServiceProvider; + + constructor Create( InjectionSubject1: TObject; + ServiceType1 : TRttiType; + const Client1: IInterface; + const InjectionOverride: IServiceProvider); + destructor Destroy; override; + procedure Inject( const Provider: IServiceProvider); + + protected + FMembers: TEnumerable; + function GetMembers: TEnumerable; virtual; abstract; + end; +TSuiteInjectorClass = class of TSuiteInjector; +TSuitesArray = array[0..1] of TSuiteInjectorClass; + + +TDataMemberInjector = class( TSuiteInjector) + protected + function GetMembers: TEnumerable; override; + end; + +TWritablePropertyInjector = class( TSuiteInjector) + protected + function GetMembers: TEnumerable; override; + end; + +TInjectableDataMember = class( TInjectableMember) + private + FMember: TRttiField; + protected + function IsInjectable: boolean; override; + function AsRttiMember: TRttiMember; override; + function MemberType: TRttiType; override; + procedure SetValue( const Inject: TValue); override; + public + constructor Create( Owner1: TSuiteInjector; Member1: TRttiField); + end; + +TInjectablePropMember = class( TInjectableMember) + private + FMember: TRttiProperty; + protected + function IsInjectable: boolean; override; + function AsRttiMember: TRttiMember; override; + function MemberType: TRttiType; override; + procedure SetValue( const Inject: TValue); override; + public + constructor Create( Owner1: TSuiteInjector; Member1: TRttiProperty); + end; + + +TMemberEnumable = class( TEnumerable) + private + FMembers: TArray; + FSuite: TSuiteInjector; + public + constructor Create( Suite1: TSuiteInjector); virtual; + end; + +TPropEnumerable = class( TMemberEnumable) + protected + function DoGetEnumerator: TEnumerator; override; + private + constructor Create( Suite1: TSuiteInjector); override; + end; + +TFieldEnumerable = class( TMemberEnumable) + protected + function DoGetEnumerator: TEnumerator; override; + private + constructor Create( Suite1: TSuiteInjector); override; + end; + +TMemberEnumator = class( TEnumerator) + protected + FOwner: TMemberEnumable; + FIndex: integer; + function DoMoveNext: Boolean; override; + public + constructor Create( Owner1: TMemberEnumable); + end; + +TPropEnumator = class( TMemberEnumator) + protected + function DoGetCurrent: IInjectableMember; override; + public + constructor Create( Owner1: TMemberEnumable); + end; + +TFieldEnumator = class( TMemberEnumator) + protected + function DoGetCurrent: IInjectableMember; override; + public + constructor Create( Owner1: TMemberEnumable); + end; + +TServiceEqualityComparer = class( TInterfacedObject, IEqualityComparer) + private + function Key_Equals( const Left, Right: RServiceKey): boolean; + function IEqualityComparer.Equals = Key_Equals; + function Key_GetHashCode( const Value: RServiceKey): integer; + function IEqualityComparer.GetHashCode = Key_GetHashCode; + end; + + +constructor TServiceProvider.BaseCreate; +begin +FGn := TGenericServiceProvider.Create( self); +FServices := TDictionary.Create( TServiceEqualityComparer.Create); +FServices.OnValueNotify := OnServiceNotify; +FdoFreeGroupOnRemoval := False; +FRtti.Create +end; + + +constructor TServiceProvider.Create; +begin +BaseCreate; +FNextCookie := 1; + +RegisterFlyweightService( IServiceProvider, + function( const Config: string; + const ServiceProvider: IServiceProvider): IInterface + begin + result := self as IServiceProvider + end, '', ''); + +RegisterFlyweightService( IServiceProvider, + function( const Config: string; + const ServiceProvider: IServiceProvider): IInterface + begin + result := StandardServiceProvider + end, 'New', '') +end; + +constructor TServiceProvider.CreateAsClone( Source: TServiceProvider); +var + Pair: TPair; + ClonedGroup: RGroupOfServices; +begin +BaseCreate; +FNextCookie := Source.FNextCookie; +for Pair in Source.FServices do + begin + ClonedGroup := Pair.Value; + ClonedGroup.FMembers := ClonedGroup.FMembers.Clone; + FServices.Add( Pair.Key, ClonedGroup) + end +end; + + +procedure TServiceProvider.Merge( const Source: IServiceProvider); +var + IntrnlIntf: IServiceProviderInternal; + Pair: TPair; + Group: RGroupOfServices; + Service, Addend: RService; + isNewGroup: boolean; +begin +if Supports( Source, IServiceProviderInternal, IntrnlIntf) then + for Pair in IntrnlIntf.GetServices do + begin + isNewGroup := not FServices.ContainsKey( Pair.Key); + if isNewGroup then + Group.Create + else + Group := FServices[ Pair.Key]; + for Service in Pair.Value.FMembers do + begin + Addend := Service; + Addend.FCookie := NextCookie; + Group.FMembers.Add( Addend) + end; + if isNewGroup then + Group.FAffinity := Pair.Value.FAffinity; + if (not assigned( Group.FMakeCollection)) and + (not assigned( Group.FAddToCollection)) then + begin + Group.FMakeCollection := Pair.Value.FMakeCollection; + Group.FAddToCollection := Pair.Value.FAddToCollection + end; + Group.FisPooled := Group.FisPooled or Pair.Value.FisPooled; + FServices.AddOrSetValue( Pair.Key, Group) + end +end; + + +procedure TServiceProvider.OnServiceNotify( Sender: TObject; + const Item: RGroupOfServices; Action: TCollectionNotification); +begin +if FdoFreeGroupOnRemoval and (Action = cnRemoved) then + Item.Free +end; + + + +function TServiceProvider.ParseServiceClass( + Registrant: TClass; const ServiceIID: TGUID; ParseAction: TServiceProc; + var Cookies: TIntegers): integer; +var + ServiceType: TRttiType; + A: TCustomAttribute; + M: TRttiMethod; + ConfigAttrib: Configuration; + j: integer; + ConstructorParamCount: integer; + Params: TArray; + Configs, Blacklist: TStrings; + sConfig: string; + Cookie: integer; + L: integer; +begin +SetLength( Cookies, 0); +result := 0; +L := 1; +if assigned( Registrant) and Supports( Registrant, ServiceIID) then + begin + Configs := TStringList.Create; + Blacklist := TStringList.Create; + try + ServiceType := FRtti.GetType( Registrant); + for A in ServiceType.GetAttributes do + if A is BlacklistConfigs then + Blacklist.AddStrings( BlacklistConfigs(A).FConfigs); + for M in ServiceType.GetMethods do + begin + if not M.IsConstructor then continue; + ConstructorParamCount := -1; + Params := M.GetParameters; + if Length( Params) = 0 then + ConstructorParamCount := 0 + else if (Length( Params) = 1) and + (Params[0].ParamType.TypeKind = tkUString) and + (Params[0].Flags = [pfConst]) then + ConstructorParamCount := 1; + if ConstructorParamCount = -1 then continue; + for A in M.GetAttributes do + begin + if not (A is Configuration) then continue; + ConfigAttrib := Configuration(A); + for j := 0 to ConfigAttrib.FConfigs.Count - 1 do + begin + sConfig := ConfigAttrib.FConfigs[j]; + if (Configs .IndexOf( sConfig) <> -1) or + (Blacklist.IndexOf( sConfig) <> -1) then + continue; + Configs.Add( sConfig); + if assigned( ParseAction) then + Cookie := ParseAction( ServiceIID, sConfig, ConfigAttrib.FId, Registrant, M) + else + Cookie := 0; + if Cookie >= 1 then + begin + if result = 0 then + result := Cookie; + SetLength( Cookies, L); + Cookies[L-1] := Cookie; + Inc( L) + end; + end + end + end + finally + Configs.Free; + Blacklist.Free + end + end +end; + +procedure RService.Create; +begin +FLiveService := nil; +FFlyweightCreateBase := nil; +FFlyweightFactory := nil; +FConstructor := nil; +FCookie := -1; +FIdentifier := '' +end; + + + +procedure RGroupOfServices.Create; +begin +FAffinity := afCompetitive; +FCollectionName := ''; +FMembers := TServiceList.Create; +FMakeCollection := nil; +FAddToCollection := nil; +FIsPooled := False; +FActiveIndex := -1 +end; + +procedure RGroupOfServices.Free; +begin +FMembers.Free +end; + + +function RGroupOfServices.isEmpty: boolean; +begin +result := FMembers.Count = 0; +if result and (FAffinity = afCooperative) then + result := (not assigned( FMakeCollection)) and (not assigned( FAddToCollection)) +end; + +function RGroupOfServices.TServiceList.Clone: TServiceList; +begin +result := TServiceList.Create( self) +end; + +procedure RGroupOfServices.TServiceList.SetLiveService( + Idx: integer; const LiveService: IInterface); +var + Member: RService; +begin +if (Idx < 0) or (Idx >= Count) then exit; +Member := Items[Idx]; +if assigned( Member.FLiveService) then exit; +Member.FLiveService := LiveService; +Items[ Idx] := Member +end; + + +function TServiceProvider.Internal_GetServices: TDictionary; +begin +result := FServices +end; + + +function TServiceProvider.Acquire( const ServiceIID: TGUID; + const Client: IInterface; out Intf; const Config: string; + const InjectionOverride: IServiceProvider): boolean; +begin +result := Internal_Acquire( ServiceIID, Client, Intf, Config, InjectionOverride, True) +end; + + +function TServiceProvider.AcquireOneService( + const Client: IInterface; const SecondaryProvider: IServiceProvider; + const Config: string; const Svc: TGUID; + out Intf1; const Value1: RService; var isInception: boolean): boolean; +var + Obj: TObject; + IntfResult: IInterface; + + procedure CreateFromFlyweight; + const + Suites: TSuitesArray = (TDataMemberInjector, TWritablePropertyInjector); + var + Cls: TClass; + ServiceType: TRttiType; + SuiteCls: TSuiteInjectorClass; + Hold: IInterface; + Injector: ISuiteInjector; + A: TArray; // Work-around bug in D2010-with-packages + begin + Cls := Value1.FFlyweightCreateBase; + if assigned( Cls) then + begin + Obj := Cls.NewInstance; + Supports( Obj, IInterface, Hold); + // ^-- Needed for reference counted objects which do not use + // the BeforeConstruction property to set the reference count + // to one. + ServiceType := FRtti.GetType( Cls); + for SuiteCls in Suites do + begin + Injector := nil; + Injector := SuiteCls.Create( Obj, ServiceType, Client, SecondaryProvider) as ISuiteInjector; + Injector.Inject( self) + end; + end + else + Obj := nil; + if not assigned( Value1.FConstructor) then + raise Exception.Create( 'Internal error - AcquireOneService'); + A := Value1.FConstructor.GetParameters; + if Length( A) = 0 then + Value1.FConstructor.Invoke( Obj, []) + else + Value1.FConstructor.Invoke( Obj, [Config]); + Obj.AfterConstruction; + result := Supports( Obj, Svc, IntfResult); + if result then + IInterface( Intf1) := IntfResult + else + FreeAndNil( Obj); + isInception := result + end; + +begin +isInception := False; +IInterface( Intf1) := Value1.FLiveService; +result := assigned( IInterface( Intf1)); +if result then exit; +Obj := nil; +try + if not assigned( Value1.FFlyweightFactory) then + CreateFromFlyweight + else + begin + IntfResult := Value1.FFlyweightFactory( Config, self); + result := Supports( IntfResult, Svc, Intf1); + isInception := result + end + except + begin + Obj.Free; + raise + end + end +end; + + +function TServiceProvider.Internal_Acquire( const Svc: TGUID; + const Client: IInterface; out Intf; const Config: string; + const SecondaryProvider: IServiceProvider; + SecondaryIsOverride: boolean): boolean; +const + Suites: array[0..1] of TSuiteInjectorClass = (TDataMemberInjector, TWritablePropertyInjector); +var + Key: RServiceKey; + Value: RService; + Group: RGroupOfServices; + Gang: IInterface; + Gang_AsInterfaceList: IInterfaceList; + GangMember: IInterface; + isNewbie: boolean; + Idx: integer; + +begin +Key.FServiceIID := Svc; +Key.FConfig := Config; +result := FServices.TryGetValue( Key, Group); +if not result then exit; +case Group.FAffinity of + afCooperative: + begin + Gang_AsInterfaceList := nil; + if assigned( Group.FMakeCollection) then + Gang := Group.FMakeCollection( Config) + else + Gang := IInterface( (TInterfaceList.Create as IInterfaceList)); + IInterface( Intf) := Gang; + for Idx := 0 to Group.FMembers.Count - 1 do + begin + Value := Group.FMembers[ Idx]; + if AcquireOneService( Client, SecondaryProvider, Config, Svc, GangMember, Value, isNewbie) then + begin + if assigned( Group.FAddToCollection) then + Group.FAddToCollection( Gang, GangMember) + else if Supports( Gang, IInterfaceList, Gang_AsInterfaceList) then + Gang_AsInterfaceList.Add( GangMember) + else + isNewbie := False; + if isNewbie and Group.FisPooled then + Group.FMembers.SetLiveService( Idx, GangMember) + end + end + end; + afCompetitive: + begin + Idx := Group.FActiveIndex; + result := (Idx >= 0) and (Idx < Group.FMembers.Count); + if not result then exit; + result := AcquireOneService( Client, SecondaryProvider, Config, Svc, Intf, Group.FMembers[Idx], isNewbie); + if isNewbie and Group.FisPooled then + Group.FMembers.SetLiveService( Idx, IInterface( Intf)) + end + end +end; + +function TServiceProvider.Clone: IServiceProvider; +begin +result := TServiceProvider.CreateAsClone( self) +end; + +procedure TServiceProvider.DeregisterLiveServiceByName( + const ServiceIID: TGUID; const Config, SelectionArrayMemberName: string); +begin +DeregisterServiceByCookie( GetCookieByName( ServiceIID, Config, SelectionArrayMemberName)) +end; + +procedure TServiceProvider.DeregisterServiceByCookie( Cookie: integer); +var + Key: RServiceKey; + Idx: Integer; + Group: RGroupOfServices; +begin +if (Cookie >= 1) and FindKey( Cookie, Key, Idx) then + begin + Group := FServices.Items[ Key]; + Group.FMembers.Delete( Idx); + if Group.FActiveIndex >= Group.FMembers.Count then + Group.FActiveIndex := Group.FMembers.Count - 1; + if Group.IsEmpty then + RemoveGroup( Key) + else + FServices.Items[Key] := Group + end; +end; + +procedure TServiceProvider.DeregisterServicesByCookie( const Cookies: TIntegers); +var + Cookie: integer; +begin +for Cookie in Cookies do + DeregisterServiceByCookie( Cookie) +end; + +procedure TServiceProvider.DeregisterServicesOfClass( Registrant: TClass); +begin +DeregisterServicesByCookie( GetCookiesOfServiceClass( Registrant)) +end; + +destructor TServiceProvider.Destroy; +begin +ShutDown; +FServices.Free; +FRtti.Free; +FGn.Free; +inherited +end; + +function TServiceProvider.FindKey( + Cookie: Integer; out Key: RServiceKey; out Idx: integer): boolean; +var + Pair: TPair; + Service: RService; +begin +result := False; +for Pair in FServices do + begin + Idx := 0; + for Service in Pair.Value.FMembers do + begin + result := Service.FCookie = Cookie; + if result then Break; + Inc( Idx) + end; + if not result then continue; + Key := Pair.Key; + break + end +end; + +function TServiceProvider.GetActiveArrayMemberCookie( + const ServiceIID: TGUID; const Config: string): integer; +var + Key: RServiceKey; + Group: RGroupOfServices; + Members: RGroupOfServices.TServiceList; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +Members := nil; +if FServices.ContainsKey( Key) then + begin + Group := FServices.Items[Key]; + Members := Group.FMembers; + result := Group.FActiveIndex + end + else + result := -1; +if (result >= 0) and (result < Members.Count) then + result := Members[result].FCookie + else + result := 0 +end; + +function TServiceProvider.GetActiveArrayMemberName( + const ServiceIID: TGUID; const Config: string): string; +var + Key: RServiceKey; + Idx: integer; + Group: RGroupOfServices; + Members: RGroupOfServices.TServiceList; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +Members := nil; +if FServices.ContainsKey( Key) then + begin + Group := FServices.Items[Key]; + Members := Group.FMembers; + Idx := Group.FActiveIndex + end + else + Idx := -1; +if (Idx >= 0) and (Idx < Members.Count) then + result := Members[Idx].FIdentifier + else + result := '' +end; + +function TServiceProvider.GetCookieByName( + const ServiceIID: TGUID; const Config, Name: string): integer; +var + Key: RServiceKey; + Service: RService; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +result := 0; +if FServices.ContainsKey( Key) then + for Service in FServices.Items[Key].FMembers do + begin + if Service.FIdentifier <> Name then continue; + result := Service.FCookie; + break + end +end; + +function TServiceProvider.GetCookieOfLiveService( + const ServiceIID: TGUID; const Service: IInterface; const Config: string): integer; +var + Key: RServiceKey; + ServiceRec: RService; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +result := 0; +if FServices.ContainsKey( Key) then + for ServiceRec in FServices.Items[Key].FMembers do + begin + if ServiceRec.FLiveService <> Service then continue; + result := ServiceRec.FCookie; + break + end +end; + +function TServiceProvider.GetCookies( + const ServiceIID: TGUID; const Config: string): TIntegers; +var + Key: RServiceKey; + Service: RService; + L: integer; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +L := 1; +if FServices.ContainsKey( Key) then + for Service in FServices.Items[Key].FMembers do + if Service.FCookie >= 1 then + begin + SetLength( result, L); + result[L-1] := Service.FCookie; + Inc( L) + end; +end; + +function TServiceProvider.GetCookiesOfServiceClass( + Registrant: TClass): TIntegers; +var + Group: RGroupOfServices; + Service: RService; + L: integer; +begin +L := 1; +for Group in FServices.Values do + for Service in Group.FMembers do + begin + if Service.FFlyweightCreateBase <> Registrant then continue; + SetLength( result, L); + result[L-1] := Service.FCookie; + Inc( L) + end +end; + +function TServiceProvider.GetGroupCount( + const ServiceIID: TGUID; const Config: string): integer; +var + Key: RServiceKey; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + result := FServices.Items[Key].FMembers.Count + else + result := 0 +end; + +function TServiceProvider.GetIsPooled( + const ServiceIID: TGUID; const Config: string): boolean; +var + Key: RServiceKey; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +result := FServices.ContainsKey( Key) and FServices.Items[Key].FisPooled +end; + +function TServiceProvider.GetNameByCookie( Cookie: integer): string; +var + Key: RServiceKey; + Idx: integer; +begin +if FindKey( Cookie, Key, Idx) then + result := FServices.Items[Key].FMembers[Idx].FIdentifier + else + result := '' +end; + +function TServiceProvider.GetServiceAffinity( + const ServiceIID: TGUID; const Config: string): TServiceAffinity; +var + Key: RServiceKey; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + result := FServices.Items[Key].FAffinity + else + result := afCompetitive +end; + +function TServiceProvider.Gn: TGenericServiceProvider; +// Design notes +// 1. TServiceProvider owns and weakly points to an instance of +// TGenericServiceProvider (via FGn). +// 2. TGenericServiceProvider weakly points (data member = FController) back to +// the parent TServiceProvider through the IServiceProviderInternal +// interface. +begin +result := FGn +end; + + +function TServiceProvider.NextCookie: integer; +begin +result := FNextCookie; +Inc( FNextCookie) +end; + +function TServiceProvider.RegisterFlyweightService( + const ServiceIID: TGUID; Factory: TServiceFactory; const Config, + SelectionArrayMemberName: string): integer; +var + Key: RServiceKey; + Group: RGroupOfServices; + Value: RService; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + Group := FServices.Items[ Key] + else + Group.Create; +Value.FLiveService := nil; +Value.FFlyweightFactory := Factory; +Value.FIdentifier := SelectionArrayMemberName; +result := NextCookie; +Value.FCookie := result; +Group.FMembers.Add( Value); +if Group.FActiveIndex = -1 then + Group.FActiveIndex := 0; +FServices.AddOrSetValue( Key, Group) +end; + +function TServiceProvider.RegisterLiveService( + const ServiceIID: TGUID; const Service: IInterface; const Config, + SelectionArrayMemberName: string): integer; +var + Key: RServiceKey; + Group: RGroupOfServices; + Value: RService; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + Group := FServices.Items[ Key] + else + Group.Create; +Value.FFlyweightCreateBase := nil; +Value.FFlyweightFactory := nil; +Value.FLiveService := Service; +Value.FIdentifier := SelectionArrayMemberName; +result := NextCookie; +Value.FCookie := result; +Group.FMembers.Add( Value); +if Group.FActiveIndex = -1 then + Group.FActiveIndex := 0; +FServices.AddOrSetValue( Key, Group) +end; + +{$if CompilerVersion < 22} +function TServiceProvider.RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): integer; +{$else} +function TServiceProvider.RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): TIntegers; +{$ifend} +var + AllCookies: TIntegers; + FirstCookie: integer; +begin +FirstCookie := + ParseServiceClass( Registrant, ServiceIID, + function ( + const ServiceIID: TGUID; const Config, Id: string; + RegCls: TClass; ConstructorMethod: TRttiMethod): integer + var + Key: RServiceKey; + Service: RService; + Group: RGroupOfServices; + begin + result := NextCookie; + Key.FServiceIID := ServiceIID; + Key.FConfig := Config; + if FServices.ContainsKey( Key) then + Group := FServices[ Key] + else + Group.Create; + Service.Create; + Service.FFlyweightCreateBase := RegCls; + Service.FConstructor := ConstructorMethod; + Service.FCookie := result; + Service.FIdentifier := Id; + Group.FMembers.Add( Service); + if Group.FActiveIndex < 0 then + Group.FActiveIndex := 0; + FServices.AddOrSetValue( Key, Group) + end, + AllCookies); +{$if CompilerVersion < 22} +result := FirstCookie; +{$else} +result := AllCookies; +{$ifend} +if FirstCookie = 0 then + raise Exception.CreateFmt( 'TServiceProvider.RegisterServiceClass - ' + + '%s not validly decorated for registration.
', [Registrant.ClassName]) +end; + +procedure TServiceProvider.RemoveGroup( const Key: RServiceKey); +begin +FdoFreeGroupOnRemoval := True; +try + FServices.Remove( Key) +finally + FdoFreeGroupOnRemoval := False + end +end; + +procedure TServiceProvider.SetActiveArrayMemberByCookie( + const ServiceIID: TGUID; const Config: string; Cookie: integer); +var + Key: RServiceKey; + Group: RGroupOfServices; + Idx: Integer; +begin +if Cookie <= 0 then exit; +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if not FServices.ContainsKey( Key) then exit; +Group := FServices.Items[ Key]; +for Idx := 0 to Group.FMembers.Count - 1 do + begin + if Group.FMembers[Idx].FCookie <> Cookie then continue; + if Group.FActiveIndex <> Idx then + begin + Group.FActiveIndex := Idx; + FServices.Items[ Key] := Group + end; + break + end +end; + +procedure TServiceProvider.SetActiveArrayMemberByName( + const ServiceIID: TGUID; const Config, Name: string); +var + Key: RServiceKey; + Group: RGroupOfServices; + Value: RService; + Cookie: integer; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if not FServices.ContainsKey( Key) then exit; +Group := FServices.Items[ Key]; +Cookie := 0; +for Value in Group.FMembers do + begin + if Value.FIdentifier <> Name then continue; + Cookie := Value.FCookie; + break + end; +if Cookie >= 1 then + SetActiveArrayMemberByCookie( ServiceIID, Config, Cookie) +end; + +procedure TServiceProvider.SetCompetitiveAffinity( + const ServiceIID: TGUID; const Config: string); +var + Key: RServiceKey; + Group: RGroupOfServices; +begin +if GetServiceAffinity( ServiceIID, Config) = afcompetitive then exit; +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + Group := FServices.Items[ Key] + else + Group.Create; +Group.FAffinity := afcompetitive; +if (Group.FActiveIndex < 0) or + (Group.FActiveIndex >= Group.FMembers.Count) then + Group.FActiveIndex := 0; +Group.FMakeCollection := nil; +Group.FAddToCollection := nil; +if Group.isEmpty then + begin + if FServices.ContainsKey( Key) then + RemoveGroup( Key) + else + Group.Free + end + else + FServices.AddOrSetValue( Key, Group) +end; + +procedure TServiceProvider.SetCooperativeAffinity( + const ServiceIID: TGUID; + const CollectionName, Config: string; + MakeCollection: TCooperativeCollectionFactory; + AddToCollection: TAddToCollectionProc); +var + Key: RServiceKey; + Group: RGroupOfServices; +begin +if GetServiceAffinity( ServiceIID, Config) = afCooperative then exit; +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + Group := FServices.Items[ Key] + else + Group.Create; +if CollectionName <> '' then + Group.FCollectionName := CollectionName; +Group.FAffinity := afCooperative; +Group.FMakeCollection := MakeCollection; +Group.FAddToCollection := AddToCollection; +FServices.AddOrSetValue( Key, Group) +end; + +procedure TServiceProvider.SetIsPooled( + const ServiceIID: TGUID; const Config: string; Value: boolean); +var + Key: RServiceKey; + Group: RGroupOfServices; +begin +Key.FServiceIID := ServiceIID; +Key.FConfig := Config; +if FServices.ContainsKey( Key) then + begin + Group := FServices.Items[Key]; + if Group.FisPooled <> Value then + begin + Group.FisPooled := Value; + FServices.Items[Key] := Group + end + end + else if Value then + raise Exception.Create('Cannot set isPooled on unregistered service'); +end; + +procedure TServiceProvider.ShutDown; +begin +FdoFreeGroupOnRemoval := True; +try + FServices.Clear +finally + FdoFreeGroupOnRemoval := False + end; +if assigned( FGn) then + FGn.ShutDown +end; + + +constructor TSuiteInjector.Create( + InjectionSubject1: TObject; ServiceType1: TRttiType; + const Client1: IInterface; const InjectionOverride: IServiceProvider); +begin +FInjectionSubject := InjectionSubject1; +FServiceType := ServiceType1; +FClient := Client1; +FInjectionOverride := InjectionOverride; +Supports( FInjectionSubject, IInterface, FInjectionsClient) +end; + + +destructor TSuiteInjector.Destroy; +begin +FMembers.Free; +inherited +end; + +procedure TSuiteInjector.Inject( const Provider: IServiceProvider); +var + Member: IInjectableMember; + isInjection: boolean; + sInjectionConfig: string; + Inject: IInterface; + InjectAsRttiValue: TValue; + MemberType1: TRttiType; + doInject: boolean; + InjectableGUID: TGUID; + AvailableCount: integer; + InjectionAttri: TSBDUnit_BaseAttribute; + Providers: TList; + SelectedProvider, Provider1: IServiceProvider; + isMarkedCollection: boolean; + CollectionAttri: TSBDUnit_BaseAttribute; + sColName: string; + Pair: TPair; + isIInterfaceList: boolean; + + function IsMemberDecorated( const Memb: IInjectableMember; AttriCls: TSBDUnit_BaseAttributeClass; + var Attri: TSBDUnit_BaseAttribute): boolean; + var + Run: TCustomAttribute; + begin + result := False; + for Run in Memb.AsRttiMember.GetAttributes do + begin + result := Run.InheritsFrom( AttriCls); + if not result then continue; + Attri := Run as TSBDUnit_BaseAttribute; + break + end; + end; + +begin +for Member in GetMembers do + begin + MemberType1 := Member.MemberType; + sInjectionConfig := ''; + Inject := nil; + InjectionAttri := nil; + isInjection := IsMemberDecorated( Member, Injection, InjectionAttri); + if isInjection then + sInjectionConfig := (InjectionAttri as Injection).FConfig; + doInject := False; + if isInjection and + (MemberType1.TypeKind = tkInterface) and + (MemberType1 is TRttiInterfaceType) and + Member.IsInjectable then + begin + InjectableGUID := TRttiInterfaceType( MemberType1).GUID; + Providers := TList.Create; + try + if assigned( FInjectionOverride) then + Providers.Add( FInjectionOverride); + if assigned( Provider) then + Providers.Add( Provider); + SelectedProvider := Provider; + isIInterfaceList := IsEqualGUID( TRttiInterfaceType( MemberType1).GUID, IInterfaceList); + isMarkedCollection := IsMemberDecorated( Member, Collection, CollectionAttri); + if isMarkedCollection then + sColName := (CollectionAttri as Collection).FName + else + sColName := ''; + AvailableCount := 0; + for Provider1 in Providers do + begin + if not isMarkedCollection then + AvailableCount := Provider1.GetGroupCount( InjectableGUID, sInjectionConfig) + else + begin + for Pair in (Provider1 as IServiceProviderInternal).GetServices do + begin + if (Pair.Key.FConfig = sInjectionConfig) and + (Pair.Value.FAffinity = afCooperative) and + (Pair.Value.FCollectionName = sColName) and + (Pair.Value.FMembers.Count > 0) and + (assigned( Pair.Value.FMakeCollection) or isIInterfaceList) then + begin + InjectableGUID := Pair.Key.FServiceIID; + Inc( AvailableCount, Pair.Value.FMembers.Count); + break + end + end + end; + if AvailableCount = 0 then continue; + SelectedProvider := Provider1; + break + end; + if AvailableCount = 0 then + begin + doInject := IsEqualGUID( InjectableGUID, IInterface) and + (sInjectionConfig = sClientRef) and + assigned( FClient); + if doInject then + Inject := FClient + end + else + doInject := (SelectedProvider as IServiceProviderInternal).Internal_Acquire( + InjectableGUID, FInjectionsClient, Inject, sInjectionConfig, nil, False) + finally + Providers.Free + end; + if doInject then + begin + TValue.Make( @Inject, Member.MemberType.Handle, InjectAsRttiValue); + Member.SetValue( InjectAsRttiValue) + end + end; + end +end; + + +function TDataMemberInjector.GetMembers: TEnumerable; +begin +if not Assigned( FMembers) then + FMembers := TFieldEnumerable.Create( self); +result := FMembers +end; + + + +function TWritablePropertyInjector.GetMembers: TEnumerable; +begin +if not Assigned( FMembers) then + FMembers := TPropEnumerable.Create( self); +result := FMembers +end; + + + +constructor TInjectableMember.Create( Owner1: TSuiteInjector); +begin +FOwner := Owner1 +end; + + +function TInjectableDataMember.AsRttiMember: TRttiMember; +begin +result := FMember +end; + +constructor TInjectableDataMember.Create( + Owner1: TSuiteInjector; Member1: TRttiField); +begin +inherited Create( Owner1); +FMember := Member1 +end; + + +function TInjectableDataMember.IsInjectable: boolean; +begin +result := True +end; + + +function TInjectableDataMember.MemberType: TRttiType; +begin +result := FMember.FieldType +end; + + +procedure TInjectableDataMember.SetValue( const Inject: TValue); +begin +FMember.SetValue( FOwner.FInjectionSubject, Inject) +end; + + +function TInjectablePropMember.AsRttiMember: TRttiMember; +begin +result := FMember +end; + +constructor TInjectablePropMember.Create( + Owner1: TSuiteInjector; Member1: TRttiProperty); +begin +inherited Create( Owner1); +FMember := Member1 +end; + +function TInjectablePropMember.IsInjectable: boolean; +begin +result := FMember.IsWritable and (FMember is TRttiInstanceProperty) +end; + +function TInjectablePropMember.MemberType: TRttiType; +begin +result := FMember.PropertyType +end; + +procedure TInjectablePropMember.SetValue( const Inject: TValue); +begin +FMember.SetValue( FOwner.FInjectionSubject, Inject) +end; + +{ TMemberEnumable } + +constructor TMemberEnumable.Create( Suite1: TSuiteInjector); +begin +FSuite := Suite1 +end; + + +constructor TPropEnumerable.Create( Suite1: TSuiteInjector); +var + A: TArray; // Work-around D1020-with-delphi bug +begin +inherited Create( Suite1); +A := FSuite.FServiceType.GetProperties; +FMembers := A +end; + +function TPropEnumerable.DoGetEnumerator: TEnumerator; +begin +result := TPropEnumator.Create( self) +end; + + +constructor TFieldEnumerable.Create( Suite1: TSuiteInjector); +var + A: TArray; // Needed to work-around D2010-with-packages bug. +begin +inherited Create( Suite1); +A := FSuite.FServiceType.GetFields; +FMembers := A +end; + +function TFieldEnumerable.DoGetEnumerator: TEnumerator; +begin +result := TFieldEnumator.Create( self) +end; + + +constructor TMemberEnumator.Create( Owner1: TMemberEnumable); +begin +FOwner := Owner1; +FIndex := -1 +end; + +function TMemberEnumator.DoMoveNext: Boolean; +begin +result := FIndex < Length( FOwner.FMembers); +if not result then exit; +inc( FIndex); +result := FIndex < Length( FOwner.FMembers) +end; + + +constructor TPropEnumator.Create( Owner1: TMemberEnumable); +begin +inherited Create( Owner1) +end; + +function TPropEnumator.DoGetCurrent: IInjectableMember; +begin +result := TInjectablePropMember.Create( FOwner.FSuite, FOwner.FMembers[FIndex]) +end; + + +constructor TFieldEnumator.Create(Owner1: TMemberEnumable); +begin +inherited Create( Owner1) +end; + +function TFieldEnumator.DoGetCurrent: IInjectableMember; +begin +result := TInjectableDataMember.Create( FOwner.FSuite, FOwner.FMembers[FIndex]) +end; + + +function TServiceEqualityComparer. + Key_Equals( const Left, Right: RServiceKey): boolean; +begin +result := IsEqualGUID( Left.FServiceIID, Right.FServiceIID) and + (Left.FConfig = Right.FConfig) +end; + + +{$IF CompilerVersion < 24} +function Low( const s: string): integer; inline; +begin +result := 1; +end; +{$IFEND} + +function TServiceEqualityComparer.Key_GetHashCode( + const Value: RServiceKey): integer; +var + L: integer; +begin +result := BobJenkinsHash( Value.FServiceIID, SizeOf( Value.FServiceIID), 0); +L := Length( Value.FConfig); +if L > 0 then + result := BobJenkinsHash( Value.FConfig[ Low( Value.FConfig)], L * SizeOf( Char), result) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/SBD.ServiceProvider.pas b/LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/SBD.ServiceProvider.pas new file mode 100644 index 0000000..bdccbab --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/external-libraries/sbd-dependency-injection/SBD.ServiceProvider.pas @@ -0,0 +1,281 @@ +unit SBD.ServiceProvider; +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +// +// COPYRIGHT NOTICE +// ================ +// copyright (c) Sean B. Durkin, 2014 +// The copyright holder and author, is and was Sean B. Durkin of Sydney, +// Australia. +// +// +// STATEMENT OF COPYING PERMISSION +// =============================== +// You are hereby granted permission to copy this unit under the conditions of +// the Mozilla Public License, v. 2.0 (MPL 2.0). The MPL 2.0 license can be +// found in the file named "MPL2.0_LicenseTerms.txt" distributed along with +// this library. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ + +interface +uses Classes, Generics.Collections; + +const + sClientRef = 'client'; // Use: decorate an IInterface data member/property with [Injection('client')] + SBD_DependencyInjectionFramework_Version = 4; + +type +IServiceProvider = interface; +TServiceFactory = reference to function( + const Config: string; + const ServiceProvider: IServiceProvider): IInterface; + +TServiceAffinity = ( + afcompetitive, // A single service or an array of competing services with + // the same interface and config. Select one, the 'active' + // service, like radio buttons to be the one acquired. + afCooperative); // A gang of services with the same interface and config, + // working co-operatively together to solve a shared problem. + +TIntegers = array of integer; +// Warning: Support for Generics in D2010 is very flaky, +// so use this instead of TArray + +TGenericServiceProvider = class + strict private + FController: TObject; + public + function Acquire( const Client: IInterface; out Intf: Svc; const Config: string = ''; const InjectionOverride: IServiceProvider = nil): boolean; + + public // Syntactically public but you should read as strict private + constructor Create( Controller1: TObject); + procedure ShutDown; + end; + +TCooperativeCollectionFactory = reference to function( const Config: string): IInterface; +TAddToCollectionProc = reference to procedure( const Collection, Addend: IInterface); + +IServiceProvider = interface + ['{4E38BEF6-2768-46E3-8740-25B8C526C912}'] + {$REGION 'property accessors'} + function GetServiceAffinity( const ServiceIID: TGUID; const Config: string): TServiceAffinity; + function GetActiveArrayMemberCookie( const ServiceIID: TGUID; const Config: string): integer; + procedure SetActiveArrayMemberByCookie( const ServiceIID: TGUID; const Config: string; Cookie: integer); + function GetActiveArrayMemberName( const ServiceIID: TGUID; const Config: string): string; + procedure SetActiveArrayMemberByName( const ServiceIID: TGUID; const Config, Name: string); + function GetNameByCookie( Cookie: integer): string; + function GetIsPooled( const ServiceIID: TGUID; const Config: string): boolean; + procedure SetIsPooled( const ServiceIID: TGUID; const Config: string; Value: boolean); + function Gn: TGenericServiceProvider; + {$ENDREGION} + + // Lookup methods + function GetGroupCount( const ServiceIID: TGUID; const Config: string): integer; + function GetCookies( const ServiceIID: TGUID; const Config: string): TIntegers; + function GetCookieByName( const ServiceIID: TGUID; const Config, Name: string): integer; + function GetCookieOfLiveService( const ServiceIID: TGUID; const Service: IInterface; const Config: string): integer; + function GetCookiesOfServiceClass( Registrant: TClass): TIntegers; + property ActiveArrayMemberCookie[ const ServiceIID: TGUID; const Config: string]: integer + read GetActiveArrayMemberCookie write SetActiveArrayMemberByCookie; + property ActiveArrayMemberName[ const ServiceIID: TGUID; const Config: string]: string + read GetActiveArrayMemberName write SetActiveArrayMemberByName; + property NameByCookie[ Cookie: integer]: string read GetNameByCookie; + + // Registration methods + procedure SetCompetitiveAffinity( const ServiceIID: TGUID; const Config: string); + procedure SetCooperativeAffinity( + const ServiceIID: TGUID; + const CollectionName: string; + const Config: string; + MakeCollection: TCooperativeCollectionFactory; + AddToCollection: TAddToCollectionProc); + + function RegisterLiveService( const ServiceIID: TGUID; const Service: IInterface; + const Config: string = ''; const SelectionArrayMemberName: string = ''): integer; + function RegisterFlyweightService( const ServiceIID: TGUID; Factory: TServiceFactory; + const Config: string = ''; const SelectionArrayMemberName: string = ''): integer; + {$if CompilerVersion < 22} + function RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): integer; + {$else} + function RegisterServiceClass( const ServiceIID: TGUID; Registrant: TClass): TIntegers; + // Due to a compiler bug we cannot use this ^ form in D2010, unless the client code + // declares a variable of type TIntegers. Scince this rule would be a bit too arbitary for + // users to consume, we resolve the issue by not using TIntegers in D2010. + {$ifend} + + // Deregistration methods + procedure DeregisterServiceByCookie( Cookie: integer); + procedure DeregisterServicesByCookie( const Cookies: TIntegers); + procedure DeregisterLiveServiceByName( const ServiceIID: TGUID; const Config: string = ''; const SelectionArrayMemberName: string = ''); + procedure DeregisterServicesOfClass( Registrant: TClass); + + // Acquisition methods + function Acquire( const ServiceIID: TGUID; const Client: IInterface; out Intf; const Config: string = ''; const InjectionOverride: IServiceProvider = nil): boolean; + + // Life-cycle methods + function Clone: IServiceProvider; + procedure Merge( const Source: IServiceProvider); // Add Source's services to this. + procedure ShutDown; + + // Main properties of service acquisition + property ServiceAffinity[ const ServiceIID: TGUID; const Config: string]: TServiceAffinity read GetServiceAffinity; + property IsPooled[ const ServiceIID: TGUID; const Config: string]: boolean + read GetIsPooled write SetIsPooled; + end; + + +TSBDUnit_BaseAttribute = class( TCustomAttribute) end; + +Injection = class( TSBDUnit_BaseAttribute) + public + FConfig: string; + + constructor Create; overload; + constructor Create( const Config1: string); overload; + end; + +Configuration = class( TSBDUnit_BaseAttribute) + public + FConfigs: TStrings; + FId: string; + + constructor Create; overload; + constructor Create( const Config1: string); overload; + destructor Destroy; override; + end; + +BlacklistConfigs = class( TSBDUnit_BaseAttribute) + public + FConfigs: TStrings; + + constructor Create( const Config1: string); overload; + destructor Destroy; override; + end; + +Collection = class( TSBDUnit_BaseAttribute) + public + FName: string; + + constructor Create( const Name1: string); + end; + + +function StandardServiceProvider: IServiceProvider; + +implementation + + + + +uses TypInfo, SysUtils, SBD.ServiceProvider.Internal; +{ TGenericServiceProvider } + + + + +function TGenericServiceProvider.Acquire( + const Client: IInterface; out Intf: Svc; const Config: string; + const InjectionOverride: IServiceProvider): boolean; +var + Intnl: IServiceProviderInternal; +begin +result := Supports( FController, IServiceProviderInternal, Intnl) and + Intnl.GnAcquire( GetTypeData(TypeInfo( Svc)).Guid, + Client, Intf, Config, InjectionOverride) +end; + + +function CommaSplit( const CommaSeparedList: string): TStrings; +begin +result := TStringList.Create; +result.StrictDelimiter := True; +result.CommaText := Trim( CommaSeparedList) +end; + + +constructor Configuration.Create( const Config1: string); +const + IdIntro = 'Id='; +var + j: integer; +begin +FConfigs := CommaSplit( Config1); +for j := FConfigs.Count - 1 downto 0 do + if SameText( Copy( Trim( FConfigs[j]), 1, Length( IdIntro)), IdIntro) then + begin + FId := Trim( FConfigs[j]); + Delete( FId, 1, Length( IdIntro)); + FId := Trim( FId); + FConfigs.Delete( j) + end; +if FConfigs.Count = 0 then + FConfigs.Add( '') +end; + +constructor Configuration.Create; +begin +Create('') +end; + + +destructor Configuration.Destroy; +begin +FConfigs.Free; +inherited +end; + + +constructor TGenericServiceProvider.Create( Controller1: TObject); +begin +FController := Controller1 +end; + +procedure TGenericServiceProvider.ShutDown; +begin +FController := nil +end; + +{ Injection } + +constructor Injection.Create; +begin +FConfig := '' +end; + +constructor Injection.Create( const Config1: string); +begin +FConfig := Config1 +end; + +{ BlacklistConfigs } + +constructor BlacklistConfigs.Create( const Config1: string); +begin +FConfigs := CommaSplit( Config1) +end; + +destructor BlacklistConfigs.Destroy; +begin +FConfigs.Free; +inherited +end; + +function StandardServiceProvider: IServiceProvider; +begin +result := TServiceProvider.Create as IServiceProvider +end; + + + +constructor Collection.Create( const Name1: string); +begin +FName := Name1 +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/includes/DUnitM.inc b/LockBox3/unit-tests/dunit-m/includes/DUnitM.inc new file mode 100644 index 0000000..fe0844e --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/includes/DUnitM.inc @@ -0,0 +1,321 @@ +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2013 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{$DEFINE UNSUPPORTED_COMPILER_VERSION} +{$DEFINE DELPHI_XE8_DOWN} +{$DEFINE DELPHI_D10_Seatle_DOWN} +{$DEFINE DELPHI_D10_1Brln_DOWN} +{$DEFINE DELPHI_XE7_DOWN} +{$DEFINE DELPHI_XE6_DOWN} +{$DEFINE DELPHI_XE5_DOWN} +{$DEFINE DELPHI_XE4_DOWN} +{$DEFINE DELPHI_XE3_DOWN} +{$DEFINE DELPHI_XE2_DOWN} +{$DEFINE DELPHI_XE_DOWN} +{$DEFINE DELPHI_2010_DOWN} + +{$IFDEF VER210} // RAD Studio 2010 + {$DEFINE DELPHI_2010} + {$DEFINE DELPHI_2010_UP} + {$DEFINE CPUX86} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} +{$ENDIF VER210} + +{$IFDEF VER220} // RAD Studio XE + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE} + {$DEFINE DELPHI_XE_UP} + {$DEFINE SUPPORTS_REGEX} + {$DEFINE CPUX86} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} +{$ENDIF VER220} + +{$IFDEF VER230} // RAD Studio XE2 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} +{$ENDIF VER230} + +{$IFDEF VER240} // RAD Studio XE3 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} +{$ENDIF VER240} + +{$IFDEF VER250} // RAD Studio XE4 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} +{$ENDIF VER250} + +{$IFDEF VER260} // RAD Studio XE5 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} +{$ENDIF VER260} + +{$IFDEF VER270} // RAD Studio XE6 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE DELPHI_XE6_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} + {$UNDEF DELPHI_XE5_DOWN} +{$ENDIF VER270} + +{$IFDEF VER280} // RAD Studio XE7 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE DELPHI_XE6_UP} + {$DEFINE DELPHI_XE7_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} + {$UNDEF DELPHI_XE5_DOWN} + {$UNDEF DELPHI_XE6_DOWN} +{$ENDIF VER280} + +{$IF CompilerVersion = 29.0} // VER290, RAD Studio XE8 + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE DELPHI_XE6_UP} + {$DEFINE DELPHI_XE7_UP} + {$DEFINE DELPHI_XE8_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} + {$UNDEF DELPHI_XE5_DOWN} + {$UNDEF DELPHI_XE6_DOWN} + {$UNDEF DELPHI_XE7_DOWN} +{$ENDIF} + +{$IF CompilerVersion = 30.0} // VER300, Delphi 2010 Seattle + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE DELPHI_XE6_UP} + {$DEFINE DELPHI_XE7_UP} + {$DEFINE DELPHI_XE8_UP} + {$DEFINE DELPHI_D10_Seattle_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} + {$UNDEF DELPHI_XE5_DOWN} + {$UNDEF DELPHI_XE6_DOWN} + {$UNDEF DELPHI_XE7_DOWN} +{$ENDIF} + + +{$IF CompilerVersion = 31.0} // VER310, Delphi D10.1 Berlin + {$DEFINE DELPHI_2010_UP} + {$DEFINE DELPHI_XE_UP} + {$DEFINE DELPHI_XE2_UP} + {$DEFINE DELPHI_XE3_UP} + {$DEFINE DELPHI_XE4_UP} + {$DEFINE DELPHI_XE5} + {$DEFINE DELPHI_XE5_UP} + {$DEFINE DELPHI_XE6_UP} + {$DEFINE DELPHI_XE7_UP} + {$DEFINE DELPHI_XE8_UP} + {$DEFINE DELPHI_D10_Seattle_UP} + {$DEFINE DELPHI_D10_1Brln_UP} + {$DEFINE SUPPORTS_REGEX} + {$UNDEF UNSUPPORTED_COMPILER_VERSION} + {$UNDEF DELPHI_2010_DOWN} + {$UNDEF DELPHI_XE_DOWN} + {$UNDEF DELPHI_XE2_DOWN} + {$UNDEF DELPHI_XE3_DOWN} + {$UNDEF DELPHI_XE4_DOWN} + {$UNDEF DELPHI_XE5_DOWN} + {$UNDEF DELPHI_XE6_DOWN} + {$UNDEF DELPHI_XE7_DOWN} + {$UNDEF DELPHI_D10_Seattle_DOWN} +{$ENDIF} + + + +{$IFDEF UNSUPPORTED_COMPILER_VERSION} + {$MESSAGE ERROR 'Unsupported compiler version! Delphi 10.1 Berlin or later required.'} +{$ENDIF} + + +// The following section is copied from the includes for the OmniThread Library. +// Apache license. Refer to the statement of copying permission and license agreement +// in the OTL. + +{$IF CompilerVersion >= 26}{$LEGACYIFEND ON}{$IFEND} + +{$IF CompilerVersion < 19} //D2007 + {$DEFINE OTL_NeedsWindowsAPIs} +{$IFEND} + +{$IF CompilerVersion >= 20} //D2009 + {$DEFINE OTL_Anonymous} + {$DEFINE OTL_Generics} + {$DEFINE OTL_HasInterlockedCompareExchangePointer} +{$IFEND} + +{$IF CompilerVersion >= 21} //D2010 + {$DEFINE OTL_ERTTI} + {$DEFINE OTL_DeprecatedResume} + {$DEFINE OTL_KnowsParamCount} + {$DEFINE OTL_HasTkPointer} + {$DEFINE OTL_HasArrayOfT} + {$DEFINE OTL_HasNameThreadForDebugging} +{$IFEND} + +{$IF CompilerVersion >= 22} //DXE + {$DEFINE OTL_HasThreadID} + {$DEFINE OTL_HasTInterlocked} + {$DEFINE OTL_GoodGenerics} + {$DEFINE OTL_HasTThreadYield} +{$IFEND} + +{$IF CompilerVersion >= 23} //DXE2 + {$DEFINE OTL_Supports64Bit} + {$DEFINE OTL_HasSystemTypes} + {$DEFINE OTL_HasCorrectNativeInt} +{$IFEND} + +{$IF CompilerVersion >= 24} //DXE3 + {$DEFINE OTL_LongGetMethodInfo} +{$IFEND} + +{$IF CompilerVersion >= 26} //DXE5 + {$DEFINE OTL_StrPasInAnsiStrings} +{$IFEND} + +{$IF CompilerVersion >= 28} //DXE7 + {$DEFINE OTL_MobileSupport} +{$IFEND} + + + + {$ifdef CONDITIONALEXPRESSIONS} + {$if CompilerVersion >= 25.0} + {$LEGACYIFEND OFF} + {$endif} + {$endif} + + {$IFDEF CPU386} {$define CPUINTEL} {$ENDIF} + {$IFDEF CPUX64} {$define CPUINTEL} {$ENDIF} + + {$IF (defined( CPU32BITS) and defined( CPU64BITS)) or ((not defined( CPU32BITS)) and (not defined( CPU64BITS)))} + {$undef CPU32BITS} + {$undef CPU64BITS} + {$IF SizeOf( pointer) = 4} + {$define CPU32BITS} + {$ENDIF} + {$IF SizeOf( pointer) = 8} + {$define CPU64BITS} + {$ENDIF} + {$ENDIF} + +{$IFDEF CPU64BITS} + {$ALIGN 8} +{$ELSE} + {$ALIGN 4} +{$ENDIF} + + {$IF (defined( CPUARM) and defined( CPUINTEL)) or ((not defined( CPUARM)) and (not defined( CPUINTEL)))} + {$Message Fatal 'CPU = ?'} + {$ENDIF} + + {$IF (defined( CPU32BITS) and defined( CPU64BITS)) or ((not defined( CPU32BITS)) and (not defined( CPU64BITS)))} + {$Message Fatal 'Architecture = ?'} + {$ENDIF} + + + diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.Assertion.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.Assertion.pas new file mode 100644 index 0000000..81a2fa6 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.Assertion.pas @@ -0,0 +1,776 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.Assertion; +interface +uses DunitM.UnitTestFramework, Classes, DUnitM.TestNode, SysUtils; + +{$I ../includes/DUnitM.inc} + +type +TAssertChecker = class( TInterfacedObject, IAssert) + private + FCheckGateway: ICheckGateway; + + private + {$ifdef DELPHI_XE_UP} + FGn: TAssertGeneric; + function Gn: TAssertGeneric; + {$endif} + + procedure Check; + procedure Pass; + procedure Fail( const message : string = ''; const errorAddrs : pointer = nil); + procedure Warn( const message : string = ''); + procedure AreEqual(const left : string; const right : string; const ignoreCase : boolean; const message : string);overload; + procedure AreEqual(const left : string; const right : string; const message : string = '');overload; + procedure AreEqual(const left, right : Extended; const tolerance : Extended; const message : string = '');overload; + procedure AreEqual(const left, right : Extended; const message : string = '');overload; + procedure AreEqual(const left, right : TClass; const message : string = '');overload; + procedure AreEqual(const left, right : TDate; const message : string = '');overload; + procedure AreEqual(const left, right : TDateTime; const message : string = '');overload; + procedure AreEqual(const left, right : Integer; const message : string = '');overload; + procedure AreEqualMemory(const left : Pointer; const right : Pointer; const size : Cardinal; message : string = ''); + procedure AreNotEqual(const left : string; const right : string; const ignoreCase : boolean = true; const message : string = '');overload; + procedure AreNotEqual(const left, right : Extended; const tolerance : Extended; const message : string = '');overload; + procedure AreNotEqual(const left, right : TClass; const message : string = '');overload; + procedure AreNotEqual(const left, right : TDate; const message : string = '');overload; + procedure AreNotEqual(const left, right : TDateTime; const message : string = '');overload; + procedure AreNotEqual(const left, right : Integer; const message : string = '');overload; + procedure AreNotEqualMemory(const left : Pointer; const right : Pointer; const size : Cardinal; message : string = ''); + procedure AreSame(const left, right : TObject; const message : string = '');overload; + procedure AreSame(const left, right : IInterface; const message : string = '');overload; + + procedure AreNotSame(const left, right : TObject; const message : string = '');overload; + procedure AreNotSame(const left, right : IInterface; const message : string = '');overload; + + procedure IsTrue ( const condition : boolean; const message : string = ''); + procedure IsFalse( const condition : boolean; const message : string = ''); + procedure IsNull(const condition : TObject; const message : string = '');overload; + procedure IsNull(const condition : Pointer; const message : string = '');overload; + procedure IsNull(const condition : IInterface; const message : string = '');overload; + procedure IsNull(const condition : Variant; const message : string = '');overload; + + procedure IsNotNull(const condition : TObject; const message : string = '');overload; + procedure IsNotNull(const condition : Pointer; const message : string = '');overload; + procedure IsNotNull(const condition : IInterface; const message : string = '');overload; + procedure IsNotNull(const condition : Variant; const message : string = '');overload; + + procedure IsEmpty(const value : string; const message : string = '');overload; + procedure IsEmpty(const value : Variant; const message : string = '');overload; + procedure IsEmpty(const value : TStrings; const message : string = '');overload; + procedure IsEmpty(const value : TList; const message : string = '');overload; + procedure IsEmpty(const value : IInterfaceList; const message : string = '');overload; + + procedure IsNotEmpty(const value : string; const message : string = '');overload; + procedure IsNotEmpty(const value : Variant; const message : string = '');overload; + procedure IsNotEmpty(const value : TStrings; const message : string = '');overload; + procedure IsNotEmpty(const value : TList; const message : string = '');overload; + procedure IsNotEmpty(const value : IInterfaceList; const message : string = '');overload; + + procedure WillRaise(const AMethod : TTestLocalMethod; const exceptionClass : ExceptClass = nil; const msg : string = ''); overload; + procedure WillRaise(const AMethod : TTestMethod; const exceptionClass : ExceptClass = nil; const msg : string = ''); overload; + procedure WillNotRaise(const AMethod : TTestLocalMethod; const exceptionClass : ExceptClass = nil; const msg : string = ''); overload; + procedure WillNotRaise(const AMethod : TTestMethod; const exceptionClass : ExceptClass = nil; const msg : string = ''); overload; + procedure Contains(const theString : string; const subString : string; const ignoreCase : boolean = true; const message : string = '');overload; + procedure StartsWith(const theString : string; const subString : string;const ignoreCase : boolean = true; const message : string = ''); + procedure EndsWith(const theString : string; const subString : string;const ignoreCase : boolean = true; const message : string = ''); + procedure InheritsFrom(const descendant : TClass; const parent : TClass; const message : string = ''); + {$IFDEF SUPPORTS_REGEX} + procedure IsMatch(const regexPattern : string; const theString : string; const message : string = ''); + {$ENDIF} + public + constructor Create( const CheckGateway1: ICheckGateway); + destructor Destroy; override; + + {$ifdef DELPHI_XE_UP} + private type + TConcreteAssertGn = class sealed( TAssertGeneric) + private + FContrlrObj: TAssertChecker; + constructor CreateConcreteGn( ContrlrObj: TAssertChecker); + protected + procedure Check; override; + procedure FailFmt( const Fmt: string; const Args: array of const); override; + end; + {$endif} + end; + + + +function IsBadPointer(P: Pointer):boolean; register; + +{$IFDEF DELPHI_XE_DOWN} {$IFDEF ASSEMBLER} {$IFDEF MSWINDOWS} {$IFDEF CPUX86} {$IFNDEF PUREPASCAL} + {$define ReturnAddressAvaliable} +{$ENDIF} {$ENDIF} {$ENDIF} {$ENDIF} {$ENDIF} + +{$IFDEF ReturnAddressAvaliable} +function ReturnAddress: Pointer; assembler; +{$ENDIF} + +implementation + + + + + + + + +uses Math, Variants, StrUtils, SBD.Utils.XML2 + {$IFDEF SUPPORTS_REGEX} + , RegularExpressions + {$ENDIF} + ; + +function IsBadPointer( P: Pointer):Boolean;register; +begin + try + Result := (p = nil) or ((Pointer(P^) <> P) and (Pointer(P^) = P)); + except + Result := true; + end +end; + +{$IFDEF ReturnAddressAvaliable} +function ReturnAddress: Pointer; assembler; +const + CallerIP = $4; +asm + mov eax, ebp + call IsBadPointer + test eax,eax + jne @@Error + + mov eax, [ebp].CallerIP + sub eax, 5 // 5 bytes for call + + push eax + call IsBadPointer + test eax,eax + pop eax + je @@Finish + +@@Error: + xor eax, eax +@@Finish: +end; +{$ENDIF} + + + + + +constructor TAssertChecker.Create( const CheckGateway1: ICheckGateway); +begin +FCheckGateway := CheckGateway1; +{$ifdef DELPHI_XE_UP} +FGn := TConcreteAssertGn.CreateConcreteGn( self) +{$endif} +end; + + +{$ifdef DELPHI_XE_UP} +constructor TAssertChecker.TConcreteAssertGn.CreateConcreteGn( ContrlrObj: TAssertChecker); +begin +FContrlrObj := ContrlrObj; +inherited Create( FContrlrObj as IInterface) +end; + +procedure TAssertChecker.TConcreteAssertGn.Check; +begin +FContrlrObj.Check +end; + + +procedure TAssertChecker.TConcreteAssertGn.FailFmt( const Fmt: string; const Args: array of const); +begin +FContrlrObj.Fail( Format( Fmt, Args), nil) +end; + + +{$endif} + + + +destructor TAssertChecker.Destroy; +begin +inherited; +{$ifdef DELPHI_XE_UP} +FGn.Free +{$endif} +end; + +{$ifdef DELPHI_XE_UP} +function TAssertChecker.Gn: TAssertGeneric; +begin +result := FGn +end; +{$endif} + +procedure TAssertChecker.AreEqual( const left, right, tolerance: Extended; const message: string); +begin +Check; +if not Math.SameValue(left,right,tolerance) then + Fail(Format('left %g but got %g - %s' ,[left,right,message]), ReturnAddress); +end; + + +procedure TAssertChecker.AreEqual( const left, right: TClass; const message: string); +var + msg : string; +begin +Check; + if left <> right then + begin + msg := ' is not equal to '; + if left = nil then + msg := 'nil' + msg + else + msg := left.ClassName + msg; + + if right = nil then + msg := msg + 'nil' + else + msg := msg + right.ClassName; + + if message <> '' then + msg := msg + '. ' + message; + + Fail(msg, ReturnAddress); + end; +end; + +procedure TAssertChecker.AreEqual(const left, right: Integer; const message: string); +begin +Check; + if left <> right then + Fail(Format('left %d but got %d - %s' ,[left, right, message]), ReturnAddress); +end; + +function DateAsMessageString( Datum: TDate): string; +begin +result := SBD.Utils.XML2.Txs_dateTime.EncodeDate( Datum) +end; + +function DateTimeAsMessageString( Datum: TDate): string; +begin +result := SBD.Utils.XML2.Txs_dateTime.Encode( Datum, False, 0) +end; + +procedure TAssertChecker.AreEqual( const left, right: TDate; const message: string); +begin +Check; +if left <> right then + Fail( Format('left %s but got %s - %s' ,[DateAsMessageString( left), DateAsMessageString( right), message]), ReturnAddress) +end; + +procedure TAssertChecker.AreEqual( const left, right: TDateTime; const message: string); +begin +Check; +if left <> right then + Fail( Format('left %s but got %s - %s' ,[DateTimeAsMessageString( left), DateTimeAsMessageString( right), message]), ReturnAddress) +end; + +procedure TAssertChecker.AreEqual(const left, right: Extended; const message: string); +begin +Check; +AreEqual(left, right, 0, message); +end; + +procedure TAssertChecker.AreEqualMemory(const left : Pointer; const right : Pointer; const size : Cardinal; message : string); +begin +Check; +if not CompareMem(left, right, size) then + Fail('Memory values are not equal. ' + message, ReturnAddress); +end; + +procedure TAssertChecker.AreNotEqual(const left, right, tolerance: Extended; const message: string); +begin +Check; + if Math.SameValue(left, right, tolerance) then + Fail(Format('%g equals right %g %s' ,[left,right,message]), ReturnAddress); +end; + + +procedure TAssertChecker.AreNotEqual(const left, right: string;const ignoreCase: boolean; const message: string); + + function AreNotEqualText(const left, right: string; const ignoreCase: boolean): boolean; + begin + if ignoreCase then + Result := SameText(left, right) + else + Result := SameStr(left, right); + + end; +begin +Check; + if AreNotEqualText(left, right, ignoreCase) then + Fail(Format('[%s] is Equal to [%s] %s', [left, right, message]), ReturnAddress); +end; + +procedure TAssertChecker.AreNotEqual(const left, right: TClass; const message: string); +var + msg : string; +begin +Check; + if left = right then + begin + msg := ' is equal to '; + if left = nil then + msg := 'nil' + msg + else + msg := left.ClassName + msg; + + if right = nil then + msg := msg + 'nil' + else + msg := msg + right.ClassName; + if message <> '' then + msg := msg + '. ' + message; + + Fail(msg, ReturnAddress); + end; +end; + + +procedure TAssertChecker.AreNotEqual(const left, right: Integer; const message: string); +begin +Check; +if left = right then + Fail( Format('%d equals right %d %s' ,[left, right, message]), ReturnAddress); +end; + +procedure TAssertChecker.AreNotEqual( + const left, right: TDate; const message: string); +begin +Check; +if left = right then + Fail( Format('%s equals right %s %s' ,[DateAsMessageString( left), DateAsMessageString( right), message]), ReturnAddress); +end; + +procedure TAssertChecker.AreNotEqual(const left, right: TDateTime; + const message: string); +begin +Check; +if left = right then + Fail( Format('%s equals right %s %s' ,[DateTimeAsMessageString( left), DateTimeAsMessageString( right), message]), ReturnAddress); +end; + + +procedure TAssertChecker.AreNotEqualMemory(const left, right: Pointer; const size: Cardinal; message: string); +begin +Check; + if CompareMem(left,right, size) then + Fail('Memory values are equal. ' + message, ReturnAddress); +end; + +procedure TAssertChecker.AreNotSame(const left, right: TObject; const message: string); +begin +Check; + if left.Equals(right) then + Fail(Format('Object [%s] Equals Object [%s] %s',[left.ToString,right.ToString,message]), ReturnAddress); +end; + +procedure TAssertChecker.AreNotSame(const left, right: IInterface; const message: string); +begin +Check; + if left = right then + Fail(Format('references are the same. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.AreSame(const left, right: IInterface; const message: string); +begin +Check; + if left <> right then + Fail(Format('references are Not the same. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.AreSame(const left, right: TObject; const message: string); +begin +Check; + if not left.Equals(right) then + Fail(Format('Object [%s] Not Object [%s] %s',[left.ToString,right.ToString,message]), ReturnAddress); +end; + + + + +procedure TAssertChecker.InheritsFrom(const descendant, parent: TClass; const message: string); +var + msg : string; +begin +Check; + if (descendant = nil) or (parent = nil) or (not descendant.InheritsFrom(parent)) then + begin + msg := ' does not inherit from '; + if descendant = nil then + msg := 'nil' + msg + else + msg := descendant.ClassName + msg; + if parent = nil then + msg := msg + 'nil' + else + msg := parent.ClassName + msg; + msg := msg + '.'; + if True then + if message <> '' then + msg := msg + ' ' + message; + + Fail(msg, ReturnAddress); + end; + +end; + +procedure TAssertChecker.IsEmpty(const value: IInterfaceList; const message: string); +begin +Check; + if value.Count > 0 then + Fail(Format('List is Not empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsEmpty(const value: TList; const message: string); +begin +Check; + if value.Count > 0 then + Fail(Format('List is Not empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsEmpty(const value, message: string); +begin +Check; + if Length(value) > 0 then + Fail(Format('String is Not empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsEmpty(const value: Variant; const message: string); +begin +Check; + if VarIsEmpty(value) or VarIsNull(value) then + Fail(Format('Variant is Not empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsEmpty(const value: TStrings; const message: string); +begin +Check; + if value.Count > 0 then + Fail(Format('List is Not empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsFalse(const condition: boolean; const message: string); +begin +Check; + if condition then + Fail(Format('Condition is True when False expected. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotEmpty(const value: TList; const message: string); +begin +Check; + if value.Count = 0 then + Fail(Format('List is Empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotEmpty(const value: IInterfaceList; const message: string); +begin +Check; + if value.Count = 0 then + Fail(Format('List is Empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotEmpty(const value: TStrings; const message: string); +begin +Check; + if value.Count = 0 then + Fail(Format('List is Empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotEmpty(const value, message: string); +begin +Check; + if value = '' then + Fail(Format('Variant is Empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotEmpty(const value: Variant; const message: string); +begin +Check; + if VarIsEmpty(value) then + Fail(Format('Variant is Empty. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotNull(const condition: IInterface; const message: string); +begin +Check; + if condition = nil then + Fail(Format('Interface is Nil when not nil expected. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotNull(const condition: Pointer; const message: string); +begin +Check; + if condition = nil then + Fail(Format('Pointer is Nil when not Nil expected. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotNull(const condition: TObject; const message: string); +begin +Check; + if condition = nil then + Fail(Format('Object is Nil when Not Nil expected. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNotNull(const condition: Variant; const message: string); +begin +Check; + if VarIsNull(condition) then + Fail(Format('Variant is Null when Not Null expcted. %s',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNull(const condition: Variant; const message: string); +begin +Check; + if not VarIsNull(condition) then + Fail(Format('Variant is Not Null when Null expected. [%s]',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNull(const condition: IInterface; const message: string); +begin +Check; + if condition <> nil then + Fail(Format('Interface is not Nil when nil expected. [%s]',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNull(const condition: TObject; const message: string); +begin +Check; + if condition <> nil then + Fail(Format('Object is not nil when nil expected. [%s]',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsNull(const condition: Pointer; const message: string); +begin +Check; + if condition <> nil then + Fail(Format('Pointer is not Nil when nil expected. [%s]',[message]), ReturnAddress); +end; + +procedure TAssertChecker.IsTrue(const condition: boolean;const message : string); +begin +Check; + if not condition then + Fail(Format('Condition is False when True expected. [%s]',[message]), ReturnAddress); +end; + +procedure TAssertChecker.WillNotRaise(const AMethod: TTestMethod; const exceptionClass: ExceptClass; const msg: string); +begin +WillNotRaise( + procedure + begin + AMethod; + end, + exceptionClass, msg); +end; + +procedure TAssertChecker.WillRaise( const AMethod : TTestLocalMethod; const exceptionClass : ExceptClass; const msg : string); +begin +Check; +try + AMethod; + Fail( 'Method did not throw any exceptions.', ReturnAddress); +except on E: Exception do + begin + if assigned( exceptionClass) and (E.ClassType <> exceptionClass) then + Fail( Format('Method raised [%s] was expecting [%s]. %s', + [E.ClassName, exceptionClass.ClassName, E.message]), ReturnAddress) + end + end +end; + + +procedure TAssertChecker.WillNotRaise( const AMethod : TTestLocalMethod; const exceptionClass : ExceptClass; const msg : string); +begin +Check; +try + AMethod +except on E: Exception do + begin + if not assigned( exceptionClass) then + Fail( Format('Method raised [%s] was expecting not to raise any exception. %s', + [E.ClassName, E.message]), ReturnAddress) + else if E.ClassType = exceptionClass then + Fail( Format('Method raised [%s] was expecting not to raise [%s]. %s', + [E.ClassName, exceptionClass.ClassName, E.message]), ReturnAddress) + end + end +end; + + +procedure TAssertChecker.WillRaise(const AMethod: TTestMethod; const exceptionClass: ExceptClass; const msg: string); +begin +WillRaise( + procedure + begin + AMethod; + end, + exceptionClass, msg); +end; + +procedure TAssertChecker.AreEqual(const left : string; const right : string; const message : string); +begin +AreEqual( left, right, true, message); +end; + +procedure TAssertChecker.AreEqual(const left, right : string; const ignoreCase : boolean; const message: string); +begin +Check; + if ignoreCase then + begin + if not SameText(left,right) then + Fail(Format('[%s] is Not Equal to [%s] %s',[left,right,message]), ReturnAddress); + end + else if not SameStr(left,right) then + Fail(Format('[%s] is Not Equal to [%s] %s',[left,right,message]), ReturnAddress); +end; + +procedure TAssertChecker.Contains(const theString : string; const subString : string; const ignoreCase : boolean; const message : string); +begin +Check; + if ignoreCase then + begin + if not StrUtils.ContainsText(theString,subString) then + Fail(Format('[%s] does not contain [%s] %s',[theString,subString,message]), ReturnAddress); + end + else if not StrUtils.ContainsStr(theString,subString) then + Fail(Format('[%s] does not contain [%s] %s',[theString,subString,message]), ReturnAddress); +end; + +procedure TAssertChecker.EndsWith(const theString : string; const subString : string; const ignoreCase : boolean; const message : string); +begin +Check; + if ignoreCase then + begin + if not StrUtils.EndsText(theString,subString) then + Fail(Format('[%s] does not end with [%s] %s',[theString,subString,message]), ReturnAddress); + end + else if not StrUtils.EndsStr(theString,subString) then + Fail(Format('[%s] does not end with [%s] %s',[theString,subString,message]), ReturnAddress); +end; + +{$IFDEF SUPPORTS_REGEX} +procedure TAssertChecker.IsMatch(const regexPattern, theString, message: string); +begin +Check; + if not TRegEx.IsMatch(theString,regexPattern) then + Fail(Format('[%s] does not match [%s] %s',[theString,regexPattern,message]), ReturnAddress); +end; +{$ENDIF} + +procedure TAssertChecker.StartsWith(const theString : string; const subString : string; const ignoreCase : boolean; const message: string); +begin +Check; + if ignoreCase then + begin + if not StrUtils.StartsText(theString,subString) then + Fail(Format('[%s] does Not Start with [%s] %s',[theString,subString,message]), ReturnAddress); + end + else if not StrUtils.StartsStr(theString,subString) then + Fail(Format('[%s] does Not Start with [%s] %s',[theString,subString,message]), ReturnAddress); +end; + + +procedure TAssertChecker.Pass; +begin +Check; +FCheckGateway.Pass +//raise ETestPass.Create('Abortive pass') +end; + + +procedure TAssertChecker.Fail( const message : string; const errorAddrs : pointer); +var + p: pointer; +begin +// If we have been given a return then use it. (makes the exception appear on level above in the stack) +if errorAddrs <> nil then + p := errorAddrs +else + // Otherwise use the return address we can currently get to for where to raise the exception + p := ReturnAddress; +FCheckGateway.Fail( message, p) +end; + +procedure TAssertChecker.Warn( const message: string); +begin +FCheckGateway.Warn( message) +end; + + +procedure TAssertChecker.Check; +begin +FCheckGateway.Check +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.BaseExecutive.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.BaseExecutive.pas new file mode 100644 index 0000000..d1e3ee4 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.BaseExecutive.pas @@ -0,0 +1,204 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.BaseExecutive; +interface +uses DUnitM.UnitTestFramework, Classes, SBD.ServiceProvider; + +type + +IExecutive = interface + ['{45B82A12-5F95-4515-BFE6-CE54799E4E2F}'] + procedure StartUp; + procedure ShutDown; + function Model: IUnitTestingEngine; + procedure DeclareMainForm( MainForm: TComponent); + function Services: IServiceProvider; + procedure RegisterTestFixtures; + function ApplicationTitle: string; + end; + +TBaseExecutive = class( TInterfacedObject, IExecutive) + private + FMainForm: TComponent; + + procedure StartUp; + procedure ShutDown; + function Model: IUnitTestingEngine; + procedure DeclareMainForm( MainForm: TComponent); + function Services: IServiceProvider; + + protected + FServices: IServiceProvider; + FModel: IUnitTestingEngine; + + function ApplicationTitle: string; virtual; abstract; + procedure RegisterTestFixtures; virtual; abstract; + procedure RegisterServices; virtual; + public + constructor Create; + destructor Destroy; override; + end; + + +implementation + + + + + + + +uses DUnitM.UnitTestFramework.Solution, DUnitM.MemoryMonitor.Solution, + DUnitM.Fixture, DUnitM.TestProcedure, DUnitM.NUnit.LoggerUI.Solution, + SBD.Generics, DUnitM.NUnit.Logger.Solution, + DUnitM.NUnit25.ResultsLog.Solution, + DUnitM.XMLWriter.Solution; + + +constructor TBaseExecutive.Create; +begin +FServices := StandardServiceProvider; +RegisterServices; +FServices.Gn.Acquire( nil, FModel) +end; + +procedure TBaseExecutive.DeclareMainForm( MainForm: TComponent); +begin +FMainForm := MainForm +end; + +destructor TBaseExecutive.Destroy; +begin +ShutDown; +inherited +end; + +function TBaseExecutive.Model: IUnitTestingEngine; +begin +result := FModel +end; + + +type +TAdditionalLoggers = class( TList2, IAdditionalLoggers) + end; + +procedure TBaseExecutive.RegisterServices; +begin +DUnitM.UnitTestFramework.Solution.RegisterServices( FServices); +DUnitM.MemoryMonitor.Solution .RegisterServices( FServices); +DUnitM.Fixture .RegisterServices( FServices); +DUnitM.TestProcedure .RegisterServices( FServices); +DUnitM.NUnit25.ResultsLog.Solution .RegisterServices( FServices); +DUnitM. XMLWriter.Solution .RegisterServices( FServices); + +DUnitM.NUnit.LoggerUI.Solution.RegisterServices( FServices); +FServices.SetCooperativeAffinity( ILoggerFactoryUI, '', '', + function( const Config: string): IInterface + begin + result := TAdditionalLoggers.Create as IAdditionalLoggers + end, + + procedure( const Collection, Addend: IInterface) + begin + (Collection as IList2).Add( Addend as ILoggerFactoryUI) + end); + +DUnitM.NUnit.Logger.Solution.RegisterServices( FServices); +// Register more loggers and thier factories here ... + +// As required, acquire the collection of factories like so ... +// if FServices.Acquire( ILoggerFactoryUI, nil, Gang, '', nil) then +// for Member in Gang do +// DoSomethingWith( Member) +end; + +function TBaseExecutive.Services: IServiceProvider; +begin +result := FServices +end; + +procedure TBaseExecutive.ShutDown; +begin +if assigned( FServices) then + begin + FServices.ShutDown; + FServices := nil + end; +if assigned( FModel) then + begin + FModel.Shutdown; + FModel := nil + end +end; + +procedure TBaseExecutive.StartUp; +begin +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.CommandLine.General.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.CommandLine.General.pas new file mode 100644 index 0000000..c080d08 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.CommandLine.General.pas @@ -0,0 +1,686 @@ +unit DUnitM.CommandLine.General; +interface +uses Types, XMLIntf, Generics.Collections, Classes; +type + +IPrimitiveCommandLine = interface + ['{C1B61925-A98F-4A2E-9FB7-9188D4663997}'] + function ApplicationName: string; + function Parameters: TStringDynArray; + end; + +TParamKind = (pkString, pkInteger, pkFloat, pkBoolean, pkDateTime, pkDate, pkTime, pkXML); + // pkXML is an unecrypted XML file, specified by file-name. + +ICommandLineParamValue = interface + // Can be cast into one of IFloatParamValue etc. + ['{E6347C57-5A7A-4765-ABD0-9091D046189D}'] + function Kind: TParamKind; + function AsString: string; + function IsNull: boolean; + end; + +TCommandLineDict = class( TDictionary) + end; + +TCommandLineReadError = (erDocumentRead, erDocumentFileDelete); +TCommandLineReadErrorSet = set of TCommandLineReadError; + +// Assume that all parameters are of the form.. +// -pName:pValue +// where: +// 1. pName in the above is a place-marker for the parameter name. +// 2. pValue in the above is a place-marker for the parameter value. +// 3. The '-' character in the above can be substited with '/', with no effect. +// 4. The ':' character in the above can be substited with '=', with no effect. +// 5. pName is non-empty. +// 6. pName is unique. +// 7. pName is case insensitive. When read back, the lowercase form will be presented. +// 8. pName must conform to a legal unprefixed XML element name (XML 1.0 standard; 5th edition) . +// (Therefore pName may not contain either the ':' nor the '=" characters.) +// 9. There are no restrictions on pValue, and if it is a string type, it is case sensitive. +// 10. Zero or one parameter (with pName equal to DocumentName()) is the document name. +// This is a file name of an XML document (possibly encrypted) that contains +// Additional parameter values passed by the client. +// 11. If a parameter is present in both the document and the raw command line, +// the value given in the raw command line shall prevail. + + +ICommandLine = interface + ['{1157FD56-7FE3-49D0-8EC0-8DCC9E361361}'] + function RawForm: IPrimitiveCommandLine; + function ParameterDocument: IXMLDocument; + function DocumentName: string; + function Params: TCommandLineDict; + end; + +IStringParamValue = interface( ICommandLineParamValue) + ['{F3A1E908-CA84-426E-9ECC-6379DAD0A794}'] + end; + +IFloatParamValue = interface( ICommandLineParamValue) + ['{D0E3E94C-16A4-489F-A9A1-B5A7A980F185}'] + procedure GetValue( var Value: double; var IsDefaulted: boolean); + end; + +IIntegerParamValue = interface( ICommandLineParamValue) + ['{75F11C08-707F-400F-B7DB-E92EE87C0CBB}'] + procedure GetValue( var Value: integer; var IsDefaulted: boolean); + end; + +IBooleanParamValue = interface( ICommandLineParamValue) + ['{3BE46F7B-AB36-4235-8DE4-652C4198159D}'] + procedure GetValue( var Value: boolean; var IsDefaulted: boolean); + end; + +IDateTimeParamValue = interface( ICommandLineParamValue) + ['{A41B4335-8007-4A34-A0E1-2A82E1BD7BFF}'] + procedure GetValue( var Value: TDateTime; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + end; + +IDateParamValue = interface( ICommandLineParamValue) + ['{E505EA27-78F3-40AD-BE72-D44666802E5E}'] + procedure GetValue( var Value: TDate; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + end; + +ITimeParamValue = interface( ICommandLineParamValue) + ['{1B2433B4-85FE-45C4-BFF3-9F52BCFA4AB5}'] + procedure GetValue( var Value: TTime; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + end; + +IXDocValue = interface( ICommandLineParamValue) + ['{6A4D5311-956D-4C82-98FA-7E430E5C8FC1}'] + procedure GetValue( var Value: IXMLDocument; var SourceFileName: string); + end; + +TDecisionFunc = reference to function( const Doc: IXMLDocument; NameValues: TStrings): boolean; +TDecryptor = reference to function( CipherText: TStream; NameValues: TStrings): TStream; + // The input stream is taken from its current position. + // The returned stream has a position of 0, and will be of type TMemoryStream. + +IParameterRegistrar = interface + ['{A64B3211-E062-489E-88D0-F6F7B8975B1D}'] + // Name == name of the parameter + // Default == default or deemed value if the parameter is absent. + // AllowedInRaw == Look for the parameter on the raw command line. + // DocXPath == If not empty, and the parameter was not found on the command line, the this is the XPath expression to the value in the document. + // IncludesTZ = If True, the default value includes a Time-Zone component. + // TZMinutes = If IncludesTZ, the time zone component of the default value is specified in minutes as an offset to UTC. + procedure RegisterStringParameter ( const Name, Default, DocXPath: string; EmptyCountsAsAbsent, AllowedInRaw: boolean); + procedure RegisterIntegerParameter ( const Name: string; Default: integer; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterFloatParameter ( const Name: string; Default: double; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterBooleanParameter ( const Name: string; Default: boolean; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterDateTimeParameter( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterDateParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterTimeParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterXMLParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; const Namespaces: string); + end; + +TParameterRegistrationFragment = reference to procedure( const Registrar: IParameterRegistrar); + +ICommandLineFactory = interface + ['{E5C15EE8-3759-41DD-96A5-3B8483475CEB}'] + function Make( + const RawForm: IPrimitiveCommandLine; + const DocParamName: string; // Name of the command-line parameter that + // specifies the file name of the xml document to be read for + // other parameter values. This can be null. + const NamespaceDecls: string; // xml namespaces for the DocXPath parameters passed to the ParameterRegistry. + var CommandLine: ICommandLine; // Returns the manufactured ICommandLine. + var Errors: TCommandLineReadErrorSet; // Returns any errors + RegistrationProc: TParameterRegistrationFragment; // The user defines parameter defaults and xpaths here. Can be nil. + DoDeleleDocumentFile: TDecisionFunc; // If this function exists and returns True, + // the document file will be deleted after it is read. + // If the document is invalid, it will not be deleted. + DocDecryptor: TDecryptor) // If assigned, it designates that the document is encrypted, and this function will decrypt it. + : boolean; // Return True if there we no errors. + end; + + +IApplicationSpecificCommandLineFactory = interface + ['{E43FFC99-3F50-4FF2-9017-6FE97CB73BE9}'] + function Make( + const RawForm: IPrimitiveCommandLine; + const ProtocolReader: ICommandLineFactory; + var CommandLine: ICommandLine; + var Errors: TCommandLineReadErrorSet) + : boolean; + end; + +function StandardPrimitiveCommandLine: IPrimitiveCommandLine; +function StandardCommandLineFactory: ICommandLineFactory; + +implementation + + + + + + + + + + + + + + +type +ICommandLineParamValue_Internal = interface + ['{36EB5296-7480-483B-BEA5-7774393340AC}'] + function SetFromRawCommandLine( const Value: string): boolean; + function SetFromParamDocument ( const Value: IXMLNode): boolean; + end; + +TCommandLineParamValue = class abstract( TInterfacedObject, ICommandLineParamValue, ICommandLineParamValue_Internal) + protected + FisNull: boolean; + FAllowedInRaw: boolean; + FDocXPath: string; + function Kind: TParamKind; virtual; abstract; + function AsString: string; virtual; abstract; + function IsNull: boolean; virtual; + function SetFromRawCommandLine( const Value: string): boolean; virtual; abstract; + function SetFromParamDocument ( const Value: IXMLNode): boolean; virtual; + constructor Create( isNull, AllowedInRaw: boolean; const DocXPath: string); + end; + + +TStringParamValue = class( TCommandLineParamValue, IStringParamValue) + protected + FEmptyCountsAsAbsent: boolean; + FDefault: string; + function Kind: TParamKind; override; + function AsString: string; override; + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( const Default, DocXPath: string; EmptyCountsAsAbsent, AllowedInRaw: boolean); + end; + +TFloatParamValue = class( TCommandLineParamValue, IFloatParamValue) + private + FDefault: double; + procedure GetValue( var Value: double; var IsDefaulted: boolean); + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( Default: double; const DocXPath: string; AllowedInRaw: boolean); + end; + +TIntegerParamValue = class( TCommandLineParamValue, IIntegerParamValue) + private + FDefault: integer; + procedure GetValue( var Value: integer; var IsDefaulted: boolean); + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( Default: integer; const DocXPath: string; AllowedInRaw: boolean); + end; + +TBooleanParamValue = class( TCommandLineParamValue, IBooleanParamValue) + private + FDefault: boolean; + procedure GetValue( var Value: boolean; var IsDefaulted: boolean); + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( Default: boolean; const DocXPath: string; AllowedInRaw: boolean); + end; + +TDateTimeParamValue = class( TCommandLineParamValue, IDateTimeParamValue) + private + procedure GetValue( var Value: TDateTime; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + protected + FDefault: TDateTime; + FIncludesTZ: boolean; + FTZMinutes: integer; + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( const DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean; TZMinutes: integer); + end; + +TDateParamValue = class( TDateTimeParamValue, IDateParamValue) + private + procedure GetValue( var Value: TDate; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + protected + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( const DocXPath: string; AllowedInRaw: boolean; Default: TDate; IncludesTZ: boolean; TZMinutes: integer); + end; + +TTimeParamValue = class( TCommandLineParamValue, ITimeParamValue) + private + procedure GetValue( var Value: TTime; var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); + protected + function SetFromRawCommandLine( const Value: string): boolean; override; + function SetFromParamDocument ( const Value: IXMLNode): boolean; override; + public + constructor Create( const DocXPath: string; AllowedInRaw: boolean; Default: TTime; IncludesTZ: boolean; TZMinutes: integer); + end; + +TXDocValue = class( TCommandLineParamValue, IXDocValue) + private + FNamespaces: string; + procedure GetValue( var Value: IXMLDocument; var SourceFileName: string); + public + constructor Create( const DocXPath: string; AllowedInRaw: boolean; const Namespaces: string); + end; + +TPrimitiveCommandLine = class( TInterfacedObject, IPrimitiveCommandLine) + private + function ApplicationName: string; + function Parameters: TStringDynArray; + end; + + +TCommandLineFactory = class( TInterfacedObject, ICommandLineFactory) + private + function Make( + const RawForm: IPrimitiveCommandLine; + const DocParamName: string; + const NamespaceDecls: string; + var CommandLine: ICommandLine; + var Errors: TCommandLineReadErrorSet; + RegistrationProc: TParameterRegistrationFragment; + DoDeleleDocumentFile: TDecisionFunc; + DocDecryptor: TDecryptor) + : boolean; + end; + +TParameterRegistrar = class( TInterfacedObject, IParameterRegistrar) + private + FParams: TCommandLineDict; + procedure RegisterStringParameter ( const Name, Default, DocXPath: string; EmptyCountsAsAbsent, AllowedInRaw: boolean); + procedure RegisterIntegerParameter ( const Name: string; Default: integer; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterFloatParameter ( const Name: string; Default: double; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterBooleanParameter ( const Name: string; Default: boolean; const DocXPath: string; AllowedInRaw: boolean); + procedure RegisterDateTimeParameter( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterDateParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterTimeParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean = False; TZMinutes: integer = 0); + procedure RegisterXMLParameter ( const Name, DocXPath: string; AllowedInRaw: boolean; const Namespaces: string); + + public + constructor Create( Params1: TCommandLineDict); + end; + +TCommandLine = class( TInterfacedObject, ICommandLine) + private + FRawForm: IPrimitiveCommandLine; + FParamDoc: IXMLDocument; + FDocName: string; + FParams: TCommandLineDict; + + function RawForm: IPrimitiveCommandLine; + function ParameterDocument: IXMLDocument; + function DocumentName: string; + function Params: TCommandLineDict; + + public + constructor Create( + const RawForm: IPrimitiveCommandLine; + const DocParamName: string; + const NamespaceDecls: string; + var Errors: TCommandLineReadErrorSet; + RegistrationProc: TParameterRegistrationFragment; + DoDeleleDocumentFile: TDecisionFunc; + DocDecryptor: TDecryptor); + destructor Destroy; override; + end; + +function StandardPrimitiveCommandLine: IPrimitiveCommandLine; +begin +result := TPrimitiveCommandLine.Create +end; + +function StandardCommandLineFactory: ICommandLineFactory; +begin +result := TCommandLineFactory.Create +end; + + + +function TPrimitiveCommandLine.ApplicationName: string; +begin +result := ParamStr( 0) +end; + +function TPrimitiveCommandLine.Parameters: TStringDynArray; +begin +// TODO + +end; + + +function TCommandLineFactory.Make(const RawForm: IPrimitiveCommandLine; + const DocParamName, NamespaceDecls: string; var CommandLine: ICommandLine; + var Errors: TCommandLineReadErrorSet; + RegistrationProc: TParameterRegistrationFragment; + DoDeleleDocumentFile: TDecisionFunc; DocDecryptor: TDecryptor): boolean; +begin +CommandLine := TCommandLine.Create( + RawForm, DocParamName, NamespaceDecls, + Errors, RegistrationProc, DoDeleleDocumentFile, DocDecryptor) +end; + + +constructor TCommandLine.Create( + const RawForm: IPrimitiveCommandLine; + const DocParamName, NamespaceDecls: string; + var Errors: TCommandLineReadErrorSet; + RegistrationProc: TParameterRegistrationFragment; + DoDeleleDocumentFile: TDecisionFunc; DocDecryptor: TDecryptor); +var + NameValues: TStrings; + Reg: IParameterRegistrar; +begin +FRawForm := RawForm; +Errors := []; +FParamDoc := nil; +FParams := TCommandLineDict.Create; +NameValues := TStringList.Create; +Reg := TParameterRegistrar.Create( FParams); + +// TODO + +NameValues.Free +end; + +destructor TCommandLine.Destroy; +begin +FParams.Free; +inherited +end; + +function TCommandLine.DocumentName: string; +begin +result := FDocName +end; + +function TCommandLine.ParameterDocument: IXMLDocument; +begin +result := FParamDoc +end; + +function TCommandLine.Params: TCommandLineDict; +begin +result := FParams +end; + +function TCommandLine.RawForm: IPrimitiveCommandLine; +begin +result := FRawForm +end; + +{ TParameterRegistrar } + +constructor TParameterRegistrar.Create( Params1: TCommandLineDict); +begin +FParams := Params1 +end; + +procedure TParameterRegistrar.RegisterBooleanParameter( const Name: string; + Default: boolean; const DocXPath: string; AllowedInRaw: boolean); +begin + +end; + +procedure TParameterRegistrar.RegisterDateParameter( const Name, + DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; + IncludesTZ: boolean; TZMinutes: integer); +begin + +end; + +procedure TParameterRegistrar.RegisterDateTimeParameter( const Name, + DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; + IncludesTZ: boolean; TZMinutes: integer); +begin + +end; + +procedure TParameterRegistrar.RegisterFloatParameter( const Name: string; + Default: double; const DocXPath: string; AllowedInRaw: boolean); +begin + +end; + +procedure TParameterRegistrar.RegisterIntegerParameter( const Name: string; + Default: integer; const DocXPath: string; AllowedInRaw: boolean); +begin + +end; + +procedure TParameterRegistrar.RegisterStringParameter( const Name, Default, + DocXPath: string; EmptyCountsAsAbsent, AllowedInRaw: boolean); +begin + +end; + +procedure TParameterRegistrar.RegisterTimeParameter( const Name, + DocXPath: string; AllowedInRaw: boolean; Default: TDateTime; + IncludesTZ: boolean; TZMinutes: integer); +begin + +end; + +procedure TParameterRegistrar.RegisterXMLParameter( const Name, DocXPath: string; + AllowedInRaw: boolean; const Namespaces: string); +begin + +end; + +{ TCommandLineParamValue } + +constructor TCommandLineParamValue.Create(isNull, AllowedInRaw: boolean; + const DocXPath: string); +begin + +end; + +function TCommandLineParamValue.IsNull: boolean; +begin + +end; + +function TCommandLineParamValue.SetFromParamDocument( + const Value: IXMLNode): boolean; +begin + +end; + +{ TStringParamValue } + +function TStringParamValue.AsString: string; +begin + +end; + +constructor TStringParamValue.Create(const Default, DocXPath: string; + EmptyCountsAsAbsent, AllowedInRaw: boolean); +begin + +end; + +function TStringParamValue.Kind: TParamKind; +begin + +end; + +function TStringParamValue.SetFromParamDocument(const Value: IXMLNode): boolean; +begin + +end; + +function TStringParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TFloatParamValue } + +constructor TFloatParamValue.Create(Default: double; const DocXPath: string; + AllowedInRaw: boolean); +begin + +end; + +procedure TFloatParamValue.GetValue(var Value: double; + var IsDefaulted: boolean); +begin + +end; + +function TFloatParamValue.SetFromParamDocument(const Value: IXMLNode): boolean; +begin + +end; + +function TFloatParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TIntegerParamValue } + +constructor TIntegerParamValue.Create(Default: integer; const DocXPath: string; + AllowedInRaw: boolean); +begin + +end; + +procedure TIntegerParamValue.GetValue(var Value: integer; + var IsDefaulted: boolean); +begin + +end; + +function TIntegerParamValue.SetFromParamDocument( + const Value: IXMLNode): boolean; +begin + +end; + +function TIntegerParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TBooleanParamValue } + +constructor TBooleanParamValue.Create(Default: boolean; const DocXPath: string; + AllowedInRaw: boolean); +begin + +end; + +procedure TBooleanParamValue.GetValue(var Value, IsDefaulted: boolean); +begin + +end; + +function TBooleanParamValue.SetFromParamDocument( + const Value: IXMLNode): boolean; +begin + +end; + +function TBooleanParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TDateTimeParamValue } + +constructor TDateTimeParamValue.Create(const DocXPath: string; + AllowedInRaw: boolean; Default: TDateTime; IncludesTZ: boolean; + TZMinutes: integer); +begin + +end; + +procedure TDateTimeParamValue.GetValue(var Value: TDateTime; + var TZMinutes: integer; var TZIncluded, IsDefaulted: boolean); +begin + +end; + +function TDateTimeParamValue.SetFromParamDocument( + const Value: IXMLNode): boolean; +begin + +end; + +function TDateTimeParamValue.SetFromRawCommandLine( + const Value: string): boolean; +begin + +end; + +{ TDateParamValue } + +constructor TDateParamValue.Create(const DocXPath: string; + AllowedInRaw: boolean; Default: TDate; IncludesTZ: boolean; + TZMinutes: integer); +begin + +end; + +procedure TDateParamValue.GetValue(var Value: TDate; var TZMinutes: integer; + var TZIncluded, IsDefaulted: boolean); +begin + +end; + +function TDateParamValue.SetFromParamDocument(const Value: IXMLNode): boolean; +begin + +end; + +function TDateParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TTimeParamValue } + +constructor TTimeParamValue.Create(const DocXPath: string; + AllowedInRaw: boolean; Default: TTime; IncludesTZ: boolean; + TZMinutes: integer); +begin + +end; + +procedure TTimeParamValue.GetValue(var Value: TTime; var TZMinutes: integer; + var TZIncluded, IsDefaulted: boolean); +begin + +end; + +function TTimeParamValue.SetFromParamDocument(const Value: IXMLNode): boolean; +begin + +end; + +function TTimeParamValue.SetFromRawCommandLine(const Value: string): boolean; +begin + +end; + +{ TXDocValue } + +constructor TXDocValue.Create(const DocXPath: string; AllowedInRaw: boolean; + const Namespaces: string); +begin + +end; + +procedure TXDocValue.GetValue(var Value: IXMLDocument; + var SourceFileName: string); +begin + +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.DDExtensions.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.DDExtensions.pas new file mode 100644 index 0000000..a9fd265 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.DDExtensions.pas @@ -0,0 +1,895 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.DDExtensions; +{$I ../includes/DUnitM.inc} +interface +uses DUnitM.UnitTestFramework, Rtti + {$ifdef MSWINDOWS} + , XMLIntf + {$endif} + ; + +type +{$ifdef MSWINDOWS} +ADOAttribute = class( TDataDrivenTestAttributeBase) +public + sConnectionString: string; + sTableName: string; + constructor Create( const psConnectionString, psTableName: string); + function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; override; + procedure CustomiseConnectionString( var sFinalConString, sFinalTableName: string); virtual; +end; +{$endif} + +{$ifdef MSWINDOWS} +ExcelAttribute = class( ADOAttribute) +public + constructor Create( const psTableName: string + {$ifdef SUPPORTS_REGEX} + ; const psConnectionOverrides: string = '' + {$endif}); + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; override; +end; +{$endif} + +TextFileAttribute = class( TDataDrivenTestAttributeBase) +public + function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; override; +end; + +{$ifdef MSWINDOWS} +XMLAttribute = class( TDataDrivenTestAttributeBase) +public + sXPath: string; + sNamespaceDecls: string; + constructor Create( const psXPath: string; const psNamespaceDecls: string = ''); + function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; override; +end; +{$endif} + + +implementation + + + + + + + +uses DUnitM.TestCase, DUnitM.TestNode, TypInfo, SysUtils, Classes, + DUnitM.RttiUtils, IOUtils, SBD.Utils.XML2 + {$ifdef SUPPORTS_REGEX} + , RegularExpressions + {$endif} + {$ifdef MSWINDOWS} + {$ifdef DELPHI_XE2_UP} + , Data.Win.ADODB + {$else} + , ADODB + {$endif} + {$endif} + ; + + +type +TDDTestCaseFactoryBase = class abstract( TInterfacedObject, IDataDrivenTestCaseFactory) + protected + ProcAsObject: TReflector; + ProcMethod: TRttiMethod; + DrivingAttribute: TDataDrivenTestAttributeBase; + function Repeats: integer; virtual; + function MethodSkips: integer; virtual; + function Name: string; virtual; + function Make: ITestCase; virtual; abstract; + function ManagerClass: TDataDrivenTestCaseNavManagerClass; virtual; abstract; + public + constructor Create( Attri: TDataDrivenTestAttributeBase; ProcParentAsObject: TReflector; ProcType: TRttiMethod); virtual; + class function SignatureMatches( poTestMethod: TRttiMethod): boolean; virtual; abstract; + end; + +{$ifdef MSWINDOWS} +TADOFactory = class( TDDTestCaseFactoryBase) + protected + function Make: ITestCase; override; + function ManagerClass: TDataDrivenTestCaseNavManagerClass; override; + function MethodSkips: integer; override; + + protected type + TDDManager = class( TDataDrivenTestCaseNavManager) + public + constructor Create( Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); override; + function EstimatedCount( TestBed: TObject; var CountItems: integer): boolean; override; + function OpenLineItemCursor( TestBed: TObject): ITestCaseLineItemCursor; override; + procedure TestLineItem( TestBed: TObject; Cursor: ITestCaseLineItemCursor); override; + + protected + FGetFileNameMeth : TRttiMethod; + sConnectionString: string; + sTableName : string; + FAttri : ADOAttribute; + procedure MakeComponents( + TestBed: TObject; var ADOCon: TADOConnection; var ADOTable: TADOTable); + end; + + protected type + TTestCaseLineItemCursor = class( TInterfacedObject, ITestCaseLineItemCursor) + protected + FADOCon: TADOConnection; + FADOTable: TADOTable; + FisFirst: boolean; + function Next: boolean; virtual; + procedure GetLineItemDescription( RowNumber: integer; var sDescription: string); virtual; + function LineItemObject: TObject; virtual; + public + constructor Create( ADOCon: TADOConnection; ADOTable: TADOTable); + destructor Destroy; override; + end; + + public + class function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + end; +{$endif} + +TTextFactory = class( TDDTestCaseFactoryBase) + protected + function Make: ITestCase; override; + function ManagerClass: TDataDrivenTestCaseNavManagerClass; override; + function MethodSkips: integer; override; + + protected type + TDDManager = class( TDataDrivenTestCaseNavManager) + public + constructor Create( Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); override; + function EstimatedCount( TestBed: TObject; var CountItems: integer): boolean; override; + function OpenLineItemCursor( TestBed: TObject): ITestCaseLineItemCursor; override; + procedure TestLineItem( TestBed: TObject; Cursor: ITestCaseLineItemCursor); override; + + protected + FGetFileNameMeth : TRttiMethod; + function GetTextFileName( TestBed: TObject): string; + end; + + protected type + TTextLineCursor = class( TInterfacedObject, ITestCaseLineItemCursor) + protected + FIdx: integer; + FData: TStrings; + FCurrent: TObject; + function Next: boolean; virtual; + procedure GetLineItemDescription( RowNumber: integer; var sDescription: string); virtual; + function LineItemObject: TObject; virtual; + public + constructor Create( const sFileName: string); + destructor Destroy; override; + end; + + public + class function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + end; + +{$ifdef MSWINDOWS} +TXMLFactory = class( TDDTestCaseFactoryBase) + protected + function Make: ITestCase; override; + function ManagerClass: TDataDrivenTestCaseNavManagerClass; override; + function MethodSkips: integer; override; + + protected type + TDDManager = class( TDataDrivenTestCaseNavManager) + public + constructor Create( Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); override; + function EstimatedCount( TestBed: TObject; var CountItems: integer): boolean; override; + function OpenLineItemCursor( TestBed: TObject): ITestCaseLineItemCursor; override; + procedure TestLineItem( TestBed: TObject; Cursor: ITestCaseLineItemCursor); override; + + protected + FGetFileNameMeth : TRttiMethod; + sXPath: string; + sNamespaceDecls: string; + end; + + protected type + TNodeCursor = class( TInterfacedObject, ITestCaseLineItemCursor) + protected + FDoc : IXMLDocument; + FCursor : IEnumerator; + FCurrent: TObject; + function Next: boolean; virtual; + procedure GetLineItemDescription( RowNumber: integer; var sDescription: string); virtual; + function LineItemObject: TObject; virtual; + public + constructor Create( const FileName1, XPath1, NamespaceDecl1: string); + destructor Destroy; override; + end; + + public + class function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + end; +{$endif} + + + + + + + + + +{$ifdef MSWINDOWS} +constructor ADOAttribute.Create( const psConnectionString, psTableName: string); +begin +sConnectionString := psConnectionString; +sTableName := psTableName +end; + +procedure ADOAttribute.CustomiseConnectionString( + var sFinalConString, sFinalTableName: string); +begin +end; + +function ADOAttribute.AcquireFactory( + ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; +begin +result := TADOFactory.Create( self, ProcParentAsObject as TReflector, ProcType) +end; + +function ADOAttribute.SignatureMatches( poTestMethod: TRttiMethod): boolean; +begin +result := TADOFactory.SignatureMatches( poTestMethod) +end; + + +constructor ExcelAttribute.Create( const psTableName: string + {$ifdef SUPPORTS_REGEX} + ; const psConnectionOverrides: string = '' + {$endif}); +var + ConProps: TStrings; + {$ifdef SUPPORTS_REGEX} + Match: TMatch; + {$endif} + sCon, sPropDef: string; +begin +ConProps := TStringList.Create; +ConProps.Add( 'Provider=Microsoft.ACE.OLEDB.12.0'); +ConProps.Add( 'Mode=Read'); +ConProps.Add( 'Extended Properties="Excel 12.0 Xml;HDR=YES"'); +ConProps.Add( 'Persist Security Info=False'); +{$ifdef SUPPORTS_REGEX} +if psConnectionOverrides <> '' then + for Match in TRegex.Matches( psConnectionOverrides+';', + '([^;="]+)=([^;="]*|("[^"]*")+);') do + ConProps.Values[ Match.Groups[1].Value] := Match.Groups[2].Value; +{$endif} +for sPropDef in ConProps do + sCon := sCon + sPropDef + ';'; +Delete( sCon, Length( sCon), 1); +inherited Create( sCon, psTableName) +end; + +function ExcelAttribute.AcquireFactory( + ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; +begin +result := TADOFactory.Create( self, ProcParentAsObject as TReflector, ProcType) +end; +{$endif} + + + +function TextFileAttribute.AcquireFactory( + ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; +begin +result := TTextFactory.Create( self, ProcParentAsObject as TReflector, ProcType) +end; + +function TextFileAttribute.SignatureMatches( poTestMethod: TRttiMethod): boolean; +begin +result := TTextFactory.SignatureMatches( poTestMethod) +end; + + +{$ifdef MSWINDOWS} +constructor XMLAttribute.Create( const psXPath, psNamespaceDecls: string); +begin +sXPath := psXPath; +sNamespaceDecls := psNamespaceDecls +end; + + +function XMLAttribute.AcquireFactory( + ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; +begin +result := TXMLFactory.Create( self, ProcParentAsObject as TReflector, ProcType) +end; + +function XMLAttribute.SignatureMatches( poTestMethod: TRttiMethod): boolean; +begin +result := TXMLFactory.SignatureMatches( poTestMethod) +end; +{$endif} + + +constructor TDDTestCaseFactoryBase.Create( + Attri: TDataDrivenTestAttributeBase; ProcParentAsObject: TReflector; ProcType: TRttiMethod); +begin +ProcAsObject := ProcParentAsObject; +ProcMethod := ProcType; +DrivingAttribute := Attri +end; + +function TDDTestCaseFactoryBase.MethodSkips: integer; +begin +result := 0 +end; + +function TDDTestCaseFactoryBase.Name: string; +begin +result := ProcMethod.Name +end; + +function TDDTestCaseFactoryBase.Repeats: integer; +begin +result := 1 +end; + + +{$ifdef MSWINDOWS} +function TADOFactory.Make: ITestCase; +begin +result := TDataDrivenTestCase.CreateCase( ManagerClass, ProcAsObject, ProcMethod, DrivingAttribute) +end; + +function TADOFactory.ManagerClass: TDataDrivenTestCaseNavManagerClass; +begin +result := TDDManager +end; + +function TADOFactory.MethodSkips: integer; +begin +result := 1 +end; + +class function TADOFactory.SignatureMatches( poTestMethod: TRttiMethod): boolean; +// Signature looks like ... +// {$ifdef MSWINDOWS} +// [DataDrivenTest] +// [DUnitM.DDExtensions.ADO('ADO-connection-string','TabName')] +// procedure TestIt2( DataSource: TADOTable); +// function TestIt2FileName: string; +// {$endif} +var + FileMeth: TRttiMethod; + DataSourceParam: TRttiParameter; + ExpectedFlags: TParamFlags; +begin +result := (poTestMethod.MethodKind = mkProcedure) and + (Length( poTestMethod.GetParameters) = 1); +if not result then exit; +DataSourceParam := poTestMethod.GetParameters[0]; +{$ifdef DELPHI_XE2_UP} + ExpectedFlags := [pfAddress]; +{$else} + ExpectedFlags := []; +{$endif} +result := (DataSourceParam.ParamType.TypeKind = tkClass) and + (DataSourceParam.Flags = ExpectedFlags) and + (DataSourceParam.ParamType.Handle = TypeInfo( TADOTable)) and + + NextDeclaredMethod( poTestMethod, FileMeth) and + (FileMeth.MethodKind = mkFunction) and + (Length( FileMeth.GetParameters) = 0) and + (FileMeth.ReturnType.TypeKind = tkUString) +end; + + +constructor TADOFactory.TDDManager.Create( + Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); +begin +PrimitiveCreate( Parent, Method); +NextDeclaredMethod( Method, FGetFileNameMeth); // function TestIt2FileName: string; +FAttri := nil; +if Attribute is ADOAttribute then + begin + FAttri := ADOAttribute( Attribute); + self.sConnectionString := FAttri.sConnectionString; + self.sTableName := FAttri.sTableName + end +end; + +procedure TADOFactory.TDDManager.MakeComponents( + TestBed: TObject; var ADOCon: TADOConnection; var ADOTable: TADOTable); +var + sCon, sTabName: string; + sFN: string; +begin +ADOCon := TADOConnection.Create( nil); +with ADOCon do + begin + Attributes := []; + CommandTimeout := 30; + ConnectionTimeout := 15; + ConnectOptions := coConnectUnspecified; + CursorLocation := clUseClient; + IsolationLevel := ilCursorStability; + KeepConnection := True; + LoginPrompt := False; + Mode := cmRead + end; +ADOTable := TADOTable.Create( nil); +sTabName := self.sTableName; +with ADOTable do + begin + AutoCalcFields := False; + CacheSize := 1; + CommandTimeout := 30; + Connection := ADOCon; + CursorLocation := clUseClient; + CursorType := ctStatic; + EnableBCD := True; + ExecuteOptions := []; + LockType := ltReadOnly; + MarshalOptions := moMarshalAll; + ReadOnly := True; + TableDirect := not sTabName.StartsWith('[') + end; +sCon := self.sConnectionString; +try + sFN := FGetFileNameMeth.Invoke( TestBed, []).AsString +except + sFN := '' + end; +if sFN <> '' then + begin + if sCon <> '' then + sCon := sCon + ';'; + sCon := sCon + 'Data Source=' + sFN + end; +if assigned( FAttri) then + FAttri.CustomiseConnectionString( sCon, sTabName); +ADOCon.ConnectionString := sCon; +ADOTable.TableName := sTabName +end; + +function TADOFactory.TDDManager.EstimatedCount( + TestBed: TObject; var CountItems: integer): boolean; +var + ADOCon: TADOConnection; + ADOTable: TADOTable; +begin +CountItems := 0; +MakeComponents( TestBed, ADOCon, ADOTable); +try try + ADOCon.Connected := True; + ADOTable.Active := True; + ADOTable.Active := False; + ADOTable.Active := True; + if ADOTable.Active then + CountItems := ADOTable.RecordCount; + result := ADOTable.Active +except on E: Exception do + result := False + end +finally + ADOTable.Active := False; + ADOCon.Connected := False; + ADOTable.Free; + ADOCon.Free + end +end; + +function TADOFactory.TDDManager.OpenLineItemCursor( + TestBed: TObject): ITestCaseLineItemCursor; +var + ADOCon: TADOConnection; + ADOTable: TADOTable; + Owns: boolean; +begin +result := nil; +Owns := True; +MakeComponents( TestBed, ADOCon, ADOTable); +try try + ADOCon.Connected := True; + ADOTable.Active := True; + ADOTable.Active := False; + ADOTable.Active := True; + if ADOTable.Active then + begin + Owns := False; + result := TTestCaseLineItemCursor.Create( ADOCon, ADOTable) + end +except on E: Exception do + result := nil + end +finally + if Owns then + begin + ADOTable.Active := False; + ADOCon.Connected := False; + ADOTable.Free; + ADOCon.Free + end + end +end; + +procedure TADOFactory.TDDManager.TestLineItem( + TestBed: TObject; Cursor: ITestCaseLineItemCursor); +begin +TestMeth.Invoke( TestBed, [Cursor.LineItemObject as TADOTable]) +end; +{$endif} + + +constructor TADOFactory.TTestCaseLineItemCursor.Create(ADOCon: TADOConnection; + ADOTable: TADOTable); +begin +FADOCon := ADOCon; +FADOTable := ADOTable; +FisFirst := True +end; + +destructor TADOFactory.TTestCaseLineItemCursor.Destroy; +begin +FADOTable.Free; +FADOCon.Free; +inherited +end; + +procedure TADOFactory.TTestCaseLineItemCursor.GetLineItemDescription( + RowNumber: integer; var sDescription: string); +begin +end; + +function TADOFactory.TTestCaseLineItemCursor.LineItemObject: TObject; +begin +result := FADOTable +end; + +function TADOFactory.TTestCaseLineItemCursor.Next: boolean; +begin +result := not FADOTable.Eof; +if not result then exit; +if FisFirst then + FisFirst := False + else + begin + FADOTable.Next; + result := not FADOTable.Eof + end +end; + + +function TTextFactory.Make: ITestCase; +begin +result := TDataDrivenTestCase.CreateCase( ManagerClass, ProcAsObject, ProcMethod, DrivingAttribute) +end; + +function TTextFactory.ManagerClass: TDataDrivenTestCaseNavManagerClass; +begin +result := TDDManager +end; + +function TTextFactory.MethodSkips: integer; +begin +result := 1 +end; + +class function TTextFactory.SignatureMatches( + poTestMethod: TRttiMethod): boolean; +// Signature looks like ... +// [DataDrivenTest] +// [DUnitM.DDExtensions.TextFile] +// procedure TestIt4( const Line: string); +// function TestIt4FileName: string; +// +var + FileMeth: TRttiMethod; +begin +result := (poTestMethod.MethodKind = mkProcedure) and + (Length( poTestMethod.GetParameters) = 1); +if not result then exit; +with poTestMethod.GetParameters[0] do + result := (ParamType.TypeKind = tkUString) and + (Flags = [pfConst]) and + + NextDeclaredMethod( poTestMethod, FileMeth) and + (FileMeth.MethodKind = mkFunction) and + (Length( FileMeth.GetParameters) = 0) and + (FileMeth.ReturnType.TypeKind = tkUString) +end; + + +constructor TTextFactory.TDDManager.Create( + Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); +begin +PrimitiveCreate( Parent, Method); +NextDeclaredMethod( Method, FGetFileNameMeth); // function TestIt2FileName: string; +end; + + +function TTextFactory.TDDManager.EstimatedCount( + TestBed: TObject; var CountItems: integer): boolean; +var + Data: TStrings; +begin +Data := TStringList.Create; +try try + Data.LoadFromFile( GetTextFileName( TestBed)); + CountItems := Data.Count; + result := True +finally + Data.Free + end +except + result := False + end +end; + +function TTextFactory.TDDManager.GetTextFileName( TestBed: TObject): string; +begin +try + result := FGetFileNameMeth.Invoke( TestBed, []).AsString +except + result := '' + end +end; + +type TStringWrapper = class( TAggregatedObject) + public + sValue: string; + end; + +function TTextFactory.TDDManager.OpenLineItemCursor( + TestBed: TObject): ITestCaseLineItemCursor; +begin +result := TTextLineCursor.Create( GetTextFileName( TestBed)) +end; + +procedure TTextFactory.TDDManager.TestLineItem( + TestBed: TObject; Cursor: ITestCaseLineItemCursor); +begin +TestMeth.Invoke( TestBed, [(Cursor.LineItemObject as TStringWrapper).sValue]) +end; + + +constructor TTextFactory.TTextLineCursor.Create( + const sFileName: string); +begin +FCurrent := TStringWrapper.Create( self); +FData := TStringList.Create; +FIdx := -1 +end; + +destructor TTextFactory.TTextLineCursor.Destroy; +begin +FCurrent.Free; +FData.Free; +inherited +end; + +procedure TTextFactory.TTextLineCursor.GetLineItemDescription( + RowNumber: integer; var sDescription: string); +begin +end; + +function TTextFactory.TTextLineCursor.LineItemObject: TObject; +begin +result := FCurrent; +TStringWrapper( FCurrent).sValue := FData[ FIdx] +end; + +function TTextFactory.TTextLineCursor.Next: boolean; +begin +result := FIdx <= (FData.Count - 2); +if result then + Inc( FIdx) +end; + + + + + + + + + + +{$ifdef MSWINDOWS} +function TXMLFactory.Make: ITestCase; +begin +result := TDataDrivenTestCase.CreateCase( ManagerClass, ProcAsObject, ProcMethod, DrivingAttribute) +end; + +function TXMLFactory.ManagerClass: TDataDrivenTestCaseNavManagerClass; +begin +result := TDDManager +end; + +function TXMLFactory.MethodSkips: integer; +begin +result := 1 +end; + +class function TXMLFactory.SignatureMatches( poTestMethod: TRttiMethod): boolean; +// {$ifdef MSWINDOWS} +// [DataDrivenTest] +// [DUnitM.DDExtensions.XML('XPath-expression')] +// procedure TestIt5( const Node: IXMLNode); +// function TestIt5FileName: string; +// {$endif} +var + FileMeth: TRttiMethod; + NodeParam: TRttiParameter; +begin +result := (poTestMethod.MethodKind = mkProcedure) and + (Length( poTestMethod.GetParameters) = 1); +if not result then exit; +NodeParam := poTestMethod.GetParameters[0]; +result := (NodeParam.ParamType.TypeKind = tkInterface) and + (NodeParam.Flags = [pfConst, pfAddress]) and + // Does D2010 use pfAddress for interface pointers? To be investigated. + (NodeParam.ParamType is TRttiInterfaceType) and + IsEqualGUID( + TRttiInterfaceType( NodeParam.ParamType).GUID, + IXMLNode) and + + NextDeclaredMethod( poTestMethod, FileMeth) and + (FileMeth.MethodKind = mkFunction) and + (Length( FileMeth.GetParameters) = 0) and + (FileMeth.ReturnType.TypeKind = tkUString) +end; + + +constructor TXMLFactory.TDDManager.Create( + Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); +var + Attri: XMLAttribute; +begin +PrimitiveCreate( Parent, Method); +NextDeclaredMethod( Method, FGetFileNameMeth); // function TestIt2FileName: string; +if Attribute is XMLAttribute then + begin + Attri := XMLAttribute( Attribute); + self.sXPath := Attri.sXPath; + self.sNamespaceDecls := Attri.sNamespaceDecls + end +end; + +function TXMLFactory.TDDManager.EstimatedCount( + TestBed: TObject; var CountItems: integer): boolean; +begin +result := False +// When we can build an XPath 3.0 engine, we will be able to leverage +// XPath to do the counting. For now, manually count the items. +end; + +function TXMLFactory.TDDManager.OpenLineItemCursor( + TestBed: TObject): ITestCaseLineItemCursor; +var + sFN: string; +begin +sFN := FGetFileNameMeth.Invoke( TestBed, []).AsString; +result := TXMLFactory.TNodeCursor.Create( sFN, sXPath, sNamespaceDecls) +end; + + +type TXMLNodeWrapper = class( TAggregatedObject) + public + FDatum: IXMLNode; + end; + +procedure TXMLFactory.TDDManager.TestLineItem( + TestBed: TObject; Cursor: ITestCaseLineItemCursor); +var + Datum: IXMLNode; + Args : array of TValue; +begin +Datum := (Cursor.LineItemObject as TXMLNodeWrapper).FDatum; +SetLength( Args, 1); +Args[0] := TValue.From( Datum); +TestMeth.Invoke( TestBed, Args) +end; + + +constructor TXMLFactory.TNodeCursor.Create( + const FileName1, XPath1, NamespaceDecl1: string); +begin +FDoc := SBD.Utils.XML2.TXMLDoc.FromFile( FileName1); +if NamespaceDecl1 <> '' then + SBD.Utils.XML2.TXMLDoc.DeclareSelectionNamespaces( FDoc, NamespaceDecl1); +FCursor := SBD.Utils.XML2.TXPath.Enum( + SBD.Utils.XML2.TXPath.Select( FDoc.Node, XPath1)).GetEnumerator; +FCurrent := TXMLNodeWrapper.Create( self) +end; + +destructor TXMLFactory.TNodeCursor.Destroy; +begin +FCurrent.Free; +FCursor := nil; +FDoc := nil; +inherited +end; + +procedure TXMLFactory.TNodeCursor.GetLineItemDescription( + RowNumber: integer; var sDescription: string); +begin +end; + +function TXMLFactory.TNodeCursor.LineItemObject: TObject; +begin +result := FCurrent; +TXMLNodeWrapper( FCurrent).FDatum := FCursor.Current +end; + +function TXMLFactory.TNodeCursor.Next: boolean; +begin +result := FCursor.MoveNext +end; +{$endif} + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.Executive.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.Executive.pas new file mode 100644 index 0000000..0612fe7 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.Executive.pas @@ -0,0 +1,91 @@ +unit DUnitM.Executive; +// The contents of this unit are dynamically generated by the DUnit-m Wizard. +interface +uses DUnitM.BaseExecutive; + +function AcquireExecutive: IExecutive; + +implementation + + +uses System.Classes, DUnitM.ViewModel_Tree, DUnitM.TestSuiteDxVirtualTree, + System.SysUtils, TPLB3.Random + , uLockBox_TestCases + , uLockBox_CipherTestCases + , uLockBox_Hashes + , uLockBox_HugeCardinalTestCases + , uLockBox_OpenSSLTestCases + , uLockBox_RSA_TestCases + , uLockBox_Signatory_TestCases + ; + +type +TExecutive = class( TBaseExecutive) + protected + procedure RegisterTestFixtures; override; + procedure RegisterServices; override; + function ApplicationTitle: string; override; + end; + + +function AcquireExecutive: IExecutive; +begin +result := TExecutive.Create +end; + +function TExecutive.ApplicationTitle: string; +begin +result := 'DUnit-M Suite Runner: TP Lockbox 3 Unit Test Suite' +end; + + +procedure TExecutive.RegisterServices; +begin +inherited; +DUnitM.TestSuiteDxVirtualTree.RegisterServices( FServices); +TEncoding.Unicode; +TEncoding.UTF8; +TEncoding.ANSI; +TEncoding.ASCII; +TEncoding.BigEndianUnicode; +TEncoding.UTF7; +TRandomStream.Instance.Randomize +end; + + +procedure TExecutive.RegisterTestFixtures; +begin + FModel.RegisterFixtureClass( uLockBox_TestCases.TEnvironment_TestCase); + + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TAES128_RefTestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TAES192_RefTestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TAES256_RefTestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TBase64_TestCases); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TDES_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TDES_Reference_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.T3DES_Reference_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.T3DES_KO1_Reference_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TBlowfish_Reference_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TTwofish_Reference_TestCase); + FModel.RegisterFixtureClass( uLockBox_CipherTestCases.TMasBug_TestCase); + + FModel.RegisterFixtureClass( uLockBox_Hashes.TMD5_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA1_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA256_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA224_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA512_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA384_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA512_224_TestCase); + FModel.RegisterFixtureClass( uLockBox_Hashes.TSHA512_256_TestCase); + + FModel.RegisterFixtureClass( uLockBox_HugeCardinalTestCases.THugeCardinal_TestCase); + + FModel.RegisterFixtureClass( uLockBox_OpenSSLTestCases.TOpenSSL_TestCase); + + FModel.RegisterFixtureClass( uLockBox_RSA_TestCases.TRSA_TestCase); + FModel.RegisterFixtureClass( uLockBox_RSA_TestCases.TRSA_Crypto_TestCase); + + FModel.RegisterFixtureClass( uLockBox_Signatory_TestCases.TRSASignatory_TestCase); +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.Fixture.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.Fixture.pas new file mode 100644 index 0000000..4269cea --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.Fixture.pas @@ -0,0 +1,1035 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.Fixture; +interface +uses DUnitM.TestNode, Rtti, SBD.Generics, DUnitM.UnitTestFramework, DUnitM.MemoryMonitor, + SBD.ServiceProvider; + +type +IFixturesInternal = interface( IList2) + ['{BCEC2CA8-A15E-440E-BF32-A7C02029C092}'] + function FindOrAddNamespaceFixture( const NodeName: string; const NSFactory: ITestNodeFactory): ITestFixtureInternal; + function AddLeafFixture( const Factory: ITestNodeFactory; const FixtureName: string; FixtureType: TRttiType): ITestFixtureInternal; + procedure ShutDown; + end; + +ITestSuiteInternal = interface( ITestSuite) + ['{F1AA35C1-1904-4BF5-84AD-4D86C61B9FC0}'] + procedure RegisterFixture( FixtureType: TRttiType); + function Run( const ExecServices: IRunnerExecutiveServices): ITestResult; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + + +implementation + + + + + + + + + + + + + + + + + + + + + + +uses SysUtils, DUnitM.RttiUtils, TypInfo, DUnitM.TestProcedure, + SBD.Messages,SBD.Messages.Solution, DUnitM.StringUtils, + DUnitM.MemoryMonitor.Solution, DUnitM.Assertion, + DUnitM.RunInstance; + + +type +TNamespaceFixtureOrSuite = class abstract( TTestNode, ITestFixture, ITestFixtureInternal) + protected + FChildren: IFixturesInternal; // TFixtureList + function Parent: ITestFixture; virtual; + function FixtureChildren: ISEnumerable; virtual; + function TestProcedures: ISEnumerable; virtual; + function isNamespaceFixture: boolean; virtual; + function PreliminaryPlatterObject: TObject; virtual; + procedure Setup( Platter: TObject); virtual; + procedure Teardown( Platter: TObject); virtual; + function NodeChildren: ISEnumerable; override; + function Load: integer; override; + function MakeRunInstance( ParentRunInstance: TReflector; const Mem1: IMemoryMonitor): IRunInstance; virtual; + + public + constructor CreateNamespaceFixture( ParentAsObject: TReflector); + end; + +TNamespaceFactory = class sealed( TBaseNodeFactory) + protected + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; override; + public + [Configuration('rnNamespaceFixture')] constructor ServiceModeCreate; + + private type + TNamespaceFixture = class( TNamespaceFixtureOrSuite, IFixtureChild) + private + FName: string; + FDescription: string; + + protected + function Description: string; override; + function Name: string; override; + function NodeKind: TResultNodeKind; override; + // IFixtureChild + function MakeRunInstanceOfFixtureChild( const ParentFixture: IRunInstance; var Addend: IRunInstance): boolean; virtual; + end; + end; + + +TFixtureList = class( TList2, IFixturesInternal, IShutDown) + public + function FindOrAddNamespaceFixture( const NodeName: string; const NSFactory: ITestNodeFactory): ITestFixtureInternal; + function AddLeafFixture( const Factory: ITestNodeFactory; const FixtureName: string; FixtureType: TRttiType): ITestFixtureInternal; + procedure ShutDown; + end; + + +TSuiteFactory = class sealed( TBaseNodeFactory) + protected + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; override; + public + [Configuration('rnRoot')] constructor ServiceModeCreate; + + private + [Injection( 'rnLeafFixture')] FLeafFactory: ITestNodeFactory; + [Injection( 'rnNamespaceFixture')] FNSFactory: ITestNodeFactory; + + private type + TTestSuite = class sealed( TNamespaceFixtureOrSuite, ITestSuite, ITestSuiteInternal) + private + FLeafFactory: ITestNodeFactory; + FNSFactory: ITestNodeFactory; + + function Fixtures: ISEnumerable; + procedure RegisterFixture( FixtureType: TRttiType); + function Run( const ExecServices: IRunnerExecutiveServices): ITestResult; + function CreateRunInstance( const ExecServices: IRunnerExecutiveServices): IRunInstance; + function ProvideRunInstanceServices( const ExecServices: IRunnerExecutiveServices): IRunInstanceServices; + + protected + function NodeKind: TResultNodeKind; override; + function Name: string; override; + function Parent: ITestFixture; override; + function Description: string; override; + end; + end; + + +TCaseBearingFixtureFactory = class sealed( TBaseNodeFactory) + protected + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; override; + public + [Configuration('rnLeafFixture')] constructor ServiceModeCreate; + + private + [Injection( 'rnTestProc')] FProcFactory: ITestNodeFactory; + + private type + TCaseBearingFixture = class sealed( TNamespaceFactory.TNamespaceFixture, IPlatterFactory) + private + FFixtureClass: TRttiType; + FProcedures: IProceduresInternal; + FSetupMeth: TRttiMethod; + FTearDownMeth: TRttiMethod; + FFixtureSetupMeth: TRttiMethod; + FAssertDataMembers: IList2; + FPreliminaryPlatterObject: TObject; + + protected + procedure ShutDown; override; + function TestProcedures: ISEnumerable; override; + function Load: integer; override; + function isNamespaceFixture: boolean; override; + function PreliminaryPlatterObject: TObject; override; + procedure Setup( Platter: TObject); override; + procedure Teardown( Platter: TObject); override; + function NodeKind: TResultNodeKind; override; + function MakeRunInstance( ParentRunInstance: TReflector; const Mem1: IMemoryMonitor): IRunInstance; override; + + private + function CreatePlatter( var Hold: IInterface): TObject; + procedure ReleasePlatter( var Hold: IInterface; var Obj: TObject); + procedure SetGateway( TestBed1: TObject; const Gateway: ICheckGateway); + procedure ComputeAndCacheLoads; + end; + end; + + + +TFixture_RunInstance2 = class( TTestNode_RunInstanceWithChildren, IFixtureRunInstance) + protected + FFixture: ITestFixtureInternal; + + // IFixtureRunInstance + function MakeProcedureRunInstance( const TestProc: ITestProcedure): IRunInstance; virtual; + function MakeFixtureRunInstance( const Fixture: ITestFixture): IRunInstance; + function TestNode: ITestNode; override; + function RoundsPerTestCase: integer; override; + function Fixture: ITestFixture; override; + function NodeKind: TResultNodeKind; override; + procedure DoInnerRun; override; + + public + constructor Create( ParentAsObject: TReflector; const Fixture1: ITestFixtureInternal; const Mem1: IMemoryMonitor); + end; + +TCaseBearingFixture_RunInstance2 = class( TFixture_RunInstance2) + protected + FTestBed: TObject; + function MakeProcedureRunInstance( const TestProc: ITestProcedure): IRunInstance; override; + procedure DoInnerRun; override; + function NodeKind: TResultNodeKind; override; + end; + +TSuite_RunInstance2 = class( TFixture_RunInstance2) + protected + function NodeKind: TResultNodeKind; override; + public + constructor Create( const Suite1: ITestSuiteInternal; const Mem1: IMemoryMonitor); + end; + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( ITestNodeFactory, TSuiteFactory); +Provider.RegisterServiceClass( ITestNodeFactory, TCaseBearingFixtureFactory); +Provider.RegisterServiceClass( ITestNodeFactory, TNamespaceFactory); + +end; + + +constructor TNamespaceFixtureOrSuite.CreateNamespaceFixture( ParentAsObject: TReflector); +begin +inherited CreateTestNode( ParentAsObject); +FChildren := TFixtureList.Create +end; + +function TNamespaceFactory.TNamespaceFixture.Description: string; +begin +result := FDescription +end; + +function TNamespaceFixtureOrSuite.FixtureChildren: ISEnumerable; +begin +result := FChildren +end; + +function TNamespaceFixtureOrSuite.isNamespaceFixture: boolean; +begin +result := True +end; + +function TNamespaceFixtureOrSuite.Load: integer; +var + Child: ITestFixture; +begin +result := 0; +for Child in FixtureChildren do + Inc( Result, Child.Load) +end; + +function TNamespaceFixtureOrSuite.MakeRunInstance( ParentRunInstance: TReflector; const Mem1: IMemoryMonitor): IRunInstance; +begin +result := TFixture_RunInstance2.Create( ParentRunInstance, Self, Mem1) +end; + +function TNamespaceFactory.TNamespaceFixture.MakeRunInstanceOfFixtureChild( + const ParentFixture: IRunInstance; var Addend: IRunInstance): boolean; +var + FixRun: IFixtureRunInstance; +begin +result := Supports( ParentFixture, IFixtureRunInstance, FixRun); +if result then + Addend := FixRun.MakeFixtureRunInstance( self) +end; + +function TNamespaceFactory.TNamespaceFixture.Name: string; +begin +result := FName +end; + +function TNamespaceFixtureOrSuite.NodeChildren: ISEnumerable; +var + Accumulator: ITestNodes; + TestFixture: ITestFixture; + TestProc: ITestProcedure; +begin +Accumulator := TTestNodes.Create; +result := Accumulator; +for TestFixture in FixtureChildren do + Accumulator.Add( TestFixture as ITestNode); +for TestProc in TestProcedures do + Accumulator.Add( TestProc as ITestNode) +end; + +function TNamespaceFactory.TNamespaceFixture.NodeKind: TResultNodeKind; +begin +result := rnNamespaceFixture +end; + +function TNamespaceFixtureOrSuite.Parent: ITestFixture; +begin +if (not assigned( FParent)) or + (not Supports( FParent.FController, ItestFixture, result)) then + result := nil +end; + +function TNamespaceFixtureOrSuite.PreliminaryPlatterObject: TObject; +begin +result := nil +end; + +procedure TNamespaceFixtureOrSuite.Setup( Platter: TObject); +begin +end; + +type +TEmptyProcedures = class( TSEnumerable) + protected + function GetEnumerator: ISEnumerator; override; + end; + +function TEmptyProcedures.GetEnumerator: ISEnumerator; +begin +result := TEmptyCursor.Create( nil) +end; + + +procedure TNamespaceFixtureOrSuite.Teardown( Platter: TObject); +begin +end; + +function TNamespaceFixtureOrSuite.TestProcedures: ISEnumerable; +begin +result := TEmptyProcedures.Create +end; + + +function TCaseBearingFixtureFactory.TCaseBearingFixture.CreatePlatter( var Hold: IInterface): TObject; +var + Cls: TClass; + InstanceObj: TObject; +begin +Cls := TypInfo.GetTypeData( FFixtureClass.Handle)^.ClassType; +if assigned( FFixtureSetupMeth) then + begin + InstanceObj := Cls.NewInstance; + result := InstanceObj; + FFixtureSetupMeth.Invoke( result, []); + result.AfterConstruction + end + else + result := Cls.Create; +if (not Supports( result, IInterface, Hold)) or + ((Hold._AddRef + Hold._Release) = -2) then + Hold := nil +end; + + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.SetGateway( + TestBed1: TObject; const Gateway: ICheckGateway); +var + AssertDataMember: TRttiField; + AssertChecker: IAssert; + Injection: TValue; +begin +if not assigned( TestBed1) then exit; +AssertChecker := nil; +if assigned( Gateway) and (FAssertDataMembers.Count > 0) then + AssertChecker := TAssertChecker.Create( Gateway) + else + AssertChecker := nil; +Injection := TValue.From( AssertChecker); +for AssertDataMember in FAssertDataMembers do + AssertDataMember.SetValue( TestBed1, Injection) +end; + + + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.ReleasePlatter( var Hold: IInterface; var Obj: TObject); +begin +if assigned( Hold) then + Hold := nil + else + begin + Hold := nil; + Obj.Free + end; +Obj := nil +end; + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.ComputeAndCacheLoads; +var + Proc: ITestProcedure; + TCase: ITestCase; + CaseIntnl: ITestCaseInternal; + RequiresPreliminaryLoadCount: boolean; + Obj: TObject; + Hold: IInterface; +begin +RequiresPreliminaryLoadCount := False; +for Proc in FProcedures do + for TCase in Proc.TestCases do + if Supports( TCase, ITestCaseInternal, CaseIntnl) and + CaseIntnl.RequiresPreliminaryLoadCount then + begin + RequiresPreliminaryLoadCount := True; + break + end; +if RequiresPreliminaryLoadCount then + try + Obj := CreatePlatter( Hold); + try + FPreliminaryPlatterObject := Obj; + Load + finally + FPreliminaryPlatterObject := nil; + ReleasePlatter( Hold, Obj) + end + except on E: Exception do + for Proc in FProcedures do + for TCase in Proc.TestCases do + if Supports( TCase, ITestCaseInternal, CaseIntnl) then + CaseIntnl.SetDeferredError( E.Message) + end +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.isNamespaceFixture: boolean; +begin +result := False +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.Load: integer; +var + Proc: ITestProcedure; +begin +result := inherited Load; +for Proc in TestProcedures do + Inc( result, Proc.Load) +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.MakeRunInstance( + ParentRunInstance: TReflector; const Mem1: IMemoryMonitor): IRunInstance; +begin +result := TCaseBearingFixture_RunInstance2.Create( ParentRunInstance, self, Mem1) +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.NodeKind: TResultNodeKind; +begin +result := rnLeafFixture +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.PreliminaryPlatterObject: TObject; +begin +result := FPreliminaryPlatterObject +end; + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.Setup( Platter: TObject); +begin +if assigned( FSetupMeth) then + FSetupMeth.Invoke( Platter, []) +end; + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.ShutDown; +begin +inherited; +FProcedures.ShutDown +end; + +procedure TCaseBearingFixtureFactory.TCaseBearingFixture.Teardown( Platter: TObject); +begin +if assigned( FTeardownMeth) then + FTeardownMeth.Invoke( Platter, []) +end; + +function TCaseBearingFixtureFactory.TCaseBearingFixture.TestProcedures: ISEnumerable; +begin +result := FProcedures +end; + +function TFixtureList.AddLeafFixture( + const Factory: ITestNodeFactory; const FixtureName: string; FixtureType: TRttiType): ITestFixtureInternal; +begin +result := Factory.MakeNode( FixtureName, nil, FixtureType, nil) as ITestFixtureInternal; +Add( result as ITestFixture) +end; + +function TFixtureList.FindOrAddNamespaceFixture( + const NodeName: string; const NSFactory: ITestNodeFactory): ITestFixtureInternal; +var + Run: ITestFixture; +begin +result := nil; +for Run in (self as IFixturesInternal) do + if (Run.Name = NodeName) and Run.isNamespaceFixture then + begin + result := Run as ITestFixtureInternal; + break + end; +if assigned( result) then exit; +result := NSFactory.MakeNode( NodeName, nil, nil, nil) as ITestFixtureInternal; +// result := TNamespaceFactory.TNamespaceFixture.CreateNamespaceFixture( ParentName, FixtureParentAsObject); +Add( result as ITestFixture) +end; + + +procedure TFixtureList.ShutDown; +var + Child: ITestFixture; + Shut: IShutDown; +begin +for Child in (self as IFixturesInternal) do + if Supports( Child, IShutDown, Shut) then + Shut.ShutDown +end; + + + + + + + + + + + +function TSuiteFactory.TTestSuite.Description: string; +begin +result := '' +end; + +function TSuiteFactory.TTestSuite.Fixtures: ISEnumerable; +begin +result := FixtureChildren +end; + +function TSuiteFactory.TTestSuite.Name: string; +begin +result := '' +end; + +function TSuiteFactory.TTestSuite.NodeKind: TResultNodeKind; +begin +result := rnRoot +end; + +function TSuiteFactory.TTestSuite.Parent: ITestFixture; +begin +result := nil +end; + + +type +TRunInstanceServices = class( TInterfacedObject, IRunInstanceServices) + private + FExecServices: IRunnerExecutiveServices; + procedure StatusChange( const Source: IRunInstance; const Changee: ITestNode; const Round: integer); + procedure Put( const Source: IRunInstance; const Node: ITestNode; const Msg: RMessage; const Round: integer); + function IsAborted: boolean; + public + constructor Create( const ExecServices1: IRunnerExecutiveServices); + end; + +function TSuiteFactory.TTestSuite.ProvideRunInstanceServices( + const ExecServices: IRunnerExecutiveServices): IRunInstanceServices; +begin +result := TRunInstanceServices.Create( ExecServices) +end; + + +procedure TSuiteFactory.TTestSuite.RegisterFixture( FixtureType: TRttiType); +var + FA: TestFixtureAttribute; + Path, sParticle, sParent: string; + FixtureList: IFixturesInternal; + Fixture: ITestFixtureInternal; + FixtureParentAsObject: TReflector; +begin +if TAttributes.GetFirst( FixtureType, FA) then + Path := FA.FPathedName + else + Path := FixtureType.UnitName + '.' + FixtureType.Name; +sParent := ''; +FixtureParentAsObject := nil; +FixtureList := FChildren; +for sParticle in Split( Path, '.') do + begin + if sParent <> '' then + begin + FNSFactory.ParentAsObject := FixtureParentAsObject; + Fixture := FixtureList.FindOrAddNamespaceFixture( sParent, FNSFactory); + FixtureList := Fixture.FixtureChildren as IFixturesInternal; + FixtureParentAsObject := Fixture.AsObject + end; + sParent := sParticle + end; +if sParticle <> '' then + begin + FLeafFactory.ParentAsObject := FixtureParentAsObject; + FixtureList.AddLeafFixture( FLeafFactory, sParticle, FixtureType) + end +end; + + +function TSuiteFactory.TTestSuite.Run( + const ExecServices: IRunnerExecutiveServices): ITestResult; +var + Instance: IRunInstance; +begin +ExecServices.EnterLeaveRunners( +1); +Instance := CreateRunInstance( ExecServices); +ExecServices.OnBeginRunInstance( Instance, Load); +try + Instance.Run( ProvideRunInstanceServices( ExecServices), nil) +finally + result := Instance as ITestResult; + ExecServices.OnEndRunInstance( Instance, result); + ExecServices.EnterLeaveRunners( -1) + end +end; + + +function TSuiteFactory.TTestSuite.CreateRunInstance( + const ExecServices: IRunnerExecutiveServices): IRunInstance; +var + Provider: IServiceProvider; + Mem: IMemoryMonitor; +begin +Provider := StandardServiceProvider; +DUnitM.MemoryMonitor.Solution.RegisterServices( Provider); +Provider.Gn.Acquire( self, Mem); +result := TSuite_RunInstance2.Create( self, Mem) +end; + + + +constructor TRunInstanceServices.Create( + const ExecServices1: IRunnerExecutiveServices); +begin +FExecServices := ExecServices1 +end; + +function TRunInstanceServices.IsAborted: boolean; +begin +result := assigned( FExecServices) and FExecServices.IsAborted +end; + +procedure TRunInstanceServices.Put( + const Source: IRunInstance; const Node: ITestNode; + const Msg: RMessage; const Round: integer); +begin +if assigned( FExecServices) then + FExecServices.OnAuxilaryMessage( Node, Source, Source.TestCase, Msg, Round) +end; + + +procedure TRunInstanceServices.StatusChange( + const Source: IRunInstance; const Changee: ITestNode; const Round: integer); +var + Fixture : ITestFixture; + TestProc: ITestProcedure; + TestCase: ITestCase; + LoggerNodeKind: TLoggerNode; + EngineNodeKind: TResultNodeKind; + s: string; +begin +try +s := '1'; +EngineNodeKind := Changee.NodeKind; +s := '2'; +if not (EngineNodeKind in [rnNamespaceFixture .. rnTestCaseRound]) then exit; +s := '3'; +case EngineNodeKind of + rnNamespaceFixture, + rnLeafFixture : begin +s := '4'; + LoggerNodeKind := nFixture; + Fixture := Changee as ITestFixture; + TestProc := nil; + TestCase := nil +;s := '5'; + end; + + rnTestProc : begin +;s := '6'; + LoggerNodeKind := nTestProc; + TestProc := Changee as ITestProcedure; + Fixture := TestProc.Parent; + TestCase := nil +;s := '7'; + end; + + rnTestCase, + rnTestCaseRound : begin +;s := '8'; + LoggerNodeKind := nTestCase; + TestCase := Changee as ITestCase; + TestProc := TestCase.Parent; + Fixture := TestProc.Parent +;s := '9'; + end + else LoggerNodeKind := nFixture + end; +s := '10'; +FExecServices.OnChangeStatus( LoggerNodeKind, Fixture, TestProc, TestCase, Source) +;s := '111'; +except + s := s + 'F' +end; +end; + + +constructor TFixture_RunInstance2.Create( + ParentAsObject: TReflector; + const Fixture1: ITestFixtureInternal; const Mem1: IMemoryMonitor); +var + Child: ITestNode; + Node: ITestNode; + Addend: IRunInstance; + FixChild: IFixtureChild; +begin +FFixture := Fixture1; +inherited Create( ParentAsObject, Mem1); +if Supports( FFixture, ITestNode, Node) then + for Child in Node.NodeChildren do + if Supports( Child, IFixtureChild, FixChild) and + FixChild.MakeRunInstanceOfFixtureChild( self, Addend) and + assigned( Addend) then + FChildren.Add( Addend) +end; + +procedure TFixture_RunInstance2.DoInnerRun; +var + Child: IRunInstance; +begin +for Child in FChildren do + begin + Child.Run( FRunInstanceServices, + procedure( Value: TTestStatus) + begin + if Value in [tsSetup, tsTeardown, tsExecuting] then + Status := Value + end); + if FStatus = tsError then break + end; +if ErrorCount > 0 then + Status := tsError +else if FailCount > 0 then + Status := tsFail +else if WarnCount > 0 then + Status := tsWarn +else if PassCount > 0 then + Status := tsPass +else + Status := tsSkipped +end; + +function TFixture_RunInstance2.Fixture: ITestFixture; +begin +result := FFixture as ITestFixture +end; + +function TFixture_RunInstance2.MakeFixtureRunInstance( + const Fixture: ITestFixture): IRunInstance; +begin +result := (Fixture as ITestFixtureInternal).MakeRunInstance( FWeakClients, FMem) +end; + +function TFixture_RunInstance2.MakeProcedureRunInstance( + const TestProc: ITestProcedure): IRunInstance; +begin +result := nil +end; + +function TFixture_RunInstance2.NodeKind: TResultNodeKind; +begin +result := rnNamespaceFixture +end; + +function TFixture_RunInstance2.RoundsPerTestCase: integer; +begin +result := 1 +end; + +function TFixture_RunInstance2.TestNode: ITestNode; +begin +result := FFixture as ITestNode +end; + + +procedure TCaseBearingFixture_RunInstance2.DoInnerRun; +var + PlatterFactory: IPlatterFactory; + Hold: IInterface; + FixNode: ITestNode; +begin +if Supports( FFixture, ITestNode, FixNode) and + FixNode.HasEnabledTestCases and + Supports( FFixture, IPlatterFactory, PlatterFactory) and + assigned( PlatterFactory) then + FTestBed := PlatterFactory.CreatePlatter( Hold) + else + FTestBed := nil; +try + inherited DoInnerRun +finally + if assigned( PlatterFactory) then + PlatterFactory.ReleasePlatter( Hold, FTestBed) + end; +end; + +function TCaseBearingFixture_RunInstance2.MakeProcedureRunInstance( + const TestProc: ITestProcedure): IRunInstance; +begin +result := (TestProc as ITestProcedureInternal).MakeRunInstance( + FWeakClients, + function: TObject + begin + result := FTestBed + end, + FMem) +end; + +function TCaseBearingFixture_RunInstance2.NodeKind: TResultNodeKind; +begin +result := rnLeafFixture +end; + + +constructor TSuite_RunInstance2.Create( + const Suite1: ITestSuiteInternal; const Mem1: IMemoryMonitor); +begin +inherited Create( nil, Suite1 as ITestFixtureInternal, Mem1) +end; + +function TSuite_RunInstance2.NodeKind: TResultNodeKind; +begin +result := rnRoot +end; + + +function TSuiteFactory.MakeNode( + const NodeName: string; Method: TRttiMethod; + FixtureType: TRttiType; TestCaseAttri: TDUnitXAttributeBase): ITestNode; +var + AddendObj: TTestSuite; +begin +AddendObj := TTestSuite.CreateNamespaceFixture( nil); +AddendObj.FLeafFactory := FLeafFactory; +AddendObj.FNSFactory := FNSFactory; +result := AddendObj +end; + +constructor TSuiteFactory.ServiceModeCreate; +begin +end; + +{ TCaseBearingFixtureFactory } + +function TCaseBearingFixtureFactory.MakeNode( + const NodeName: string; + Method: TRttiMethod; FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase): ITestNode; +var + Addend: TCaseBearingFixture; + Desc: DescriptionAttribute; + Meth: TRttiMethod; + DataMember: TRttiField; + Skips: integer; +begin +Addend := TCaseBearingFixture.CreateNamespaceFixture( FParentAsObject); +result := Addend as ITestNode; +// result := TCaseBearingFixture.CreateFixture( FixtureName=NodeName, Parent1=FParentAsObject, FixtureType) +Addend.FFixtureClass := FixtureType; +Addend.FName := NodeName; +Addend.FDescription := ''; +Addend.FProcedures := TProcedureList.Create; +FProcFactory.ParentAsObject := Addend.FWeakClients; + +// Fixtures can have [Description]s. If more than one, they are concatinated. +for Desc in TAttributes.Get( FixtureType) do + begin + if Addend.FDescription <> '' then + Addend.FDescription := Addend.FDescription + #13#10; + Addend.FDescription := Addend.FDescription + Desc.FText + end; +Addend.FSetupMeth := nil; +Addend.FTeardownMeth := nil; +Addend.FFixtureSetupMeth := nil; +for Meth in FixtureType.GetDeclaredMethods do + begin + // [Setup] procedure MySetup; + if (not assigned( Addend.FSetupMeth)) and TAttributes.Has( Meth) then + Addend.FSetupMeth := Meth; + + // [Teardown] procedure MyTearDown; + if (not assigned( Addend.FTeardownMeth)) and TAttributes.Has( Meth) then + Addend.FTeardownMeth := Meth; + + // [FixtureSetup] constructor MyCreate; + if (not assigned( Addend.FFixtureSetupMeth)) and TAttributes.Has( Meth) then + Addend.FFixtureSetupMeth := Meth + end; + +// Pick defaults, when we couldn't find an attribute. +for Meth in FixtureType.GetDeclaredMethods do + begin + // published procedure Setup; + if (not assigned( Addend.FSetupMeth)) and (Meth.Visibility = TypInfo.mvPublished) and + SameText( Meth.Name, 'Setup') and (Meth.MethodKind = mkProcedure) and + (Length( Meth.GetParameters) = 0) then + Addend.FSetupMeth := Meth; + + // published procedure Teardown; + if (not assigned( Addend.FTeardownMeth)) and (Meth.Visibility = TypInfo.mvPublished) and + SameText( Meth.Name, 'Teardown') and (Meth.MethodKind = mkProcedure) and + (Length( Meth.GetParameters) = 0) then + Addend.FTeardownMeth := Meth; + + // published constructor AnyName; + if (not assigned( Addend.FFixtureSetupMeth)) and (Meth.Visibility = TypInfo.mvPublished) and + (Meth.MethodKind = mkConstructor) and + (Length( Meth.GetParameters) = 0) then + Addend.FFixtureSetupMeth := Meth + end; + +Addend.FAssertDataMembers := TList2.Create; +for DataMember in FixtureType.GetFields do + begin + // FMyAssert: IAssert; + if (DataMember.FieldType.TypeKind = tkInterface) and + (DataMember.FieldType is TRttiInterfaceType) and + IsEqualGUID( TRttiInterfaceType( DataMember.FieldType).GUID, IAssert) then + Addend.FAssertDataMembers.Add( DataMember) + end; +Skips := 0; +for Meth in FixtureType.GetDeclaredMethods do + begin + if Skips > 0 then + Dec( Skips) + else if TAttributes.Has( Meth) or + TAttributes.Has( Meth) or + TAttributes.Has( Meth) then + Skips := (Addend.FProcedures.AddProcedure( FProcFactory, Meth, FixtureType) + as ITestProcedureInternal).DeclaredMethodSkips + end; +if Addend.FProcedures.GetCount = 0 then + raise Exception.Create( 'Test fixture has no valid test procedures.'); +Addend.ComputeAndCacheLoads +end; + +constructor TCaseBearingFixtureFactory.ServiceModeCreate; +begin +end; + +{ TNamespaceFactory } + +function TNamespaceFactory.MakeNode( const NodeName: string; Method: TRttiMethod; + FixtureType: TRttiType; TestCaseAttri: TDUnitXAttributeBase): ITestNode; +var + AddendObj: TNamespaceFixture; +begin +AddendObj := TNamespaceFixture.CreateNamespaceFixture( FParentAsObject); +AddendObj.FName := NodeName; +AddendObj.FDescription := ''; +result := AddendObj +end; + + +constructor TNamespaceFactory.ServiceModeCreate; +begin +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.GeneralCommandLine.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.GeneralCommandLine.pas new file mode 100644 index 0000000..3ad7569 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.GeneralCommandLine.pas @@ -0,0 +1,7 @@ +unit DUnitM.GeneralCommandLine; + +interface + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.Solution.pas new file mode 100644 index 0000000..1fa1eb3 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.Solution.pas @@ -0,0 +1,171 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.MemoryMonitor.Solution; +interface +uses DUnitM.MemoryMonitor, SBD.ServiceProvider, Classes; + +type +TMemoryMonitor = class( TInterfacedObject, IMemoryMonitor) + private + FMS1, FMS2: TMemoryManagerState; + FLeakageOffset: int64; + FIsMonitoring: boolean; + procedure Clear; + procedure HeapMonitoring_ON; + procedure HeapMonitoring_OFF; + function Leakage: int64; + public + constructor Create; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); +// Provides: +// GUID config ArrayId Mode +// ---------------------------------------------------------------------------------- +// IMemoryMonitor '' 'System.TMemoryManagerState' Competitive +// +// Requires: +// GUID config ArrayId Mode +// ---------------------------------------------------------------------------------- +// None + + +implementation + + + + + + + + +uses SysUtils; + + + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterFlyweightService( IMemoryMonitor, + function( const Config: string; const ServiceProvider: IServiceProvider): IInterface + begin + result := TMemoryMonitor.Create as IMemoryMonitor + end, + '', 'System.TMemoryManagerState') +end; + + +constructor TMemoryMonitor.Create; +begin +Clear +end; + +procedure TMemoryMonitor.Clear; +begin +FIsMonitoring := False; +FLeakageOffset := 0 +end; + + +procedure TMemoryMonitor.HeapMonitoring_OFF; +var + i: Integer; + SMBSize1, SMBSize2: uint64; +begin +if not FIsMonitoring then exit; +SMBSize1 := 0; +SMBSize2 := 0; +GetMemoryManagerState( FMS2); +for i := 0 to NumSmallBlockTypes - 1 do // Iterate through the blocks + begin + with FMS1.SmallBlockTypeStates[i] do + Inc( SMBSize1, (InternalBlockSize * AllocatedBlockCount)); + with FMS2.SmallBlockTypeStates[i] do + Inc( SMBSize2, (InternalBlockSize * AllocatedBlockCount)) + end; +FLeakageOffset := FLeakageOffset + + int64( SMBSize2) - int64( SMBSize1) + + (int64( FMS2.TotalAllocatedMediumBlockSize) - int64( FMS1.TotalAllocatedMediumBlockSize)) + + (int64( FMS2.TotalAllocatedLargeBlockSize ) - int64( FMS1.TotalAllocatedLargeBlockSize )); +FIsMonitoring := False +end; + +procedure TMemoryMonitor.HeapMonitoring_ON; +begin +if FIsMonitoring then exit; +GetMemoryManagerState( FMS1); +FIsMonitoring := True +end; + +function TMemoryMonitor.Leakage: int64; +begin +result := FLeakageOffset +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.pas new file mode 100644 index 0000000..0ec817e --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.MemoryMonitor.pas @@ -0,0 +1,83 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.MemoryMonitor; +interface + +type +IMemoryMonitor = interface + ['{1A8B725F-7C5E-4D31-B801-0EBEDAFFF69C}'] + procedure Clear; + procedure HeapMonitoring_ON; + procedure HeapMonitoring_OFF; + function Leakage: int64; + end; + + // TMemoryManagerState + // FastMMMemLeakMonitor + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.Logger.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.Logger.Solution.pas new file mode 100644 index 0000000..8a8d898 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.Logger.Solution.pas @@ -0,0 +1,341 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.NUnit.Logger.Solution; +interface +uses DUnitM.UnitTestFramework, SBD.ServiceProvider, DUnitM.NUnit, SBD.Messages; + +type +TNUnit25_Logger = class( TInterfacedObject, ITestLogger) + private + [Injection('NUnit2.5')] FFilenameSource: IFilenameSource; + [Injection] FNUnit25DomainLogger: INUnit25_ResultsLog; + FDescription: string; + FFilename: string; + + function MenuDescription: string; + procedure OnEnableChange( const Eng: IUnitTestingEngine; const Proc: ITestProcedure; const Datum: IInterface); + procedure OnBeginRunInstance( Workload: integer); + procedure OnEndRunInstance( const RunResult: ITestResult); + procedure OnChangeStatus( + NodeKind: TLoggerNode; + const Fixture: ITestFixture; + const TestProc: ITestProcedure; + const TestCase: ITestCase; + const TestResult: ITestResult; + const NodeDatum: IInterface); + procedure OnProgressTick( const GrossResult: ITestResult; WorkDone, WorkLoad: integer); + procedure Breathe; + procedure OnAuxilaryMessage( const TestResult: ITestResult; const TestCase: ITestCase; const Msg: RMessage; const NodeDatum: IInterface); + procedure Shutdown( const Eng: IUnitTestingEngine); + procedure OnAttachSuite( Suite: ITestSuite; + SetFixtureDatum: TSetFixtureDatumFunc; + SetTestProcDatum: TSetTestProcDatumFunc; + SetTestCaseDatum: TSetTestCaseDatumFunc); + public + [Configuration('NUnit2.5')] constructor ServiceModeCreate; + end; + +TLoggerFactory = class( TInterfacedObject, ILoggerFactory, IFilenameSource) + private + [Injection] FLoggerProvider: IServiceProvider; + FParams: IInterface; + function MenuDescription: string; + function CreateLogger( const Params: IInterface): ITestLogger; + function FileName: string; + public + [Configuration('NUnit2.5')] constructor ServiceModeCreate; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + + + + + +uses IOUtils, SysUtils, Classes, SBD.Generics; + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( ITestLogger, TNUnit25_Logger); +Provider.RegisterServiceClass( ILoggerFactory, TLoggerFactory); +end; + + +procedure TNUnit25_Logger.Breathe; +begin +end; + +function TNUnit25_Logger.MenuDescription: string; +begin +result := FDescription +end; + +procedure TNUnit25_Logger.OnAttachSuite(Suite: ITestSuite; + SetFixtureDatum: TSetFixtureDatumFunc; + SetTestProcDatum: TSetTestProcDatumFunc; + SetTestCaseDatum: TSetTestCaseDatumFunc); +begin +end; + +procedure TNUnit25_Logger.OnAuxilaryMessage( + const TestResult: ITestResult; const TestCase: ITestCase; const Msg: RMessage; const NodeDatum: IInterface); +begin +end; + +procedure TNUnit25_Logger.OnBeginRunInstance( Workload: integer); +begin +end; + +procedure TNUnit25_Logger.OnChangeStatus( + NodeKind: TLoggerNode; + const Fixture: ITestFixture; const TestProc: ITestProcedure; + const TestCase: ITestCase; const TestResult: ITestResult; + const NodeDatum: IInterface); +begin +end; + +procedure TNUnit25_Logger.OnEnableChange( + const Eng: IUnitTestingEngine; const Proc: ITestProcedure; const Datum: IInterface); +begin +end; + +procedure TNUnit25_Logger.OnEndRunInstance( const RunResult: ITestResult); +var + Source: TStream; + NUnit25, RootLevel_NUnit25: INUnit25_TestSuite; + Total, Errored, NotRun, Ignored, Skipped: integer; + GrossDuration: double; + NUnitRunResult: TNUnitResult; + SourceIsTransferred: boolean; + + procedure ParseResults( var ParentSuite: INUnit25_TestSuite; const Results: ISEnumerable; doCloseResults: boolean); + const + ElementPathTail = '/test-suite/results'; + var + NUnitRunResult: TNUnitResult; + TestResult: ITestResult; + Suite: INUnit25_TestSuite; + Duration: double; + Reason: string; + Msg: RMessage; + + begin + // Upon entry to this routine, we assume that we are at an open + // and below that an open element. + // The task here is to add the content for the collection of ITestResult's ('Results'), + // and then close the element and the element. + // For fixtures, the content is a test-suite element. + // For test cases, the content is a test-case element. + // Test procedures are not directly represented, as this concept is not supported by N-Unit. + NUnitRunResult := rInconclusive; + for TestResult in Results do + begin + Suite := nil; + Duration := TestResult.Timing.FDuration_ms / (1000 * SecsPerDay); + case TestResult.Status of + tsError, tsSetup, tsTeardown, tsExecuting: NUnitRunResult := rError; + tsNeutral, tsSkipped: NUnitRunResult := rIgnored; + tsPass, tsWarn: NUnitRunResult := rSuccess; + tsFail: NUnitRunResult := rFailure; + end; + if TestResult.ErrorOrFailureMsg( Msg) then + Reason := Msg.FDisplayText + else + Reason := ''; + case TestResult.NodeKind of + rnNamespaceFixture: + // Add a element, and then below that + // another element. + Suite := ParentSuite.AddNamespaceSuite( + TestResult.Fixture.Name, TestResult.Executed, NUnitRunResult, + Duration, 0); + + rnLeafFixture: + // Add a element, and then below that + // another element. + Suite := ParentSuite.AddFixtureSuite( + TestResult.Fixture.Name, TestResult.Fixture.Description, + TestResult.Executed, NUnitRunResult, Duration, 0, Reason); + + rnTestProc: + begin + // Ignore the procedure level. Drill down to the test cases. + Suite := nil; + ParseResults( ParentSuite, TestResult.ChildResults, False) + end; + + rnTestCase: + begin + Suite := nil; + ParentSuite.AddTestCase( + TestResult.TestCase.DisplayName, TestResult.TestCase.Parent.Description, + TestResult.Executed, NUnitRunResult, Duration, 0, Reason) + // Ignore the test case round level. All rounds are summarised and rolled up + // into TestCase results. + end + end; + if assigned( Suite) then + // If suite exists then we have an open element to close off, + // as a consequence of our response to the TestResult child + ParseResults( Suite, TestResult.ChildResults, True) + end; + if doCloseResults and assigned( ParentSuite) then + ParentSuite := ParentSuite.Close // < closes the results,test-suites elements. + end; + +begin +SourceIsTransferred := False; +Source := TFile.Open( FFilename, IOUtils.TFileMode.fmOpenOrCreate); +try + Source.Size := 0; + Errored := RunResult.ErrorCount; + Total := RunResult.PassCount + RunResult.FailCount + RunResult.WarnCount; + NotRun := 0; // To be developed + Ignored := 0; // To be developed + Skipped := 0; // To be developed + if Errored > 0 then + NUnitRunResult := rError + else if RunResult.FailCount > 0 then + NUnitRunResult := rFailure + else if (RunResult.PassCount + RunResult.WarnCount) > 0 then + NUnitRunResult := rSuccess + else + NUnitRunResult := rIgnored; + GrossDuration := RunResult.Timing.FDuration_ms / (1000 * SecsPerDay); + SourceIsTransferred := True; + NUnit25 := FNUnit25DomainLogger.OpenLog( Source, ParamStr( 0), RunResult.Timing.FStart, + Total, RunResult.FailCount, Errored, NotRun, Ignored, Skipped, NUnitRunResult, GrossDuration); + RootLevel_NUnit25 := NUnit25; + ParseResults( NUnit25, RunResult.ChildResults, True); + RootLevel_NUnit25.CloseTestResults +finally + FNUnit25DomainLogger.CloseLog; + if not SourceIsTransferred then + Source.Free + end +end; + +procedure TNUnit25_Logger.OnProgressTick( + const GrossResult: ITestResult; WorkDone, WorkLoad: integer); +begin +end; + +constructor TNUnit25_Logger.ServiceModeCreate; +begin +if assigned( FFilenameSource) then + begin + FFilename := FFilenameSource.FileName; + FFilenameSource := nil + end + else + FFilename := ''; +if FFilename = '' then + FFilename := TPath.ChangeExtension( ParamStr( 0), '.log'); +FDescription := Format( 'NUnit 2.5 log at %s', [TPath.GetFileName( FFilename)]) +end; + +procedure TNUnit25_Logger.Shutdown( const Eng: IUnitTestingEngine); +begin +end; + +{ TLoggerFactory } + +function TLoggerFactory.CreateLogger( const Params: IInterface): ITestLogger; +var + InjectionOverride: IServiceProvider; +begin +FParams := Params; +InjectionOverride := StandardServiceProvider; +InjectionOverride.RegisterLiveService( IFileNameSource, self as IFileNameSource, 'NUnit2.5'); +FLoggerProvider.Gn.Acquire( nil, result, 'NUnit2.5', InjectionOverride); +InjectionOverride.ShutDown; +FParams := nil +end; + +function TLoggerFactory.FileName: string; +var + FNParam: IFilenameFactoryParameter; +begin +if Supports( FParams, IFilenameFactoryParameter, FNParam) then + result := FNParam.FileName + else + result := '' +end; + +function TLoggerFactory.MenuDescription: string; +begin +result := 'NUnit v2.5' +end; + +constructor TLoggerFactory.ServiceModeCreate; +begin +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.LoggerUI.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.LoggerUI.Solution.pas new file mode 100644 index 0000000..35159af --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.LoggerUI.Solution.pas @@ -0,0 +1,163 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.NUnit.LoggerUI.Solution; +interface +uses DUnitM.UnitTestFramework, SBD.ServiceProvider; + +type +TLoggerFactoryUI = class( TInterfacedObject, ILoggerFactoryUI) + private + [Injection('NUnit2.5')] FFactory: ILoggerFactory; + function Factory: ILoggerFactory; + function EnquireForCreateLogger( out Params: IInterface): boolean; + procedure ViewEditProperties( const Logger: ITestLogger; Params: IInterface); + public + [Configuration] constructor ServiceModeCreate; + end; + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + + + + + + +uses SysUtils, Dialogs, IOUtils; + +type +TFilenameFactoryParameter = class( TInterfacedObject, IFilenameFactoryParameter) + private + FFileName: string; + function FileName: string; + procedure SetFileName( const Value: string); + function isValidFilename( const Value: string): boolean; + end; + + + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( ILoggerFactoryUI, TLoggerFactoryUI) +end; + +function TLoggerFactoryUI.EnquireForCreateLogger( + out Params: IInterface): boolean; +var + FNParam: IFilenameFactoryParameter; + AFileName: string; +begin +AFileName := 'NUnit25.log'; +result := Dialogs.PromptForFileName( AFileName, 'NUnit log filename?', '.log', 'Title', '', True); +if not result then exit; +AFileName := TPath.GetFullPath( AFileName); +FNParam := TFilenameFactoryParameter.Create; +FNParam.SetFileName( AFileName); +Params := FNParam; +result := FNParam.isValidFilename( AFileName) +end; + +function TLoggerFactoryUI.Factory: ILoggerFactory; +begin +result := FFactory +end; + +constructor TLoggerFactoryUI.ServiceModeCreate; +begin +end; + +procedure TLoggerFactoryUI.ViewEditProperties( + const Logger: ITestLogger; Params: IInterface); +var + FNParam: IFilenameFactoryParameter; + FN: string; +begin +if Supports( Params, IFilenameFactoryParameter, FNParam) then + FN := FNParam.FileName; +Dialogs.ShowMessageFmt( 'DUnit 2.5 log file is %s', [FN]) +end; + + +function TFilenameFactoryParameter.FileName: string; +begin +result := FFileName +end; + +function TFilenameFactoryParameter.isValidFilename( + const Value: string): boolean; +begin +result := True +end; + +procedure TFilenameFactoryParameter.SetFileName( const Value: string); +begin +FFileName := Value +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.pas new file mode 100644 index 0000000..896ec10 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit.pas @@ -0,0 +1,127 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.NUnit; +interface +uses Classes; + +type +TNUnitResult = (rFailure, rSuccess, rIgnored, rError, rInconclusive, rNotRunnable); +INUnit25_TestSuite = interface + ['{B9400675-292A-4646-A890-2246C2CD4060}'] + function AddNamespaceSuite( + const Name: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer): INUnit25_TestSuite; + + function AddFixtureSuite( + const Name, Description: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; + + procedure AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string); + + function Close: INUnit25_TestSuite; + procedure CloseTestResults; + function ElementStack: string; + end; + +type +INUnit25_ResultsLog = interface + ['{3C975A4D-F0A4-4AF2-9DF0-BD6407325F99}'] +{$REGION 'HelpInsight'} +/// +/// OpenLog() clears the stream and writes like ... +/// +/// <test-results name="etc" > +/// <environment nunit-version="2.5.8.0" /> +/// <culture-info current-culture="en" current-uiculture="en" /> +/// <test-suite name="etc.exe" executed="true" result="Success" success="true" time="0.000" asserts="0" type="Assembly" > +/// <results +/// +/// +{$ENDREGION} + function OpenLog( OutStream1: TStream; + const ProgName: string; + RunStamp: TDateTime; + Total, Failed, Errored, NotRun, Ignored, Skipped: integer; + RunResult: TNUnitResult; + GrossDuration: double) // units of days. + : INUnit25_TestSuite; + +{$REGION 'HelpInsight'} +/// +/// CloseLog() closes the stream and assumes that all open elements have been closed. +/// +{$ENDREGION} + procedure CloseLog; + end; + + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit25.ResultsLog.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit25.ResultsLog.Solution.pas new file mode 100644 index 0000000..28d95a7 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.NUnit25.ResultsLog.Solution.pas @@ -0,0 +1,655 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.NUnit25.ResultsLog.Solution; +interface +uses Classes, DUnitM.NUnit, DUnitM.XMLWriter, SBD.ServiceProvider; +type + +TNUnit25_ResultsLog = class( TInterfacedObject, INUnit25_ResultsLog) + private + [Injection('UTF-8')] FXMLWriter: IXMLWriter; +{$REGION 'HelpInsight'} +/// +/// OpenLog() clears the stream and writes like ... +/// +/// <test-results name="etc" > +/// <environment nunit-version="2.5.8.0" /> +/// <culture-info current-culture="en" current-uiculture="en" /> +/// <test-suite name="etc.exe" executed="true" result="Success" success="true" time="0.000" asserts="0" type="Assembly" > +/// <results +/// +/// +{$ENDREGION} + function OpenLog( OutStream1: TStream; + const ProgName: string; + RunStamp: TDateTime; + Total, Failed, Errored, NotRun, Ignored, Skipped: integer; + RunResult: TNUnitResult; + GrossDuration: double) + : INUnit25_TestSuite; // units of days. +{$REGION 'HelpInsight'} +/// +/// CloseLog() closes the stream and assumes that all open elements have been closed. +/// +{$ENDREGION} + procedure CloseLog; + + private + FDoc: IXMLWriter_Document; + + public + [Configuration] constructor ServiceModeCreate; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + + + + + + + + + + + + +uses SysUtils, SBD.Utils.XML2; + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( INUnit25_ResultsLog, TNUnit25_ResultsLog) +end; + + +type +TTestSuite = class abstract( TInterfacedObject, INUnit25_TestSuite) + protected + FParent: INUnit25_TestSuite; + FElement: IXMLWriter_Element; + FRoot: IXMLWriter_Element; + + procedure AddAttribute( const Name, Value: string); overload; + procedure AddAttribute( const Name: string; Value: integer); overload; + procedure AddAttribute( const Name: string; Value: boolean); overload; + procedure AddAttribute( const Name: string; DurationValue: double); overload; + procedure AddAttribute( const Name: string; Value: TNUnitResult); overload; + procedure AddSuccessAttribute( Value: TNUnitResult); + procedure AddOptionalAttribute( const Name, Value: string); + procedure PushElement( const ElementName: string); + procedure PopElement; + procedure AddTextedElement( const ElementName, Content: string); + procedure AddMessage( const Content: string); + procedure CloseTestResults; + function ElementStack: string; + +{$REGION 'HelpInsight'} +/// +/// See the TGroup override. Not valid for TestCase +/// +{$ENDREGION} + function AddNamespaceSuite( + const Name: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer): INUnit25_TestSuite; virtual; abstract; + +{$REGION 'HelpInsight'} +/// +/// See the TGroup override. Not valid for TestCase +/// +{$ENDREGION} + function AddFixtureSuite( + const Name, Description: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; virtual; abstract; + + procedure AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string); virtual; abstract; + + function Close: INUnit25_TestSuite; virtual; abstract; + + procedure PushTestElement( + const ElementName, Name, Description: string; Executed: boolean; + RunResult: TNUnitResult; Duration: double; Asserts: integer); + + public + constructor Create( const Parent1: INUnit25_TestSuite; const ParentElement1: IXMLWriter_Element); + end; + +type +TGroup = class ( TTestSuite) + protected +{$REGION 'HelpInsight'} +/// +/// AddNamespaceSuite() at the TGroup/TFixture level writes like ... +/// +/// <test-suite name="NewTests" executed="false" result="Success" success="true" time="0.000" asserts="0" type="Namespace" > +/// <results +/// +/// where "NewTests" comes from the 'Name' parameter value. Notice that the 'type' attribute value is 'Namespace'. +/// +{$ENDREGION} + function AddNamespaceSuite( + const Name: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer): INUnit25_TestSuite; override; + +{$REGION 'HelpInsight'} +/// +/// AddFixtureSuite() at the TGroup/TFixture level writes like ... +/// +/// <test-suite name="Sprint5" description="Banana banana banana" executed="false" result="Success" success="true" time="0.000" asserts="0" type="TestFixture" > +/// <results +/// +/// where "NewTests" comes from the 'Name' parameter value. Notice that the 'type' attribute value is 'TestFixture'. +/// Also optionally, a <reason/> element may be inserted beneath <test-suite/>, at the same level as <results/>. +/// +{$ENDREGION} + function AddFixtureSuite( + const Name, Description: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; override; + + procedure AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string); override; + +{$REGION 'HelpInsight'} +/// +/// Close() closes the TestSuite by writing ... +/// +/// </results> +/// </test-suite> +/// +/// It is assumed that the </test-suite> and </results> are open upon function entry. +/// +{$ENDREGION} + function Close: INUnit25_TestSuite; override; + + public + constructor CreateGeneric( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const TestSuiteType, Name, Description: string; Executed: boolean; + RunResult: TNUnitResult; GrossDuration: Double; Asserts: integer; + const Reason: string); + +{$REGION 'HelpInsight'} +/// +/// CreateAssembly() writes like ... +/// +/// <test-suite name="etc.exe" executed="true" result="Success" success="true" time="0.000" asserts="0" type="Assembly" > +/// <results +/// +/// +{$ENDREGION} + constructor CreateAssembly( + const ParentElement: IXMLWriter_Element; + const ProgName: string; RunResult: TNUnitResult; GrossDuration: Double; + const Root1: IXMLWriter_Element); + + constructor CreateNamespace( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const Name: string; Executed: boolean; + RunResult: TNUnitResult; GrossDuration: Double; Asserts: integer); + end; + +TFixture = class ( TGroup) + protected +{$REGION 'HelpInsight'} +/// +/// AddTestCase() writes like a <test-case/> element... +/// +/// <test-case name="TestOne" description="Banana banana" executed="true" result="Success" success="true" time="0.000" asserts="0" /> +/// +/// Optional sub-elements may include either <failure/>/<stack-trace/> or reason <elements/>. +/// +{$ENDREGION} + procedure AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string); override; + + public + constructor CreateFixture( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const Name, Description: string; Executed: boolean; + RunResult: TNUnitResult; GrossDuration: Double; Asserts: integer; + const Reason: string); + end; + +TTestCase = class ( TTestSuite) + protected + function AddNamespaceSuite( + const Name: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer): INUnit25_TestSuite; override; + + function AddFixtureSuite( + const Name, Description: string; Executed: boolean; NetResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; override; + + procedure AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; + const Reason: string); override; + + function Close: INUnit25_TestSuite; override; + + public + constructor Create( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const Name, Description: string; Executed: boolean; + RunResult: TNUnitResult; GrossDuration: Double; Asserts: integer); + end; + + +function EncodeResult( NUnitResult: TNUnitResult): string; +const + ResultStrings: array[ TNUnitResult] of string = ( + 'Failure', 'Success', 'Ignored', 'Error', 'Inconclusive', 'NotRunnable'); +begin +result := ResultStrings[ NUnitResult] +end; + +function EncodeDuration( Duration: double): string; +begin +result := Format( '%.3f', [Duration]) +end; + + +constructor TNUnit25_ResultsLog.ServiceModeCreate; +begin +end; + +procedure TNUnit25_ResultsLog.CloseLog; +begin +FDoc.Close // Closes the stream +end; + +function TNUnit25_ResultsLog.OpenLog( + OutStream1: TStream; + const ProgName: string; + RunStamp: TDateTime; + Total, Failed, Errored, NotRun, Ignored, Skipped: integer; + RunResult: TNUnitResult; + GrossDuration: double): INUnit25_TestSuite; +var + El: IXMLWriter_Element; + ErrorCount: integer; + FailureCount: integer; + Root: IXMLWriter_Element; + + procedure AddAttribute( const Name, Value: string); overload; + begin + El.AddAttribute( '', Name, Value) + end; + + procedure AddAttribute( const Name: string; Value: integer); overload; + begin + AddAttribute( Name, Txs_integer.Encode( Value)) + end; + +begin +FDoc := FXMLWriter.OpenDocument( OutStream1); +El := FDoc.AddElement( '', 'test-results'); +Root := El; +AddAttribute( 'name', ProgName); +AddAttribute( 'total', Total); +ErrorCount := 0; +FailureCount := 0; +case RunResult of + rFailure: FailureCount := 1; + rError : ErrorCount := 1; + end; +AddAttribute( 'errors', ErrorCount); +AddAttribute( 'failures', FailureCount); +AddAttribute( 'not-run', NotRun); +AddAttribute( 'inconclusive', 0); +AddAttribute( 'ignored', Ignored); +AddAttribute( 'skipped', Skipped); +AddAttribute( 'invalid', 0); +AddAttribute( 'date', Txs_dateTime.EncodeDate( Trunc( RunStamp))); +AddAttribute( 'time', Txs_dateTime.EncodeTime( Frac( RunStamp), False, 0)); +El := El.AddElement( '', 'environment'); +AddAttribute( 'nunit-version','2.5.8.0'); +AddAttribute( 'clr-version','2.0.50727.1433'); +AddAttribute( 'os-version','(to be developed)'); +AddAttribute( 'platform','(to be developed)'); +AddAttribute( 'cwd','(to be developed)'); +AddAttribute( 'machine-name','(to be developed)'); +AddAttribute( 'user','(to be developed)'); +AddAttribute( 'user-domain','(to be developed)'); +El := El.Close as IXMLWriter_Element; +El := El.AddElement( '', 'culture-info'); +AddAttribute( 'current-culture','en'); +AddAttribute( 'current-uiculture','en'); +El := El.Close as IXMLWriter_Element; +result := TGroup.CreateAssembly( El, ProgName, RunResult, GrossDuration, Root) +end; + + +procedure TTestSuite.AddAttribute( const Name, Value: string); +begin +FElement.AddAttribute( '', Name, Value) +end; + +procedure TTestSuite.AddAttribute( const Name: string; Value: boolean); +begin +AddAttribute( Name, Txs_boolean.Encode( Value)) +end; + +procedure TTestSuite.AddAttribute( const Name: string; Value: integer); +begin +AddAttribute( Name, Txs_integer.Encode( Value)) +end; + +procedure TTestSuite.AddAttribute( const Name: string; Value: TNUnitResult); +begin +AddAttribute( Name, EncodeResult( Value)) +end; + +procedure TTestSuite.AddTextedElement( const ElementName, Content: string); +begin +PushElement( ElementName); +FElement.AddTextNode( Content); +PopElement +end; + + +procedure TTestSuite.AddMessage( const Content: string); +begin +AddTextedElement( 'message', Content) +end; + +procedure TTestSuite.AddAttribute( const Name: string; DurationValue: double); +begin +AddAttribute( Name, EncodeDuration( DurationValue)) +end; + +procedure TTestSuite.AddOptionalAttribute( const Name, Value: string); +begin +if Value <> '' then + AddAttribute( Name, Value) +end; + +procedure TTestSuite.AddSuccessAttribute( Value: TNUnitResult); +begin +AddAttribute( 'success', Value = rSuccess) +end; + +procedure TTestSuite.CloseTestResults; +begin +if assigned( FRoot) then + FRoot.Close // closes the test-results element +end; + +constructor TTestSuite.Create( + const Parent1: INUnit25_TestSuite; const ParentElement1: IXMLWriter_Element); +begin +FParent := Parent1; +FElement := ParentElement1 +end; + +function TTestSuite.ElementStack: string; +begin +if assigned( FElement) then + result := FElement.ElementStack + else + result := '' +end; + +procedure TTestSuite.PushElement( const ElementName: string); +begin +FElement := FElement.AddElement( '', ElementName) +end; + +procedure TTestSuite.PushTestElement( + const ElementName, Name, Description: string; + Executed: boolean; RunResult: TNUnitResult; Duration: double; Asserts: integer); +begin +PushElement( ElementName); +AddAttribute( 'name', Name); +AddOptionalAttribute( 'description', Description); // Only valid for 'TestFixture' +AddAttribute( 'executed', Executed); +AddAttribute( 'result', RunResult); +AddSuccessAttribute( RunResult); +AddAttribute( 'time', Duration); +AddAttribute( 'asserts', Asserts) +end; + + + +procedure TTestSuite.PopElement; +begin +if not Supports( FElement.Close, IXMLWriter_Element, FElement) then + FElement := nil +end; + +{ TGroup } + +constructor TGroup.CreateAssembly( + const ParentElement: IXMLWriter_Element; + const ProgName: string; RunResult: TNUnitResult; + GrossDuration: Double; const Root1: IXMLWriter_Element); +begin +CreateGeneric( nil, ParentElement, 'Assembly', ProgName, '', True, RunResult, GrossDuration, 0, ''); +FRoot := Root1 +end; + +constructor TGroup.CreateGeneric( + const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const TestSuiteType, Name, Description: string; Executed: boolean; + RunResult: TNUnitResult; GrossDuration: Double; Asserts: integer; + const Reason: string); +begin +inherited Create( Parent1, ParentElement); +PushTestElement( 'test-suite', Name, Description, Executed, RunResult, GrossDuration, Asserts); +AddAttribute( 'type', TestSuiteType); // Either 'Assembly', 'Namespace' or 'TestFixture' +if Reason <> '' then // Only valid for 'TestFixture' + begin + PushElement( 'reason'); + AddMessage( Reason); + PopElement + end; +PushElement( 'results') +end; + + +constructor TGroup.CreateNamespace( + const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; const Name: string; + Executed: boolean; RunResult: TNUnitResult; GrossDuration: Double; + Asserts: integer); +begin +CreateGeneric( Parent1, ParentElement, 'Namespace', Name, '', Executed, + RunResult, GrossDuration, Asserts, '') +end; + +function TGroup.AddNamespaceSuite( const Name: string; Executed: boolean; + NetResult: TNUnitResult; Time: double; + Asserts: integer): INUnit25_TestSuite; +begin +result := TGroup.CreateNamespace( self, FElement, Name, Executed, NetResult, Time, Asserts) +end; + +function TGroup.AddFixtureSuite( const Name, Description: string; Executed: boolean; + NetResult: TNUnitResult; Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; +begin +result := TFixture.CreateFixture( self, FElement, Name, Description, Executed, NetResult, Time, Asserts, Reason) +end; + +procedure TGroup.AddTestCase( const Name, Description: string; Executed: boolean; + CaseResult: TNUnitResult; Time: double; Asserts: integer; + const Reason: string); +begin +raise Exception.Create( 'Test cases cannot be direct children of Namespace groups.') +end; + +function TGroup.Close: INUnit25_TestSuite; +begin +(FElement.Close as IXMLWriter_Element) // closes +// Now we are at +.Close; // closes +// Now we are at original parent +result := FParent +end; + + + +{ TFixture } + +constructor TFixture.CreateFixture( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const Name, Description: string; Executed: boolean; RunResult: TNUnitResult; + GrossDuration: Double; Asserts: integer; const Reason: string); +begin +inherited CreateGeneric( + Parent1, ParentElement, 'TestFixture', Name, Description, Executed, + RunResult, GrossDuration, Asserts, Reason) +end; + + + + +procedure TFixture.AddTestCase( + const Name, Description: string; Executed: boolean; CaseResult: TNUnitResult; + Time: double; Asserts: integer; const Reason: string); +var + TestCase: INUnit25_TestSuite; +begin +TestCase := TTestCase.Create( self, FElement, Name, Description, Executed, CaseResult, Time, Asserts); +if Reason <> '' then + begin + if CaseResult = rFailure then + begin + PushElement( 'failure'); + AddMessage( Reason); + AddTextedElement( 'stack-trace', 'Not implemented') + end + else + begin + PushElement( 'reason'); + AddMessage( Reason) + end; + PopElement // reason/failure + end; +TestCase.Close +end; + + + + +{ TTestCase } + +constructor TTestCase.Create( const Parent1: INUnit25_TestSuite; + const ParentElement: IXMLWriter_Element; + const Name, Description: string; Executed: boolean; RunResult: TNUnitResult; + GrossDuration: double; Asserts: integer); +begin +// +inherited Create( Parent1, ParentElement); +PushTestElement( 'test-case', Name, Description, Executed, RunResult, GrossDuration, Asserts) +end; + +function TTestCase.Close: INUnit25_TestSuite; +begin +PopElement; // closes +// Now we are at original parent +result := FParent +end; + +function TTestCase.AddFixtureSuite(const Name, Description: string; Executed: boolean; + NetResult: TNUnitResult; Time: double; Asserts: integer; + const Reason: string): INUnit25_TestSuite; +begin +raise Exception.Create( 'Test cases cannot have children.') +end; + +function TTestCase.AddNamespaceSuite(const Name: string; Executed: boolean; + NetResult: TNUnitResult; Time: double; + Asserts: integer): INUnit25_TestSuite; +begin +raise Exception.Create( 'Test cases cannot have children.') +end; + +procedure TTestCase.AddTestCase(const Name, Description: string; Executed: boolean; + CaseResult: TNUnitResult; Time: double; Asserts: integer; + const Reason: string); +begin +raise Exception.Create( 'Test cases cannot have children.') +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.RttiUtils.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.RttiUtils.pas new file mode 100644 index 0000000..c302cf6 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.RttiUtils.pas @@ -0,0 +1,247 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.RttiUtils; +interface +uses Rtti, SBD.Generics, Sysutils; + +type + +TAttributes = class + public + class function Get( Subject: TRttiObject): ISEnumerable; + class function GetFirst( Subject: TRttiObject; out Attri: T): boolean; + class function Has( Subject: TRttiObject): boolean; + end; + +{$REGION 'Internal only'} +type +TAttributesEnumerable = class ( TSEnumerable) + private + FSubject: TRttiObject; + protected + function GetEnumerator: ISEnumerator; override; + public + constructor Create( Subject: TRttiObject); + end; + +type +TAttributesCursor = class( TSEnumerator) + private + FAll: TArray; + FIdx: integer; + protected + function MoveNext: boolean; override; + function GetCurrent: T; override; + public + constructor Create( Enumerable1: TSEnumerable); override; + end; +{$ENDREGION} + + +TCompileInformation = class + public + class function BuiltWithRuntimePackages: boolean; + class function CompilerName: string; + end; + +function NextDeclaredMethod( BaseMethod: TRttiMethod; var Next: TRttiMethod): boolean; + +implementation + + + + + +class function TAttributes.Get( Subject: TRttiObject): ISEnumerable; +begin +result := TAttributesEnumerable.Create( Subject) +end; + +class function TAttributes.GetFirst( Subject: TRttiObject; out Attri: T): boolean; +var + Run: T; +begin +Attri := Default( T); +for Run in Get( Subject) do + begin + Attri := Run; + break + end; +result := assigned( Attri) +end; + + +class function TAttributes.Has( Subject: TRttiObject): boolean; +var + Dummy: T; +begin +result := TAttributes.GetFirst( Subject, Dummy) +end; + +constructor TAttributesEnumerable.Create( Subject: TRttiObject); +begin +FSubject := Subject +end; + + + +function TAttributesEnumerable.GetEnumerator: ISEnumerator; +begin +result := TAttributesCursor.Create( self); +end; + +constructor TAttributesCursor.Create( Enumerable1: TSEnumerable); +begin +inherited Create( Enumerable1); +FAll := (Enumerable1 as TAttributesEnumerable).FSubject.GetAttributes; +FIdx := -1 +end; + +function TAttributesCursor.GetCurrent: T; +begin +result := T( FAll[ FIdx]) +end; + +function TAttributesCursor.MoveNext: boolean; +begin +result := False; +while (not result) and (FIdx < Length( FAll)) do + begin + Inc( FIdx); + result := (FIdx < Length( FAll)) and FAll[ FIdx].InheritsFrom( T) + end +end; + + +class function TCompileInformation.BuiltWithRuntimePackages: boolean; +begin +result := FindClassHInstance( TObject) <> HInstance +end; + +class function TCompileInformation.CompilerName: string; +begin +if CompilerVersion > 28 then + result := 'post XE7' + else if CompilerVersion = 28 then + result := 'XE7' + else if CompilerVersion = 27 then + result := 'XE6' + else if CompilerVersion = 26.5 then + result := 'Appmethod 1.0' + else if CompilerVersion = 26 then + result := 'XE5' + else if CompilerVersion = 25 then + result := 'XE4' + else if CompilerVersion = 24 then + result := 'XE3' + else if CompilerVersion = 23 then + result := 'XE2' + else if CompilerVersion = 22 then + result := 'XE' + else if CompilerVersion = 21 then + result := 'D2010' + else if CompilerVersion = 20 then + result := 'D2009' + else if CompilerVersion = 18.5 then + result := 'D2007' + else if CompilerVersion = 18 then + result := 'D2006' + else if CompilerVersion = 17 then + result := 'D2005' + else if CompilerVersion = 16 then + result := 'D8' + else if CompilerVersion = 15 then + result := 'D7' + else if CompilerVersion = 14 then + result := 'D6' +end; + + +function NextDeclaredMethod( BaseMethod: TRttiMethod; var Next: TRttiMethod): boolean; +var + Meth: TRttiMethod; + Found: boolean; +begin +result := False; +Found := False; +Next := nil; +if assigned( BaseMethod) then + for Meth in BaseMethod.Parent.GetDeclaredMethods do + begin + if (not Found) and (Meth <> BaseMethod) then continue; + if Found then + begin + result := True; + Next := Meth; + break + end + else + Found := True + end +end; + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.RunInstance.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.RunInstance.pas new file mode 100644 index 0000000..60a71cd --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.RunInstance.pas @@ -0,0 +1,453 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.RunInstance; +interface +uses SBD.Messages, DUnitM.UnitTestFramework, SysUtils, DUnitM.MemoryMonitor, + SBD.Generics, DUnitM.TestNode; + +type + +TTestNode_RunInstance = class( TInterfacedObject, IRunInstance, ITestResult) + protected + FStatus: TTestStatus; + FTiming: RTimingStats; + FExecuted: boolean; + FRunInstanceServices: IRunInstanceServices; + FStatusInformerProc: TStatusInformerProc; + FMem: IMemoryMonitor; + FParent: TReflector; // weak reference to parent, with ARC. + FWeakClients: TReflector; + + // IRunInstance + procedure Run( const RunInstanceServices: IRunInstanceServices; OnStatusChangeProc: TStatusInformerProc); virtual; + procedure Clear; virtual; + function Parent: IRunInstance; virtual; + function WorkLoad: integer; virtual; + function HasMessageList( var Lst: IMessageList): boolean; virtual; + function TestNode: ITestNode; virtual; abstract; + function ChildInstances: IList2; virtual; + function Description: string; virtual; + + // ITestResult + function GetStatus: TTestStatus; virtual; + function ITestResult.Status = GetStatus; + function IRunInstance.Status = GetStatus; + function RoundsCompleted: integer; virtual; + function RoundsPerTestCase: integer; virtual; + function ErrorCount: integer; virtual; + function PassCount: integer; virtual; + function FailCount: integer; virtual; + function WarnCount: integer; virtual; + function Timing: RTimingStats; virtual; + function Messages: IMessageSource; virtual; + function TestCase: ITestCase; virtual; + function Fixture: ITestFixture; virtual; + function ChildResults: ISEnumerable; virtual; + function Executed: boolean; virtual; + function IgnoredCount: integer; virtual; + function SkippedCount: integer; virtual; + function NodeKind: TResultNodeKind; virtual; abstract; + function ErrorOrFailureMsg( var FailMsg: RMessage): boolean; virtual; + + procedure BeforeRun; virtual; + procedure DoInnerRun; virtual; + procedure CleanUpAfterRun; virtual; + procedure PutSimpleMessage( Code: integer; const sMsg: string; Lv: TMessageLevel); virtual; + procedure SetStatus( Value: TTestStatus); virtual; + function NodeName: string; + + public + property Status: TTestStatus read GetStatus write SetStatus; + + public + constructor Create( ParentAsObject: TReflector; const Mem1: IMemoryMonitor); + end; + + +TTestNode_RunInstanceWithChildren = class( TTestNode_RunInstance) + protected + FChildren: IList2; + function ChildInstances: IList2; override; + public + constructor Create( ParentAsObject: TReflector; const Mem1: IMemoryMonitor); + end; + + + +implementation + + + + + + + + +uses SBD.Messages.Solution; + +type +TEmptyMessages = class( TSEnumerable, IMessageSource) + protected + function GetEnumerator: ISEnumerator; override; + end; + +function TEmptyMessages.GetEnumerator: ISEnumerator; +begin +result := TEmptyCursor.Create( nil) +end; + + + + + +constructor TTestNode_RunInstance.Create( + ParentAsObject: TReflector; const Mem1: IMemoryMonitor); +begin +if assigned( ParentAsObject) then + ParentAsObject.SetWeakReference( FParent); +FWeakClients := TReflector.Create( self); +FRunInstanceServices := nil; +FStatusInformerProc := nil; +FMem := Mem1; +Clear +end; + + +procedure TTestNode_RunInstance.BeforeRun; +begin +end; + +function TTestNode_RunInstance.Description: string; +begin +result := TestNode.Name +end; + +procedure TTestNode_RunInstance.DoInnerRun; +begin +end; + +function TTestNode_RunInstance.ChildInstances: IList2; +begin +result := TList2.Create +end; + +function TTestNode_RunInstance.ChildResults: ISEnumerable; +var + TestResult: ITestResult; + RunInstance: IRunInstance; + Lst: IList2; +begin +Lst := TList2.Create; +result := Lst; +for RunInstance in ChildInstances do + if Supports( RunInstance, ITestResult, TestResult) then + Lst.Add( TestResult) +end; + + +procedure TTestNode_RunInstance.CleanUpAfterRun; +begin +end; + +procedure TTestNode_RunInstance.Clear; +begin +FStatus := tsNeutral; +FTiming.Clear; +FExecuted := False; +// TODO: +// ChildResults.Reset +end; + + +function TTestNode_RunInstance.ErrorCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.ErrorCount) +end; + + +function TTestNode_RunInstance.ErrorOrFailureMsg( + var FailMsg: RMessage): boolean; +var + Lst: IMessageList; + Filter: TMessageLevelSet; + M: RMessage; +begin +result := HasMessageList( Lst) and Lst.Has( [lvError, lvFatalError]); +if not result then exit; +if Lst.Has( [lvFatalError]) then + Filter := [lvFatalError] + else + Filter := [lvError]; +for M in Lst.AsSource( Filter) do + begin + FailMsg := M; + break + end +end; + + +function TTestNode_RunInstance.Executed: boolean; +begin +result := FExecuted +end; + +function TTestNode_RunInstance.FailCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.FailCount) +end; + +function TTestNode_RunInstance.Fixture: ITestFixture; +var + TestCase1: ITestCase; + TestProc1: ITestProcedure; +begin +TestCase1 := TestCase(); +if assigned( TestCase1) then + TestProc1 := TestCase1.Parent + else + TestProc1 := nil; +if assigned( TestProc1) then + result := TestProc1.Parent + else + result := nil +end; + +function TTestNode_RunInstance.GetStatus: TTestStatus; +begin +result := FStatus +end; + +function TTestNode_RunInstance.HasMessageList( var Lst: IMessageList): boolean; +begin +result := False +end; + +function TTestNode_RunInstance.IgnoredCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.IgnoredCount) +end; + +function TTestNode_RunInstance.Messages: IMessageSource; +var + Lst: IMessageList; +begin +if HasMessageList( Lst) then + result := Lst.AsSource( AllMessages) + else + result := TEmptyMessages.Create +end; + +function TTestNode_RunInstance.NodeName: string; +var + Node: ITestNode; +begin +Node := TestNode(); +if assigned( Node) then + result := Node.Name + else + result := '' +end; + +function TTestNode_RunInstance.Parent: IRunInstance; +begin +if (not assigned( FParent)) or + (not Supports( FParent.FController, IRunInstance, result)) then + result := nil +end; + +function TTestNode_RunInstance.PassCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.PassCount) +end; + + +procedure TTestNode_RunInstance.PutSimpleMessage( + Code: integer; const sMsg: string; Lv: TMessageLevel); +var + Msg: RMessage; + Lst: IMessageList; +begin +if not HasMessageList( Lst) then exit; +SetFrameworkMessage( Msg, Code, sMsg, Lv); +Lst.Add( Msg); +if assigned( FRunInstanceServices) then + FRunInstanceServices.Put( self, TestNode(), Msg, RoundsCompleted()) +end; + +function TTestNode_RunInstance.RoundsCompleted: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.RoundsCompleted) +end; + +function TTestNode_RunInstance.RoundsPerTestCase: integer; +begin +result := 1 +end; + +procedure TTestNode_RunInstance.Run( + const RunInstanceServices: IRunInstanceServices; + OnStatusChangeProc: TStatusInformerProc); +begin +FRunInstanceServices := RunInstanceServices; +FStatusInformerProc := OnStatusChangeProc; +Clear; +BeforeRun; +FTiming.FStart := Now; +DoInnerRun; +FTiming.FEnd := Now; +FTiming.FDuration_ms := Round( (FTiming.FEnd - FTiming.FStart) * MSecsPerDay); +FRunInstanceServices := nil; +FStatusInformerProc := nil; +CleanUpAfterRun +end; + +procedure TTestNode_RunInstance.SetStatus( Value: TTestStatus); +var + TestNode1: ITestNode; +begin +if FStatus = Value then exit; +FStatus := Value; +TestNode1 := TestNode(); +if assigned( FStatusInformerProc) then + FStatusInformerProc( FStatus); +if assigned( FRunInstanceServices) then + FRunInstanceServices.StatusChange( self, TestNode(), RoundsCompleted()) +end; + +function TTestNode_RunInstance.SkippedCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.SkippedCount) +end; + +function TTestNode_RunInstance.TestCase: ITestCase; +begin +result := nil +end; + +function TTestNode_RunInstance.Timing: RTimingStats; +begin +result := FTiming +end; + +function TTestNode_RunInstance.WarnCount: integer; +var + Child: ITestResult; +begin +result := 0; +for Child in ChildResults do + Inc( result, Child.WarnCount) +end; + +function TTestNode_RunInstance.WorkLoad: integer; +var + Child: ITestResult; + Run: IRunInstance; +begin +result := 0; +for Child in ChildResults do + if Supports( Child, IRunInstance, Run) then + Inc( result, Run.WorkLoad) +end; + + + +function TTestNode_RunInstanceWithChildren.ChildInstances: IList2; +begin +result := FChildren +end; + +constructor TTestNode_RunInstanceWithChildren.Create( + ParentAsObject: TReflector; const Mem1: IMemoryMonitor); +begin +FChildren := TList2.Create; +inherited Create( ParentAsObject, Mem1) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.StringUtils.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.StringUtils.pas new file mode 100644 index 0000000..f03c146 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.StringUtils.pas @@ -0,0 +1,214 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.StringUtils; +interface +uses SBD.Generics; + +type +IStringEnumerable = interface( ISEnumerable) + ['{12EB292B-9B33-4088-B523-826BF289E44A}'] + end; + +IStringCursor = interface( ISEnumerator) + ['{0C0D1CFD-FBC6-4376-A09C-D4083C2CDBBA}'] + end; + +function Split( const Joined, Delimiter : string): IStringEnumerable; + +{$ifdef MSWINDOWS} +function AbsPathToRelPath( const AbsPath, BasePath: string): string; +function PathCanonise( const Uncanonical: string): string; +{$endif} + +implementation + + +{$ifdef MSWINDOWS} +uses Windows, ShLwApi, SysUtils; +{$endif} + +type +TSplitter = class( TSEnumerable, IStringEnumerable) + private + FJoined: string; + FDelimiter: string; + + private type + TParticleCursor = class ( TSEnumerator) + private + FBuffer: string; + FCrsrDelim: string; + FDelimLen: integer; + function DelimPos: integer; + protected + function MoveNext: boolean; override; + function GetCurrent: string; override; + public + constructor Create( Enumerable1: TSEnumerable); override; + end; + + protected + function GetEnumerator: ISEnumerator; override; + public + constructor Create( const Joined, Delimiter : string); + end; + + +function Split( const Joined, Delimiter : string): IStringEnumerable; +begin +result := TSplitter.Create( Joined, Delimiter) +end; + + +constructor TSplitter.Create( const Joined, Delimiter: string); +begin +FJoined := Joined; +FDelimiter := Delimiter +end; + +constructor TSplitter.TParticleCursor.Create( Enumerable1: TSEnumerable); +begin +inherited Create( Enumerable1); +with Enumerable1 as TSplitter do + begin + FCrsrDelim := FDelimiter; + FBuffer := FCrsrDelim + FJoined + end; +FDelimLen := Length( FCrsrDelim) +end; + +function TSplitter.TParticleCursor.DelimPos: integer; +begin +result := Pos( FCrsrDelim, FBuffer) +end; + +function TSplitter.TParticleCursor.GetCurrent: string; +var + P: integer; +begin +result := FBuffer; +P := DelimPos; +if P > 0 then + SetLength( result, P - 1) +end; + +function TSplitter.TParticleCursor.MoveNext: boolean; +var + P: integer; +begin +P := DelimPos; +result := P > 0; +if not result then exit; +Delete( FBuffer, 1, P + FDelimLen - 1) +end; + +function TSplitter.GetEnumerator: ISEnumerator; +begin +result := TSplitter.TParticleCursor.Create( self) +end; + + +{$ifdef MSWINDOWS} +function AbsPathToRelPath( const AbsPath, BasePath: string): string; +// Copied from Andreas Rejbrand (http://stackoverflow.com/users/282848/andreas-rejbrand) +// http://stackoverflow.com/questions/5329472 +// TODO: Find solution for non-Windows platforms. +var + Path: array[0..MAX_PATH-1] of char; +begin +if AbsPath = BasePath then + result := '' // Same place. Use empty rather than '.' . + else if AbsPath = '' then + result := '' // Path is unknown or not yet intialized. + else if BasePath = '' then + result := AbsPath // No base. So Absolute is the best we can get + else if PathRelativePathTo( @Path[0], PChar( BasePath), FILE_ATTRIBUTE_DIRECTORY, PChar( AbsPath), 0) then + result := ExcludeTrailingPathDelimiter( Path) + else + result := AbsPath; // The computation bombed for some reason. So Absolute is the best we can get. +if Copy( result, 1, 2) = '.\' then + System.Delete( result, 1, 2) +end; + + +function PathCanonicalize( lpszDst: PChar; lpszSrc: PChar): LongBool; stdcall; + external 'shlwapi.dll' name 'PathCanonicalizeW'; + +function PathCanonise( const Uncanonical: string): string; +var + Path: array[0..MAX_PATH-1] of char; +begin +if PathCanonicalize( @Path[0], PChar( Uncanonical)) then + begin + result := Path; + SetLength( result, StrLen( PChar( @Path[0]))) + end + else + result := Uncanonical +end; +{$endif} + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCase.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCase.pas new file mode 100644 index 0000000..d423a93 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCase.pas @@ -0,0 +1,951 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestCase; +interface +uses DUnitM.UnitTestFramework, DUnitM.TestNode, Rtti, SBD.Generics, SBD.Messages, + DUnitM.MemoryMonitor, DUnitM.RunInstance, DUnitM.TestCaseParameters; + +type + +TTestCase = class( TTestNode, ITestCase, ITestCaseInternal) + private + function GetEnabled: boolean; + procedure SetEnabled( Value: boolean); + function DisplayName: string; + function Parent: ITestProcedure; + procedure SetDeferredError( const ErMsg: string); + function GetDeferredError( var ErMsg: string): boolean; + + protected + FName: string; + FData: string; + FEnabled: boolean; + FParams: TTestCaseParamProcessor; + FDeferredError: string; + + function RequiresPreliminaryLoadCount: boolean; virtual; + function Load: integer; override; + procedure ShutDown; override; + function NodeKind: TResultNodeKind; override; + function Name: string; override; + function NodeChildren: ISEnumerable; override; + procedure Execute( Platter: TObject); + function EstimateRoundCount: integer; virtual; + function MakeRunInstance( ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; virtual; + function HasEnabledTestCases: boolean; override; + + public + FProcType: TRttiMethod; + + constructor CreateCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestCaseAttribute); + destructor Destroy; override; + end; + +type +/// Controller is TDataDrivenTestCase below +TDataDrivenTestCaseNavManager = class( TAggregatedObject) + public + /// + /// Has signature like ... + /// function Navigator: IDataDrivenTestCaseNavigator; + /// + FNavigatorMeth: TRttiMethod; + /// + /// Actually of type TDataDrivenTestCase. This is the parent object and controller. + /// + FParentTestCase: TTestCase; + + /// + /// Generally, this just points back to TDataDrivenTestCase.FProcType + /// Has signature like ... + /// procedure TestLineItem( Item: TObject); + /// + function TestMeth: TRttiMethod; virtual; + + constructor Create( Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); virtual; + function EstimatedCount( TestBed: TObject; var CountItems: integer): boolean; virtual; + function OpenLineItemCursor( TestBed: TObject): ITestCaseLineItemCursor; virtual; + procedure TestLineItem( TestBed: TObject; Cursor: ITestCaseLineItemCursor); virtual; + function Name: string; virtual; + + protected + constructor PrimitiveCreate( Parent: TTestCase; Method: TRttiMethod); + end; +TDataDrivenTestCaseNavManagerClass = class of TDataDrivenTestCaseNavManager; + + +TDataDrivenTestCase = class( TTestCase, IDataDrivenTestCase) + private + FisLoadCached: boolean; + FLoad: integer; + FNavManager: TDataDrivenTestCaseNavManager; // Can be a descendant type. + + function AcquireDataDriver( Platter: TObject): IDataDrivenTestCaseNavigator; + function OpenLineItemTestCursor( Platter: TObject): ITestCaseLineCursoredItem; + + protected + function Load: integer; override; + function RequiresPreliminaryLoadCount: boolean; override; + function EstimateRoundCount: integer; override; + + public + constructor CreateCase( + MgrCls1: TDataDrivenTestCaseNavManagerClass; + ProcParentAsObject: TReflector; ProcType: TRttiMethod; + Attri: TDataDrivenTestAttributeBase); + + destructor Destroy; override; + end; + +TSimpleTestCase = class( TTestCase) + private + constructor CreateCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod); + end; + +TTestCaseList = class ( TList2, ITestCasesInternal, IShutDown) + public + function AddCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestCaseAttribute): ITestCaseInternal; + function AddDataDrivenCase(ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TDataDrivenTestAttributeBase): ITestCaseInternal; + function AddSimpleCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestAttribute): ITestCaseInternal; + function isDataDriven( ProcParentAsObject: TReflector; ProcType: TRttiMethod; var DDTestCaseFactory: IDataDrivenTestCaseFactory): boolean; + function AddByFactory( const Fact: IDataDrivenTestCaseFactory): ITestCaseInternal; + procedure ShutDown; + end; + + + + +TTestCase_RunInstance = class( TTestNode_RunInstanceWithChildren) + protected + FDeferredErrorCount: integer; + FTestCase: ITestCaseInternal; + FTestBed: TGetObjectFunc; + FRoundsCompleted: integer; + FMessages: IMessageList; + + procedure Clear; override; + function HasMessageList( var Lst: IMessageList): boolean; override; + function WorkLoad: integer; override; + function TestNode: ITestNode; override; + function RoundsCompleted: integer; override; + function RoundsPerTestCase: integer; override; + function TestCase: ITestCase; override; + function NodeKind: TResultNodeKind; override; + procedure DoInnerRun; override; + function IgnoredCount: integer; override; + function SkippedCount: integer; override; + function ErrorCount: integer; override; + + public + constructor Create( ParentAsObject: TReflector; TestBed: TGetObjectFunc; + const Case1: ITestCaseInternal; const Mem1: IMemoryMonitor); + end; + + +type +TDataDrivenTestCaseFactory = class( TInterfacedObject, IDataDrivenTestCaseFactory) + private + ProcAsObject: TReflector; + ProcMethod: TRttiMethod; + DrivingAttribute: DataDrivenTestAttribute; + FRepeats, FSkips: integer; + FName: string; + FMgrCls: TDataDrivenTestCaseNavManagerClass; + function Repeats: integer; + function MethodSkips: integer; + function Name: string; + function Make: ITestCase; + public + constructor Create( Attri: DataDrivenTestAttribute; ProcParentAsObject: TReflector; ProcType: TRttiMethod); + class function SignatureMatches( poTestMethod: TRttiMethod): boolean; + class function MethodMatches_Procedure_Param1_Object( Method: TRttiMethod): boolean; + class function MethodMatches_Function_Returns_IDataDrivenTestCaseNavigator( Method: TRttiMethod): boolean; + end; + + + + +implementation + + + + + + +uses Generics.Collections, SysUtils, TypInfo, SBD.Utils.XML2, Math, + SBD.Messages.Solution, DUnitM.TestCaseRound, DUnitM.RttiUtils; + + + +constructor TTestCase.CreateCase( + ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestCaseAttribute); +begin +inherited CreateTestNode( ProcParentAsObject); +FName := Attri.FName; +FProcType := ProcType; +FEnabled := Parent.GetDefaultEnabled; +FViewTokens := TDictionary.Create; +FData := Attri.FData; +FParams := TTestCaseParamProcessor.Create( FProcType, FData); +FParams.Parse; +if FParams.FParseResult = psSyntaxError then + raise Exception.Create( '[TestCase] syntax error') +end; + +destructor TTestCase.Destroy; +begin +inherited; +FParams.Free +end; + +function TTestCase.DisplayName: string; +begin +result := Name +end; + +function TTestCase.EstimateRoundCount: integer; +begin +result := Parent.RepeatCount +end; + +procedure TTestCase.Execute( Platter: TObject); +begin +FParams.Invoke( Platter) +end; + +function TTestCase.GetDeferredError( var ErMsg: string): boolean; +begin +ErMsg := FDeferredError; +result := ErMsg <> '' +end; + +function TTestCase.GetEnabled: boolean; +begin +result := FEnabled +end; + +function TTestCase.Load: integer; +begin +result := Parent.RepeatCount +end; + +function TTestCase.MakeRunInstance( + ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; +begin +result := TTestCase_RunInstance.Create( ParentAsObject, TestBed, self, Mem1) +end; + +function TTestCase.Name: string; +begin +result := FName +end; + +function TTestCase.NodeChildren: ISEnumerable; +var + Accumulator: ITestNodes; +begin +Accumulator := TTestNodes.Create; +result := Accumulator +end; + +function TTestCase.NodeKind: TResultNodeKind; +begin +result := rnTestCase +end; + +function TTestCase.Parent: ITestProcedure; +begin +if (not assigned( FParent)) or + (not Supports( FParent.FController, ITestProcedure, result)) then + result := nil +end; + + +function TTestCase.RequiresPreliminaryLoadCount: boolean; +begin +result := False +end; + +// The NUnit format +// =================== +// Examples: +// NUnit 2.5: http://nunit.org/files/testresult_25.txt +// NUnit 3.0: http://nunit.org/files/testresult_30.txt +// Will probably go iwth 2.5 +// Schema: +// NUnit 2.5: http://nunit.org/files/testresult_schema_25.txt +// ? unknown version at http://www.nunit.org/docs/2.2/files/Results.xsd + +procedure TTestCase.SetDeferredError( const ErMsg: string); +begin +FDeferredError := ErMsg +end; + +procedure TTestCase.SetEnabled( Value: boolean); +begin +FEnabled := Value +end; + +procedure TTestCase.ShutDown; +begin +inherited; +FViewTokens.Clear +end; + + + +constructor TDataDrivenTestCase.CreateCase( + MgrCls1: TDataDrivenTestCaseNavManagerClass; ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TDataDrivenTestAttributeBase); +begin +inherited CreateTestNode( ProcParentAsObject); +if not assigned( MgrCls1) then + MgrCls1 := TDataDrivenTestCaseNavManager; +FNavManager := MgrCls1.Create( self, ProcType, Attri); +FName := FNavManager.Name; +FEnabled := Parent.GetDefaultEnabled; +FData := ''; +FParams := nil; +FisLoadCached := False; +FLoad := 1 +end; + +destructor TDataDrivenTestCase.Destroy; +begin +FNavManager.Free; +inherited +end; + +function TDataDrivenTestCase.EstimateRoundCount: integer; +begin +result := Load +end; + + +type +TDriver = class( TInterfacedObject, IDataDrivenTestCaseNavigator) + private + FPlatter: TObject; + FMngr: TDataDrivenTestCaseNavManager; + function EstimatedCount( var CountItems: integer): boolean; + function OpenLineItemCursor: ITestCaseLineItemCursor; + public + constructor Create( Platter: TObject; Mngr: TDataDrivenTestCaseNavManager); + end; + +constructor TDriver.Create( Platter: TObject; Mngr: TDataDrivenTestCaseNavManager); +begin +FPlatter := Platter; +FMngr := Mngr +end; + +function TDriver.EstimatedCount( var CountItems: integer): boolean; +begin +result := FMngr.EstimatedCount( FPlatter, CountItems) +end; + +function TDriver.OpenLineItemCursor: ITestCaseLineItemCursor; +begin +result := FMngr.OpenLineItemCursor( FPlatter) +end; + +type TTestCaseLineCursoredItem = class( TInterfacedObject, ITestCaseLineCursoredItem) + private + FPlatter: TObject; + FMngr: TDataDrivenTestCaseNavManager; + FPureCursor: ITestCaseLineItemCursor; + FRowNumber: integer; + function Next: boolean; + function LineItemDescription: string; + procedure ConductTest; + public + constructor Create( Platter: TObject; Mngr: TDataDrivenTestCaseNavManager); + end; + +constructor TTestCaseLineCursoredItem.Create( Platter: TObject; Mngr: TDataDrivenTestCaseNavManager); +begin +FPlatter := Platter; +FMngr := Mngr; +FRowNumber := 0; +FPureCursor := Mngr.OpenLineItemCursor( FPlatter) +end; + +function TTestCaseLineCursoredItem.Next: boolean; +begin +result := FPureCursor.Next; +if result then + Inc( FRowNumber) +end; + +function TTestCaseLineCursoredItem.LineItemDescription: string; +begin +result := Format( 'Line item %d', [FRowNumber]); +FPureCursor.GetLineItemDescription( FRowNumber, result) +end; + +procedure TTestCaseLineCursoredItem.ConductTest; +begin +FMngr.TestLineItem( FPlatter, FPureCursor) +end; + + +function TDataDrivenTestCase.AcquireDataDriver( Platter: TObject): IDataDrivenTestCaseNavigator; +begin +result := TDriver.Create( Platter, FNavManager) +end; + +function TDataDrivenTestCase.Load: integer; +var + Obj: TObject; + Cursor: IDataDrivenTestCaseNavigator; + Fixture: ITestFixtureInternal; +begin +if not FisLoadCached then + begin + result := 1; + try + FisLoadCached := True; + FLoad := 1; + if FDeferredError <> '' then exit; + if Supports( Parent.Parent, ITestFixtureInternal, Fixture) then + Obj := Fixture.PreliminaryPlatterObject + else + Obj := nil; + if assigned( Obj) then + begin + Fixture.Setup( Obj); + try + Cursor := AcquireDataDriver( Obj); + try + FLoad := ForceGetEstimatedCount( Cursor) + finally + Cursor := nil + end + finally + Fixture.Teardown( Obj) + end; + if FLoad <= 0 then + begin + FLoad := 1; + SetDeferredError( 'Data driven test procedure returned an invalid preliminary load estimate.') + end + end + else + SetDeferredError( 'Preliminatry load estimate could not be computed due to unavailable test fixture.') + except on E: Exception do + begin + FLoad := 1; + SetDeferredError( E.Message) + end + end + end; +result := FLoad +end; + + +function TDataDrivenTestCase.OpenLineItemTestCursor( Platter: TObject): ITestCaseLineCursoredItem; +begin +result := TTestCaseLineCursoredItem.Create( Platter, FNavManager) +end; + +function TDataDrivenTestCase.RequiresPreliminaryLoadCount: boolean; +begin +result := not FisLoadCached +end; + + +{ TSimpleTestCase } + +constructor TSimpleTestCase.CreateCase( + ProcParentAsObject: TReflector; ProcType: TRttiMethod); +begin +inherited CreateTestNode( ProcParentAsObject); +FProcType := ProcType; +FName := FProcType.Name; +FEnabled := Parent.GetDefaultEnabled; +FData := ''; +FParams := TTestCaseParamProcessor.CreateSimple( FProcType) +end; + + + + + +function TTestCaseList.AddCase( ProcParentAsObject: TReflector; + ProcType: TRttiMethod; Attri: TestCaseAttribute): ITestCaseInternal; +begin +result := TTestCase.CreateCase( ProcParentAsObject, ProcType, Attri); +Add( result) +end; + +function TTestCaseList.AddDataDrivenCase(ProcParentAsObject: TReflector; + ProcType: TRttiMethod; Attri: TDataDrivenTestAttributeBase): ITestCaseInternal; +begin +result := TDataDrivenTestCase.CreateCase( nil, ProcParentAsObject, ProcType, Attri); +Add( result) +end; + +function TTestCaseList.AddSimpleCase(ProcParentAsObject: TReflector; + ProcType: TRttiMethod; Attri: TestAttribute): ITestCaseInternal; +begin +result := TSimpleTestCase.CreateCase( ProcParentAsObject, ProcType); +Add( result) +end; + + + +function TTestCaseList.isDataDriven( + ProcParentAsObject: TReflector; ProcType: TRttiMethod; + var DDTestCaseFactory: IDataDrivenTestCaseFactory): boolean; +var + oAttrib: TCustomAttribute; + Attri, BestMatch: TDataDrivenTestAttributeBase; +begin +result := False; +BestMatch := nil; +for Attri in TAttributes.Get( ProcType) do + begin + if not Attri.SignatureMatches( ProcType) then continue; + result := True; + BestMatch := Attri + // If there are multiple matches, we take the last. + end; +if result then + DDTestCaseFactory := Attri.AcquireFactory( ProcParentAsObject, ProcType) +end; + + +function TTestCaseList.AddByFactory( + const Fact: IDataDrivenTestCaseFactory): ITestCaseInternal; +begin +result := Fact.Make as ITestCaseInternal; +Add( result) +end; + +procedure TTestCaseList.ShutDown; +var + Child: ITestCase; + Shut: IShutDown; +begin +for Child in (self as ITestCasesInternal) do + if Supports( Child, IShutDown, Shut) then + Shut.ShutDown +end; + + + + + + +type +TRepeatRowsCursor = class( TInterfacedObject, ITestCaseLineCursoredItem) + private + FCase: ITestCaseInternal; + FTestBed: TObject; + FRounds: integer; + FRound: integer; + function Next: boolean; + function LineItemDescription: string; + procedure ConductTest; + public + constructor Create( Case1: ITestCaseInternal; TestBed1: TObject); + end; + +function TTestCase.HasEnabledTestCases: boolean; +var + sErr: string; +begin +result := GetEnabled and (not GetDeferredError( sErr)) +end; + + + + +constructor TTestCase_RunInstance.Create( + ParentAsObject: TReflector; + TestBed: TGetObjectFunc; const Case1: ITestCaseInternal; + const Mem1: IMemoryMonitor); +begin +FMessages := TMessageList.Create; +inherited Create( ParentAsObject, Mem1); +FTestCase := Case1; +FTestBed := TestBed +end; + +procedure TTestCase_RunInstance.Clear; +begin +inherited; +FMessages.Clear; +FDeferredErrorCount := 0; +FRoundsCompleted := 0; +if assigned( FMem) then + FMem.HeapMonitoring_OFF +end; + + +procedure TTestCase_RunInstance.DoInnerRun; +var + TestBedObj: TObject; + sErr: string; + Addend: IRunInstance; + sIgnoreReason: string; + DD: IDataDrivenTestCase; + Cursor: ITestCaseLineCursoredItem; +begin +TestBedObj := FTestBed(); +if FTestCase.Enabled and FTestCase.GetDeferredError( sErr) then + begin + FDeferredErrorCount := 1; + Status := tsError; + PutSimpleMessage( SyntaxError, sErr, lvError) + end + else if FTestCase.Enabled and (not FRunInstanceServices.IsAborted) then + begin + if Supports( FTestCase, IDataDrivenTestCase, DD) then + Cursor := DD.OpenLineItemTestCursor( TestBedObj) + else + Cursor := TRepeatRowsCursor.Create( FTestCase, TestBedObj); + Status := tsExecuting; + while Cursor.Next and (not FRunInstanceServices.IsAborted) do + begin + Addend := TTestCaseRound_RunInstance.Create( FWeakClients, TestBedObj, FTestCase, FRoundsCompleted, FMem, Cursor); + FChildren.Add( Addend); + Addend.Run( FRunInstanceServices, + procedure ( ChildStatus: TTestStatus) + begin + if ChildStatus in [tsPass..tsSkipped] then + Inc( FRoundsCompleted); + if ChildStatus in [tsSetup, tsExecuting, tsTeardown] then + Status := ChildStatus + end); + FExecuted := True; + if ErrorCount > 0 then break + end; + if ErrorCount > 0 then + Status := tsError + else if FailCount > 0 then + Status := tsFail + else if WarnCount > 0 then + Status := tsWarn + else if FRoundsCompleted > 0 then + Status := tsPass + else + // Skipped because there were no rounds to execute. + Status := tsSkipped + end + else if FTestCase.Parent.IsIgnored( sIgnoreReason) and (not FRunInstanceServices.IsAborted) then + begin + // Skipped because the test case is marked as ignore + Status := tsSkipped; + Self.PutSimpleMessage( IgnoredTestCase, sIgnoreReason, lvHint) + end + else + // Skipped because teh test case is disabled (but not ignored) or user aborted + Status := tsSkipped +end; + +function TTestCase_RunInstance.ErrorCount: integer; +begin +result := FDeferredErrorCount + inherited ErrorCount +end; + +function TTestCase_RunInstance.HasMessageList(var Lst: IMessageList): boolean; +begin +result := True; +Lst := FMessages +end; + +function TTestCase_RunInstance.IgnoredCount: integer; +// The ignored count of a test case is ... +// If the status is skipped and the test proc is marked as Ignore, then it is RoundsPerTestCase. +// Otherwise it is zero. +var + sIgnoreReason: string; +begin +if (FStatus = tsSkipped) and FTestCase.Parent.IsIgnored( sIgnoreReason) then + result := RoundsPerTestCase + else + result := 0 +end; + +function TTestCase_RunInstance.NodeKind: TResultNodeKind; +begin +result := rnTestCase +end; + +function TTestCase_RunInstance.RoundsCompleted: integer; +begin +result := FRoundsCompleted +end; + +function TTestCase_RunInstance.RoundsPerTestCase: integer; +begin +result := Max( FTestCase.EstimateRoundCount, FChildren.Count) +end; + +function TTestCase_RunInstance.SkippedCount: integer; +// The skip count of a test case is ... +// If the status is some kind of done (pass, fail, error, skip) then +// it is the remainder (RoundsPerTestCase - passes - fails - errors - ignores) +// Otherwise it is zero +begin +if FStatus in [tsPass..tsSkipped] then + result := RoundsPerTestCase - PassCount - FailCount - ErrorCount - IgnoredCount + else + result := 0 +end; + +function TTestCase_RunInstance.TestCase: ITestCase; +begin +result := FTestCase +end; + +function TTestCase_RunInstance.TestNode: ITestNode; +begin +result := FTestCase as ITestNode +end; + +function TTestCase_RunInstance.WorkLoad: integer; +begin +if FTestCase.Enabled then + result := RoundsPerTestCase + else + result := 0 +end; + +constructor TDataDrivenTestCaseNavManager.PrimitiveCreate( + Parent: TTestCase; Method: TRttiMethod); +begin +inherited Create( Parent as IInterface); +FParentTestCase := Parent; +FParentTestCase.FProcType := Method; +FNavigatorMeth := nil +end; + + +// [DataDrivenTest] +// [Description('Tests the StringToDate() function')] +// function Navigator: IDataDrivenTestCaseNavigator; +// procedure TestLineItem( Item: TObject); + +constructor TDataDrivenTestCaseNavManager.Create( + Parent: TTestCase; Method: TRttiMethod; Attribute: TDataDrivenTestAttributeBase); +begin +PrimitiveCreate( Parent, Method); +NextDeclaredMethod( Method, FNavigatorMeth) +end; + + +function TDataDrivenTestCaseNavManager.EstimatedCount( + TestBed: TObject; var CountItems: integer): boolean; +var + Args: array of TValue; + Nav: IDataDrivenTestCaseNavigator; + Crs: ITestCaseLineItemCursor; +begin +// FNavigatorMeth has signature function Navigator: IDataDrivenTestCaseNavigator(); +Nav := FNavigatorMeth.Invoke( TestBed, []).AsType; +Nav._AddRef; +CountItems := 0; +result := assigned( Nav) and Nav.EstimatedCount( CountItems); +if result or (not assigned( Nav)) then exit; +Crs := Nav.OpenLineItemCursor; +result := assigned( Crs); +if result then + while Crs.Next do + Inc( CountItems) +end; + + +function TDataDrivenTestCaseNavManager.Name: string; +begin +result := TestMeth.Name +end; + +function TDataDrivenTestCaseNavManager.OpenLineItemCursor( + TestBed: TObject): ITestCaseLineItemCursor; +var + Args: array of TValue; + Nav: IDataDrivenTestCaseNavigator; +begin +// FNavigatorMeth has signature function Navigator: IDataDrivenTestCaseNavigator(); +Nav := FNavigatorMeth.Invoke( TestBed, []).AsType; +Nav._AddRef; +result := Nav.OpenLineItemCursor +end; + +procedure TDataDrivenTestCaseNavManager.TestLineItem( + TestBed: TObject; Cursor: ITestCaseLineItemCursor); +// TestMeth() has signature like ... +// procedure TestLineItem( Item: TObject); +begin +TestMeth.Invoke( TestBed, [Cursor.LineItemObject]) +end; + +function TDataDrivenTestCaseNavManager.TestMeth: TRttiMethod; +begin +result := FParentTestCase.FProcType +end; + + +class function TDataDrivenTestCaseFactory.MethodMatches_Procedure_Param1_Object( Method: TRttiMethod): boolean; +// Method is like ... procedure TestIt( Item: TObject); +begin +result := (Method.MethodKind = mkProcedure) and + (Length( Method.GetParameters) = 1) and + (Method.GetParameters[0].ParamType.TypeKind = tkClass) and + ((Method.GetParameters[0].Flags * [pfArray, pfOut]) = []) +end; + +class function TDataDrivenTestCaseFactory.MethodMatches_Function_Returns_IDataDrivenTestCaseNavigator( Method: TRttiMethod): boolean; +// Method is like ... function Navigator: IDataDrivenTestCaseNavigator; +begin +result := (Method.MethodKind = mkFunction) and + (Length( Method.GetParameters) = 0) and + (Method.ReturnType.TypeKind = tkInterface) and + (Method.ReturnType is TRttiInterfaceType) and + IsEqualGUID( + TRttiInterfaceType( Method.ReturnType).GUID, + IDataDrivenTestCaseNavigator) +end; + + +class function TDataDrivenTestCaseFactory.SignatureMatches( + poTestMethod: TRttiMethod): boolean; +var + Next: TRttiMethod; +begin + // like ... procedure TestIt( Item: TObject); + result := MethodMatches_Procedure_Param1_Object( poTestMethod) and + NextDeclaredMethod( poTestMethod, Next) and + // like ... function Navigator: IDataDrivenTestCaseNavigator; + MethodMatches_Function_Returns_IDataDrivenTestCaseNavigator( Next) +end; + +constructor TDataDrivenTestCaseFactory.Create( Attri: DataDrivenTestAttribute; ProcParentAsObject: TReflector; ProcType: TRttiMethod); +begin +ProcAsObject := ProcParentAsObject; +ProcMethod := ProcType; +DrivingAttribute := Attri; +FRepeats := 1; +FSkips := 1; +FMgrCls := TDataDrivenTestCaseNavManager; +FName := ProcMethod.Name +end; + +function TDataDrivenTestCaseFactory.Repeats: integer; +begin +result := FRepeats +end; + +function TDataDrivenTestCaseFactory.MethodSkips: integer; +begin +result := FSkips +end; + +function TDataDrivenTestCaseFactory.Name: string; +begin +result := FName +end; + +function TDataDrivenTestCaseFactory.Make: ITestCase; +begin +result := TDataDrivenTestCase.CreateCase( FMgrCls, ProcAsObject, ProcMethod, DrivingAttribute) +end; + + +constructor TRepeatRowsCursor.Create( Case1: ITestCaseInternal; TestBed1: TObject); +begin +FCase := Case1; +FTestBed := TestBed1; +FRounds := FCase.Parent.RepeatCount; +FRound := -1 +end; + + + +function TRepeatRowsCursor.LineItemDescription: string; +begin +if FRounds = 1 then + result := 'single round' + else + result := Format( 'Round %d', [FRound + 1]) +end; + +function TRepeatRowsCursor.Next: boolean; +begin +result := FRound <= (FRounds - 2); +if result then + Inc( FRound) +end; + + +procedure TRepeatRowsCursor.ConductTest; +begin +FCase.Execute( FTestBed) +end; + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseParameters.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseParameters.pas new file mode 100644 index 0000000..6ec4162 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseParameters.pas @@ -0,0 +1,450 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestCaseParameters; +interface +uses DUnitM.UnitTestFramework, DUnitM.TestNode, Rtti, SBD.Generics, SBD.Messages, + DUnitM.MemoryMonitor, DUnitM.RunInstance; + +type + +TTestCaseParamProcessorStatus = (psMore, psSyntaxError, psDone); +RTestCaseParamDatum = record + FParam: TRttiParameter; + FActualValue: TValue; + FSetCounter: integer; + end; + + +TTestCaseParamProcessor = class + public + FMethod: TRttiMethod; + FStringToParse: string; + FParseResult: TTestCaseParamProcessorStatus; + FParams: IList2; + constructor Create( Method1: TRttiMethod; const StringToParse1: string); + constructor CreateSimple( Method1: TRttiMethod); + procedure Parse; + procedure Invoke( Obj: TObject); + private + procedure ParseOneParam; + function ParseName( var sParamName: string): boolean; + function FindParamIndex( const sParamName: string; var Idx: integer): boolean; + function ParseEquals: boolean; + function ParseOpenQuote( var sQuoteChar: string): boolean; + function ParseValue( const sQuoteChar: string; Idx: integer; var ParamValue: TValue): boolean; + function ParseCloseQuote( const sQuoteChar: string): boolean; + end; + + +implementation + + + + + + + + +uses Generics.Collections, SysUtils, TypInfo, SBD.Utils.XML2, Math, + SBD.Messages.Solution, DUnitM.TestCaseRound; + +constructor TTestCaseParamProcessor.CreateSimple( Method1: TRttiMethod); +begin +FMethod := Method1; +FStringToParse := ''; +FParseResult := psDone; +FParams := TList2.Create +end; + + +constructor TTestCaseParamProcessor.Create( + Method1: TRttiMethod; const StringToParse1: string); +var + Params: TArray; + Param: TRttiParameter; + ParamRec: RTestCaseParamDatum; + idx: integer; + RequireFlags: TParamFlags; + RequireType: TList; + Ok: boolean; + +begin +FMethod := Method1; +FStringToParse := StringToParse1; +FParseResult := psMore; +FParams := TList2.Create; +Params := FMethod.GetParameters; +Ok := True; +RequireType := TList.Create; +for idx := 0 to Length( Params) - 1 do + begin + Param := Params[ idx]; + ParamRec.FParam := Param; + RequireFlags := []; + RequireType.Clear; + case Param.ParamType.TypeKind of + tkInteger : RequireFlags := []; + tkUString : RequireFlags := [pfConst]; + tkFloat : begin + RequireFlags := []; + RequireType.Add( TypeInfo( TDateTime)); + RequireType.Add( TypeInfo( Double)); + end; + tkEnumeration: begin + RequireFlags := []; + RequireType.Add( TypeInfo( boolean)) + end + else Ok := False + end; + Ok := Ok and (Param.Flags = RequireFlags) and + ((RequireType.Count = 0) or (RequireType.IndexOf( Param.ParamType.Handle) <> -1)); + if not Ok then break; + ParamRec.FSetCounter := 0; + FParams.Add( ParamRec) + end; +RequireType.Free; +if not Ok then + FParseResult := psSyntaxError +end; + +procedure TTestCaseParamProcessor.Invoke( Obj: TObject); +var + Args: array of TValue; + iParam: integer; + Ok: Boolean; + Kind: TTypeKind; + +begin +SetLength( Args, FParams.Count); +for iParam := 0 to FParams.Count - 1 do + begin + Args[ iParam] := FParams[ iParam].FActualValue; + Ok := not FParams[ iParam].FActualValue.IsEmpty; + Kind := FParams[ iParam].FActualValue.Kind + end; +FMethod.Invoke( Obj, Args) +end; + +procedure TTestCaseParamProcessor.Parse; +var + ParamRec: RTestCaseParamDatum; +begin +while FParseResult = psMore do + ParseOneParam; +for ParamRec in FParams do + if ParamRec.FSetCounter <> 1 then + FParseResult := psSyntaxError +end; + +function TTestCaseParamProcessor.FindParamIndex( + const sParamName: string; var Idx: integer): boolean; +var + ParamRec: RTestCaseParamDatum; +begin +result := False; +Idx := -1; +for ParamRec in FParams do + begin + Inc( Idx); + result := SameText( ParamRec.FParam.Name, sParamName); + if result then break + end; +if not result then + FParseResult := psSyntaxError +end; + + +procedure TTestCaseParamProcessor.ParseOneParam; +var + ParamRec: RTestCaseParamDatum; + Idx: integer; + ParamValue: TValue; + sParamName: string; + sQuoteChar: string; +begin +if FParseResult = psSyntaxError then exit; +FStringToParse := Trim( FStringToParse); +if FStringToParse = '' then + begin + FParseResult := psDone; + exit + end; +if ParseName( sParamName) and + FindParamIndex( sParamName, Idx) and + ParseEquals and + ParseOpenQuote( sQuoteChar) and + ParseValue( sQuoteChar, Idx, ParamValue) and + ParseCloseQuote( sQuoteChar) and + (FParseResult <> psSyntaxError) then + begin + ParamRec := FParams[ Idx]; + ParamRec.FActualValue := ParamValue; + Inc( ParamRec.FSetCounter); + FParams[ Idx] := ParamRec + end +end; + +function TTestCaseParamProcessor.ParseOpenQuote( + var sQuoteChar: string): boolean; +begin +sQuoteChar := Copy( FStringToParse, 1, 1); +result := (sQuoteChar = '"') or (sQuoteChar = ''''); +Delete( FStringToParse, 1, 1); +if not result then + FParseResult := psSyntaxError +end; + +function TTestCaseParamProcessor.ParseCloseQuote( + const sQuoteChar: string): boolean; +begin +result := Copy( FStringToParse, 1, 1) = sQuoteChar; +Delete( FStringToParse, 1, 1); +if not result then + FParseResult := psSyntaxError +end; + +function TTestCaseParamProcessor.ParseEquals: boolean; +begin +result := Copy( FStringToParse, 1, 1) = '='; +Delete( FStringToParse, 1, 1); +if not result then + FParseResult := psSyntaxError +end; + +function TTestCaseParamProcessor.ParseName( var sParamName: string): boolean; +var + iCh: integer; + ParseLen, ValueLen: integer; +begin +iCh := 0; +ParseLen := Length( FStringToParse); +ValueLen := ParseLen; +while iCh <= (ParseLen - 1) do + begin + Inc( iCh); + if Copy( FStringToParse, iCh, 1) <> '=' then continue; + ValueLen := iCh - 1; + break + end; +sParamName := Copy( FStringToParse, 1, ValueLen); +Delete( FStringToParse, 1, ValueLen); +result := sParamName <> ''; +if not result then + FParseResult := psSyntaxError +end; + + +type +TSubparserClass = class of TSubparser; +TSubparser = class + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; virtual; abstract; + end; + +TIntegerSubparser = class( TSubparser) + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; override; + end; + +TBooleanSubparser = class( TSubparser) + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; override; + end; + +TStringSubparser = class( TSubparser) + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; override; + end; + +TDoubleSubparser = class( TSubparser) + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; override; + end; + +TDateTimeSubparser = class( TSubparser) + public + function Parse( const sValue: string; var ParamValue: TValue): boolean; override; + end; + + +function TTestCaseParamProcessor.ParseValue( + const sQuoteChar: string; Idx: integer; var ParamValue: TValue): boolean; +type + RSubparserMap = record + TypeKind: TTypeKind; + SubParser: TSubparserClass; + end; +const + SubParsers: array[0..3] of RSubparserMap = ( + (TypeKind: tkInteger ; SubParser: TIntegerSubparser), + (TypeKind: tkFloat ; SubParser: TDoubleSubparser), + (TypeKind: tkUString ; SubParser: TStringSubparser), + (TypeKind: tkEnumeration; SubParser: TBooleanSubparser)); +var + Key: TTypeKind; + Cls: TSubparserClass; + I: integer; + SubParser: TSubparser; + sUnescaped: string; + iCh: integer; + QuotLen: integer; + ParseLen: integer; + ValueLen: integer; +begin +QuotLen := Length( sQuoteChar); +iCh := 0; +ParseLen := Length( FStringToParse); +ValueLen := ParseLen; +while iCh <= (ParseLen - 1) do + begin + Inc( iCh); + if Copy( FStringToParse, iCh, QuotLen) <> sQuoteChar then continue; + if Copy( FStringToParse, iCh + QuotLen, QuotLen) = sQuoteChar then + Inc( iCh, 2 * QuotLen - 1) + else + begin + ValueLen := iCh - 1; + break + end; + end; +sUnescaped := StringReplace( Copy( FStringToParse, 1, ValueLen), sQuoteChar+sQuoteChar, sQuoteChar, [rfReplaceAll]); +Delete( FStringToParse, 1, ValueLen); +Key := FParams[ Idx].FParam.ParamType.TypeKind; +Cls := nil; +for i := Low( Subparsers) to High( Subparsers) do + begin + if Subparsers[i].TypeKind <> Key then Continue; + Cls := Subparsers[i].SubParser; + break + end; +if (Cls = TDoubleSubparser) and (FParams[ Idx].FParam.ParamType.Handle = TypeInfo( TDateTime)) then + Cls := TDateTimeSubparser; +SubParser := Cls.Create; +result := SubParser.Parse( sUnescaped, ParamValue); +SubParser.Free; +if not result then + FParseResult := psSyntaxError +end; + + +function TIntegerSubparser.Parse( + const sValue: string; var ParamValue: TValue): boolean; +var + i64: int64; + i32: integer; +begin +result := Txs_integer.Decode( sValue, i64); +i32 := integer( i64); +result := result and (int64( i32) = i64); +ParamValue := i32 +end; + + +function TBooleanSubparser.Parse( + const sValue: string; var ParamValue: TValue): boolean; +begin +result := sValue <> ''; +ParamValue := Txs_boolean.Decode( sValue, False) +end; + + +function TStringSubparser.Parse( + const sValue: string; var ParamValue: TValue): boolean; +begin +result := True; +ParamValue := sValue +end; + + +function TDoubleSubparser.Parse( const sValue: string; + var ParamValue: TValue): boolean; +var + Dub: double; +begin +result := Txs_float.Decode( sValue, Dub); +ParamValue := Dub +end; + + +function TDateTimeSubparser.Parse( + const sValue: string; var ParamValue: TValue): boolean; +var + Decoded: TDateTime; + bIncludeTZ: boolean; + TZMinutes: integer; + Ok: boolean; + X: TValue; +begin +result := Txs_dateTime.Decode( sValue, Decoded, bIncludeTZ, TZMinutes) and + (not bIncludeTZ); +// The following commented-out line appears not be working in D2010. +// ParamValue.From( Decoded); +// So this is the work-around ... +TValue.Make( @Decoded, System.TypeInfo( TDateTime), ParamValue); +Ok := not ParamValue.IsEmpty; +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseRound.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseRound.pas new file mode 100644 index 0000000..f49d8f6 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestCaseRound.pas @@ -0,0 +1,497 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestCaseRound; +interface +uses SBD.Messages, DUnitM.UnitTestFramework, SysUtils, DUnitM.MemoryMonitor, + SBD.Generics, DUnitM.TestNode, DUnitM.RunInstance; + +type + + + +TTestCaseRound_RunInstance = class( TTestNode_RunInstance, ICheckGateway) + private + FCheckCount: Integer; + FRoundsCompleted: integer; + FErrorCount: integer; + FPassCount: integer; + FFailCount: integer; + FWarnCount: integer; + FExecutionMessages: IMessageList; + FMessages: IMessageList; + FTestCase: ITestCaseInternal; + FTestBed: TObject; + FRoundNumber: integer; + FCursor: ITestCaseLineCursoredItem; + FAbortedAfterSetup: boolean; + doSetGateway: boolean; + Fctry: IPlatterFactory; + + private + procedure Check; + procedure Pass; + procedure Fail( const sErrMsg: string; Address: pointer); + procedure Warn( const sWarning: string); + + protected + procedure Clear; override; + function WorkLoad: integer; override; + function HasMessageList( var Lst: IMessageList): boolean; override; + function TestNode: ITestNode; override; + function RoundsCompleted: integer; override; + function RoundsPerTestCase: integer; override; + function ErrorCount: integer; override; + function PassCount: integer; override; + function FailCount: integer; override; + function WarnCount: integer; override; + function TestCase: ITestCase; override; + function IgnoredCount: integer; override; + function SkippedCount: integer; override; + function NodeKind: TResultNodeKind; override; + procedure BeforeRun; override; + procedure DoInnerRun; override; + procedure CleanUpAfterRun; override; + function Description: string; override; + + private + procedure ClearHeapMonitoring; + function LeakageDetected( var Leakage: int64): boolean; + procedure ActivateHeapMonitoring( TurnOn: Boolean); + procedure Setup; + procedure Execute; + procedure TearDown; + + protected + // function RowDescription: string; virtual; + procedure RawExecute; virtual; + + public + constructor Create( + ParentAsObject: TReflector; TestBed: TObject; + const Case1: ITestCaseInternal; RoundNumber1: integer; + const Mem1: IMemoryMonitor; const Cursor: ITestCaseLineCursoredItem); + end; + +implementation + + + + + +uses SBD.Messages.Solution; + + +constructor TTestCaseRound_RunInstance.Create( + ParentAsObject: TReflector; TestBed: TObject; + const Case1: ITestCaseInternal; RoundNumber1: integer; + const Mem1: IMemoryMonitor; const Cursor: ITestCaseLineCursoredItem); +begin +FMessages := TMessageList.Create; +FExecutionMessages := TMessageList.Create; +inherited Create( ParentAsObject, Mem1); +FRoundNumber := RoundNumber1; +FTestCase := Case1; +FTestBed := TestBed; +FCursor := Cursor +end; + +procedure TTestCaseRound_RunInstance.Clear; +begin +inherited; +FCheckCount := 0; +FRoundsCompleted := 0; +FErrorCount := 0; +FPassCount := 0; +FFailCount := 0; +FWarnCount := 0; +FMessages.Clear; +FExecutionMessages.Clear; +FAbortedAfterSetup := False +end; + + +procedure TTestCaseRound_RunInstance.ActivateHeapMonitoring( TurnOn: Boolean); +begin +if not assigned( FMem) then exit; +if TurnOn then + FMem.HeapMonitoring_ON + else + FMem.HeapMonitoring_OFF +end; + +procedure TTestCaseRound_RunInstance.BeforeRun; +begin +doSetGateway := Supports( Fixture, IPlatterFactory, Fctry) and assigned( FTestBed); +if doSetGateway then + Fctry.SetGateway( FTestBed, self) +end; + +procedure TTestCaseRound_RunInstance.Check; +begin +Inc( FCheckCount) +end; + +procedure TTestCaseRound_RunInstance.CleanUpAfterRun; +begin +FCursor := nil; +FTestBed := nil +end; + +procedure TTestCaseRound_RunInstance.ClearHeapMonitoring; +begin +if assigned( FMem) then + FMem.Clear +end; + +procedure TTestCaseRound_RunInstance.DoInnerRun; +begin +Setup; +if GetStatus = tsExecuting then + Execute; +if GetStatus = tsTeardown then + Teardown; +FRoundsCompleted := 1; +if doSetGateway then + Fctry.SetGateway( FTestBed, nil); +if FFailCount > 0 then + Status := tsFail + else if FWarnCount > 0 then + Status := tsWarn + else if FAbortedAfterSetup then + Status := tsSkipped + else + begin + Inc( FPassCount); + Status := tsPass + end +end; + +function TTestCaseRound_RunInstance.ErrorCount: integer; +begin +result := FErrorCount +end; + +procedure TTestCaseRound_RunInstance.Execute; +var + Ok: boolean; + sFail: string; + Msg: RMessage; + Code: integer; + + procedure Call_Execute; + begin + try + RawExecute + except on E: ETestPass do + Inc( FCheckCount) + end; + end; + +begin +Code := 0; +if FRunInstanceServices.IsAborted then + FAbortedAfterSetup := True + else + begin + try + ActivateHeapMonitoring( True); + Call_Execute; + ActivateHeapMonitoring( False); + Ok := True + except + on E: ETestFailure do + begin + Ok := False; + sFail := E.Message; + Code := TestFailure; + end; + on E: Exception do + begin + Ok := False; + Code := TestException; + sFail := Format( 'Test case failed because of unexpected exception %s: %s', [E.ClassName, E.Message]) + end; + end; + UniqueCloneList( FExecutionMessages, FMessages); + ActivateHeapMonitoring( True); + FExecutionMessages.Clear; + ActivateHeapMonitoring( False); + if Ok and (FCheckCount = 0) then + begin + Ok := False; + sFail := 'Test case failed because no assertions were made.'; + Code := NoChecks; + end; + if not Ok then + begin + Inc( FFailCount); + PutSimpleMessage( Code, sFail, lvError) + end; + if assigned( FRunInstanceServices) then + for Msg in FMessages.AsSource( [lvWarning]) do + begin + Inc( FWarnCount, 1); + FRunInstanceServices.Put( self, FTestCase as ITestNode, Msg, FRoundsCompleted); + end + end; +FExecuted := True; +Status := tsTeardown +end; + +procedure TTestCaseRound_RunInstance.Fail( const sErrMsg: string; Address: pointer); +begin +if GetStatus = tsExecuting then + raise ETestFailure.Create( sErrMsg) at Address + else + raise Exception.Create( 'Assert called outside of the test case. ' + sErrMsg) +end; + +function TTestCaseRound_RunInstance.FailCount: integer; +begin +result := FFailCount +end; + +function TTestCaseRound_RunInstance.HasMessageList( var Lst: IMessageList): boolean; +begin +result := True; +Lst := FMessages +end; + +function TTestCaseRound_RunInstance.IgnoredCount: integer; +begin +result := 0 +end; + +function TTestCaseRound_RunInstance.LeakageDetected( var Leakage: int64): boolean; +begin +result := assigned( FMem); +if result then + begin + Leakage := FMem.Leakage; + result := Leakage <> 0 + end + else + Leakage := 0 +end; + +function TTestCaseRound_RunInstance.NodeKind: TResultNodeKind; +begin +result := rnTestCaseRound +end; + +procedure TTestCaseRound_RunInstance.Pass; +begin +if FStatus = tsExecuting then + raise ETestPass.Create( 'Pass') + else + raise Exception.Create( 'Assert called outside of the test case.') +end; + +function TTestCaseRound_RunInstance.PassCount: integer; +begin +result := FPassCount +end; + +procedure TTestCaseRound_RunInstance.RawExecute; +begin +if assigned( FCursor) then + FCursor.ConductTest + else + FTestCase.Execute( FTestBed) +end; + +function TTestCaseRound_RunInstance.RoundsCompleted: integer; +begin +result := FRoundsCompleted +end; + +function TTestCaseRound_RunInstance.RoundsPerTestCase: integer; +begin +result := 1 +end; + +function TTestCaseRound_RunInstance.Description: string; +begin +if assigned( FCursor) then + result := FCursor.LineItemDescription + else + result := '(none)' +end; + +procedure TTestCaseRound_RunInstance.Setup; +var + Ok: boolean; + sErr: string; + Msg: RMessage; + + procedure Call_Setup; + begin + (FTestCase.Parent.Parent as ITestFixtureInternal).Setup( FTestBed) + end; + +begin +Status := tsSetup; +ClearHeapMonitoring; +try + ActivateHeapMonitoring( True); + Call_Setup; + ActivateHeapMonitoring( False); + Ok := True + except on E: Exception do + begin + Ok := False; + sErr := E.Message + end + end; +if Ok then + Status := tsExecuting + else + begin + Inc( FErrorCount); + PutSimpleMessage( SetupError, sErr, lvError); + Status := tsError + end +end; + +function TTestCaseRound_RunInstance.SkippedCount: integer; +begin +if GetStatus = tsSkipped then + result := 1 + else + result := 0 +end; + +procedure TTestCaseRound_RunInstance.TearDown; +var + Ok: boolean; + sErr, sFail: string; + Leakage: int64; + + procedure Call_Teardown; + begin + (FTestCase.Parent.Parent as ITestFixtureInternal).Teardown( FTestBed) + end; + +begin +try + ActivateHeapMonitoring( True); + Call_Teardown; + ActivateHeapMonitoring( False); + Ok := True +except on E: Exception do + begin + Ok := False; + sErr := E.Message + end + end; +if Ok then + begin + if LeakageDetected( Leakage) and (not TestCase.Parent.IgnoreLeaks) and + (FErrorCount = 0) and (FFailCount = 0) then + begin + Ok := False; + sFail := Format( 'Memory leakage detected %d. bytes lost', [Leakage]); + Inc( FFailCount); + PutSimpleMessage( LeakageFailure, sFail, lvError) + end + end + else + begin + Inc( FErrorCount); + PutSimpleMessage( TearDownError, sErr, lvError); + Status := tsError + end +end; + +function TTestCaseRound_RunInstance.TestCase: ITestCase; +begin +result := FTestCase +end; + +function TTestCaseRound_RunInstance.TestNode: ITestNode; +begin +result := FTestCase as ITestNode +end; + +procedure TTestCaseRound_RunInstance.Warn( const sWarning: string); +var + Msg: RMessage; +begin +SetFrameworkMessage( Msg, UserIssuedWarning, sWarning, lvWarning); +FExecutionMessages.Add( Msg) +end; + +function TTestCaseRound_RunInstance.WarnCount: integer; +begin +result := FWarnCount +end; + +function TTestCaseRound_RunInstance.WorkLoad: integer; +begin +result := 1 +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestNode.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestNode.pas new file mode 100644 index 0000000..53bd908 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestNode.pas @@ -0,0 +1,494 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestNode; +interface +uses SBD.Messages, DUnitM.UnitTestFramework, SysUtils, DUnitM.MemoryMonitor, + SBD.Generics, Generics.Collections, Rtti, SBD.ServiceProvider; +type + +ITestNode = interface; +IRunInstance = interface; +IRunInstanceServices = interface + ['{E234CF36-9AD7-46A2-A542-688BC0C939D1}'] + procedure StatusChange( const Source: IRunInstance; const Changee: ITestNode; const Round: integer); + // Round=-1 for testcase results and above. + procedure Put( const Source: IRunInstance; const Node: ITestNode; const Msg: RMessage; const Round: integer); + function IsAborted: boolean; + end; +TStatusInformerProc = reference to procedure( Value: TTestStatus); +IRunInstance = interface( ITestResult) + ['{69870E86-AE6A-42D0-8992-052674A45E4A}'] + procedure Run( + const RunInstanceServices: IRunInstanceServices; + OnStatusChangeProc: TStatusInformerProc); + procedure Clear; + function Parent: IRunInstance; + function WorkLoad: integer; + function TestNode: ITestNode; + function ChildInstances: IList2; + function Description: string; + end; + +IFixtureRunInstance = interface + ['{35624EEC-A6ED-4287-9B16-16FD4D921394}'] + function MakeProcedureRunInstance( const TestProc: ITestProcedure): IRunInstance; + function MakeFixtureRunInstance( const Fixture: ITestFixture): IRunInstance; + end; + +ICheckGateway = interface + ['{8CF6F0D4-3768-4E69-97F0-E86AC79EC99D}'] + procedure Check; + procedure Pass; + procedure Fail( const sErrMsg: string; Address: pointer); + procedure Warn( const sWarning: string); + end; + +ETestFrameworkException = class( Exception); +EAbort = class( ETestFrameworkException); +ETestFailure = class( EAbort); +ETestPass = class( EAbort); + +TGetObjectFunc = reference to function: TObject; + +PReflector = ^TReflector; +TReflector = class + public + FController: TObject; + FWeakReferences: TList; + constructor Create( Controller: TObject); + destructor Destroy; override; + procedure SetWeakReference( var Ref: TReflector); + procedure ClearWeakReference( var Ref: TReflector); + end; + +ITestCaseInternal = interface( ITestCase) + ['{4F6B72EA-F054-473E-9DD0-5CB8AC295DB5}'] + procedure ShutDown; + function RequiresPreliminaryLoadCount: boolean; + procedure SetDeferredError( const ErMsg: string); + function GetDeferredError( var ErMsg: string): boolean; + procedure Execute( Platter: TObject); + function EstimateRoundCount: integer; + function MakeRunInstance( ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; + end; + +IRunnerExecutiveServices = interface + ['{77943668-0977-4B68-92B0-732709CCEEB3}'] + procedure EnterLeaveRunners( Delta: integer); + function Suite: ITestSuite; + procedure OnBeginRunInstance( const Instance: IRunInstance; Workload: integer); + procedure OnEndRunInstance( const Instance: IRunInstance; const RunResult: ITestResult); + function IsAborted: boolean; + procedure OnChangeStatus( + NodeKind: TLoggerNode; + const Fixture: ITestFixture; + const TestProc: ITestProcedure; + const TestCase: ITestCase; + const TestResult: ITestResult); + procedure OnAuxilaryMessage( const Node: ITestNode; const TestResult: ITestResult; const TestCase: ITestCase; const Msg: RMessage; Round: integer); + end; + +ITestNode = interface + ['{D92D4093-EF1D-4FBE-A54B-473FD2747006}'] + procedure AttachViewDatum( const Logger: ITestLogger; const ViewDatum: IInterface); + function ViewDatumOfLogger( const Logger: ITestLogger): IInterface; + function NodeKind: TResultNodeKind; + procedure ShutDown; + function Name: string; + function Description: string; + function ParentNode: ITestNode; + function NodeChildren: ISEnumerable; + function Load: integer; + function AsObject: TReflector; + function HasEnabledTestCases: boolean; + end; + +IFixtureChild = interface + ['{69387C5A-FE24-4548-B071-45307DF69E91}'] + function MakeRunInstanceOfFixtureChild( const ParentFixture: IRunInstance; var Addend: IRunInstance): boolean; + end; + +IShutDown = interface + ['{1A2A2FB1-C87B-4B6F-8708-4BB4F6FE690D}'] + procedure ShutDown; + end; + +IRunInstances = interface( IList2) + ['{837F57D3-E844-4653-91EF-BF99A31600C3}'] + procedure Reset; + end; + + +ITestCaseLineCursoredItem = interface + ['{47DA010A-1BD4-49AC-989E-0CC842D3E639}'] + function Next: boolean; + function LineItemDescription: string; + procedure ConductTest; + end; + + + +IDataDrivenTestCase = interface( ITestCaseInternal) + ['{7E491901-1F50-4FA9-9E56-51927772D738}'] + function AcquireDataDriver ( Platter: TObject): IDataDrivenTestCaseNavigator; + function OpenLineItemTestCursor( Platter: TObject): ITestCaseLineCursoredItem; + end; + +ITestCasesInternal = interface( IList2) + ['{9041FD2C-5248-4DDD-93D5-14BC7B05CEC1}'] + function AddCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestCaseAttribute): ITestCaseInternal; + function AddDataDrivenCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TDataDrivenTestAttributeBase): ITestCaseInternal; + function AddSimpleCase( ProcParentAsObject: TReflector; ProcType: TRttiMethod; Attri: TestAttribute): ITestCaseInternal; + function isDataDriven( ProcParentAsObject: TReflector; ProcType: TRttiMethod; var DDTestCaseFactory: IDataDrivenTestCaseFactory): boolean; + function AddByFactory( const Fact: IDataDrivenTestCaseFactory): ITestCaseInternal; + procedure ShutDown; + end; + +TTestNode = class abstract( TInterfacedObject, ITestNode, IShutDown) + protected + FParent: TReflector; // weak reference to parent, with ARC. + FWeakClients: TReflector; + FViewTokens: TDictionary; + + function ViewDatumOfLogger( const Logger: ITestLogger): IInterface; + procedure AttachViewDatum( const Logger: ITestLogger; const ViewDatum: IInterface); virtual; + function NodeKind: TResultNodeKind; virtual; abstract; + procedure ShutDown; virtual; + function Name: string; virtual; abstract; + function ParentNode: ITestNode; virtual; + function NodeChildren: ISEnumerable; virtual; abstract; + function Load: integer; virtual; abstract; + function AsObject: TReflector; virtual; + function HasEnabledTestCases: boolean; virtual; + function Description: string; virtual; + + public + constructor CreateTestNode( ParentAsObject: TReflector); + destructor Destroy; override; + end; + +TRunInstances = class( TList2, IRunInstances) + private + procedure Reset; + end; + +TTestResults = class( TList2) + public + constructor CreateCastFrom( Source: IRunInstances); + end; + +ITestNodes = interface( IList2) + ['{0C592110-ACF3-425C-BF6E-C09B5C2C166D}'] + end; + +TTestNodes = class( TList2, ITestNodes) + end; + +ITestFixtureInternal = interface( ITestFixture) + ['{6D6DD812-1CE5-41CC-A0CA-AE5BB525D321}'] + function AsObject: TReflector; + function PreliminaryPlatterObject: TObject; + procedure Setup( Platter: TObject); + procedure Teardown( Platter: TObject); + function MakeRunInstance( ParentRunInstance: TReflector; const Mem1: IMemoryMonitor): IRunInstance; + end; + +IPlatterFactory = interface + ['{1B77577F-0CC9-43AE-A5AF-37D46C541FC8}'] + function CreatePlatter( var Hold: IInterface): TObject; + procedure ReleasePlatter( var Hold: IInterface; var Obj: TObject); + procedure SetGateway( TestBed1: TObject; const Gateway: ICheckGateway); + end; + +ITestProcedureInternal = interface( ITestProcedure) + ['{6D6DD812-1CE5-41CC-A0CA-AE5BB525D321}'] + function AsObject: TReflector; + procedure ShutDown; + function MakeRunInstance( ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; + function DeclaredMethodSkips: integer; + end; + +ITestNodeFactory = interface + ['{6FC8CB4D-652E-4196-8C8D-81230CDC9CA7}'] + function GetParentAsObject: TReflector; + procedure SetParentAsObject( Value: TReflector); + + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; + property ParentAsObject: TReflector read GetParentAsObject write SetParentAsObject; + end; + +IProceduresInternal = interface( IList2) + ['{EAB481FC-5C86-4F93-9304-FC5B6509A113}'] + function AddProcedure( const Factory: ITestNodeFactory; Method: TRttiMethod; FixtureType: TRttiType): ITestProcedureInternal; + procedure ShutDown; + end; + + + +TBaseNodeFactory = class abstract( TInterfacedObject, ITestNodeFactory) + protected + FParentAsObject: TReflector; + [Injection] FServices: IServiceProvider; + + function GetParentAsObject: TReflector; virtual; + procedure SetParentAsObject( Value: TReflector); virtual; + + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; virtual; abstract; + end; + +procedure SetFrameworkMessage( + var Msg: RMessage; MessageCode: integer; const Text: string; Lv: TMessageLevel); + +implementation + + + + + + + + + + + + + + + +constructor TReflector.Create( Controller: TObject); +begin +FController := Controller; +FWeakReferences := TList.Create +end; + +destructor TReflector.Destroy; +var + Client: PReflector; +begin +for Client in FWeakReferences do + Client^ := nil; +FWeakReferences.Free; +inherited +end; + +procedure TReflector.ClearWeakReference( var Ref: TReflector); +begin +FWeakReferences.Remove( @Ref); +Ref := nil +end; + +procedure TReflector.SetWeakReference( var Ref: TReflector); +begin +if Ref = self then exit; +ClearWeakReference( Ref); +FWeakReferences.Add( @Ref); +Ref := self +end; + + + + +constructor TTestNode.CreateTestNode( ParentAsObject: TReflector); +begin +if assigned( ParentAsObject) then + ParentAsObject.SetWeakReference( FParent); +FWeakClients := TReflector.Create( self); +FViewTokens := TDictionary.Create +end; + +function TTestNode.Description: string; +begin +result := Name +end; + +destructor TTestNode.Destroy; +begin +ShutDown; +if assigned( FParent) then + FParent.ClearWeakReference( FParent); +FWeakClients.Free; +FViewTokens.Free; +inherited; +end; + +function TTestNode.HasEnabledTestCases: boolean; +var + Child: ITestNode; +begin +result := False; +for Child in NodeChildren do + result := result or Child.HasEnabledTestCases +end; + +function TTestNode.AsObject: TReflector; +begin +result := FWeakClients +end; + +procedure TTestNode.AttachViewDatum( + const Logger: ITestLogger; const ViewDatum: IInterface); +var + Current: IInterface; +begin +if FViewTokens.ContainsKey( Logger) then + Current := FViewTokens[ Logger] + else + Current := nil; +if ViewDatum = Current then exit; +if assigned( ViewDatum) and assigned( Current) then + FViewTokens[ Logger] := ViewDatum + else if assigned( Current) then + FViewTokens.Remove( Logger) + else + FViewTokens.Add( Logger, ViewDatum) +end; + + + + +function TTestNode.ParentNode: ITestNode; +begin +if (not assigned( FParent)) or + (not Supports( FParent.FController, ITestNode, result)) then + result := nil +end; + +procedure TTestNode.ShutDown; +var + Child: ITestNode; +begin +FViewTokens.Clear; +for Child in NodeChildren do + Child.ShutDown +end; + + +function TTestNode.ViewDatumOfLogger( const Logger: ITestLogger): IInterface; +begin +if FViewTokens.ContainsKey( Logger) then + result := FViewTokens[ Logger] + else + result := nil +end; + + + +constructor TTestResults.CreateCastFrom( Source: IRunInstances); +var + Run: IRunInstance; +begin +inherited Create; +for Run in Source do + Add( Run as ITestResult) +end; + + + + + + +procedure TRunInstances.Reset; +var + Child: IRunInstance; +begin +for Child in (Self as IList2) do + Child.Clear +end; + +procedure SetFrameworkMessage( + var Msg: RMessage; MessageCode: integer; const Text: string; Lv: TMessageLevel); +begin +Msg.FMessageURL.FURL := DUnixtM_Framework_URL; +Msg.FMessageURL.FPrefix := DUnixtM_Framework_Prefix; +Msg.FMessageCode := MessageCode; +Msg.FDisplayText := Text; +Msg.FLevel := Lv; +Msg.FStamp := Now; +SetLength( Msg.FData, 0) +end; + + +{ TBaseNodeFactory } + +function TBaseNodeFactory.GetParentAsObject: TReflector; +begin +result := FParentAsObject +end; + +procedure TBaseNodeFactory.SetParentAsObject( Value: TReflector); +begin +FParentAsObject := Value +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestProcedure.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestProcedure.pas new file mode 100644 index 0000000..f28e2a1 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestProcedure.pas @@ -0,0 +1,419 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestProcedure; +interface +uses DUnitM.TestNode, Rtti, SBD.Generics, DUnitM.MemoryMonitor, DUnitM.UnitTestFramework, + SBD.ServiceProvider; + +type +TProcedureList = class ( TList2, IProceduresInternal, IShutDown) + public + function AddProcedure( const Factory: ITestNodeFactory; Method: TRttiMethod; FixtureType: TRttiType): ITestProcedureInternal; + procedure ShutDown; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + +uses DUnitM.RttiUtils, SysUtils, TypInfo, SBD.Messages, DUnitM.TestCase, + SBD.Messages.Solution, DUnitM.RunInstance; + +type +TProcedureFactory = class sealed( TBaseNodeFactory) + protected + function MakeNode( const NodeName: string; + Method: TRttiMethod; + FixtureType: TRttiType; + TestCaseAttri: TDUnitXAttributeBase + ): ITestNode; override; + public + [Configuration('rnTestProc')] constructor ServiceModeCreate; + + private type + TTestProcedure = class( TTestNode, ITestProcedure, ITestProcedureInternal, IFixtureChild) + private + FTestMeth: TRttiMethod; + FCases: ITestCasesInternal; + FIgnoreMemoryLeaks: boolean; + FIgnore: boolean; + FIgnoreReason: string; + FDefaultEnabled: boolean; + FDescription: string; + FName: string; + FRepeats: integer; + FSkips: integer; + + function Parent: ITestFixture; + function TestCases: ISEnumerable; + function RepeatCount: integer; + function Description: string; + function GetDefaultEnabled: boolean; + function IsIgnored( var IgnoreReason: string): boolean; + function MakeRunInstance( ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; + function IgnoreLeaks: boolean; + function DeclaredMethodSkips: integer; + + // IFixtureChild + function MakeRunInstanceOfFixtureChild( const ParentFixture: IRunInstance; var Addend: IRunInstance): boolean; + + protected + function NodeKind: TResultNodeKind; override; + procedure ShutDown; override; + function Name: string; override; + function NodeChildren: ISEnumerable; override; + function Load: integer; override; + end; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( ITestNodeFactory, TProcedureFactory); + +end; + + +function TProcedureFactory.TTestProcedure.DeclaredMethodSkips: integer; +begin +result := FSkips +end; + +function TProcedureFactory.TTestProcedure.Description: string; +begin +result := FDescription +end; + +function TProcedureFactory.TTestProcedure.GetDefaultEnabled: boolean; +begin +result := FDefaultEnabled +end; + +function TProcedureFactory.TTestProcedure.IgnoreLeaks: boolean; +begin +result := FIgnoreMemoryLeaks +end; + +function TProcedureFactory.TTestProcedure.IsIgnored( var IgnoreReason: string): boolean; +begin +result := FIgnore; +IgnoreReason := FIgnoreReason +end; + +function TProcedureFactory.TTestProcedure.Load: integer; +var + TestCase: ITestCase; +begin +result := 0; +for TestCase in TestCases do + if TestCase.Enabled then + inc( result, TestCase.Load) +end; + +function TProcedureFactory.TTestProcedure.Name: string; +begin + result := FName +end; + +function TProcedureFactory.TTestProcedure.NodeChildren: ISEnumerable; +var + Accumulator: ITestNodes; + TestCase: ITestCase; +begin + Accumulator := TTestNodes.Create; + result := Accumulator; + for TestCase in TestCases do + Accumulator.Add( TestCase as ITestNode) +end; + +function TProcedureFactory.TTestProcedure.NodeKind: TResultNodeKind; +begin + result := rnTestProc +end; + +function TProcedureFactory.TTestProcedure.Parent: ITestFixture; +begin + result := ParentNode as ITestFixture +end; + +function TProcedureFactory.TTestProcedure.RepeatCount: integer; +begin + result := FRepeats +end; + +procedure TProcedureFactory.TTestProcedure.ShutDown; +begin + inherited; + FCases.ShutDown +end; + +function TProcedureFactory.TTestProcedure.TestCases: ISEnumerable; +begin + result := FCases +end; + +function TProcedureList.AddProcedure( + const Factory: ITestNodeFactory; Method: TRttiMethod; FixtureType: TRttiType): ITestProcedureInternal; +begin + result := Factory.MakeNode( '', Method, FixtureType, nil) as ITestProcedureInternal; + Add( result as ITestProcedure) +end; + + +procedure TProcedureList.ShutDown; +var + Proc: ITestProcedure; + Shut: IShutdown; +begin + for Proc in (self as IProceduresInternal) do + if Supports( Proc, IShutdown, Shut) then + Shut.ShutDown +end; + +type +TProcedure_RunInstance = class( TTestNode_RunInstanceWithChildren) + private + FTestBed: TGetObjectFunc; + FTestProc: ITestProcedureInternal; + + protected + function TestNode: ITestNode; override; + function RoundsPerTestCase: integer; override; + function Fixture: ITestFixture; override; + function NodeKind: TResultNodeKind; override; + procedure DoInnerRun; override; + + public + constructor Create( ParentAsObject: TReflector; TestBed: TGetObjectFunc; const TestProc1: ITestProcedureInternal; const Mem1: IMemoryMonitor); + end; + +function TProcedureFactory.TTestProcedure.MakeRunInstance( + ParentAsObject: TReflector; TestBed: TGetObjectFunc; const Mem1: IMemoryMonitor): IRunInstance; +begin + result := TProcedure_RunInstance.Create( ParentAsObject, TestBed, self, Mem1) +end; + +function TProcedureFactory.TTestProcedure.MakeRunInstanceOfFixtureChild( + const ParentFixture: IRunInstance; var Addend: IRunInstance): boolean; +var + FixRun: IFixtureRunInstance; +begin + result := Supports( ParentFixture, IFixtureRunInstance, FixRun); + if result then + Addend := FixRun.MakeProcedureRunInstance( self) +end; + +constructor TProcedure_RunInstance.Create( + ParentAsObject: TReflector; + TestBed: TGetObjectFunc; const TestProc1: ITestProcedureInternal; + const Mem1: IMemoryMonitor); +var + TestCase: ITestCase; +begin +inherited Create( ParentAsObject, Mem1); + FTestBed := TestBed; + FTestProc := TestProc1; + for TestCase in FTestProc.TestCases do + FChildren.Add( (TestCase as ITestCaseInternal) + .MakeRunInstance( FWeakClients, FTestBed, FMem)) +end; + +procedure TProcedure_RunInstance.DoInnerRun; +var + Child: IRunInstance; +begin + for Child in FChildren do + begin + Child.Run( FRunInstanceServices, + procedure( Value: TTestStatus) + begin + if Value in [tsSetup, tsTeardown, tsExecuting] then + Status := Value + end); + FExecuted := True; + if FStatus = tsError then break + end; + if ErrorCount > 0 then + Status := tsError + else if FailCount > 0 then + Status := tsFail + else if WarnCount > 0 then + Status := tsWarn + else if PassCount > 0 then + Status := tsPass + else + Status := tsSkipped +end; + +function TProcedure_RunInstance.Fixture: ITestFixture; +begin + result := FTestProc.Parent +end; + +function TProcedure_RunInstance.NodeKind: TResultNodeKind; +begin + result := rnTestProc +end; + +function TProcedure_RunInstance.RoundsPerTestCase: integer; +begin + result := FTestProc.Load +end; + +function TProcedure_RunInstance.TestNode: ITestNode; +begin + result := FTestProc as ITestNode +end; + + +function TProcedureFactory.MakeNode( const NodeName: string; Method: TRttiMethod; + FixtureType: TRttiType; TestCaseAttri: TDUnitXAttributeBase): ITestNode; +var + Desc: DescriptionAttribute; + TestAttri: TestAttribute; + IgnoreAttri: IgnoreAttribute; + RepeatsAttri: RepeatsAttribute; + IgnoreMemoryLeaksAttri: IgnoreMemoryLeaksAttribute; + DataDrivenTestAttri: TDataDrivenTestAttributeBase; + Addend: TTestProcedure; + TestCaseAttri2: TestCaseAttribute; + Skips: integer; + DDFactory: IDataDrivenTestCaseFactory; +begin + Addend := TTestProcedure.CreateTestNode( FParentAsObject); + result := Addend as ITestNode; + Addend.FTestMeth := Method; + Addend.FCases := TTestCaseList.Create; + Addend.FIgnoreMemoryLeaks := False; + Addend.FIgnore := False; + Addend.FIgnoreReason := ''; + Addend.FDefaultEnabled := True; + Addend.FRepeats := 1; + Addend.FName := Addend.FTestMeth.Name; + for Desc in TAttributes.Get( Method) do + begin + if Addend.FDescription <> '' then + Addend.FDescription := Addend.FDescription + #13#10; + Addend.FDescription := Addend.FDescription + Desc.FText + end; + if TAttributes.GetFirst( Addend.FTestMeth, IgnoreAttri) then + begin + Addend.FIgnore := True; + Addend.FDefaultEnabled := False; + Addend.FIgnoreReason := IgnoreAttri.FReason + end; + if TAttributes.GetFirst( Addend.FTestMeth, RepeatsAttri) then + Addend.FRepeats := RepeatsAttri.FCount; + if TAttributes.GetFirst( Addend.FTestMeth, TestAttri) then + Addend.FDefaultEnabled := TestAttri.FEnabled and (not Addend.FIgnore); + if TAttributes.GetFirst( Addend.FTestMeth, IgnoreMemoryLeaksAttri) then + Addend.FIgnoreMemoryLeaks := True; + + {$if CompilerVersion = 21.0} + try + {$ifend} + + if TAttributes.GetFirst( Addend.FTestMeth, TestCaseAttri2) then + begin + for TestCaseAttri2 in TAttributes.Get( Addend.FTestMeth) do + Addend.FCases.AddCase( Addend.FWeakClients, Addend.FTestMeth, TestCaseAttri2) + end + + else if Addend.FCases.isDataDriven( Addend.FWeakClients, Addend.FTestMeth, DDFactory) then + begin + Addend.FRepeats := DDFactory.Repeats; + Addend.FSkips := DDFactory.MethodSkips; + Addend.FName := DDFactory.Name; + Addend.FCases.AddByFactory( DDFactory) + end + + else if TAttributes.GetFirst( Addend.FTestMeth, TestAttri) then + Addend.FCases.AddSimpleCase( Addend.FWeakClients, Addend.FTestMeth, TestAttri); + + {$if CompilerVersion = 21.0} + except + begin + if TCompileInformation.BuiltWithRuntimePackages then + raise Exception.Create( + 'Due to a compiler bug in Delphi 2010, when your application is "Build with packages"=CHECKED,'#13#10 + + 'you must compile after build. To just build and then run, will result in a defective executable.'); + // NOTE: The compiler bug may also prevent this exception message being propagated, as it will + // be maksed by AV's. + end +end; + {$ifend} + + if Addend.FCases.Count = 0 then + raise Exception.Create( 'Test procedure has no valid test cases.') +end; + +constructor TProcedureFactory.ServiceModeCreate; +begin +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.dfm b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.dfm new file mode 100644 index 0000000..c3fbd5b --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.dfm @@ -0,0 +1,7 @@ +object TestSuiteVirtualTree: TTestSuiteVirtualTree + Left = 0 + Top = 0 + Width = 455 + Height = 240 + TabOrder = 0 +end diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.pas new file mode 100644 index 0000000..fe273ed --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.TestSuiteDxVirtualTree.pas @@ -0,0 +1,738 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.TestSuiteDxVirtualTree; +interface +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, DUnitM.VirtualTrees, DUnitM.ViewModel_Tree, DUnitM.UnitTestFramework, + ImgList, DUnitM.dmVirtualTreeNonVisualSupport, SBD.ServiceProvider; + +type + TTestSuiteVirtualTreeObj = class; + TTestSuiteVirtualTree = class(TFrame) + procedure TreeFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode); + procedure TreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; + Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; + var ImageIndex: Integer); + procedure TreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; + Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); + procedure TreeInitNode(Sender: TBaseVirtualTree; ParentNode, + Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); + procedure TreeChecked(Sender: TBaseVirtualTree; Node: PVirtualNode); + procedure TreeGetHint( + Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string); + + public + Tree:TVirtualStringTree; + procedure ConstructVirtualTree; + private + FObj: TTestSuiteVirtualTreeObj; + FDataModule: TdmVirtualTreeNonVisualSupport; + private const + KindImages : array[ TVisualTestSuiteNodeKind ] of integer = ( + // nkNeutral, nkTestCase, nkTestProc, nkTestFixture, nkGroup + -1, 0, 10, 1, 1); + StateImages: array[ TTestStatus] of integer = ( + // tsNeutral, tsSetup, tsTeardown, tsExecuting, tsPass, tsWarn, tsFail, tsError, tsSkipped + -1, 5, 6, 7, 2, 3, 4, 9, -1); + end; + + TTestSuiteVirtualTreeObj = class( TInterfacedObject, IVisualTestSuiteTree) + private + FFrame: TTestSuiteVirtualTree; + FTree: TVirtualStringTree; + FPopulating: boolean; + function FactoryDisplayName: string; + function Nodes( const Parent: IVisualTestSuiteNode): IEnumerable; + function AllNodes: IEnumerable; + function Change( const Parent: IVisualTestSuiteNode): IVisualTestSuiteTreeChangeContext; + procedure InvalidateRendering( const DeltaNode: IVisualTestSuiteNode); + procedure BeforePopulate; + procedure AfterPopulate; + procedure SetChecked( const Node: IVisualTestSuiteNode; Value: boolean; Source: TSetCheckedSource); + + private type + TChangeContext = class( TInterfacedObject, IVisualTestSuiteTreeChangeContext) + private + FTreeObj: TTestSuiteVirtualTreeObj; + FParent: IVisualTestSuiteNode; + FParentV: PVirtualNode; + function ChildNodes: IEnumerable; + function Insert( const Sibling: IVisualTestSuiteNode; Position: TInserPosition; AddCount: integer): IVisualTestSuiteNode; + function Append( AddCount: integer): IEnumerable; + procedure AttachRenderer( const Newbie: IVisualTestSuiteNode; const Renderer: INodeRenderer); + procedure Delete( const Victim: IVisualTestSuiteNode); + public + constructor Create( TreeObj1: TTestSuiteVirtualTreeObj; const Parent1: IVisualTestSuiteNode); + destructor Destroy; override; + end; + + public + constructor CreateFromFactory( AOwner: TComponent; AParent: TWinControl; const AName: string); + destructor Destroy; override; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + + + + + +{$R *.dfm} + +type +RNodeDatum = record + FToken: IVisualTestSuiteNode; + FRenderer: INodeRenderer; + end; +PNodeDatum = ^RNodeDatum; + +IVisualTestSuiteNodeEx = interface( IVisualTestSuiteNode) + ['{AACA02D2-26B9-41F4-8C15-6AA2ECEA90F3}'] + function GetNode: PVirtualNode; + end; + +TVisualTestSuiteNode = class( TInterfacedObject, IVisualTestSuiteNode, IVisualTestSuiteNodeEx) + private + FDatum: pointer; + FNode: PVirtualNode; + function GetDatum: pointer; + procedure SetDatum( Value: pointer); + function GetNode: PVirtualNode; + public + constructor Create( Node1: PVirtualNode); + end; + +TTestSuiteNodeList = class( TInterfacedObject, IEnumerable, IEnumerable) + private + FTree:TVirtualStringTree; + FParentV, FStartV: PVirtualNode; + FAddCount: integer; + function GetEnumerator: IEnumerator; + function GetEnumeratorIntf: IEnumerator; + function IEnumerable.GetEnumerator = GetEnumeratorIntf; + public + constructor Create( Tree1:TVirtualStringTree; ParentV1, StartV1: PVirtualNode; AddCount1: integer); + end; + +TTestSuiteNodeCursor = class( TInterfacedObject, IEnumerator, IEnumerator) + private + FTree:TVirtualStringTree; + FParentV, FStartV: PVirtualNode; + FAddCount: integer; + FCurrentV: PVirtualNode; + FIndex : integer; + + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentIntf: IVisualTestSuiteNode; + function IEnumerator.GetCurrent = GetCurrentIntf; + public + constructor Create( Tree1:TVirtualStringTree; ParentV1, StartV1: PVirtualNode; AddCount1: integer); + end; + + +constructor TTestSuiteVirtualTreeObj.CreateFromFactory( AOwner: TComponent; AParent: TWinControl; const AName: string); +var + Owner: TComponent; + Parent: TWinControl; +begin +FPopulating := False; +FFrame := TTestSuiteVirtualTree.Create( nil); +FFrame.ConstructVirtualTree; +FFrame.Loaded; +FFrame.FObj := self; +FTree := FFrame.Tree; +FFrame.RemoveComponent( FTree); +FTree.NodeDataSize := SizeOf( RNodeDatum); +Owner := AOwner; +Parent := AParent; +FTree.Name := AName; +if assigned( Owner) and (Owner is TWinControl) and (not assigned( Parent)) then + Parent := Owner as TWinControl; +if assigned( Parent) and (not assigned( Owner)) then + Owner := Parent; +if assigned( Owner) then + Owner.InsertComponent( FTree); +if assigned( Parent) then + FTree.Parent := Parent +end; + +destructor TTestSuiteVirtualTreeObj.Destroy; +begin +FFrame.Free; +inherited +end; + +function TTestSuiteVirtualTreeObj.Change( + const Parent: IVisualTestSuiteNode): IVisualTestSuiteTreeChangeContext; +begin +result := TChangeContext.Create( self, Parent) +end; + +function TTestSuiteVirtualTreeObj.FactoryDisplayName: string; +begin +result := FTree.ClassName +end; + +procedure TTestSuiteVirtualTreeObj.InvalidateRendering( + const DeltaNode: IVisualTestSuiteNode); +begin +FTree.InvalidateNode( (DeltaNode as IVisualTestSuiteNodeEx).GetNode) +end; + +type +TVisualTestSuiteTreeFactory = class( TInterfacedObject, IVisualTestSuiteTreeFactory) + private + function MakeVisualTestSuiteTree( AOwner: TComponent; AParent: TWinControl; const AName: string): IVisualTestSuiteTree; + public + [Configuration] constructor ServiceModeCreate; + end; + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( IVisualTestSuiteTreeFactory, TVisualTestSuiteTreeFactory) +end; + +function TVisualTestSuiteTreeFactory.MakeVisualTestSuiteTree( AOwner: TComponent; AParent: TWinControl; const AName: string): IVisualTestSuiteTree; +begin +result := TTestSuiteVirtualTreeObj.CreateFromFactory( AOwner, AParent, AName) +end; + +function TTestSuiteVirtualTreeObj.Nodes( + const Parent: IVisualTestSuiteNode): IEnumerable; +var + ParentV: PVirtualNode; +begin +if assigned( Parent) then + ParentV := (Parent as IVisualTestSuiteNodeEx).GetNode + else + ParentV := nil; +result := TTestSuiteNodeList.Create( FTree, ParentV, nil, MaxInt) +end; + +type +TTestSuiteAllNodes = class( TInterfacedObject, IEnumerable) + private + FNodesRec: TVTVirtualNodeEnumeration; + FTree: TBaseVirtualTree; + function GetEnumerator: IEnumerator; + function GetEnumeratorIntf: IEnumerator; + function IEnumerable.GetEnumerator = GetEnumeratorIntf; + + private type + TTestSuiteAllNodesCursor = class( TInterfacedObject, IEnumerator, IEnumerator) + private + FEnumaratorRec: TVTVirtualNodeEnumerator; + FTree: TBaseVirtualTree; + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentIntf: IVisualTestSuiteNode; + function IEnumerator.GetCurrent = GetCurrentIntf; + public + constructor Create( Tree1: TBaseVirtualTree; Enum: TVTVirtualNodeEnumerator); + end; + + public + constructor Create( Tree1: TBaseVirtualTree; Nodes: TVTVirtualNodeEnumeration); + end; + +function TTestSuiteVirtualTreeObj.AllNodes: IEnumerable; +begin +result := TTestSuiteAllNodes.Create( FTree, FTree.Nodes(False)) +end; + + + +procedure TTestSuiteVirtualTreeObj.SetChecked( + const Node: IVisualTestSuiteNode; + Value: boolean; Source: TSetCheckedSource); +var + InitialCheckState: TCheckState; + NextCheckState: TCheckState; + DemandedCheckState: TCheckState; +begin +InitialCheckState := FTree.CheckState[ (Node as IVisualTestSuiteNodeEx).GetNode]; +case Value of + False: DemandedCheckState := csUncheckedNormal; + True : DemandedCheckState := csCheckedNormal; + end; +case Source of + csPopulation, csUser : + NextCheckState := DemandedCheckState; + csPostPopulate: + begin + case InitialCheckState of + csMixedNormal, csMixedPressed: NextCheckState := InitialCheckState; + else NextCheckState := DemandedCheckState; + end + end; +end; +if NextCheckState <> InitialCheckState then + FTree.CheckState[ (Node as IVisualTestSuiteNodeEx).GetNode] := NextCheckState +end; + +constructor TTestSuiteVirtualTreeObj.TChangeContext.Create( + TreeObj1: TTestSuiteVirtualTreeObj; const Parent1: IVisualTestSuiteNode); +begin +FTreeObj := TreeObj1; +FParent := Parent1; +FTreeObj.FTree.BeginUpdate; +if assigned( FParent) then + FParentV := (FParent as IVisualTestSuiteNodeEx).GetNode + else + FParentV := nil +end; + +destructor TTestSuiteVirtualTreeObj.TChangeContext.Destroy; +begin +FTreeObj.FTree.EndUpdate; +inherited +end; + +function TTestSuiteVirtualTreeObj.TChangeContext.Append( + AddCount: integer): IEnumerable; +var + StartV: PVirtualNode; +begin +with FTreeObj.FTree do + begin + StartV := GetLastChildNoInit( FParentV); + ChildCount[ FParentV] := ChildCount[ FParentV] + AddCount + end; +if assigned( FParentV) then + Include( FParentV.States, vsHasChildren); +result := TTestSuiteNodeList.Create( FTreeObj.FTree, FParentV, StartV, AddCount) +end; + +procedure TTestSuiteVirtualTreeObj.TChangeContext.AttachRenderer( + const Newbie: IVisualTestSuiteNode; const Renderer: INodeRenderer); +var + DatumRec: PNodeDatum; +begin +DatumRec := FTreeObj.FTree.GetNodeData( (Newbie as IVisualTestSuiteNodeEx).GetNode); +DatumRec^.FRenderer := Renderer; +if assigned( Renderer) then + Renderer.Attached( Newbie) +end; + +function TTestSuiteVirtualTreeObj.TChangeContext.ChildNodes: IEnumerable; +begin +result := TTestSuiteNodeList.Create( FTreeObj.FTree, FParentV, nil, MaxInt) +end; + +procedure TTestSuiteVirtualTreeObj.TChangeContext.Delete( + const Victim: IVisualTestSuiteNode); +var + Node: PVirtualNode; +begin +Node := (Victim as IVisualTestSuiteNodeEx).GetNode; +FTreeObj.FTree.DeleteNode( Node) +end; + + +function TTestSuiteVirtualTreeObj.TChangeContext.Insert( + const Sibling: IVisualTestSuiteNode; Position: TInserPosition; + AddCount: integer): IVisualTestSuiteNode; +var + DatumRec: PNodeDatum; + Node, Base: PVirtualNode; + Mode: TVTNodeAttachMode; + Idx: Integer; +begin +result := nil; +Base := (Sibling as IVisualTestSuiteNodeEx).GetNode; +FTreeObj.FTree.DeleteNode( Node); +case Position of + iBefore: Mode := amInsertBefore; + iAfter : Mode := amInsertAfter; + end; +for Idx := 1 to AddCount do + begin + FTreeObj.FTree.InsertNode( Base, Mode); + DatumRec := FTreeObj.FTree.GetNodeData( Node); + Include( Node.States, vsInitialUserData); + Node.CheckType := ctTriStateCheckBox; + DatumRec^.FToken := TVisualTestSuiteNode.Create( Node); + if not assigned( result) then + // Only return the first one. + result := DatumRec^.FToken; + Base := Node + end +end; + +procedure TTestSuiteVirtualTreeObj.BeforePopulate; +begin +FPopulating := True; +FTree.BeginUpdate; +FTree.Clear +end; + +procedure TTestSuiteVirtualTreeObj.AfterPopulate; +var + Node: PVirtualNode; +begin +for Node in FTree.Nodes do + FTree.Expanded[ Node] := True; +FTree.EndUpdate; +FPopulating := False +end; + +procedure TTestSuiteVirtualTree.ConstructVirtualTree; +// We are not linking with the dfm. +// All properties are set at run-time via this method. +begin +if assigned( Tree) then exit; +FDataModule := TdmVirtualTreeNonVisualSupport.Create( Self); +Tree := TVirtualStringTree.Create( self); +with Tree do + begin + Left := 0; + Top := 0; + Width := 455; + Height := 240; + Align := alClient; + Header.AutoSizeIndex := 0; + Header.Font.Charset := DEFAULT_CHARSET; + Header.Font.Color := clWindowText; + Header.Font.Height := -11; + Header.Font.Name := 'Tahoma'; + Header.Font.Style := []; + Images := FDataModule.imglstStates16x16; + StateImages := FDataModule.imglstStates16x16; + TabOrder := 0; + ShowHint := True; + HintMode := hmHint; + TreeOptions.MiscOptions := [toCheckSupport, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]; + TreeOptions.PaintOptions := [toHideFocusRect, toHideSelection, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toShowVertGridLines, toThemeAware, toUseBlendedImages]; + TreeOptions.SelectionOptions := [toFullRowSelect]; + OnChecked := TreeChecked; + OnFreeNode := TreeFreeNode; + OnGetText := TreeGetText; + OnGetImageIndex := TreeGetImageIndex; + OnInitNode := TreeInitNode; + OnGetHint := TreeGetHint; + with Header.Columns.Add do + begin + MinWidth := 200; + Position := 0; + Width := 300; + Text := 'Test case' + end; + with Header.Columns.Add do + begin + Position := 1; + Text := 'Run count' + end + end +end; + +procedure TTestSuiteVirtualTree.TreeChecked( + Sender: TBaseVirtualTree; Node: PVirtualNode); +var + DatumRec: PNodeDatum; +begin +if FObj.FPopulating then exit; +DatumRec := Sender.GetNodeData( Node); +if assigned( DatumRec^.FRenderer) then + DatumRec^.FRenderer.SetChecked( Node^.CheckState in + [csCheckedNormal, csCheckedPressed, csMixedNormal, csMixedPressed], csUser) +end; + +procedure TTestSuiteVirtualTree.TreeFreeNode( + Sender: TBaseVirtualTree; Node: PVirtualNode); +var + DatumRec: PNodeDatum; + Rndr: INodeRenderer; +begin +DatumRec := Sender.GetNodeData( Node); +Rndr := DatumRec^.FRenderer; +if assigned( Rndr) then + Rndr.Detach; +Finalize( DatumRec^) +end; + +procedure TTestSuiteVirtualTree.TreeGetHint( + Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string); +var + DatumRec: PNodeDatum; + Rndr: INodeRenderer; +begin +DatumRec := Sender.GetNodeData( Node); +if assigned( DatumRec) then + Rndr := DatumRec^.FRenderer; +if assigned( Rndr) then + HintText := Rndr.Hint +end; + +procedure TTestSuiteVirtualTree.TreeGetImageIndex(Sender: TBaseVirtualTree; + Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; + var Ghosted: Boolean; var ImageIndex: Integer); +var + DatumRec: PNodeDatum; + Rndr: INodeRenderer; +begin +if Column <> 0 then exit; +DatumRec := Sender.GetNodeData( Node); +Rndr := DatumRec^.FRenderer; +if not assigned( Rndr) then exit; +case Kind of + ikNormal, + ikSelected: ImageIndex := KindImages [ Rndr.GetKind ]; + ikState: ImageIndex := StateImages[ Rndr.GetState]; + ikOverlay: ; + end; +end; + +procedure TTestSuiteVirtualTree.TreeGetText( + Sender: TBaseVirtualTree; + Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; + var CellText: string); +var + DatumRec: PNodeDatum; + Rndr: INodeRenderer; + Count: integer; +begin +if TextType <> ttNormal then exit; +DatumRec := Sender.GetNodeData( Node); +Rndr := DatumRec^.FRenderer; +if not assigned( Rndr) then exit; +case Column of + 0: CellText := Rndr.GetDisplayName; + 1: begin + Count := Rndr.GetFullCycleCount; + if Count = -1 then + CellText := '' + else + CellText := Format( '%d / %d', [Rndr.GetDoneCycleCount, Count]) + end; + end; +end; + +procedure TTestSuiteVirtualTree.TreeInitNode( Sender: TBaseVirtualTree; ParentNode, + Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); +begin +end; + +{ TVisualTestSuiteNode } + +constructor TVisualTestSuiteNode.Create( Node1: PVirtualNode); +begin +FNode := Node1; +FDatum := nil +end; + +function TVisualTestSuiteNode.GetDatum: pointer; +begin +result := FDatum +end; + +function TVisualTestSuiteNode.GetNode: PVirtualNode; +begin +result := FNode +end; + +procedure TVisualTestSuiteNode.SetDatum( Value: pointer); +begin +FDatum := Value +end; + + +constructor TTestSuiteNodeList.Create( + Tree1: TVirtualStringTree; ParentV1, StartV1: PVirtualNode; AddCount1: integer); +begin +FTree := Tree1; +FParentV := ParentV1; +FStartV := StartV1; +FAddCount := AddCount1 +end; + +function TTestSuiteNodeList.GetEnumerator: IEnumerator; +begin +result := nil +end; + +function TTestSuiteNodeList.GetEnumeratorIntf: IEnumerator; +begin +result := TTestSuiteNodeCursor.Create( FTree, FParentV, FStartV, FAddCount) +end; + +{ TTestSuiteNodeCursor } + +constructor TTestSuiteNodeCursor.Create(Tree1: TVirtualStringTree; ParentV1, + StartV1: PVirtualNode; AddCount1: integer); +begin +FTree := Tree1; +FParentV := ParentV1; +FStartV := StartV1; +FAddCount := AddCount1; +Reset +end; + +procedure TTestSuiteNodeCursor.Reset; +begin +FCurrentV := FStartV; +FIndex := 0 +end; + +function TTestSuiteNodeCursor.GetCurrent: TObject; +begin +result := nil +end; + +function TTestSuiteNodeCursor.GetCurrentIntf: IVisualTestSuiteNode; +var + DatumRec: PNodeDatum; +begin +DatumRec := FTree.GetNodeData( FCurrentV); +result := DatumRec.FToken; +if assigned( result) then exit; +Include( FCurrentV.States, vsInitialUserData); +FCurrentV.CheckType := ctTriStateCheckBox; +result := TVisualTestSuiteNode.Create( FCurrentV); +DatumRec.FToken := result +end; + +function TTestSuiteNodeCursor.MoveNext: boolean; +var + NextV: PVirtualNode; +begin +if assigned( FCurrentV) then + NextV := FCurrentV^.NextSibling + else if (not assigned( FStartV)) and assigned( FParentV) then + NextV := FParentV.FirstChild + else if not assigned( FStartV) then + NextV := FTree.GetFirstNoInit + else + NextV := nil; +result := assigned( NextV) and (FIndex < FAddCount); +if not result then exit; +FCurrentV := NextV; +Inc( FIndex) +end; + + +{ TTestSuiteAllNodes } + +constructor TTestSuiteAllNodes.Create( Tree1: TBaseVirtualTree; Nodes: TVTVirtualNodeEnumeration); +begin +FTree := Tree1; +FNodesRec := Nodes +end; + +function TTestSuiteAllNodes.GetEnumerator: IEnumerator; +begin +result := nil +end; + +function TTestSuiteAllNodes.GetEnumeratorIntf: IEnumerator; +begin +result := TTestSuiteAllNodesCursor.Create( FTree, FNodesRec.GetEnumerator) +end; + +{ TTestSuiteAllNodes.TTestSuiteAllNodesCursor } + +constructor TTestSuiteAllNodes.TTestSuiteAllNodesCursor.Create( Tree1: TBaseVirtualTree; Enum: TVTVirtualNodeEnumerator); +begin +FTree := Tree1; +FEnumaratorRec := Enum +end; + +function TTestSuiteAllNodes.TTestSuiteAllNodesCursor.GetCurrent: TObject; +begin +result := nil +end; + +function TTestSuiteAllNodes.TTestSuiteAllNodesCursor.GetCurrentIntf: IVisualTestSuiteNode; +var + DatumRec: PNodeDatum; +begin +DatumRec := FTree.GetNodeData( FEnumaratorRec.Current); +result := DatumRec^.FToken +end; + +function TTestSuiteAllNodes.TTestSuiteAllNodesCursor.MoveNext: Boolean; +begin +result := FEnumaratorRec.MoveNext +end; + +procedure TTestSuiteAllNodes.TTestSuiteAllNodesCursor.Reset; +begin +end; + +constructor TVisualTestSuiteTreeFactory.ServiceModeCreate; +begin +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.Solution.pas new file mode 100644 index 0000000..93e122f --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.Solution.pas @@ -0,0 +1,634 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.UnitTestFramework.Solution; +interface +uses DUnitM.UnitTestFramework, SBD.ServiceProvider, Rtti, SBD.Generics, + DUnitM.MemoryMonitor; + +procedure RegisterServices( const Provider: IServiceProvider); +// Provides: +// GUID config ArrayId Mode +// ---------------------------------------------------------------------------------- +// IUnitTestingEngine '' '' Competitive +// +// Requires: +// GUID config Mode +// ------------------------------------------------- +// IMemoryMonitor '' Competitive + +implementation + + + +// **************************************************************** +// ********** Common definitions ********************************** +// **************************************************************** +uses SBD.Messages, Classes, DUnitM.StringUtils, DUnitM.RttiUtils, + Generics.Collections, SysUtils, TypInfo, SBD.Utils.XML2, + Math, Variants, StrUtils, SBD.Messages.Solution, DUnitM.TestNode, + DUnitM.Fixture; + +type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// **************************************************************** +// ********** Unit Testing Engine ********************************* +// **************************************************************** + +TUnitTestingEngine = class( TInterfacedObject, IUnitTestingEngine, IRunnerExecutiveServices) + private + [Injection('rnRoot')] FSuiteFactory: ITestNodeFactory; + [Injection] FMemMonitor: IMemoryMonitor; + + private + FStarted: boolean; + FCtx: TRttiContext; + FSuite: ITestSuite; + FLoggers: IList2; + FController: IUnitTestingController; + FRunInstanceCount: integer; + FAbortPending, FAborted: boolean; + FBreakOnFirstFail: boolean; + FDeferredLoggerException: Exception; + FTroubleMaker: ITestLogger; + + procedure RegisterFixtureClass( FixtureCls: TClass); + function Suite: ITestSuite; + procedure EnterLeaveRunners( Delta: integer); + procedure Subscribe( const Observer: ITestLogger); + procedure Unsubscribe( const Observer: ITestLogger); + function Run: ITestResult; + procedure StartUp; + procedure Shutdown; + procedure Abort; + function IsAborted: boolean; + procedure SetController( const Controller: IUnitTestingController); + function Can_Run: boolean; + function Can_Abort: boolean; + function IsRunning: boolean; + procedure OnBeginRunInstance( const Instance: IRunInstance; Workload: integer); + procedure OnEndRunInstance( const Instance: IRunInstance; const RunResult: ITestResult); + procedure OnChangeStatus( + NodeKind: TLoggerNode; + const Fixture: ITestFixture; + const TestProc: ITestProcedure; + const TestCase: ITestCase; + const TestResult: ITestResult); + procedure OnAuxilaryMessage( const Node: ITestNode; const TestResult: ITestResult; const TestCase: ITestCase; const Msg: RMessage; Round: integer); + function GetBreakOnFirstFailure: boolean; + procedure SetBreakOnFirstFailure( Value: boolean); + procedure MarkLoggerException( const TroubleMaker: ITestLogger; const LoggerException: Exception); + procedure FlushLoggerExceptions; + + strict private + procedure StartUpLogger( const Logger: ITestLogger); + + strict private type + TLoggerProc = reference to procedure( const Logger: ITestLogger; var doBreak: boolean); + + private + procedure ForEachLogger( Proc: TLoggerProc; doTrapExceptions: boolean); + + public + [Configuration] constructor ServiceModeCreate; + destructor Destroy; override; + end; + + + + + + + + + + + + + + + +// **************************************************************** +// ********** Unit Testing Engine - Solution ********************** +// **************************************************************** + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( IUnitTestingEngine, TUnitTestingEngine) +end; + +constructor TUnitTestingEngine.ServiceModeCreate; +begin +FCtx.Create; +FDeferredLoggerException := nil; +FSuite := FSuiteFactory.MakeNode( '', nil, nil, nil) as ITestSuite; +FLoggers := TList2.Create; +FBreakOnFirstFail := False +end; + + +procedure TUnitTestingEngine.Abort; +begin +FAbortPending := True +end; + +function TUnitTestingEngine.Can_Abort: boolean; +begin +result := (FRunInstanceCount > 0) and (not FAbortPending) +end; + +function TUnitTestingEngine.Can_Run: boolean; +begin +result := FRunInstanceCount = 0 +end; + +destructor TUnitTestingEngine.Destroy; +begin +Shutdown; +FSuite := nil; +FLoggers := nil; +FCtx.Free; +inherited +end; + +procedure TUnitTestingEngine.EnterLeaveRunners( Delta: integer); +begin +if (FRunInstanceCount = 0) and (Delta > 0) and FAbortPending then + FAbortPending := False; +Inc( FRunInstanceCount, Delta); +if (FRunInstanceCount <= 0) and FAbortPending then + FAbortPending := False; +end; + +procedure TUnitTestingEngine.ForEachLogger( + Proc: TLoggerProc; doTrapExceptions: boolean); +var + Logger: ITestLogger; + doBreak: boolean; +begin +doBreak := False; +if assigned( Proc) then + begin + if doTrapExceptions then + for Logger in FLoggers do + try + Proc( Logger, doBreak); + if doBreak then break + except on E: Exception do + MarkLoggerException( Logger, E) + end + else + for Logger in FLoggers do + begin + Proc( Logger, doBreak); + if doBreak then break + end + end; +FlushLoggerExceptions +end; + +function TUnitTestingEngine.GetBreakOnFirstFailure: boolean; +begin +result := FBreakOnFirstFail +end; + +function TUnitTestingEngine.IsAborted: boolean; +var + Msg: RMessage; +begin +if (not FAbortPending) and assigned( FController) and FController.CheckAbort then + FAbortPending := True; +if FAbortPending and (not FAborted) then + begin + FAborted := True; + SetFrameworkMessage( Msg, UserAbort, 'Abortion of run, at user request, is now pending.', lvRegular); + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.OnAuxilaryMessage( nil, nil, Msg, nil) + end + , True) + end; +result := FAborted +end; + +function TUnitTestingEngine.IsRunning: boolean; +begin +result := FRunInstanceCount > 0 +end; + + +procedure TUnitTestingEngine.OnAuxilaryMessage( + const Node: ITestNode; const TestResult: ITestResult; + const TestCase: ITestCase; const Msg: RMessage; Round: integer); +var + Msg2: RMessage; +begin +Msg2 := Msg; +ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + var Datum: IInterface; + begin + Datum := Node.ViewDatumOfLogger( Logger); + Logger.OnAuxilaryMessage( TestResult, TestCase, Msg2, Datum) + end + , True) +end; + + +procedure TUnitTestingEngine.OnBeginRunInstance( + const Instance: IRunInstance; Workload: integer); +begin +ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.OnBeginRunInstance( Workload); + Logger.OnProgressTick( Instance, 0, WorkLoad) + end + , True) +end; + +procedure TUnitTestingEngine.OnEndRunInstance( + const Instance: IRunInstance; const RunResult: ITestResult); +begin +ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.OnEndRunInstance( RunResult) + end + , True) +end; + +procedure TUnitTestingEngine.OnChangeStatus( + NodeKind: TLoggerNode; const Fixture: ITestFixture; + const TestProc: ITestProcedure; const TestCase: ITestCase; + const TestResult: ITestResult); +var + Node: ITestNode; + Ok: boolean; + Run: IRunInstance; + RoundsCompleted, Workload: integer; + GrossResult: ITestResult; + sCompletedMsg, sPrefix: string; + Msg: RMessage; + Round: integer; + +begin +case NodeKind of + nFixture : Ok := Supports( Fixture , ITestNode, Node); + nTestProc: Ok := Supports( TestProc, ITestNode, Node); + nTestCase: Ok := Supports( TestCase, ITestNode, Node); + else Ok := False + end; +case TestResult.Status of + tsNeutral, + tsSetup, + tsTeardown, + tsExecuting: sCompletedMsg := ''; + tsPass : sCompletedMsg := 'completed with result PASS.'; + tsWarn : sCompletedMsg := 'completed with result WARN.'; + tsFail : sCompletedMsg := 'completed with result FAIL.'; + tsError : sCompletedMsg := 'completed with result ERROR.'; + tsSkipped : sCompletedMsg := 'completed with result SKIP.'; + end; +Run := TestResult as IRunInstance; +Round := 1; +if sCompletedMsg <> '' then + case TestResult.NodeKind of + rnRoot : sPrefix := ''; + rnNamespaceFixture, rnLeafFixture: sPrefix := 'Fixture'; + rnTestProc : sPrefix := 'Test Procedure'; + rnTestCase : sPrefix := 'Test Case'; + rnTestCaseRound: begin + Round := Run.Parent.RoundsCompleted; + sPrefix := Format( 'Round %d', [Round]) + end; + end; +if sPrefix <> '' then + begin + SetFrameworkMessage( Msg, ResultAnnouncement, sPrefix + ' [' + Run.Description + '] ' + sCompletedMsg, lvStatistic); + OnAuxilaryMessage( Run.TestNode, TestResult, Run.TestCase, Msg, Round); + end; +if (TestResult.NodeKind = rnTestCaseRound) and + (TestResult.Status in [tsPass, tsWarn, tsFail, tsError]) then + begin + while assigned( Run) and assigned( Run.Parent) and (Run.NodeKind <> rnRoot) do + Run := Run.Parent; + if assigned( Run) then + begin + RoundsCompleted := Run.RoundsCompleted; + Workload := Run.WorkLoad; + GrossResult := Run as ITestResult; + SetFrameworkMessage( Msg, ProgressAnnouncement, Format( 'Progress is %d of %d', [RoundsCompleted,Workload]), lvDebug); + OnAuxilaryMessage( (TestResult as IRunInstance).TestNode, TestResult, TestResult.TestCase, Msg, Round); + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.OnProgressTick( GrossResult, RoundsCompleted, WorkLoad) + end + , True) + end + end; +if Ok then + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + var Datum: IInterface; + begin + Datum := Node.ViewDatumOfLogger( Logger); + if assigned( Datum) then + Logger.OnChangeStatus( NodeKind, Fixture, TestProc, TestCase, TestResult, Datum) + end + , True); + +if (TestResult.NodeKind = rnTestCaseRound) and (not FAbortPending) and + ( ((TestResult.Status = tsFail) and FBreakOnFirstFail) or + (TestResult.Status = tsError)) + then + begin + FAbortPending := True; + if TestResult.Status = tsFail then + begin + SetFrameworkMessage( Msg, AbortOnFirstFail, 'Aborting on first failure.', lvRegular); + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.OnAuxilaryMessage( nil, nil, Msg, nil) + end + , True); + end + end; +ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + Logger.Breathe + end + , True) +end; + + +procedure TUnitTestingEngine.RegisterFixtureClass( FixtureCls: TClass); +begin +(FSuite as ITestSuiteInternal).RegisterFixture( FCtx.GetType( FixtureCls)); +end; + +function TUnitTestingEngine.Run: ITestResult; +begin +FAbortPending := False; +FAborted := False; +result := (FSuite as ITestSuiteInternal).Run( self); +FAbortPending := False +end; + +procedure TUnitTestingEngine.SetBreakOnFirstFailure( Value: boolean); +begin +FBreakOnFirstFail := Value +end; + +procedure TUnitTestingEngine.SetController( + const Controller: IUnitTestingController); +begin +FController := Controller +end; + +procedure TUnitTestingEngine.Shutdown; +var + Shut: IShutDown; +begin +if FLoggers.Count > 0 then + begin + FlushLoggerExceptions; + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + var SelfAsEngine: IUnitTestingEngine; + begin + if RefCount <= 0 then + // If some how, RefCount is zero, it is no longer safe to + // cast to an interface, as this would cause a double + // destruction of the TUnitTestingEngine instance. + // I don't think it is possible to reach this point, + // but just in case ... + SelfAsEngine := nil + else + SelfAsEngine := self as IUnitTestingEngine; + Logger.Shutdown( SelfAsEngine) + end + , False); + FLoggers.Clear + end; +FTroubleMaker := nil; +if Supports( FSuite, IShutDown, Shut) then + Shut.Shutdown; +FSuite := nil; +FController := nil; +FMemMonitor := nil +end; + +procedure TUnitTestingEngine.StartUpLogger( const Logger: ITestLogger); +begin +Logger.OnAttachSuite( FSuite, + procedure (const Addend: ITestFixture; const ViewDatum: IInterface) + begin + (Addend as ITestNode).AttachViewDatum( Logger, ViewDatum) + end, + procedure (const Addend: ITestProcedure; const ViewDatum: IInterface) + begin + (Addend as ITestNode).AttachViewDatum( Logger, ViewDatum) + end, + procedure (const Addend: ITestCase; const ViewDatum: IInterface) + begin + (Addend as ITestNode).AttachViewDatum( Logger, ViewDatum) + end + ) +end; + +procedure TUnitTestingEngine.StartUp; +begin +if FStarted then Exit; +FStarted := True; +ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + StartUpLogger( Logger) + end + , False) +end; + +procedure TUnitTestingEngine.Subscribe( const Observer: ITestLogger); +begin +if not assigned( Observer) then exit; +FLoggers.Add( Observer); +if FStarted then + StartUpLogger( Observer) +end; + +function TUnitTestingEngine.Suite: ITestSuite; +begin +result := FSuite +end; + +procedure TUnitTestingEngine.Unsubscribe( const Observer: ITestLogger); + + procedure DetachFrom( Node: ITestNode); + var + Child: ITestNode; + begin + Node.AttachViewDatum( Observer, nil); + for Child in Node.NodeChildren do + DetachFrom( Child) + end; + +begin +FLoggers.Remove( Observer); +if FTroubleMaker = Observer then + FTroubleMaker := nil; +DetachFrom( FSuite as ITestNode) +end; + + +procedure TUnitTestingEngine.MarkLoggerException( const TroubleMaker: ITestLogger; const LoggerException: Exception); +begin +if not assigned( FDeferredLoggerException) then + // Some logger exceptions must be lost. If we don't draw the line some where, + // we could get a stack overflow of exceptions raised by faulty loggers + // reporting exceptions by other (or the same) faulty loggers, and so on. + + // The policy is that we just handle one level of exception and swallow the rest. + // An exception raised by a logger method, will be broadcast as an error message + // of all other loggers. + begin + FDeferredLoggerException := LoggerException; + FTroubleMaker := TroubleMaker + end +end; + + +procedure TUnitTestingEngine.FlushLoggerExceptions; +var + Msg: RMessage; + TroubleName: string; + MinCount: integer; +begin +if not assigned( FDeferredLoggerException) then exit; +if assigned( FTroubleMaker) then + MinCount := 2 + else + MinCount := 1; +if FLoggers.Count >= MinCount then + begin + if assigned( FTroubleMaker) then + try + TroubleName := FTroubleMaker.MenuDescription; + if TroubleName = '' then + TroubleName := '(unnamed)' + except on E: Exception do + TroubleName := E.Message + end + else + TroubleName := '(unsubscribed logger)'; + SetFrameworkMessage( Msg, LoggerException, + Format( 'Logger "%s" reported exception %s: %s', + [TroubleName, FDeferredLoggerException.ClassName, FDeferredLoggerException.Message]), + lvError); + ForEachLogger( procedure( const Logger: ITestLogger; var doBreak: boolean) + begin + if Logger <> FTroubleMaker then + Logger.OnAuxilaryMessage( nil, nil, Msg, nil) + end + , True) + end; +FDeferredLoggerException := nil; +FTroubleMaker := nil +end; + + + + + + + + + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.pas new file mode 100644 index 0000000..45d5745 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.UnitTestFramework.pas @@ -0,0 +1,727 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.UnitTestFramework; + +interface + +uses SBD.Messages, SBD.Generics, Classes, SysUtils, RTTI; + +{$I ../includes/DUnitM.inc} + +const + // Message URL for framework messages: + DUnixtM_Framework_URL = 'http://www.seanbdurkin.id.au/pascaliburnus2'; + DUnixtM_Framework_Prefix = 'dm'; + + // Message codes for framework messages: + UserIssuedWarning = 1; + TestFailure = 2; + TestError = 3; + IgnoredTestCase = 4; + SetupError = 5; + TestException = 6; + NoChecks = 7; + LeakageFailure = 8; + TeardownError = 9; + SyntaxError = 10; + ResultAnnouncement = 11; + ProgressAnnouncement = 12; + UserAbort = 13; + AbortOnFirstFail = 14; + LoggerException = 15; + +type + TTestStatus = (tsNeutral, tsSetup, tsTeardown, tsExecuting, tsPass, tsWarn, + tsFail, tsError, tsSkipped); + + ITestProcedure = interface; + + ITestCase = interface + ['{4AC7C199-4E4E-4FF9-89B5-76C28A7E2D2D}'] + function GetEnabled: boolean; + procedure SetEnabled(Value: boolean); + function DisplayName: string; + function Parent: ITestProcedure; + function Load: integer; + property Enabled: boolean read GetEnabled write SetEnabled; + end; + + ITestFixture = interface; + + ITestProcedure = interface + ['{A3AF569F-DEF8-49CE-A551-608D273D15EC}'] + function Name: string; + function Parent: ITestFixture; + function TestCases: ISEnumerable; + function Load: integer; + function RepeatCount: integer; + function Description: string; + function GetDefaultEnabled: boolean; + function IsIgnored(var IgnoreReason: string): boolean; + function IgnoreLeaks: boolean; + end; + + ITestResult = interface; + + ITestFixture = interface + ['{F8BECF10-535D-4815-8759-E8854F640D44}'] + function Name: string; + function Parent: ITestFixture; + function FixtureChildren: ISEnumerable; + function TestProcedures: ISEnumerable; + function Load: integer; + function Description: string; + function isNamespaceFixture: boolean; + end; + + RTimingStats = record + FStart, FEnd: TDateTime; + FDuration_ms: integer; // Milliseconds of duration. + procedure Clear; + end; + + TResultNodeKind = (rnRoot, rnNamespaceFixture, rnLeafFixture, rnTestProc, + rnTestCase, rnTestCaseRound); + + ITestSuite = interface + ['{A870F6AD-54CF-48A2-B079-229C4C941095}'] + function Fixtures: ISEnumerable; + end; + + ITestResult = interface + ['{8704A3FD-C908-4294-80A6-84F6775BF0E9}'] + function Status: TTestStatus; + function RoundsCompleted: integer; + function RoundsPerTestCase: integer; + function ErrorCount: integer; + function PassCount: integer; + function FailCount: integer; + function WarnCount: integer; + function Timing: RTimingStats; + function Messages: IMessageSource; + function TestCase: ITestCase; + function Fixture: ITestFixture; + function ChildResults: ISEnumerable; + function Executed: boolean; + function IgnoredCount: integer; + function SkippedCount: integer; + function NodeKind: TResultNodeKind; + function ErrorOrFailureMsg(var FailMsg: RMessage): boolean; + function NodeName: string; + end; + + TLoggerNode = (nFixture, nTestProc, nTestCase); + + TSetFixtureDatumFunc = reference to procedure(const Addend: ITestFixture; + const ViewDatum: IInterface); + TSetTestProcDatumFunc = reference to procedure(const Addend: ITestProcedure; + const ViewDatum: IInterface); + TSetTestCaseDatumFunc = reference to procedure(const Addend: ITestCase; + const ViewDatum: IInterface); + +type + /// + /// Loggers that log to a file, may depend on a IFilenameSource service. + /// + IUnitTestingEngine = interface; + + ITestLogger = interface + ['{0BE3D866-6188-40EB-96BB-6F51BF086E07}'] + function MenuDescription: string; + procedure OnEnableChange(const Eng: IUnitTestingEngine; + const Proc: ITestProcedure; const Datum: IInterface); + procedure OnBeginRunInstance(Workload: integer); + procedure OnEndRunInstance(const RunResult: ITestResult); + procedure OnChangeStatus(NodeKind: TLoggerNode; + const Fixture: ITestFixture; const TestProc: ITestProcedure; + const TestCase: ITestCase; const TestResult: ITestResult; + const Datum: IInterface); + procedure OnAuxilaryMessage(const TestResult: ITestResult; + const TestCase: ITestCase; const Msg: RMessage; + const NodeDatum: IInterface); + procedure Shutdown(const Eng: IUnitTestingEngine); + procedure OnAttachSuite(Suite: ITestSuite; + SetFixtureDatum: TSetFixtureDatumFunc; + SetTestProcDatum: TSetTestProcDatumFunc; + SetTestCaseDatum: TSetTestCaseDatumFunc); + procedure OnProgressTick(const GrossResult: ITestResult; + WorkDone, Workload: integer); + procedure Breathe; + end; + + IUnitTestingController = interface; + + IUnitTestingEngine = interface + ['{0420BDA2-583F-4A2D-85CF-1C586ECC13DB}'] + procedure RegisterFixtureClass(FixtureCls: TClass); + function Suite: ITestSuite; + procedure Subscribe(const Observer: ITestLogger); + procedure Unsubscribe(const Observer: ITestLogger); + function Run: ITestResult; + procedure StartUp; + procedure Shutdown; + procedure Abort; + procedure SetController(const Controller: IUnitTestingController); + + function Can_Run: boolean; + function Can_Abort: boolean; + function IsRunning: boolean; + function GetBreakOnFirstFailure: boolean; + procedure SetBreakOnFirstFailure(Value: boolean); + + property BreakOnFirstFailure: boolean read GetBreakOnFirstFailure write + SetBreakOnFirstFailure; + end; + + IUnitTestingController = interface + ['{AE64C153-E5B0-412B-A414-9FEFE90799D2}'] + procedure UpdateActionStatii(const Eng: IUnitTestingEngine); + function CheckAbort: boolean; + end; + + IFilenameSource = interface + ['{555499CC-460D-4FAA-96E5-CE9BE8209A6D}'] + function FileName: string; + end; + + IFilenameFactoryParameter = interface + ['{C43C96B8-B35F-4615-BB96-007EA946EB5D}'] + function FileName: string; + procedure SetFileName(const Value: string); + function isValidFilename(const Value: string): boolean; + end; + + ILoggerFactory = interface + ['{64122CBF-56B0-432B-B36A-58AA430E2C47}'] + function MenuDescription: string; + function CreateLogger(const Params: IInterface): ITestLogger; + end; + + ILoggerFactoryUI = interface + ['{9220819C-79F1-45E9-B8BD-98E8041FFA9C}'] + function Factory: ILoggerFactory; + function EnquireForCreateLogger(out Params: IInterface): boolean; + procedure ViewEditProperties(const Logger: ITestLogger; Params: IInterface); + end; + + IAdditionalLoggers = interface(ISEnumerable) + ['{F7542D70-C258-445D-BA6B-D61868760D51}'] + end; + + TDUnitXAttributeBase = class(TCustomAttribute) + end; + + TTestMethod = procedure of object; + TTestLocalMethod = reference to procedure; + + {$ifdef DELPHI_XE_UP} + TAssertGeneric = class abstract( TAggregatedObject) + protected + procedure Check; virtual; abstract; + procedure FailFmt( const Fmt: string; const Args: array of const); virtual; abstract; + + public + procedure AreEqual ( const left, right: T; const message: string = ''); + procedure AreNotEqual ( const left, right: T; const message: string = ''); + procedure Contains ( const list: IEnumerable; const Value: T; const message: string = ''); + procedure DoesNotContain( const list: IEnumerable; const Value: T; const message: string = ''); + procedure IsEmpty ( const Value: IEnumerable; const message: string = ''); + procedure IsNotEmpty ( const Value: IEnumerable; const message: string = ''); + procedure IsType ( const Value: T; const message: string = ''); + end; + {$endif} + + IAssert = interface + ['{23BD3BBE-257D-4AFE-ADF7-15B21BB181E8}'] + {$ifdef DELPHI_XE_UP} + function Gn: TAssertGeneric; + {$endif} + + procedure Pass; + procedure Fail( const message: string = ''; const errorAddrs: pointer = nil); + procedure Warn( const message: string = ''); + + procedure AreEqual( + const left: string; const right: string; + const ignoreCase: boolean; const message: string); overload; + + procedure AreEqual( + const left: string; const right: string; + const message: string = ''); overload; + + procedure AreEqual( + const left, right: Extended; const tolerance: Extended; + const message: string = ''); overload; + + procedure AreEqual( + const left, right: Extended; const message: string = ''); overload; + + procedure AreEqual( const left, right: TClass; const message: string = ''); overload; + procedure AreEqual( const left, right: TDate; const message: string = ''); overload; + procedure AreEqual( const left, right: TDateTime; const message: string = ''); overload; + + procedure AreEqual(const left, right: integer; const message: string = ''); + overload; + + procedure AreEqualMemory( const left: pointer; const right: pointer; + const size: Cardinal; message: string = ''); + + procedure AreNotEqual( const left: string; const right: string; + const ignoreCase: boolean = true; const message: string = ''); overload; + + procedure AreNotEqual( const left, right: Extended; + const tolerance: Extended; const message: string = ''); overload; + + procedure AreNotEqual( + const left, right: TClass; const message: string = ''); overload; + + procedure AreNotEqual( + const left, right: TDate; const message: string = ''); overload; + + procedure AreNotEqual( + const left, right: TDateTime; const message: string = ''); overload; + + procedure AreNotEqual( + const left, right: integer; const message: string = ''); overload; + + procedure AreNotEqualMemory( + const left: pointer; const right: pointer; + const size: Cardinal; message: string = ''); + + procedure AreSame( const left, right: TObject; const message: string = ''); overload; + procedure AreSame( const left, right: IInterface; const message: string = ''); overload; + + procedure AreNotSame( const left, right: TObject; const message: string = ''); overload; + procedure AreNotSame( const left, right: IInterface; const message: string = ''); overload; + procedure IsTrue ( const condition: boolean; const message: string = ''); + procedure IsFalse( const condition: boolean; const message: string = ''); + procedure IsNull( const condition: TObject; const message: string = ''); overload; + procedure IsNull( const condition: pointer; const message: string = ''); overload; + procedure IsNull( const condition: IInterface; const message: string = ''); overload; + procedure IsNull( const condition: Variant; const message: string = ''); overload; + procedure IsNotNull( const condition: TObject; const message: string = ''); overload; + procedure IsNotNull( const condition: pointer; const message: string = ''); overload; + procedure IsNotNull( const condition: IInterface; const message: string = ''); overload; + procedure IsNotNull( const condition: Variant; const message: string = ''); overload; + procedure IsEmpty( const Value: string; const message: string = ''); overload; + procedure IsEmpty( const Value: Variant; const message: string = ''); overload; + procedure IsEmpty( const Value: TStrings; const message: string = ''); overload; + procedure IsEmpty( const Value: TList; const message: string = ''); overload; + procedure IsEmpty( const Value: IInterfaceList; const message: string = ''); overload; + procedure IsNotEmpty( const Value: string; const message: string = ''); overload; + procedure IsNotEmpty( const Value: Variant; const message: string = ''); overload; + procedure IsNotEmpty( const Value: TStrings; const message: string = ''); overload; + procedure IsNotEmpty( const Value: TList; const message: string = ''); overload; + procedure IsNotEmpty( + const Value: IInterfaceList; const message: string = ''); overload; + + procedure WillRaise( + const AMethod: TTestLocalMethod; + const exceptionClass: ExceptClass = nil; const Msg: string = ''); overload; + + procedure WillRaise( + const AMethod: TTestMethod; + const exceptionClass: ExceptClass = nil; const Msg: string = ''); overload; + + procedure WillNotRaise( + const AMethod: TTestLocalMethod; + const exceptionClass: ExceptClass = nil; const Msg: string = ''); overload; + + procedure WillNotRaise( + const AMethod: TTestMethod; + const exceptionClass: ExceptClass = nil; const Msg: string = ''); overload; + + procedure Contains( + const theString: string; const subString: string; + const ignoreCase: boolean = true; const message: string = ''); overload; + + procedure StartsWith( + const theString: string; const subString: string; + const ignoreCase: boolean = true; const message: string = ''); + + procedure EndsWith( const theString: string; const subString: string; + const ignoreCase: boolean = true; const message: string = ''); + + procedure InheritsFrom( + const descendant: TClass; const Parent: TClass; const message: string = ''); + + {$IFDEF SUPPORTS_REGEX} + procedure IsMatch( + const regexPattern: string; const theString: string; const message: string = ''); + {$ENDIF} + end; + + TestFixtureAttribute = class abstract( TDUnitXAttributeBase) + public + FPathedName: string; + constructor Create(const PathedName: string); + end; + // A test fixture class MUST also have a protected datamember of type Assert: IAssert + + TestAttribute = class( TDUnitXAttributeBase) + public + FEnabled: boolean; + constructor Create( Enabled: boolean); overload; + constructor Create; overload; + end; + +ITestCaseLineItemCursor = interface + ['{D66570A1-5BEB-4DC3-AA9D-9AEC2050639A}'] + function Next: boolean; + procedure GetLineItemDescription( RowNumber: integer; var sDescription: string); + function LineItemObject: TObject; + end; + +TTestCaseLineItemCursorBase = class abstract( TInterfacedObject, ITestCaseLineItemCursor) + protected + function Next: boolean; virtual; abstract; + procedure GetLineItemDescription( RowNumber: integer; var sDescription: string); virtual; + function LineItemObject: TObject; virtual; abstract; + end; + +IDataDrivenTestCaseNavigator = interface + ['{722A1367-AC8F-4E29-A495-E7CEC249C225}'] + function EstimatedCount( var CountItems: integer): boolean; + function OpenLineItemCursor: ITestCaseLineItemCursor; + end; + +function ForceGetEstimatedCount( const Nav: IDataDrivenTestCaseNavigator): integer; + +type +TDDTestCaseNavigatorBase = class abstract( TInterfacedObject, IDataDrivenTestCaseNavigator) + protected + function EstimatedCount( var CountItems: integer): boolean; virtual; abstract; + function OpenLineItemCursor: ITestCaseLineItemCursor; virtual; abstract; + end; + + +IDataDrivenTestCaseFactory = interface +['{775496DC-FF7A-4F53-94D4-15B592D6FCF4}'] + function Repeats: integer; + function MethodSkips: integer; + function Name: string; + function Make: ITestCase; +end; + + +TDataDrivenTestAttributeBase = class abstract( TDUnitXAttributeBase) +public + function SignatureMatches( poTestMethod: TRttiMethod): boolean; virtual; abstract; + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; virtual; abstract; +end; + +DataDrivenTestAttribute = class( TDataDrivenTestAttributeBase) + // Applies to method with signature ... + // function Navigator: IDataDrivenTestCaseNavigator; + // procedure TestIt( Item: TObject); +public + function SignatureMatches( poTestMethod: TRttiMethod): boolean; override; + function AcquireFactory( ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; override; +end; + +TestCaseAttribute = class( TDUnitXAttributeBase) +public + FName: string; + FData: string; + constructor Create( const Name, Data: string); +end; + +DescriptionAttribute = class( TDUnitXAttributeBase) +public + FText: string; + constructor Create( const Text: string); +end; + +IgnoreAttribute = class( TDUnitXAttributeBase) +public + FReason: string; + constructor Create( const Reason: string); +end; + +RepeatsAttribute = class( TDUnitXAttributeBase) +public + FCount: integer; + constructor Create( Count: integer); +end; + +IgnoreMemoryLeaksAttribute = class( TDUnitXAttributeBase) +end; + +SetupAttribute = class( TDUnitXAttributeBase) +end; + +TearDownAttribute = class( TDUnitXAttributeBase) +end; + +FixtureSetupAttribute = class( TDUnitXAttributeBase) +end; +// Decorates a constructor. + + + +implementation + + + + + + + +uses TypInfo, DUnitM.TestCase, DUnitM.TestNode + {$ifdef DELPHI_XE_UP} + , System.Generics.Defaults + {$endif} + ; + +constructor TestFixtureAttribute.Create( const PathedName: string); +begin + FPathedName := PathedName +end; + + +constructor TestAttribute.Create(Enabled: boolean); +begin + FEnabled := Enabled +end; + +constructor TestAttribute.Create; +begin + Create(true) +end; + + +function DataDrivenTestAttribute.SignatureMatches( poTestMethod: TRttiMethod): boolean; +begin +result := TDataDrivenTestCaseFactory.SignatureMatches( poTestMethod) +end; + + +function DataDrivenTestAttribute.AcquireFactory( + ProcParentAsObject: TObject; ProcType: TRttiMethod): IDataDrivenTestCaseFactory; +var + ParentReflector: TReflector; +begin +if ProcParentAsObject is TReflector then + ParentReflector := TReflector( ProcParentAsObject) + else + ParentReflector := nil; +result := TDataDrivenTestCaseFactory.Create( self, ParentReflector, ProcType) +end; + +constructor TestCaseAttribute.Create(const Name, Data: string); +begin + FName := Name; + FData := Data +end; + + +constructor DescriptionAttribute.Create(const Text: string); +begin + FText := Text +end; + + +constructor IgnoreAttribute.Create(const Reason: string); +begin + FReason := Reason +end; + + +constructor RepeatsAttribute.Create(Count: integer); +begin + FCount := Count +end; + + + +procedure RTimingStats.Clear; +begin +end; + + +{$ifdef DELPHI_XE_UP} +procedure TAssertGeneric.AreEqual( + const left, right: T; const message: string = ''); +var + comparer : IComparer; + leftvalue, rightvalue : TValue; + pInfo : PTypeInfo; + tInfo : TValue; +begin +Check; +comparer := TComparer.Default; +if comparer.Compare(right,left) <> 0 then + begin + leftValue := TValue.From(left); + rightValue := TValue.From(right); + pInfo := TypeInfo(string); + + if leftValue.IsEmpty or rightvalue.IsEmpty then + FailFmt( 'left is not equal to right - %s', [message]) + else + begin + if leftValue.TryCast(pInfo,tInfo) then + FailFmt( 'left %s but got %s - %s', [leftValue.AsString, rightValue.AsString, message]) + else + FailFmt( 'left is not equal to right - %s', [message]) + end + end +end; + +procedure TAssertGeneric.AreNotEqual( const left, right: T; const message: string); +var + comparer : IComparer; + leftValue, rightValue : TValue; +begin +Check; +comparer := TComparer.Default; +if comparer.Compare(right,left) = 0 then + begin + leftValue := TValue.From(left); + rightValue := TValue.From(right); + FailFmt( 'left %s Not Equal To %s', [leftValue.AsString,rightValue.AsString]) + end +end; + +procedure TAssertGeneric.Contains( const list: IEnumerable; const value: T; const message: string); +var + o: T; + comparer: IComparer; +begin +Check; +comparer := TComparer.Default; +for o in list do + if comparer.Compare(o,value) = 0 then + exit; +FailFmt( 'List does not contain value. %s', [message]) +end; + +procedure TAssertGeneric.DoesNotContain( const list: IEnumerable; const value: T; const message: string); +var + o: T; + comparer: IComparer; +begin +Check; +comparer := TComparer.Default; +for o in list do + if comparer.Compare( o, value) = 0 then + FailFmt( 'List contains value. %s', [message]) +end; + + +procedure TAssertGeneric.IsEmpty( const Value: IEnumerable; const message: string = ''); +var + o: T; +begin +Check; +for o in value do + FailFmt( 'List is Not empty. %s', [message]) +end; + + +procedure TAssertGeneric.IsNotEmpty( const Value: IEnumerable; const message: string = ''); +var + o: T; +begin +Check; +for o in value do + exit; +FailFmt( 'List is empty. %s', [message]) +end; + +procedure TAssertGeneric.IsType( const Value: T; const message: string = ''); +var + val : TValue; +begin +Check; +val := TValue.From(value); +if not val.IsType then + FailFmt( 'value is not of expected type', []) +end; +{$endif} + + +procedure TTestCaseLineItemCursorBase.GetLineItemDescription( + RowNumber: integer; var sDescription: string); +begin +end; + + + +function ForceGetEstimatedCount( const Nav: IDataDrivenTestCaseNavigator): integer; +var + Cursor: ITestCaseLineItemCursor; +begin +result := 1; +if Nav.EstimatedCount( result) then exit; +result := 0; +Cursor := Nav.OpenLineItemCursor; +while assigned( Cursor) and Cursor.Next do + Inc( result) +end; + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_Tree.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_Tree.pas new file mode 100644 index 0000000..96356bf --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_Tree.pas @@ -0,0 +1,128 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.ViewModel_Tree; +interface +uses Classes, Controls, DUnitM.UnitTestFramework; + +type + +TVisualTestSuiteNodeKind = (nkNeutral, nkTestCase, nkTestProc, nkTestFixture, nkGroup); + +IVisualTestSuiteNode = interface + ['{660A0B5D-7DCC-4C62-B3A2-54CD873DCDC5}'] + {$REGION 'property accesssors'} + function GetDatum: pointer; + procedure SetDatum( Value: pointer); + {$ENDREGION} + property Datum: pointer read GetDatum write SetDatum; + end; + +TInserPosition = (iBefore, iAfter); + +TSetCheckedSource = (csPopulation, csPostPopulate, csUser); +INodeRenderer = interface + ['{1C46A49A-44C3-4505-B7A7-D46D7B1AFC51}'] + procedure Attached( const Node: IVisualTestSuiteNode); + procedure Detach; + function GetState: TTestStatus; + function GetKind: TVisualTestSuiteNodeKind; + function GetDisplayName: string; + function Hint: string; + function GetFullCycleCount: integer; + function GetDoneCycleCount: integer; + procedure SetChecked( Value: boolean; Source: TSetCheckedSource); + end; + +IVisualTestSuiteTreeChangeContext = interface + ['{B81C4E46-E097-4FB3-9D7F-5DCD526AE8D3}'] + function ChildNodes: IEnumerable; + function Insert( const Sibling: IVisualTestSuiteNode; Position: TInserPosition; AddCount: integer): IVisualTestSuiteNode; + function Append( AddCount: integer): IEnumerable; + procedure AttachRenderer( const Newbie: IVisualTestSuiteNode; const Renderer: INodeRenderer); + procedure Delete( const Victim: IVisualTestSuiteNode); + end; + +IVisualTestSuiteTree = interface + ['{92018040-E850-4275-8357-0E200E223A2E}'] + // When constructed by a ServiceProvider, IComponentContext may be injected as a data member. + function FactoryDisplayName: string; + function Nodes( const Parent: IVisualTestSuiteNode): IEnumerable; + function AllNodes: IEnumerable; + function Change( const Parent: IVisualTestSuiteNode): IVisualTestSuiteTreeChangeContext; + procedure InvalidateRendering( const DeltaNode: IVisualTestSuiteNode); + procedure BeforePopulate; + procedure AfterPopulate; + procedure SetChecked( const Node: IVisualTestSuiteNode; Value: boolean; Source: TSetCheckedSource); + end; + +IVisualTestSuiteTreeFactory = interface + ['{991B77D7-E057-47FB-8B9B-0A2253AB1168}'] + function MakeVisualTestSuiteTree( AOwner: TComponent; AParent: TWinControl; const AName: string): IVisualTestSuiteTree; + end; + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_VCLForms.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_VCLForms.pas new file mode 100644 index 0000000..5b73c6d --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.ViewModel_VCLForms.pas @@ -0,0 +1,998 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.ViewModel_VCLForms; +interface +uses DUnitM.UnitTestFramework, Forms, DUnitM.BaseExecutive, DUnitM.ViewModel_Tree, + Classes, Controls, Generics.Collections, SBD.Messages; + +// TODO: +// 2. Add menu items for secondary loggers +// 3. Windows Console solution +// 4. OS X FM Solution +// 5. OS X Console Solution +// 6. iOS FM Solution +// 7. Android FM Solution +// 8. Refactor to injection +// 9. Attribute extensibility + +type +TPutLevel = (lvDebug, lvNormal, lvHighLight); + +IViewModel_VCLForms = interface( IUnitTestingController) + ['{B9BF01AA-1877-4073-9E43-C4A72F8FA8FC}'] + procedure FormLoaded( Form: TCustomForm); + procedure FirstIdleEvent; + procedure FormDestroyed; + function Executive: IExecutive; + function Model: IUnitTestingEngine; + procedure Run; + procedure AttachSecondaryLogger( const Addend: ITestLogger); + procedure DetachSecondaryLogger( const Observer: ITestLogger); + procedure ClearLog; + procedure Put( Level: TPutLevel; const Line: string; const Args: array of const); + procedure ToggleSelections; + procedure ClearSelections; + function CanClearSelections: boolean; + procedure SelectAll; + procedure SelectFailed; + procedure SelectDefault; + function CanSelectFailed: boolean; + function GetShowProgressBar: boolean; + procedure SetShowProgressBar( Value: boolean); + function GetProgressPosition: integer; + procedure SetProgressPosition( Value: integer); + function GetProgressMax: integer; + procedure SetProgressMax( Value: integer); + procedure RequestAbort; + function IsAbortRequested: boolean; + function CanToggleHaltOnFirstFailure: boolean; + function GetDoHaltOnFirstFailure: boolean; + procedure SetDoHaltOnFirstFailure( Value: boolean); + function CanDialog: boolean; + + procedure ClearAll; + + property ShowProgressBar: boolean read GetShowProgressBar write SetShowProgressBar; + property ProgressPosition: integer read GetProgressPosition write SetProgressPosition; + property ProgressMax: integer read GetProgressMax write SetProgressMax; + property DoHaltOnFirstFailure: boolean read GetDoHaltOnFirstFailure write SetDoHaltOnFirstFailure; + end; + +TSuiteRunnerState = (rsIdle, rsSettingUp, rsExecuting, rsTearingDown, rsBetweenTests); + +TViewModel_VCLForms = class( TInterfacedObject, ITestLogger, IUnitTestingController, IViewModel_VCLForms) + private + FTree: IVisualTestSuiteTree; + FTestCaseCount: integer; + + function Executive: IExecutive; + function Model: IUnitTestingEngine; + procedure ClearTree; + + protected type + TNode = class abstract( TInterfacedObject, INodeRenderer) + protected + FToken: IVisualTestSuiteNode; + FModel: TViewModel_VCLForms; + FState: TTestStatus; + FTestResult: ITestResult; + + procedure Attached( const Node: IVisualTestSuiteNode); + procedure Detach; virtual; + function GetState: TTestStatus; virtual; + function GetKind: TVisualTestSuiteNodeKind; virtual; abstract; + function GetDisplayName: string; virtual; abstract; + function GetFullCycleCount: integer; virtual; abstract; + function GetDoneCycleCount: integer; virtual; + procedure SetChecked( Value: boolean; Source: TSetCheckedSource); virtual; abstract; + function IsChecked: boolean; virtual; + function Hint: string; virtual; abstract; + public + constructor Create( Model1: TViewModel_VCLForms); + end; + + + protected + FForm: TCustomForm; + FModel: IUnitTestingEngine; + FState: TSuiteRunnerState; + FisInOperation: boolean; + FAbortRequested: boolean; + FExecutive: IExecutive; + + function MenuDescription: string; + procedure OnEnableChange( const Eng: IUnitTestingEngine; const Proc: ITestProcedure; const Datum: IInterface); + procedure OnBeginRunInstance( Workload: integer); + procedure OnEndRunInstance( const RunResult: ITestResult); + procedure OnChangeStatus( + NodeKind: TLoggerNode; + const Fixture: ITestFixture; + const TestProc: ITestProcedure; + const TestCase: ITestCase; + const TestResult: ITestResult; + const NodeDatum: IInterface); + procedure OnAuxilaryMessage( const TestResult: ITestResult; const TestCase: ITestCase; const Msg: RMessage; const NodeDatum: IInterface); + procedure Shutdown( const Eng: IUnitTestingEngine); + procedure OnAttachSuite( Suite: ITestSuite; + SetFixtureDatum: TSetFixtureDatumFunc; + SetTestProcDatum: TSetTestProcDatumFunc; + SetTestCaseDatum: TSetTestCaseDatumFunc); + procedure OnProgressTick( const GrossResult: ITestResult; WorkDone, WorkLoad: integer); virtual; + + procedure EnterOperation( isEntering: boolean); virtual; + procedure FormLoaded( Form: TCustomForm); virtual; + procedure FirstIdleEvent; virtual; + procedure FormDestroyed; virtual; + function AcquireExecutive: IExecutive; virtual; + procedure UpdateActionStatii( const Eng: IUnitTestingEngine); + function GetDoHaltOnFirstFailure: boolean; + procedure SetDoHaltOnFirstFailure( Value: boolean); + function CanToggleHaltOnFirstFailure: boolean; virtual; + function CanDialog: boolean; virtual; + + function TreeOwner: TComponent; virtual; abstract; + function TreeParent: TWinControl; virtual; abstract; + function TreeName: string; virtual; abstract; + + procedure IntegrateSecondariesIntoMenus; virtual; abstract; + procedure AttachVisualTree; virtual; + procedure AttachSecondaryLogger( const Addend: ITestLogger); + procedure DetachSecondaryLogger( const Observer: ITestLogger); + + procedure ClearLog; virtual; abstract; + procedure Put( Level: TPutLevel; const Line: string; const Args: array of const); virtual; abstract; + procedure SetDisplayState( Value: TSuiteRunnerState); virtual; + procedure Breathe; virtual; abstract; + procedure InitiateView( TestCaseCount: integer); virtual; + procedure SetApplicationTitle( const Title: string); virtual; + function GetShowProgressBar: boolean; virtual; + procedure SetShowProgressBar( Value: boolean); virtual; + function GetProgressPosition: integer; virtual; + procedure SetProgressPosition( Value: integer); virtual; + function GetProgressMax: integer; virtual; + procedure SetProgressMax( Value: integer); virtual; + function CheckAbort: boolean; virtual; + procedure ClearAll; + + function FindVisualNode( + const NodeDatum: IInterface; + var VisNode: IVisualTestSuiteNode; var Node: TNode): boolean; + + public + constructor Create; virtual; + property ShowProgressBar: boolean read GetShowProgressBar write SetShowProgressBar; + property ProgressPosition: integer read GetProgressPosition write SetProgressPosition; + property ProgressMax: integer read GetProgressMax write SetProgressMax; + + private + procedure AttachVCLForm( Form: TCustomForm); + procedure AttachExecutive; + procedure AttachModel; + procedure RegisterTestFixtures; + procedure AcquireVisualTree; + procedure PopulateTree; + procedure Run; + procedure ToggleSelections; + procedure ClearSelections; + function CanClearSelections: boolean; + procedure SelectAll; + procedure SelectFailed; + procedure SelectDefault; + function CanSelectFailed: boolean; + procedure SetClearAll( Value: boolean); + procedure RequestAbort; + function IsAbortRequested: boolean; + + private type + TPerNode = reference to procedure( Leaf: TNode; var doBreak: boolean); + private + function PerLeafNode( Proc: TPerNode): boolean; // Returns True if exit via PerNode break. + end; + + +implementation + + + + + + + + + + + + + +uses DUnitM.Executive, SysUtils, Math; + +type +TFixtureNode = class( TViewModel_VCLForms.TNode) + protected + FFixture: ITestFixture; + + procedure Detach; override; + function GetKind: TVisualTestSuiteNodeKind; override; + function GetDisplayName: string; override; + function GetFullCycleCount: integer; override; + procedure SetChecked( Value: boolean; Source: TSetCheckedSource); override; + function Hint: string; override; + public + constructor Create( Model1: TViewModel_VCLForms; const Fixture1: ITestFixture); + end; + +TTestCaseNode = class( TViewModel_VCLForms.TNode) + protected + FTestCase: ITestCase; + + procedure Detach; override; + function GetKind: TVisualTestSuiteNodeKind; override; + function GetDisplayName: string; override; + function GetFullCycleCount: integer; override; + procedure SetChecked( Value: boolean; Source: TSetCheckedSource); override; + function IsChecked: boolean; override; + function Hint: string; override; + public + constructor Create( Model1: TViewModel_VCLForms; const TestCase1: ITestCase); + end; + +constructor TViewModel_VCLForms.Create; +begin +FAbortRequested := False +end; + +procedure TViewModel_VCLForms.DetachSecondaryLogger( const Observer: ITestLogger); +begin +Model.Unsubscribe( Observer) +end; + +procedure TViewModel_VCLForms.FormLoaded( Form: TCustomForm); +begin +AttachVCLForm( Form) +end; + + +function TViewModel_VCLForms.GetProgressMax: integer; +begin +result := 100 +end; + +function TViewModel_VCLForms.GetProgressPosition: integer; +begin +result := 0 +end; + +function TViewModel_VCLForms.GetShowProgressBar: boolean; +begin +result := False +end; + +procedure TViewModel_VCLForms.InitiateView( TestCaseCount: integer); +begin +SetDisplayState( rsIdle); +SetProgressMax( 100); +SetShowProgressBar( False) +end; + + +function TViewModel_VCLForms.IsAbortRequested: boolean; +begin +result := FAbortRequested +end; + +procedure TViewModel_VCLForms.AttachVCLForm( Form: TCustomForm); +begin +FForm := Form; +AttachExecutive; +SetApplicationTitle( FExecutive.ApplicationTitle) +end; + + +procedure TViewModel_VCLForms.AttachVisualTree; +begin +FModel.Subscribe( self) +end; + +procedure TViewModel_VCLForms.SetApplicationTitle( const Title: string); +begin +FForm.Caption := Title +end; + +procedure TViewModel_VCLForms.AttachExecutive; +begin +FExecutive := AcquireExecutive; +if not assigned( FExecutive) then exit; +if Application.MainForm = FForm then + FExecutive.DeclareMainForm( FForm) +end; + + +procedure TViewModel_VCLForms.FirstIdleEvent; +begin +AttachModel; +RegisterTestFixtures; +IntegrateSecondariesIntoMenus; // Overriden in view +AcquireVisualTree; +AttachVisualTree; // Overriden in view +PopulateTree; +InitiateView( FTestCaseCount); +FExecutive.StartUp +end; + + +function TViewModel_VCLForms.AcquireExecutive: IExecutive; +begin +result := DUnitM.Executive.AcquireExecutive +end; + +procedure TViewModel_VCLForms.AttachModel; +begin +FModel := FExecutive.Model; +FModel.SetController( self) +end; + + +procedure TViewModel_VCLForms.AttachSecondaryLogger( const Addend: ITestLogger); +begin +FModel.Subscribe( Addend) +end; + +procedure TViewModel_VCLForms.AcquireVisualTree; +var + Factory: IVisualTestSuiteTreeFactory; +begin +if FExecutive.Services.Gn.Acquire( nil, Factory) then + FTree := Factory.MakeVisualTestSuiteTree( TreeOwner, TreeParent, TreeName) +end; + +procedure TViewModel_VCLForms.PopulateTree; +begin +Model.StartUp +end; + +procedure TViewModel_VCLForms.OnAttachSuite( + Suite: ITestSuite; + SetFixtureDatum: TSetFixtureDatumFunc; + SetTestProcDatum: TSetTestProcDatumFunc; + SetTestCaseDatum: TSetTestCaseDatumFunc); +var + Fixture: ITestFixture; + + procedure PopulateSubTree( const Fixture1: ITestFixture; const ParentVisualNode: IVisualTestSuiteNode); + var + FixtureContext : IVisualTestSuiteTreeChangeContext; + TestCaseContext: IVisualTestSuiteTreeChangeContext; + Newbie, TestCaseNewbs: IVisualTestSuiteNode; + Addend: TNode; + TestCase: ITestCase; + Child: ITestFixture; + Proc: ITestProcedure; + begin + FixtureContext := FTree.Change( ParentVisualNode); + for Newbie in FixtureContext.Append( 1) do + begin + Addend := TFixtureNode.Create( self, Fixture1); + Newbie.Datum := Pointer( Addend); + FixtureContext.AttachRenderer( Newbie, Addend); + if assigned( SetFixtureDatum) then + SetFixtureDatum( Fixture1, Newbie); + FTree.SetChecked( Newbie, False, csPopulation); + for Child in Fixture1.FixtureChildren do + PopulateSubTree( Child, Newbie); + for Proc in Fixture1.TestProcedures do + for TestCase in Proc.TestCases do + begin + TestCaseContext := FTree.Change( Newbie); + for TestCaseNewbs in TestCaseContext.Append(1) do + begin + Addend := TTestCaseNode.Create( self, TestCase); + if TestCase.Enabled then + Inc( FTestCaseCount); + TestCaseNewbs.Datum := Pointer( Addend); + TestCaseContext.AttachRenderer( TestCaseNewbs, Addend); + SetTestCaseDatum( TestCase, TestCaseNewbs); + // At start-up the enabled state of each test case will the the DefaultEnabled. + // Business rule: + // DefaultEnabled is true iff: + // (1) The test procedure is NOT marked as [Test(False)]; and + // (2) The test procedure is NOT set to ignored [Ignore('For some reason.')]. + FTree.SetChecked( TestCaseNewbs, TestCase.Enabled, csPopulation); + end + end + end + end; + +begin +FTestCaseCount := 0; +FTree.BeforePopulate; +for Fixture in Suite.Fixtures do + PopulateSubTree( Fixture, nil); +FTree.AfterPopulate +end; + + +procedure TViewModel_VCLForms.RegisterTestFixtures; +begin +FExecutive.RegisterTestFixtures +end; + +procedure TViewModel_VCLForms.RequestAbort; +begin +FAbortRequested := True +end; + +procedure TViewModel_VCLForms.ClearTree; +var + GenericNode: IVisualTestSuiteNode; +begin +for GenericNode in FTree.AllNodes do + begin + TNode( GenericNode.Datum).FState := tsNeutral; + TNode( GenericNode.Datum).FTestResult := nil; + FTree.InvalidateRendering( GenericNode) + end +end; + +procedure TViewModel_VCLForms.Run; +begin +EnterOperation( True); +try + ClearTree; + Breathe; + FModel.Run +finally + EnterOperation( False) + end +end; + +procedure TViewModel_VCLForms.SetDisplayState( Value: TSuiteRunnerState); +begin +FState := Value; +if FState = rsIdle then + FAbortRequested := False +end; + +function TViewModel_VCLForms.GetDoHaltOnFirstFailure: boolean; +begin +result := FModel.BreakOnFirstFailure +end; + +procedure TViewModel_VCLForms.SetDoHaltOnFirstFailure( Value: boolean); +begin +FModel.BreakOnFirstFailure := Value +end; + +const + LevelStrings: array[ SBD.Messages.TMessageLevel] of string = ( + { lvDebug ==> } '', + { lvStatistic ==> } '', + { lvHint ==> } 'Hint (%d)', + { lvRegular ==> } '', + { lvWarning ==> } 'Warning (%d)', + { lvError ==> } 'Error (%d)', + { lvFatalError ==> } 'Fatal error (%d)' + ); + + +function MessageToString( const Msg: RMessage): string; +begin +result := LevelStrings[ Msg.FLevel]; +if Pos( '%d', result) > 0 then + result := Format( result, [Msg.FMessageCode]); +if result <> '' then + result := result + ': '; +Result := result + Msg.FDisplayText +end; + + +procedure TViewModel_VCLForms.SetProgressMax( Value: integer); +begin +end; + +procedure TViewModel_VCLForms.SetProgressPosition( Value: integer); +begin +end; + +procedure TViewModel_VCLForms.SetShowProgressBar( Value: boolean); +begin +end; + +procedure TViewModel_VCLForms.Shutdown( const Eng: IUnitTestingEngine); +begin +FModel.SetController( nil) +end; + +procedure TViewModel_VCLForms.EnterOperation( isEntering: boolean); +begin +FisInOperation := isEntering +end; + +function TViewModel_VCLForms.Executive: IExecutive; +begin +result := FExecutive +end; + +procedure TViewModel_VCLForms.FormDestroyed; +var + Exec: IExecutive; +begin +FTree := nil; +if (Application.MainForm = FForm) and assigned( FExecutive) then + begin + Exec := FExecutive; + FExecutive := nil; + Exec.ShutDown + end +end; + +function TViewModel_VCLForms.MenuDescription: string; +begin +result := 'Main form' +end; + +function TViewModel_VCLForms.Model: IUnitTestingEngine; +begin +result := FModel +end; + + +procedure TViewModel_VCLForms.OnAuxilaryMessage( + const TestResult: ITestResult; const TestCase: ITestCase; + const Msg: RMessage; const NodeDatum: IInterface); +var + Lvl: TPutLevel; + VisNode: IVisualTestSuiteNode; + Node: TNode; + s: string; +begin +Lvl := lvDebug; +if FindVisualNode( NodeDatum, VisNode, Node) then + begin + // TODO: Attach message to the VisNode + end; +case Msg.FLevel of + SBD.Messages.lvDebug : Lvl := DUnitM.ViewModel_VCLForms.lvDebug; + + lvStatistic, + lvHint, + lvRegular, + lvWarning : Lvl := lvNormal; + + lvError, + lvFatalError: Lvl := lvHighLight; + end; +s := LevelStrings[ Msg.FLevel]; +if Pos( '%d', s) > 0 then + s := Format( s, [Msg.FMessageCode]); +if (s <> '') and assigned( TestResult) and (TestCase.DisplayName <> '') then + s := s + ' - '; +if assigned( TestCase) then + begin + if TestCase.DisplayName <> '' then + s := s + '"' + TestCase.DisplayName + '"' + end + else if assigned( TestResult) then + begin + if TestResult.NodeName <> '' then + s := s + '"' + TestResult.NodeName + '"' + end; +if s <> '' then + s := s + ': '; +Put( Lvl, s + Msg.FDisplayText, []) +end; + +procedure TViewModel_VCLForms.OnBeginRunInstance( Workload: integer); +begin +SetDisplayState( rsBetweenTests); +Put( lvNormal, 'Begin Run. Workload = %d', [Workload]); +SetShowProgressBar( True) +end; + + +function TViewModel_VCLForms.FindVisualNode( + const NodeDatum: IInterface; + var VisNode: IVisualTestSuiteNode; var Node: TNode): boolean; +begin +result := Supports( NodeDatum, IVisualTestSuiteNode, VisNode) and + assigned( VisNode.Datum) and + (TObject( VisNode.Datum) is TNode); +if result then + Node := TNode( VisNode.Datum) +end; + +procedure TViewModel_VCLForms.OnChangeStatus( NodeKind: TLoggerNode; + const Fixture: ITestFixture; const TestProc: ITestProcedure; + const TestCase: ITestCase; const TestResult: ITestResult; + const NodeDatum: IInterface); +var + VisNode: IVisualTestSuiteNode; + Node: TNode; + s: string; + State: TSuiteRunnerState; +begin +State := rsSettingUp; +if FindVisualNode( NodeDatum, VisNode, Node) then + begin + Node.FState := TestResult.Status; + Node.FTestResult := TestResult; + FTree.InvalidateRendering( VisNode); + Breathe; + end; +if assigned( TestResult) and (Node.FState in [tsPass, tsWarn, tsFail, tsError]) then + begin + case TestResult.NodeKind of + rnRoot: s := 'suite'; + rnNamespaceFixture, rnLeafFixture: s := 'Fixture ' + Fixture.Name; + rnTestProc: s := 'procedure ' + TestProc.Name; + rnTestCase: s := 'test case ' + TestCase.DisplayName; + rnTestCaseRound: s := 'round'; // ? Round? + end; + Put( lvNormal, '%s completed in %d ms.', [s ,TestResult.Timing.FDuration_ms]) + end; +case TestResult.Status of + tsNeutral : State := rsBetweenTests; + tsSetup : State := rsSettingUp; + tsTeardown : State := rsTearingDown; + tsExecuting: State := rsExecuting; + tsPass : State := rsBetweenTests; + tsWarn : State := rsBetweenTests; + tsFail : State := rsBetweenTests; + tsError : State := rsBetweenTests; + tsSkipped : State := rsBetweenTests; + end; +SetDisplayState( State) +end; + + +procedure TViewModel_VCLForms.OnEnableChange( + const Eng: IUnitTestingEngine; const Proc: ITestProcedure; const Datum: IInterface); +begin +end; + +procedure TViewModel_VCLForms.OnEndRunInstance( const RunResult: ITestResult); +begin +Put( lvNormal, 'End Run. RoundsCompleted = %d', [RunResult.RoundsCompleted]); +SetDisplayState( rsIdle) +end; + + + + +procedure TViewModel_VCLForms.OnProgressTick( + const GrossResult: ITestResult; WorkDone, WorkLoad: integer); +begin +ProgressMax := WorkLoad; +ProgressPosition := WorkDone +end; + +function TViewModel_VCLForms.PerLeafNode( Proc: TPerNode): boolean; +var + GenericNode: IVisualTestSuiteNode; + Child: IVisualTestSuiteNode; + Node: TNode; + isLeaf: boolean; +begin +result := False; +for GenericNode in FTree.AllNodes do + begin + isLeaf := True; + for Child in FTree.Nodes( GenericNode) do + begin + isLeaf := False; + break + end; + if not isLeaf then continue; + Node := TNode( GenericNode.Datum); + Proc( Node, result); + if result then break + end +end; + + +function TViewModel_VCLForms.CanClearSelections: boolean; +begin +result := PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := Leaf.IsChecked + end) +end; + +function TViewModel_VCLForms.CanDialog: boolean; +begin +result := not FModel.IsRunning +end; + +function TViewModel_VCLForms.CanSelectFailed: boolean; +begin +result := PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := Leaf.FState in [tsError, tsFail] + end) +end; + +function TViewModel_VCLForms.CanToggleHaltOnFirstFailure: boolean; +begin +result := not FModel.IsRunning +end; + +function TViewModel_VCLForms.CheckAbort: boolean; +begin +result := FAbortRequested +end; + +procedure TViewModel_VCLForms.SetClearAll( Value: boolean); +begin +PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := False; + Leaf.SetChecked( Value, csUser); + FTree.SetChecked( Leaf.FToken, Leaf.IsChecked, csUser) + end) +end; + +procedure TViewModel_VCLForms.ClearAll; +begin +ClearSelections; +ClearTree; +ClearLog; +ShowProgressBar := False +end; + +procedure TViewModel_VCLForms.ClearSelections; +begin +SetClearAll( False) +end; + +procedure TViewModel_VCLForms.SelectAll; +begin +SetClearAll( True) +end; + +procedure TViewModel_VCLForms.SelectDefault; +begin +PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := False; + Leaf.SetChecked( (Leaf as TTestCaseNode).FTestCase.Parent.GetDefaultEnabled, csUser); + FTree.SetChecked( Leaf.FToken, Leaf.IsChecked, csUser) + end) +end; + +procedure TViewModel_VCLForms.SelectFailed; +begin +PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := False; + Leaf.SetChecked( Leaf.FState in [tsError, tsFail], csUser); + FTree.SetChecked( Leaf.FToken, Leaf.IsChecked, csUser) + end) +end; + +procedure TViewModel_VCLForms.ToggleSelections; +begin +PerLeafNode( procedure( Leaf: TNode; var doBreak: boolean) + begin + doBreak := False; + Leaf.SetChecked( not Leaf.IsChecked, csUser); + FTree.SetChecked( Leaf.FToken, Leaf.IsChecked, csUser) + end) +end; + + + +procedure TViewModel_VCLForms.UpdateActionStatii( const Eng: IUnitTestingEngine); +begin + +end; + +procedure TViewModel_VCLForms.TNode.Attached( const Node: IVisualTestSuiteNode); +begin +FToken := Node +end; + +constructor TViewModel_VCLForms.TNode.Create( Model1: TViewModel_VCLForms); +begin +FModel := Model1 +end; + +procedure TViewModel_VCLForms.TNode.Detach; +begin +FModel := nil; +FToken := nil +end; + +function TViewModel_VCLForms.TNode.GetDoneCycleCount: integer; +begin +if assigned( FTestResult) then + result := FTestResult.RoundsCompleted + else + result := 0 +end; + +function TViewModel_VCLForms.TNode.GetState: TTestStatus; +begin +result := FState +end; + +function TViewModel_VCLForms.TNode.IsChecked: boolean; +begin +result := False +end; + +{ TFixtureNode } + +constructor TFixtureNode.Create( + Model1: TViewModel_VCLForms; const Fixture1: ITestFixture); +begin +inherited Create( Model1); +FFixture := Fixture1; +FState := tsNeutral +end; + +procedure TFixtureNode.Detach; +begin +inherited Detach; +FFixture := nil +end; + +function TFixtureNode.GetDisplayName: string; +begin +result := FFixture.Name +end; + + +function TFixtureNode.GetFullCycleCount: integer; +begin +result := FFixture.Load +end; + +function TFixtureNode.GetKind: TVisualTestSuiteNodeKind; +begin +result := nkTestFixture +end; + + +function TFixtureNode.Hint: string; +begin +result := '' +end; + +procedure TFixtureNode.SetChecked( Value: boolean; Source: TSetCheckedSource); +begin +end; + +{ TTestCaseNode } + +constructor TTestCaseNode.Create( + Model1: TViewModel_VCLForms; const TestCase1: ITestCase); +begin +inherited Create( Model1); +FTestCase := TestCase1 +end; + +procedure TTestCaseNode.Detach; +begin +inherited Detach; +FTestCase := nil +end; + +function TTestCaseNode.GetDisplayName: string; +begin +result := FTestCase.DisplayName +end; + + +function TTestCaseNode.GetFullCycleCount: integer; +begin +result := FTestCase.Load +end; + +function TTestCaseNode.GetKind: TVisualTestSuiteNodeKind; +begin +result := nkTestCase +end; + + +function TTestCaseNode.Hint: string; +var + Msg: RMessage; + Child: ITestResult; + + procedure AccumulateMessage( var s: string); + begin + if Msg.FDisplayText = '' then exit; + if s <> '' then + s := s + #13#10; + s := MessageToString( Msg) + end; + +begin +if assigned( FTestResult) then + begin + for Msg in FTestResult.Messages do + AccumulateMessage( result); + for Child in FTestResult.ChildResults do + for Msg in Child.Messages do + AccumulateMessage( result) + end +end; + + +function TTestCaseNode.IsChecked: boolean; +begin +result := FTestCase.Enabled +end; + + +procedure TTestCaseNode.SetChecked( Value: boolean; Source: TSetCheckedSource); +begin +if (Source = csUser) and (FTestCase.Enabled <> Value) then + FTestCase.Enabled := Value + // Assume it is successful. + // If not, we must test for failure and propagate back to the view +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.Solution.pas new file mode 100644 index 0000000..07a6b57 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.Solution.pas @@ -0,0 +1,575 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.XMLWriter.Solution; +interface + +// Service Files +// interface [Configuration] Affinity Contract +// ============================================================================= +// IXMLWriter 'UTF-8' Competitive Writes lexical XML to file. + + + +uses Classes, DUnitM.XMLWriter, SBD.ServiceProvider; + +type + +TXMLWriter = class( TInterfacedObject, IXMLWriter) + private + function OpenDocument( OutStream1: TStream): IXMLWriter_Document; + public + [Configuration('UTF-8')] constructor ServiceModeCreate; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); + + +var + sXLog: string; + +implementation + + + + + +uses Generics.Collections, SysUtils, SBD.Utils.XML2; + +type +TNamespaceAxis = class + private + FInheritedDeclarations: TNamespaceAxis; + FDefaultNamespace: string; + FDeclaredNamespaces : TDictionary; // URL --> prefix + FUndeclaredNamespaces: TDictionary; // URL --> prefix + public + constructor Create( InheriteFrom: TNamespaceAxis); + destructor Destroy; override; + function HasPrefix( const Prefix: string; var URI: string): boolean; + function HasNamespace( const URI: string; var Prefix: string): boolean; + procedure DeclareNamespace( const PreferredPrefix, URI: string); + procedure UnDeclareNamespace( const URI: string); + procedure DeclareDefaultNamespace( const URI: string); + procedure UnDeclareDefaultNamespace; + function Serialise: string; + end; + +IStringStream = interface + ['{F13608A9-4846-44BB-88F3-C32A7B227CAC}'] + procedure Put( const Datum: string); + end; + +TNodeParent = class( TInterfacedObject, IXMLWriter_NodeParent) + protected + FCanvas: IStringStream; + FParent: IXMLWriter_NodeParent; + function Close: IXMLWriter_NodeParent; virtual; abstract; + function AddElement( const URI, LocalName: string): IXMLWriter_Element; virtual; abstract; + procedure AddProcessingInstruction( const Target, Content: string); virtual; + procedure AddComment( const Content: string); virtual; + procedure AddTextNode( const Value: string); virtual; + procedure Put( const Datum: string); virtual; + procedure PutPrefix( const Prefix: string); + function Canvas: IStringStream; + public + constructor Create( const Canvas1: IStringStream; Parent1: IXMLWriter_NodeParent); + end; + +TElement = class( TNodeParent, IXMLWriter_Element) + private + FNamespaces: TNamespaceAxis; + FhasChildren: boolean; + FPrefix: string; + FURI: string; + FLocalName: string; + FLevel: integer; + + protected + function Close: IXMLWriter_NodeParent; override; + function AddElement( const URI, LocalName: string): IXMLWriter_Element; override; + procedure AddProcessingInstruction( const Target, Content: string); override; + procedure AddComment( const Content: string); override; + procedure AddTextNode( const Value: string); override; + + private + procedure DeclareNamespace( const PreferredPrefix, URI: string); + procedure UnDeclareNamespace( const URI: string); + procedure DeclareDefaultNamespace( const URI: string); + procedure UnDeclareDefaultNamespace; + procedure AddAttribute( const Namespace, LocalName, Value: string); + procedure SetChildNodes; + procedure PutIndent; + function ElementStack: string; + + public + constructor Create( + const URI, LocalName: string; + const Canvas1: IStringStream; const Parent1: IXMLWriter_NodeParent; + Namespaces: TNamespaceAxis; Level1: integer); + destructor Destroy; override; + end; + +TDocument = class( TNodeParent, IXMLWriter_Document, IStringStream) + private + FOutStream: TStream; + protected + procedure Put( const Datum: string); override; + function Close: IXMLWriter_NodeParent; override; + function AddElement( const URI, LocalName: string): IXMLWriter_Element; override; + procedure AddTextNode( const Value: string); override; + public + constructor Create( OutStream1: TStream); + destructor Destroy; override; + end; + + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterServiceClass( IXMLWriter, TXMLWriter) +end; + + +function AttributeOutputEscape( const Plaintext: string): string; +begin +result := StringReplace( Plaintext, '&' , '&Amp;' , [rfReplaceAll]); +result := StringReplace( result , '<' , '<' , [rfReplaceAll]); +result := StringReplace( result , '>' , '>' , [rfReplaceAll]); +result := StringReplace( result , '''' , ''', [rfReplaceAll]); +result := StringReplace( result , '"' , '"', [rfReplaceAll]) +end; + +function TextNodeOutputEscape( const Plaintext: string): string; +begin +result := StringReplace( Plaintext, '&' , '&Amp;' , [rfReplaceAll]); +result := StringReplace( result , '<' , '<' , [rfReplaceAll]); +result := StringReplace( result , ']]>' , ']]>', [rfReplaceAll]) +end; + + +function TXMLWriter.OpenDocument( OutStream1: TStream): IXMLWriter_Document; +begin +result := TDocument.Create( OutStream1) +end; + +constructor TXMLWriter.ServiceModeCreate; +begin +end; + +{ TNodeParent } + +procedure TNodeParent.AddComment( + const Content: string); +begin +Assert( not Contains( '-' + Content + '-', '--'), ''); +Put( '') +end; + +procedure TNodeParent.AddProcessingInstruction( const Target, Content: string); +begin +Put( '') +end; + +procedure TNodeParent.AddTextNode( const Value: string); +begin +Put( TextNodeOutputEscape( Value)) +end; + +function TNodeParent.Canvas: IStringStream; +begin +result := FCanvas; +if not assigned( Result) then + Supports( Self, IStringStream, result) +end; + +constructor TNodeParent.Create( + const Canvas1: IStringStream; Parent1: IXMLWriter_NodeParent); +begin +FCanvas := Canvas1; +FParent := Parent1 +end; + +procedure TNodeParent.Put( const Datum: string); +var + Canvas1: IStringStream; +begin +Canvas1 := Canvas; +if assigned( Canvas1) then + Canvas1.Put( Datum) +end; + +procedure TNodeParent.PutPrefix( const Prefix: string); +begin +if Prefix <> '' then + Put( Prefix + ':') +end; + +{ TElement } + +procedure TElement.AddAttribute( const Namespace, LocalName, Value: string); +var + Prefix: string; +begin +Assert( not FhasChildren, 'Cannot add attributes after child nodes.'); +if not FNamespaces.HasNamespace( Namespace, Prefix) then + begin + FNamespaces.DeclareNamespace( 'ns0', Namespace); + FNamespaces.HasNamespace( Namespace, Prefix) + end; +PutPrefix( Prefix); +Put( LocalName + '="' + AttributeOutputEscape( Value) + '" ') +end; + +procedure TElement.AddComment( const Content: string); +begin +SetChildNodes; +inherited AddComment( Content) +end; + +function TElement.AddElement( const URI, LocalName: string): IXMLWriter_Element; +begin +SetChildNodes; +result := TElement.Create( URI, LocalName, Canvas, self, FNamespaces, FLevel) +end; + +procedure TElement.AddProcessingInstruction( const Target, Content: string); +begin +SetChildNodes; +inherited AddProcessingInstruction( Target, Content) +end; + +procedure TElement.SetChildNodes; +begin +if FhasChildren then exit; +FhasChildren := True; +Put( '>'#$0A) +end; + +procedure TElement.AddTextNode( const Value: string); +begin +SetChildNodes; +inherited AddTextNode( Value) +end; + +function TElement.Close: IXMLWriter_NodeParent; +begin +if FhasChildren then + begin + PutIndent; + Put( ''#$0A); + result := FParent +end; + +constructor TElement.Create( + const URI, LocalName: string; const Canvas1: IStringStream; + const Parent1: IXMLWriter_NodeParent; Namespaces: TNamespaceAxis; + Level1: integer); +begin +FLevel := Level1 + 1; +inherited Create( Canvas1, Parent1); +FURI := URI; +FLocalName := LocalName; +FhasChildren := False; +FNamespaces := TNamespaceAxis.Create( Namespaces); +if FURI <> '' then + FNamespaces.DeclareNamespace( 'ns0', FURI); +FNamespaces.HasNamespace( FURI, FPrefix); +PutIndent; +Canvas.Put( '<'); +PutPrefix( FPrefix); +Put( FLocalName + ' ') +end; + +procedure TElement.DeclareDefaultNamespace( const URI: string); +begin +FNamespaces.DeclareDefaultNamespace( URI) +end; + +procedure TElement.DeclareNamespace( const PreferredPrefix, URI: string); +begin +FNamespaces.DeclareNamespace( PreferredPrefix, URI) +end; + +destructor TElement.Destroy; +begin +FNamespaces.Free; +inherited +end; + +function TElement.ElementStack: string; +var + ParentElement: IXMLWriter_Element; +begin +if Supports( FParent, IXMLWriter_Element, ParentElement) then + result := ParentElement.ElementStack + else + result := ''; +result := result + '/' + FLocalName +end; + +const IndentFactor = 2; // 2 spaces of indentation per level. + +procedure TElement.PutIndent; +var + sWhite: string; + j: integer; + Spaces: integer; +begin +Spaces := FLevel * IndentFactor; +if Spaces <= 0 then exit; +SetLength( sWhite, Spaces); +for j := 1 to Spaces do + sWhite[j] := ' '; +Put( sWhite) +end; + +procedure TElement.UnDeclareDefaultNamespace; +begin +FNamespaces.UnDeclareDefaultNamespace +end; + +procedure TElement.UnDeclareNamespace( const URI: string); +begin +FNamespaces.UnDeclareNamespace( URI) +end; + +{ TDocument } + +function TDocument.AddElement( const URI, LocalName: string): IXMLWriter_Element; +begin +result := TElement.Create( URI, LocalName, Canvas, self, nil, -1) +end; + +procedure TDocument.AddTextNode( const Value: string); +begin +if XMLTrim( Value) = '' then + inherited AddTextNode( Value) + else + raise Exception.Create( 'Cannot add text child to a document, except white space.') +end; + + +function TDocument.Close: IXMLWriter_NodeParent; +begin +FreeAndNil( FOutStream); +result := nil +end; + +constructor TDocument.Create( OutStream1: TStream); +begin +sXLog := ''; +FOutStream := OutStream1; +inherited Create( nil, nil) +end; + +destructor TDocument.Destroy; +begin +Close; +inherited +end; + + +procedure TDocument.Put( const Datum: string); +var + AsUTF8: UTF8String; + Len: integer; +begin +sXLog := sXLog + Datum; +AsUTF8 := UTF8Encode( StringReplace( Datum, #$0D#$0A, #$0A, [rfReplaceAll])); +Len := Length( AsUTF8); +if Len > 0 then + FOutStream.WriteBuffer( AsUTF8[1], Len) +end; + +{ TNamespaceAxis } + +constructor TNamespaceAxis.Create( InheriteFrom: TNamespaceAxis); +begin +FInheritedDeclarations := InheriteFrom; +FDeclaredNamespaces := TDictionary.Create; +if assigned( FInheritedDeclarations) then + FDefaultNamespace := FInheritedDeclarations.FDefaultNamespace + else + begin + FDefaultNamespace := ''; + FDeclaredNamespaces.Add( 'http://www.w3.org/XML/1998/namespace', 'xml'); + FDeclaredNamespaces.Add( 'http://www.w3.org/2000/xmlns/', 'xmlns') + end; +FUndeclaredNamespaces := TDictionary.Create +end; + +destructor TNamespaceAxis.Destroy; +begin +FDeclaredNamespaces.Free; +FUndeclaredNamespaces.Free; +inherited +end; + + +procedure TNamespaceAxis.DeclareDefaultNamespace( const URI: string); +begin +FDefaultNamespace := URI +end; + +procedure TNamespaceAxis.DeclareNamespace( const PreferredPrefix, URI: string); +var + Prefix: string; + Dummy: string; + n: integer; +begin +if HasNamespace( URI, Prefix) then exit; +if FUndeclaredNamespaces.ContainsKey( URI) then + FUndeclaredNamespaces.Remove( URI) + else + begin + Prefix := PreferredPrefix; + n := -1; + while HasPrefix( Prefix, Dummy) do + begin + Inc( n); + Prefix := Format( 'ns%d', [n]) + end; + FDeclaredNamespaces.Add( URI, Prefix) + end +end; + +function TNamespaceAxis.HasNamespace( + const URI: string; var Prefix: string): boolean; +begin +result := URI = FDefaultNamespace; +if result then + begin + Prefix := ''; + exit; + end; +result := FDeclaredNamespaces.ContainsKey( URI); +if result then + Prefix := FDeclaredNamespaces[ URI] + else + result := assigned( FInheritedDeclarations) and + FInheritedDeclarations.HasNamespace( URI, Prefix) and + (not FUndeclaredNamespaces.ContainsKey( URI)) +end; + +function TNamespaceAxis.HasPrefix( + const Prefix: string; var URI: string): boolean; +var + Pair: TPair; +begin +result := FDeclaredNamespaces.ContainsValue( Prefix); +if result then + for Pair in FDeclaredNamespaces do + begin + if Pair.Value = Prefix then + URI := Pair.Key + end + else + result := assigned( FInheritedDeclarations) and + FInheritedDeclarations.HasPrefix( Prefix, URI) and + (not FUndeclaredNamespaces.ContainsValue( Prefix)) +end; + +function TNamespaceAxis.Serialise: string; +var + InheritedDefault: string; + Pair: TPair; +begin +if assigned( FInheritedDeclarations) then + InheritedDefault := FInheritedDeclarations.FDefaultNamespace + else + InheritedDefault := ''; +if FDefaultNamespace <> InheritedDefault then + result := 'xmlns="' + FDefaultNamespace + '" '; +for Pair in FDeclaredNamespaces do + result := result + 'xmlns:' + Pair.Value + '="' + Pair.Key + '" '; +for Pair in FUndeclaredNamespaces do + result := result + 'xmlns:' + Pair.Value + '="" '; +end; + +procedure TNamespaceAxis.UnDeclareDefaultNamespace; +begin +FDefaultNamespace := '' +end; + +procedure TNamespaceAxis.UnDeclareNamespace( const URI: string); +var + Prefix: string; +begin +if URI = FDefaultNamespace then + FDefaultNamespace := ''; +if FDeclaredNamespaces.ContainsKey( URI) then + FDeclaredNamespaces.Remove( URI); +if HasNamespace( URI, Prefix) then + FUndeclaredNamespaces.Add( URI, Prefix) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.pas new file mode 100644 index 0000000..cb4493e --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.XMLWriter.pas @@ -0,0 +1,106 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.XMLWriter; +interface + + +uses Classes; + +type +IXMLWriter_Element = interface; +IXMLWriter_NodeParent = interface + ['{14A30196-F7B1-4D37-9C7A-BDA9B520CB96}'] + function Close: IXMLWriter_NodeParent; + function AddElement( const URI, LocalName: string): IXMLWriter_Element; + procedure AddProcessingInstruction( const Target, Content: string); + procedure AddComment( const Content: string); + procedure AddTextNode( const Value: string); + end; + +IXMLWriter_Element = interface( IXMLWriter_NodeParent) + ['{5F7435DA-A642-4B3D-AD6A-4ED8799DDA2D}'] + procedure DeclareNamespace( const PreferredPrefix, URI: string); + procedure UnDeclareNamespace( const URI: string); + procedure DeclareDefaultNamespace( const URI: string); + procedure UnDeclareDefaultNamespace; + procedure AddAttribute( const Namespace, LocalName, Value: string); + function ElementStack: string; + end; + +IXMLWriter_Document = interface( IXMLWriter_NodeParent) + ['{EF843DAD-8609-46A8-A77D-B78D3D0F4BAE}'] + end; + +IXMLWriter = interface + ['{D51A54E2-30C5-417A-B896-A91BFD267DAE}'] + function OpenDocument( OutStream1: TStream): IXMLWriter_Document; + end; + + + +implementation + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.dfm b/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.dfm new file mode 100644 index 0000000..580e6e1 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.dfm @@ -0,0 +1,412 @@ +object dmVirtualTreeNonVisualSupport: TdmVirtualTreeNonVisualSupport + OldCreateOrder = False + Height = 146 + Width = 255 + object imglstStates16x16: TImageList + Left = 72 + Top = 40 + Bitmap = { + 494C01010B003500300010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000003000000001002000000000000030 + 00000000000000000000000000000000000000000000B5B5B500EDEDED00EAEA + EA00EBEBEB00EBEBEB00EBEBEB00EBEBEB00EBEBEB00EBEBEB00EBEBEB00EBEB + EB00EBEBEB00EAEAEA00EDEDED00B5B5B5000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FCFCFC00FCFCFC0000000000FCFCFC00FCFCFC0000000000FCFCFC000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F4F4F400D9D9D900D9D9D900FCFC + FC00F9F9F900F8F8F800F8F8F800F8F8F800F8F8F800F8F8F800F8F8F800F8F8 + F800F9F9F900FCFCFC00D9D9D900D9D9D900FEFAF700B6C4D600ABB6C700ABB6 + C700ABB6C700ABB6C700ACB6C700ACB7C700ACB6C700ACB7C700ACB7C700ABB6 + C600AEB9CA00C7CFDB00FFFFFE00000000000000000000000000000000000000 + 0000FDFDFD0000000000A0A0A00000000000000000007F7F7F00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300E0E0E000E6E6E600EAEA + EA00FDFDFD00FBFBFB00FBFBFB00FBFBFB00FBFBFB00FBFBFB00FBFBFB00FBFB + FB00FDFDFD00EAEAEA00E6E6E600E0E0E0005B98E0000D80F7001383F8001080 + F7000F7FF8000D7EF8000B7DF800097CF800077BF700057AF700037AF7000279 + F7000179F700006EF300AABFDC00000000000000000000000000000000000000 + 000000000000F1F1F10000000000191919002C2C2C0000000000D3D3D3000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FFFFFF00D7D7 + D700FDFDFD00FEFEFE00FDFDFD00FDFDFD00FFFFFF00FDFDFD00FDFDFD00FEFE + FE00FDFDFD00D7D7D700FFFFFF00DFDFDF007FB0EB00017BF7000076F5000D85 + F7000A83F6000A83F6000B84F8000C88FE000B83F6000B83F6000C84F6000A83 + F6000075F5000074F300CDDCF000000000000000000000000000000000000000 + 000000000000C8C8C800000000008B8B8B00D1D1D10000000000A4A4A4000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FFFF + FF00D4D4D400FFFFFF00FFFFFF00FFFFFF00DDDDDD00FFFFFF00FFFFFF00FFFF + FF00D4D4D400FFFFFF00FBFBFB00DFDFDF00F7F7FA002183ED000070F5003FAF + FC0045B5FC0044B5FE0042B0F5003785B50045B9FF0044B4FC0049B9FD002094 + F8000075F6004490E7000000000000000000FF000000FF000000000000000000 + 000000000000CCCCCC0000000000898989008181810000000000A7A7A7000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FEFE + FE00F9F9F900DFDFDF00FFFFFF00D4D4D400D4D4D400D4D4D400FFFFFF00DFDF + DF00F9F9F900FEFEFE00FBFBFB00DFDFDF00000000007EADE800077DF7000B83 + F60044B5FC003FB3FF003184BA000F0A050041BCFF003EAFFC003EAFFC000071 + F4000074EE00DDE5F40000000000000000000000000000000000FF000000FF00 + 000000000000CDCDCD00000000008B8B8B007979790000000000A5A5A5000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FDFD + FD00FFFFFF00E8E8E800DFDFDF00D4D4D400FFFFFF00D4D4D400DFDFDF00E8E8 + E800FFFFFF00FDFDFD00FBFBFB00DFDFDF0000000000FFFCFB002282EB00006E + F40035A7FA003FB0FC0040B8FF003694D3003FB3FF0043B4FC00148BF7000076 + F6005396E6000000000000000000000000000000000000000000000000000000 + 0000FF000000FF000000FF000000878787008D8D8D0000000000A8A8A8000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FDFD + FD00FFFFFF00FFFFFF00C3C3C300FFFFFF00FAFAFA00FFFFFF00C3C3C300FFFF + FF00FFFFFF00FDFDFD00FBFBFB00DFDFDF0000000000000000008AB4EA000A7E + F7000680F50045B6FE003EB1FF001C394B0042BCFF003BACFB000070F4000B79 + EF00E7ECF6000000000000000000000000000000000000000000000000000000 + 000000000000CFCFCF0000000000FF000000FF00000000000000A6A6A6000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FDFD + FD00FFFFFF00C2C2C200F9F9F900FCFCFC00FAFAFA00FCFCFC00F9F9F900C2C2 + C200FFFFFF00FDFDFD00FBFBFB00DFDFDF000000000000000000FFFEFC002D88 + EC00006DF40032A6FE003CA1E200151E220049C5FF000F86F6000078F60066A1 + E800000000000000000000000000000000000000000000000000000000000000 + 000000000000D0D0D000000000008888880095959500FF000000FF000000FF00 + 00000000000000000000FF000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FBFBFB00FFFF + FF00D6D6D600E7E7E700FFFFFF00FBFBFB00FBFBFB00FBFBFB00FFFFFF00E7E7 + E700D6D6D600FFFFFF00FBFBFB00DFDFDF0000000000000000000000000093B9 + EB000E81F600037FFA003F9ED8001E3C4D003BB5FF00006FF400117BEE00F2F3 + F800000000000000000000000000000000000000000000000000000000000000 + 000000000000CECECE0000000000858585008080800000000000A6A6A6000000 + 0000FF000000FF000000FF000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FDFDFD00EEEE + EE00D0D0D000FFFFFF00FCFCFC00FCFCFC00FCFCFC00FCFCFC00FCFCFC00FFFF + FF00D0D0D000EEEEEE00FDFDFD00DFDFDF00000000000000000000000000FFFF + FE003087E900006FF5002EA3FE004BC3FF000A82F600027BF70073A7E7000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000D0D0D0000000000089898900C4C4C40000000000A9A9A9000000 + 000000000000FF000000FF000000FF0000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300DFDFDF00FEFEFE00C1C1 + C100FFFFFF00FDFDFD00FCFCFC00FCFCFC00FCFCFC00FCFCFC00FCFCFC00FDFD + FD00FFFFFF00C1C1C100FEFEFE00DFDFDF000000000000000000000000000000 + 00009BBEEB001181F700017BF50039AAFB00006EF4001D80EB00FAF9FA000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000CECECE00000000001F1F1F004444440000000000A1A1A1000000 + 0000FF000000FF000000FF000000FF0000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F3F3F300E5E5E500C5C5C500FAFA + FA00FFFFFF00FEFEFE00FEFEFE00FEFEFE00FEFEFE00FEFEFE00FEFEFE00FEFE + FE00FFFFFF00FAFAFA00C5C5C500E5E5E5000000000000000000000000000000 + 0000000000003A8CEA000073F5000076F4000B80F70084B1E900000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000EBEBEB006F6F6F0074747400747474006E6E6E00D7D7D7000000 + 0000FCFCFC00FDFDFD0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F6F6F600C0C0C000E9E9E900FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00E9E9E900C0C0C0000000000000000000000000000000 + 000000000000A8C5ED001684F6000071F5002883EB00FFFFFD00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000EFEFEF00858585009595950098989800979797009797970085858500DDDD + DD0000000000FEFEFE0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000B4B4B400FDFDFD00F6F6 + F600F6F6F600F6F6F600F6F6F600F6F6F600F6F6F600F6F6F600F6F6F600F6F6 + F600F6F6F600F6F6F600FDFDFD00B4B4B4000000000000000000000000000000 + 000000000000000000003789E7001082F8008EB6EA0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000C7C7C700000000000A0A0A00070707000B0B0B000A0A0A0000000000A8A8 + A80000000000FCFCFC0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FFFFFF00E1E1E100D9D9D900DADA + DA00DADADA00DADADA00DADADA00DADADA00DADADA00DADADA00DADADA00DADA + DA00DADADA00DADADA00D9D9D900E1E1E1000000000000000000000000000000 + 00000000000000000000E6EEF8009BC0EF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FEFEFE00FEFEFE0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000F5E1 + B600DB940000EECC7F00DA8F0000FDFCF800E8BA5200FEFEFC00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000F8E9C600DF950000EABC + 4D00E0990000DF960000E19C0000DF980000E4A7180000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC66001CAC66001CAC66001CAC66001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000001CAC6600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000EBB93D00E49D + 0000E6A40000F0CB6E00E9AF1C00E59F0000E9B12300E8AC1300F8E6BB000000 + 0000000000000000000000000000000000000000000000000000B7B7D2003333 + 7F00B7B7D20000000000000000000000000000000000B7B7D20033337F00B7B7 + D200000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000001CAC6600FF0000001CAC66000000000000000000000000000000 + 000000000000000000000000000000000000FBF0D500E79D0000EAA70000EAA7 + 0000FDFAF2000000000000000000ECB21700E9A30000EFC34D00FEFFFF000000 + 00000000000000000000000000000000000000000000B7B7D80033338E001111 + D80033338E00B7B7D8000000000000000000B7B7D80033338E001111D8003333 + 8E00B7B7D8000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 00000000000000000000000000000000000000000000FEFDF900EDAB0000EEB1 + 0A00000000000000000000000000F2C13E00EDAA0000F0B61900FBEBBF000000 + 0000000000000000000000000000000000000000000033339B001111D0001111 + D0001111D00033339B00B7B7DB00B7B7DB0033339B001111D0001111D0001111 + D00033339B000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000001CAC + 6600FF000000FF000000FF000000FF000000FF0000001CAC6600000000000000 + 000000000000000000000000000000000000FEFEFD00EEB40B00EEB00100EEAF + 0000F5D3730000000000F9E7B000EEAF0000EFB61300F4CE6200F4D992000000 + 0000DFA21F00E7BB5A0000000000F5E2B90000000000B7B7DD0033339F001111 + C4001111C4001111C40033339F0033339F001111C4001111C4001111C4003333 + 9F00B7B7DD000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 00000000000000000000000000000000000000000000000000001CAC66001CAC + 660035C38000FF000000FF000000FF00000030BF7E001CAC66001CAC66000000 + 00000000000000000000000000000000000000000000FDF6E400F9E3A600EEB0 + 0000EFB20200EEAF0000EEB20000EFB50C00F0B50700F2D07500D98D0000F6E4 + BB00DC950000E3A92400EDC87500D78500000000000000000000B7B7DE003333 + A3001111B8001111B8001111B8001111B8001111B8001111B8003333A300B7B7 + DE00000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000F3C94900F6D4 + 6F00F3C53D00F2BE2400F1BB1700F4CF5E00EFC55200FCF0CB00E09A0000E099 + 0000E19D0000E19C0000E0990000E4A71400000000000000000000000000B7B7 + DF003333A7001515AF001111AC001111AC001111AC003333A700B7B7DF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000F5D36600FAE9B600FAE8AE00F3CE5A00E39E0000E39D0000E5A30000E39D + 0000E9AF2000E7AB1500E49E0000E5A20000000000000000000000000000B7B7 + E1003333AB002525B4001111A2001111A2001414A5003333AB00B7B7E1000000 + 00000000000000000000000000000000000000000000000000001CAC66001CAC + 660035C38000FF000000FF000000FF00000030BF7E001CAC66001CAC66000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000FBF2DA00E7A30000E7A20000F5DB + 99000000000000000000F1CC6A00E8A300000000000000000000B7B7E3003333 + AF005353DB002E2EB7003D3DC6003131BA0015159F001E1EA8003333AF00B7B7 + E300000000000000000000000000000000000000000000000000000000001CAC + 6600FF000000FF000000FF000000FF000000FF0000001CAC6600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000EEB51C00EAA50000ECAA0000EDB10D000000 + 0000000000000000000000000000EBA3000000000000B7B7E4003333B3006767 + EF003636BE005E5EE6003333B3003333B3004F4FD7003636BE004545CD003333 + B300B7B7E4000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000FAEDC500F6D57A00EDAD0000EEAF0100FEFE + FC000000000000000000FCF3D900ECA90000000000003333B5007676FE004C4C + D4007272FA003333B500B7B7E500B7B7E5003333B5006262EA004C4CD4005C5C + E4003333B5000000000000000000000000000000000000000000000000000000 + 0000000000001CAC6600FF0000001CAC66000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC6600FF000000FF000000FF0000001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000F5D16C00EEAD0000EFB10500F1BB + 2400FAE9B900F9E4A900EFB41100EFB2080000000000B7B7E6003333B8007777 + FF003333B800B7B7E6000000000000000000B7B7E6003333B8007070F8003333 + B800B7B7E6000000000000000000000000000000000000000000000000000000 + 000000000000000000001CAC6600000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00001CAC66001CAC66001CAC66001CAC66001CAC660000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000FDF4DE00EFB40700F6D78100EFB61000EFB5 + 0800EFB20000EFB20000EFB60C00F1BC21000000000000000000B7B7E7003333 + BB00B7B7E70000000000000000000000000000000000B7B7E7003333BB00B7B7 + E700000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000EEB00000F3C7 + 4400F0BB1900F2C02900F1BE2400F0B910000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000FCF4DD00F5D264000000 + 0000F4C94400F7D97D0000000000F3C840000000000000000000000000000000 + 0000FCFCFC00FCFCFC0000000000FCFCFC00FCFCFC0000000000FCFCFC000000 + 00000000000000000000000000000000000000000000FFFFFF00696969000000 + 0000000000000000000005050500000000000000000000000000000000000000 + 000000000000FFFFFF0000000000FFFFFF000000000000000000000000000000 + 00000000000087CF8B002CA932002A942F00ADE3B00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000087CF8B002CA932002A942F00ADE3B00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FDFDFD0000000000A0A0A00000000000000000007F7F7F00000000000000 + 000000000000000000000000000000000000FBFBFB00FFFFFF00606060000000 + 0000CFCFCF000000000008080800262626002222220022222200262626000303 + 030000000000FFFFFF00FBFBFB00FFFFFF000000000000000000000000000000 + 0000B3DFB60005910E0079F0840086FF920011871500D1FAD600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000B3DFB60005910E0000FFFF0000FFFF0011871500D1FAD600000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000F1F1F10000000000191919002C2C2C0000000000D3D3D3000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF005A5A5A004F4F + 4F00FFFFFF002D2D2D009D9D9D00FFFFFF00FFFFFF00FFFFFF00FFFFFF008787 + 870000000000FFFFFF00FEFEFE00FFFFFF00000000000000000000000000D7EC + DA0003860F004AD8560064FF73006CFF7B005AF7670018871D00DEF6E0000000 + 000000000000000000000000000000000000000000000000000000000000D7EC + DA0003860F004AD8560000FFFF0000FFFF0000FFFF0018871D00DEF6E0000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000C8C8C800000000008B8B8B00D1D1D10000000000A4A4A4000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00616161000909 + 090036363600E5E5E50000000000000000000000000000000000000000000000 + 000000000000FFFFFF00F9F9F900FFFFFF000000000000000000E5EEE500248F + 2E002AB5350058FB67006DF27A0065F473005DFF6E0037D241003D9C4200EFF8 + F100000000000000000000000000000000000000000000000000E5EEE500248F + 2E0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0037D241003D9C4200EFF8 + F100000000000000000000000000000000000000000000000000000000000000 + 000000000000CCCCCC0000000000898989008181810000000000A7A7A7000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00646464000000 + 0000000000000000000003030300000000000000000000000000000000000101 + 010000000000FFFFFF0000000000FFFFFF0000000000F3F6F300519957000F98 + 1B0047E4550071E67C0094ED9C008AF0940056EB640050F5600022B32C005FA7 + 64000000000000000000000000000000000000000000F3F6F300519957000F98 + 1B0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0022B32C005FA7 + 6400000000000000000000000000000000000000000000000000000000000000 + 000000000000CDCDCD00000000008B8B8B007979790000000000A5A5A5000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00636363000000 + 0000C3C3C30000000000070707001E1E1E001B1B1B001B1B1B001F1F1F000000 + 000000000000FFFFFF0000000000FFFFFF00000000008AB78E001886220035C8 + 45007BDF840095E69D00A8E4AD00A4E3A90079E8830044E4540042E151000E8F + 170079B17D00000000000000000000000000000000008AB78E001886220000FF + FF0000FFFF0095E69D00A8E4AD00A4E3A90000FFFF0000FFFF0000FFFF000E8F + 170079B17D000000000000000000000000000000000000000000000000000000 + 000000000000D0D0D00000000000878787008D8D8D0000000000A8A8A8000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF005A5A5A004545 + 4500FFFFFF002C2C2C009C9C9C00FFFFFF00FFFFFF00FFFFFF00FFFFFF008B8B + 8B0000000000FFFFFF00FDFDFD00FFFFFF00BAD7BC003B92430047BA520080D9 + 890097DE9E00B4EABA0078BE7E0063B46800A5E7AB005CDB68003BDD4A0034C9 + 4100007205009FC19F000000000000000000BAD7BC003B92430047BA520000FF + FF0000FFFF00B4EABA0078BE7E0063B46800A5E7AB0000FFFF0000FFFF0034C9 + 4100007205009FC19F0000000000000000000000000000000000000000000000 + 000000000000CFCFCF0000000000888888007E7E7E0000000000A6A6A6000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00606060000B0B + 0B0040404000E0E0E00000000000000000000000000000000000000000000000 + 000000000000FFFFFF0000000000FFFFFF0088BD8B004CA053009FDEA6009ED9 + A400BBEABF0088CA8D0061BB680084CC8A0062B569009FE9A60048D055002DD4 + 3D0024B13100075F0B00C2D0C2000000000088BD8B004CA0530000FFFF0000FF + FF00BBEABF0088CA8D0061BB680084CC8A0062B569009FE9A60000FFFF0000FF + FF0024B13100075F0B00C2D0C200000000000000000000000000000000000000 + 000000000000D0D0D00000000000888888009595950000000000A8A8A8000000 + 000000000000000000000000000000000000FFFFFF00FFFFFF00636363000000 + 0000000000000404040000000000000000000000000000000000000000000000 + 000000000000FFFFFF00FDFDFD00FFFFFF00D8EBDA0062AD6900A2D2A700D2EA + D700ACD7AE0039A93C00DEF3DF00000000005AB9620072BB78008BDF930034C3 + 42001DC92E001592200029632B00D7DFD700D8EBDA0062AD6900A2D2A70000FF + FF00ACD7AE0039A93C00DEF3DF00000000005AB9620072BB78008BDF930000FF + FF0000FFFF001592200029632B00D7DFD7000000000000000000000000000000 + 000000000000CECECE0000000000858585008080800000000000A6A6A6000000 + 000000000000000000000000000000000000FDFDFD00FFFFFF005F5F5F000000 + 000001010100030303000B0B0B000C0C0C000808080008080800000000000202 + 020000000000FFFFFF00FBFBFB00FFFFFF0000000000AFD9B1005DB36300C1E0 + C4002AA03000C9E7C8000000000000000000ECFBEE0032A23C0082C4880073D1 + 7C001FB72D000CB91E000A7914004B784E0000000000AFD9B1005DB36300C1E0 + C4002AA03000C9E7C8000000000000000000ECFBEE0032A23C0082C4880073D1 + 7C0000FFFF000CB91E000A7914004B784E000000000000000000000000000000 + 000000000000D0D0D0000000000089898900C4C4C40000000000A9A9A9000000 + 000000000000000000000000000000000000FEFEFE00FFFFFF00D7D7D7000000 + 000000000000FFFFFF00CECECE00D1D1D100CFCFCF00FFFFFF003C3C3C000000 + 00006A6A6A00FFFFFF00FDFDFD00FFFFFF0000000000FFFFFE008CCE9000249B + 2E0093D2970000000000000000000000000000000000B9E4BD00379B3D0092CC + 980059BE630008A6180002A20F000D6E150000000000FFFFFE008CCE9000249B + 2E0093D2970000000000000000000000000000000000B9E4BD00379B3D0092CC + 980059BE630000FFFF0002A20F000D6E15000000000000000000000000000000 + 000000000000CECECE00000000001F1F1F004444440000000000A1A1A1000000 + 000000000000000000000000000000000000FDFDFD0000000000FFFFFF00FDFD + FD00DEDEDE00FFFFFF0000000000000000000000000090909000F5F5F500E9E9 + E900FFFFFF00FBFBFB00FAFAFA00FFFFFF000000000000000000F0F9F100C5E4 + C700FCFEFD00000000000000000000000000000000000000000093CD9600439A + 4A00A4CFA8003CA24700008D06000D9013000000000000000000F0F9F100C5E4 + C700FCFEFD00000000000000000000000000000000000000000093CD9600439A + 4A00A4CFA8003CA2470000FFFF000D9013000000000000000000000000000000 + 000000000000EBEBEB006F6F6F0074747400747474006E6E6E00D7D7D7000000 + 0000FCFCFC00FDFDFD000000000000000000F9F9F900FEFEFE00FBFBFB00FDFD + FD00FFFFFF00F5F5F5000000000001010100000000008F8F8F00FFFFFF00FDFD + FD00FFFFFF00FBFBFB00FDFDFD00FFFFFF000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000067B9 + 6B005DA16100A3CAA8001D832600288F2F000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000067B9 + 6B005DA16100A3CAA8001D832600288F2F000000000000000000000000000000 + 0000EFEFEF00858585009595950098989800979797009797970085858500DDDD + DD0000000000FEFEFE000000000000000000FFFFFF0000000000FFFFFF00FDFD + FD00F8F8F800FDFDFD0039393900000000001A1A1A00B8B8B800FFFFFF00FFFF + FF00FBFBFB00FFFFFF00FDFDFD00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00002C9D330083B288009AC29D0067A36D000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00002C9D330083B288009AC29D0067A36D000000000000000000000000000000 + 0000C7C7C700000000000A0A0A00070707000B0B0B000A0A0A0000000000A8A8 + A80000000000FCFCFC000000000000000000FFFFFF00FFFFFF00FFFFFF00FDFD + FD00FFFFFF00FFFFFF0053535300E1E1E1001C1C1C00FFFFFF00FEFEFE00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000820900ACC5AD005C9E62000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000820900ACC5AD005C9E62000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000FEFEFE00FEFEFE000000000000000000FFFFFF00FFFFFF00FFFFFF00FDFD + FD00FDFDFD00FFFFFF00CECECE002A2A2A008E8E8E00FFFFFF00F9F9F900FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000E2F4E300017F0900A5CFA9000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000E2F4E300017F0900A5CFA900424D3E000000000000003E000000 + 2800000040000000300000000100010000000000800100000000000000000000 + 000000000000000000000000FFFFFF008000FFFFF25F000000000001F43F0000 + 00000001F81F000000000001F81F000000000003381F000000008003C81F0000 + 00008007F01F00000000C007F81F00000000C00FF80D00000000E00FF8110000 + 0000E01FF81800000000F01FF81000000000F83FF81300000000F83FF00B0000 + 8000FC7FF00B00000000FCFFFFF30000FFFFFFFFFFFFE03FFFFFFFFFFFFF807F + FFFFF07FFDFFC01FC78FF07FF8FF061F8307F07FF07F8E1F8007F07FE03F0412 + 8007F07FC01F8000C00FF07FF07FC000E01FF07FF07FF000E01FC01FF07FFF0C + C00FE03FF07FFE1E8007F07FF07FFE0C8007F8FFF07FFF008307FDFFF07FFE00 + C78FFFFFFFFFFFC0FFFFFFFFFFFFFF92F25F8002F87FF87FF43F0000F03FF03F + F81F0000E01FE01FF81F0000C00FC00FF81F0002800F800FF81F000280078007 + F81F000000030003F81F000200010001F81F000001000100F81F000083008300 + F81F000087808780F81F4000C7C0C7C0F8130000FFE0FFE0F00B4000FFF0FFF0 + F00B0000FFF8FFF8FFF30000FFF8FFF800000000000000000000000000000000 + 000000000000} + end +end diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.pas new file mode 100644 index 0000000..d51c4ca --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.dmVirtualTreeNonVisualSupport.pas @@ -0,0 +1,85 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.dmVirtualTreeNonVisualSupport; +interface +uses + SysUtils, Classes, ImgList, Controls; + +type + TdmVirtualTreeNonVisualSupport = class(TDataModule) + imglstStates16x16: TImageList; + private + { Private declarations } + public + { Public declarations } + end; + + +implementation + +{$R *.dfm} + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.dfm b/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.dfm new file mode 100644 index 0000000..e8b30fb --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.dfm @@ -0,0 +1,410 @@ +object fmAboutDUnitM: TfmAboutDUnitM + Left = 0 + Top = 0 + BorderIcons = [biSystemMenu] + BorderStyle = bsDialog + Caption = 'About this application and the DUnit-M framework' + ClientHeight = 571 + ClientWidth = 679 + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poOwnerFormCenter + OnShow = FormShow + DesignSize = ( + 679 + 571) + PixelsPerInch = 96 + TextHeight = 13 + object imgLogo: TImage + Left = 8 + Top = 8 + Width = 64 + Height = 64 + Picture.Data = { + 07544269746D6170360C0000424D360C00000000000036000000280000002000 + 0000200000000100180000000000000C00000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000FCFCFCD8D8D8B8B8B8A3A3A3C0C0C0E6E6E6FCFCFC0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + FFFFFFCECECE5B5B5B1717171F1F1F2E2E2E3232322929291515152121218989 + 89CDCDCD00000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000010101A2A2A2565656 + 4E4E4E3131314141415252525353535555555B5B5B5959595353534848482828 + 28232323454545585858F5F5F500000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000BABABA484848474747 + 4A4A4A5252525555555E5E5E7373738484849494948A8A8A7E7E7E7A7A7A7878 + 785D5D5D2D2D2D2B2B2B353535ABABAB00000000000000000000000000000000 + 0000000000000000000000000000000000F6F6F67474744F4F4F545454535353 + 5F5F5F777777A7A6A4CAC8C4D8D5CFDEDAD4E3E0D9E2DFDBE3E1DEDFDEDDAEAD + ADA4A4A48787875D5D5D2E2E2E353535595959F3F3F300000000000000000000 + 0000000000000000000000000000F7F7F77373735959595858585B5B5B707070 + 9D9B99D1CBC2EBE4D7F8EFE1FCF5E7FCF6EAFCF6ECFDF7EFFDF9F2FAF7F1F3F0 + EDE6E4E3BFBFBF9A9A9A6F6F6F3535352D2D2D4C4C4C00000000000000000000 + 0000000000000000000000070707838383616161606060626262858483BDB9B0 + EEE9D1F3EFD6FBF1DFFBF2E2FCF3E4FCF4E7FCF5EAFCF6EBFDF7EEFDF8F1FDF9 + F3F4F1F4F2F1F3EAE9E8A7A7A78787873D3D3D30303080808000000000000000 + 0000000000000000000000CACACA6969696363636565657A7A7ACBC4B7EEE7CD + 8BDB7CA1E090FBF0DDFBF1DFFCF3E2FCF3E4FCF4E6FCF5EAFCF6ECFDF7EEFCF8 + F1A3A3E28B8CDFE9E7F2E6E5E4ABABAB797979373737333333ACACAC00000000 + 0000000000000000C2C2C27676767070706868687A7A79C2BBADDDE7B96CD661 + 33CC3339CD38DEEBC3FBF0DCFBF1DEFBF2E2FCF3E3FCF3E6FCF5E9FCF6EBD3CF + E74347D1252ACB5256D4E3E1F2EFEFEDA2A2A27575752C2C2C3E3E3E00000000 + 00000000000101018F8F8F7A7A7A7373736A6A6AA9A59BF0E3C771D66336CC35 + 33CC3355D24FE1EAC3FAEFDAFBF0DCFBF1DEFBF2E1FCF3E3FCF4E6FCF5E9DCD8 + E7595CD4252ACC252ACC7073DAE8E6F2D2D1D09999994949492A2A2AEBEBEB00 + 0000000000FFFFFF8F8F8F8686866C6C6C797977E8DCC1A7E09133CC3333CC33 + 7AD76BE8E9C4FAEDD5FAEDD7FAEFDAFBF0DCFBF0DDFBF1E1FCF3E3FCF3E5FCF5 + E8F5F0EA6D6FD8282DCD272CCC8889DFF5F3F0B3B2B27C7C7C3535354E4E4EFE + FEFE000000E6E6E68787878484846B6B6BA7A094E4E8BE62D55B33CC334BD046 + E2E6BBF9EACFFAECD2FAEDD5FAEED6FAEFDAFBF0DCFBF0DDFBF2E1FCF3E3FCF4 + E5FCF5E8DBD7E75155D4242ACD3237CFE7E4EFE2E1DF818181525252222222CC + CCCC000000B2B2B28C8C8C8484846E6D6BD5C8ADB9E6A742D0413BCD39B5DE94 + F9E8CAF9E9CCF9EACEF9EBD1FAEDD4FAEDD6FAEED9FAEFDBFBF0DDFBF1E0FCF3 + E3FCF3E4FCF5E8C5C1E32329CF2329CE9090E0EDEAE6A0A0A06868683737375A + 5A5AFEFEFE9191919595957E7E7E7B7871E8D9BB9AE3933CCE3C5BD151DFE3B3 + F8E7C7F9E8CAF9EACDF9EACEFAECD1FAEDD4FAEDD6FAEED9FBF0DCFBF0DDFBF2 + E0FCF3E3FCF3E5F7EFE74347D42228D06063D8EDE9EEB1B1B079797931313116 + 1616F0F0F0959595A1A1A1727272918B80F1E3C481E08038CD387FD669F8E5C2 + F8E6C5F8E7C6F9E8C9F9E9CCF7E9CDE0D6C29C968E9B958BFAEED8FAEFDBFBF0 + DCFBF1DFFCF3E2FCF3E48181DB2228D24448D6D6D3E9B5B4B283838332323212 + 1212E4E4E49A9A9AA6A6A66969699B9387F0E5C381E0813CCE3C96D879F8E4BF + F8E5C1F8E6C5F8E7C7F9E8C9E9DDC7ADACAB88898B696A6CCEC5B4FAEED8FBF0 + DBFBF0DCFBF1E0FBF2E29B99DD2027D3393ED5CBC8E6BEBCB88686863838381C + 1C1CDFDFDF9E9E9EAEAEAE676767A0988AF0E6C388E28843D043A1D97FF7E3BD + F8E4BEF8E4C1F8E6C4DDCEB28C8984B6B6B8A3A4A687888AACA599F9ECD4FAEE + D7FAEFDBFBF0DCFBF0DEA7A4DD2027D5373CD6C9C6E5C0BEBA81818142424223 + 2323EAEAEAA3A3A3AFAFAF717171928A7EF3E2C296E5954FD44F90D672F7E2BA + F7E3BCF8E4BED4C4A758554F525357B6B6B8B3B3B4BEB9B0F4E6CCFAECD3FAED + D5FAEED7FAEFDBFBF0DC9291DA1F26D54045D7D3CEE3B5B3AF7676763C3C3C1C + 1C1CF7F7F7A8A8A8AEAEAE818181787369ECDAB9ACE8A56EDB6E68D257EBDFAE + F3DEB6C0B1953F3F3F494B4D868279C5BAA3F8E7C7F9E8CBF9EACDF9EACFFAEC + D2FAEDD5FAEED7FAEEDA575AD91E26D75256D9E6DFE1A3A2A06D6D6D39393913 + 1313FFFFFFBABABAB0B0B09898985A5854DDCBA9C6EAB490E49050D049CADB98 + AFA087504F4D686662B7AB95EDDBB8F8E6C3F8E7C6F8E7C7F9E9CBF9EACDF9EB + CFFAECD2FAEDD5E2D8D7262DD91D25D87979DAEEE6D98F8F8F5F5F5F4242422A + 2A2A000000E0E0E0AFAFAFB0B0B0585959B1A38BE3E6BAA4E7A06DD36D59914E + 6A675EB4A68EF7E1B8F7E2BBF8E4BEF8E4BFF8E5C2F8E6C5F8E7C7F9E8CAF9EA + CDF9EACEEFE2D27171D81D25DA2229DACCC5DBD1CBC16F6F6F55555543434390 + 9090000000F2F2F2B7B7B7BABABA6B6C6C74726CEFDDB4BEE7AD91C29259AA5A + 9AC876F4DEB3F7E0B7F7E1B8F7E3BBF8E4BEF8E4BFF8E5C2F8E7C5F8E7C7F9E9 + CAF9EACDA39ED22B32D91D25DA5D5FD9EDE3D2AFADA85D5D5D565656383838D2 + D2D20000000A0A0AC5C5C5BABABAA5A5A54A4A4ABBAF97E8DDB8A9E8A395E595 + 5AD55790D570E7DDAAF6DFB6F7E0B8F7E2BBF7E3BDF8E4BFF8E5C2F8E6C5E8E5 + BAA1DC8642B15F2E4CBF474BD9D2C9D5C6C0B47676765B5B5B4848488C8C8C00 + 0000000000010101D6D6D6B7B7B7BEBEBE7D7D7D5D5A55D7C4A1DCE8BAA5E7A0 + 8FE38F65D8636FD25AB5D888F1DFB3F7E0B8F7E2BAF7E3BDF0E3B9C3DF9B69D4 + 5B3CCD3A35CC3546B262BDB5D1E3D8C48C8A896666665959595C5C5CEEEEEE00 + 0000000000000000FDFDFDD0D0D0B8B8B8BCBCBC66666663615DE1CCA6E8E5BB + ADE8A59CE69B82E08258D5584AD0465BD04E68D2575CD14F3ECD3B33CC3333CC + 333BCE3B6ED765CFE4ADDDD2BC93918C69696963636357575765656500000000 + 0000000000000000000000EDEDEDC4C4C4BEBEBEABABAB5D5D5D6C675FD4C2A0 + EAE3B8CBE9B59EE69D95E59583E08372DC725FD75F56D55653D4535AD65A75DC + 73A8E399E7E8BFDED2BA8A87837070706868685C5C5C767676BEBEBE00000000 + 0000000000000000000000000000DBDBDBC0C0C0C0C0C0B8B8B86C6C6C505050 + A29682DDC9A6F0E3BCDCE7B8BFE7ACB8E8AAB4E8A9B6E7A9C1E8AED7E8BAEFE6 + C3E4D5B7A8A1947777756E6E6E6C6C6C666666757575FFFFFF00000000000000 + 0000000000000000000000000000FDFDFDD8D8D8C2C2C2BDBDBDB8B8B8868686 + 5252525C5853A29987D0C0A4EAD6B1F1DEB6F1E1B7F1DFB8E9D7B7D6C7ADA099 + 8C7B79736D6D6D7272727272726A6A6A7C7C7C8B8B8B00000000000000000000 + 0000000000000000000000000000000000020202E4E4E4C9C9C9BABABAC0C0C0 + B2B2B29090905B5B5B4D4D4E5A5A5A6061616D6C6B6666666060615D5D5D6C6C + 6C7979797B7B7B7676767676768F8F8FFFFFFF01010100000000000000000000 + 0000000000000000000000000000000000000000000000EEEEEECCCCCCC1C1C1 + B6B6B6B9B9B9B6B6B6A4A4A48B8B8B7F7F7F7676767979797F7F7F8A8A8A8F8F + 8F8989897E7E7E8C8C8C909090CECECE00000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000050505FBFBFB + D4D4D4BABABAB3B3B3B3B3B3B2B2B2B4B4B4B2B2B2ABABABA4A4A49C9C9C9292 + 928F8F8FBCBCBCF5F5F501010100000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + FFFFFFF3F3F3D3D3D3B9B9B9B7B7B7B8B8B8B7B7B7B1B1B1A1A1A1A0A0A0CBCB + CBE8E8E8000000000000000000000000000000000000000000FFFFFF00000000 + 0000} + Stretch = True + end + object txtIntro: TStaticText + Left = 88 + Top = 8 + Width = 583 + Height = 64 + Anchors = [akLeft, akTop, akRight] + AutoSize = False + BorderStyle = sbsSunken + Caption = + 'This is an application for the purpose of unit testing.'#13#10'This ap' + + 'plication is based on the DUnit-M unit testing framework.' + Color = clBlack + Font.Charset = DEFAULT_CHARSET + Font.Color = clCream + Font.Height = -16 + Font.Name = 'Tahoma' + Font.Style = [] + ParentColor = False + ParentFont = False + TabOrder = 0 + Transparent = False + end + object pnlFlow: TFlowPanel + Left = 8 + Top = 78 + Width = 663 + Height = 485 + Anchors = [akLeft, akTop, akRight, akBottom] + Caption = 'pnlFlow' + UseDockManager = False + Locked = True + Padding.Left = 10 + Padding.Top = 10 + Padding.Right = 10 + Padding.Bottom = 10 + ShowCaption = False + TabOrder = 1 + object pnlTitle: TPanel + AlignWithMargins = True + Left = 16 + Top = 16 + Width = 310 + Height = 234 + Margins.Left = 5 + Margins.Top = 5 + Margins.Right = 5 + Margins.Bottom = 5 + Caption = 'pnlTitle' + Color = clBlack + ParentBackground = False + ShowCaption = False + TabOrder = 0 + object pnlTitleCaptionBar: TPanel + Left = 1 + Top = 1 + Width = 308 + Height = 24 + Align = alTop + Caption = 'Title' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWhite + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + end + object scrbxTitle: TScrollBox + Left = 1 + Top = 25 + Width = 308 + Height = 208 + HorzScrollBar.Range = 10000 + VertScrollBar.Range = 25 + Align = alClient + AutoScroll = False + BevelInner = bvNone + BevelOuter = bvNone + BorderStyle = bsNone + TabOrder = 1 + object txtTitle: TStaticText + Left = 10 + Top = 10 + Width = 400 + Height = 175 + Align = alCustom + AutoSize = False + BevelInner = bvNone + BevelOuter = bvNone + Caption = + 'DUnit-M unit testing application'#13#10#13#10'Application title:'#13#10' <#AppT' + + 'itle>'#13#10#13#10'Executable filename:'#13#10' <#AppFileName>'#13#10#13#10'Executable lo' + + 'cation:'#13#10' <#AppPath>' + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + ParentFont = False + TabOrder = 0 + Transparent = False + end + object btnDummyButtonToForceScrollBar: TButton + Left = 1000 + Top = 0 + Width = 75 + Height = 25 + Caption = 'btnDummyButtonToForceScrollBar' + TabOrder = 1 + end + end + end + object pnlPlatform: TPanel + AlignWithMargins = True + Left = 336 + Top = 16 + Width = 310 + Height = 234 + Margins.Left = 5 + Margins.Top = 5 + Margins.Right = 5 + Margins.Bottom = 5 + Caption = 'pnlTitle' + Color = clBlack + ParentBackground = False + ShowCaption = False + TabOrder = 1 + object pnlPlatformCaptionBar: TPanel + Left = 1 + Top = 1 + Width = 308 + Height = 24 + Align = alTop + Caption = 'Platform' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWhite + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + end + object txtPlatform: TStaticText + Left = 10 + Top = 31 + Width = 290 + Height = 196 + Align = alCustom + Anchors = [akLeft, akTop, akRight, akBottom] + AutoSize = False + BevelInner = bvNone + BevelOuter = bvNone + Caption = + 'Target platform:'#13#10' <#Platform> VCL'#13#10#13#10'Host platform architectur' + + 'e:'#13#10' <#OSArchitecture>'#13#10#13#10'Operating system version:'#13#10' <#OSVers' + + 'ion>'#13#10#13#10'Now:'#13#10' <#Now>'#13#10' TimeZone <#TZ>' + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + ParentFont = False + TabOrder = 1 + Transparent = False + end + end + object pnlArchitecture: TPanel + AlignWithMargins = True + Left = 16 + Top = 260 + Width = 310 + Height = 213 + Margins.Left = 5 + Margins.Top = 5 + Margins.Right = 5 + Margins.Bottom = 5 + Caption = 'pnlTitle' + Color = clBlack + ParentBackground = False + ShowCaption = False + TabOrder = 2 + object pnlArchitectureCaptionBar: TPanel + Left = 1 + Top = 1 + Width = 308 + Height = 24 + Align = alTop + Caption = 'Architecture' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWhite + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + end + object txtArchitecture: TStaticText + Left = 10 + Top = 31 + Width = 290 + Height = 175 + Align = alCustom + Anchors = [akLeft, akTop, akRight, akBottom] + AutoSize = False + BevelInner = bvNone + BevelOuter = bvNone + Caption = + 'Presentational paradigm:'#13#10' Model-View View Model (MVVM) GUI'#13#10#13#10 + + 'Application type:'#13#10' Desktop' + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + ParentFont = False + TabOrder = 1 + Transparent = False + end + end + object pnlBuild: TPanel + AlignWithMargins = True + Left = 336 + Top = 260 + Width = 310 + Height = 213 + Margins.Left = 5 + Margins.Top = 5 + Margins.Right = 5 + Margins.Bottom = 5 + Caption = 'pnlBuild' + Color = clBlack + ParentBackground = False + ShowCaption = False + TabOrder = 3 + object pnlBuildCaptionBar: TPanel + Left = 1 + Top = 1 + Width = 308 + Height = 24 + Align = alTop + Caption = 'Build' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWhite + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + end + object txtBuild: TStaticText + Left = 10 + Top = 31 + Width = 290 + Height = 175 + Align = alCustom + Anchors = [akLeft, akTop, akRight, akBottom] + AutoSize = False + BevelInner = bvNone + BevelOuter = bvNone + Caption = + 'Delphi Compiler version:'#13#10' <#CompilerVersion>'#13#10' '#13#10'Delphi Compil' + + 'er name:'#13#10' <#CompilerName>'#13#10#13#10'Build-With-packages:'#13#10' <#BuildWi' + + 'thPackages>'#13#10#13#10'$(Config):'#13#10' <#Config>' + Font.Charset = DEFAULT_CHARSET + Font.Color = clYellow + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + ParentFont = False + TabOrder = 1 + Transparent = False + end + end + end + object ppStats: TPageProducer + StripParamQuotes = False + OnHTMLTag = ppStatsHTMLTag + Left = 608 + Top = 24 + end +end diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.pas b/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.pas new file mode 100644 index 0000000..3cc9224 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitM.fmAboutDUnitM.pas @@ -0,0 +1,247 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.fmAboutDUnitM; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, HTTPApp, HTTPProd; + +type + TfmAboutDUnitM = class(TForm) + imgLogo: TImage; + txtIntro: TStaticText; + pnlFlow: TFlowPanel; + pnlTitle: TPanel; + pnlTitleCaptionBar: TPanel; + pnlPlatform: TPanel; + pnlPlatformCaptionBar: TPanel; + txtPlatform: TStaticText; + pnlArchitecture: TPanel; + pnlArchitectureCaptionBar: TPanel; + txtArchitecture: TStaticText; + pnlBuild: TPanel; + pnlBuildCaptionBar: TPanel; + txtBuild: TStaticText; + ppStats: TPageProducer; + scrbxTitle: TScrollBox; + txtTitle: TStaticText; + btnDummyButtonToForceScrollBar: TButton; + procedure ppStatsHTMLTag(Sender: TObject; Tag: TTag; + const TagString: string; TagParams: TStrings; var ReplaceText: string); + procedure FormShow(Sender: TObject); + private + procedure CheckReplacements; + public + { Public declarations } + end; + + +implementation + + + + + + + +uses IOUtils, DUnitM.RttiUtils, SBD.Environment + {$if CompilerVersion >= 27.0} + , System.Types + {$ifend} + ; +{$R *.dfm} + +procedure TfmAboutDUnitM.CheckReplacements; +var + Comp: TComponent; + TextThing: TStaticText; + DC: HDC; + MultiLine: TStrings; + EachLine: string; + TextSize, GrossTextSize: TSize; + SaveFont: HFONT; + +begin +if not assigned( ppStats) then exit; +for Comp in self do + if Comp is TStaticText then + begin + TextThing := TStaticText( Comp); + ppStats.HTMLDoc.Text := TextThing.Caption; + TextThing.Caption := ppStats.Content + end; +FreeAndNil( ppStats); + +MultiLine := TStringList.Create; +MultiLine.Text := txtTitle.Caption; +GrossTextSize.cx := 0; +GrossTextSize.cy := 0; +DC := GetDC( 0); +try + SaveFont := SelectObject( DC, txtTitle.Font.Handle); + for EachLine in MultiLine do + begin + GetTextExtentPoint32( DC, EachLine, Length( EachLine), TextSize); + if TextSize.cx > GrossTextSize.cx then + GrossTextSize.cx := TextSize.cx; + GrossTextSize.cy := GrossTextSize.cy + TextSize.cy + 10 + end; + SelectObject( DC, SaveFont) +finally + ReleaseDC( 0, DC) + end; +txtTitle.Align := alNone; +txtTitle.SetBounds( txtTitle.Left, txtTitle.Top, + GrossTextSize.cx + (GetSystemMetrics( SM_CXBORDER) * 4) + 10, + GrossTextSize.cy + (GetSystemMetrics( SM_CYBORDER) * 4)); +btnDummyButtonToForceScrollBar.SetBounds( + txtTitle.Left + txtTitle.Width - 1, + txtTitle.Top, 1, 1); +scrbxTitle.HorzScrollBar.Range := txtTitle.Width +end; + +procedure TfmAboutDUnitM.FormShow(Sender: TObject); +begin +CheckReplacements +end; + +type +{$if CompilerVersion < 20.00} + TrueNativeInt = integer; +{$else} + TrueNativeInt = NativeInt; +{$ifend} + +procedure TfmAboutDUnitM.ppStatsHTMLTag( + Sender: TObject; Tag: TTag; const TagString: string; TagParams: TStrings; var ReplaceText: string); +const + ArchStrings: array[ TProcessorArchitecture] of string = ( + 'x86 (32 bit)', + 'x64 (64 bit)', + 'Intel Itanium Processor Family (IPF) (64 bit)', + 'iOS', + 'OS X', + 'Android', + 'Linux', + 'Unrecognised architecture'); +begin +if TagString = 'AppTitle' then + ReplaceText := Application.Title + + else if TagString = 'AppFileName' then + ReplaceText := TPath.GetFileName( Application.ExeName) + + else if TagString = 'AppPath' then + ReplaceText := TPath.GetDirectoryName( Application.ExeName) + + else if TagString = 'Platform' then + begin + if SizeOf( TrueNativeInt) = 4 then + ReplaceText := 'Win32' + else + ReplaceText := 'Win64' + end + else if TagString = 'OSArchitecture' then + ReplaceText := ArchStrings[ TProcessorInformation.Architecture] + + else if TagString = 'OSVersion' then + ReplaceText := TProcessorInformation.OSVersion + + else if TagString = 'Now' then + {$if CompilerVersion >= 22.0} + ReplaceText := FormatDateTime( FormatSettings.LongDateFormat, Now) + {$else} + ReplaceText := FormatDateTime( LongDateFormat, Now) + {$ifend} + else if TagString = 'TZ' then + ReplaceText := TProcessorInformation.UTC_Offset + + else if TagString = 'CompilerVersion' then + ReplaceText := Format( '%2.2f', [CompilerVersion]) + + else if TagString = 'CompilerName' then + ReplaceText := TCompileInformation.CompilerName + + else if TagString = 'BuildWithPackages' then + ReplaceText := BoolToStr( TCompileInformation.BuiltWithRuntimePackages, True) + + else if TagString = 'Config' then + begin + {$IFDEF DEBUG} + ReplaceText := 'DEBUG' + {$ELSE} + {$IFDEF RELEASE} + ReplaceText := 'RELEASE' + {$ELSE} + ReplaceText := '(unrecognised)' + {$ENDIF} + {$ENDIF} + end; +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitX.ConsoleWriter.Base.pas b/LockBox3/unit-tests/dunit-m/run/DUnitX.ConsoleWriter.Base.pas new file mode 100644 index 0000000..a156cbd --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitX.ConsoleWriter.Base.pas @@ -0,0 +1,210 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitX.ConsoleWriter.Base; + +interface + +uses + classes; + +{$I ../includes/DUnitM.inc} + + +type + TConsoleColour = (ccDefault, ccBrightRed, ccDarkRed, + ccBrightBlue, ccDarkBlue, + ccBrightGreen, ccDarkGreen, + ccBrightYellow, ccDarkYellow, + ccBrightAqua, ccDarkAqua, + ccBrightPurple, ccDarkPurple, + ccGrey, ccBlack, + ccBrightWhite, + ccWhite); // the normal colour of text on the console + {$M+} + IDUnitXConsoleWriter = interface + ['{EFE59EB8-0C0B-4790-A964-D8126A2728A9}'] + function GetIndent : Integer; + procedure SetIndent(const count: Integer); + procedure SetColour(const foreground: TConsoleColour; const background: TConsoleColour = ccDefault); + procedure WriteLn(const s: String);overload; + procedure WriteLn;overload; + procedure Write(const s : string); + procedure Indent(const value : integer = 1); + procedure Outdent(const value : integer = 1); + property CurrentIndentLevel : Integer read GetIndent write SetIndent; + + end; + + TDUnitXConsoleWriterBase = class(TInterfacedObject,IDUnitXConsoleWriter) + private + FIndent : integer; + FConsoleWidth : integer; + FRedirectedStdOut : boolean; + protected + function GetIndent : Integer; + procedure SetIndent(const count: Integer);virtual; + procedure InternalWriteLn(const s : string); virtual;abstract; + procedure InternalWrite(const s : string);virtual;abstract; + procedure Indent(const value : integer = 1); + procedure Outdent(const value : integer = 1); + property ConsoleWidth : integer read FConsoleWidth write FConsoleWidth; + property RedirectedStdOut : boolean read FRedirectedStdOut write FRedirectedStdOut; + public + constructor Create;virtual; + procedure SetColour(const foreground: TConsoleColour; const background: TConsoleColour = ccDefault); virtual;abstract; + procedure WriteLn(const s: String);overload;virtual; + procedure WriteLn;overload;virtual; + procedure Write(const s : string);virtual; + property CurrentIndentLevel : Integer read GetIndent write SetIndent; + end; + + +implementation + +{ TDUnitXConsoleWriterBase } + +constructor TDUnitXConsoleWriterBase.Create; +begin + FConsoleWidth := 80; + FIndent := 0; +end; + + +function TDUnitXConsoleWriterBase.GetIndent: Integer; +begin + result := FIndent; +end; + +procedure TDUnitXConsoleWriterBase.Indent(const value: integer); +begin + SetIndent(FIndent + value); +end; + +procedure TDUnitXConsoleWriterBase.Outdent(const value: integer); +begin + SetIndent(FIndent - value); +end; + +procedure TDUnitXConsoleWriterBase.SetIndent(const count: Integer); +begin + if Count < 0 then + FIndent := 0 + else + begin + FIndent := count; + if not FRedirectedStdOut then + begin + if FIndent > FConsoleWidth -2 then + FIndent := FConsoleWidth - 2; + end; + end; +end; + + +procedure TDUnitXConsoleWriterBase.Write(const s: string); +var + offset, width, len : Integer; +begin + width := FConsoleWidth - FIndent - 1; + len := Length(s); + if (width > 0) and (len > width) then // Need to break into multiple lines + begin + offset := 1; + while offset < len do + begin + InternalWrite(Copy(s, offset, width)); + Inc(offset, width); + end; + end + else // Can write out on a single line + InternalWrite(s); +end; + +procedure TDUnitXConsoleWriterBase.WriteLn; +begin + WriteLn(''); +end; + +procedure TDUnitXConsoleWriterBase.WriteLn(const s: String); +var + offset, width, len : Integer; +begin + width := FConsoleWidth - FIndent - 1; + len := Length(s); + if (width > 0) and (len > width) then // Need to break into multiple lines + begin + offset := 1; + while offset < len do + begin + InternalWriteLn(Copy(s, offset, width)); + Inc(offset, width); + end; + end + else // Can write out on a single line + InternalWriteLn(s); +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DUnitX.Windows.Console.pas b/LockBox3/unit-tests/dunit-m/run/DUnitX.Windows.Console.pas new file mode 100644 index 0000000..1a0654d --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DUnitX.Windows.Console.pas @@ -0,0 +1,249 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitX.Windows.Console; + +interface + +uses + classes, + DUnitX.ConsoleWriter.Base; + +{$I ../includes/DUnitM.inc} + +type + TDUnitXWindowsConsoleWriter = class(TDUnitXConsoleWriterBase) + private + FDefaultForeground : Word; + FDefaultBackground : Word; + FLastForeground : TConsoleColour; + FLastBackground : TConsoleColour; + FStdOut : THandle; + function GetForegroundColourCode(const cc: TConsoleColour): Word; + function GetBackgroundColourCode(const cc: TConsoleColour): Word; + function GetConsoleWidth : Integer; + protected + procedure InternalWriteLn(const s : String); override; + procedure InternalWrite(const s : String); override; + public + procedure SetColour(const foreground: TConsoleColour; const background: TConsoleColour = ccDefault); override; + constructor Create;override; + destructor Destroy; override; + end; + + +implementation + +uses + {$IFDEF MSWINDOWS} + {$if CompilerVersion < 23 } + Windows + {$else} + WinAPI.Windows // Delphi XE2 (CompilerVersion 23) added scopes in front of unit names + {$ifend} + {$ENDIF} + , DUnitM.StringUtils + ; + + +constructor TDUnitXWindowsConsoleWriter.Create; +var + dummy : Cardinal; + consoleInfo : _CONSOLE_SCREEN_BUFFER_INFO; +begin + inherited; + FStdOut := GetStdHandle(STD_OUTPUT_HANDLE); + if not GetConsoleMode(FStdOut, dummy) then // Not a console handle + Self.RedirectedStdOut := True; + Self.ConsoleWidth := GetConsoleWidth; + FLastForeground := ccDarkYellow; // Just to ensure the first colour change goes through + FLastBackground := ccDarkYellow; + // Save the current console colour settings so we can restore them: + if GetConsoleScreenBufferInfo(FStdOut, consoleInfo) then + begin + FDefaultForeground := consoleInfo.wAttributes and (FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED or FOREGROUND_INTENSITY); + FDefaultBackground := consoleInfo.wAttributes and (BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED or BACKGROUND_INTENSITY); + end + else + begin + FDefaultForeground := GetForegroundColourCode(ccWhite); + FDefaultBackground := GetBackgroundColourCode(ccBlack); + end; +end; + +procedure TDUnitXWindowsConsoleWriter.SetColour(const foreground, background: TConsoleColour); +begin + if (FLastForeground <> foreground) or (FLastBackground <> background) then + begin + SetConsoleTextAttribute(FStdOut, + GetForegroundColourCode(foreground) or + GetBackgroundColourCode(background)); + FLastForeground := foreground; + FLastBackground := background; + end; +end; + +function TDUnitXWindowsConsoleWriter.GetForegroundColourCode(const cc : TConsoleColour) : Word; +begin + Result := 0; + case cc of + ccDefault : Result := FDefaultForeground; + ccBrightRed : Result := FOREGROUND_RED or FOREGROUND_INTENSITY; + ccDarkRed : Result := FOREGROUND_RED; + ccBrightBlue : Result := FOREGROUND_BLUE or FOREGROUND_INTENSITY; + ccDarkBlue : Result := FOREGROUND_BLUE; + ccBrightGreen : Result := FOREGROUND_GREEN or FOREGROUND_INTENSITY; + ccDarkGreen : Result := FOREGROUND_GREEN; + ccBrightYellow : Result := FOREGROUND_GREEN or FOREGROUND_RED or FOREGROUND_INTENSITY; + ccDarkYellow : Result := FOREGROUND_GREEN or FOREGROUND_RED; + ccBrightAqua : Result := FOREGROUND_GREEN or FOREGROUND_BLUE or FOREGROUND_INTENSITY; + ccDarkAqua : Result := FOREGROUND_GREEN or FOREGROUND_BLUE; + ccBrightPurple : Result := FOREGROUND_BLUE or FOREGROUND_RED or FOREGROUND_INTENSITY; + ccDarkPurple : Result := FOREGROUND_BLUE or FOREGROUND_RED; + ccGrey : Result := FOREGROUND_INTENSITY; + ccBlack : Result := 0; + ccBrightWhite : Result := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED or FOREGROUND_INTENSITY; + ccWhite : Result := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED; + end; +end; + + +function PadString(const s: string; const totalLength: integer; const padLeft: boolean = True; padChr: Char = ' '): string; +begin + Result := s; + while Length(result) < totalLength do + begin + if padLeft then + Result := padChr + Result + else + Result := Result + padChr; + end; +end; + +procedure TDUnitXWindowsConsoleWriter.InternalWrite(const s: String); +var + output : string; + dummy : Cardinal; +begin + output := PadString(s, length(s)+ Self.CurrentIndentLevel, True, ' '); + if Self.RedirectedStdOut then + System.Write(output) + else + WriteConsoleW(FStdOut, PWideChar(output), Length(output), dummy, nil); +end; + +procedure TDUnitXWindowsConsoleWriter.InternalWriteLn(const s: String); +var + output : string; + dummy : Cardinal; +begin + output := PadString(s, length(s)+ Self.CurrentIndentLevel, True, ' ') + #13#10; + if Self.RedirectedStdOut then + System.Write(output) + else + WriteConsoleW(FStdOut, PWideChar(output), Length(output), dummy, nil); +end; + +destructor TDUnitXWindowsConsoleWriter.Destroy; +begin + SetColour(ccDefault); // Restore default console colours + inherited; +end; + +function TDUnitXWindowsConsoleWriter.GetBackgroundColourCode(const cc : TConsoleColour) : Word; +begin + Result := 0; + case cc of + ccDefault : Result := FDefaultBackground; + ccBrightRed : Result := BACKGROUND_RED or BACKGROUND_INTENSITY; + ccDarkRed : Result := BACKGROUND_RED; + ccBrightBlue : Result := BACKGROUND_BLUE or BACKGROUND_INTENSITY; + ccDarkBlue : Result := BACKGROUND_BLUE; + ccBrightGreen : Result := BACKGROUND_GREEN or BACKGROUND_INTENSITY; + ccDarkGreen : Result := BACKGROUND_GREEN; + ccBrightYellow : Result := BACKGROUND_GREEN or BACKGROUND_RED or BACKGROUND_INTENSITY; + ccDarkYellow : Result := BACKGROUND_GREEN or BACKGROUND_RED; + ccBrightAqua : Result := BACKGROUND_GREEN or BACKGROUND_BLUE or BACKGROUND_INTENSITY; + ccDarkAqua : Result := BACKGROUND_GREEN or BACKGROUND_BLUE; + ccBrightPurple : Result := BACKGROUND_BLUE or BACKGROUND_RED or BACKGROUND_INTENSITY; + ccDarkPurple : Result := BACKGROUND_BLUE or BACKGROUND_RED; + ccGrey : Result := BACKGROUND_INTENSITY; + ccBlack : Result := 0; + ccBrightWhite : Result := BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED or BACKGROUND_INTENSITY; + ccWhite : Result := BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED; + end; +end; + +function TDUnitXWindowsConsoleWriter.GetConsoleWidth: Integer; +var + info : CONSOLE_SCREEN_BUFFER_INFO; +begin + Result := High(Integer); // Default is unlimited width + if GetConsoleScreenBufferInfo(FStdOut, info) then + Result := info.dwSize.X; +end; + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DunitM.CommandLine.Console.Solution.pas b/LockBox3/unit-tests/dunit-m/run/DunitM.CommandLine.Console.Solution.pas new file mode 100644 index 0000000..e5e26c4 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DunitM.CommandLine.Console.Solution.pas @@ -0,0 +1,50 @@ +unit DunitM.CommandLine.Console.Solution; +interface +uses DUnitM.CommandLine.General, Types, XMLIntf, Generics.Collections, Classes; + + +type +TConsoleCommandLineProtocol = class( TInterfacedObject, IApplicationSpecificCommandLineFactory) + private + function Make( + const RawForm: IPrimitiveCommandLine; + const ProtocolReader: ICommandLineFactory; + var CommandLine: ICommandLine; + var Errors: TCommandLineReadErrorSet) + : boolean; + end; + + +implementation + + + + + + +uses SBD.Utils.XML2; + +function TConsoleCommandLineProtocol.Make( + const RawForm: IPrimitiveCommandLine; + const ProtocolReader: ICommandLineFactory; var CommandLine: ICommandLine; + var Errors: TCommandLineReadErrorSet): boolean; +begin +result := ProtocolReader.Make( + RawForm, + 'DocParamName', // TODO + 'NamespaceDecls', // TODO + CommandLine, Errors, + procedure( const Registrar: IParameterRegistrar) + begin + // TODO + + end, + + function( const Doc: IXMLDocument; NameValues: TStrings): boolean + begin + // TODO + end, + nil) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.dfm b/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.dfm new file mode 100644 index 0000000..6777e26 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.dfm @@ -0,0 +1,565 @@ +object mfmGUIRunner: TmfmGUIRunner + Left = 0 + Top = 0 + Caption = 'MVVM Gui Runner' + ClientHeight = 578 + ClientWidth = 804 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + ShowHint = True + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object splTestCases: TSplitter + Left = 0 + Top = 361 + Width = 804 + Height = 2 + Cursor = crVSplit + Align = alTop + ExplicitTop = 472 + ExplicitWidth = 898 + end + object tlbrMain: TActionToolBar + Left = 0 + Top = 0 + Width = 804 + Height = 23 + ActionManager = actmngrMain + Caption = 'Main ToolBar' + ColorMap.HighlightColor = clWhite + ColorMap.BtnSelectedColor = clBtnFace + ColorMap.UnusedColor = clWhite + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + Spacing = 0 + end + object sbarMain: TStatusBar + Left = 0 + Top = 559 + Width = 804 + Height = 19 + Panels = < + item + Alignment = taCenter + Text = 'Idle' + Width = 200 + end + item + Alignment = taRightJustify + Text = 'Test cases = 0' + Width = 100 + end + item + Text = 'of 1' + Width = 100 + end> + end + object pnlTestCases: TPanel + Left = 0 + Top = 23 + Width = 804 + Height = 338 + Align = alTop + Caption = 'Tree of test cases goes here' + ParentShowHint = False + ShowHint = True + TabOrder = 2 + end + object pbarTests: TProgressBar + Left = 0 + Top = 542 + Width = 804 + Height = 17 + Align = alBottom + TabOrder = 3 + end + object memoLog: TRichEdit + Left = 0 + Top = 363 + Width = 804 + Height = 179 + Align = alClient + BorderStyle = bsNone + Color = clInfoBk + Font.Charset = ANSI_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Lines.Strings = ( + '[Log output goes here.]') + ParentFont = False + PopupMenu = popupLogMemo + ReadOnly = True + ScrollBars = ssVertical + TabOrder = 4 + Zoom = 100 + end + object appevMain: TApplicationEvents + OnIdle = appevMainIdle + Left = 32 + Top = 184 + end + object actmngrMain: TActionManager + ActionBars = < + item + Items = < + item + Action = actSelectAll + Caption = '&Select all' + end + item + Action = actSelectFailed + Caption = 'S&elect failed' + end + item + Action = actToggleSelection + Caption = '&Toggle selections' + end + item + Action = actSelectDefault + Caption = 'Select &default' + end + item + Action = actClear + Caption = '&Clear selections' + end + item + Caption = '-' + end + item + Action = actRun + Caption = '&Run' + end + item + Action = actAbort + Caption = '&Abort' + end + item + Action = actClearAll + Caption = 'C&lear all' + end + item + Caption = '-' + end + item + Items = < + item + Action = actHaltOnFirstFailure + Caption = '&Halt on first failure' + ImageIndex = 2 + end + item + Caption = '&Secondary loggers' + end + item + Caption = '&Attach new logger' + ImageIndex = 6 + end + item + Action = actAbout + Caption = 'A&bout ...' + ImageIndex = 3 + end> + Caption = '&Options' + end> + ActionBar = tlbrMain + end> + Images = imglstGlyphs16x16 + Left = 112 + Top = 184 + StyleName = 'XP Style' + object actRun: TAction + Category = 'Operation' + Caption = 'Run' + OnExecute = actRunExecute + OnUpdate = actRunUpdate + end + object actSelectAll: TAction + Category = 'Selection' + Caption = 'Select all' + OnExecute = actSelectAllExecute + end + object actSelectFailed: TAction + Category = 'Selection' + Caption = 'Select failed' + OnExecute = actSelectFailedExecute + OnUpdate = actSelectFailedUpdate + end + object actClear: TAction + Category = 'Selection' + Caption = 'Clear selections' + OnExecute = actClearExecute + OnUpdate = actClearUpdate + end + object actToggleSelection: TAction + Category = 'Selection' + Caption = 'Toggle selections' + OnExecute = actToggleSelectionExecute + end + object actAttachLogger: TAction + Category = 'Attach' + Caption = 'Attach new %s logger' + ImageIndex = 4 + OnExecute = actAttachLoggerExecute + end + object actDetachLogger: TAction + Category = 'Per Secondary Logger' + Caption = 'Detach' + ImageIndex = 5 + OnExecute = actDetachLoggerExecute + end + object actEditLoggerProps: TAction + Category = 'Per Secondary Logger' + Caption = 'Properties...' + ImageIndex = 6 + OnExecute = actEditLoggerPropsExecute + end + object actHaltOnFirstFailure: TAction + Category = 'Options' + AutoCheck = True + Caption = 'Halt on first failure' + Checked = True + ImageIndex = 2 + OnExecute = actHaltOnFirstFailureExecute + OnUpdate = actHaltOnFirstFailureUpdate + end + object actNotYetDeveloped: TAction + Category = 'Options' + Caption = '(placemarker - Not yet developed)' + end + object actAbout: TAction + Category = 'Options' + Caption = 'About ...' + ImageIndex = 3 + OnExecute = actAboutExecute + OnUpdate = actAboutUpdate + end + object actClearLog: TAction + Category = 'Log' + Caption = 'Clear' + OnExecute = actClearLogExecute + end + object actClearAll: TAction + Category = 'Selection' + Caption = 'Clear all' + OnExecute = actClearAllExecute + end + object actSelectDefault: TAction + Category = 'Selection' + Caption = 'Select default' + OnExecute = actSelectDefaultExecute + end + end + object coloursXP: TXPColorMap + HighlightColor = 15660791 + BtnSelectedColor = clBtnFace + UnusedColor = 15660791 + Left = 200 + Top = 184 + end + object imglstGlyphs16x16: TImageList + Left = 296 + Top = 184 + Bitmap = { + 494C010107000800380010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000002000000001002000000000000020 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000C0C0C0000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000000000000FF + FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000000000000000000000000000000000000000000000 + 00000000000000000000C0C0C00000000000C0C0C00000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000808080000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000C0C0C000000000000000 + 00000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF00000000000000 + 00000000000000000000C0C0C000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000C0C0 + C000000000000000000000FFFF0000FFFF0000FFFF000000000000000000C0C0 + C0000000000000000000000000000000000000000000000000000000000000FF + FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000808080000000 + 00000000000000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 00000000000000000000000000000000000000000000C0C0C000000000000000 + 00000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF00000000000000 + 00000000000000000000C0C0C000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 000000FFFF0000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000C0C0 + C000000000000000000000FFFF0000FFFF0000FFFF000000000000000000C0C0 + C000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF0000FFFF0000FFFF00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000C0C0 + C00000000000000000000000000000000000000000000000000000000000C0C0 + C000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000008080800000FFFF0000FFFF0000FFFF0000FFFF0000FF + FF0000FFFF000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000FFFF0000FFFF0000FFFF0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000008080800000FFFF0000FF + FF0000FFFF000000000080808000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000C0C0 + C00000000000000000000000000000000000000000000000000000000000C0C0 + C00000000000000000000000000000000000000000000000000000000000C0C0 + C00000000000000000000000000000000000000000000000000000000000C0C0 + C000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000008080800000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000733A2D00733A2D00783C2A00793D2A00753B2B00693531000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000006D332700853C130095440D0096450D00873D1200703425000000 + 00000000000000000000000000000000000000000000FFFCFC00EAE5FF007877 + D3002223AB000E0CB7000F08CD001707E1001604E7001302EA001105EF000B02 + EB000F0BCA001817AD004D45C400AEAAF1000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000763B + 2B00763B2B007B3D290080402700814126007F3F27007E3F28007F3F27007F40 + 27006A3531000000000000000000000000000000000000000000000000007037 + 2A00A04B0C00CD772700E8AD7000F3CCA100F4CDA300E9B17600D07C2C00A64F + 0A006F352900000000000000000000000000FFFBF900F7EFFF008F86DE002418 + B3001A0ECF00170BDC001508D2003727E6004B39EE00533FFA003E2AF6002411 + EB001304E6001207E1001D0ED1004B41CC000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000006A3632008D4C + 2A00984E1F00A2511500AF580F00B55B0B00B2580A00A45213008B4621007C3E + 2900814126006E372F000000000000000000000000000000000086411D00C062 + 0B00F0C29200FFFEFA00FEFAF700F5E3D100F5E2D000FDF8F400FFFFFD00F2C9 + 9E00C66911007B3A21000000000000000000FDFFFF00B5B6E300352F9F001005 + BD000B01CF00110ECB00585DE50097A5F000B2C3EB00C0CFF400A6B0E9008589 + E8003438E4000000E3000F06DB00130CAA000000000000000000FFFFFF00FFFF + FF00FFFFFF00FFFFFF00BFA89E00B2887400B0846E00BB9D8E00FFFFFF00FFFF + FF00FFFFFF00FFFFFF0000000000000000000000000069363400BC763E00CF7D + 3100D1771E00D16E0800CC610000CC630000D06C0500CE660200C55C0000A954 + 110083412600824126006B36300000000000000000008C451C00C1610700F7DB + BD00FFFEFE00E0A36900CE6F1500C9610000C9610000CC6A0C00DB965300FDFA + F700FAE5CC00C6680D006F35280000000000F5F9F6005E61A5000909A0000C0A + D0001716C1007D80E900E3E6FF00A4A9E500555AAD00444DA7006678BD00C5DC + F700B8C5FF004445E100170ECD00120EC9000000000000000000FFFFFF00DDE3 + E500C9BAB10098451D0095431B009B512E00974A25009B512E008B320700BA97 + 8600D9E1E400FFFFFF00000000000000000000000000AD724D00F5AC5E00E698 + 4800DE8A3400D5771800E0A26200FFF8F000FFF8F000FFF8F000EABC8D00D170 + 0C00B75B0700874324007D3F28000000000000000000AF520100ECBD8B00FFFF + FF00DA8F4500C85B0000C95E0000CB650000CA620000D37D2700D98E4A00D585 + 3400FDFAF700F3CB9F00A64E060000000000E4E0E40040419B000F15CB000003 + C500535BCF00E1E4F400FFFFFF007C67C5001F08CF001107E5001C27C200A8C4 + E600F6FFFF00AFA9EE00281EBB000A05D7000000000000000000E0E2E400D2C4 + BE009B3F14009B461D00AA654400DFD1C900FEFFFF00BE937E008D3910008B32 + 0800BA948100DDE3E600000000000000000082442C00E8AF7900F6B77500EBA3 + 5A00E4924000F0C79E00FFF8F000E1A15F00D37B2200D88C3E00E9BE9300D175 + 1800CE650000A8541300844225006C363000A04D1000CE772100FFFDFB00E8B6 + 8400CE670000FFFFFF00DD985200CB620000C85D0000E4AE7900FFFFFF00C85E + 0000DE9E5E00FFFFFF00CF7B280070352500B8B8DA003D45A5001F2BCA001726 + BC00A1AAF300FFFFFF00FFFCFF007468C4001109C8000603DA002129C300B1BF + EB00FEFFFF00F6F1FF00594FD6000200C2000000000000000000E4EBEF00AF5E + 3700A54F2600A45129009C441900BF8C7400F8FFFF0091360A00994821009545 + 1F008C340900D9D6D4000000000000000000AB6C4200FFD19C00FBC28900F5C3 + 8F00F5CDA500FFF8F000EEC39800E3A26100E1A26200D5833400C75B0000CA64 + 0000CD670000C4630500984C1B00783C2A00AF550700E5AA6F00FFFFFF00DD8F + 3F00D87B1C00FFFFFF00FFFFFF00E4AA6F00CB600000E3AB7300FFFFFF00CB66 + 0100CD6C0A00FDFAF600E9B17500873D1100A0A6F1002F39AB003D49D9003842 + BA00BDC2F100FFFFFE00FFFFFF006D6FC900050DB8000000BF002629B500C3BF + EC00FFFFFC00FFFFFF00746BDA001B11C5000000000000000000D2C7C000AB4B + 1D00AD582F00AB562D00A54C2200C5947D00F7FFFF009B4318009F4C25009C4B + 2400953E1500BD9987000000000000000000C2824C00FFD4A000FFCB9600FED7 + AE00FFF8F000FBECDD00F5CFA900F3CEA900F1CCA600E4A96C00CE690400CB66 + 0100CB660000CC670000B45A0D0082412500BB5F0A00F0CAA100FCF4ED00E193 + 4300E08D3800FFFFFF00FFFFFF00FFFFFF00EBC09400E7B58200FFFFFF00CC68 + 0400C9600000F5E3D000F3CEA40095440C009198F4003139BA00434ADD003B3D + B100C3C4F100FFFFFF00FAFEFF006F77D0001925CC00161DD6003531B800C8B9 + E900FFFEFC00FFFFFF00716ACA00140EB0000000000000000000D9B9AA00B253 + 2700B35C3300B15A3100AA4D2100C6917700F7FFFF00A2481D00A4522900A350 + 28009D481E00B9846A000000000000000000CA854A00FFD7A600FFCB9500FFDA + B500FFF8F000FDF1E400FFF8F000FFF8F000FFF8F000FFF8F000DD904300D06D + 0A00CC670200CB660000CC6700008E481F00C1650F00F2CDA600FDF7F000E9A1 + 5800E89C4E00FFFFFF00FFFFFF00FFFFFF00F1D2B200EBBC8E00FFFFFF00CC68 + 0400C9610000F6E6D400F3CCA10094440C009AB0E800384CA7004651CD003339 + A000AEB3DD00FFFFFE00F7FFFF00767ED6004043EB004945FF004A3ECC00CABA + ED00FFFFFF00F3F7FF005958B8001814AB000000000000000000DBBDAE00B858 + 2A00BA613700B55B3000C07B5900EAE6E400F7FFFF00A94E2100AB552D00A954 + 2C00A34C2200BE876D000000000000000000D3976200FFE0BF00FFCF9D00FFCE + 9C00FFE3C600FFF8F000FBCD9E00F6C38E00F1B98100ECB07300E0903E00D87C + 1F00D2741500CD690400D168000087442300C1640D00EEBC8800FFFFFF00F1B7 + 7C00EFA96100FFFFFF00FFFFFF00F1C99F00DB812500EAB98700FFFFFF00CB66 + 0000CE6F0E00FEFCFA00E7AC6D00853B1300CBE5EF0042588F004E5DC400333F + A5006472AA00DAEAEF00F6FFFF00777CC2004D49D1005A54EA004B47B000C4C4 + E000FCFFFF00AAAEEE003B3BAB003F3ECC000000000000000000DED5D000BF59 + 2900C0663B00BD633800BC643A00BD6C4500CC967B00B35B3200B25B3100AF59 + 3000A84C2000CCA998000000000000000000D9A16C00F3D3B300FFE7CB00FFCC + 9600FFCC9700FFF8F000FEEAD400FAC18600F4B06C00ECA35900EFBF8E00ECBC + 8B00DA822900D7781800C5670D006B362F00BF600600E5A05900FFFDFA00FBE0 + C400F7B87600FFFFFF00F4CA9E00E6994900DF883200EDC09300FFFFFF00C95F + 0000E2A96E00FFFFFE00CC7520006D342800EAF2F9007781B400444FB2005361 + D3002E3E92007E8DB800E9F5FF00AFB2E3008180D1008487D8008394BC00D1EC + E700C5D7F9004045B0003639B7003F43C7000000000000000000EEF8FC00CF7C + 5500C5663900C4683E00C0613500C9836200D09D8400B85A2D00B8603600B55D + 3300AE4E2100FFFFFF00000000000000000000000000E2A36300FFFBF200FFE1 + C200FFCB9600FFD09E00FFF8F000FFF8F000FFF8F000FFF8F000FDF5EB00F0BF + 8C00E2924000E68D3100A35B2A000000000000000000D57F2B00FAD9B800FFFF + FF00FEDCB900F8BB7D00F0AB6300E9A05600E1903D00E0944700DC914600DB93 + 4B00FFFFFF00EFC08C00A04A080000000000FDF1FF00AFA8E5005457BB00505B + D7004650C900373AA1007470C200BBB5FA00D4D2FF00DAE1FF00BAD4EF008FB1 + BE003F529F002D30B5004C4FCF003C3FB4000000000000000000FFFFFF00EBE4 + E000C9633300C9683B00C35E2D00E8DED900F8FFFF00C0643900BD613500B650 + 2100D9B9A900FFFFFF00000000000000000000000000CD6A0600F3C79A00FFFD + F600FFE8D000FFD2A400FFCC9600FFD8AF00FFE0BF00FFDAB500F8BF8500F0AC + 6600F3AB6000CB8346006A3633000000000000000000C3620400E79E5500FEEB + D700FFFFFF00FBDFC200F1B87D00E9A25900E2944500DD8E3D00E6B17C00FFFF + FF00F6D8B700BE5F06006B342C0000000000FFF2FF00ECDEFF008D8BD7005359 + C3005A5DE1005C55E400382AAF005849B2006962AE006669A80052619E002F42 + 8D003340AC004C50D1004A4CBC005357AF000000000000000000FFFFFF00EDF1 + F300E8E0DB00D07A5100C85F2C00CA6B3E00CD7B5400C2592900C3633500DEC1 + B300ECF4F800FFFFFF0000000000000000000000000000000000CF6D0D00F2C2 + 8F00FFF9EE00FFF8EE00FFE9D100FFDDB900FFD9B100FFDAB300FFDEB800FFD4 + A300D89A63007941320000000000000000000000000000000000C6670C00E69E + 5500FAD9B600FFFBF600FFFFFF00FEF8F200FDF6EF00FFFFFF00FEF9F200ECB8 + 8400BE5F0900753826000000000000000000FBF5F800FFFFFF00EBEEF7009397 + C4006060BB006762E4006C61F2005C53DB00534BC5004944BA005047CF00564B + E6005D59DC004C50B2006464B000B3B2E4000000000000000000FFFFFF00FFFF + FF00FFFFFF00FFFFFF00E6D7CF00E3BDAB00E1B7A200E4CDC100FFFFFF00FFFF + FF00FFFFFF00FFFFFF000000000000000000000000000000000000000000CF6D + 0D00E1954700F6CDA300FFEBD600FFF1E000FFF1DF00FFEBD400F1CDAC00C289 + 5E00C2895E00000000000000000000000000000000000000000000000000C060 + 0500D27E2C00E49F5A00EEBA8600F2CAA000F0C59900E4A76800CC741E00A64D + 0600783A2700000000000000000000000000FEFFF700FBFCF200FFFFFA00EDEE + F700ACABD900676DB8005664C3005A6CD1006675D900616BD0006A6BDA005955 + CB005857B700787CBD00D2D1F400F9F7FF000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000D47A1F00D47A1F00D5843600CF823B00C0722E00C0722E000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000B65C0A00B8601200B9611300B25A0F00A24F0E008E451A000000 + 000000000000000000000000000000000000F7FFF500FDFEF40000000000FFFF + F900FCFCFF00D7E9F80099BAE6005C86C3005378BC00516DB3006E7EC1008993 + D500C8CDF400E1E4FB00FDFDFF00FFFAF9000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000200000000100010000000000000100000000000000000000 + 000000000000000000000000FFFFFF00FEFFFEFFFBFF0000FC7FFBBFFBFF0000 + FC7FF6DFFBFF0000FC7FFC7FFBFF00000000FC7FFBFF00000000FC7FFBF00000 + 80010000F9F00000E00F0000F8000000F83F8001F8000000F83FE00FF8000000 + F83FF83FF8000000F83FF83FF8000000F83FF83FF8000000E00FF83FF8000000 + C007F83FF8010000E00FE00FFB030000F81FF81F8000FFFFE007E0070000FFFF + C003C0030000C003800180010000C003800180010000C003000000000000C003 + 000000000000C003000000000000C003000000000000C003000000000000C003 + 000000000000C003800180010000C003800180010000C003C003C0030000C003 + E007E0070000FFFFF81FF81F2000FFFF00000000000000000000000000000000 + 000000000000} + end + object popupLogMemo: TPopupActionBar + Left = 400 + Top = 184 + object miClearLog: TMenuItem + Action = actClearLog + end + end + object actmngrIntraRun: TActionManager + Images = imglstGlyphs16x16 + Left = 112 + Top = 248 + StyleName = 'Platform Default' + object actAbort: TAction + Caption = 'Abort' + OnExecute = actAbortExecute + OnUpdate = actAbortUpdate + end + end +end diff --git a/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.pas b/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.pas new file mode 100644 index 0000000..86d098c --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/DunitM.GUIRunnerForm.pas @@ -0,0 +1,716 @@ +{***************************************************************************} +{ } +{ DUnit-M } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +{***************************************************************************} +{ } +{ NOTICE of DERIVATION and CHANGE } +{ } +{ This project is a derived work. It is dervied from the DUnitX library } +{ created By Vincent Parrett } +{ (hosted at https://github.com/VSoftTechnologies/DUnitX). } +{ The copyright holder for the original code is as per the following } +{ comment block. The copyright holder for all changes in this file from } +{ that base is as denoted following. } +{ } +{ Copyright (C) 2015 Sean B. Durkin } +{ } +{ Author: Sean B. Durkin } +{ sean@seanbdurkin.id.au } +{***************************************************************************} + +// The Original DUnitX comment header was .... + +{***************************************************************************} +{ } +{ DUnitX } +{ } +{ Copyright (C) 2012 Vincent Parrett } +{ } +{ vincent@finalbuilder.com } +{ http://www.finalbuilder.com } +{ } +{ Contributors : Vincent Parrett } +{ Jason Smith } +{ Nick Hodges } +{ Nicholas Ring } +{ } +{***************************************************************************} + +// DUnit-M is a unit testing framework for software written in and for Delphi XE7 +// or later. Some of the files from this project are either copied or derived +// from the DUnitX project. + +unit DUnitM.GUIRunnerForm; + +interface + +{$if RTLVersion < 24.00} +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, DUnitM.BaseExecutive, AppEvnts, + DUnitM.ViewModel_VCLForms, PlatformDefaultStyleActnCtrls, Menus, ActnPopup, + ComCtrls, ImgList, ActnMan, ActnColorMaps, ActnList, ExtCtrls, StdCtrls, + ToolWin, ActnCtrls, XPStyleActnCtrls, Generics.Collections, DUnitM.UnitTestFramework; +{$else} +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, DUnitM.BaseExecutive, AppEvnts, + DUnitM.ViewModel_VCLForms, PlatformDefaultStyleActnCtrls, Menus, ActnPopup, + ComCtrls, ImgList, ActnMan, ActnColorMaps, ActnList, ExtCtrls, StdCtrls, + ToolWin, ActnCtrls, XPStyleActnCtrls, Generics.Collections, DUnitM.UnitTestFramework, + System.Actions, System.ImageList; +{$ifend} + +const + doAutoScroll = True; + +type + TmfmGUIRunner = class(TForm) + appevMain: TApplicationEvents; + actmngrMain: TActionManager; + tlbrMain: TActionToolBar; + sbarMain: TStatusBar; + pnlTestCases: TPanel; + splTestCases: TSplitter; + actRun: TAction; + actSelectAll: TAction; + actSelectFailed: TAction; + actClear: TAction; + actToggleSelection: TAction; + coloursXP: TXPColorMap; + imglstGlyphs16x16: TImageList; + pbarTests: TProgressBar; + actAttachLogger: TAction; + actDetachLogger: TAction; + actEditLoggerProps: TAction; + actHaltOnFirstFailure: TAction; + actNotYetDeveloped: TAction; + popupLogMemo: TPopupActionBar; + actAbout: TAction; + actClearLog: TAction; + miClearLog: TMenuItem; + memoLog: TRichEdit; + actmngrIntraRun: TActionManager; + actAbort: TAction; + actClearAll: TAction; + actSelectDefault: TAction; + procedure FormDestroy(Sender: TObject); + procedure appevMainIdle(Sender: TObject; var Done: Boolean); + procedure actRunExecute(Sender: TObject); + procedure actAttachLoggerExecute(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure actClearLogExecute(Sender: TObject); + procedure actAbortExecute(Sender: TObject); + procedure actAbortUpdate(Sender: TObject); + procedure actSelectAllExecute(Sender: TObject); + procedure actSelectFailedExecute(Sender: TObject); + procedure actSelectFailedUpdate(Sender: TObject); + procedure actClearExecute(Sender: TObject); + procedure actClearUpdate(Sender: TObject); + procedure actToggleSelectionExecute(Sender: TObject); + procedure actEditLoggerPropsExecute(Sender: TObject); + procedure actDetachLoggerExecute(Sender: TObject); + procedure actRunUpdate(Sender: TObject); + procedure actClearAllExecute(Sender: TObject); + procedure actSelectDefaultExecute(Sender: TObject); + procedure actHaltOnFirstFailureExecute(Sender: TObject); + procedure actHaltOnFirstFailureUpdate(Sender: TObject); + procedure actAboutExecute(Sender: TObject); + procedure actAboutUpdate(Sender: TObject); + + private + FViewModel: IViewModel_VCLForms; + + function CreateAttachLoggerAction( const Factory: ILoggerFactoryUI): TAction; + function CreateLoggerAction( + Template: TAction; const Factory1: ILoggerFactoryUI; const Logger: ITestLogger; + const Properties: IInterface; const DisplayName: string; AnchorPoint: TActionClientItem): TAction; + + protected + procedure Loaded; override; + end; + +var + mfmGUIRunner: TmfmGUIRunner; + +implementation + + + + + + +uses RichEdit, DUnitM.fmAboutDUnitM; +{$R *.dfm} + +type +TFactoryAction = class( TAction) + public + FFactory: ILoggerFactoryUI; + constructor CreateFactoryAction( AOwner: TComponent; const Factory: ILoggerFactoryUI); + end; + +TLoggerAction = class( TAction) + public + FFactory: ILoggerFactoryUI; + FLogger: ITestLogger; + FProps: IInterface; + FAnchorPoint: TActionClientItem; + constructor CreateLoggerAction( + AOwner: TComponent; const Factory1: ILoggerFactoryUI; const Logger: ITestLogger; + const Props: IInterface; AnchorPoint: TActionClientItem); + end; + +TConcreteView = class( TViewModel_VCLForms) + protected + function TreeOwner: TComponent; override; + function TreeParent: TWinControl; override; + function TreeName: string; override; + procedure IntegrateSecondariesIntoMenus; override; + procedure ClearLog; override; + procedure Put( Level: TPutLevel; const Line: string; const Args: array of const); override; + procedure SetDisplayState( Value: TSuiteRunnerState); override; + procedure Breathe; override; + procedure InitiateView( TestCaseCount: integer); override; + procedure EnterOperation( isEntering: boolean); override; + function GetShowProgressBar: boolean; override; + procedure SetShowProgressBar( Value: boolean); override; + function GetProgressPosition: integer; override; + procedure SetProgressPosition( Value: integer); override; + function GetProgressMax: integer; override; + procedure SetProgressMax( Value: integer); override; + + private + FSensitivity: TPutLevel; + FBreathing: boolean; + function Form: TmfmGUIRunner; + + public + constructor Create; override; + end; + + +procedure AssignAction( Destination, Source: TAction); +begin +Destination.OnExecute := Source.OnExecute; +Destination.OnUpdate := Source.OnUpdate; +Destination.AutoCheck := Source.AutoCheck; +Destination.Caption := Source.Caption; +Destination.Checked := Source.Checked; +Destination.DisableIfNoHandler := Source.DisableIfNoHandler; +Destination.Enabled := Source.Enabled; +Destination.GroupIndex := Source.GroupIndex; +Destination.HelpContext := Source.HelpContext; +Destination.HelpKeyword := Source.HelpKeyword; +Destination.HelpType := Source.HelpType; +Destination.Hint := Source.Hint; +Destination.ImageIndex := Source.ImageIndex; +Destination.ShortCut := Source.ShortCut; +Destination.SecondaryShortCuts := Source.SecondaryShortCuts; +Destination.Visible := Source.Visible; +Destination.OnHint := Source.OnHint +end; + + + +procedure TmfmGUIRunner.Loaded; +begin +inherited; +FViewModel := TConcreteView.Create; +FViewModel.FormLoaded( self) +end; + + +function TmfmGUIRunner.CreateLoggerAction( + Template: TAction; const Factory1: ILoggerFactoryUI; + const Logger: ITestLogger; const Properties: IInterface; const DisplayName: string; + AnchorPoint: TActionClientItem): TAction; +begin +result := TLoggerAction.CreateLoggerAction( Template.Owner, Factory1, Logger, Properties, AnchorPoint); +result.ActionList := Template.ActionList; +AssignAction( result, Template); +if Pos( '%s', result.Caption) > 0 then + result.Caption := Format( result.Caption, [DisplayName]); +result.Category := '(dynamic)' +end; + +procedure TmfmGUIRunner.actAbortExecute( Sender: TObject); +begin +FViewModel.RequestAbort +end; + +procedure TmfmGUIRunner.actAbortUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := (not FViewModel.IsAbortRequested) and + FViewModel.Model.IsRunning +end; + +procedure TmfmGUIRunner.actAboutExecute( Sender: TObject); +var + Dlg: TfmAboutDUnitM; +begin +Dlg := TfmAboutDUnitM.Create( Self); +try + Dlg.ShowModal +finally + Dlg.Free + end +end; + +procedure TmfmGUIRunner.actAboutUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := FViewModel.CanDialog +end; + + +function FindMenuByCaption( ParentMenu: TActionClients; const Caption: string; var Finding: TActionClients): boolean; +var + Item: TCollectionItem; +begin +result := False; +Finding := nil; +if assigned( ParentMenu) then + for Item in ParentMenu do + begin + result := SameText( StringReplace( (Item as TActionClientItem).Caption, '&', '', [rfReplaceAll]), Caption); + if not result then continue; + Finding := TActionClientItem( Item).Items; + break + end +end; + + + +procedure TmfmGUIRunner.actAttachLoggerExecute( Sender: TObject); +var + Logger: ITestLogger; + Properties: IInterface; + DisplayName: string; + Anchor: TActionClientItem; + OptionsMenu, SecondaryLoggersMenu: TActionClients; + + procedure AddActionMenuItem( Menu: TActionClients; Action: TAction); + begin + Menu.Add.Action := CreateLoggerAction( + Action, (Sender as TFactoryAction).FFactory, Logger, Properties, DisplayName, Anchor) + end; + +begin + // For each attached secondary logger, we will also have ... + // - Logger properties + // - Detach +with Sender as TFactoryAction do + begin + if not FFactory.EnquireForCreateLogger( Properties) then exit; + Logger := FFactory.Factory.CreateLogger( Properties); + DisplayName := Logger.MenuDescription; + FViewModel.AttachSecondaryLogger( Logger); + if FindMenuByCaption( tlbrMain.ActionClient.Items, 'Options', OptionsMenu) and + FindMenuByCaption( OptionsMenu, 'Secondary loggers', SecondaryLoggersMenu) then + begin + Anchor := SecondaryLoggersMenu.Add; + Anchor.Caption := DisplayName; + AddActionMenuItem( Anchor.Items, actEditLoggerProps); + AddActionMenuItem( Anchor.Items, actDetachLogger ) + end; + end; +end; + +procedure TmfmGUIRunner.actClearAllExecute( Sender: TObject); +begin +FViewModel.ClearAll +end; + +procedure TmfmGUIRunner.actClearExecute( Sender: TObject); +begin +FViewModel.ClearSelections +end; + +procedure TmfmGUIRunner.actClearLogExecute( Sender: TObject); +begin +FViewModel.ClearLog +end; + +procedure TmfmGUIRunner.actClearUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := FViewModel.CanClearSelections +end; + +procedure TmfmGUIRunner.actDetachLoggerExecute( Sender: TObject); +begin +FViewModel.DetachSecondaryLogger( (Sender as TLoggerAction).FLogger); +(Sender as TLoggerAction).FAnchorPoint.Destroy +end; + +procedure TmfmGUIRunner.actEditLoggerPropsExecute( Sender: TObject); +begin +with Sender as TLoggerAction do + FFactory.ViewEditProperties( FLogger, FProps) +end; + +procedure TmfmGUIRunner.actHaltOnFirstFailureExecute( Sender: TObject); +begin +FViewModel.DoHaltOnFirstFailure := (Sender as TAction).Checked +end; + +procedure TmfmGUIRunner.actHaltOnFirstFailureUpdate( Sender: TObject); +begin +(Sender as TAction).Enabled := FViewModel.CanToggleHaltOnFirstFailure; +(Sender as TAction).Checked := FViewModel.DoHaltOnFirstFailure +end; + +procedure TmfmGUIRunner.actRunExecute( Sender: TObject); +begin +FViewModel.Run +end; + +procedure TmfmGUIRunner.actRunUpdate(Sender: TObject); +begin +(Sender as TAction).Enabled := FViewModel.Model.Can_Run +end; + +procedure TmfmGUIRunner.actSelectAllExecute( Sender: TObject); +begin +FViewModel.SelectAll +end; + +procedure TmfmGUIRunner.actSelectDefaultExecute(Sender: TObject); +begin +FViewModel.SelectDefault +end; + +procedure TmfmGUIRunner.actSelectFailedExecute( Sender: TObject); +begin +FViewModel.SelectFailed +end; + +procedure TmfmGUIRunner.actSelectFailedUpdate( Sender: TObject); +var + Can: boolean; +begin +Can := FViewModel.CanSelectFailed; +actSelectFailed.Enabled := Can +end; + +procedure TmfmGUIRunner.actToggleSelectionExecute( Sender: TObject); +begin +FViewModel.ToggleSelections +end; + +procedure TmfmGUIRunner.appevMainIdle( Sender: TObject; var Done: Boolean); +begin +appevMain.OnIdle := nil; +FViewModel.FirstIdleEvent +end; + +//procedure TmfmGUIRunner.CreateDynamicMenuItems( SecondaryLoggers: IAdditionalLoggers); +//var +// Options, Addend: TActionClientItem; +// Factory: ILoggerFactoryUI; +//begin +//Options := (tlbrMain.ActionClient as TActionBarItem).Items.Add; +//Options.Caption := 'Options'; +//Addend := Options.Items.Add; +//Addend.Action := actHaltOnFirstFailure; +//Addend := Options.Items.Add; +//Addend.Action := actFailOnLeak; +//Addend := Options.Items.Add; +//Addend.Caption := 'Secondary loggers'; +//FSecondaryLoggersItem := Addend; +// +// // For each attached secondary logger, we will also have ... +// // - Logger properties +// // - Detach +// // - Secondary logger log level +// // -- Information (group 2+) +// // -- Warning +// // -- Error +// +//for Factory in SecondaryLoggers do +// begin +// Addend := FSecondaryLoggersItem.Items.Add; +// Addend.Action := CreateAttachLoggerAction( Factory); +// end; +//tlbrMain.RecreateControls; +//end; + +function TmfmGUIRunner.CreateAttachLoggerAction( const Factory: ILoggerFactoryUI): TAction; +begin +result := TFactoryAction.CreateFactoryAction( actAttachLogger.Owner, Factory); +result.ActionList := actAttachLogger.ActionList; +AssignAction( result, actAttachLogger); +result.Caption := Format( result.Caption, [Factory.Factory.MenuDescription]); +result.Category := '(dynamic)' +end; + +procedure TmfmGUIRunner.FormCreate(Sender: TObject); +begin +memoLog.Clear +end; + +procedure TmfmGUIRunner.FormDestroy( Sender: TObject); +begin +FViewModel.FormDestroyed +end; + + + + +procedure TConcreteView.Breathe; +begin +if FBreathing then exit; +FBreathing := True; +try + PostMessage( FForm.Handle, CM_UPDATEACTIONS, 0, 0); + Application.ProcessMessages; +finally + FBreathing := False + end +end; + + +procedure TConcreteView.ClearLog; +begin +Form.memoLog.Clear +end; + +constructor TConcreteView.Create; +begin +FSensitivity := Low( TPutLevel); +FBreathing := False; +inherited Create +end; + +procedure TConcreteView.EnterOperation( isEntering: boolean); +var + SubList: TCollectionItem; + + procedure AlignActionClientsWithActions( List: TCustomActionList); + var + Action: TContainedAction; + EnableableAction: TCustomAction; + Enabled: boolean; + begin + for Action in List do + begin + if not (Action is TCustomAction) then continue; + EnableableAction := TCustomAction( Action); + Enabled := EnableableAction.Enabled; + EnableableAction.Enabled := not Enabled; + EnableableAction.Enabled := Enabled + end; + end; + +begin +inherited; +if isEntering then + Form.actmngrMain.State := asSuspended + else + begin + Form.actmngrMain.State := asNormal; + // This next fragment of code is a work-around for a defect in the + // way actions work in D2010. + AlignActionClientsWithActions( Form.actmngrMain); + for SubList in Form.actmngrMain.LinkedActionLists do + AlignActionClientsWithActions( (SubList as TActionListItem).ActionList) + end +end; + +function TConcreteView.Form: TmfmGUIRunner; +begin +result := FForm as TmfmGUIRunner +end; + +function TConcreteView.GetProgressMax: integer; +begin +result := Form.pbarTests.Max +end; + +function TConcreteView.GetProgressPosition: integer; +begin +result := Form.pbarTests.Position +end; + +function TConcreteView.GetShowProgressBar: boolean; +begin +result := Form.pbarTests.Visible +end; + +procedure TConcreteView.InitiateView( TestCaseCount: integer); +begin +inherited; +ShowProgressBar := False; +ProgressPosition := 0; +ProgressMax := TestCaseCount +end; + +procedure TConcreteView.IntegrateSecondariesIntoMenus; +var + Gang: IAdditionalLoggers; + SecondaryLogger: ILoggerFactoryUI; + OptionsMenu, SecondaryLoggersMenu: TActionClients; +begin +if FExecutive.Services.Acquire( ILoggerFactoryUI, nil, Gang, '', nil) and + FindMenuByCaption( Form.tlbrMain.ActionClient.Items, 'Options', OptionsMenu) and + FindMenuByCaption( OptionsMenu, 'Attach new logger', SecondaryLoggersMenu) then + for SecondaryLogger in Gang do + with SecondaryLoggersMenu.Add do + // The Addend type is TActionClientItem + Action := Form.CreateAttachLoggerAction( SecondaryLogger); + +end; + + + + + + + + +procedure TConcreteView.Put( Level: TPutLevel; const Line: string; const Args: array of const); +var + Size1: integer; + Style1: TFontStyles; + Colour1: TColor; + OldCharRange, NewCharRange: TCharRange; +begin +Size1 := 10; +Colour1 := clBlack; +if FSensitivity > Level then exit; +case Level of + lvDebug: begin + Size1 := 8; + Style1 := []; + Colour1 := clDkGray + end; + + lvNormal: begin + Size1 := 10; + Style1 := []; + Colour1 := clBlack + end; + + lvHighLight: begin + Size1 := 12; + Style1 := [fsBold]; + Colour1 := clRed + end; + end; +with Form.memoLog do + begin + SendMessage( Handle, EM_EXGETSEL, 0, LParam( @OldCharRange)); + try + NewCharRange.cpMin := Form.memoLog.GetTextLen; + NewCharRange.cpMax := NewCharRange.cpMin; + SendMessage( Handle, EM_EXSETSEL, 0, LParam( @NewCharRange)); + SelAttributes.Size := Size1; + SelAttributes.Style := Style1; + SelAttributes.Color := Colour1; + SelText := Format( Line, Args) + #13#10 + finally + if not doAutoScroll then + SendMessage( Handle, EM_EXSETSEL, 0, LParam( @OldCharRange)) + end + end +end; + +procedure TConcreteView.SetDisplayState( Value: TSuiteRunnerState); +const + StateStrings: array[ TSuiteRunnerState] of string = ( + // rsIdle, rsSettingUp, rsExecuting, rsTearingDown, rsBetweenTests + 'Idle', 'Setting up', 'Executing', 'Tearing down', 'In between'); +begin +inherited SetDisplayState( Value); +Form.sbarMain.Panels[0].Text := StateStrings[ Value] +end; + +procedure TConcreteView.SetProgressMax( Value: integer); +var + s: string; +begin +Form.pbarTests.Max := Value; +if ShowProgressBar then + s := Format( 'of %d', [Value]) + else + s := ''; +Form.sbarMain.Panels[2].Text := s +end; + +procedure TConcreteView.SetProgressPosition( Value: integer); +var + s: string; +begin +Form.pbarTests.Position := Value; +if ShowProgressBar then + s := Format( 'Test cases = %d', [Value]) + else + s := ''; +Form.sbarMain.Panels[1].Text := s +end; + +procedure TConcreteView.SetShowProgressBar( Value: boolean); +begin +Form.pbarTests.Visible := Value +end; + +function TConcreteView.TreeName: string; +begin +result := 'treeTestSuite' +end; + +function TConcreteView.TreeOwner: TComponent; +begin +result := FForm +end; + +function TConcreteView.TreeParent: TWinControl; +begin +result :=(FForm as TmfmGUIRunner).pnlTestCases +end; + +{ TFactoryAction } + +constructor TFactoryAction.CreateFactoryAction( + AOwner: TComponent; const Factory: ILoggerFactoryUI); +begin +inherited Create( AOwner); +FFactory := Factory +end; + +{ TLoggerAction } + +constructor TLoggerAction.CreateLoggerAction( + AOwner: TComponent; const Factory1: ILoggerFactoryUI; const Logger: ITestLogger; + const Props: IInterface; AnchorPoint: TActionClientItem); +begin +inherited Create( AOwner); +FFactory := Factory1; +FLogger := Logger; +FProps := Props; +FAnchorPoint := AnchorPoint +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SBD.Environment.pas b/LockBox3/unit-tests/dunit-m/run/SBD.Environment.pas new file mode 100644 index 0000000..4dc38a5 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SBD.Environment.pas @@ -0,0 +1,166 @@ +unit SBD.Environment; +interface + +type +TProcessorArchitecture = ( + paIntel, // x86 + paAMD64, // x64 (AMD or Intel) + paIA64, // Intel Itanium Processor Family (IPF) + paIOS, + paOSX, + paAndroid, + paLinux, + paUnknown); // Unknown processor. + +TProcessorInformation = class + public + class function Architecture: TProcessorArchitecture; + class function OSVersion: string; + class function UTC_Offset: string; + end; + + +implementation + + +uses + {$IFDEF MSWINDOWS} + Windows, + {$ENDIF} + SysUtils; + + +{$IFDEF MSWINDOWS} +const + PROCESSOR_ARCHITECTURE_AMD64 = 9; // x64 (AMD or Intel) + PROCESSOR_ARCHITECTURE_IA64 = 6; // Intel Itanium Processor Family (IPF) + PROCESSOR_ARCHITECTURE_INTEL = 0; // x86 + PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF; // Unknown processor. + + Architectures: array[ 0..2 ] of record + FCode: word; FArch: TProcessorArchitecture end = ( + (FCode: PROCESSOR_ARCHITECTURE_INTEL; FArch: paIntel), + (FCode: PROCESSOR_ARCHITECTURE_AMD64; FArch: paAMD64), + (FCode: PROCESSOR_ARCHITECTURE_IA64 ; FArch: paIA64)); + +type +TGetNativeSystemInfo = procedure( var lpSystemInfo: TSystemInfo); stdcall; + +function WinArchitecture: TProcessorArchitecture; +var + KernelLib: integer; + GetNativeSystemInfoProc: TGetNativeSystemInfo; + Ok: boolean; + SystemInfo: TSystemInfo; + j: integer; +begin +result := paUnknown; +GetNativeSystemInfoProc := nil; +KernelLib := SafeLoadLibrary( 'Kernel32.dll'); +try + if KernelLib <> 0 then + GetNativeSystemInfoProc := GetProcAddress( + KernelLib, 'GetNativeSystemInfoA'); + Ok := assigned( GetNativeSystemInfoProc); + if Ok then + GetNativeSystemInfoProc( SystemInfo) +finally + if KernelLib <> 0 then + FreeLibrary( KernelLib) + end; +if not Ok then + windows.GetSystemInfo( SystemInfo); +for j := Low( Architectures) to High( Architectures) do + begin + if Architectures[j].FCode <> SystemInfo.wProcessorArchitecture then + continue; + result := Architectures[j].FArch; + break + end +end; +{$ENDIF} + +class function TProcessorInformation.Architecture: TProcessorArchitecture; +begin +{$IFDEF MSWINDOWS} + result := WinArchitecture; +{$ENDIF} +{$IFDEF IOS} + result := paIOS; +{$ENDIF} +{$IFDEF MACOS} + result := paOSX; +{$ENDIF} +{$IFDEF ANDROID} + result := paAndroid; +{$ENDIF} +{$IFDEF LINUX} + result := paLinux; +{$ENDIF} +end; + +class function TProcessorInformation.OSVersion: string; +begin +{$IFDEF MSWINDOWS} + result := Format( '%d.%d %s', [SysUtils.Win32MajorVersion, + SysUtils.Win32MinorVersion, + SysUtils.Win32CSDVersion]); +{$ENDIF} +{$IFDEF IOS} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF MACOS} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF ANDROID} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF LINUX} + result := 'function not yet developed'; +{$ENDIF} +end; + +class function TProcessorInformation.UTC_Offset: string; +{$IFDEF MSWINDOWS} +var + Info: TTimeZoneInformation; +{$ENDIF} + + function BiasAsString( BiasMinutes: integer): string; + begin + if BiasMinutes = 0 then + result := 'Z' + else + begin + result := Format( '%.2d:%.2d', [Abs( BiasMinutes) div 60, Abs( BiasMinutes) mod 60]); + if BiasMinutes < 0 then + result := 'UTC-' + result + else + result := 'UTC+' + result + end + end; + +begin +{$IFDEF MSWINDOWS} +case GetTimeZoneInformation( Info) of + TIME_ZONE_ID_INVALID, + TIME_ZONE_ID_UNKNOWN: result := '(unknown)'; + TIME_ZONE_ID_STANDARD: result := BiasAsString( Info.Bias + Info.StandardBias); + TIME_ZONE_ID_DAYLIGHT: result := BiasAsString( Info.Bias + Info.DaylightBias); + end; +{$ENDIF} +{$IFDEF IOS} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF MACOS} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF ANDROID} + result := 'function not yet developed'; +{$ENDIF} +{$IFDEF LINUX} + result := 'function not yet developed'; +{$ENDIF} +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SBD.Generics.pas b/LockBox3/unit-tests/dunit-m/run/SBD.Generics.pas new file mode 100644 index 0000000..3060674 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SBD.Generics.pas @@ -0,0 +1,520 @@ +{***************************************************************************} +{ } +{ Copyright (C) 2014 Sean B. Durkin } +{ } +{ sean@seanbdurkin.id.au } +{ http://seanbdurkin.id.au/sean } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +unit SBD.Generics; +interface + +uses Generics.Collections, Generics.Defaults; +type + +ISEnumerator = interface + ['{7DF98A2B-53EF-4D8D-AC14-ED9AC7A56C1B}'] + function MoveNext: boolean; + function GetCurrent: T; + property Current: T read GetCurrent; + end; + +ISEnumerable = interface + ['{42397EFC-5A3B-4873-8F09-7F2DD9AF2095}'] + function GetEnumerator: ISEnumerator; + end; + +type +TSEnumerable = class abstract( TInterfacedObject, ISEnumerable) + protected + function GetEnumerator: ISEnumerator; virtual; abstract; + end; + +TSEnumerator = class abstract( TInterfacedObject, ISEnumerator) + protected + FEnumerable: TSEnumerable; + FEnumHold : IInterface; + function MoveNext: boolean; virtual; abstract; + function GetCurrent: T; virtual; abstract; + public + constructor Create( Enumerable1: TSEnumerable); virtual; + end; + +IListWrap = interface + ['{A3BE9895-B1B5-4F16-8C61-FD1DF85D8B7A}'] + function GetList: TList; + property List: TList read GetList; + end; + +TListWrap = class( TInterfacedObject, IListWrap) + protected + FList: TList; + function GetList: TList; + public + constructor Create; overload; + constructor Create( const AComparer: IComparer); overload; + constructor Create( Collection: TEnumerable); overload; + constructor Create( const Collection: ISEnumerable); overload; + destructor Destroy; override; + property List: TList read GetList; + end; + +IList2 = interface( ISEnumerable) + ['{E2FD2C1F-E9B1-4D21-AD21-9C8CA9F2B977}'] + {$REGION 'property accessors'} + function GetCapacity: integer; + procedure SetCapacity( Value: integer); + function GetCount: integer; + procedure SetCount( Value: integer); + function GetItem( Index: integer): T; + procedure SetItem( Index: integer; const Value: T); + function GetOnNotify: TCollectionNotifyEvent; + procedure SetOnNotify( Value: TCollectionNotifyEvent); + {$ENDREGION} + + function Add(const Value: T): Integer; + procedure AddRange(const Values: array of T); overload; + procedure AddRange(const Collection: IEnumerable); overload; + procedure AddRange(Collection: TEnumerable); overload; + procedure AddRange(const Collection: ISEnumerable); overload; + procedure Insert(Index: Integer; const Value: T); + procedure InsertRange(Index: Integer; const Values: array of T); overload; + procedure InsertRange(Index: Integer; const Collection: IEnumerable); overload; + procedure InsertRange(Index: Integer; const Collection: TEnumerable); overload; + procedure InsertRange(Index: Integer; const Collection: ISEnumerable); overload; + function Remove(const Value: T): Integer; + procedure Delete(Index: Integer); + procedure DeleteRange(AIndex, ACount: Integer); + function Extract(const Value: T): T; + procedure Exchange(Index1, Index2: Integer); + procedure Move(CurIndex, NewIndex: Integer); + function First: T; + function Last: T; + procedure Clear; + function Contains(const Value: T): Boolean; + function IndexOf(const Value: T): Integer; + function LastIndexOf(const Value: T): Integer; + procedure Reverse; + procedure Sort; overload; + procedure Sort(const AComparer: IComparer); overload; + function BinarySearch(const Item: T; out Index: Integer): Boolean; overload; + function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer): Boolean; overload; + procedure TrimExcess; + property Capacity: Integer read GetCapacity write SetCapacity; + property Count: Integer read GetCount write SetCount; + property Items[Index: Integer]: T read GetItem write SetItem; default; + property OnNotify: TCollectionNotifyEvent read GetOnNotify write SetOnNotify; + end; + +TListCursor = class( TSEnumerator) + protected + FIdx: integer; + function MoveNext: boolean; override; + function GetCurrent: T; override; + function ListObj: TList; + public + constructor Create( Enumerable1: TSEnumerable); override; + end; + + +TList2 = class( TSEnumerable, IList2) + protected + FListObj: TList; + + function GetEnumerator: ISEnumerator; override; + function GetCapacity: integer; + procedure SetCapacity( Value: integer); + function GetCount: integer; + procedure SetCount( Value: integer); + function GetItem( Index: integer): T; + procedure SetItem( Index: integer; const Value: T); + function GetOnNotify: TCollectionNotifyEvent; + procedure SetOnNotify( Value: TCollectionNotifyEvent); + function Add(const Value: T): Integer; + procedure AddRange(const Values: array of T); overload; + procedure AddRange(const Collection: IEnumerable); overload; + procedure AddRange(const Collection: ISEnumerable); overload; + procedure AddRange(Collection: TEnumerable); overload; + procedure Insert(Index: Integer; const Value: T); + procedure InsertRange(Index: Integer; const Values: array of T); overload; + procedure InsertRange(Index: Integer; const Collection: IEnumerable); overload; + procedure InsertRange(Index: Integer; const Collection: ISEnumerable); overload; + procedure InsertRange(Index: Integer; const Collection: TEnumerable); overload; + function Remove(const Value: T): Integer; + procedure Delete(Index: Integer); + procedure DeleteRange(AIndex, ACount: Integer); + function Extract(const Value: T): T; + procedure Exchange(Index1, Index2: Integer); + procedure Move(CurIndex, NewIndex: Integer); + function First: T; + function Last: T; + procedure Clear; + function Contains(const Value: T): Boolean; + function IndexOf(const Value: T): Integer; + function LastIndexOf(const Value: T): Integer; + procedure Reverse; + procedure Sort; overload; + procedure Sort(const AComparer: IComparer); overload; + function BinarySearch(const Item: T; out Index: Integer): Boolean; overload; + function BinarySearch(const Item: T; out Index: Integer; const AComparer: IComparer): Boolean; overload; + procedure TrimExcess; + + public + constructor Create; overload; + constructor Create( const AComparer: IComparer); overload; + constructor Create( Collection: TEnumerable); overload; + constructor Create( const Collection: ISEnumerable); overload; + destructor Destroy; override; + + property Capacity: Integer read GetCapacity write SetCapacity; + property Count: Integer read GetCount write SetCount; + property Items[Index: Integer]: T read GetItem write SetItem; default; + property OnNotify: TCollectionNotifyEvent read GetOnNotify write SetOnNotify; + end; + +TEmptyCursor = class( TSEnumerator) + protected + function MoveNext: boolean; override; + function GetCurrent: T; override; + end; + +implementation + + + +//function TSEnumerable.GetEnumerator: IEnumerator; +//// This does not work for D2010 due to a compiler bug. So must override for D2010. +//var +// Cls: TClass; +//begin +//Cls := EnumeratorClass; +//if Cls.InheritsFrom( TSEnumerator) then +// result := TSEnumerator( Cls).Create( self) +// // ^ This is the part that breaks in D2010. It seems the compiler +// // can't find the correct location for the class VMT. +// else +// result := nil +//end; + + +constructor TSEnumerator.Create( Enumerable1: TSEnumerable); +begin +FEnumerable := Enumerable1; +FEnumHold := FEnumerable as IInterface +end; + + +constructor TListWrap.Create; +begin +FList := TList.Create +end; + +constructor TListWrap.Create( const AComparer: IComparer); +begin +FList := TList.Create( AComparer) +end; + +constructor TListWrap.Create( Collection: TEnumerable); +begin +FList := TList.Create( Collection) +end; + +constructor TListWrap.Create( const Collection: ISEnumerable); +var + Addend: T; +begin +Create; +for Addend in Collection do + FList.Add( Addend) +end; + + +destructor TListWrap.Destroy; +begin +FList.Free; +inherited +end; + +function TListWrap.GetList: TList; +begin +result := FList +end; + + + +function TEmptyCursor.GetCurrent: T; +begin +result := default( T) +end; + +function TEmptyCursor.MoveNext: boolean; +begin +result := False +end; + + +function TList2.Add( const Value: T): Integer; +begin +result := FListObj.Add( Value) +end; + +procedure TList2.AddRange( const Collection: IEnumerable); +begin +FListObj.AddRange( Collection) +end; + +procedure TList2.AddRange( Collection: TEnumerable); +begin +FListObj.AddRange( Collection) +end; + +procedure TList2.AddRange(const Values: array of T); +begin +FListObj.AddRange( Values) +end; + +procedure TList2.AddRange( const Collection: ISEnumerable); +begin +InsertRange( FListObj.Count, Collection) +end; + +function TList2.BinarySearch(const Item: T; out Index: Integer; + const AComparer: IComparer): Boolean; +begin +result := FListObj.BinarySearch( Item, Index, AComparer) +end; + +function TList2.BinarySearch(const Item: T; out Index: Integer): Boolean; +begin +result := FListObj.BinarySearch( Item, Index) +end; + +procedure TList2.Clear; +begin +FListObj.Clear +end; + +function TList2.Contains(const Value: T): Boolean; +begin +result := FListObj.Contains( Value) +end; + +constructor TList2.Create; +begin +FListObj := TList.Create +end; + +constructor TList2.Create( const AComparer: IComparer); +begin +FListObj := TList.Create( AComparer) +end; + +constructor TList2.Create( Collection: TEnumerable); +begin +FListObj := TList.Create( Collection) +end; + +constructor TList2.Create( const Collection: ISEnumerable); +begin +Create; +InsertRange( 0, Collection) +end; + +procedure TList2.Delete( Index: Integer); +begin +FListObj.Delete( Index) +end; + +procedure TList2.DeleteRange( AIndex, ACount: Integer); +begin +FListObj.DeleteRange( AIndex, ACount) +end; + +destructor TList2.Destroy; +begin +FListObj.Free; +inherited +end; + +procedure TList2.Exchange(Index1, Index2: Integer); +begin +FListObj.Exchange( Index1, Index2) +end; + +function TList2.Extract(const Value: T): T; +begin +result := FListObj.Extract( Value) +end; + +function TList2.First: T; +begin +result := FListObj.First +end; + +function TList2.GetCapacity: integer; +begin +result := FListObj.Capacity +end; + +function TList2.GetCount: integer; +begin +result := FListObj.Count +end; + +function TList2.GetEnumerator: ISEnumerator; +begin +result := TListCursor.Create( self) +end; + +function TList2.GetItem(Index: integer): T; +begin +result := FListObj[ Index] +end; + +function TList2.GetOnNotify: TCollectionNotifyEvent; +begin +result := FListObj.OnNotify +end; + +function TList2.IndexOf( const Value: T): Integer; +begin +result := FListObj.IndexOf( Value) +end; + +procedure TList2.Insert(Index: Integer; const Value: T); +begin +FListObj.Insert( Index, Value) +end; + +procedure TList2.InsertRange(Index: Integer; + const Collection: ISEnumerable); +var + Addend: T; +begin +for Addend in Collection do + begin + Insert( Index, Addend); + Inc( Index) + end +end; + +procedure TList2.InsertRange(Index: Integer; + const Collection: IEnumerable); +begin +FListObj.InsertRange( Index, Collection) +end; + +procedure TList2.InsertRange(Index: Integer; + const Collection: TEnumerable); +begin +FListObj.InsertRange( Index, Collection) +end; + +procedure TList2.InsertRange(Index: Integer; const Values: array of T); +begin +FListObj.InsertRange( Index, Values) +end; + +function TList2.Last: T; +begin +result := FListObj.Last +end; + +function TList2.LastIndexOf(const Value: T): Integer; +begin +result := FListObj.LastIndexOf( Value) +end; + +procedure TList2.Move(CurIndex, NewIndex: Integer); +begin +FListObj.Move( CurIndex, NewIndex) +end; + +function TList2.Remove(const Value: T): Integer; +begin +result := FListObj.Remove( Value) +end; + +procedure TList2.Reverse; +begin +FListObj.Reverse +end; + +procedure TList2.SetCapacity(Value: integer); +begin +FListObj.Capacity := Value +end; + +procedure TList2.SetCount(Value: integer); +begin +FListObj.Count := Value +end; + +procedure TList2.SetItem(Index: integer; const Value: T); +begin +FListObj[ Index] := Value +end; + +procedure TList2.SetOnNotify(Value: TCollectionNotifyEvent); +begin +FListObj.OnNotify := Value +end; + +procedure TList2.Sort(const AComparer: IComparer); +begin +FListObj.Sort( AComparer) +end; + +procedure TList2.Sort; +begin +FListObj.Sort +end; + +procedure TList2.TrimExcess; +begin +FListObj.TrimExcess +end; + + +constructor TListCursor.Create( Enumerable1: TSEnumerable); +begin +inherited Create( Enumerable1); +FIdx := -1 +end; + +function TListCursor.ListObj: TList; +begin +result := TList2( FEnumerable).FListObj +end; + +function TListCursor.GetCurrent: T; +begin +result := ListObj[ FIdx] +end; + +function TListCursor.MoveNext: boolean; +begin +result := FIdx <= (ListObj.Count - 2); +if result then + Inc( FIdx) +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SBD.Messages.Solution.pas b/LockBox3/unit-tests/dunit-m/run/SBD.Messages.Solution.pas new file mode 100644 index 0000000..5912dde --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SBD.Messages.Solution.pas @@ -0,0 +1,196 @@ +{***************************************************************************} +{ } +{ Copyright (C) 2014 Sean B. Durkin } +{ } +{ sean@seanbdurkin.id.au } +{ http://seanbdurkin.id.au/sean } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +unit SBD.Messages.Solution; +interface +uses SBD.Generics, SBD.Messages, Generics.Collections, SBD.ServiceProvider; + +type +TMessageList = class; +TMessageSource = class( TSEnumerable, IMessageSource) + private + FFilter: TMessageLevelSet; + FList: TMessageList; + FHold: IInterface; + protected + function GetEnumerator: ISEnumerator; override; + function EnumeratorClass: TClass; virtual; + public + constructor CreateAsSource( Filter: TMessageLevelSet; List1: TMessageList); + end; + +TMessageEnumerator = class( TSEnumerator) + private + FBaseCursor: ISEnumerator; + protected + function MoveNext: boolean; override; + function GetCurrent: RMessage; override; + public + constructor CreateMesgEnumrtr( Source: TMessageSource); + end; + +TMessageList = class( TList2, IMessageList, IMessageSink) + private + function AsSink: IMessageSink; + function AsSource( Filter: TMessageLevelSet): IMessageSource; + function Count( Filter: TMessageLevelSet): integer; + function Has( Filter: TMessageLevelSet): boolean; + function Clone: IMessageList; + procedure Post( const Addend: RMessage); + function ListeningLevel: TMessageLevel; + end; + + + + + +procedure RegisterServices( const Provider: IServiceProvider); + +implementation + + + + +uses SysUtils; + +procedure RegisterServices( const Provider: IServiceProvider); +begin +Provider.RegisterFlyweightService( IMessageList, + function( const Config: string; const ServiceProvider: IServiceProvider): IInterface + begin + Supports( TMessageList.Create, IMessageList, result) + end) +end; + + +function TMessageList.AsSink: IMessageSink; +begin +result := self +end; + +function TMessageList.AsSource( Filter: TMessageLevelSet): IMessageSource; +begin +result := TMessageSource.CreateAsSource( Filter, self) +end; + +function TMessageList.Clone: IMessageList; +type TMessageListClass = class of TMessageList; +var + Newbie: TMessageList; + Msg: RMessage; + Sink: IMessageSink; +begin +Newbie := TMessageListClass( ClassType).Create; +result := Newbie; +Sink := result.AsSink; +for Msg in AsSource( AllMessages) do + Sink.Post( Msg) +end; + +function TMessageList.Count( Filter: TMessageLevelSet): integer; +var + Msg: RMessage; +begin +if Filter = AllMessages then + result := GetCount + else + begin + result := 0; + for Msg in AsSource( Filter) do + Inc( result) + end +end; + + +function TMessageList.Has( Filter: TMessageLevelSet): boolean; +var + Msg: RMessage; +begin +if Filter = AllMessages then + result := GetCount > 0 + else + begin + result := False; + for Msg in AsSource( Filter) do + begin + result := True; + break + end + end +end; + +function TMessageList.ListeningLevel: TMessageLevel; +begin +if Has( [lvFatalError]) then + result := lvFatalError + else + result := Low( TMessageLevel) +end; + +procedure TMessageList.Post( const Addend: RMessage); +begin +Add( Addend) +end; + + +constructor TMessageSource.CreateAsSource( + Filter: TMessageLevelSet; List1: TMessageList); +begin +FFilter := Filter; +FList := List1; +FHold := List1 as IInterface +end; + +function TMessageSource.EnumeratorClass: TClass; +begin +result := TMessageEnumerator +end; + +function TMessageSource.GetEnumerator: ISEnumerator; +type TMessageEnumeratorClass = class of TMessageEnumerator; +begin +result := TMessageEnumeratorClass( EnumeratorClass).CreateMesgEnumrtr( self) +end; + + + +constructor TMessageEnumerator.CreateMesgEnumrtr( Source: TMessageSource); +begin +inherited Create( Source); +FBaseCursor := Source.FList.GetEnumerator +end; + +function TMessageEnumerator.GetCurrent: RMessage; +begin +result := FBaseCursor.Current +end; + +function TMessageEnumerator.MoveNext: boolean; +begin +repeat + result := FBaseCursor.MoveNext +until (not result) or (FBaseCursor.Current.FLevel in TMessageSource( FEnumerable).FFilter) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SBD.Messages.pas b/LockBox3/unit-tests/dunit-m/run/SBD.Messages.pas new file mode 100644 index 0000000..ab9a067 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SBD.Messages.pas @@ -0,0 +1,169 @@ +{***************************************************************************} +{ } +{ Copyright (C) 2014 Sean B. Durkin } +{ } +{ sean@seanbdurkin.id.au } +{ http://seanbdurkin.id.au/sean } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +unit SBD.Messages; +interface +uses SBD.Generics; + +type + +RMessageURL = record + /// + /// A URL together with an error code represents a family of messages with + /// the same structure. The URL is restricted in the following ways: + /// (1) It must be a valid URL. + /// (2) It must be in canonical form + /// (3) Only http: or https: protocol is permitted. + /// (4) Absolute only. No relative URL permitted. + /// (5) No fragments are permitted. + /// (6) Non-empty. Nulls and empty strings are not permitted. + /// + FURL: string; + + /// + /// Prefix is a unique abbrieviation for the URL. + /// It may be either the preferred prefix or the actual prefix, depending + /// on context. + /// + FPrefix: string; + end; + +type +TMessageLevel = ( + /// Message for debugging purposes only. + lvDebug, + /// Low importance, verbose message or general information. + lvStatistic, + /// In use for compilers, parsers and interpreters. + // Suggests an improvement in efficiency, + lvHint, + /// Regular message, not fitting into any other category. + lvRegular, + /// A potential defect. + lvWarning, + /// A recoverable error. + lvError, + /// A non-recoverable error. All further processing will cease. + lvFatalError); +TMessageLevelSet = set of TMessageLevel; + +const + AllMessages: TMessageLevelSet = [Low( TMessageLevel) .. High( TMessageLevel)]; + Errors : TMessageLevelSet = [lvError, lvFatalError]; + +type +RMessage = record + FMessageURL: RMessageURL; // The prefix part of this is the preferred prefix. + FMessageCode: integer; // Restricted to be non-zero. + FDisplayText: string; // Trim and non-empty. + FLevel: TMessageLevel; + FStamp: TDateTime; + /// + /// Restricted to the following types: + /// vtInteger + /// vtBoolean + /// vtExtended + /// vtClass + /// vtCurrency + /// vtInt64 + /// vtUnicodeString + /// Length( FData) restricted to a maximum of 9. + /// + FData: array of TVarRec; + procedure Clear; + end; + +IMessageSink = interface + ['{B5B7C8EB-3E76-44BD-A192-370385F860DB}'] + procedure Post( const Addend: RMessage); + function ListeningLevel: TMessageLevel; + end; + +IMessageSource = interface( ISEnumerable) + ['{5BE35232-0DEA-4F31-86B1-AD58F4AC1EED}'] + function GetEnumerator: ISEnumerator; + end; + +IMessageList = interface( IList2) + ['{0868AF4B-A4A3-42A3-85F1-9877762718A4}'] + function AsSink: IMessageSink; + function AsSource( Filter: TMessageLevelSet): IMessageSource; + procedure Clear; + function Count( Filter: TMessageLevelSet): integer; + function Has( Filter: TMessageLevelSet): boolean; + function Clone: IMessageList; + end; + + +function UniqueCloneMessage( const Source: RMessage): RMessage; +procedure UniqueCloneList( const Source: IMessageList; var Destination: IMessageList); +procedure CopyMessages( const Source: IMessageSource; const Destination: IMessageSink); + +implementation + + + + + + + + + +procedure RMessage.Clear; +begin +FMessageURL.FURL := ''; +FMessageURL.FPrefix := ''; +FMessageCode := 0; +FDisplayText := ''; +FLevel := lvDebug; +FStamp := 0.0; +SetLength( FData, 0) +end; + + +function UniqueCloneMessage( const Source: RMessage): RMessage; +begin +result := Source; +UniqueString( result.FDisplayText); +UniqueString( result.FMessageURL.FURL); +UniqueString( result.FMessageURL.FPrefix) +end; + +procedure UniqueCloneList( const Source: IMessageList; var Destination: IMessageList); +var + Msg: RMessage; +begin +for Msg in Source.AsSource( AllMessages) do + Destination.Add( UniqueCloneMessage( Msg)) +end; + +procedure CopyMessages( const Source: IMessageSource; const Destination: IMessageSink); +var + Msg: RMessage; +begin +for Msg in Source do + Destination.Post( Msg); +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SBD.Utils.XML2.pas b/LockBox3/unit-tests/dunit-m/run/SBD.Utils.XML2.pas new file mode 100644 index 0000000..44c56e3 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SBD.Utils.XML2.pas @@ -0,0 +1,3569 @@ +{***************************************************************************} +{ } +{ Copyright (C) 2014 Sean B. Durkin } +{ } +{ sean@seanbdurkin.id.au } +{ http://seanbdurkin.id.au/sean } +{ } +{ } +{***************************************************************************} +{ } +{ Licensed under the Apache License, Version 2.0 (the "License"); } +{ you may not use this file except in compliance with the License. } +{ You may obtain a copy of the License at } +{ } +{ http://www.apache.org/licenses/LICENSE-2.0 } +{ } +{ Unless required by applicable law or agreed to in writing, software } +{ distributed under the License is distributed on an "AS IS" BASIS, } +{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. } +{ See the License for the specific language governing permissions and } +{ limitations under the License. } +{ } +{***************************************************************************} + +unit SBD.Utils.XML2; +interface +uses XMLIntf, Classes, FMTBcd, Generics.Defaults; + +type + TMatchResult = (mNoMatch, mMatch); + TMatchResultSet = set of TMatchResult; + TPatternFunc = reference to function( const Haystack: string; var Position: integer): integer; + // returns length of next match. + RMatchFragment = record + FResult: TMatchResult; + FFragment: string; + end; + +{$REGION 'summary'} +type +/// +/// Helper functions for IXMLDocument +/// +{$ENDREGION} +TXMLDoc = class + public + class function NewEmtpy: IXMLDocument; + class function FromString( const psXMLStr: string): IXMLDocument; + class function FromUTF8String( const psXMLStr: utf8string): IXMLDocument; + class function FromFile( const psXMLFN: string): IXMLDocument; + class function FromStream( const Stream: TStream; EncodingType: TXMLEncodingType = xetUnknown): IXMLDocument; +{$ifdef MSWINDOWS} + class procedure DeclareSelectionNamespaces( const Doc: IXMLDocument; const Namespaces: string {space separated list of namespace declarations}); +{$endif} + end; + + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:boolean +/// +{$ENDREGION} +Txs_boolean = class + public + class function Encode( pbValue: boolean): string; + class function Decode( const psEncodedValue: string; Default: boolean): boolean; + end; + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:float and xs:double +/// +{$ENDREGION} +Txs_float = class + public + class function Encode( pnValue: double): string; overload; + class function Encode( pnValue: single): string; overload; + class function Decode( const psEncodedValue: string; var pnDecoded: double): boolean; overload; + class function Decode( const psEncodedValue: string; var pnDecoded: single): boolean; overload; + end; + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:decimal +/// +{$ENDREGION} +Txs_decimal = class + public + class function Encode( const pnValue: TBcd): string; + class function Decode( psEncodedValue: string; var pnDecoded: TBcd): boolean; + end; + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:integer +/// +{$ENDREGION} +Txs_integer = class + public + class function Encode( pnValue: int64): string; overload; + class function Encode( pnValue: uint64): string; overload; + class function Decode( const psEncodedValue: string; var pnDecoded: int64): boolean; overload; + class function Decode( const psEncodedValue: string; var pnDecoded: uint64): boolean; overload; + end; + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:duration +/// +{$ENDREGION} +Txs_duration = record + bPositive: boolean; + nYears : cardinal; + nMonths : cardinal; + nDays : cardinal; + nHours : cardinal; + nMinutes : cardinal; + nSeconds : double; // Maximum number of digits, when encoded is 18. + + procedure Zeroise; + procedure Negate; + procedure Normalise; + function isNormalForm: Boolean; + function Encode: string; + function Decode( const psEncodedValue: string): boolean; + class function GetEqualityComparer: IEqualityComparer; static; + function Equals( const Right: Txs_duration): boolean; + function GetHashCode: integer; + function isZero: boolean; + procedure DiffDateTime( a, b: TDateTime); + class operator Add( const a, b: Txs_duration): Txs_duration; + class operator Add( const a: Txs_duration; b: TDateTime): TDateTime; + class operator Add( a: TDateTime; const b: Txs_duration): TDateTime; + class operator Subtract( const a, b: Txs_duration): Txs_duration; + class operator Multiply( const b: Txs_duration; Factor: integer): Txs_duration; + end; + + +{$REGION 'summary'} +type +/// +/// Helper functions for XML data type xs:time, xs:date and xs:dateTime +/// +{$ENDREGION} +Txs_dateTime = class + public + class function EncodeTime( pdValue: TTime; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function DecodeTime( const psEncodedValue: string; var pdDecoded: TTime; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + + class function EncodeDate( pdValue: TDate): string; + class function DecodeDate( const psEncodedValue: string; var pdDecoded: TDate; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + + class function Encode( pdValue: TDateTime; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdDecoded: TDateTime; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + +TDateHelper = class + public + class function EncodeDate( Year: integer; Month, Day: word): TDate; + class procedure DecodeDate( Value: TDate; var Year: integer; var Month, Day: word); + end; + +Txs_gYearMonth = class + public + class function Encode( pdYear: integer; pdMonth: word; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdYear: integer; var pdMonth: word; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + +Txs_gMonth = class + public + class function Encode( pdMonth: word; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdMonth: word; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + +Txs_gYear = class + public + class function Encode( pdYear: integer; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdYear: integer; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + +Txs_gMonthDay = class + public + class function Encode( pdMonth, pdDay: word; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdMonth, pdDay: word; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + +Txs_gDay = class + public + class function Encode( pdDay: word; pbIncludeTZ: boolean; TZMinutes: integer): string; + class function Decode( const psEncodedValue: string; var pdDay: word; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + end; + + +Txs_Binary = class + public + class function EncodeHex( poData: TStream): string; + class function DecodeHex( const psEncodedValue: string; var poData: TStream): boolean; + class function EncodeBase64( poData: TStream): string; + class function DecodeBase64( const psEncodedValue: string; var poData: TStream): boolean; + end; + + +{$REGION 'summary'} +type +/// +/// Helper functions for MS XML's XPath 1.0 engine +/// +{$ENDREGION} +TXPath = class + public + class function SelectFirst( const poFocusNode: IXMLNode; const psXPath: string; var poSelectedNode: IXMLNode): boolean; + class function Select ( const poFocusNode: IXMLNode; const psXPath: string): TArray; + class function Enum( const poNodes: TArray) : IEnumerable; + + class function SelectString( const poFocusNode: IXMLNode; const psXPath: string; var psValue: string): boolean; + class function SelectedString( const poFocusNode: IXMLNode; const psXPath: string): string; + class function SelectedTrimString( const poFocusNode: IXMLNode; const psXPath: string): string; + class function SelectBoolean( const poFocusNode: IXMLNode; const psXPath: string; pbDefault: boolean): boolean; + class function SelectSingle( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: single): boolean; + class function SelectDouble( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: double): boolean; + class function SelectBCD( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: TBcd): boolean; + class function SelectInt32 ( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: integer): boolean; + class function SelectUInt32( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: cardinal): boolean; + class function SelectInt64 ( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: int64): boolean; + class function SelectUInt64( const poFocusNode: IXMLNode; const psXPath: string; var pnValue: uint64): boolean; + class function SelectDuration( const poFocusNode: IXMLNode; const psXPath: string; var pdValue: Txs_duration): boolean; + class function SelectDateTime( const poFocusNode: IXMLNode; const psXPath: string; var pdValue: TDateTime; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + class function SelectDate( const poFocusNode: IXMLNode; const psXPath: string; var pdValue: TDate; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + class function SelectTime( const poFocusNode: IXMLNode; const psXPath: string; var pdValue: TTime; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; + class function SelectHexBinary( const poFocusNode: IXMLNode; const psXPath: string; var poData: TStream): boolean; + class function SelectBase64Binary( const poFocusNode: IXMLNode; const psXPath: string; var poData: TStream): boolean; + + end; + + + +function StringValue( poNode: IXMLNode): string; + +type TDeclKind = (kXMLdecl, kTextDecl); +function DemarcEncoding( const Encoding: string; Decl: TDeclKind; XMLVer: string): string; + +function XMLTrim( const Value: string): string; overload; +function XMLTrim( const Value: utf8string): utf8string; overload; + +type +IStyleSheetParameter = interface + ['{29A0F508-7EF1-4CAC-ABC0-50ABCC81707B}'] + {$REGION 'property accessors'} + function GetURI: string; + function GetName: string; + function GetValue: string; + procedure SetValue( const Value: string); + function GetIsNull: boolean; + procedure SetIsNull( Value: boolean); + {$ENDREGION} + property URI: string read GetURI; + property ParamterName: string read GetName; + property ParameterValue: string read GetValue write SetValue; + property isNull: boolean read GetIsNull write SetIsNull; +end; + +IStyleSheetParameterSet = interface + ['{3481BD34-7220-4436-8C5B-7759F7BF05F1}'] + function Param( const URI, Name: string): IStyleSheetParameter; + function GetEnumerator: IEnumerator; +end; +TParametersSetProc = reference to procedure( const poParams: IStyleSheetParameterSet); + +function Contains ( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +function StartsWith( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +function EndsWith ( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +function CharIn( Ch: Char; const List: string): boolean; +function NormalizeXMLSpace( const Raw: string): string; + +function Substring( const sHaystack: string; Pos: Integer; Len: integer = -1): string; +// The substring function returns the substring of sHaystack +// starting at the position specified by Pos +// with length specified by Len. +// For example, substring("12345",2,3) returns "234". +// If the Len is -1, it returns the substring starting at the Pos and +// continuing to the end of the string. +// For example, substring("12345",2) returns "2345". + +function SubstringBefore( const sHaystack, sSubstring: string; isCaseInsensitive: boolean = False): string; +// The SubstringBefore function returns the substring of sHaystack that +// precedes the first occurrence of the sSubstring in sHaystack, +// or the empty string if sHaystack does not contain sSubstring. +// For example, SubstringBefore("1999/04/01","/") returns 1999. + +function SubstringAfter( const sHaystack, sSubstring: string; isCaseInsensitive: boolean = False): string; +// The SubstringAfter function returns the substring of sHaystack that +// follows the first occurrence of the sSubstring in sHaystack, +// or the empty string if sHaystack does not contain sSubstring. + +function StringLength( const sValue: string): integer; +// Length of the string in unicode character. Not the length of Char. + +function Translate( const sContent, sPattern, sReplacement: string): string; +// The translate function returns sContent with occurrences of characters +// in sPattern replaced by the character at the corresponding position in sReplacement. +// For example, Tnslate("bar","abc","ABC") returns the string BAr. +// If there is a character in sPattern with no character at a corresponding position in sReplacement +// (because sPattern is longer than sReplacement), then occurrences of that character in sContent are removed. +// For example, Translate("--aaa--","abc-","ABC") returns "AAA". +// If a character occurs more than once in sPattern, then the first occurrence determines the replacement character. +// If the sReplacement string is longer than the sPattern string, +// then excess characters are ignored. +// Note: This works on a unicode character basis, not a Char basis. + +{$if CompilerVersion >= 22.0} +function Tokenize( const Haystack: string; ReturnSet: TMatchResultSet; Pattern: TPatternFunc): IEnumerable; +{$ifend} + +{$ifdef MSWINDOWS} +type +TTransformOptions = ( + oSimpleXSLT1, + oPrettyPrint, + oAsNow + ); + +TTransformOptionSet = set of TTransformOptions; + +TXMLVersionInstruction = (xmlDefault, xml10, xml11); +TXSDVersionInstruction = (xsdDefault, xsd10, xsd11); + +TStyleSheet = class( TComponent) + private + oContent: TStrings; + oOptions: TTransformOptionSet; + sSaxonDir: string; + sContentName: string; + hasConvertedResource: boolean; + sWorkDir: string; + sURI: string; + oFilesToDelete: TStrings; + sCatalog: string; + nRepeats: cardinal; + eXMLVer: TXMLVersionInstruction; + eXSDVer: TXSDVersionInstruction; + dtAsNow: TDateTime; + nAsNowTZ: integer; + + procedure SetContent( Value: TStrings); + function ContentAsUtf8: UTF8String; + function NewTempFile( bDeleteWhenFinished: boolean; const Ext: string = ''): string; + procedure PurgeTemporaryFiles; + + published + property Content: TStrings read oContent write SetContent; + property ContentAsResource: string read sContentName write sContentName; + property Options: TTransformOptionSet read oOptions write oOptions; + property URI: string read sURI write sURI; + property Catalog: string read sCatalog write sCatalog; + property RepeatCount: cardinal read nRepeats write nRepeats default 1; + property XMLVer: TXMLVersionInstruction read eXMLVer write eXMLVer default xmlDefault; + property XSDVer: TXSDVersionInstruction read eXSDVer write eXSDVer default xsdDefault; + // Event to create and acquire a temporary file. + + public + property SaxonDirectory: string read sSaxonDir write sSaxonDir; + property WorkingDirectory: string read sWorkDir write sWorkDir; + property AsNow: TDateTime read dtAsNow write dtAsNow; + property AsNowTZ_Minutes: integer read nAsNowTZ write nAsNowTZ; + + constructor Create( AOwner: TComponent); override; + destructor Destroy; override; + function Parameters: IStyleSheetParameterSet; + function Transform( + InputDocumentFN : string; + OutputDocumentFN: string; + var ErrorOutput: string; + const WithParams: IStyleSheetParameterSet): boolean; + procedure LoadedAtRunTime; + + protected + procedure Loaded; override; + + private + procedure SetStaticDefaults; + procedure SetDynamicDefaults; + end; + + XFocus = record // Record containing the focus node for an XPATH expression. + N: IXMLNode; + class operator Explicit( const N1: IXMLNode): XFocus; + class operator Divide( const a: XFocus; const b: string): IEnumerable; + class operator IntDivide( const a: XFocus; const b: string): IXMLNode; +// class operator In( const a: string; const b: XFocus): boolean; +// class operator Multiply( const a: XFocus; StyleSheet: TStyleSheet): IXMLDocument; overload; + end; +{$endif} + + + +{$REGION 'Internal'} +{$if CompilerVersion >= 22.0} +type TTokenizer = class( TInterfacedObject, IEnumerable) + private + sHaystack: string; + oReturnSet: TMatchResultSet; + oPattern: TPatternFunc; + function GetEnumerator: IEnumerator; + function GetEnumeratorIntf: IEnumerator; + function IEnumerable.GetEnumerator = GetEnumeratorIntf; + + private type + TTokenCursor = class( TInterfacedObject, IEnumerator) + private + nPosition: integer; + oTokenizer: TTokenizer; + oHold: IInterface; + oCurrentRec: RMatchFragment; + bBufferedMatch: boolean; + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentRec: RMatchFragment; + function IEnumerator.GetCurrent = GetCurrentRec; + constructor Create( poTokenizer: TTokenizer); + end; + + public + constructor Create( const Haystack: string; ReturnSet: TMatchResultSet; Pattern: TPatternFunc); + end; +{$ifend} +{$ENDREGION} + + +type +UniChar = UCS4Char; + +RCodePoint = record + FIndex: integer; + FCurrentAsUniChar: UniChar; + FCurrentAsString: string; + end; + +ICodePointEnumerator = interface + ['{BC104326-7481-4E41-BFF8-A2BF6759AC66}'] + function MoveNext: boolean; + function GetCurrent: RCodePoint; + property Current: RCodePoint read GetCurrent; + end; + +RUnicodeParser = record + private + FValue: string; + + public + function GetEnumerator: ICodePointEnumerator; + class function ByCodePoint( const Value: string): RUnicodeParser; static; + end; + +{$ifdef MSWINDOWS} + ITransform = interface + ['{1004AE9A-D4AE-40E1-956D-AD98801AF7C1}'] + procedure SetInputDocumentFileName ( const sValue: string); + procedure SetOutputDocumentFileName( const sValue: string); + procedure AddParameter( const sParamBaseName, sParamValue, sNamespaceURI: string); + procedure Transform; + + property InputDocumentFileName : string write SetInputDocumentFileName; + property OutputDocumentFileName: string write SetOutputDocumentFileName; + end; + +XSelfTransform = record + csLiteralStyleSheet: string; + cParamsProc: TParametersSetProc; + bOk: boolean; + class operator Explicit( const psLiteralStyleSheet: string): XSelfTransform; + class operator Add( const This: XSelfTransform; ParamsProc: TParametersSetProc): XSelfTransform; + class operator Multiply( const sDocumentFileName: string; const This: XSelfTransform): XSelfTransform; overload; + class operator Multiply( const This: XSelfTransform; const sDocumentFileName: string): XSelfTransform; overload; + end; +{$endif} + +{$ifdef MSWINDOWS} +function ResourceName_to_Utf8( const ResourceName: string): UTF8String; +function MS_Transform( const sStylesheet: string; doPrettyPrint: boolean): ITransform; +{$endif} + +type + TUtilsFilenameToUriOptions = set of (fuSetLocalhost, fuPlainColon); +// Copied from UriUtils +function FilenameToUriStr( const Path: string; const Opt: TUtilsFilenameToUriOptions): string; + +{$ifdef MSWINDOWS} +var + sGlobalSaxonDir: string; +{$endif} + +{$ifdef MSWINDOWS} +const + DefaultNamespaceBase = 'http://www.seanbdurkin.id.au/pascaliburnus2/stylesheet'; +{$endif} + +implementation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +uses XMLDoc, xmldom, SysUtils, StrUtils, Math, Character, Generics.Collections + {$ifdef MSWINDOWS} + , ShlObj, Windows, msxmldom, msxml + {$endif} + , Contnrs, IOUtils, EncdDecd; + + +{$ifdef MSWINDOWS} +type IXMLDOMDocument2 = interface(IXMLDOMDocument) + ['{2933BF95-7B36-11D2-B20E-00C04F983E60}'] + function Get_namespaces: IXMLDOMSchemaCollection; safecall; + function Get_schemas: OleVariant; safecall; + procedure _Set_schemas(otherCollection: OleVariant); safecall; + function validate: IXMLDOMParseError; safecall; + procedure setProperty(const name: WideString; value: OleVariant); safecall; + function getProperty(const name: WideString): OleVariant; safecall; + property namespaces: IXMLDOMSchemaCollection read Get_namespaces; + property schemas: OleVariant read Get_schemas write _Set_schemas; +end; +{$endif} + +type TXMLDocProc = reference to procedure( const poDoc: IXMLDocument); + +{$ifdef MSWINDOWS} +RParamKey = record + sURI: string; + sName: string; + end; + +TParameter = class( TInterfacedObject, IStyleSheetParameter) + private + oParamName: RParamKey; + sValue: string; + bIsNull: boolean; + function GetURI: string; + function GetName: string; + function GetValue: string; + procedure SetValue( const Value: string); + function GetIsNull: boolean; + procedure SetIsNull( Value: boolean); + public + constructor Create( const poParamName: RParamKey); + end; +{$endif} + +{$ifdef MSWINDOWS} +TStyleSheetParameterSet = class( TInterfacedObject, IStyleSheetParameterSet) + private type + TKeyComparer = class( TInterfacedObject, IEqualityComparer) + private + function CmprEquals( const Left, Right: RParamKey): boolean; + function IEqualityComparer.Equals = CmprEquals; + function CmprGetHashCode( const Value: RParamKey): integer; + function IEqualityComparer.GetHashCode = CmprGetHashCode; + end; + private type + TParamDict = class( TDictionary) + protected + procedure ValueNotify(const Value: TParameter; Action: Generics.Collections.TCollectionNotification); override; + public + constructor Create( poStyleSheet: TStylesheet); + end; + private + coStyleSheet: TStyleSheet; + coParameters: TParamDict; + function Param( const URI, Name: string): IStyleSheetParameter; + function GetEnumerator: IEnumerator; + + public + constructor Create( poStyleSheet: TStyleSheet); + destructor Destroy; override; + end; +{$endif} + + +{$ifdef MSWINDOWS} +TParameterCursor = class( TInterfacedObject, IEnumerator) + private + oParamSet: TStyleSheetParameterSet; + nIndex : TEnumerator; + oHold : IInterface; + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentIntf: IStyleSheetParameter; + function IEnumerator.GetCurrent = GetCurrentIntf; + public + constructor Create( poParamSet: TStyleSheetParameterSet); + destructor Destroy; override; + end; +{$endif} + + + +function CyclicDiv( Quotient: int64; Divisor: integer): integer; +begin + Assert( Divisor > 0); + if Quotient >= 0 then + result := Quotient div Divisor + else + result := -( (Divisor - Quotient - 1) div Divisor) +end; + + +function DaysPerYear( y: integer): integer; +begin + result := (365*y) + CyclicDiv( y, 4) - CyclicDiv( y, 100) + CyclicDiv( y, 400) +end; + +// http://alcor.concordia.ca/~gpkatch/gdate-algorithm.html +function g( y,m,d: integer): integer; +var + y2: integer; +begin + y2 := y; + if m <= 2 then + Dec( y2); + result := + d - 1 + // Day component. + ((306 * ((m + 9) mod 12) + 5) div 10) + // Month component. + DaysPerYear( y2) +end; + + +procedure d( g: integer; var y, m, d: integer); +var + diff: integer; + mi: integer; + g64: Int64; + miPlus2: integer; + + procedure ComputeDiff; + begin + diff := g - DaysPerYear( y) + end; + +begin +g64 := g; +y := CyclicDiv( (10000*g64 + 14780), 3652425); +ComputeDiff; +if diff < 0 then + begin + Dec( y); + ComputeDiff + end; +mi := CyclicDiv( 100 * diff + 52, 3060); +miPlus2 := mi + 2; +m := (miPlus2 mod 12) + 1; +Inc( y, miPlus2 div 12); +d := diff - ((mi*306 + 5) div 10) + 1 +end; + + +const Delphi_To_1Mar1BC_Offset = 693899; + + +class function TDateHelper.EncodeDate( Year: integer; Month, Day: word): TDate; +// Replacement function for SysUtils.EncodeDate() +begin +result := g( Year, Month, Day) - Delphi_To_1Mar1BC_Offset +end; + +class procedure TDateHelper.DecodeDate( Value: TDate; var Year: integer; var Month, Day: Word); +// Replacement procedure for SysUtils.DecodeDate() +var + iMonth, iDay: integer; +begin +d( Math.Floor( Value) + Delphi_To_1Mar1BC_Offset, Year, iMonth, iDay); +Month := iMonth; +Day := iDay +end; + + +{$ifdef MSWINDOWS} +procedure SetMSXMLProperty( const poDoc: IXMLDocument; const PropName, PropValue: string; doForce: boolean); +var + XMLDOMNodeRef: IXMLDOMNodeRef; + Dom2: IXMLDOMDocument2; +begin +if Supports( poDoc.DOMDocument, IXMLDOMNodeRef, XMLDOMNodeRef) and + Supports( XMLDOMNodeRef.GetXMLDOMNode, IXMLDOMDocument2, Dom2) and + (doForce or (Dom2.getProperty( PropName) <> PropValue)) then + Dom2.setProperty( PropName, PropValue) +end; +{$endif} + +function CreateXMLDoc( OnLoad: TXMLDocProc): IXMLDocument; +var + oDoc: TXMLDocument; +begin + oDoc := TXMLDocument.Create( nil); + oDoc.Options := [doNodeAutoCreate, doNodeAutoIndent, doAttrNull, + doAutoPrefix, doNamespaceDecl]; +{$ifdef MSWINDOWS} + oDoc.DOMVendor := GetDOMVendor( 'MSXML'); +{$endif} + result := oDoc; + if assigned( OnLoad) then + OnLoad( result); + result.Active := True; +{$ifdef MSWINDOWS} + SetMSXMLProperty( Result, 'SelectionLanguage', 'XPath', False); +{$endif} +end; + + + +class function TXMLDoc.FromString( const psXMLStr: string): IXMLDocument; +begin +result := CreateXMLDoc( + procedure( const poDoc: IXMLDocument) + begin + poDoc.LoadFromXML( psXMLStr) + end); +end; + +class function TXMLDoc.FromUTF8String( const psXMLStr: utf8string): IXMLDocument; +begin +result := CreateXMLDoc( + procedure( const poDoc: IXMLDocument) + begin + poDoc.LoadFromXML( UTF8ToString( psXMLStr)) + end); +end; + + +class function TXMLDoc.NewEmtpy: IXMLDocument; +begin +result := CreateXMLDoc( nil) +end; + +class function TXMLDoc.FromFile( const psXMLFN: string): IXMLDocument; +begin +result := CreateXMLDoc( + procedure( const poDoc: IXMLDocument) + begin + poDoc.LoadFromFile( psXMLFN) + end); +end; + +class function TXMLDoc.FromStream( const Stream: TStream; EncodingType: TXMLEncodingType): IXMLDocument; +begin +result := CreateXMLDoc( + procedure( const poDoc: IXMLDocument) + begin + poDoc.LoadFromStream( Stream, EncodingType) + end); +end; + +{$ifdef MSWINDOWS} +class procedure TXMLDoc.DeclareSelectionNamespaces( const Doc: IXMLDocument; const Namespaces: string); +begin + SetMSXMLProperty( Doc, 'SelectionNamespaces', Namespaces, True); +end; +{$endif} + +class function TXPath.SelectFirst( const poFocusNode: IXMLNode; const psXPath: string; var poSelectedNode: IXMLNode): boolean; +var + oDomNodeSelect: IDomNodeSelect; + oDOMNode : IDomNode; + oDocAccess : IXmlDocumentAccess; + oDoc : TXmlDocument; +begin + poSelectedNode := nil; + oDOMNode := nil; + oDoc := nil; + if assigned( poFocusNode) and + Supports( poFocusNode.DOMNode, IDomNodeSelect, oDomNodeSelect) then + oDOMNode := oDomNodeSelect.selectNode( psXPath); + if assigned( poFocusNode) and Supports( poFocusNode.GetOwnerDocument, IXmlDocumentAccess, oDocAccess) then + oDoc := oDocAccess.DocumentObject; + if assigned( oDOMNode) then + poSelectedNode := TXmlNode.Create( oDOMNode, nil, oDoc); + result := assigned( poSelectedNode) +end; + +class function TXPath.SelectString( + const poFocusNode: IXMLNode; const psXPath: string; var psValue: string): boolean; +var + Node: IXMLNode; +begin + result := SelectFirst( poFocusNode, psXPath, Node); + if result then + psValue := StringValue( Node) +end; + +class function TXPath.SelectedString( + const poFocusNode: IXMLNode; const psXPath: string): string; +begin + if not SelectString( poFocusNode, psXPath, result) then + result := '' +end; + +class function TXPath.SelectedTrimString( + const poFocusNode: IXMLNode; const psXPath: string): string; +begin + result := XMLTrim( SelectedString( poFocusNode, psXPath)) +end; + + +class function TXPath.SelectHexBinary(const poFocusNode: IXMLNode; + const psXPath: string; var poData: TStream): boolean; +begin + // TODO + result := False +end; + +class function TXPath.SelectInt32( + const poFocusNode: IXMLNode; const psXPath: string; var pnValue: integer): boolean; +var + sValue: string; + Code: integer; +begin + sValue := SelectedTrimString( poFocusNode, psXPath); + Val( sValue, pnValue, Code); + result := (sValue <> '') and (Code = 0) +end; + +class function TXPath.SelectInt64( + const poFocusNode: IXMLNode; const psXPath: string; var pnValue: int64): boolean; +var + sValue: string; + Code: integer; +begin + sValue := SelectedTrimString( poFocusNode, psXPath); + Val( sValue, pnValue, Code); + result := (sValue <> '') and (Code = 0) +end; + +class function TXPath.SelectSingle( + const poFocusNode: IXMLNode; const psXPath: string; var pnValue: single): boolean; +begin + result := Txs_float.Decode( SelectedTrimString( poFocusNode, psXPath), pnValue) +end; + +class function TXPath.SelectTime( + const poFocusNode: IXMLNode; const psXPath: string; var pdValue: TTime; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +begin + result := Txs_dateTime.DecodeTime( SelectedTrimString( poFocusNode, psXPath), pdValue, pbIncludeTZ, TZMinutes) +end; + +class function TXPath.SelectUInt32(const poFocusNode: IXMLNode; + const psXPath: string; var pnValue: cardinal): boolean; +var + sValue: string; + Code: integer; +begin + sValue := SelectedTrimString( poFocusNode, psXPath); + Val( sValue, pnValue, Code); + result := (sValue <> '') and (Code = 0) +end; + +class function TXPath.SelectUInt64(const poFocusNode: IXMLNode; + const psXPath: string; var pnValue: uint64): boolean; +var + sValue: string; + Code: integer; +begin + sValue := SelectedTrimString( poFocusNode, psXPath); + Val( sValue, pnValue, Code); + result := (sValue <> '') and (Code = 0) +end; + +class function TXPath.Select( const poFocusNode: IXMLNode; const psXPath: string): TArray; +var + oDomNodeSelect: IDomNodeSelect; + oDOMNode : IDomNode; + oDocAccess : IXmlDocumentAccess; + oDoc : TXmlDocument; + oDOMNodes : IDOMNodeList; + iDOMNode : integer; +begin + oDOMNodes := nil; + SetLength( result, 0); + if assigned( poFocusNode) and + Supports( poFocusNode.DOMNode, IDomNodeSelect, oDomNodeSelect) then + oDOMNodes := oDomNodeSelect.SelectNodes( psXPath); + if not assigned( oDOMNodes) then exit; + SetLength( result, oDOMNodes.Length); + for iDOMNode := 0 to oDOMNodes.Length - 1 do + begin + oDoc := nil; + oDOMNode := oDOMNodes.item[iDOMNode]; + if Supports( oDOMNode, IXmlDocumentAccess, oDocAccess) then + oDoc := oDocAccess.DocumentObject; + result[ iDOMNode] := TXmlNode.Create( oDOMNode, nil, oDoc) as IXMLNode + end +end; + + +class function TXPath.SelectBase64Binary( + const poFocusNode: IXMLNode; const psXPath: string; var poData: TStream): boolean; +var + Node: IXMLNode; +begin + result := SelectFirst( poFocusNode, psXPath, Node) and + Txs_Binary.DecodeBase64( Node.Text, poData) +end; + +class function TXPath.SelectBCD( + const poFocusNode: IXMLNode; const psXPath: string; var pnValue: TBcd): boolean; +begin + result := Txs_decimal.Decode( SelectedTrimString( poFocusNode, psXPath), pnValue) +end; + +class function TXPath.SelectBoolean( + const poFocusNode: IXMLNode; const psXPath: string; pbDefault: boolean): boolean; +begin + result := Txs_boolean.Decode( SelectedTrimString( poFocusNode, psXPath), pbDefault) +end; + +class function TXPath.SelectDate( + const poFocusNode: IXMLNode; const psXPath: string; var pdValue: TDate; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +begin + result := Txs_dateTime.DecodeDate( SelectedTrimString( poFocusNode, psXPath), pdValue, pbIncludeTZ, TZMinutes) +end; + +class function TXPath.SelectDateTime(const poFocusNode: IXMLNode; + const psXPath: string; var pdValue: TDateTime; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +begin + result := Txs_dateTime.Decode( SelectedTrimString( poFocusNode, psXPath), pdValue, pbIncludeTZ, TZMinutes) +end; + +class function TXPath.SelectDouble(const poFocusNode: IXMLNode; + const psXPath: string; var pnValue: double): boolean; +begin + result := Txs_float.Decode( SelectedTrimString( poFocusNode, psXPath), pnValue) +end; + +class function TXPath.SelectDuration( + const poFocusNode: IXMLNode; const psXPath: string; var pdValue: Txs_duration): boolean; +begin + result := pdValue.Decode( SelectedTrimString( poFocusNode, psXPath)) +end; + +class function Txs_boolean.Encode( pbValue: boolean): string; +//http://www.w3.org/TR/xmlschema-2/#boolean +//3.2.2.1 Lexical representation +//An instance of a datatype that is defined as ·boolean· can have the following legal literals {true, false, 1, 0}. +begin + result := IfThen( pbValue, 'true', 'false') +end; + + +class function Txs_boolean.Decode( const psEncodedValue: string; Default: boolean): boolean; +begin + if psEncodedValue = '' then + result := Default + else + result := Pos( LowerCase( Copy( psEncodedValue + ' ', 1, 1)), 't1') > 0 +end; + +class function Txs_float.Decode( const psEncodedValue: string; var pnDecoded: single): boolean; +//The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively. Lexical representations for zero may take a positive or negative sign. +//For example, -1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 and INF are all legal literals for float. +var + nValueAsDouble: double; +begin + result := Decode( psEncodedValue, nValueAsDouble); + if Result then + pnDecoded := nValueAsDouble +end; + +class function Txs_float.Decode( const psEncodedValue: string; var pnDecoded: double): boolean; +begin + result := True; + if psEncodedValue = 'INF' then + pnDecoded := Infinity + else if psEncodedValue = '-INF' then + pnDecoded := NegInfinity + else if psEncodedValue = 'NaN' then + pnDecoded := NaN + else + result := TryStrToFloat( psEncodedValue, pnDecoded) +end; + +class function Txs_float.Encode( pnValue: single): string; +var + nValueAsDouble: double; +begin + nValueAsDouble := pnValue; + result := Encode( nValueAsDouble) +end; + + +function FloatToStrEx( Value: double): string; +// Copied from TypeTrans +var + FormatSettings : TFormatSettings; +begin + if IsNan( Value) then + result := 'NaN' + else if IsInfinite( Value) then + begin + if ((PInt64( @Value)^ and $8000000000000000) = $8000000000000000) then + result := '-INF' + else + result := 'INF'; + end + else + begin + FormatSettings.DecimalSeparator := '.'; + result := FloatToStr( Value, FormatSettings); + end; +end; + +class function Txs_float.Encode( pnValue: double): string; +begin + result := FloatToStrEx( pnValue) +end; + +{ Txs_decimal } + +class function Txs_decimal.Decode( + psEncodedValue: string; var pnDecoded: TBcd): boolean; +begin + result := FMTBcd.TryStrToBcd( psEncodedValue, pnDecoded) +end; + +class function Txs_decimal.Encode( const pnValue: TBcd): string; +begin + result := FMTBcd.BcdToStr( pnValue) +end; + +{$R-} +function TryStrToUINT64( StrValue:String; var uValue:UInt64 ):Boolean; +// Thanks to Warren P (http://stackoverflow.com/users/84704/warren-p) +// http://stackoverflow.com/questions/6077258 +var + Start,Base,Digit:Integer; + n:Integer; + Nextvalue:UInt64; +begin + result := false; + Digit := 0; + Base := 10; + Start := 1; + StrValue := UpperCase( StrValue); + if StrValue='' then + exit; + if StrValue[1]='-' then + exit; + if StrValue[1]='$' then + begin + Base := 16; + Start := 2; + if Length(StrValue)>17 then // $+16 hex digits = max hex length. + exit; + end; + uValue := 0; + for n := Start to Length(StrValue) do + begin + {$if CompilerVersion >= 27.0} + if StrValue[n].IsDigit then + {$else} + if Character.IsDigit(StrValue[n]) then + {$ifend} + Digit := Ord(StrValue[n])-Ord('0') + else if (Base=16) and (StrValue[n] >= 'A') and (StrValue[n] <= 'F') then + Digit := (Ord(StrValue[n])-Ord('A'))+10 + else + exit;// invalid digit. + + Nextvalue := (uValue * base) + digit; + if (Nextvalue < uValue) then + exit; + uValue := Nextvalue; + end; + result := true; // success. +end; +{$R+} + +class function Txs_integer.Decode( + const psEncodedValue: string; var pnDecoded: int64): boolean; +begin + result := TryStrToInt64( psEncodedValue, pnDecoded) +end; + +class function Txs_integer.Decode(const psEncodedValue: string; + var pnDecoded: uint64): boolean; +begin + result := TryStrToUINT64( psEncodedValue, pnDecoded) +end; + +class function Txs_integer.Encode( pnValue: int64): string; +begin + result := IntToStr( pnValue) +end; + +class function Txs_integer.Encode( pnValue: uint64): string; +begin + // result := UIntToStr( pnValue) + FmtStr( result, '%u', [pnValue]) +end; + +function FloorFrac( x: double): double; +begin + result := x - Math.Floor( x) +end; + + + +class function Txs_dateTime.Encode( pdValue: TDateTime; pbIncludeTZ: boolean; TZMinutes: integer): string; +// '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?, +begin + result := Txs_dateTime.EncodeDate( pdValue) + 'T' + + Txs_dateTime.EncodeTime( FloorFrac( pdValue), pbIncludeTZ, TZMinutes) +end; + + +function daysInMonth( m: word; isLeap: boolean): Word; +begin + case m of + 2: if isLeap then + result := 29 + else + result := 28; + 4, 6, 9, 11: result := 30; + else result := 31 + end; +end; + + +function ReadWord( const psEncoded: string; StartPos, Length: integer; MinVal, MaxVal: word; var Val1: word): boolean; +var + Code: integer; +begin + Val( Copy( psEncoded, StartPos, Length), Val1, Code); + result := (Code = 0) and (Val1 >= MinVal) and (Val1 <= MaxVal); +end; + + + +function Txs_dateTime_DecodeTimeZone( + const psEncodedValue: string; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +var + L: integer; + ch: char; + TZHour, TZMin: word; + + function ReadWord( StartPos, Length: integer; MinVal, MaxVal: word; var Val1: word): boolean; + begin + result := SBD.Utils.XML2.ReadWord( psEncodedValue, StartPos, Length, MinVal, MaxVal, Val1); + end; + +begin + result := True; + TZMinutes := 0; + L := Length( psEncodedValue); + if L > 0 then + ch := psEncodedValue[1] + else + ch := ' '; + case ch of + '+', '-': begin + pbIncludeTZ := True; + result := result and ReadWord( 2, 2, 0, 99, TZHour) and + ReadWord( 5, 2, 0, 59, TZMin); + TZMinutes := TZHour * 60 + TZMin; + result := result and (TZMinutes <= 840); + if ch = '-' then + TZMinutes := - TZMinutes + end; + 'Z': begin + pbIncludeTZ := True + end; + else pbIncludeTZ := False + end; +end; + + +class function Txs_dateTime.DecodeDate( + const psEncodedValue: string; var pdDecoded: TDate; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +var + sEncoded: string; + L: integer; + isNeg: boolean; + P: integer; + Year, Code: integer; + Month, Day: word; + isLeap: boolean; + MaxDay: word; + + function ReadWord( StartPos, Length: integer; MinVal, MaxVal: word; var Val1: word): boolean; + begin + result := SBD.Utils.XML2.ReadWord( sEncoded, StartPos, Length, MinVal, MaxVal, Val1); + end; + +begin + pdDecoded := 0.0; + Year := 0; + Month := 1; + Day := 1; + // '-9998-01-01' + sEncoded := psEncodedValue; + L := Length( sEncoded); + isNeg := (L > 0) and (sEncoded[1] = '-'); + if isNeg then + Delete( sEncoded, 1, 1); + // '9998-01-01' + P := Pos( '-', sEncoded); + if P > 0 then + Val( Copy( sEncoded, 1, P-1), Year, Code); + result := (P > 0) and (P <= 5) and (Code=0) and (Year >= 0) and (Year <= 9999); + if isNeg then + Year := -Year; + Delete( sEncoded, 1, P); + // '01-01' + result := result and ReadWord( 1, 2, 1, 12, Month); + isLeap := IsLeapYear( Year); + MaxDay := daysInMonth( Month, isLeap); + result := result and ReadWord( 4, 2, 1, MaxDay, Day); + Delete( sEncoded, 1, 5); + if result and ((Year <= -9999) or (Year >= 10000)) then + result := False; // Minimun supported date is 1-Jan-9999 BC. This is xs:dateTime('-9998-01-01T00:00:00') in xml schema v1.1 + if result then + begin + pdDecoded := TDateHelper.EncodeDate( Year, Month, Day); + result := Txs_dateTime_DecodeTimeZone( sEncoded, pbIncludeTZ, TZMinutes) + end +end; + + +function Txs_dateTime_DecodeTimeWithDayBump( + const psEncodedValue: string; var DayBump: word; var pdDecoded: TTime; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +var + sEncoded: string; + L: integer; + P, P1: integer; + Code: integer; + Hour, Minute, Sec: Word; + Milli: double; + + function ReadWord( StartPos, Length: integer; MinVal, MaxVal: word; var Val1: word): boolean; + begin + result := SBD.Utils.XML2.ReadWord( sEncoded, StartPos, Length, MinVal, MaxVal, Val1); + end; + +begin + pdDecoded := 0.0; + TZMinutes := 0; + Hour := 0; + Minute := 0; + Sec := 0; + Milli := 0.0; + // TZHour := 0; + // TZMin := 0; + DayBump := 0; + // '00:00:00' + sEncoded := psEncodedValue; + result := ReadWord( 1, 2, 0, 24, Hour) and + ReadWord( 4, 2, 0, 59, Minute) and + ReadWord( 7, 2, 0, 59, Sec); + Delete( sEncoded, 1, 8); + // '.124+11:00' + L := Length( sEncoded); + P := Pos( '+', sEncoded); + P1 := Pos( '-', sEncoded); + if (P = 0) or (P1 < P) then + P := P1; + P1 := Pos( 'Z', sEncoded); + if (P = 0) or (P1 < P) then + P := P1; + if P = 0 then + P := L + 1; + if (L > 0) and (sEncoded[1]='.') and (P >= 3) then + begin + Val( '0' + Copy( sEncoded, 1, P - 1), Milli, Code); + result := result and (Code = 0); + Delete( sEncoded, 1, P - 1) + end; + // '+11:00' + if result and (Hour = 24) then + begin + result := (Minute = 0) and (Sec = 0) and (Milli = 0.0); + Hour := 0; + DayBump := 1 + end; + result := result and Txs_dateTime_DecodeTimeZone( sEncoded, pbIncludeTZ, TZMinutes); + if result then + pdDecoded := SysUtils.EncodeTime( Hour, Minute, Sec, Round( Milli * 1000)) +end; + + +class function Txs_dateTime.DecodeTime( + const psEncodedValue: string; + var pdDecoded: TTime; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +var + DayBump: word; +begin + result := Txs_dateTime_DecodeTimeWithDayBump( + psEncodedValue, DayBump, pdDecoded, pbIncludeTZ, TZMinutes) +end; + + + +class function Txs_dateTime.Decode( + const psEncodedValue: string; var pdDecoded: TDateTime; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +var + dDate: TDate; + dTime: TTime; + sDatePart, sTimePart: string; + dDayBump: word; + P: integer; + iYear, iMonth, iDay: integer; +begin + P := Pos( 'T', psEncodedValue); + if P > 0 then + begin + sDatePart := Copy( psEncodedValue, 1, P - 1); + sTimePart := Copy( psEncodedValue, P + 1, MaxInt) + end + else + begin + sDatePart := psEncodedValue; + sTimePart := '' + end; + result := Txs_dateTime.DecodeDate( sDatePart, dDate, pbIncludeTZ, TZMinutes); + if result and (sTimePart <> '') then + result := Txs_dateTime_DecodeTimeWithDayBump( sTimePart, dDayBump, dTime, pbIncludeTZ, TZMinutes) + else + begin + dDayBump := 0; + dTime := 0.0 + end; + if result then + begin + dDate := dDate + dDayBump; + // Earliest supported date is 1-Jan-9999 BC. This is xs:dateTime('-9998-01-01T00:00:00') in xml schema v1.1 + d( Math.Floor( dDate) + Delphi_To_1Mar1BC_Offset, iYear, iMonth, iDay); + result := (iYear >= -9998) and (iYear <= 9999) + end; + if result then + pdDecoded := dDate + dTime; +end; + + + +class function Txs_dateTime.EncodeDate( pdValue: TDate): string; +var + Year: integer; + Month, Day: word; +begin + TDateHelper.DecodeDate( pdValue, Year, Month, Day); + // Don't use FormatDateTime() because it does not work for our target range of dates. + result := Format( '%.4d-%.2d-%.2d', [Abs( Year), Month, Day]); + if Year < 0 then + result := '-' + result; +end; + + +function Txs_dateTime_EncodeTimeZone( TZMinutes: integer): string; +begin + if TZMinutes = 0 then + result := 'Z' + else + begin + result := Format( '%.2d:%.2d', [Abs( TZMinutes) div 60, Abs( TZMinutes) mod 60]); + if TZMinutes >= 0 then + result := '+' + result + else + result := '-' + result + end; +end; + +class function Txs_dateTime.EncodeTime( pdValue: TTime; pbIncludeTZ: boolean; TZMinutes: integer): string; +var + Hour, Min, Sec, Milli: word; + L: integer; + LastCh: Char; +begin + SysUtils.DecodeTime( pdValue, Hour, Min, Sec, Milli); + result := result + Format('%.2d:%.2d:%.2d', [Hour, Min, Sec] ); + if Milli > 0 then + begin + result := result + Format('.%.3d', [Milli]); + L := Length( Result); + repeat + LastCh := result[L]; + if (LastCh = '0') or (LastCh = '.') then + begin + Dec( L); + SetLength( result, L) + end + until (LastCh <> '0') or (L = 0) + end; + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + + +function StringValue( poNode: IXMLNode): string; +var + oChild: IXMLNode; +begin + if not assigned( poNode) then + result := '' + else if poNode.NodeType in [ntElement, ntDocument, ntDocFragment] then + begin + result := ''; + oChild := poNode.ChildNodes.First; + while assigned( oChild) do + begin + result := result + StringValue( oChild); + oChild := oChild.NextSibling; + end; + end + else + result := poNode.text +end; + + +function isWhiteChar( Utf16CodeUnit: Char): boolean; inline; +begin +result := (Utf16CodeUnit = #$0020) or (Utf16CodeUnit = #$0009) or (Utf16CodeUnit = #$000D) or (Utf16CodeUnit = #$000A) +end; + +function isWhiteCharA( Utf16CodeUnit: AnsiChar): boolean; inline; +begin +result := (Utf16CodeUnit = #$0020) or (Utf16CodeUnit = #$0009) or (Utf16CodeUnit = #$000D) or (Utf16CodeUnit = #$000A) +end; + +function XMLTrim( const Value: string): string; +var + L, Base: integer; +begin +result := Value; +L := Length( result); +Base := 0; +while L > 0 do + begin + if isWhiteChar( result[1]) then + Base := 1 + else if isWhiteChar( result[L]) then + Base := L + else + break; + Delete( result, Base, 1); + Dec( L) + end +end; + +function XMLTrim( const Value: utf8string): utf8string; +var + L, Base: integer; +begin +result := Value; +L := Length( result); +Base := 0; +while L > 0 do + begin + if isWhiteCharA( result[1]) then + Base := 1 + else if isWhiteCharA( result[L]) then + Base := L + else + break; + Delete( result, Base, 1); + Dec( L) + end +end; + +function DemarcEncoding( const Encoding: string; Decl: TDeclKind; XMLVer: string): string; +begin + +end; + +function Contains( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +var + P: integer; +begin + if isCaseInsensitive then + P := Pos( LowerCase( sPattern), LowerCase( sHaystack)) + else + P := Pos( sPattern, sHaystack); + result := P > 0 +end; + +function StartsWith( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +begin + if isCaseInsensitive then + result := SameText( Copy( sHaystack, 1, Length( sPattern)), sPattern) + else + result := Copy( sHaystack, 1, Length( sPattern)) = sPattern +end; + +function EndsWith( const sHaystack, sPattern: string; isCaseInsensitive: boolean = False): boolean; +begin + if isCaseInsensitive then + result := SameText( Copy( sHaystack, Length( sHaystack) - Length( sPattern) + 1, Length( sPattern)), sPattern) + else + result := Copy( sHaystack, Length( sHaystack) - Length( sPattern) + 1, Length( sPattern)) = sPattern +end; + +function CharIn( Ch: Char; const List: string): boolean; +begin + result := Pos( Ch, List) > 0 +end; + +function NormalizeXMLSpace( const Raw: string): string; +var + bIsWhite, bPrevWhite: boolean; + ch: Char; + iRaw, j: integer; +begin + result := Raw; + bPrevWhite := True; + j := 1; + for iRaw := 1 to Length( Raw) do + begin + ch := Raw[ iRaw]; + bIsWhite := IsWhiteChar( ch); + if bPrevWhite and bIsWhite then continue; + result[ j] := ch; + Inc( j); + bPrevWhite := bIsWhite + end; + if bPrevWhite and (j >= 2) then + Dec( j); + SetLength( result, j - 1) +end; + +function Substring( const sHaystack: string; Pos: Integer; Len: integer = -1): string; +// The substring function returns the substring of sHaystack +// starting at the position specified by Pos +// with length specified by Len. +// For example, substring("12345",2,3) returns "234". +// If the Len is -1, it returns the substring starting at the Pos and +// continuing to the end of the string. +// For example, substring("12345",2) returns "2345". +begin + if Len <> -1 then + result := Copy( sHaystack, Pos, Len) + else + result := Copy( sHaystack, Pos, MaxInt) +end; + +function SubstringBefore( const sHaystack, sSubstring: string; isCaseInsensitive: boolean = False): string; +// The SubstringBefore function returns the substring of sHaystack that +// precedes the first occurrence of the sSubstring in sHaystack, +// or the empty string if sHaystack does not contain sSubstring. +// For example, SubstringBefore("1999/04/01","/") returns 1999. +var + P: integer; + sHay, sSub: string; +begin + if isCaseInsensitive then + begin + sHay := sHaystack; + sSub := sSubstring; + end + else + begin + sHay := Lowercase( sHaystack); + sSub := Lowercase( sSubstring); + end ; + P := Pos( sSub, sHay); + if P > 0 then + result := Copy( sHaystack, 1, P - 1) + else + result := '' +end; + +function SubstringAfter( const sHaystack, sSubstring: string; isCaseInsensitive: boolean = False): string; +// The SubstringAfter function returns the substring of sHaystack that +// follows the first occurrence of the sSubstring in sHaystack, +// or the empty string if sHaystack does not contain sSubstring. +var + P: integer; + sHay, sSub: string; +begin + if isCaseInsensitive then + begin + sHay := sHaystack; + sSub := sSubstring; + end + else + begin + sHay := Lowercase( sHaystack); + sSub := Lowercase( sSubstring); + end ; + P := Pos( sSub, sHay); + if P > 0 then + result := Copy( sHaystack, P + Length( sSubstring), MaxInt) + else + result := '' +end; + +function StringLength( const sValue: string): integer; +var + CodePoint: RCodePoint; +begin + result := 0; + for CodePoint in RUnicodeParser.ByCodePoint( sValue) do + Inc( result) +end; + +function Translate( const sContent, sPattern, sReplacement: string): string; +var + Dict: TDictionary; + CodePoint: RCodePoint; + ReplacerCursor: ICodePointEnumerator; + sReplac: string; +begin + Dict := TDictionary.Create; + ReplacerCursor := RUnicodeParser.ByCodePoint( sReplacement).GetEnumerator; + for CodePoint in RUnicodeParser.ByCodePoint( sPattern) do + begin + if assigned( ReplacerCursor) and ReplacerCursor.MoveNext then + sReplac := ReplacerCursor.Current.FCurrentAsString + else + begin + ReplacerCursor := nil; + sReplac := '' + end; + Dict.AddOrSetValue( CodePoint.FCurrentAsString, sReplac) + end; + result := ''; + for CodePoint in RUnicodeParser.ByCodePoint( sPattern) do + begin + if Dict.ContainsKey( CodePoint.FCurrentAsString) then + sReplac := Dict[ CodePoint.FCurrentAsString] + else + sReplac := CodePoint.FCurrentAsString; + result := result + sReplac + end; + Dict.Free +end; + + +{$if CompilerVersion >= 22.0} +function Tokenize( const Haystack: string; ReturnSet: TMatchResultSet; Pattern: TPatternFunc): IEnumerable; +begin + result := TTokenizer.Create( Haystack, ReturnSet, Pattern) +end; +{$ifend} + +type TNodeArrayEnumerable = class( TInterfacedObject, IEnumerable) + private + coNodes: TArray; + function GetEnumerator: IEnumerator; + function GetNodeEnumerator: IEnumerator; + function IEnumerable.GetEnumerator = GetNodeEnumerator; + private type + TCursor = class( TInterfacedObject, IEnumerator) + private + coNodes: TArray; + ciIdx : integer; + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentNode: IXMLNode; + function IEnumerator.GetCurrent = GetCurrentNode; + constructor Create( const poNodes: TArray); + end; + public + constructor Create( const poNodes: TArray); + end; + +class function TXPath.Enum( const poNodes: TArray): IEnumerable; +begin + result := TNodeArrayEnumerable.Create( poNodes) +end; + +{$ifdef MSWINDOWS} +class operator XFocus.Divide( + const a: XFocus; const b: string): IEnumerable; +begin + result := TXPath.Enum( TXPath.Select( a.N, b)) +end; + +class operator XFocus.Explicit( const N1: IXMLNode): XFocus; +begin + result.N := N1 +end; + +class operator XFocus.IntDivide(const a: XFocus; const b: string): IXMLNode; +begin +if not TXpath.SelectFirst( a.N, b, result) then + result := nil +end; +{$endif} + + +function Txs_duration_Normalise( const psUnnormal: Txs_duration): Txs_duration; +var + nTemp: UInt64; +begin + result := psUnnormal; + if (result.nSeconds < 0.0) and (result.nMinutes = 0) and + (result.nHours = 0) and (result.nDays = 0) and + (result.nMonths = 0) and (result.nYears = 0) then + begin + result.nSeconds := - result.nSeconds; + result.bPositive := not result.bPositive + end; + if result.nSeconds >= 60.0 then + begin + nTemp := Trunc( result.nSeconds / 60.0); + result.nSeconds := result.nSeconds - (nTemp * 60); + result.nMinutes := result.nMinutes + nTemp + end; + if result.nMinutes >= 60 then + begin + nTemp := result.nMinutes; + result.nMinutes := nTemp mod 60; + result.nHours := result.nHours + (nTemp div 60) + end; + if result.nHours >= 24 then + begin + nTemp := result.nHours; + result.nHours := nTemp mod 24; + result.nDays := result.nDays + (nTemp div 24) + end; + if result.nMonths >= 12 then + begin + nTemp := result.nMonths; + result.nMonths := nTemp mod 12; + result.nYears := result.nYears + (nTemp div 12) + end; + if (result.nSeconds = 0.0) and (result.nMinutes = 0) and + (result.nHours = 0) and (result.nDays = 0) and + (result.nMonths = 0) and (result.nYears = 0) and + (not result.bPositive) then + result.bPositive := True +end; + + +class operator Txs_duration.Add( const a, b: Txs_duration): Txs_duration; +var + NegB: Txs_duration; +begin + if a.bPositive = b.bPositive then + begin + result.bPositive := a.bPositive; + result.nYears := a.nYears + b.nYears; + result.nMonths := a.nMonths + b.nMonths; + result.nDays := a.nDays + b.nDays; + result.nHours := a.nHours + b.nHours; + result.nMinutes := a.nMinutes + b.nMinutes; + Result.nSeconds := a.nSeconds + b.nSeconds; + result.Normalise + end + else + begin + NegB := b; + NegB.Negate; + result := a - NegB + end +end; + + +class operator Txs_duration.Add( const a: Txs_duration; b: TDateTime): TDateTime; +var + Year: integer; + Month, Day: word; +begin + TDateHelper.DecodeDate( b, Year, Month, Day); + if a.bPositive then + begin + {$WARNINGS OFF} // Operands will be coerced into int64 and then back to int32. + // This is safe. + Year := Year + a.nYears + (a.nMonths div 12); + {$WARNINGS ON} + Month := Month + (a.nMonths mod 12); + if Month > 12 then + begin + Dec( Month, 12); + Inc( Year) + end; + result := TDateHelper.EncodeDate( Year, Month, Day) + FloorFrac( b) + a.nDays + + (a.nHours + ((a.nMinutes + (a.nSeconds / 60.0)) / 60.0) / 24.0); + end + else + begin + {$WARNINGS OFF} // Operands will be coerced into int64 and then back to int32. + // This is safe. + Year := Year - a.nYears - (a.nMonths div 12); + {$WARNINGS ON} + if Month <= (a.nMonths mod 12) then + begin + Inc( Month, 12 - (a.nMonths mod 12)); + Dec( Year); + end + else + Month := Month - (a.nMonths mod 12); + result := TDateHelper.EncodeDate( Year, Month, Day) + FloorFrac( b) - a.nDays - + (a.nHours + ((a.nMinutes + (a.nSeconds / 60.0)) / 60.0) / 24.0); + end; +end; + +class operator Txs_duration.Add( a: TDateTime; const b: Txs_duration): TDateTime; +begin + result := b + a +end; + + +function Txs_duration.Decode( const psEncodedValue: string): boolean; +// The lexical representation for duration is the [ISO 8601] extended format PnYnMnDTnHnMnS +type + TParticle = (eNull, eYear, eMonth, eDay, eTime, eHour, eMinute, eSecond); +var + s: string; + L: integer; + p: integer; + ch: char; + EndP: integer; + nDigits, nDots: integer; + Done: TParticle; + nDimension: integer; +begin + s := psEncodedValue; + L := Length( s); + Done := eNull; + Zeroise; + bPositive := (L = 0) or (s[1] <> '-'); + if not bPositive then + begin + Delete( s, 1, 1); + Dec( L) + end; + result := (L > 0) and (s[1]='P'); + if not result then exit; + Delete( s, 1, 1); + Dec( L); + while result and (L > 0) do + begin + EndP := L; + nDigits := 0; + nDots := 0; + ch := #1; + for p := 1 to L do + begin + ch := s[p]; + {$if CompilerVersion >= 27.0} + if ch.IsDigit then + {$else} + if Character.IsDigit( ch) then + {$ifend} + Inc( nDigits) + else if ch = '.' then + Inc( nDots) + else if ch = 'T' then + begin + EndP := p; + break + end + else + begin + EndP := p - 1; + break + end + end; + if (nDigits > 0) and (nDots = 0) then + begin + result := (Pos( ch, 'YMDH') > 0) and TryStrToInt( Copy( s, 1, EndP), nDimension); + Delete( s, 1, EndP + 1); + Dec( L, EndP + 1); + if L < 0 then + L := 0; + if result then + case ch of + 'Y': begin + result := Done < eYear; + Done := eYear; + nYears := nDimension + end; + 'M': begin + result := Done in [eNull, eYear, eTime, eHour]; + if Done in [eNull, eYear] then + begin + Done := eMonth; + nMonths := nDimension + end + else + begin + Done := eMinute; + nMinutes := nDimension + end + end; + 'D': begin + result := Done < eDay; + Done := eDay; + nDays := nDimension + end; + 'H': + begin + result := Done = eTime; + Done := eHour; + nHours := nDimension + end; + 'S': + begin + result := Done in [eTime, eHour, eMinute]; + Done := eSecond + end; + end; + end + else if (nDigits > 0) and (nDots = 1) then + begin + result := (Done in [eTime, eHour, eMinute]) and + (L > EndP) and + (s[EndP+1] = 'S') and + TryStrToFloat( Copy( s, 1, EndP), nSeconds); + Delete( s, 1, EndP + 1); + Dec( L, EndP + 1); + Done := eSecond + end + else if (nDigits = 0) and (nDots = 0) and (ch = 'T') then + begin + result := Done < eTime; + Done := eTime + end + else + result := False + end; + if result then + Normalise +end; + +procedure Txs_duration.DiffDateTime( a, b: TDateTime); +var + v: double; +begin + v := b - a; + Zeroise; + bPositive := v >= 0; + if not bPositive then + v := -v; + nDays := Trunc( v); + nSeconds := Frac( v) * 24 * 60 * 60; + Normalise +end; + +function Txs_duration.Encode: string; +var + V: Txs_duration; +begin + V := Txs_duration_Normalise( self); + result := 'P'; + if V.nYears <> 0 then + result := result + IntToStr( V.nYears) + 'Y'; + if V.nMonths <> 0 then + result := result + IntToStr( V.nMonths) + 'M'; + if V.nDays <> 0 then + result := result + IntToStr( V.nDays) + 'D'; + if (V.nHours <> 0) or (V.nMinutes <> 0) or (V.nSeconds > 0.0) then + result := result + 'T'; + if V.nHours <> 0 then + result := result + IntToStr( V.nHours) + 'H'; + if V.nMinutes <> 0 then + result := result + IntToStr( V.nMinutes) + 'M'; + if V.nSeconds <> 0 then + result := Format( '%s%fS', [result, V.nSeconds]); + if result = 'P' then + result := 'P0D'; + if not V.bPositive then + result := '-' + result +end; + +function Txs_duration.Equals( const Right: Txs_duration): boolean; +var + L, R: Txs_duration; +begin + L := Txs_duration_Normalise( self); + R := Txs_duration_Normalise( Right); + result := (L.nSeconds = R.nSeconds ) and + (L.nMinutes = R.nMinutes ) and + (L.nHours = R.nHours ) and + (L.nDays = R.nDays ) and + (L.nMonths = R.nMonths ) and + (L.nYears = R.nYears ) and + (L.bPositive = R.bPositive) +end; + +type +Txs_duration_GetEqualityComparer = class( TInterfacedObject, IEqualityComparer) + private + function CmprEquals( const Left, Right: Txs_duration): boolean; + function IEqualityComparer.Equals = CmprEquals; + function CmprGetHashCode( const Value: Txs_duration): integer; + function IEqualityComparer.GetHashCode = CmprGetHashCode; + public + constructor Create; + end; + +class function Txs_duration.GetEqualityComparer: IEqualityComparer; +begin + result := Txs_duration_GetEqualityComparer.Create +end; + +function Txs_duration.GetHashCode: integer; +var + x: Txs_duration; + v: uint64; +begin + x := Txs_duration_Normalise( self); + result := Ord( x.bPositive); + v := x.nYears * 12 + x.nMonths; + result := BobJenkinsHash( v, 8, result); + v := (x.nDays * 24 + x.nHours) * 60 + x.nMinutes; + result := BobJenkinsHash( v, 8, result); + result := BobJenkinsHash( x.nSeconds, SizeOf( x.nSeconds), result); +end; + +function Txs_duration.isNormalForm: Boolean; +var + L: Txs_duration; +begin + L := Txs_duration_Normalise( self); + result := (L.nSeconds = nSeconds ) and + (L.nMinutes = nMinutes ) and + (L.nHours = nHours ) and + (L.nDays = nDays ) and + (L.nMonths = nMonths ) and + (L.nYears = nYears ) and + (L.bPositive = bPositive) +end; + +function Txs_duration.isZero: boolean; +begin + result := (nYears = 0) and + (nMonths = 0) and + (nDays = 0) and + (nHours = 0) and + (nMinutes = 0) and + (nSeconds = 0.0) +end; + +class operator Txs_duration.Multiply( + const b: Txs_duration; Factor: integer): Txs_duration; +var + AbsFactor: cardinal; + isNegFactor: boolean; +begin + if Factor = 0 then + begin + result.Zeroise; + exit + end; + isNegFactor := Factor < 0; + if isNegFactor then + begin + AbsFactor := cardinal( - Factor); + result.bPositive := b.bPositive; + end + else + begin + AbsFactor := cardinal( Factor); + result.bPositive := b.bPositive; + end; + result.nSeconds := b.nSeconds * AbsFactor; + result.nMinutes := b.nMinutes * AbsFactor; + result.nHours := b.nHours * AbsFactor; + result.nDays := b.nDays * AbsFactor; + result.nMonths := b.nMonths * AbsFactor; + result.nYears := b.nYears * AbsFactor; + result.Normalise +end; + +procedure Txs_duration.Negate; +begin + bPositive := not bPositive +end; + +procedure Txs_duration.Normalise; +begin + self := Txs_duration_Normalise( self) +end; + +class operator Txs_duration.Subtract( const a, b: Txs_duration): Txs_duration; +var + NegB: Txs_duration; + DiffMonths, DiffMinutes: int64; + DiffSeconds: double; + M: uint64; +begin + if a.bPositive = b.bPositive then + begin + DiffMonths := (a.nYears - b.nYears) * 12 + (a.nMonths - b.nMonths); + DiffMinutes := ((a.nDays - b.nDays)*24 + (a.nHours - b.nHours)) * 60 + + (a.nMinutes - b.nMinutes); + DiffSeconds := a.nSeconds - b.nSeconds; + if (DiffMinutes > 0) and (DiffSeconds < 0.0) then + begin + M := Trunc(- DiffSeconds / 60.0) + 1; + DiffSeconds := DiffSeconds + (60.0 * M); + Dec( DiffMinutes, M); + end + else if (DiffMinutes < 0) and (DiffSeconds > 0.0) then + begin + M := Trunc( DiffSeconds / 60.0) + 1; + DiffSeconds := DiffSeconds - (60.0 * M); + Inc( DiffMinutes, M); + end; + if ((DiffMonths > 0) and (DiffMinutes < 0)) or + ((DiffMonths < 0) and (DiffMinutes > 0)) then + raise Exception.CreateFmt( 'Subtraction not defined between xs:duration %s and %s', [a.Encode, b.Encode]); + result.bPositive := a.bPositive; + if (DiffMonths < 0) or (DiffMinutes < 0) then + result.bPositive := not result.bPositive; + result.nYears := 0; + result.nMonths := Abs( DiffMonths); + result.nDays := 0; + result.nHours := 0; + result.nMinutes := Abs( DiffMinutes); + result.nSeconds := Abs( DiffSeconds); + result.Normalise + end + else + begin + NegB := b; + NegB.Negate; + result := a + NegB + end; +end; + +procedure Txs_duration.Zeroise; +begin + bPositive := True; + nYears := 0; + nMonths := 0; + nDays := 0; + nHours := 0; + nMinutes := 0; + nSeconds := 0 +end; + +{ Txs_duration_GetEqualityComparer } + +constructor Txs_duration_GetEqualityComparer.Create; +begin +end; + +function Txs_duration_GetEqualityComparer.CmprEquals( + const Left, Right: Txs_duration): boolean; +begin + result := Left.Equals( Right) +end; + +function Txs_duration_GetEqualityComparer.CmprGetHashCode( + const Value: Txs_duration): integer; +begin + result := Value.GetHashCode +end; + +{ TNodeArrayEnumerable } + +constructor TNodeArrayEnumerable.Create( const poNodes: TArray); +begin + coNodes := poNodes +end; + +function TNodeArrayEnumerable.GetEnumerator: IEnumerator; +begin + result := nil +end; + +function TNodeArrayEnumerable.GetNodeEnumerator: IEnumerator; +begin + result := TCursor.Create( coNodes) +end; + +{ TNodeArrayEnumerable.TCursor } + +constructor TNodeArrayEnumerable.TCursor.Create( + const poNodes: TArray); +begin + coNodes := poNodes; + Reset +end; + +function TNodeArrayEnumerable.TCursor.GetCurrent: TObject; +begin + result := nil +end; + +function TNodeArrayEnumerable.TCursor.GetCurrentNode: IXMLNode; +begin + result := coNodes[ ciIdx] +end; + +function TNodeArrayEnumerable.TCursor.MoveNext: Boolean; +begin + result := ciIdx <= (Length( coNodes) - 2); + if result then + Inc( ciIdx) +end; + +procedure TNodeArrayEnumerable.TCursor.Reset; +begin + ciIdx := -1 +end; + + + +{ Txs_Binary } + +class function Txs_Binary.DecodeBase64( + const psEncodedValue: string; var poData: TStream): boolean; +begin + result := True; + poData := TBytesStream.Create( EncdDecd.DecodeBase64( UTF8Encode( psEncodedValue))) +end; + +class function Txs_Binary.DecodeHex( + const psEncodedValue: string; var poData: TStream): boolean; +begin + result := False; + // TODO +end; + +class function Txs_Binary.EncodeBase64( poData: TStream): string; +begin + // TODO +end; + +class function Txs_Binary.EncodeHex( poData: TStream): string; +begin + result := ''; + // TODO +end; + +{ Txs_gYearMonth } + +class function Txs_gYearMonth.Decode( const psEncodedValue: string; + var pdYear: integer; var pdMonth: word; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +var + L: integer; + isNeg: boolean; + P: integer; + Code: integer; + sEncoded: string; +begin + sEncoded := psEncodedValue; + L := Length( sEncoded); + isNeg := (L > 0) and (psEncodedValue[1] = '-'); + if isNeg then + Delete( sEncoded, 1, 1); + P := Pos( '-', sEncoded); + if P > 0 then + Val( Copy( sEncoded, 1, P-1), pdYear, Code); + result := (P > 0) and (P <= 5) and (Code=0) and (pdYear >= 0) and (pdYear <= 9999); + if isNeg then + pdYear := -pdYear; + result := result and ReadWord( sEncoded, P+1, 2, 1, 12, pdMonth) + and Txs_dateTime_DecodeTimeZone( Copy( sEncoded, P+3, MaxInt), pbIncludeTZ, TZMinutes); +end; + + +class function Txs_gYearMonth.Encode( + pdYear: integer; pdMonth: word; + pbIncludeTZ: boolean; TZMinutes: integer): string; +begin + result := Format( '%.4d-%.2d', [Abs( pdYear), pdMonth]); + if pdYear < 0 then + result := '-' + result; + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + +{ Txs_gMonth } + +class function Txs_gMonth.Decode(const psEncodedValue: string; + var pdMonth: word; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +begin + result := ReadWord( psEncodedValue, 3, 2, 1, 12, pdMonth) + and Txs_dateTime_DecodeTimeZone( Copy( psEncodedValue, 5, MaxInt), pbIncludeTZ, TZMinutes); +end; + +class function Txs_gMonth.Encode( pdMonth: word; pbIncludeTZ: boolean; + TZMinutes: integer): string; +begin + result := Format( '--%.2d', [pdMonth]); + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + +{ Txs_gYear } + +class function Txs_gYear.Decode( + const psEncodedValue: string; + var pdYear: integer; var pbIncludeTZ: boolean; + var TZMinutes: integer): boolean; +var + L: integer; + isNeg: boolean; + Code: integer; + sEncoded: string; +begin + sEncoded := psEncodedValue; + L := Length( sEncoded); + isNeg := (L > 0) and (sEncoded[1] = '-'); + if isNeg then + Delete( sEncoded, 1, 1); + Val( Copy( sEncoded, 1, 4), pdYear, Code); + result := (L > 0) and (Code=0) and (pdYear >= 0) and (pdYear <= 9999); + if isNeg then + pdYear := -pdYear; + result := result and Txs_dateTime_DecodeTimeZone( Copy( sEncoded, 5, MaxInt), pbIncludeTZ, TZMinutes); +end; + +class function Txs_gYear.Encode( + pdYear: integer; pbIncludeTZ: boolean; TZMinutes: integer): string; +begin + result := Format( '%.4d', [Abs( pdYear)]); + if pdYear < 0 then + result := '-' + result; + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + +{ Txs_gMonthDay } + +class function Txs_gMonthDay.Decode( + const psEncodedValue: string; var pdMonth, + pdDay: word; var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +begin + result := ReadWord( psEncodedValue, 3, 2, 1, 12, pdMonth) + and ReadWord( psEncodedValue, 6, 2, 1, 31, pdDay) + and Txs_dateTime_DecodeTimeZone( Copy( psEncodedValue, 8, MaxInt), pbIncludeTZ, TZMinutes); +end; + +class function Txs_gMonthDay.Encode( + pdMonth, pdDay: word; pbIncludeTZ: boolean; TZMinutes: integer): string; +begin + result := Format( '--%.2d-%.2d', [pdMonth, pdDay]); + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + +{ Txs_gDay } + +class function Txs_gDay.Decode( + const psEncodedValue: string; var pdDay: word; + var pbIncludeTZ: boolean; var TZMinutes: integer): boolean; +begin + result := ReadWord( psEncodedValue, 4, 2, 1, 31, pdDay) + and Txs_dateTime_DecodeTimeZone( Copy( psEncodedValue, 6, MaxInt), pbIncludeTZ, TZMinutes); +end; + +class function Txs_gDay.Encode( + pdDay: word; pbIncludeTZ: boolean; TZMinutes: integer): string; +begin + result := Format( '---%.2d', [pdDay]); + if pbIncludeTZ then + result := result + Txs_dateTime_EncodeTimeZone( TZMinutes) +end; + +class function RUnicodeParser.ByCodePoint( const Value: string): RUnicodeParser; +begin +result.FValue := Value +end; + +type +TCodePointEnumerator = class( TInterfacedObject, ICodePointEnumerator) + private + FCurrent: RCodePoint; + FValue: string; + FIndex: integer; + function MoveNext: boolean; + function GetCurrent: RCodePoint; + constructor Create( const Value1: string); + end; + +function RUnicodeParser.GetEnumerator: ICodePointEnumerator; +begin +result := TCodePointEnumerator.Create( FValue) +end; + +constructor TCodePointEnumerator.Create( const Value1: string); +begin +FValue := Value1; +FIndex := 0; +FCurrent.FIndex := 0; +FCurrent.FCurrentAsUniChar := 0; +FCurrent.FCurrentAsString := '' +end; + +function TCodePointEnumerator.GetCurrent: RCodePoint; +begin +result := FCurrent +end; + + +function IsLeadSurrogate( ch: Char): boolean; inline; +begin +result := (ch >= #$D800) and (ch <= #$DBFF) +end; + +//function IsTrailSurrogate( ch: Char): boolean; inline; +//begin +//result := (ch >= #$DC00) and (ch <= #$DFFF) +//end; + + +const + ReplacementCharacter: UniChar = $00FFFD; + ReplacementChar : Char = #$FFFD; + +function Char_to_UniChar1( Lead: Char; var ch: UniChar): boolean; +begin +result := IsLeadSurrogate( Lead); +ch := Ord( Lead) +end; + +procedure Char_to_UniChar2( Trail: Char; var ch: UniChar); +begin +if (Trail >= #$DC00) and (ch >= $D800) then + ch := ((LongRec(ch).Lo - $D800) shl 10) + (Ord( Trail) - $DC00) + $010000 + else + ch := ReplacementCharacter +end; + +function TCodePointEnumerator.MoveNext: boolean; +var + ch1, ch2: Char; +begin +result := FIndex > Length( FValue); +if not result then exit; +Inc( FIndex); +result := FIndex > Length( FValue); +if result then + begin + ch1 := FValue[ FIndex]; + if Char_to_UniChar1( ch1, FCurrent.FCurrentAsUniChar) then + begin + Inc( FIndex); + if FIndex > Length( FValue) then + begin + SetLength( FCurrent.FCurrentAsString, 2); + ch2 := FValue[ FIndex]; + Char_to_UniChar2( ch2, FCurrent.FCurrentAsUniChar); + FCurrent.FCurrentAsString[2] := ch2 + end + else + begin + SetLength( FCurrent.FCurrentAsString, 1); + FCurrent.FCurrentAsUniChar := ReplacementCharacter; + ch1 := ReplacementChar + end + end + else + SetLength( FCurrent.FCurrentAsString, 1); + FCurrent.FCurrentAsString[1] := ch1 + end; +FCurrent.FIndex := FIndex +end; + +{$if CompilerVersion >= 22.0} +constructor TTokenizer.Create( + const Haystack: string; ReturnSet: TMatchResultSet; Pattern: TPatternFunc); +begin + sHaystack := Haystack; + oReturnSet := ReturnSet; + oPattern := Pattern +end; + +function TTokenizer.GetEnumerator: IEnumerator; +begin + result := nil +end; + +function TTokenizer.GetEnumeratorIntf: IEnumerator; +begin + result := TTokenCursor.Create( self) +end; + + +constructor TTokenizer.TTokenCursor.Create( poTokenizer: TTokenizer); +begin + oTokenizer := poTokenizer; + oHold := oTokenizer; + Reset +end; + +function TTokenizer.TTokenCursor.GetCurrent: TObject; +begin + result := nil +end; + +function TTokenizer.TTokenCursor.GetCurrentRec: RMatchFragment; +begin + result := oCurrentRec +end; + +function TTokenizer.TTokenCursor.MoveNext: boolean; +var + nStart, Len: integer; + nFragStart, nFragLen: integer; +begin + nStart := 1; + Len := 0; + repeat + result := bBufferedMatch or (nPosition < Length( oTokenizer.sHaystack)); + if not result then break; + if not bBufferedMatch then + begin + Inc( nPosition); + nStart := nPosition; + Len := oTokenizer.oPattern( oTokenizer.sHaystack, nPosition) + end; + nFragStart := nStart; + if (not bBufferedMatch) and (Len = 0) then + begin + oCurrentRec.FResult := mNoMatch; + nFragLen := MaxInt; + nPosition := Length( oTokenizer.sHaystack) + end + else if (not bBufferedMatch) and (nPosition > nStart) then + begin + oCurrentRec.FResult := mNoMatch; + nFragLen := nPosition - nStart; + bBufferedMatch := True + end + else + begin + oCurrentRec.FResult := mMatch; + nFragStart := nPosition; + nFragLen := Len; + Inc( nPosition, Len); + bBufferedMatch := False + end; + oCurrentRec.FFragment := Copy( oTokenizer.sHaystack, nFragStart, nFragLen); + until (oCurrentRec.FResult in oTokenizer.oReturnSet) or (not result) +end; + +procedure TTokenizer.TTokenCursor.Reset; +begin + nPosition := 0; + bBufferedMatch := False +end; +{$ifend} + +{$ifdef MSWINDOWS} +function ResourceName_to_Utf8( const ResourceName: string): UTF8String; +const + BOM: packed array[0..2] of byte = (239,187,191); +var + ResStream: TStream; +begin +ResStream := TResourceStream.Create( hInstance, ResourceName, RT_RCDATA); +SetLength( result, ResStream.Size); +if result <> '' then + ResStream.Read( result[1], Length(result)); +ResStream.Free; +if (Length( result) >= 3) and CompareMem( @result[1], @BOM[0], 3) then + Delete( result, 1, 3) +end; +{$endif} + +function FilenameToUriStr( const Path: string; const Opt: TUtilsFilenameToUriOptions): string; +var + I, L: Integer; +begin + if fuSetLocalhost in Opt then + Result := 'file://localhost' + else + Result := 'file://'; + L := Length(Path); + if L > 0 then + begin + // Add leading '/': + Result := Concat(Result, '/'); + I := 1; + while I <= L do + begin + case Byte(Path[I]) of + // A-z a-z 0-9 ! '()* - . _ ~ + $41..$5A, $61..$7A, $30..$39, $21, $27..$2A, $2D, $2E, $5F, $7E: + Result := Concat(Result, Path[I]); + // special treatment for colons (':'): + $3A: + if fuPlainColon in Opt then + Result := Concat(Result, ':') + else + Result := Concat(Result, '%3a'); +{$IFDEF LINUX} + // keep '/' in Linux filenames. + $2F: + Result := Concat(Result, '/'); +{$ELSE} + // translate '\' to '/' in Windows filenames: + $5C: + Result := Concat(Result, '/'); +{$ENDIF} + else + // calculate escape sequence: + Result := Concat(Result, '%', IntToHex(Byte(Path[I]), 2)); + end; + Inc(I); + end; {while ...} + end; {if ...} +end; + + +{$ifdef MSWINDOWS} +function TStyleSheet.ContentAsUtf8: UTF8String; +begin + result := UTF8Encode( XMLTrim( oContent.Text)); + if (result = '') and (sContentName <> '') and (not hasConvertedResource) then + begin + hasConvertedResource := True; + result := XMLTrim( ResourceName_to_Utf8( sContentName)); + oContent.Text := UTF8ToString( result) + end +end; + +constructor TStyleSheet.Create( AOwner: TComponent); +begin + inherited; + nRepeats := 1; + eXMLVer := xmlDefault; + eXSDVer := xsdDefault; + oContent := TStringList.Create; + hasConvertedResource := False; + oFilesToDelete := TStringList.Create; + SetStaticDefaults +end; + +destructor TStyleSheet.Destroy; +begin + PurgeTemporaryFiles; + oFilesToDelete.Free; + oContent.Free; + inherited +end; + +procedure TStyleSheet.Loaded; +begin + inherited; + SetDynamicDefaults +end; + +procedure TStyleSheet.LoadedAtRunTime; +begin + Loaded +end; + +function TStyleSheet.Parameters: IStyleSheetParameterSet; +begin + result := TStyleSheetParameterSet.Create( self) +end; + +function TStyleSheet.NewTempFile( bDeleteWhenFinished: boolean; const Ext: string): string; +var + sDir: string; +begin + if Ext = '' then + begin + {$ifdef MSWINDOWS} + if sWorkDir = '' then + result := TPath.GetTempFileName + else + begin + SetLength( result, MAX_PATH); + if Windows.GetTempFileName( PChar( sWorkDir), 'tmp', 0, PChar( result)) = 0 then + raise EInOutError.Create( SysErrorMessage( GetLastError)) + end; + SetLength( Result, StrLen( PChar( result))) + {$else} + result := TPath.GetTempFileName + {$endif} + end + else + begin + sDir := sWorkDir; + if sDir = '' then + sDir := IncludeTrailingPathDelimiter( TPath.GetTempPath); + repeat + result := sDir + '\tmp' + Format( '%.6d', [Random(1000000)]) + Ext + until not TFile.Exists( result) + end; + TFile.Create( result).Destroy; + if bDeleteWhenFinished then + oFilesToDelete.Add( result) +end; + +procedure TStyleSheet.PurgeTemporaryFiles; +var + sFN: string; +begin + for sFN in oFilesToDelete do + try + TFile.Delete( sFN) + except end; + oFilesToDelete.Clear +end; + +procedure TStyleSheet.SetContent( Value: TStrings); +begin + oContent.Clear; + if assigned( Value) then + oContent.AddStrings( Value) +end; + +procedure TStyleSheet.SetDynamicDefaults; +begin + if sSaxonDir = '' then + sSaxonDir := sGlobalSaxonDir; + if (sURI = '') and (Name <> '') then + sURI := DefaultNamespaceBase + '/' + Name; + sWorkDir := IncludeTrailingPathDelimiter( sWorkDir ); + sSaxonDir := IncludeTrailingPathDelimiter( sSaxonDir) +end; + +procedure TStyleSheet.SetStaticDefaults; +begin + oOptions := [oPrettyPrint] +end; + +type + TStylesheetLinkKind = (eInclude, eImport); + TStylesheetLinkKindSet = set of TStylesheetLinkKind; + + TDependentStylesheets = class( TInterfacedObject, IEnumerable) + public + constructor Create( psPrimus: TStylesheet; pLinkage: TStylesheetLinkKindSet); + private + coPrimus: TStyleSheet; + Linkage: TStylesheetLinkKindSet; + function GetEnumerator: IEnumerator; + function GetEnumeratorIntf: IEnumerator; + function IEnumerable.GetEnumerator = GetEnumeratorIntf; + private type + TDependenctCursor = class( TInterfacedObject, IEnumerator) + public + constructor Create( poPrimus: TStylesheet; pLinkage: TStylesheetLinkKindSet); + destructor Destroy; override; + private + coDependents: TObjectList; + coContainer: TDataModule; + ciIndex: integer; + coPrimus: TStyleSheet; + Linkage: TStylesheetLinkKindSet; + function GetCurrent: TObject; + function MoveNext: Boolean; + procedure Reset; + function GetCurrentIntf: TStylesheet; + function IEnumerator.GetCurrent = GetCurrentIntf; + end; + end; + +function Dependents( psPrimus: TStylesheet; Linkage: TStylesheetLinkKindSet): IEnumerable; +begin + result := TDependentStylesheets.Create( psPrimus, Linkage) +end; +{$endif} + +{$ifdef MSWINDOWS} +function ShortForm( const psLongFileName: string): string; +var + Buffer: array[0..MAX_PATH - 1] of Char; +begin + result := psLongFileName; + SetString( result, Buffer, + GetShortPathName( PChar( result), Buffer, SizeOf( Buffer))); + if result = '' then + result := psLongFileName +end; +{$endif} + +{$ifdef MSWINDOWS} +function GetSpecialFolder( FolderID: longint): string; +var + idList : PItemIDList; +begin + SetLength( result, MAX_PATH); + if SHGetFolderLocation( 0, FolderID, 0, 0, idList) = S_OK then + begin + SHGetPathFromIDList( idList, PChar( result)); + SetLength( result, StrLen( PChar( result))); + ILFree( idList) + end + else + result := '' +end; +{$endif} + +{$ifdef MSWINDOWS} +type + TMS_XSLT = class( TInterfacedObject, ITransform) + private + FStylesheet: IXSLTemplate; + FStylesheetAsDoc: IXMLDOMDocument2; + FInputFN, FOutputFN: string; + FProcessor: IXSLProcessor; + FWriter: IMXWriter; + + procedure SetInputDocumentFileName ( const sValue: string); + procedure SetOutputDocumentFileName( const sValue: string); + procedure MakeProcessor; + + public + constructor Create( const sStylesheet: string; doPrettyPrint: boolean); + procedure AddParameter( const sParamBaseName, sParamValue, sNamespaceURI: string); + procedure Transform; + + property InputDocumentFileName : string write SetInputDocumentFileName; + property OutputDocumentFileName: string write SetOutputDocumentFileName; + end; + +constructor TMS_XSLT.Create( const sStylesheet: string; doPrettyPrint: boolean); +begin + if doPrettyPrint then + begin + FWriter := msxml.CoMXXMLWriter60.Create; + FWriter.indent := True; + FWriter.encoding := 'utf-8'; + FWriter.byteOrderMark := False; + FWriter.standalone := False; + FWriter.omitXMLDeclaration := True; + FWriter.version := '1.0'; + FWriter.disableOutputEscaping := False; + end; + FStyleSheet := msxml.CoXSLTemplate60.Create; + FStylesheetAsDoc := msxml.CoFreeThreadedDOMDocument60.Create as IXMLDOMDocument2; + FStylesheetAsDoc.loadXML( sStyleSheet); + FStylesheet.stylesheet := FStylesheetAsDoc +end; + +procedure TMS_XSLT.MakeProcessor; +begin +if not assigned( FProcessor) then + begin + FProcessor := FStylesheet.createProcessor; + if assigned( FWriter) then + FProcessor.output := FWriter + end +end; + +procedure TMS_XSLT.SetInputDocumentFileName( const sValue: string); +begin +FInputFN := sValue +end; + +procedure TMS_XSLT.SetOutputDocumentFileName( const sValue: string); +begin +FOutputFN := sValue +end; + +procedure TMS_XSLT.AddParameter( const sParamBaseName, sParamValue, +sNamespaceURI: string); +begin +MakeProcessor; +FProcessor.addParameter( sParamBaseName, sParamValue, sNamespaceURI) +end; + +procedure TMS_XSLT.Transform; +const + Modes: array[ boolean] of word = (fmCreate, fmOpenReadWrite); +var + DocIntf: IXMLDocument; + XMLDOMNode: IXMLDOMNodeRef; + sOutput: string; + asOutput: UTF8String; + Mode: word; + OutStream: TStream; +begin +MakeProcessor; +try + DocIntf := TXMLDoc.FromFile( FInputFN); + if Supports( DocIntf.Node.DOMNode, IXMLDOMNodeRef, XMLDOMNode) then + FProcessor.input := XMLDOMNode.GetXMLDOMNode; + FProcessor.transform; + while FProcessor.readyState <> 4 do sleep(1); + if assigned( FWriter) then + begin + sOutput := FWriter.output; + FWriter.flush + end + else + sOutput := FProcessor.output; + if sOutput <> '' then + begin + asOutput := UTF8Encode( sOutput); + Mode := Modes[ TFile.Exists( FOutputFN)]; + OutStream := TFileStream.Create( FOutputFN, Mode); + try + if Mode = fmOpenReadWrite then + OutStream.Size := 0; + OutStream.WriteBuffer( asOutput[1], Length( asOutput) * SizeOf( +asOutput[1])) + finally + OutStream.Free + end + end +finally + FProcessor := nil + end +end; + +function MS_Transform( const sStylesheet: string; doPrettyPrint: boolean): ITransform; +begin + result := TMS_XSLT.Create( sStylesheet, doPrettyPrint) +end; + +function GetSystem32Dir: string; +begin + result := GetSpecialFolder( CSIDL_SYSTEM) +end; + +function TStyleSheet.Transform( InputDocumentFN, OutputDocumentFN: string; + var ErrorOutput: string; const WithParams: IStyleSheetParameterSet): boolean; +const + sCatNS = 'urn:oasis:names:tc:entity:xmlns:xml:catalog'; + +type + TCommandPassKind = (eRaw, eShortForm, eURI); + +var + Doc: IXMLDocument; + s: string; + nVer: double; + sMethod: string; + sErrorFN, sBatchFN, sMainFN, sOutBackup: string; + OutDoc, OutBack: TStream; + DependentSheet: TStyleSheet; + CatDoc: IXMLDocument; + sDependent: string; + nCatEntries: integer; + sPassedInput: string; + sPassedCatalog: string; + Command: string; + DefaultDir, DefaultDrive: string; + Param: IStyleSheetParameter; + Security: TSecurityAttributes; + SEInfo: TSTARTUPINFO; + peInfo: TProcessINFORMATION; + vresult: DWord; + AppName: string; + ErrorStream: TStream; + sAnsi: UTF8String; + MSXform: ITransform; + sVer: string; + ExitCode: cardinal; + didLaunch: boolean; + + function EncodeCommandLineParameter( const psRaw: string): string; + begin + if Contains( psRaw, ' ') or Contains( psRaw, '"') or Contains( psRaw, '''') then + result := '"' + ReplaceStr( psRaw, '"', '""') + '"' + else + result := psRaw + end; + + procedure AddCommandOption( const Option, URI, Local: string; LocalKind: TCommandPassKind; const Value: string=''); + // Refer: http://saxonica.com/documentation/html/using-xsl/commandline.html + var + Param: string; + PassedLocal: string; + begin + case LocalKind of + eRaw : PassedLocal := Local; + eShortForm: PassedLocal := ShortForm( Local); + eURI : PassedLocal := FilenameToUriStr( Local, [fuPlainColon]) + end; + if Option <> '' then + Param := '-' + Option + ':'; + if URI <> '' then + Param := Param + '{' + URI + '}'; + Param := Param + PassedLocal; + if Value <> '' then + Param := Param + '=' + Value; + if Command <> '' then + Command := Command + ' '; + Command := Command + EncodeCommandLineParameter( Param) + end; + + procedure AddCommandFlag( const Option: string; Value: boolean); + begin + AddCommandOption( Option, '', IfThen( Value, 'on', 'off'), eRaw); + end; + + procedure WriteStringToFile( const psContent: UTF8String; const psFileName: string); + var + OutStream: TStream; + begin + // Assume file pre-exists. + OutStream := TFile.OpenWrite( psFileName); + try + OutStream.Size := 0; + if psContent <> '' then + OutStream.WriteBuffer( psContent[1], Length( psContent) * SizeOf( psContent[1])) + finally + OutStream.Free + end + end; + +begin + Doc := TXMLDoc.FromUTF8String( ContentAsUtf8); + TXMLDoc.DeclareSelectionNamespaces( Doc, 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'); + s := (XFocus( Doc.Node) div '/*').LocalName; + result := (s = 'stylesheet') or (s = 'transform'); + if not result then + begin + ErrorOutput := 'Trying to transform using not a stylesheet.'; + exit; + end; + if (not TXPath.SelectDouble( Doc.Node, '/*/@version', nVer)) or + (nVer < 2.0) or + (not (TFile.Exists( sSaxonDir + '\Transform.exe'))) then + nVer := 1.0; + if (nVer >= 2.0) and (oSimpleXSLT1 in oOptions) then + nVer := 1.0; + + sMethod := Lowercase( TXPath.SelectedString( Doc.Node, '/*/xsl:output/@method')); + if sMethod = '' then + sMethod := 'xml'; + try + sErrorFN := NewTempFile( True); + sBatchFN := NewTempFile( True, '.bat'); + sMainFN := NewTempFile( True); + WriteStringToFile( ContentAsUtf8, sMainFN); + sPassedInput := InputDocumentFN; + if sPassedInput = '' then + sPassedInput := sMainFN; + OutDoc := nil; + OutBack := nil; + try + if TFile.Exists( OutputDocumentFN) and (nVer >= 2.0) then + begin + OutDoc := TFile.OpenRead( OutputDocumentFN); + if OutDoc.Size = 0 then + FreeAndNil( OutDoc) + end; + if Assigned( OutDoc) then + begin + sOutBackup := NewTempFile( True); + OutBack := TFile.OpenWrite( sOutBackup); + OutBack.CopyFrom( OutDoc, 0); + end + finally + OutDoc.Free; + OutBack.Free; + end; + + if nVer >= 2.0 then + begin + CatDoc := TXMLDoc.FromString( ''); + nCatEntries := 0; + for DependentSheet in Dependents( self, [eInclude, eImport]) do + begin + if DependentSheet.URI = '' then continue; + sDependent := NewTempFile( True); + WriteStringToFile( DependentSheet.ContentAsUtf8, sDependent); + with CatDoc.Node.ChildNodes[0].AddChild('uri',sCatNS) do + begin + Attributes['name'] := DependentSheet.URI; + Attributes['uri' ] := FilenameToUriStr( sDependent, [fuPlainColon]); + Inc( nCatEntries) + end; + end; + if sCatalog <> '' then + CatDoc.Node.ChildNodes[0].AddChild('nextCatalog',sCatNS).Attributes['catalog'] := FilenameToUriStr( sCatalog, [fuPlainColon]); + if nCatEntries = 0 then + CatDoc := nil; + if assigned( CatDoc) then + begin + sPassedCatalog := NewTempFile( True); + CatDoc.SaveToFile( sPassedCatalog); + CatDoc := nil + end + else if sCatalog <> '' then + sPassedCatalog := sCatalog + else + sPassedCatalog := ''; + DefaultDir := sWorkDir; + DefaultDrive := DefaultDir[1]; // 'C' + Delete( DefaultDir, 1, 2); // '\DOCUME~1\p708448\LOCALS~1\Temp' + Command := DefaultDrive + ':'#13#10 + + 'cd "' + DefaultDir + '"'#13#10 + + '"' + sSaxonDir + '\Transform.exe"'; + AddCommandOption( 'xsl', '', sMainFN, eShortForm); + AddCommandOption( 'o', '', OutputDocumentFN, eShortForm); + AddCommandOption( 's', '', sPassedInput, eShortForm); + if sPassedCatalog <> '' then + AddCommandOption( 'catalog', '', sPassedCatalog, eShortForm); + AddCommandFlag( 'expand', True); + AddCommandFlag( 'ext' , False); + AddCommandFlag( 'xi' , True); + if oAsNow in oOptions then + AddCommandOption( 'now', '', Txs_dateTime.Encode( AsNow, True, AsNowTZ_Minutes), eRaw); + if RepeatCount >= 2 then + AddCommandOption( 'repeat', '', IntToStr( RepeatCount), eRaw); + case eXMLVer of + xmlDefault: sVer := ''; + xml10 : sVer := '1.0'; + xml11 : sVer := '1.1'; + end; + if sVer <> '' then + AddCommandOption( 'xmlversion', '', sVer, eRaw); + case eXSDVer of + xsdDefault: sVer := ''; + xsd10 : sVer := '1.0'; + xsd11 : sVer := '1.1'; + end; + if sVer <> '' then + AddCommandOption( 'xsdversion', '', sVer, eRaw); + if assigned( WithParams) then + for Param in WithParams do + if not Param.isNull then + AddCommandOption( '', Param.URI, Param.ParamterName, eRaw, Param.ParameterValue); + Command := Command + ' 2>' + ShortForm( sErrorFN); + WriteStringToFile( UTF8Encode( Command), sBatchFN); + Command := '/c ' + EncodeCommandLineParameter( sBatchFN); + Security.nlength := Sizeof(TsecurityAttributes); + Security.binherithandle := True; + Security.lpsecuritydescriptor := nil; + FillChar( seInfo, Sizeof( SeInfo), 0); + SeInfo.cb := Sizeof(SeInfo); + SEInfo.dwFlags := STARTF_USESHOWWINDOW; + SEInfo.wShowWindow := SW_HIDE; + AppName := GetSystem32Dir + '\cmd.exe'; + didLaunch := CreateProcess( + PChar( AppName), PChar( Command), + @Security, @Security, + True, CREATE_SEPARATE_WOW_VDM + NORMAL_PRIORITY_CLASS, + nil, nil, seInfo, peInfo); + if result then + begin + repeat + vresult := waitForSingleObject( PeInfo.hProcess, 28800000); + until vresult = WAIT_OBJECT_0; + if not GetExitCodeProcess( PeInfo.hProcess, ExitCode) then + ExitCode := 1; + CloseHandle( peInfo.hThread); + CloseHandle( peInfo.hProcess) + end + else + ErrorOutput := 'Could not create XSL Tranform process'; + result := didLaunch and (ExitCode = 0); + if didLaunch and FileExists( sErrorFN) then + begin + ErrorStream := TFile.OpenRead( sErrorFN); + try + SetLength( sAnsi, ErrorStream.Size); + if Length( sAnsi) > 0 then + ErrorStream.Read( sAnsi[1], Length( sAnsi)) + finally + ErrorStream.Free + end; + ErrorOutput := UTF8ToString( sAnsi) + end; + if didLaunch and (not result) and (sOutBackup <> '') then + begin + // Rollback. But only if Size of OutputDocumentFN = 0 + OutBack := nil; + OutDoc := TFile.OpenWrite( OutputDocumentFN); + try + if OutDoc.Size = 0 then + begin + // Copy sOutBackup --> OutputDocumentFN + OutBack := TFile.OpenRead( sOutBackup); + OutDoc.CopyFrom( OutBack, 0); + OutBack.Free; + end + finally + OutDoc.Free; + OutBack.Free + end + end + end + else // nVer = 1.0 or 1.1 + begin + MSXform := MS_Transform( UTF8ToString( ContentAsUtf8), oPrettyPrint in oOptions); + if assigned( WithParams) then + for Param in WithParams do + if not Param.isNull then + MSXform.AddParameter( Param.ParamterName, Param.ParameterValue, Param.URI); + MSXform.InputDocumentFileName := InputDocumentFN; + MSXform.OutputDocumentFileName := OutputDocumentFN; + MSXform.Transform; + end + finally + PurgeTemporaryFiles + end +end; + + + + +constructor TStyleSheetParameterSet.Create( poStyleSheet: TStyleSheet); +begin + coStyleSheet := poStyleSheet; + coParameters := TParamDict.Create( coStyleSheet) +end; + +destructor TStyleSheetParameterSet.Destroy; +begin + coParameters.Free; + inherited +end; + +function TStyleSheetParameterSet.GetEnumerator: IEnumerator; +begin + result := TParameterCursor.Create( self) +end; + +function TStyleSheetParameterSet.Param( + const URI, Name: string): IStyleSheetParameter; +// Parameter existance is defined by the style-sheet, not by the client. +var + Key: RParamKey; +begin + Key.sURI := URI; + Key.sName := Name; + if coParameters.ContainsKey( Key) then + result := coParameters[ Key] + else + result := nil +end; + + +function TStyleSheetParameterSet.TKeyComparer.CmprEquals( + const Left, Right: RParamKey): boolean; +begin + result := (Left.sURI = Right.sURI) and (Left.sName = Right.sName) +end; + +function StringHash( const psValue: string; Init: integer = 0): integer; +begin + if psValue = '' then + result := Init + else + result := BobJenkinsHash( PChar( psValue)^, Length( psValue) * SizeOf( psValue[1]), Init) +end; + +function TStyleSheetParameterSet.TKeyComparer.CmprGetHashCode( + const Value: RParamKey): integer; +var + L: integer; +begin + result := StringHash( Value.sURI); + L := Length( Value.sURI); + result := BobJenkinsHash( L, SizeOf( L), result); + result := StringHash( Value.sName, result) +end; + + +constructor TParameter.Create( + const poParamName: RParamKey); +begin + oParamName := poParamName; + sValue := ''; + bIsNull := True +end; + +function TParameter.GetIsNull: boolean; +begin + result := bIsNull +end; + +function TParameter.GetName: string; +begin + result := oParamName.sName +end; + +function TParameter.GetURI: string; +begin + result := oParamName.sURI +end; + +function TParameter.GetValue: string; +begin + result := sValue +end; + +procedure TParameter.SetIsNull( Value: boolean); +begin + bIsNull := Value +end; + +procedure TParameter.SetValue( const Value: string); +begin + sValue := Value; + bIsNull := False +end; + + +constructor TStyleSheetParameterSet.TParamDict.Create( + poStyleSheet: TStylesheet); + +var + Dependent: TStyleSheet; + + procedure ExtractParameters( poComponentStylesheet: TStyleSheet); + var + Doc: IXMLDocument; + Node: IXMLNode; + QualifiedName: string; + Key: RParamKey; + // sSheetName: string; + begin + Doc := TXMLDoc.FromUTF8String( poComponentStylesheet.ContentAsUtf8); + TXMLDoc.DeclareSelectionNamespaces( Doc, 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'); + // sSheetName := TXPath.SelectedString( Doc.Node, '/*/xsl:variable[@name=''name'']/@select'); + for Node in XFocus( Doc.Node) / '/*/xsl:param/@name' do + begin + QualifiedName := XMLTrim(( Node.Text)); + Key.sURI := SubstringBefore( QualifiedName, ':'); + if Contains( QualifiedName, ':') then + Key.sName := SubstringAfter( QualifiedName, ':') + else + Key.sName := QualifiedName; + AddOrSetValue( Key, TParameter.Create( Key)) + end + end; + +begin + inherited Create( TKeyComparer.Create); + ExtractParameters( poStyleSheet); + for Dependent in Dependents( poStyleSheet, [eInclude]) do + ExtractParameters( Dependent); +end; + + +constructor TParameterCursor.Create( + poParamSet: TStyleSheetParameterSet); +begin + oParamSet := poParamSet; + oHold := oParamSet; + Reset +end; + +destructor TParameterCursor.Destroy; +begin + nIndex.Free; + inherited +end; + +function TParameterCursor.GetCurrent: TObject; +begin + result := nil +end; + +function TParameterCursor.GetCurrentIntf: IStyleSheetParameter; +begin + result := nIndex.Current as IStyleSheetParameter +end; + +function TParameterCursor.MoveNext: boolean; +begin + result := nIndex.MoveNext +end; + +procedure TParameterCursor.Reset; +begin + nIndex.Free; + nIndex := oParamSet.coParameters.Values.GetEnumerator +end; + +procedure TStyleSheetParameterSet.TParamDict.ValueNotify( + const Value: TParameter; + Action: Generics.Collections.TCollectionNotification); +begin + inherited; + if assigned( Value) then + case Action of + cnAdded : Value._AddRef; + cnRemoved, + cnExtracted: Value._Release; + end +end; + + +constructor TDependentStylesheets.Create( psPrimus: TStylesheet; pLinkage: TStylesheetLinkKindSet); +begin + coPrimus := psPrimus; + Linkage := pLinkage +end; + +function TDependentStylesheets.GetEnumerator: IEnumerator; +begin + result := nil +end; + +function TDependentStylesheets.GetEnumeratorIntf: IEnumerator; +begin + result := TDependenctCursor.Create( coPrimus, Linkage) +end; + + +constructor TDependentStylesheets.TDependenctCursor.Create( poPrimus: TStylesheet; pLinkage: TStylesheetLinkKindSet); +begin + Linkage := pLinkage; + coDependents := TObjectList.Create( False); + coPrimus := poPrimus; + if assigned( poPrimus) and (poPrimus.Owner is TDataModule) then + coContainer := poPrimus.Owner as TDataModule + else + coContainer := nil; + Reset +end; + +destructor TDependentStylesheets.TDependenctCursor.Destroy; +begin + coDependents.Free; + inherited +end; + +function TDependentStylesheets.TDependenctCursor.GetCurrent: TObject; +begin + result := nil +end; + +function TDependentStylesheets.TDependenctCursor.GetCurrentIntf: TStylesheet; +begin + result := coDependents[ ciIndex] as TStylesheet +end; + +function TDependentStylesheets.TDependenctCursor.MoveNext: boolean; +begin + result := ciIndex <= (coDependents.Count - 2); + if result then + Inc( ciIndex) +end; + +procedure TDependentStylesheets.TDependenctCursor.Reset; +const + LinkPaths: array[ TStylesheetLinkKind] of string = ( + {eInclude ==> } '/*/xsl:include/@href', + {eImport ==> } '/*/xsl:import/@href'); +var + sLinkPath: string; + Link: TStylesheetLinkKind; + + procedure FindDependents( Source: TStyleSheet); + var + Doc: IXMLDocument; + Node: IXMLNode; + Addend: TStyleSheet; + j: integer; + Comp: TComponent; + sURI: string; + begin + Doc := TXMLDoc.FromUTF8String( Source.ContentAsUtf8); + TXMLDoc.DeclareSelectionNamespaces( Doc, 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'); + for Node in XFocus( Doc.Node) / sLinkPath do // like '/*/xsl:include/@href | /*/xsl:import/@href' + begin + sURI := XMLTrim( Node.Text); + if sURI = '' then continue; + for j := 0 to coContainer.ComponentCount - 1 do + begin + Comp := coContainer.Components[j]; + if (not (Comp is TStyleSheet)) or (coDependents.IndexOf( Comp) <> -1) or (Comp = coPrimus) then continue; + Addend := Comp as TStyleSheet; + if Addend.URI <> sURI then continue; + coDependents.Add( Addend); + FindDependents( Addend) + end; + end; + end; +begin + sLinkPath := ''; + for Link := Low( TStylesheetLinkKind) to High( TStylesheetLinkKind) do + if Link in Linkage then + begin + if sLinkPath <> '' then + sLinkPath := sLinkPath + ' | '; + sLinkPath := sLinkPath + LinkPaths[ Link] + end; + ciIndex := -1; + coDependents.Clear; + if Linkage <> [] then + FindDependents( coPrimus) +end; + + + +class operator XSelfTransform.Explicit( + const psLiteralStyleSheet: string): XSelfTransform; +begin + result.csLiteralStyleSheet := psLiteralStyleSheet; + Result.bOk := True +end; + +class operator XSelfTransform.Add( + const This: XSelfTransform; ParamsProc: TParametersSetProc): XSelfTransform; +begin + result := This; + Result.cParamsProc := ParamsProc +end; + +class operator XSelfTransform.Multiply( + const sDocumentFileName: string; const This: XSelfTransform): XSelfTransform; +var + StyleSheet: TStyleSheet; + sError: string; + Params: IStyleSheetParameterSet; +begin + result := This; + result.bOk := True; + StyleSheet := TStyleSheet.Create( nil); + try + StyleSheet.Content.Text := result.csLiteralStyleSheet; + StyleSheet.Options := [oSimpleXSLT1, oPrettyPrint]; + StyleSheet.LoadedAtRunTime; + if assigned( result.cParamsProc) then + begin + Params := StyleSheet.Parameters; + result.cParamsProc( Params) + end; + result.bOk := StyleSheet.Transform( sDocumentFileName, sDocumentFileName, sError, Params) + finally + StyleSheet.Free + end +end; + +class operator XSelfTransform.Multiply( + const This: XSelfTransform; const sDocumentFileName: string): XSelfTransform; +begin + result := sDocumentFileName * This +end; +{$endif} + +end. diff --git a/LockBox3/unit-tests/dunit-m/run/SampleTests.pas b/LockBox3/unit-tests/dunit-m/run/SampleTests.pas new file mode 100644 index 0000000..932ba96 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/run/SampleTests.pas @@ -0,0 +1,239 @@ +unit SampleTests; +interface +uses DUnitM.UnitTestFramework, DUnitM.StringUtils, XMLIntf, + DUnitM.DDExtensions + {$ifdef MSWINDOWS} + , ADODB + {$endif} + ; + +type + +// [TestFixture] identifies and names the test fixture class. +// Use the '.' character to separate name path particles, and thus group your test fixtures. +[TestFixture('NewTests.Sprint5')] +[Description('Banana banana banana')] +TSampleThreeFixture = class + protected + Assert: IAssert; // Every test fixture class must have this data member. + + public + // The [Test] annotation identifies a test procedure. Without a [TestCase], one [TestCase] is implied. + // The boolean parameter to [Test] is the default value of its selection status in the suite of test cases. + [Test(False)] + [Description('Banana banana')] + procedure TestOne; + + // Use [TestCase] to identify one or more test cases within a test procedure. + // The first parameter to [TestCase] is the name of the test case. + // The second parameter is a space-separated list of actual parameter values to apply to the test procedure. + // Only the following paramter types are supported: + // integer + // string + // float + // boolean + // any enumerated type + // TDateTime + // Formal parameters must be pass-by-value, and string parameters must be declared with const. + // Actual DateTime literals must be presented in [TestCase] in standard xml format, as shown below. + [Test] + [TestCase('Test 2a','IntegerParam="1"')] + [TestCase('Test 2b','IntegerParam="77"')] + procedure TestTwo( IntegerParam: integer); + + [Test] + [Ignore('For some reason.')] + procedure IgnoreMe; + + [Test] + [TestCase('TripleTest - pie case','A="Blueberry pie" B="2014-01-21T14:00:00"')] + [TestCase('TripleTest - 1<2 case','A="1 is < 2" B="2014-01-21T14:00:00"')] + [Repeats(3)] + procedure DoThreeTimes( const A: string; B: TDateTime); + + [Test] + [IgnoreMemoryLeaks] + procedure Leaky; + +// // 1. Data-driven testing - general case +// [DataDrivenTest] +// [Description('Tests the StringToDate() function')] +// procedure TestLineItem( LineItemObject: TObject); +// function Navigator: IDataDrivenTestCaseNavigator; +// +// // 2. Data-driven testing using an ADO table +// {$ifdef MSWINDOWS} +// [DataDrivenTest] +// [DUnitM.DDExtensions.ADO('ADO-connection-string','TabName')] +// procedure TestIt2( DataSource: TADOTable); +// function TestIt2FileName: string; +// {$endif} +// +// // 3. Data-driven testing using a MS Excel file via ADO +// {$ifdef MSWINDOWS} +// [DataDrivenTest] +// [DUnitM.DDExtensions.Excel( 'StringToDate$' {$ifdef SUPPORTS_REGEX}, 'ConnectionStringOverrides' {$endif})] +// procedure TestIt3( DataSource: TADOTable); +// function TestIt3FileName: string; +// {$endif} +// +// // 4. Data-driven testing using a Text file +// [DataDrivenTest] +// [DUnitM.DDExtensions.TextFile] +// procedure TestIt4( const Line: string); +// function TestIt4FileName: string; +// +// // 5. Data-driven testing using an XML file +// {$ifdef MSWINDOWS} +// [DataDrivenTest] +// [DUnitM.DDExtensions.XML('m:test-data/m:test-case','xmlns:m="http://www.mlc.com.au/dunit-m/examples"')] +// procedure TestIt5( const Node: IXMLNode); +// function TestIt5FileName: string; +// {$endif} + + [Setup] procedure DenotedSetup; + [TearDown] procedure DenotedTearDown; + [FixtureSetup] constructor Create; + + destructor Destroy; override; + + published + procedure Setup; + procedure TearDown; + end; + +implementation + + + + + + + + + + + + + + + + +constructor TSampleThreeFixture.Create; +begin +end; + +procedure TSampleThreeFixture.DenotedSetup; +begin +end; + +procedure TSampleThreeFixture.DenotedTearDown; +begin +end; + +destructor TSampleThreeFixture.Destroy; +begin +inherited; +end; + +procedure TSampleThreeFixture.DoThreeTimes( const A: string; B: TDateTime); +begin // A="Blueberry pie" B="2014-01-21T14:00:00" +Assert.AreEqual( A, 'Blueberry pie') +end; + + +procedure TSampleThreeFixture.IgnoreMe; +begin +Assert.Fail('I should be ignored') +end; + +procedure TSampleThreeFixture.Leaky; +var + P: ^integer; +begin +New( P); // Deliberate leak +Assert.Pass +end; + +//function TSampleThreeFixture.Navigator: IDataDrivenTestCaseNavigator; +//begin +// // Create and return an IDataDrivenTestCaseNavigator into a cursor of an object collection. +// // These object (representing line items to test) will be passed into the previous method +// // (which in this case is procedure TestLineItem()) for testing. +//end; +// +procedure TSampleThreeFixture.Setup; +begin +end; + +procedure TSampleThreeFixture.TearDown; +begin +end; + +//procedure TSampleThreeFixture.TestIt2( DataSource: TADOTable); +//begin +// +//end; +// +//function TSampleThreeFixture.TestIt2FileName: string; +//begin +// // Return a file-name to be used in conjustion with the connection string parameter +// // of the [DUnitM.DDExtensions.ADO] attribute to specify a file-based ADO table. +// // Each row in the table is a test case, for with the previous method (TestIt2) is called. +//end; + +{$ifdef MSWINDOWS} +//procedure TSampleThreeFixture.TestIt3(DataSource: TADOTable); +//begin +// +//end; +// +//function TSampleThreeFixture.TestIt3FileName: string; +//begin +// // Return a file-name of an xlsx file. The connection string can +// // be overriden by the parameters of the [DUnitM.DDExtensions.Excel] attribute. +// // Each row in the table is a test case, for with the previous method (TestIt3) is called. +//end; +{$endif} + +//procedure TSampleThreeFixture.TestIt4( const Line: string); +//begin +// +//end; +// +//function TSampleThreeFixture.TestIt4FileName: string; +//begin +// // Return a file-name of an text file (utf-8 encoding). +// // Each line in the file is a test case, for with the previous method (TestIt4) is called. +//end; + +{$ifdef MSWINDOWS} +//procedure TSampleThreeFixture.TestIt5( const Node: IXMLNode); +//begin +// +//end; +// +//function TSampleThreeFixture.TestIt5FileName: string; +//begin +// +//end; +{$endif} + +//procedure TSampleThreeFixture.TestLineItem( LineItemObject: TObject); +//begin +// // Return a file-name of an xml file. +// // Each node in the given XPath 1.0 expression of the [DUnitM.DDExtensions.XML] attribute, +// // in the document is a test case, for with the previous method (TestIt5) is called. +//end; + +procedure TSampleThreeFixture.TestOne; +begin +Assert.IsTrue( True, 'TestOne works') +end; + +procedure TSampleThreeFixture.TestTwo( IntegerParam: integer); +begin +Assert.AreEqual( IntegerParam, 77) +end; + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_CipherTestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_CipherTestCases.pas new file mode 100644 index 0000000..5c6f3bd --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_CipherTestCases.pas @@ -0,0 +1,1312 @@ +unit uLockBox_CipherTestCases; +interface + +uses + DUnitM.UnitTestFramework, DUnitM.StringUtils, Xml.XMLIntf, + DUnitM.DDExtensions, uLockBox_TestCases, + TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.Random; + +type +TBlockSizeCase = ( + scZero, // size = 0 + scSmall, // size ~= 0.3 blocks + scUnit, // size = 1 block + scSmallish, // size = 1.5 blocks + scRough, // size = large N + about 0.1 blocks + scRound); // size = exactly N blocks. N is a large number. + +{$M+} +TBlockMode_TestCase = class( TTestCase) + protected + FLib: TCryptographicLibrary; + FCodec: TCodec; + FOriginal : TMemoryStream; + FCiphertext : TMemoryStream; + FKeyStream : TMemoryStream; + FReferenceStream : TMemoryStream; + FBlockSize: integer; + FFeatures: TAlgorithmicFeatureSet; + + procedure SetUp; virtual; + procedure TearDown; virtual; + class function CipherId: string; virtual; abstract; + procedure NormalizeKeyStream; virtual; + + procedure InversionTest( DataSize: TBlockSizeCase; const ChainMode: string); + procedure TestChainMode( const ChainMode: string); virtual; + + published + procedure Test_Reference; virtual; + end; + + +TAES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function KeySize: integer; virtual; abstract; + class function CipherId: string; override; + end; + + +[TestFixture('Block mode.AES.128')] +[Description('Tests about block mode symetric ciphers')] +TAES128_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + /// + /// This test absorbs a first-time-only small memory leak. + /// I dont know why the leak occurs. Investigations continue. + /// + [Test] + [TestCase('Inversion - ECB case','ChainMode="native.ECB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBC case','ChainMode="native.CBC"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBF case','ChainMode="native.CFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CTR case','ChainMode="native.CTR"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - OFB case','ChainMode="native.OFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CFB-8bit case','ChainMode="native.CFB-8bit"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - PCBC case','ChainMode="native.PCBC"')] [IgnoreMemoryLeaks] + procedure TestChainMode( const ChainMode: string); override; + [Test] procedure Test_Reference; override; + end; + +[TestFixture('Block mode.AES.192')] +[Description('Tests about block mode symetric ciphers')] +TAES192_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure Test_Reference; override; + [Test] + [TestCase('Inversion - ECB case','ChainMode="native.ECB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBC case','ChainMode="native.CBC"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBF case','ChainMode="native.CFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CTR case','ChainMode="native.CTR"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - OFB case','ChainMode="native.OFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CFB-8bit case','ChainMode="native.CFB-8bit"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - PCBC case','ChainMode="native.PCBC"')] [IgnoreMemoryLeaks] + procedure TestChainMode( const ChainMode: string); override; + end; + +[TestFixture('Block mode.AES.256')] +[Description('Tests about block mode symetric ciphers')] +TAES256_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure Test_Reference; override; + [Test] + [TestCase('Inversion - ECB case','ChainMode="native.ECB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBC case','ChainMode="native.CBC"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CBF case','ChainMode="native.CFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CTR case','ChainMode="native.CTR"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - OFB case','ChainMode="native.OFB"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - CFB-8bit case','ChainMode="native.CFB-8bit"')] [IgnoreMemoryLeaks] + [TestCase('Inversion - PCBC case','ChainMode="native.PCBC"')] [IgnoreMemoryLeaks] + [Repeats(10)] + procedure TestChainMode( const ChainMode: string); override; + end; + + + +TStreamModeInversion_TestCase = class( TTestCase) + protected + FLib: TCryptographicLibrary; + FCodec: TCodec; + FOriginal : TMemoryStream; + FCiphertext : TMemoryStream; + FReconstructed : TMemoryStream; + FFeatures: TAlgorithmicFeatureSet; + + procedure SetUp; virtual; + procedure TearDown; virtual; + class function CipherId: string; virtual; abstract; + class procedure TestSizeRange( var MinBytes, MaxBytes: integer); virtual; abstract; + + published + procedure GeneralInversionTest; virtual; + end; + + +[TestFixture('Stream mode')] +[Description('Tests about stream mode symetric ciphers')] +TBase64_TestCases = class( TStreamModeInversion_TestCase) + private + FKAT_Source :TStream; + + protected + class function CipherId: string; override; + class procedure TestSizeRange( var MinBytes, MaxBytes: integer); override; + + published + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + [Test] procedure GeneralInversionTest; override; + [Test] procedure Marks_KAT; + end; + + + +[TestFixture('Block mode.DES')] +TDES_TestCase = class( TTestCase) + published + [Test] procedure PC1; + [Test] procedure PC2; + [Test] procedure IP; + [Test] procedure Inverse_IP; + [Test] procedure ExpandKey; + [Test] procedure EncryptBlock; + [Test] procedure YourLipsAreSmoother; + end; + + +[TestFixture('Block mode.DES')] +TDES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + + published + [Test] procedure Test_Reference; override; + end; + +[TestFixture('Block mode.3DES')] +T3DES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + + published + [Test] procedure Test_Reference; override; + end; + +[TestFixture('Block mode.3DES.KO1')] +T3DES_KO1_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + + published + [Test] procedure Test_Reference; override; + end; + +[TestFixture('Block mode.Blowfish')] +TBlowfish_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + + published + [Test] procedure Test_Reference; override; + end; + +[TestFixture('Block mode.Twofish')] +TTwofish_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + + published + [Test] procedure Test_Reference; override; + [Test] procedure TwoFishPrimitives; + end; + + +[TestFixture('Mas.Random')] +TMasBug_TestCase = class( TTestCase) + protected + FRand: TRandomStream; + P: PByte; + Len: integer; + + public + [Setup] procedure SetUp; + [TearDown] procedure TearDown; + + published + [Test] procedure Mas_RandomStream_Bug; + end; + +implementation + + + + + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.DES, TPLB3.Constants, + TPLB3.DCP.twofish_Modified, TPLB3.Compatibility; + + + + + +const sPure_ECB_Id = 'dunit.ECB'; + +type TPure_ECB = class( TECB) + protected + function ChainingFeatures: TChainingFeatureSet; override; + function ProgId: string; override; + end; + +function TPure_ECB.ChainingFeatures: TChainingFeatureSet; +begin +result := inherited ChainingFeatures + [cfKeyStream] +// The inclusion of cfKeyStream disables block padding. +// We can only use this class in situations where be plaintext size +// is an exact multiple of the block size. +end; + +function TPure_ECB.ProgId: string; +begin +result := sPure_ECB_Id +end; + + + +procedure TBlockMode_TestCase.TestChainMode( const ChainMode: string); +var + j: TBlockSizeCase; +begin +for j := Low( TBlockSizeCase) to High( TBlockSizeCase) do + InversionTest( j, ChainMode) +end; + + + + +procedure TBlockMode_TestCase.InversionTest( + DataSize: TBlockSizeCase; const ChainMode: string); +var + TestSize, TestsCount: integer; + j: integer; + Ok: boolean; + + function RandomSizableNumber: integer; + begin + TRandomStream.Instance.Read( result, SizeOf( result)); + result := (abs( result) mod 200) + 50 + end; + +begin +FCodec.ChainModeId := ChainMode; +FCodec.Password := 'Monkey''s uncle'; +TestSize := 0; +TestsCount := 0; +case DataSize of + scZero: begin + TestSize := 0; + TestsCount := 1 + end; + + scSmall: begin + TestSize := Round( FBlockSize * 0.3); + TestsCount := 1 + end; + + scUnit: begin + TestSize := FBlockSize; + TestsCount := 1 + end; + + scSmallish: begin + TestSize := Round( FBlockSize * 1.5); + TestsCount := 10 + end; + + scRough: begin + TestSize := (RandomSizableNumber * FBlockSize) + RandomSizableNumber; + TestsCount := 100 + end; + + scRound: begin + TestSize := RandomSizableNumber * FBlockSize; + TestsCount := 10 + end; + end; +for j := 1 to TestsCount do + begin + FOriginal.Size := TestSize; + RandomFillStream( FOriginal); + FCiphertext.Size := 0; + FCodec.EncryptStream( FOriginal, FCiphertext); + FCodec.Reset; + FReferenceStream.Size := 0; + FCodec.DecryptStream( FReferenceStream, FCiphertext); + FCodec.Reset; + Ok := CompareMemoryStreams( FOriginal, FReferenceStream); + Assert.IsTrue( Ok, Format( '%s fails the general inversion test!', [FCodec.Cipher])); + if TestSize = 0 then + Assert.IsTrue( FCiphertext.Size = 0, + Format( '%s fails the zero test!', [FCodec.Cipher])); + end +end; + + +//procedure TAES128_RefTestCase.Empty; +//var +// Ciphertext: string; +//begin +//FCodec.ChainModeId := 'native.CBC'; +//FCodec.Password := 'Monkey''s uncle'; +//FCodec.EncryptString( 'abc', Ciphertext); +//Assert.Pass +//end; + + +procedure TBlockMode_TestCase.NormalizeKeyStream; +begin +end; + + +procedure TBlockMode_TestCase.SetUp; +var + Codec_TestAccess: ICodec_TestAccess; + s: utf8string; +begin +FLib := TCryptographicLibrary.Create( nil); +FLib.RegisterBlockChainingModel( TPure_ECB.Create as IBlockChainingModel); + + +FCodec := TCodec.Create( nil); +FCodec.CryptoLibrary := FLib; +FCodec.StreamCipherId := 'native.StreamToBlock'; +FCodec.BlockCipherId := CipherId; +FCodec.ChainModeId := sPure_ECB_Id; + +FOriginal := TMemoryStream.Create; +FCiphertext := TMemoryStream.Create; +FKeyStream := TMemoryStream.Create; +FReferenceStream := TMemoryStream.Create; + +if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and + (Codec_TestAccess.GetCodecIntf.BlockCipher <> nil) then + with Codec_TestAccess.GetCodecIntf.BlockCipher do + begin + FFeatures := Features; + FBlockSize := BlockSize div 8; + {$WARNINGS OFF} + Read_BigEndien_u32_Hex( SelfTest_Key , FKeyStream); + FKeyStream.Position := 0; + NormalizeKeyStream; + FKeyStream.Position := 0; + s := SelfTest_Plaintext; + Read_BigEndien_u32_Hex( s , FOriginal); + // Original MUST be an exact multiple (probably 1) of the block size. + s := SelfTest_Ciphertext; + Read_BigEndien_u32_Hex( s, FReferenceStream) + {$WARNINGS ON} + end + else + begin + FFeatures := [afNotImplementedYet]; + FBlockSize := 1 + end +end; + + + +procedure TBlockMode_TestCase.TearDown; +begin +FCodec.Free; +FLib.Free; +FOriginal.Free; +FCiphertext.Free; +FKeyStream.Free; +FReferenceStream.Free +end; + + + +procedure TBlockMode_TestCase.Test_Reference; +begin +if FOriginal.Size = 0 then exit; // Reference test not available. +Assert.IsFalse( afNotImplementedYet in FFeatures, + Format( '%s is not yet implemented!', [FCodec.Cipher])); +FKeyStream.Position := 0; +FCodec.InitFromStream( FKeyStream); +FCodec.EncryptStream( FOriginal, FCiphertext); +Assert.IsTrue( CompareMemoryStreams( FCiphertext, FReferenceStream), + Format( '%s fails the reference check!', [FCodec.Cipher])) +end; + + + +{ TAES_Reference_TestCase } + +class function TAES_Reference_TestCase.CipherId: string; +begin +result := Format( 'native.AES-%d', [KeySize]) +end; + + + +class function TAES128_RefTestCase.KeySize: integer; +begin +result := 128 +end; + +procedure TAES128_RefTestCase.SetUp; +begin + inherited; + +end; + +{ TAES192_RefTestCase } + +class function TAES192_RefTestCase.KeySize: integer; +begin +result := 192 +end; + +{ TAES256_RefTestCase } + +class function TAES256_RefTestCase.KeySize: integer; +begin +result := 256 +end; + + + +{ TStreamModeInversion_TestCase } + +procedure TStreamModeInversion_TestCase.SetUp; +var + Codec_TestAccess: ICodec_TestAccess; +begin +FLib := TCryptographicLibrary.Create( nil); +FCodec := TCodec.Create( nil); +FCodec.CryptoLibrary := FLib; +FCodec.StreamCipherId := CipherId; + +FOriginal := TMemoryStream.Create; +FCiphertext := TMemoryStream.Create; +FReconstructed := TMemoryStream.Create; + +if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and + (Codec_TestAccess.GetCodecIntf.StreamCipher <> nil) then + with Codec_TestAccess.GetCodecIntf.StreamCipher do + FFeatures := Features + else + FFeatures := [afNotImplementedYet]; +FCodec.Password := 'Fancy pants'; +end; + + + +procedure TStreamModeInversion_TestCase.TearDown; +begin +FLib.Free; +FCodec.Free; +FOriginal.Free; +FCiphertext.Free; +FReconstructed.Free +end; + + +procedure TStreamModeInversion_TestCase.GeneralInversionTest; +var + MinBytes, MaxBytes: integer; + TestSize: integer; + j: integer; + Ok: boolean; +begin +TestSizeRange( MinBytes, MaxBytes); +for j := 1 to 100 do + begin + TRandomStream.Instance.Read( TestSize, SizeOf( TestSize)); + TestSize := (abs( TestSize) mod (MaxBytes - MinBytes + 1)) + MinBytes; + FOriginal.Size := TestSize; + RandomFillStream( FOriginal); + FCiphertext.Size := 0; + FCodec.EncryptStream( FOriginal, FCiphertext); + FCodec.Reset; + FReconstructed.Size := 0; + FCodec.DecryptStream( FReconstructed, FCiphertext); + FCodec.Reset; + Ok := CompareMemoryStreams( FOriginal, FReconstructed); + Assert.IsTrue( Ok, + Format( '%s fails the general inversion test!', [FCodec.Cipher])); + Assert.IsTrue( (FCiphertext.Size >= FOriginal.Size) or + (([afCompressor,afConverter]*FFeatures) <> []), + 'Suspicious size of ciphertext.'); + if not Ok then break + end +end; + + +{ TBase64Inversion_TestCase } + +class function TBase64_TestCases.CipherId: string; +begin +result := 'native.base64' +end; + +procedure TBase64_TestCases.SetUp; +const +{$IF CompilerVersion > 19} + MarksVector: rawbytestring = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + + #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; +{$ELSE} + MarksVector: utf8string = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + + #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; +{$IFEND} +begin +inherited; +FKAT_Source := TMemoryStream.Create; +FKAT_Source.WriteBuffer( MarksVector[1], Length( MarksVector)); +FKAT_Source.Position := 0 +end; + + +procedure TBase64_TestCases.GeneralInversionTest; +begin + inherited; + +end; + +procedure TBase64_TestCases.Marks_KAT; +// Thanks to Mark for supplying this KAT. +// (Mark is user name odie34 on the lockbox forums). +begin +Assert.AreEqual( Stream_to_Base64( FKAT_Source), 'HfNxLey+A3eHHIC4W/3+isd107E=', + 'Mark''s KAT for base64 failed.'); +end; + +procedure TBase64_TestCases.TearDown; +begin +FKAT_Source.Free; +inherited +end; + +class procedure TBase64_TestCases.TestSizeRange( + var MinBytes, MaxBytes: integer); +begin +MinBytes := 0; +MaxBytes := 200 +end; + + + +{ TDES_TestCase } + +procedure TDES_TestCase.PC1; +var + K, res: uint64; +begin +//K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 (big-endien) +{$IF compilerversion <= 15} + // Delphi 7 case. +K := {}uint64( -$0E20436486A8CBED){}; // Little-endien encoding. +{$ELSE} +K := $F1DFBC9B79573413; // Little-endien encoding. +{$IFEND} + +res := PC_1( K); +//K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111 (big-endien 7-bit "rows") +// = 11110000 11001100 10101010 11110101 01010110 01100111 10001111 00000000 (little-endien 8-bit bytes) +// = F0 CC AA F5 56 67 8F 00 (big-endien) +// = +Assert.Gn.AreEqual( res, $008F6756F5AACCF0, // Little-endien encoding. + 'PC-1 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') +end; + +const +{$IF compilerversion <= 15} + // Delphi 7 case. + IP_M: uint64 = {}uint64( -$1032547698BADCFF){}; +{$ELSE} + IP_M: uint64 = $EFCDAB8967452301; +{$IFEND} + IP_L: uint32 = $FFCC00CC; + IP_R: uint32 = $AAF0AAF0; + +procedure TDES_TestCase.IP; +var + Datum: uint64; + L, R: uint32; +begin +//M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (big-endien) +Datum := IP_M; // Little-endien encoding. +IP_Transform( Datum, L, R); +//IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) +// L = 1100 1100 0000 0000 1100 1100 1111 1111 (big-endien) +// R = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) +Assert.Gn.AreEqual( L, IP_L, 'IP.L J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); +Assert.Gn.AreEqual( R, IP_R, 'IP.R J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') +end; + + + + +procedure TDES_TestCase.Inverse_IP; +var + L, R: uint32; + Datum: uint64; +begin +L := IP_L; +R := IP_R; +IP_InverseTransform( L, R, Datum); +Assert.Gn.AreEqual( Datum, IP_M, 'INV-IP J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); +end; + + +procedure TDES_TestCase.PC2; +var + L, R: uint32; + K: uint64; +const + TestMsg = 'PC-2 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'; +begin +// Test C1D1 --> K1 +// C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (big-endien, 7-bit "rows") + // C1 = 1110000110011001010101011111 (big-endien 28) + // C1 = 11100001100110010101010111110000 (big-endien 32) + // C1 = 1110 0001 | 1001 1001 | 0101 0101 | 1111 0000 (big-endien 32) + // C1 = 1111 0000 | 0101 0101 | 1001 1001 | 1110 0001 (little-endien 32) + // = $F05599E1 (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) + // D1 = 1010101011001100111100011110 (big-endien 28) + // = $E0F1CCAA (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) +L := $F05599E1; // Little-endien encoding. +R := $E0F1CCAA; // Little-endien encoding. +K := TPLB3.DES.PC_2( L, R); +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien, 6-bit "rows") +Assert.Gn.AreEqual( K, $3201073F2F0B3006, TestMsg); + +// Test C2D2 --> K2 +L := $F0AB32C3; +R := $D0E39955; +K := TPLB3.DES.PC_2( L, R); +Assert.Gn.AreEqual( K, $25273C36193B1A1E, TestMsg) +end; + + + + +procedure TDES_TestCase.YourLipsAreSmoother; +var + PlaintextStr, Recon: utf8string; + Key: uint64; + Ex: TExpandedKey; + Plaintext: uint64; + Ciphertext: uint64; + + procedure CheckOneBlock( BlockIdx: integer; Expected: uint64); + begin + Move( PlaintextStr[ BlockIdx * 8 + 1], Plaintext, 8); + TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Ex); + Assert.Gn.AreEqual( Ciphertext, Expected, + Format('Your lips are smoother than vaseline [%d]',[BlockIdx])) + end; + +begin +// Case data from preliminary example of http://orlingrabbe.com/des.htm +PlaintextStr := 'Your lips are smoother than vaseline'#13#10#0#0; +SetLength( Recon, Length( PlaintextStr)); +Key := $730D6DEA3292320E; +TPLB3.DES.ExpandKey( Key, Ex); +{$IF compilerversion <= 15} + // Delphi 7 case. +CheckOneBlock( 0, {}uint64( -$1228871C22606640){}); +CheckOneBlock( 1, {}uint64( -$117BA535F45F828E){}); +CheckOneBlock( 2, {}uint64( -$6F7EBC295B960DB9){}); +CheckOneBlock( 3, {}uint64( -$667BCA0A87D02A27){}); + // Orlan says $998435F5782FD59D + // but I think this is wrong. +CheckOneBlock( 4, {}uint64( $53E6E053B4C98A82){}); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$1228871C22606640){}, Plaintext, Ex); +Move( Plaintext, Recon[1], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$117BA535F45F828E){}, Plaintext, Ex); +Move( Plaintext, Recon[9], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$6F7EBC295B960DB9){}, Plaintext, Ex); +Move( Plaintext, Recon[17], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$667BCA0A87D02A27){}, Plaintext, Ex); +Move( Plaintext, Recon[25], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( $53E6E053B4C98A82){}, Plaintext, Ex); + +{$ELSE} +CheckOneBlock( 0, $EDD778E3DD9F99C0); +CheckOneBlock( 1, $EE845ACA0BA07D72); +CheckOneBlock( 2, $908143D6A469F247); +CheckOneBlock( 3, $998435F5782FD5D9); // Orlan says $998435F5782FD59D + // but I think this is wrong. +CheckOneBlock( 4, $53E6E053B4C98A82); +TPLB3.DES.DES_DecryptBlock( $EDD778E3DD9F99C0, Plaintext, Ex); +Move( Plaintext, Recon[1], 8); +TPLB3.DES.DES_DecryptBlock( $EE845ACA0BA07D72, Plaintext, Ex); +Move( Plaintext, Recon[9], 8); +TPLB3.DES.DES_DecryptBlock( $908143D6A469F247, Plaintext, Ex); +Move( Plaintext, Recon[17], 8); +TPLB3.DES.DES_DecryptBlock( $998435F5782FD5D9, Plaintext, Ex); +Move( Plaintext, Recon[25], 8); +TPLB3.DES.DES_DecryptBlock( $53E6E053B4C98A82, Plaintext, Ex); +{$IFEND} + +Move( Plaintext, Recon[33], 8); +SetLength( Recon, 38); +Assert.AreEqual( Recon, 'Your lips are smoother than vaseline'#13#10, + 'Inverse: Your lips are smoother than vaseline') +end; + + + +procedure TDES_TestCase.EncryptBlock; +var + Plaintext: uint64; + Ciphertext: uint64; + Key: TExpandedKey; +begin +// M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 +Plaintext := IP_M; +Key[ 0] := $3201073F2F0B3006; +Key[ 1] := $25273C36193B1A1E; +Key[ 2] := $193E2C100A321F15; +Key[ 3] := $1D14333616372A1C; +Key[ 4] := $280E353A07300E1F; +Key[ 5] := $2F2C07143E143A18; +Key[ 6] := $3C22213D3712083B; +Key[ 7] := $3B2F13303A28383D; +Key[ 8] := $011E1E3B2B2F0D38; +Key[ 9] := $0F19242E070D1F2C; +Key[10] := $060E2D37133F1508; +Key[11] := $291F06253507171D; +Key[12] := $01292B3E11173C25; +Key[13] := $3A1C2E3C370E3417; +Key[14] := $0A3C130F0D06392F; +Key[15] := $351F21030B363332; +TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Key); +Assert.Gn.AreEqual( Ciphertext, $05B40A0F5413E885, 'DES_EncryptBlock'); +TPLB3.DES.DES_DecryptBlock( Ciphertext, Plaintext, Key); +Assert.Gn.AreEqual( Plaintext, IP_M, 'DES_DecryptBlock'); +end; + + +procedure TDES_TestCase.ExpandKey; +var + Key: uint64; + Ex: TExpandedKey; + R: uint32; + E: uint64; + + procedure CheckI( Idx: integer; Expected: uint64); + begin + Assert.Gn.AreEqual( Ex[ Idx], Expected, + Format( 'DES ExpandKey[%d]; Should have be' + + 'en $%x, but got $%x',[ Idx, Expected, Ex[ Idx]])) + end; + +begin +R := $AAF0AAF0; +E := E_Bit_Selection( R); + +{$IF compilerversion <= 15} + // Delphi 7 case. +Check( E = {}uint64( $1515211E1515211E){}, 'E-Bit'); +Key := {}uint64( -$0E20436486A8CBED){}; +uTPLb_DES.ExpandKey( Key, Ex); + +// Done: +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) +CheckI( 0, {}uint64( $3201073F2F0B3006){}); +// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) +CheckI( 1, {}uint64( $25273C36193B1A1E){}); +// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 +CheckI( 2, {}uint64( $193E2C100A321F15){}); +// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 +CheckI( 3, {}uint64( $1D14333616372A1C){}); +// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 +CheckI( 4, {}uint64( $280E353A07300E1F){}); +// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 +CheckI( 5, {}uint64( $2F2C07143E143A18){}); +// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 +CheckI( 6, {}uint64( $3C22213D3712083B){}); +// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 +CheckI( 7, {}uint64( $3B2F13303A28383D){}); +// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 +CheckI( 8, {}uint64( $011E1E3B2B2F0D38){}); +// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 +CheckI( 9, {}uint64( $0F19242E070D1F2C){}); +// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 +CheckI( 10, {}uint64( $060E2D37133F1508){}); +// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 +CheckI( 11, {}uint64( $291F06253507171D){}); +// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 +CheckI( 12, {}uint64( $01292B3E11173C25){}); +// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 +CheckI( 13, {}uint64( $3A1C2E3C370E3417){}); +// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 +CheckI( 14, {}uint64( $0A3C130F0D06392F){}); +// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 +CheckI( 15, {}uint64( $351F21030B363332){}) + +{$ELSE} +Assert.Gn.AreEqual( E, $1515211E1515211E, 'E-Bit'); +Key := $F1DFBC9B79573413; +TPLB3.DES.ExpandKey( Key, Ex); + +// Done: +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) +CheckI( 0, $3201073F2F0B3006); +// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) +CheckI( 1, $25273C36193B1A1E); +// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 +CheckI( 2, $193E2C100A321F15); +// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 +CheckI( 3, $1D14333616372A1C); +// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 +CheckI( 4, $280E353A07300E1F); +// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 +CheckI( 5, $2F2C07143E143A18); +// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 +CheckI( 6, $3C22213D3712083B); +// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 +CheckI( 7, $3B2F13303A28383D); +// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 +CheckI( 8, $011E1E3B2B2F0D38); +// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 +CheckI( 9, $0F19242E070D1F2C); +// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 +CheckI( 10, $060E2D37133F1508); +// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 +CheckI( 11, $291F06253507171D); +// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 +CheckI( 12, $01292B3E11173C25); +// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 +CheckI( 13, $3A1C2E3C370E3417); +// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 +CheckI( 14, $0A3C130F0D06392F); +// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 +CheckI( 15, $351F21030B363332) +{$IFEND} +end; + + + + +{ TDES_Reference_TestCase } + +class function TDES_Reference_TestCase.CipherId: string; +begin +result := DES_ProgId +end; + +procedure TDES_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; +begin +FKeyStream.Read( NativeKey, 8); +FKeyStream.Position := 0; +SetParityBitsOnKey( NativeKey); +FKeyStream.Write( NativeKey, 8) +end; + + +procedure TDES_Reference_TestCase.SetUp; +begin + inherited; + +end; + +procedure TDES_Reference_TestCase.TearDown; +begin + inherited; + +end; + +procedure TDES_Reference_TestCase.Test_Reference; +begin + inherited; + +end; + + + +class function T3DES_Reference_TestCase.CipherId: string; +begin +result := TripleDES_ProgId +end; + + + +class function TBlowfish_Reference_TestCase.CipherId: string; +begin +result := Blowfish_ProgId +end; + + +class function TTwofish_Reference_TestCase.CipherId: string; +begin +result := Twofish_ProgId +end; + + + +procedure TTwofish_Reference_TestCase.SetUp; +begin + inherited; + +end; + +procedure TTwofish_Reference_TestCase.TearDown; +begin + inherited; + +end; + +procedure TTwofish_Reference_TestCase.Test_Reference; +begin + inherited; + +end; + +procedure TTwofish_Reference_TestCase.TwoFishPrimitives; +var + Key: TBytes; + Size: longword; + SubKeys: TSubKeys; + SBox: TSBox; + InData, OutData, RefOutData: T128; + I: integer; +begin +DCP_towfish_Precomp; +// This data from http://www.schneier.com/code/ecb_ival.txt +//KEYSIZE=128 +Size := 16; +SetLength( Key, Size); + +RefOutData[0] := $5C9F589F; // at I=1, CT=9F589F5CF6122C32B6BFEC2F2AE8C35A +RefOutData[1] := $322C12F6; +RefOutData[2] := $2FECBFB6; +RefOutData[3] := $5AC3E82A; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + if I = 1 then + Assert.AreEqualMemory( @OutData, @RefOutData, SizeOf( T128), + 'LockBox TwoFish primitives failed the 128 reference test at I=1. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + end; + +RefOutData[0] := $EF4E9D5D; // at I=49, CT=5D9D4EEFFA9151575524F115815A12E0 +RefOutData[1] := $575191FA; +RefOutData[2] := $15F12455; +RefOutData[3] := $E0125A81; + +Assert.AreEqualMemory( @OutData, @RefOutData, SizeOf( T128), + 'LockBox TwoFish primitives failed the 128 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + + +//KEYSIZE=192 +//I=1 +//KEY=000000000000000000000000000000000000000000000000 +//PT=00000000000000000000000000000000 +//I=49 +//CT=E75449212BEEF9F4A390BD860A640941 +Size := 24; +SetLength( Key, Size); + +RefOutData[0] := $214954E7; // at I=49, CT=E75449212BEEF9F4A390BD860A640941 +RefOutData[1] := $F4F9EE2B; +RefOutData[2] := $86BD90A3; +RefOutData[3] := $4109640A; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( Key[0] , Key[16], Size-16); + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + end; +Assert.AreEqualMemory( @OutData, @RefOutData, SizeOf( T128), + 'LockBox TwoFish primitives failed the 192 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + +//KEYSIZE=256 +//I=1 +//KEY=0000000000000000000000000000000000000000000000000000000000000000 +//PT=00000000000000000000000000000000 +//I=49 +//CT=37FE26FF1CF66175F5DDF4C33B97A205 +Size := 32; +SetLength( Key, Size); + +RefOutData[0] := $FF26FE37; // at I=49, CT=37FE26FF1CF66175F5DDF4C33B97A205 +RefOutData[1] := $7561F61C; +RefOutData[2] := $C3F4DDF5; +RefOutData[3] := $05A2973B; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( Key[0] , Key[16], Size-16); + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + end; +Assert.AreEqualMemory( @OutData, @RefOutData, SizeOf( T128), + 'LockBox TwoFish primitives failed the 256 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + +end; + + + + +{ T3DES_KO1_Reference_TestCase } + +class function T3DES_KO1_Reference_TestCase.CipherId: string; +begin +result := TripleDES_KO1_ProgId +end; + + +procedure T3DES_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; + SubKey: integer; +begin +for SubKey := 1 to 2 do + begin + FKeyStream.Position := (SubKey - 1) * 8; + if FKeyStream.Read( NativeKey, 8) < 8 then break; + FKeyStream.Position := (SubKey - 1) * 8; + SetParityBitsOnKey( NativeKey); + FKeyStream.Write( NativeKey, 8) + end +end; + + +procedure T3DES_Reference_TestCase.SetUp; +begin + inherited; + +end; + +procedure T3DES_Reference_TestCase.TearDown; +begin + inherited; + +end; + +procedure T3DES_Reference_TestCase.Test_Reference; +begin + inherited; + +end; + +procedure T3DES_KO1_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; + SubKey: integer; +begin +for SubKey := 1 to 3 do + begin + FKeyStream.Position := (SubKey - 1) * 8; + if FKeyStream.Read( NativeKey, 8) < 8 then break; + FKeyStream.Position := (SubKey - 1) * 8; + SetParityBitsOnKey( NativeKey); + FKeyStream.Write( NativeKey, 8) + end +end; + + +procedure T3DES_KO1_Reference_TestCase.SetUp; +begin + inherited; + +end; + +procedure T3DES_KO1_Reference_TestCase.TearDown; +begin + inherited; + +end; + +procedure T3DES_KO1_Reference_TestCase.Test_Reference; +begin + inherited; + +end; + + +{ TMasBug_TestCase } + +procedure TMasBug_TestCase.SetUp; +begin +FRand := TRandomStream.Instance ; +Len := 32; +GetMem( P, Len); +end; + +procedure TMasBug_TestCase.TearDown; +begin +FreeMem( P, Len) +end; + + + +procedure TMasBug_TestCase.Mas_RandomStream_Bug; +var + j: Integer; + PreviousFirstByte: byte; + CollisionCount: integer; +begin +FRand.Randomize; +CollisionCount := 0; +PreviousFirstByte := 0; +for j := 1 to 20 do + begin + FRand.Read( P^, Len); + if (j >= 2) and (PreviousFirstByte = P^) then + Inc( CollisionCount); + PreviousFirstByte := P^ + end; +Assert.IsTrue ( CollisionCount < 4, 'Random number generator is suspect.') +end; + + + + +procedure TAES128_RefTestCase.TearDown; +begin + inherited; + +end; + +procedure TAES128_RefTestCase.TestChainMode(const ChainMode: string); +begin + inherited; +end; + +procedure TAES128_RefTestCase.Test_Reference; +begin + inherited; + +end; + +{ TAES192_RefTestCase } + + +procedure TAES192_RefTestCase.SetUp; +begin + inherited; + +end; + +procedure TAES192_RefTestCase.TearDown; +begin + inherited; + +end; + +procedure TAES192_RefTestCase.TestChainMode(const ChainMode: string); +begin + inherited; + +end; + +procedure TAES192_RefTestCase.Test_Reference; +begin + inherited; + +end; + +{ TAES256_RefTestCase } + + +procedure TAES256_RefTestCase.SetUp; +begin + inherited; + +end; + +procedure TAES256_RefTestCase.TearDown; +begin + inherited; + +end; + +procedure TAES256_RefTestCase.TestChainMode(const ChainMode: string); +begin + inherited; + +end; + +procedure TAES256_RefTestCase.Test_Reference; +begin + inherited; + +end; + + + +procedure TBlowfish_Reference_TestCase.SetUp; +begin + inherited; + +end; + +procedure TBlowfish_Reference_TestCase.TearDown; +begin + inherited; + +end; + +procedure TBlowfish_Reference_TestCase.Test_Reference; +begin + inherited; + +end; + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Hashes.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Hashes.pas new file mode 100644 index 0000000..26e2223 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Hashes.pas @@ -0,0 +1,435 @@ +unit uLockBox_Hashes; +interface +uses DUnitM.UnitTestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.MemoryStreamPool, uLockBox_TestCases; + +type + +{$M+} +THash_TestCase = class( TTestCase) + protected + FHash: THash; + FLib: TCryptographicLibrary; + FReferenceTestSource: utf8string; + FReferenceTestRefrnc: utf8string; + FSource: TMemoryStream; + FRefValue: TMemoryStream; + FTestValue: TMemoryStream; + + procedure SetUp; virtual; + procedure TearDown; virtual; + class function HashId: string; virtual; abstract; + + published + procedure ReferenceTestVectors; virtual; + end; + + + +[TestFixture('Hashes.SHA1')] +TSHA1_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + end; + + +[TestFixture('Hashes.MD5')] +TMD5_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [IgnoreMemoryLeaks] + [Test] procedure ReferenceTestVectors; override; + end; + + + + +[TestFixture('Hashes.SHA256')] +TSHA256_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + [Test] procedure ExtraReferenceTests; + end; + + +[TestFixture('Hashes.SHA224')] +TSHA224_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + [Test] procedure ExtraReferenceTests; + end; + + +[TestFixture('Hashes.SHA512')] +TSHA512_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + [Test] procedure ExtraReferenceTests; + end; + +[TestFixture('Hashes.SHA384')] +TSHA384_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + end; + +[TestFixture('Hashes.SHA512.224')] +TSHA512_224_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + end; + +[TestFixture('Hashes.SHA512.256')] +TSHA512_256_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + public + [Setup] procedure SetUp; override; + [TearDown] procedure TearDown; override; + published + [Test] procedure ReferenceTestVectors; override; + end; + + + +implementation + + + + + + + + + +uses TPLB3.SHA2, TPLB3.Constants, TPLB3.BinaryUtils, TPLB3.HashDsc, + SysUtils, TPLB3.StreamUtils; + + +{ THash_TestCase } + +procedure THash_TestCase.SetUp; +var + TestAccess: IHash_TestAccess; + Hasher: IHasher; +begin +FLib := TCryptographicLibrary.Create( nil); +FHash := THash.Create( nil); +FHash.CryptoLibrary := FLib; +FHash.HashId := HashId; +FHash.Begin_Hash; +if Supports( FHash, IHash_TestAccess, TestAccess) then + Hasher := TestAccess.GetHasher; +FHash.End_Hash; +if assigned( Hasher) then + begin + FReferenceTestSource := Hasher.SelfTest_Source; + FReferenceTestRefrnc := Hasher.SelfTest_ReferenceHashValue + end; +FSource := TMemoryStream.Create; +FRefValue := TMemoryStream.Create; +FTestValue := TMemoryStream.Create +end; + + +//function MyEncodeUTF8( const ValueUTF16LE: string) : utf8string; +//var +// B: TBytes; +//begin +// B := TEncoding.UTF8.GetBytes( ValueUTF16LE); +// result := TEncoding.UTF8.GetString( B) +//end; + + +procedure THash_TestCase.TearDown; +begin +FHash.Free; +FLib.Free; +FSource.Free; +FRefValue.Free; +FTestValue.Free; +FReferenceTestSource := ''; +FReferenceTestRefrnc := '' +end; + + + +procedure THash_TestCase.ReferenceTestVectors; +begin +FSource.Write( FReferenceTestSource[low( FReferenceTestSource)], Length( FReferenceTestSource) * SizeOf( AnsiChar)); +{$WARNINGS OFF} +Read_BigEndien_u32_Hex( FReferenceTestRefrnc, FRefValue); +{$WARNINGS ON} +FHash.HashStream( FSource); +FTestValue.CopyFrom( FHash.HashOutputValue, 0); +FHash.Burn; +Assert.IsTrue( CompareMemoryStreams( FRefValue, FTestValue), Format( + 'Hash %s failed it''s standard reference test.',[FHash.Hash])) +end; + + +procedure TSHA256_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; +FReferenceTestRefrnc := '248D6A61 D20638B8 ' + + 'E5C02693 0C3E6039 A33CE459 64FF2167 F6ECEDD4 19DB06C1'; +ReferenceTestVectors +end; + + +procedure TSHA224_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; +FReferenceTestRefrnc := '75388B16 512776CC 5DBA5DA1 FD890150 B0C6455C B4F58B19 52522525'; +ReferenceTestVectors +end; + + + + +class function TMD5_TestCase.HashId: string; +begin +result := 'native.hash.MD5' +end; + + + + + +procedure TMD5_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TMD5_TestCase.SetUp; +begin + inherited; + +end; + +procedure TMD5_TestCase.TearDown; +begin + inherited; + +end; + +{ TSHA1_TestCase } + +class function TSHA1_TestCase.HashId: string; +begin +result := 'native.hash.SHA-1' +end; + +// Test vectors from +// http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA256.pdf + +{ TSHA2_TestCase } + +class function TSHA256_TestCase.HashId: string; +begin +result := SHA256_ProgId +end; + +procedure TSHA256_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA256_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA256_TestCase.TearDown; +begin + inherited; + +end; + +class function TSHA224_TestCase.HashId: string; +begin +result := SHA224_ProgId +end; + + +procedure TSHA224_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA224_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA224_TestCase.TearDown; +begin + inherited; + +end; + +procedure TSHA512_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijk' + + 'lmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'; +FReferenceTestRefrnc := '8E959B75 DAE313DA 8CF4F728 14FC143F ' + + '8F7779C6 EB9F7FA1 7299AEAD B6889018 501D289E 4900F7E4 ' + + '331B99DE C4B5433A C7D329EE B6DD2654 5E96E55B 874BE909'; +ReferenceTestVectors +end; + +class function TSHA512_TestCase.HashId: string; +begin +result := SHA512_ProgId +end; + + +procedure TSHA512_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA512_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA512_TestCase.TearDown; +begin + inherited; + +end; + +class function TSHA384_TestCase.HashId: string; +begin +result := SHA384_ProgId +end; + + +class function TSHA512_224_TestCase.HashId: string; +begin +result := SHA512_224_ProgId +end; + +class function TSHA512_256_TestCase.HashId: string; +begin +result := SHA512_256_ProgId +end; + + +procedure TSHA1_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA1_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA1_TestCase.TearDown; +begin + inherited; + +end; + +procedure TSHA384_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA384_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA384_TestCase.TearDown; +begin + inherited; + +end; + +procedure TSHA512_224_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA512_224_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA512_224_TestCase.TearDown; +begin + inherited; + +end; + +procedure TSHA512_256_TestCase.ReferenceTestVectors; +begin + inherited; + +end; + +procedure TSHA512_256_TestCase.SetUp; +begin + inherited; + +end; + +procedure TSHA512_256_TestCase.TearDown; +begin + inherited; + +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_HugeCardinalTestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_HugeCardinalTestCases.pas new file mode 100644 index 0000000..94ad7a2 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_HugeCardinalTestCases.pas @@ -0,0 +1,605 @@ +unit uLockBox_HugeCardinalTestCases; +interface +uses DUnitM.UnitTestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, uLockBox_TestCases, + TPLB3.MemoryStreamPool; + + +type +{$M+} +[TestFixture('HugeCardinal')] +THugeCardinal_TestCase = class( TTestCase) + public + Fbig1234: THugeCardinal; + Fbig2313: THugeCardinal; + Fbig3547: THugeCardinal; + Temp1, Temp2, Temp3, Temp4: THugeCardinal; + Temp2000_1: THugeCardinal; + Temp2000_2: THugeCardinal; + T3, F100: THugeCardinal; + TmpStream: TMemoryStream; + + [Setup] procedure SetUp; + [TearDown] procedure TearDown; + + published + [Test] procedure Test_CreateZero; + [Test] procedure CreateRandom; + [Test] procedure CreateSmall; + [Test] procedure Test_Clone; + [Test] procedure Test_Assign; + [Test] procedure Test_Zeroise; + [Test] procedure Test_CompareSmall; + [Test] procedure Test_Compare; + [Test] procedure Test_AssignSmall; + [Test] procedure Test_BitLength; + [Test] procedure Test_MaxBits; + [Test] procedure Test_Add; + [Test] procedure Test_Increment; + [Test] procedure Test_Subtract; + [Test] procedure Test_MulPower2; + [Test] procedure Test_MulSmall; + [Test] procedure Test_Multiply; + [Test] procedure Test_Modulo; + [Test] procedure Test_AddMod; + [Test] procedure Test_MultiplyMod; + [Test] procedure Test_isOdd; + [Test] procedure Test_CreateFromStreamIn; + [Test] procedure Test_CloneSized; + [Test] procedure Test_Resize; + [Test] procedure Test_AssignFromStreamIn; + [Test] procedure Test_Swap; + [Test] procedure Test_ExtactSmall; + [Test] procedure Test_StreamOut; + [Test] procedure Test_PowerMod; + [Test] procedure Test_SmallExponent_PowerMod; + end; + +implementation + + + + + + + +uses SysUtils; + + + + + +procedure THugeCardinal_TestCase.SetUp; +var + j: integer; +begin +Temp1 := THugeCardinal.CreateSmall( 1234, 100, nil); +Temp2 := THugeCardinal.CreateSmall( 10000, 100, nil); +Temp3 := THugeCardinal.CreateSmall( 2313, 100, nil); +Temp4 := THugeCardinal.CreateSmall( 3547, 100, nil); +Fbig1234 := THugeCardinal.CreateZero( 2000, nil); +Fbig2313 := THugeCardinal.CreateZero( 2000, nil); +Fbig3547 := THugeCardinal.CreateZero( 2000, nil); +Temp2000_1 := THugeCardinal.CreateZero( 2000, nil); +Temp2000_2 := THugeCardinal.CreateZero( 2000, nil); +for j := 1 to 16 do + begin + T3 := Fbig1234.Multiply( Temp2); + FBig1234.Assign( T3); + FreeAndNil( T3); + Fbig1234.Add ( Temp1); + + T3 := Fbig2313.Multiply( Temp2); + Fbig2313.Assign( T3); + FreeAndNil( T3); + Fbig2313.Add ( Temp3); + + T3 := Fbig3547.Multiply( Temp2); + Fbig3547.Assign( T3); + FreeAndNil( T3); + Fbig3547.Add ( Temp4); + end; +F100 := THugeCardinal.CreateSmall( 100, 100, nil); +TmpStream := TMemoryStream.Create; +end; + + + +procedure THugeCardinal_TestCase.TearDown; +begin +FreeAndNil( Temp1); +FreeAndNil( Temp2); +FreeAndNil( Temp2000_1); +FreeAndNil( Temp2000_2); +FreeAndNil( FBig1234); +FreeAndNil( Fbig2313); +FreeAndNil( Fbig3547); +FreeAndNil( Temp3); +FreeAndNil( Temp4); +FreeAndNil( T3); +FreeAndNil( F100); +FreeAndNil( TmpStream) +end; + + + + +procedure THugeCardinal_TestCase.CreateRandom; +var + Rand: THugeCardinal; +begin +// Create a big random and make sure bits is not more than the specified length. +Rand := THugeCardinal.CreateRandom( 201, 300, False, nil); +try + Assert.IsTrue( (Rand.BitLength <= 201) and + (Rand.BitLength >= 100), 'HugeCardinal Create Random failed.') +finally +Rand.Free +end end; + + + +procedure THugeCardinal_TestCase.CreateSmall; +begin +// Create 100 and check it is 100 +Assert.IsTrue( F100.isSmall and (F100.ExtractSmall = 100), + 'HugeCardinal CreateSmall failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Add; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 + +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +//3547354735473547354735473547354735473547354735473547354735473547 +//Construct these numbers by lots of small adds and multiplies (by 10). +Temp2000_1.Assign( Fbig1234); +Temp2000_1.Add( Fbig2313); +Assert.IsTrue( Temp2000_1.Compare( Fbig3547) = rEqualTo, 'HugeCardinal addition failed.') +end; + + +procedure THugeCardinal_TestCase.Test_AddMod; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 + +//2313231323132313231323132313231323132313231323132313231323132313 mod +// 100 = +//---------------------------------------------------------------- +// 47 +Temp2000_1.Assign( Fbig1234); +Temp2000_1.AddMod( Fbig2313, F100); +Assert.IsTrue( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 47), + 'HugeCardinal AddMod failed.') +end; + + +procedure THugeCardinal_TestCase.Test_Assign; +begin +// Start with a big random y. +// x := y +// check x = y +Temp2000_1.Assign( FBig1234); +Assert.IsTrue( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'Huge Cardinal Assign failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_AssignFromStreamIn; +begin +// Manually stream out x. +// Stream it back in. +// Check it is the same a sthe original +TmpStream.Clear; +FBig1234.StreamOut( LittleEndien, TmpStream); +FreeAndNil( Temp2000_1); +TmpStream.Position := 0; +Temp2000_1 := THugeCardinal.CreateFromStreamIn( FBig1234.MaxBits, LittleEndien, TmpStream, nil); +FreeAndNil( TmpStream); +Assert.IsTrue( Temp2000_1.Compare( Fbig1234) = rEqualTo, 'HugeCardinal AssignFromStreamIn failed.') +end; + + +procedure THugeCardinal_TestCase.Test_AssignSmall; +begin +// x := 10000; +// check x = 10000 +Temp2000_1.AssignSmall( 10000); +Assert.IsTrue( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 10000), + 'HugeCardinal AssignSmall failed.') +end; + + +procedure THugeCardinal_TestCase.Test_BitLength; +var + bl: integer; +begin +// check zero. bitlength = 0 +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// check (x shl 1).BL = x.BL + 1 +// manually count bits in x by shl -1 for maxbits. +// check manual count = original BitLength property. +Temp2000_1.Zeroise; +Assert.IsTrue( Temp2000_1.BitLength = 0, 'BitLength 0 failed.'); +bl := FBig1234.BitLength; +FBig1234.MulPower2( 1); +Assert.IsTrue( (FBig1234.BitLength) - bl = 1, 'BitLength failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Clone; +begin +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// y := clone x; +// check x = y +// check x.maxbits = y.maxbits +FreeAndNil( Temp2000_1); +Temp2000_1 := FBig1234.Clone; +Assert.IsTrue( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.Clone failed.'); +Assert.IsTrue( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.Clone failed.'); +Assert.IsTrue( Temp2000_1.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal.Clone failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CloneSized; +begin +// x := clone y, but with a different size. +// check x = y +// check size x is corrrect. +FreeAndNil( Temp2000_1); +Temp2000_1 := FBig1234.CloneSized( 3999); +Assert.IsTrue( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.CloneSized failed.'); +Assert.IsTrue( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.CloneSized failed.'); +Assert.IsTrue( Temp2000_1.MaxBits = 4000, 'THugeCardinal.CloneSized failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Compare; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 compare to +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +// less than. + +//Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 compare to +//1234123412341234123412341234123412341234123412341234123412341234 = +//---------------------------------------------------------------- +// greater than. + +//Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 compare to +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +// equals. +Assert.IsTrue( FBig2313.Compare( FBig1234) = rGreaterThan, 'THugeCardinal.Compare failed.'); +Assert.IsTrue( FBig1234.Compare( FBig2313) = rLessThan , 'THugeCardinal.Compare failed.'); +Assert.IsTrue( FBig2313.Compare( FBig2313) = rEqualTo , 'THugeCardinal.Compare failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CompareSmall; +begin +// x := 999 +// compare x = 999 +// compare x = 665 +Temp2000_1.AssignSmall( 999); +Assert.IsTrue( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 999), 'THugeCardinal.CompareSmall failed.'); +Assert.IsTrue( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall <> 665), 'THugeCardinal.CompareSmall failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CreateZero; +begin +// x := 0 +// compare x = 0 +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 10, nil); +Assert.IsTrue( Temp2000_1.isZero, 'THugeCardinal.CreateZero failed.'); +end; + +procedure THugeCardinal_TestCase.Test_ExtactSmall; +begin +// x is big. +// y := x + 44 - x +// check y = 44 +Temp2000_1.Assign( FBig1234); +Temp2000_1.Increment( 44); +Temp2000_1.Subtract( FBig1234); +Assert.IsTrue( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 44), + 'THugeCardinal.ExtactSmall/isSmall failed.') +end; + +procedure THugeCardinal_TestCase.Test_Increment; +var + v: uint64; +begin +//Check that ... +// $FFFFFFFFFFFFFFFFFF + // 8 bytes of $FF +// 1 = +//--------------------- +//$1000000000000000000 // 9 bytes +int64rec( v).Lo := $FFFFFFFF; +int64rec( v).Hi := $FFFFFFFF; +Temp2000_1.AssignSmall( v); +Temp2000_1.Increment( 1); +Temp2000_2.AssignSmall( 1); +Temp2000_2.MulPower2( 64); +Assert.IsTrue( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal Increment failed.') +end; + + +procedure THugeCardinal_TestCase.Test_isOdd; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 is even. + +// Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 is odd. + +// Check that 0 is even. +Assert.IsTrue( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +FBig1234.Increment( -1); +Assert.IsTrue( FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +FBig1234.Zeroise; +Assert.IsTrue( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_MaxBits; +begin +// create x with 5 bits. +// check x.maxbits = 64 +// create x with 100 bits. +// check x.maxbits = 104 +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 5, nil); +Assert.IsTrue( Temp2000_1.MaxBits = 64, 'MaxBits failed.'); +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 100, nil); +Assert.IsTrue( Temp2000_1.MaxBits = 104, 'MaxBits failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Modulo; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 mod +// 1000 = +//---------------------------------------------------------------- +// 234 +Temp2000_1.Assign( FBig1234); +Temp2000_2.AssignSmall( 1000); +FreeAndNil( T3); +T3 := Temp2000_1.Modulo( Temp2000_2); +Assert.IsTrue( T3.isSmall and (T3.ExtractSmall = 234), + 'THugeCardinal Modulo failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_MulPower2; +var + v: uint64; + s: string; + Method: boolean; +begin +for Method := False to True do + begin + doUseMulPower2_NewAlgorithm := Method; + + // Check that x + x = x shl 1 + // Check that x shl 88 shl -88 = x + Temp2000_1.Assign( FBig1234); + Temp2000_1.Add ( FBig1234); + Temp2000_2.Assign( FBig1234); + Temp2000_2.MulPower2( 1); +Assert.IsTrue( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 1.'); + + Temp2000_1.Assign( FBig1234); + Temp2000_1.MulPower2( 88); + Temp2000_1.MulPower2( -88); + Assert.IsTrue( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 1.'); + + int64rec( v).Lo := $FFFFFFFF; + int64rec( v).Hi := $0000FFFF; + Temp2000_1.AssignSmall( v); + Temp2000_2.AssignSmall( v); + Temp2000_2.MulPower2( 5); + s := Format( '%x', [Temp2000_2.ExtractSmall]); + Temp2000_1.MulPower2( 8); + s := Format( '%x', [Temp2000_1.ExtractSmall]); + Temp2000_1.MulPower2( -3); + s := Format( '%x', [Temp2000_1.ExtractSmall]); + Assert.IsTrue( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 3.') + end +end; + + + +procedure THugeCardinal_TestCase.Test_MulSmall; +begin +// check that x + x + x = 3 * x +Temp2000_1.Assign( FBig1234); +Temp2000_1.Add ( FBig1234); +Temp2000_1.Add ( FBig1234); +Temp2000_2.Assign( FBig1234); +Temp2000_2.MulSmall( 3); +Assert.IsTrue( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulSmall failed.'); +end; + +procedure THugeCardinal_TestCase.Test_Subtract; +begin +// check x + y - y = x +Temp2000_1.Assign( FBig1234); +Temp2000_1.Add ( FBig2313); +Temp2000_1.Subtract( FBig2313); +Assert.IsTrue( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'THugeCardinal Subtract failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_Zeroise; +begin +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// zeroise x +// check that x = 0 +Temp2000_1.Assign( FBig1234); +Temp2000_1.Zeroise; +Assert.IsTrue( Temp2000_1.IsZero,'THugeCardinal Zeroise failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_Swap; +begin +// x and y big values. +// swap x & y +// check x = original y +// check x.maxbits = original y.maxbits +// check y = original x +// check y.maxbits = original x.maxbits +Temp2000_1.Assign( FBig1234); +Temp2000_2.Assign( Fbig2313); +FBig1234.Swap( Fbig2313); +Assert.IsTrue( FBig1234.Compare( Temp2000_2) = rEqualTo, 'THugeCardinal Swap failed.'); +Assert.IsTrue( FBig1234.MaxBits = Temp2000_2.MaxBits, 'THugeCardinal Swap failed (MaxBits).'); +Assert.IsTrue( Fbig2313.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal Swap failed.'); +Assert.IsTrue( FBig2313.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal Swap failed (MaxBits).') +end; + + +procedure THugeCardinal_TestCase.Test_CreateFromStreamIn; +var + Newbie: THugeCardinal; +begin +// Manually stream out x. +// Stream it back into constructor. +// Check it is the same as the original. +Fbig2313.StreamOut( LittleEndien, TmpStream); +TmpStream.Position := 0; +Newbie := THugeCardinal.CreateFromStreamIn( TmpStream.Size*8, LittleEndien, TmpStream, nil); +Assert.IsTrue( Newbie.Compare( Fbig2313)= rEqualTo, 'THugeCardinal CreateFromStreamIn constructor failed.'); +Newbie.Free +end; + +procedure THugeCardinal_TestCase.Test_Multiply; +// Check that 10^33 * 10^44 = 10^77 + procedure Make10ToThePowerOf( var HC: THugeCardinal; Exponent: integer); + var + j: integer; + begin + // Assume Temp1 = 10 and Exponent >= 1 + HC.AssignSmall( 1); + for j := 1 to Exponent do + begin + T3 := HC.Multiply( Temp1); + HC.Assign( T3); + FreeAndNil( T3) + end; + // HC = 10 ^ Exponent + end; + +begin +Temp1.AssignSmall( 10); + +Make10ToThePowerOf( Fbig1234, 33); // Fbig1234 = 10^33 +Make10ToThePowerOf( Fbig2313, 44); // Fbig2313 = 10^44 +Make10ToThePowerOf( Fbig3547, 77); // Fbig1234 = 10^77 + +T3 := Fbig1234.Multiply( Fbig2313); +Assert.IsTrue( T3.Compare( Fbig3547) = rEqualTo, + 'THugeCardinal Multiply failed (10^33 * 10^44 = 10^77).'); +FreeAndNil( T3) +end; + +procedure THugeCardinal_TestCase.Test_MultiplyMod; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 * +//2313231323132313231323132313231323132313231323132313231323132313 mod +// 100 = +//---------------------------------------------------------------- +// 42 +Temp2.AssignSmall( 100); +FBig1234.MultiplyMod( FBig2313, Temp2); +Assert.IsTrue( FBig1234.CompareSmall( 42) = rEqualTo, + 'THugeCardinal MultiplyMod failed.'); +end; + +procedure THugeCardinal_TestCase.Test_PowerMod; +begin +// 6529 ^ 2987 mod 100 = 9 +FBig1234.AssignSmall( 6529); +Temp2.AssignSmall( 2987); +Temp3.AssignSmall( 100); +FBig1234.PowerMod( Temp2, Temp3, nil); +Assert.IsTrue( FBig1234.CompareSmall( 9) = rEqualTo, + 'THugeCardinal PowerMod failed (6529 ^ 2987 mod 100 = 9).') +end; + + +procedure THugeCardinal_TestCase.Test_Resize; +begin +// x create as 100 bits. random. +// resize to 200 bits. +// check x.size = 200 +// check x = original value. +T3 := THugeCardinal.CreateRandom( 100, 100, True, nil); +T3.Resize( 200); +Assert.IsTrue( T3.CapacityInBits = 200, + 'THugeCardinal Resize failed .'); +FreeAndNil( T3) +end; + + +procedure THugeCardinal_TestCase.Test_SmallExponent_PowerMod; +begin +// 6529 ^ 2987 mod 100 = 9 +FBig1234.AssignSmall( 6529); +Temp3.AssignSmall( 100); +FBig1234.SmallExponent_PowerMod( 2987, Temp3); +Assert.IsTrue( FBig1234.CompareSmall( 9) = rEqualTo, + 'THugeCardinal SmallExponent_PowerMod failed (6529 ^ 2987 mod 100 = 9).') +end; + + + + +procedure THugeCardinal_TestCase.Test_StreamOut; +var + Order: TByteOrder; +begin +// x big. +// stream out. +// stream in. +// check x = original value +for Order := LittleEndien to BigEndien do + begin + TmpStream.Size := 0; + Fbig2313.StreamOut( Order, TmpStream); + TmpStream.Position := 0; + Fbig1234.AssignFromStreamIn( Order, TmpStream); + Assert.IsTrue( Fbig1234.Compare( Fbig2313)= rEqualTo, + 'THugeCardinal Test_StreamOut failed.') + end +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_OpenSSLTestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_OpenSSLTestCases.pas new file mode 100644 index 0000000..cc5b7c9 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_OpenSSLTestCases.pas @@ -0,0 +1,165 @@ +unit uLockBox_OpenSSLTestCases; +interface +uses DUnitM.UnitTestFramework, Classes, TPLB3.Signatory, TPLB3.OpenSSL, SysUtils, + TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random, uLockBox_TestCases; + +type +{$M+} +[TestFixture('OpenSSL')] +TOpenSSL_TestCase = class( TTestCase) + public + FcodecOpenSSL: TOpenSSL_Codec; + FSig: TOpenSSL_Signatory; + FKey, FIV: TBytes; + FBlockSize: integer; + FPlain, FCipher, FRecon: TMemoryStream; + [Setup] procedure SetUp; + [TearDown] procedure TearDown; + + published + [Test] procedure OpenSSL_AES_Encryption; + + [IgnoreMemoryLeaks] + [Test] procedure TwoGenerations; + + [IgnoreMemoryLeaks] + [Test] procedure Signature; + end; + +implementation + + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; + + + +type +TBlock=array[0..15] of byte; +PBlock=^TBlock; +procedure TOpenSSL_TestCase.OpenSSL_AES_Encryption; +var + I: Integer; + b: byte; +begin +for I := 0 to 7 do + begin + b := i; + FPlain.Write( b, 1); + end; +FPlain.Position := 0; +FcodecOpenSSL.Encrypt( FPlain, FCipher); +FCipher.Position := 0; +FcodecOpenSSL.Decrypt( FRecon, FCipher); +Assert.IsTrue( CompareMemoryStreams( FPlain, FRecon), 'Failed general inversion') +end; + +procedure TOpenSSL_TestCase.SetUp; +var + i: Integer; +begin +FcodecOpenSSL := TOpenSSL_Codec.Create( nil); +FcodecOpenSSL.RequiredVersion := '0.9.0.0'; +FcodecOpenSSL.isLoaded := True; +Assert.IsTrue( FcodecOpenSSL.isLoaded, 'Failed to load Libeay32'); +FcodecOpenSSL.Cipher := cipher_aes_256_cbc; +FcodecOpenSSL.PaddingScheme := padPKCS; +FBlockSize := 16; +SetLength( FKey, FBlockSize); +SetLength( FIV, FBlockSize); +for i := 0 to FBlockSize - 1 do + begin + FKey[i] := 0; + FIV [i] := 0; + end; +FPlain := TMemoryStream.Create; +FCipher := TMemoryStream.Create; +FRecon := TMemoryStream.Create; +FcodecOpenSSL.SetKey( FKey); +FcodecOpenSSL.SetIV ( FIV); +FSig := TOpenSSL_Signatory.Create( nil); +FSig.RequiredVersion := '0.9.0.0'; +FSig.isLoaded := True; +Assert.IsTrue( FSig.isLoaded, 'Failed to load Libeay32'); +end; + +const + PrivateKey1: utf8string = + '-----BEGIN RSA PRIVATE KEY-----'#$A + + 'MIIEowIBAAKCAQEAvrcFyDAAU6IyOiXiPaTuAe9CTZtwwLdkDSzb6IzBYwFUH+88'#$A + + 'QAklxLlHSsK3P/UKzDScG1bDHa3Ry8LZcU/LmIuFyoPAx5kJEeP5Auk/NGSsFbIw'#$A + + '+bYuMXWU2EVMXhJqQpezJKNc+x03dgZLTBgNuH0E1SO1Reu/4FKYA29zSN5qdYeG'#$A + + '8nrk45e46lm835HYzrDl69IwgB1daZ3/mrvik6qY2JjfiGxHDMqCUtWWuvA6Ayoi'#$A + + 'G4EFpU8ej3MElt7kKjJJrx5A4wx+hbr0BzVPWsIoYtffEhTBnEWR3pGe2R1pKy9l'#$A + + 'zgklFbp7984gqBOXVigHrRXq0pSdVOhW9ZjSqwIDAQABAoIBADPiDKOiU2RtOqbR'#$A + + 'CZRlmw5RrcL5J5p2CbT/4C+Ko02w3db2OXjeRDUZhoiTIlE286IMKe/SEbCwSePZ'#$A + + '9Ve7MpMkWdh3MWnbezkvwN2G4Nf7D0mzuVkls7lm2IBhkd4BuoC1TloIS1JRZ3Yn'#$A + + 'TjK8VHc9I6RsW3NTKFb5gTtmBYHr7s/wsptT2QNFmK194AbIGAcb4WWtS34YktDT'#$A + + 'gXCdMEqZhASnmShgQhiyL8s5BgacpCBkuVEfBRqrL2MsV2ceSbyuTZUabNFMReOX'#$A + + 'BqrGWGbNebFUce1stFhShi9np6cUj3EL1bErC/RZJuXJONDxNEuVutriglInZ9D+'#$A + + 'g4vY9YkCgYEA/MtEvlO7ptfaw+9Bb/S+aEFYQTo/C8T0ELV3wW8Pj399OVhmxV8s'#$A + + 'ZEUdSYyB6cCJukLPJyGAokSktLBF+sOgxJkGY7dlei9jbUfKa1UGMwKYbxKQX2hA'#$A + + 'UGEbRR1Pt/+pNrNgAfMbiwnz+ir5i2gBRXyZvzbfuzs0RbElqpDH7/0CgYEAwSI0'#$A + + 'nkMEgOXdm/TBPJUEXLv8AjBlBWjI8KxrefGgZNRBYU64rIiKs68w7Suv4hw77fBj'#$A + + 'HIyc1io6W6bOzwx3W9+vEzEG5xHzxcoRESJ0N1195sLuU/F4aCRHioMsSouR02tm'#$A + + 'ea4ltqg2DkHSos1ulbnhWxN5/AFu36roAy/A6ccCgYB7WgiKQrt/VzbFgvrQUYGT'#$A + + 'x8bz1SMscAeUG6h69+GE6PXGxK8pQh6cMulumSRPVoceHzmL45osFAi2rokHKuxI'#$A + + '4k6u26+lpngCvBQ2uX9T5sFQ+aL/GxS+5BN1by8WHqeILJD9go3/E3U8rjmkX7S3'#$A + + 'Hmy7VGBpsSL5ms5BY3JcVQKBgQCdPWkTlMKc4wkLCTkuRrC3g4FIkvgccFRwxh/2'#$A + + 't0d77+eO/tWR+tTaN/8giVn4QD52mSlIPB8Qqm664dMsdRzUWwgiGt9gz5fl537/'#$A + + 'sUpnLSHs97Wr+EOsniT025j61CkUtTNITAV+cfMYpnSEgbbQBfc4/GFrUAth5LZi'#$A + + 'qcVpTwKBgCfrNoD1KB+hWnJoFtFoObzYz/O1dKO7PbxyeMUEV5QLc96emE5W8p9w'#$A + + '8r48LhBgq3Ma2ghmnise9zCaNIjb/DTqoyfD+ZdZat6y+bc2zyWu0tZimSGw5rgs'#$A + + '4XJeUpxr7Gm8p8tS1nUBWmooqiR18ORZEtVxdBAxUl2VRnekYnQG'#$A + + '-----END RSA PRIVATE KEY-----'; + +procedure TOpenSSL_TestCase.Signature; +var + sSecret: utf8string; + Secret: TStream; +begin +FSig.PrivateKey := PrivateKey1; +FSig.PrivateKeyStoragePassword := 'honey'; +FSig.PrivateKeyStorageCipher := cipher_aes_256_cbc; +Secret := TMemoryStream.Create; +FSig.StoreKeysToStream( Secret, [partPrivate]); +Secret.Position := 0; +SetLength( sSecret, Secret.Size); +if Secret.Size > 0 then + Secret.ReadBuffer( sSecret[1], Secret.Size); +Secret.Position := 0; +Assert.IsTrue( Pos('-----BEGIN RSA PRIVATE KEY-----', sSecret) > 0, 'OpenSSL key not properly stored.'); +Assert.IsTrue( Pos('ENCRYPTED', sSecret) > 0, 'OpenSSL key not properly encrypted.'); +FSig.LoadKeysFromStream( Secret, [partPrivate]); +Secret.Free; +Assert.IsTrue( FSig.SignVerify_SelfTest); +Assert.Warn( 'TOpenSSL_TestCase.Signature() test has known memory leaks.'); +end; + +procedure TOpenSSL_TestCase.TearDown; +begin +FcodecOpenSSL.Free; +FPlain.Free; +FCipher.Free; +FRecon.Free; +FSig.Free; +SetLength( FKey, 0); +SetLength( FIV, 0) +end; + + + + +procedure TOpenSSL_TestCase.TwoGenerations; +begin +Assert.IsTrue( FSig.GenerateKeys); +Assert.IsTrue( FSig.GenerateKeys); +Assert.Warn( 'TOpenSSL_TestCase.TwoGenerations() test has known memory leaks.'); +end; + + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_RSA_TestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_RSA_TestCases.pas new file mode 100644 index 0000000..73b2420 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_RSA_TestCases.pas @@ -0,0 +1,511 @@ +unit uLockBox_RSA_TestCases; +interface +uses DUnitM.UnitTestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, + TPLB3.MemoryStreamPool, uLockBox_TestCases; + +type +{$M+} +[TestFixture('RSA.Primitives')] +TRSA_TestCase = class( TTestCase) + public + FPool: IMemoryStreamPool; + FwasAborted: boolean; + FdoAbort: boolean; + + [Setup] procedure SetUp; + [TearDown] procedure TearDown; + procedure OnProgress( Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); + procedure CheckPowerModWithCRT( + m, d, n, p, q, dp, dq, qinv: THugeCardinal; + const Msg: string); + + published + [Test] procedure ChineseRemainderTheorem; + [Test] procedure Test_Compute_RSA_Fundamentals; + [IgnoreMemoryLeaks] + [Test] procedure Test_RSA_Primitives; + [Test] procedure Cardinal2Stream_InversionTests; + [Test] procedure RSAES_OAEP_ENCDECRYPT; + end; + + +[TestFixture('RSA.Codec')] +TRSA_Crypto_TestCase = class( TTestCase) + public + FPool: IMemoryStreamPool; + FwasAborted: boolean; + FdoAbort: boolean; + + Lib: TCryptographicLibrary; + Codec: TCodec; + + [Setup] procedure SetUp; + [TearDown] procedure TearDown; + + published + [Test] procedure Test_Encrypt; + end; + +implementation + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.RSA_Primitives, Forms; + + +{ TTestCaseFirst } + +// Output from a run of Make Sample Key +// ================================== BEGIN ===================== +//Now generating an RSA-1024 key pair +//Generation completed. +//Generation took 34s. +//318 primality tests were conducted to reach this goal, +//at a rate of 9.4 tests per second. +// +//n has 1024 bits. +//e has 17 bits. +//d has 1022 bits. +//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; +// +//e (little-endien; base64) = "AQAB"; +// +//e (decimal) = 65537 +// +//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; +// +// +//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; +//Now generating an RSA-1024 key pair +//Generation completed. +//Generation took 34s. +//318 primality tests were conducted to reach this goal, +//at a rate of 9.4 tests per second. +// +//n has 1024 bits. +//e has 17 bits. +//d has 1022 bits. +//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; +// +//e (little-endien; base64) = "AQAB"; +// +//e (decimal) = 65537 +// +//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; +// +// +//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; +// ================================== END ===================== + +const + Test_n: utf8string = // n (little-endien; base64) + 'u9GFdi6di8zy/ZoPVdyNjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTNneme' + + 'V5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZOrz80SfVals7e+/cIAxIi4v/n1OP2VVG' + + 'l6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k='; + Test_n_bits = 1024; + + Test_e: utf8string = // e (little-endien; base64) + 'AQAB'; + Test_e_bits = 17; + + Test_d: utf8string = // d (little-endien; base64) + 'cY9AhO6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR' + + '3fXxpRI2IibOEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lNfO1OIC' + + 'jlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic='; + Test_d_bits = 1022; + + Test_AES256Key: utf8string = // (base64; LoadFromStream) + '+KcK4snvh88mf8OxcdU3ri1HSPyqRu1pb0+pEB511jE='; + + + + +{ TRSA_TestCase } + +procedure TRSA_TestCase.Cardinal2Stream_InversionTests; +var + i1, i2: THugeCardinal; + s1, s2: TMemoryStream; +begin +TRandomStream.Instance.Seed := 1; + +// 1. Create a Huge Cardinal of 64 bits (8 bytes). +i1 := THugeCardinal.CreateRandom( 64, 64, True, FPool); + +// 2. Stream it out to a 9 byte stream. +s1 := FPool.NewMemoryStream( 0); +i1.StreamOut( BigEndien, s1, 9); + +// 3. Stream it back in +s1.Position := 0; +i2 := THugeCardinal.CreateFromStreamIn( 64, BigEndien, s1, FPool); + +// 4. Compare cardinal with the original +Assert.IsTrue( i1.Compare( i2) = rEqualTo, 'Cardinal --> Stream inversion test.'); + +// 1. Create a random stream with 4 bytes +s1.Size := 4; +RandomFillStream( s1); + +// 2. Stream it in. MaxBits = 32 +i1.Free; +s1.Position := 0; +i1 := THugeCardinal.CreateFromStreamIn( 32, BigEndien, s1, FPool); + +// 3. Stream it out. +s2 := FPool.NewMemoryStream( 4); +s2.Position := 0; +i1.StreamOut( BigEndien, s2, 4); + +// 4. Compare stream with the original. +Assert.IsTrue( CompareMemoryStreams( s1, s2), 'Stream --> Cardinal inversion test.'); + +i1.Free; i2.Free; +s1.Free; s2.Free +end; + + + +procedure TRSA_TestCase.OnProgress( + Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); +begin +// Application.ProcessMessages +if FdoAbort then + doAbort := True +end; + + + +procedure TRSA_TestCase.RSAES_OAEP_ENCDECRYPT; +var + n, e, d, Totient: THugeCardinal; + Count1, j, i: integer; + Plaintext, Ciphertext, Recon: TMemoryStream; + p, q, dp, dq, qinv: THugeCardinal; +begin +TRandomStream.Instance.Seed := 1; +for j := 1 to 3 do + begin + Count1 := 0; + Compute_RSA_Fundamentals_2Factors( + 480, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + nil, nil, 20, FPool, Count1, FwasAborted); + Assert.IsTrue( Validate_RSA_Fundamentals( n, e, d, Totient), 'Failed to generate RSA key pair.'); + for i := 1 to 10 do + begin + Plaintext := TMemoryStream.Create; + Plaintext.Size := RSAES_OAEP_ENCRYPT_MaxByteLen( n); + RandomFillStream( Plaintext); + Plaintext.Position := 0; + Ciphertext := TMemoryStream.Create; + Assert.IsTrue( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), 'RSAES_OAEP_ENCRYPT'); + Ciphertext.Position := 0; + Recon := TMemoryStream.Create; + Assert.IsTrue( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), 'RSAES_OAEP_DECRYPT'); + Assert.IsTrue( CompareMemoryStreams( Plaintext, Recon), 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT inversion.'); + Plaintext.Free; + Ciphertext.Free; + recon.Free; + Application.ProcessMessages; + end; + n.Free; + d.Free; + e.Free; + Totient.Free; + p.Free; q.Free; dp.Free; dq.Free; qinv.Free; + end; +end; + + + + +procedure TRSA_TestCase.SetUp; +begin +FPool := NewPool; +FwasAborted := False; +FdoAbort := False; +end; + +procedure TRSA_TestCase.TearDown; +begin +FPool := nil; +FwasAborted := False; +FdoAbort := False; +end; + +procedure TRSA_TestCase.Test_Compute_RSA_Fundamentals; +var + n, e, d, Totient: THugeCardinal; + Count1: integer; +// j, Sz, Current, Peak: integer; +// s: string; + p, q, dp, dq, qinv: THugeCardinal; +begin +GreatestPassCount := 0; + +Count1 := 0; +Compute_RSA_Fundamentals_2Factors( + 512, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + OnProgress, nil, 20, FPool, Count1, FwasAborted); + +if not FwasAborted then + Assert.IsTrue( Validate_RSA_Fundamentals( n, e, d, Totient), + 'Failed to generate RSA key pair.'); +Totient.Free; +n.Free; +e.Free; +d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +//for j := 0 to FPool.BayCount - 1 do +// begin +// Sz := FPool.GetSize( j); +// FPool.GetUsage( Sz, Current, Peak); +// s := Format( 'MemSize=%d; Final=%d; Peak=%d; Passes=%d', [Sz, Current, Peak, GreatestPassCount]); +// s := s + ' ' +// end +end; + + +procedure TRSA_TestCase.CheckPowerModWithCRT( + m, d, n, p, q, dp, dq, qinv: THugeCardinal; + const Msg: string); +var + m1, m2: THugeCardinal; +begin + m1 := m.Clone; + m2 := m.Clone; + m1.PowerMod( d, n, nil); + m2.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil); + Assert.IsTrue( m1.Compare( m2) = rEqualTo, Msg); + m1.Free; + m2.Free +end; + +procedure TRSA_TestCase.ChineseRemainderTheorem; +var + n, e, d, Totient: THugeCardinal; + Count1: integer; + p, q, dp, dq, qinv: THugeCardinal; + m0: THugeCardinal; + c: THugeCardinal; +begin + TRandomStream.Instance.Seed := 55; + + // result(=m==65) == pre_self(=c=2790) ** Exponent(=d=2753) mod Modulus(=n=3233) + c := THugeCardinal.CreateSimple( 2790); + d := THugeCardinal.CreateSimple( 2753); + n := THugeCardinal.CreateSimple( 3233); + dp := THugeCardinal.CreateSimple( 53); + dq := THugeCardinal.CreateSimple( 49); + qinv := THugeCardinal.CreateSimple( 38); + p := THugeCardinal.CreateSimple( 61); + q := THugeCardinal.CreateSimple( 53); + CheckPowerModWithCRT( c, d, n, p, q, dp, dq, qinv, 'PowerMod failed Wikipedia example.'); + FreeAndNil( c); + FreeAndNil( d); + FreeAndNil( n); + FreeAndNil( dp); + FreeAndNil( dq); + FreeAndNil( qinv); + FreeAndNil( p); + FreeAndNil( q); + +GreatestPassCount := 0; +Count1 := 0; +Compute_RSA_Fundamentals_2Factors( + 512, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + OnProgress, nil, 20, FPool, Count1, FwasAborted); + +m0 := THugeCardinal.CreateRandom( n.BitLength, n.BitLength, False, nil); +if not FwasAborted then + CheckPowerModWithCRT( m0, d, n, p, q, dp, dq, qinv, 'PowerMod failed.'); +m0.Free; +Totient.Free; +n.Free; +e.Free; +d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +end; + + + + +procedure TRSA_TestCase.Test_RSA_Primitives; +var + Tmp: TStream; + n, e, d: THugeCardinal; + p, q, dp, dq, qinv: THugeCardinal; + + PlainText, Ciphertext, Recon: TMemoryStream; + + function MakeHuge( const Definition: utf8string; BitLen: cardinal) + : THugeCardinal; + begin + Tmp.Size := 0; + Base64_to_stream( Definition, Tmp); + Tmp.Position := 0; + result := THugeCardinal.CreateFromStreamIn( BitLen, LittleEndien, Tmp, FPool) + end; + +begin +// 1. Create n +// 2. Create d +// 3. Create e +// 4. Create test plaintext stream +// 5. Encrypt +// 6. Check encryption result +// 7. Decyrpt +// 8. Check decryption result +// 9. Compare and check plaintext with reconstruction +// 10. Clean-up (n, d, e, plaintext, ciphertext, recon) + +TRandomStream.Instance.Seed := 1; +Tmp := FPool.NewMemoryStream( 0); +PlainText := TMemoryStream.Create; +Ciphertext := TMemoryStream.Create; +Recon := TMemoryStream.Create; +n := MakeHuge( Test_n, Test_n_bits); +e := MakeHuge( Test_e, Test_e_bits); +d := MakeHuge( Test_d, Test_d_bits); +p := nil; +q := nil; +dp := nil; +dq := nil; +qinv := nil; +PlainText.Size := 40; +RandomFillStream( Plaintext); + +try +Assert.IsTrue( PlainText.Size <= RSAES_OAEP_ENCRYPT_MaxByteLen( n), + Format('Plaintext too big (%d) for RSA keys.',[PlainText.Size])); + +Assert.IsTrue( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), + 'RSAES_OAEP_ENCRYPT'); + +Assert.IsTrue( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), + 'RSAES_OAEP_DECRYPT'); + +Assert.IsTrue( CompareMemoryStreams( Plaintext, Recon), + 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT general inversion test failed!') + +finally +Tmp.Free; +Plaintext.Free; +Ciphertext.Free; +Recon.Free; +n.Free; e.Free; d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +end; +Assert.Warn( 'TRSA_TestCase.Test_RSA_Primitives() test has known memory leaks.'); +end; + + + + +//PAllocationRecord(fpool.fallocrecord.[0])^.fpeakusage +// +//KeySize Trial PeakUsage +//512 1 21 +//512 2 18 +//512 3 19 +//512 4 18 +//512 5 18 +//512 6 19 +//512 7 18 +//512 8 18 +//1024 1 20 +//1024 2 19 +//1024 3 18 +//1024 4 18 +//1024 5 21 +//4096 1 +//4096 2 + +const + RSA_512_SampleKey1: utf8string = + 'QAAAADfRWmA3nhVOOvqB0CLoy1lvP6VwuPRY0gYMtGjS+G3vPVZG/adCkgcAuhduuzR' + + 'af42JCz75O8vrSS66owu2OWRAAAAA0YnbSszKdiN+s9zNiJizwIjK11cvNISf3jmFqB' + + 'iDCVKojcmJbnPEPsAbUlHx1oqpI4EpQuooNIC/3eELq0gZFAMAAAABAAE='; + + RSA_512_SampleKey2: utf8string = + 'QAAAAB90ZOa8vuzPpmWuWReBRuE12r/oAfFMJdBk8XfTIHB26+o1u1VtwV0NRYaqR/N' + + '4dkvhfF8Eb1LgzRZzf1vh9JlAAAAAcenoFSj7DtDGUByUhN3zcB+eOD0/sNn1Fqaizm' + + '+qUv1RUUg+iXnQw1qZVlLliNzvZw3k01M2myXAsJNOLVXYDwMAAAABAAE='; + + RSA_1024_SampleKey1: utf8string = + 'gAAAAIWILE/fqXIjMtXbxffzixJ3T71Kg+JsSzwuEuqbwP5y/D2f7XluAC4cYoCU3qA' + + 'WfRy23JaR+rXAWFMw2J/MSEO43Vbq1RHis0jeb4JD44Y9D1zV+sJ8CIWhzp38QzqhGb' + + 'PMDAFDQXwd9Hf5Ch9qoh7NJR7KWFBWZuA5kK/eiF2CgAAAABMwrc8ZDRGbb8uWsTNcm' + + 'sV0DoQ6gLZTLwSNAsjadAmPHviXRleVIQaBeruwuWSYUBbNJOQrPb095KM9s7BDlxSN' + + 'WJnvBkGYQx9ZXbHdwrMDlKQEkpkoetkbGSWZGLBRRCW3muhQIIXOtQ1ABUASi9HKuno' + + 'zojA3/qbs5HHn1Y0gAwAAAAEAAQ=='; + + RSA_1024_SampleKey2: utf8string = + 'gAAAAC9TuThwZQG596+UXAwLGLR5gdhOns4RmB4a/QBq0PLfaX8QiLhx4ziihWRHh2u' + + 'AtYM7TgWFegIv5ZJ75uNjpyNHOx/qOhrUwRUzCi5NT5Atl7iDwPz42uqUjJOoDNpsBx' + + 'lXhWIZUFrer3jY5b/ZJiNrt+A+I7LhaEmCbLsb9MB8gAAAAO3PcBC72KBGVQXgZJWQw' + + 'U24e9cGKYu3h4J6ujTqfdWR21QQJGbWjbl9UG6JdLSxsESxQ2FcPa0s/UWfQEdmmRhK' + + 'OjGYvSiLnlNjoUdJiXjrQ1n0lUcR/Z7+pYFdtY3P12JQ9Oml7jBwYbMFvddqh4qgPkJ' + + 'GcJLw1+G5w8DPez0BAwAAAAEAAQ=='; + + +{ TRSA_Crypto_TestCase } + +procedure TRSA_Crypto_TestCase.SetUp; +var + Store: TStream; + s: utf8string; +begin +Lib := TCryptographicLibrary.Create( nil); +Codec := TCodec.Create( nil); +Codec.CryptoLibrary := Lib; +Codec.StreamCipherId := 'native.RSA'; +Codec.AsymetricKeySizeInBits := 1024; +Store := TMemoryStream.Create; +try +case Codec.AsymetricKeySizeInBits of + 512: s := RSA_512_SampleKey1; + 1024: s := RSA_1024_SampleKey1; + else Assert.IsTrue( False, 'No test case yet for this key size.'); + end; +Base64_to_stream( s, Store); +Store.Position := 0; +Codec.InitFromStream( Store); +finally +Store.Free; +end end; + + + +procedure TRSA_Crypto_TestCase.TearDown; +begin +Codec.Free; +Lib.Free +end; + + +procedure TRSA_Crypto_TestCase.Test_Encrypt; +const + sTestPlaintext: string = 'Test me!'; +var + x, y, recon_x: string; +begin +x := sTestPlaintext; +Codec.EncryptString( x, y, TEncoding.UTF8); +Codec.Reset; +Codec.DecryptString( recon_x, y, TEncoding.UTF8); +Assert.AreEqual( x, recon_x, 'RSA Crypto'); +end; + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Signatory_TestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Signatory_TestCases.pas new file mode 100644 index 0000000..0e397e0 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_Signatory_TestCases.pas @@ -0,0 +1,186 @@ +unit uLockBox_Signatory_TestCases; +interface +uses DUnitM.UnitTestFramework, TPLB3.MemoryStreamPool, Classes, TPLB3.Signatory, + TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random, uLockBox_TestCases; + +const + +Key1_v0: utf8string = +'gAAAABVmVoAtVC4GNZi1ue+wlopkpnPkpp00bgzW5fphnOmG8ulfRoPPe9l1Asp+kfZEikoh' + +'SRmcPOW3yNKwOMyqZCFY0CWNjnChXgytOPaMYyYbWZZ/v9LOv6zZ0ucpThUuw4Prz5JJP7a7' + +'o5ODlIWD73gYCixJqJD5a0aXkWYqUG+EAwAAAAEAAYAAAADnwM7wBHZVUpEi9H+N5urr7+1q' + +'YuJtH57gYHDtw/O6I+FC2BxQhYIGydxvKNx87+z6aPYUVaLVc4OmSCL02DeN1vOlF5lRYhA0' + +'/nMChN9nCtdvF39NdD7qbSVWlnyl/tEUXRAFsxC7DzgKyrFck0rJAaEvRspL+eNZXcOCJeUU' + +'FYAAAADl+xGZxpkIb/VWE2943aqWQRpTET/3sjHXG+/ckZ1heGoXwtrUeQ5iztVT7oIg1mbE' + +'cl9b2Y6q2jjGynNMT6VOYDpQUqneDQ7e6LQXtukkJTNrT0SAF/2QYLxJ8fs5BE5ImeDRwb90' + +'WlkHWYGXQklRF71NOBXyvMTzwVYxKjuXiwMAAAABAAF/AAAAxWlONs6snpUASKl0Q+iGbTF9' + +'sxEkQx/+d4Vb9kJ4GuyfRGC74yd7zgz9r5P/cwezX6jNjJqws8ZV9IeOb+UhepJ0rrAeFB1p' + +'0IIOXXS6u8cw4PDZ7bwJUt/nYLH+tt14ZhYO9Lf1LXq6trqnXbA5CBwvseS7zkcDwvGMefWR' + +'wQ=='; + +Key2_v1: utf8string = +'TgpMb2NrQm94MwEAAAAPgAAAAEGFoI9kf0jiiNFG9EwOA4OCe31UgeYiCo5o+tGuW0aY5AUr' + +'L+hlZn5TuZAsLXc5jegyT3aqgQZgIb0/9/J/Xog1TCucvRurQ5FvmK7THqODi7m8q9f1v28N' + +'t9EqPATYdkJZlpplOnylW8dTwxsflQ0FWzdQMS2nTa/apv65sv6uAwAAAAEAAYAAAAD5/6/A' + +'Xw4Hn86czZJuiaZZ7J86nfzTq6jZv0ytY2/60JLDRfTEt7UHWRZbn5OYSDY/6uqUAyqn1HWT' + +'tb/eR8uyOsYaJRfT8RSFpwdYNpktdqHJoK9i/9tMGqYyYEXM0EX0H8QndHQKjFIKS0gS2wvD' + +'2mSYK+BigEtp8GZ5FI1OSUEAAADfv58/cruaW29nVgQHe79vThxJk0BjbAdP7b10SNUjcp2q' + +'9a6NbTYFC+OEkicxiW+O6PjMYOe/Qn/J2Ipyq5YEA0AAAADf3oszxOLVhKFEBSb4tXIEQ73b' + +'jlALC1ZW8uGcMxPwlEPGqvQEQzE+dFAdHkc7nj3OjczOmWPHNsgCaQTCNfw5QQAAADP6Lz5T' + +'xKvaLnPu4U+/ofhoMI9jqQbV67fvaK1v+gH59N3b+ZsCQmCmR4rQWlyKbA5uIFcHE5Md217i' + +'LNGqmsYCQAAAAEWhiRykobdu7mTOe4TVoPB+TpLfijY/e+992Mh1R02HnSqil3OM45lEoawb' + +'RUp2+/hBI+sG6ThICFi9G+Rp7AFAAAAAfUaWk66hjVdvH1Z/y52CI2Xh8yoafToIBH+TkEqR' + +'DSqz2MX9bndkQCUx1S1/kbM16IZcrpnWyPZY2Fv8vComp04KTG9ja0JveDMBAAAAD4AAAACD' + +'z9tWaMOeYID0V9zKzWYVk0yDmw8cGtyNYKOujgVa23VYg3Kzr0WTLVRk1FQfy+OmDu09zUz1' + +'VfNN7gMBwkMz3Vr4g45qEcPEkFOizzIDI/O6uoioIVDP3SJU3Mn5cQqjQ7N50Qz31A2mAksd' + +'HHgCPFzXATf0h1CVWpJMGzgCZgMAAAABAAGAAAAA/T1FuYxHzWDyAK5YM2PazZY+BhgkPskA' + +'7fwBxfF2imackHqX7CTsU/i6NJ57jdoAyGU+hjqocBPrgml6mSAOKbk8rT1JdtoPzGaFlVcH' + +'LSHyvfTD166GdyLnG37zWEiGswFkjQE8LCxXeSbxHBY9k9H+hQhhrpILA8svr6hAQSRBAAAA' + +'9zUbH29H9X/U93cHhJ8otE+hBjE1hhralqoCsVLiFlhQv/7Pa3YG6L59SDzQ5SiuY5P6nZGV' + +'QmmDg+1DfjlMogJAAAAA1R8J3HZjIfU/R3ypQ3/psJ98EcVi9WTNrs2WfB3Su9+UCjUHn+FM' + +'DPnDSGZeQP/QpkiHkpOOwuLQqX/Gvl+6JkEAAABl/X6i6YwGMmfM5ziZxQMbsSohq1MqblGZ' + +'+OzrnsZvAJxpOtkGYca5g3NMux7g8V4KPW3u1Bzk6hPenWrAvHRKAUAAAAAlBKizOa53K8D+' + +'bUENbDSE7Ums8p4+zi+oZZo0M5wf10FBy5W21ABcdg3QmOzGNt1qgAW11cMKtk2gp5DBHL4j' + +'QQAAAKQHxCLfZ1B6nryWxUxbtCPjWNZckoGb4t5Tp5vKZ+l2F2H3qtfbl6iDbMvo1iijoEKu' + +'fu4VhjGk6IcWlvNIJn4B'; + + +type +{$M+} +[TestFixture('RSA.Signatory')] +TRSASignatory_TestCase = class( TTestCase) + private + FSeed_StandardTest: integer; + FDocumentSize_StandardTest: integer; + + public + FKey: TStream; + FKey_v1: TStream; + FSig: TSignatory; + FcodecRSA: TCodec; + FLib: TCryptographicLibrary; + FDocument: TMemoryStream; + FSignature: TStream; + FRand: TRandomStream; + + [Setup] procedure SetUp; + [Teardown] procedure TearDown; + function OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; + procedure Generic_Signatory_InversionTests( Seed: uint64{=-1 for random}; DocumentSize, KeyFormatVersion: integer); + + published + [Test] procedure Signatory_InversionTests_Version0Keys; + [Test] procedure Signatory_InversionTests_Version1Keys; + end; + +implementation + + + + + + + + + + + + + + + + + + + + +uses SysUtils, TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; + + + +procedure TRSASignatory_TestCase.SetUp; +begin +FRand := TRandomStream.Instance; +FSeed_StandardTest := 1; +FDocumentSize_StandardTest := 4000; +FKey := TMemoryStream.Create; +FKey_v1 := TMemoryStream.Create; +Base64_to_stream( Key1_v0, FKey); +Base64_to_stream( Key2_v1, FKey_v1); +FKey.Position := 0; +FKey_v1.Position := 0; +FSig := TSignatory.Create( nil); +FcodecRSA := TCodec.Create( nil); +FLib := TCryptographicLibrary.Create( nil); +FcodecRSA.CryptoLibrary := FLib; +FcodecRSA.StreamCipherId := RSA_ProgId; +FcodecRSA.OnProgress := OnProgress; +FSig.Codec := FcodecRSA; +FDocument := TMemoryStream.Create; +FSignature := TMemoryStream.Create; +end; + + + + +procedure TRSASignatory_TestCase.Signatory_InversionTests_Version0Keys; +begin +Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 0) +end; + + +procedure TRSASignatory_TestCase.Signatory_InversionTests_Version1Keys; +begin +Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 1) +end; + +procedure TRSASignatory_TestCase.Generic_Signatory_InversionTests( + Seed: uint64; DocumentSize, KeyFormatVersion: integer); +begin +if Seed = -1 then + FRand.Randomize + else + FRand.Seed := Seed; +FDocument.Size := DocumentSize; +RandomFillStream( FDocument); +FDocument.Position := 0; +FSignature.Size := 0; +if KeyFormatVersion = 0 then + FSig.LoadKeysFromStream( FKey, [partPublic, partPrivate]) + else + FSig.LoadKeysFromStream( FKey_v1, [partPublic, partPrivate]); +Assert.IsTrue( FSig.Sign( FDocument, FSignature), 'RSA signature generation failed.'); +DisplayStream( FSignature); +Assert.IsTrue( FSig.Verify( FDocument, FSignature)<>vFail, 'RSA signature verification failed.') +end; + + + + + +function TRSASignatory_TestCase.OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; +begin +result := True +end; + + + + + +procedure TRSASignatory_TestCase.TearDown; +begin +FreeAndNil( FSig); +FreeAndNil( FcodecRSA); +FreeAndNil( FLib); +FreeAndNil( FKey); +FreeAndNil( FKey_v1); +FreeAndNil( FDocument); +FreeAndNil( FSignature) +end; + + + + + + +end. diff --git a/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_TestCases.pas b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_TestCases.pas new file mode 100644 index 0000000..77558c0 --- /dev/null +++ b/LockBox3/unit-tests/dunit-m/test-suite/uLockBox_TestCases.pas @@ -0,0 +1,113 @@ +unit uLockBox_TestCases; +interface +uses + DUnitM.UnitTestFramework, DUnitM.StringUtils, Xml.XMLIntf, + DUnitM.DDExtensions; + +type + +TTestCase = class( TObject) + public + Assert: IAssert; + end; + +[TestFixture('General')] +[Description('Tests about identity and environment')] +TEnvironment_TestCase = class( TTestCase) + published + [Test] + [Description('Compiler version')] + procedure Test_Environment; + end; + + + + + + +implementation + + + + + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.SVN_Keywords, Dialogs, TPLB3.PointerArithmetic; + + + + + + +function DelphiVersion_DisplayName: string; +begin +if CompilerVersion > 31.0 then + result := 'post Delphi 10.1' +else if CompilerVersion = 31.0 then + result := 'Delphi 10.1 Berlin' +else if CompilerVersion = 30.0 then + result := 'Delphi 10 Seattle' +else if CompilerVersion = 29.0 then + result := 'Delphi XE8' +else if CompilerVersion = 28.0 then + result := 'Delphi XE7' +else if CompilerVersion = 27.0 then + result := 'Delphi XE6' +else if CompilerVersion = 26.5 then + result := 'AppMethod 1' +else if CompilerVersion = 26.0 then + result := 'Delphi XE5' +else if CompilerVersion = 25.0 then + result := 'Delphi XE4' +else if CompilerVersion = 24.0 then + result := 'Delphi XE3' +else if CompilerVersion = 23.0 then + result := 'Delphi XE2' +else if CompilerVersion = 22.0 then + result := 'Delphi XE' +else if CompilerVersion = 21.0 then + result := 'Delphi 2010' +else if CompilerVersion = 20.0 then + result := 'Delphi 2009' +else if CompilerVersion = 19.0 then + result := 'Delphi 2007 .NET' +else if CompilerVersion = 18.5 then + result := 'Delphi 2007' +else if CompilerVersion = 18.0 then + result := 'Delphi 2006' +else if CompilerVersion = 17.0 then + result := 'Delphi 2005' +else if CompilerVersion = 16.0 then + result := 'Delphi 8 .NET' +else if CompilerVersion = 15.0 then + result := 'Delphi 7' +else if CompilerVersion = 14.0 then + result := 'Delphi 6' +else + result := 'Unrecognised version of Delphi' +end; + + + +procedure TEnvironment_TestCase.Test_Environment; +begin +Assert.AreEqual( SizeOf( TrueNativeInt ), SizeOf( pointer), 'uTPLb_PointerArithmetic Native Integer definitions wrong.'); +Assert.AreEqual( SizeOf( TrueNativeUInt), SizeOf( pointer), 'uTPLb_PointerArithmetic Native Integer definitions wrong.'); +if CompilerVersion <> 31.0 then + Assert.Warn( Format( 'This test suite was built for Delphi 10.1 Berlin. You are using %s', [DelphiVersion_DisplayName])); +end; + + + + + + + +end. + diff --git a/unit-tests/dunit/uLockBox_CipherTestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_CipherTestCases.pas similarity index 96% rename from unit-tests/dunit/uLockBox_CipherTestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_CipherTestCases.pas index e79deb9..c1981b9 100644 --- a/unit-tests/dunit/uLockBox_CipherTestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_CipherTestCases.pas @@ -1,1073 +1,1073 @@ -unit uLockBox_CipherTestCases; -interface - -uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, - TPLB3.Codec, TPLB3.StreamCipher, uLockBox_TestCases, TPLB3.Random; - -type - - -TBlockSizeCase = ( - scZero, // size = 0 - scSmall, // size ~= 0.3 blocks - scUnit, // size = 1 block - scSmallish, // size = 1.5 blocks - scRough, // size = large N + about 0.1 blocks - scRound); // size = exactly N blocks. N is a large number. - - -TBlockMode_TestCase = class( TTestCase) - protected - FLib: TCryptographicLibrary; - FCodec: TCodec; - FOriginal : TMemoryStream; - FCiphertext : TMemoryStream; - FKeyStream : TMemoryStream; - FReferenceStream : TMemoryStream; - FBlockSize: integer; - FFeatures: TAlgorithmicFeatureSet; - - procedure SetUp; override; - procedure TearDown; override; - class function CipherId: string; virtual; abstract; - procedure NormalizeKeyStream; virtual; - - procedure InversionTest( DataSize: TBlockSizeCase; const ChainMode: string); - - published - procedure Test_Reference; - procedure GeneralInversionTests; - end; - - -TAES_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function KeySize: integer; virtual; abstract; - class function CipherId: string; override; - end; - - -TAES128_RefTestCase = class( TAES_Reference_TestCase) - protected - class function KeySize: integer; override; - end; - -TAES192_RefTestCase = class( TAES_Reference_TestCase) - protected - class function KeySize: integer; override; - end; - -TAES256_RefTestCase = class( TAES_Reference_TestCase) - protected - class function KeySize: integer; override; - end; - - - -TStreamModeInversion_TestCase = class( TTestCase) - protected - FLib: TCryptographicLibrary; - FCodec: TCodec; - FOriginal : TMemoryStream; - FCiphertext : TMemoryStream; - FReconstructed : TMemoryStream; - FFeatures: TAlgorithmicFeatureSet; - - procedure SetUp; override; - procedure TearDown; override; - class function CipherId: string; virtual; abstract; - class procedure TestSizeRange( var MinBytes, MaxBytes: integer); virtual; abstract; - - published - procedure GeneralInversionTest; virtual; - end; - - -TBase64_TestCases = class( TStreamModeInversion_TestCase) - private - FKAT_Source :TStream; - - protected - procedure SetUp; override; - procedure TearDown; override; - class function CipherId: string; override; - class procedure TestSizeRange( var MinBytes, MaxBytes: integer); override; - - published - procedure Marks_KAT; - end; - - - -TDES_TestCase = class( TTestCase) - published - procedure PC1; - procedure PC2; - procedure IP; - procedure Inverse_IP; - procedure ExpandKey; - procedure EncryptBlock; - procedure YourLipsAreSmoother; - end; - - -TDES_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function CipherId: string; override; - procedure NormalizeKeyStream; override; - end; - -T3DES_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function CipherId: string; override; - procedure NormalizeKeyStream; override; - end; - -T3DES_KO1_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function CipherId: string; override; - procedure NormalizeKeyStream; override; - end; - -TBlowfish_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function CipherId: string; override; - end; - -TTwofish_Reference_TestCase = class( TBlockMode_TestCase) - protected - class function CipherId: string; override; - published - procedure TwoFishPrimitives; - end; - - -TMasBug_TestCase = class( TTestCase) - protected - FRand: TRandomStream; - P: PByte; - Len: integer; - - procedure SetUp; override; - procedure TearDown; override; - - published - procedure Mas_RandomStream_Bug; - end; -implementation - - - - - - - - - - -uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, - TPLB3.ECB, TPLB3.BlockCipher, TPLB3.HugeCardinalUtils, - TPLB3.IntegerUtils, TPLB3.DES, TPLB3.Constants, - TPLB3.DCP.twofish_Modified, TPLB3.Compatibility; - - -{ TTestCaseFirst } - - -procedure InitUnit_CipherTestCases; -begin -TestFramework.RegisterTest( TAES128_RefTestCase.Suite); -TestFramework.RegisterTest( TAES192_RefTestCase.Suite); -TestFramework.RegisterTest( TAES256_RefTestCase.Suite); -TestFramework.RegisterTest( TBase64_TestCases.Suite); -TestFramework.RegisterTest( 'DES.Basic DES', TDES_TestCase.Suite); -TestFramework.RegisterTest( 'DES.Basic DES', TDES_Reference_TestCase.Suite); -TestFramework.RegisterTest( 'DES.3DES.KO2', T3DES_Reference_TestCase.Suite); -TestFramework.RegisterTest( 'DES.3DES.KO1', T3DES_KO1_Reference_TestCase.Suite); -TestFramework.RegisterTest( TBlowfish_Reference_TestCase.Suite); -TestFramework.RegisterTest( TTwofish_Reference_TestCase.Suite); -TestFramework.RegisterTest( TMasBug_TestCase.Suite); -end; - -procedure DoneUnit_CipherTestCases; -begin -end; - - - - - - -const sPure_ECB_Id = 'dunit.ECB'; - -type TPure_ECB = class( TECB) - protected - function ChainingFeatures: TChainingFeatureSet; override; - function ProgId: string; override; - end; - -function TPure_ECB.ChainingFeatures: TChainingFeatureSet; -begin -result := inherited ChainingFeatures + [cfKeyStream] -// The inclusion of cfKeyStream disables block padding. -// We can only use this class in situations where be plaintext size -// is an exact multiple of the block size. -end; - -function TPure_ECB.ProgId: string; -begin -result := sPure_ECB_Id -end; - - - -{ TStreamModeReference_TestCase } - -procedure TBlockMode_TestCase.GeneralInversionTests; - procedure TestChainMode( const ChainMode: string); - var - j: TBlockSizeCase; - begin - for j := Low( TBlockSizeCase) to High( TBlockSizeCase) do - InversionTest( j, ChainMode) - end; - -begin -TestChainMode( 'native.ECB'); -TestChainMode( 'native.CBC'); -TestChainMode( 'native.CFB'); -TestChainMode( 'native.CTR'); -TestChainMode( 'native.OFB'); -TestChainMode( 'native.CFB-8bit'); -TestChainMode( 'native.PCBC') -end; - - - -procedure TBlockMode_TestCase.InversionTest( - DataSize: TBlockSizeCase; const ChainMode: string); -var - TestSize, TestsCount: integer; - j: integer; - Ok: boolean; - - function RandomSizableNumber: integer; - begin - TRandomStream.Instance.Read( result, SizeOf( result)); - result := (abs( result) mod 200) + 50 - end; - -begin -FCodec.ChainModeId := ChainMode; -FCodec.Password := 'Monkey''s uncle'; -TestSize := 0; -TestsCount := 0; -case DataSize of - scZero: begin - TestSize := 0; - TestsCount := 1 - end; - - scSmall: begin - TestSize := Round( FBlockSize * 0.3); - TestsCount := 1 - end; - - scUnit: begin - TestSize := FBlockSize; - TestsCount := 1 - end; - - scSmallish: begin - TestSize := Round( FBlockSize * 1.5); - TestsCount := 10 - end; - - scRough: begin - TestSize := (RandomSizableNumber * FBlockSize) + RandomSizableNumber; - TestsCount := 100 - end; - - scRound: begin - TestSize := RandomSizableNumber * FBlockSize; - TestsCount := 10 - end; - end; -for j := 1 to TestsCount do - begin - FOriginal.Size := TestSize; - RandomFillStream( FOriginal); - FCiphertext.Size := 0; - FCodec.EncryptStream( FOriginal, FCiphertext); - FCodec.Reset; - FReferenceStream.Size := 0; - FCodec.DecryptStream( FReferenceStream, FCiphertext); - FCodec.Reset; - Ok := CompareMemoryStreams( FOriginal, FReferenceStream); - Check( Ok, - Format( '%s fails the general inversion test!', [FCodec.Cipher])); - if TestSize = 0 then - Check( FCiphertext.Size = 0, - Format( '%s fails the zero test!', [FCodec.Cipher])); - if not Ok then break - end -end; - - - -procedure TBlockMode_TestCase.NormalizeKeyStream; -begin -end; - - -procedure TBlockMode_TestCase.SetUp; -var - Codec_TestAccess: ICodec_TestAccess; - s: utf8string; -begin -FLib := TCryptographicLibrary.Create( nil); -FLib.RegisterBlockChainingModel( TPure_ECB.Create as IBlockChainingModel); - - -FCodec := TCodec.Create( nil); -FCodec.CryptoLibrary := FLib; -FCodec.StreamCipherId := 'native.StreamToBlock'; -FCodec.BlockCipherId := CipherId; -FCodec.ChainModeId := sPure_ECB_Id; - -FOriginal := TMemoryStream.Create; -FCiphertext := TMemoryStream.Create; -FKeyStream := TMemoryStream.Create; -FReferenceStream := TMemoryStream.Create; - -if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and - (Codec_TestAccess.GetCodecIntf.BlockCipher <> nil) then - with Codec_TestAccess.GetCodecIntf.BlockCipher do - begin - FFeatures := Features; - FBlockSize := BlockSize div 8; - {$WARNINGS OFF} - Read_BigEndien_u32_Hex( SelfTest_Key , FKeyStream); - FKeyStream.Position := 0; - NormalizeKeyStream; - FKeyStream.Position := 0; - s := SelfTest_Plaintext; - Read_BigEndien_u32_Hex( s , FOriginal); - // Original MUST be an exact multiple (probably 1) of the block size. - s := SelfTest_Ciphertext; - Read_BigEndien_u32_Hex( s, FReferenceStream) - {$WARNINGS ON} - end - else - begin - FFeatures := [afNotImplementedYet]; - FBlockSize := 1 - end -end; - - - -procedure TBlockMode_TestCase.TearDown; -begin -FCodec.Free; -FLib.Free; -FOriginal.Free; -FCiphertext.Free; -FKeyStream.Free; -FReferenceStream.Free -end; - - - -procedure TBlockMode_TestCase.Test_Reference; -begin -if FOriginal.Size = 0 then exit; // Reference test not available. -Check( not (afNotImplementedYet in FFeatures), - Format( '%s is not yet implemented!', [FCodec.Cipher])); -FKeyStream.Position := 0; -FCodec.InitFromStream( FKeyStream); -FCodec.EncryptStream( FOriginal, FCiphertext); -Check( CompareMemoryStreams( FCiphertext, FReferenceStream), - Format( '%s fails the reference check!', [FCodec.Cipher])) -end; - - - -{ TAES_Reference_TestCase } - -class function TAES_Reference_TestCase.CipherId: string; -begin -result := Format( 'native.AES-%d', [KeySize]) -end; - -{ TAES128_RefTestCase } - -class function TAES128_RefTestCase.KeySize: integer; -begin -result := 128 -end; - -{ TAES192_RefTestCase } - -class function TAES192_RefTestCase.KeySize: integer; -begin -result := 192 -end; - -{ TAES256_RefTestCase } - -class function TAES256_RefTestCase.KeySize: integer; -begin -result := 256 -end; - - - -{ TStreamModeInversion_TestCase } - -procedure TStreamModeInversion_TestCase.SetUp; -var - Codec_TestAccess: ICodec_TestAccess; -begin -FLib := TCryptographicLibrary.Create( nil); -FCodec := TCodec.Create( nil); -FCodec.CryptoLibrary := FLib; -FCodec.StreamCipherId := CipherId; - -FOriginal := TMemoryStream.Create; -FCiphertext := TMemoryStream.Create; -FReconstructed := TMemoryStream.Create; - -if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and - (Codec_TestAccess.GetCodecIntf.StreamCipher <> nil) then - with Codec_TestAccess.GetCodecIntf.StreamCipher do - FFeatures := Features - else - FFeatures := [afNotImplementedYet]; -FCodec.Password := 'Fancy pants'; -end; - - - -procedure TStreamModeInversion_TestCase.TearDown; -begin -FLib.Free; -FCodec.Free; -FOriginal.Free; -FCiphertext.Free; -FReconstructed.Free -end; - - -procedure TStreamModeInversion_TestCase.GeneralInversionTest; -var - MinBytes, MaxBytes: integer; - TestSize: integer; - j: integer; - Ok: boolean; -begin -TestSizeRange( MinBytes, MaxBytes); -for j := 1 to 100 do - begin - TRandomStream.Instance.Read( TestSize, SizeOf( TestSize)); - TestSize := (abs( TestSize) mod (MaxBytes - MinBytes + 1)) + MinBytes; - FOriginal.Size := TestSize; - RandomFillStream( FOriginal); - FCiphertext.Size := 0; - FCodec.EncryptStream( FOriginal, FCiphertext); - FCodec.Reset; - FReconstructed.Size := 0; - FCodec.DecryptStream( FReconstructed, FCiphertext); - FCodec.Reset; - Ok := CompareMemoryStreams( FOriginal, FReconstructed); - Check( Ok, - Format( '%s fails the general inversion test!', [FCodec.Cipher])); - Check( (FCiphertext.Size >= FOriginal.Size) or - (([afCompressor,afConverter]*FFeatures) <> []), - 'Suspicious size of ciphertext.'); - if not Ok then break - end -end; - - -{ TBase64Inversion_TestCase } - -class function TBase64_TestCases.CipherId: string; -begin -result := 'native.base64' -end; - -procedure TBase64_TestCases.SetUp; -const -{$IF CompilerVersion > 19} - MarksVector: rawbytestring = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + - #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; -{$ELSE} - MarksVector: utf8string = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + - #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; -{$IFEND} -begin -inherited; -FKAT_Source := TMemoryStream.Create; -FKAT_Source.WriteBuffer( MarksVector[1], Length( MarksVector)); -FKAT_Source.Position := 0 -end; - - -procedure TBase64_TestCases.Marks_KAT; -// Thanks to Mark for supplying this KAT. -// (Mark is user name odie34 on the lockbox forums). -begin -Check( Stream_to_Base64( FKAT_Source) = 'HfNxLey+A3eHHIC4W/3+isd107E=', - 'Mark''s KAT for base64 failed.'); -end; - -procedure TBase64_TestCases.TearDown; -begin -FKAT_Source.Free; -inherited -end; - -class procedure TBase64_TestCases.TestSizeRange( - var MinBytes, MaxBytes: integer); -begin -MinBytes := 0; -MaxBytes := 200 -end; - - - -{ TDES_TestCase } - -procedure TDES_TestCase.PC1; -var - K, res: uint64; -begin -//K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 (big-endien) -{$IF compilerversion <= 15} - // Delphi 7 case. -K := {}uint64( -$0E20436486A8CBED){}; // Little-endien encoding. -{$ELSE} -K := $F1DFBC9B79573413; // Little-endien encoding. -{$IFEND} - -res := PC_1( K); -//K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111 (big-endien 7-bit "rows") -// = 11110000 11001100 10101010 11110101 01010110 01100111 10001111 00000000 (little-endien 8-bit bytes) -// = F0 CC AA F5 56 67 8F 00 (big-endien) -// = -Check( res = $008F6756F5AACCF0, // Little-endien encoding. - 'PC-1 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') -end; - -const -{$IF compilerversion <= 15} - // Delphi 7 case. - IP_M: uint64 = {}uint64( -$1032547698BADCFF){}; -{$ELSE} - IP_M: uint64 = $EFCDAB8967452301; -{$IFEND} - IP_L: uint32 = $FFCC00CC; - IP_R: uint32 = $AAF0AAF0; - -procedure TDES_TestCase.IP; -var - Datum: uint64; - L, R: uint32; -begin -//M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (big-endien) -Datum := IP_M; // Little-endien encoding. -IP_Transform( Datum, L, R); -//IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) -// L = 1100 1100 0000 0000 1100 1100 1111 1111 (big-endien) -// R = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) -Check( L = IP_L, 'IP.L J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); -Check( R = IP_R, 'IP.R J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') -end; - - - - -procedure TDES_TestCase.Inverse_IP; -var - L, R: uint32; - Datum: uint64; -begin -L := IP_L; -R := IP_R; -IP_InverseTransform( L, R, Datum); -Check( Datum = IP_M, - 'INV-IP J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); -end; - - -procedure TDES_TestCase.PC2; -var - L, R: uint32; - K: uint64; -const - TestMsg = 'PC-2 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'; -begin -// Test C1D1 --> K1 -// C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (big-endien, 7-bit "rows") - // C1 = 1110000110011001010101011111 (big-endien 28) - // C1 = 11100001100110010101010111110000 (big-endien 32) - // C1 = 1110 0001 | 1001 1001 | 0101 0101 | 1111 0000 (big-endien 32) - // C1 = 1111 0000 | 0101 0101 | 1001 1001 | 1110 0001 (little-endien 32) - // = $F05599E1 (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) - // D1 = 1010101011001100111100011110 (big-endien 28) - // = $E0F1CCAA (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) -L := $F05599E1; // Little-endien encoding. -R := $E0F1CCAA; // Little-endien encoding. -K := TPLB3.DES.PC_2( L, R); -// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien, 6-bit "rows") -Check( K = $3201073F2F0B3006, TestMsg); - -// Test C2D2 --> K2 -L := $F0AB32C3; -R := $D0E39955; -K := TPLB3.DES.PC_2( L, R); -Check( K = $25273C36193B1A1E, TestMsg) -end; - - - - -procedure TDES_TestCase.YourLipsAreSmoother; -var - PlaintextStr, Recon: utf8string; - Key: uint64; - Ex: TExpandedKey; - Plaintext: uint64; - Ciphertext: uint64; - - procedure CheckOneBlock( BlockIdx: integer; Expected: uint64); - begin - Move( PlaintextStr[ BlockIdx * 8 + 1], Plaintext, 8); - TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Ex); - Check( Ciphertext = Expected, Format('Your lips are smoother than ' + - 'vaseline [%d]',[BlockIdx])) - end; - -begin -// Case data from preliminary example of http://orlingrabbe.com/des.htm -PlaintextStr := 'Your lips are smoother than vaseline'#13#10#0#0; -SetLength( Recon, Length( PlaintextStr)); -Key := $730D6DEA3292320E; -TPLB3.DES.ExpandKey( Key, Ex); -{$IF compilerversion <= 15} - // Delphi 7 case. -CheckOneBlock( 0, {}uint64( -$1228871C22606640){}); -CheckOneBlock( 1, {}uint64( -$117BA535F45F828E){}); -CheckOneBlock( 2, {}uint64( -$6F7EBC295B960DB9){}); -CheckOneBlock( 3, {}uint64( -$667BCA0A87D02A27){}); - // Orlan says $998435F5782FD59D - // but I think this is wrong. -CheckOneBlock( 4, {}uint64( $53E6E053B4C98A82){}); -uTPLb_DES.DES_DecryptBlock( {}uint64( -$1228871C22606640){}, Plaintext, Ex); -Move( Plaintext, Recon[1], 8); -uTPLb_DES.DES_DecryptBlock( {}uint64( -$117BA535F45F828E){}, Plaintext, Ex); -Move( Plaintext, Recon[9], 8); -uTPLb_DES.DES_DecryptBlock( {}uint64( -$6F7EBC295B960DB9){}, Plaintext, Ex); -Move( Plaintext, Recon[17], 8); -uTPLb_DES.DES_DecryptBlock( {}uint64( -$667BCA0A87D02A27){}, Plaintext, Ex); -Move( Plaintext, Recon[25], 8); -uTPLb_DES.DES_DecryptBlock( {}uint64( $53E6E053B4C98A82){}, Plaintext, Ex); - -{$ELSE} -CheckOneBlock( 0, $EDD778E3DD9F99C0); -CheckOneBlock( 1, $EE845ACA0BA07D72); -CheckOneBlock( 2, $908143D6A469F247); -CheckOneBlock( 3, $998435F5782FD5D9); // Orlan says $998435F5782FD59D - // but I think this is wrong. -CheckOneBlock( 4, $53E6E053B4C98A82); -TPLB3.DES.DES_DecryptBlock( $EDD778E3DD9F99C0, Plaintext, Ex); -Move( Plaintext, Recon[1], 8); -TPLB3.DES.DES_DecryptBlock( $EE845ACA0BA07D72, Plaintext, Ex); -Move( Plaintext, Recon[9], 8); -TPLB3.DES.DES_DecryptBlock( $908143D6A469F247, Plaintext, Ex); -Move( Plaintext, Recon[17], 8); -TPLB3.DES.DES_DecryptBlock( $998435F5782FD5D9, Plaintext, Ex); -Move( Plaintext, Recon[25], 8); -TPLB3.DES.DES_DecryptBlock( $53E6E053B4C98A82, Plaintext, Ex); -{$IFEND} - -Move( Plaintext, Recon[33], 8); -SetLength( Recon, 38); -Check( Recon = 'Your lips are smoother than vaseline'#13#10, - 'Inverse: Your lips are smoother than vaseline') -end; - - - -procedure TDES_TestCase.EncryptBlock; -var - Plaintext: uint64; - Ciphertext: uint64; - Key: TExpandedKey; -begin -// M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 -Plaintext := IP_M; -Key[ 0] := $3201073F2F0B3006; -Key[ 1] := $25273C36193B1A1E; -Key[ 2] := $193E2C100A321F15; -Key[ 3] := $1D14333616372A1C; -Key[ 4] := $280E353A07300E1F; -Key[ 5] := $2F2C07143E143A18; -Key[ 6] := $3C22213D3712083B; -Key[ 7] := $3B2F13303A28383D; -Key[ 8] := $011E1E3B2B2F0D38; -Key[ 9] := $0F19242E070D1F2C; -Key[10] := $060E2D37133F1508; -Key[11] := $291F06253507171D; -Key[12] := $01292B3E11173C25; -Key[13] := $3A1C2E3C370E3417; -Key[14] := $0A3C130F0D06392F; -Key[15] := $351F21030B363332; -TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Key); -Check( Ciphertext = $05B40A0F5413E885, 'DES_EncryptBlock'); -TPLB3.DES.DES_DecryptBlock( Ciphertext, Plaintext, Key); -Check( Plaintext = IP_M, 'DES_DecryptBlock'); -end; - - -procedure TDES_TestCase.ExpandKey; -var - Key: uint64; - Ex: TExpandedKey; - R: uint32; - E: uint64; - - procedure CheckI( Idx: integer; Expected: uint64); - begin - Check( Ex[ Idx] = Expected, - Format( 'DES ExpandKey[%d]; Should have be' + - 'en $%x, but got $%x',[ Idx, Expected, Ex[ Idx]])) - end; - -begin -R := $AAF0AAF0; -E := E_Bit_Selection( R); - -{$IF compilerversion <= 15} - // Delphi 7 case. -Check( E = {}uint64( $1515211E1515211E){}, 'E-Bit'); -Key := {}uint64( -$0E20436486A8CBED){}; -uTPLb_DES.ExpandKey( Key, Ex); - -// Done: -// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) -CheckI( 0, {}uint64( $3201073F2F0B3006){}); -// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) -CheckI( 1, {}uint64( $25273C36193B1A1E){}); -// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 -CheckI( 2, {}uint64( $193E2C100A321F15){}); -// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 -CheckI( 3, {}uint64( $1D14333616372A1C){}); -// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 -CheckI( 4, {}uint64( $280E353A07300E1F){}); -// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 -CheckI( 5, {}uint64( $2F2C07143E143A18){}); -// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 -CheckI( 6, {}uint64( $3C22213D3712083B){}); -// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 -CheckI( 7, {}uint64( $3B2F13303A28383D){}); -// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 -CheckI( 8, {}uint64( $011E1E3B2B2F0D38){}); -// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 -CheckI( 9, {}uint64( $0F19242E070D1F2C){}); -// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 -CheckI( 10, {}uint64( $060E2D37133F1508){}); -// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 -CheckI( 11, {}uint64( $291F06253507171D){}); -// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 -CheckI( 12, {}uint64( $01292B3E11173C25){}); -// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 -CheckI( 13, {}uint64( $3A1C2E3C370E3417){}); -// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 -CheckI( 14, {}uint64( $0A3C130F0D06392F){}); -// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 -CheckI( 15, {}uint64( $351F21030B363332){}) - -{$ELSE} -Check( E = $1515211E1515211E, 'E-Bit'); -Key := $F1DFBC9B79573413; -TPLB3.DES.ExpandKey( Key, Ex); - -// Done: -// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) -CheckI( 0, $3201073F2F0B3006); -// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) -CheckI( 1, $25273C36193B1A1E); -// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 -CheckI( 2, $193E2C100A321F15); -// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 -CheckI( 3, $1D14333616372A1C); -// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 -CheckI( 4, $280E353A07300E1F); -// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 -CheckI( 5, $2F2C07143E143A18); -// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 -CheckI( 6, $3C22213D3712083B); -// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 -CheckI( 7, $3B2F13303A28383D); -// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 -CheckI( 8, $011E1E3B2B2F0D38); -// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 -CheckI( 9, $0F19242E070D1F2C); -// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 -CheckI( 10, $060E2D37133F1508); -// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 -CheckI( 11, $291F06253507171D); -// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 -CheckI( 12, $01292B3E11173C25); -// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 -CheckI( 13, $3A1C2E3C370E3417); -// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 -CheckI( 14, $0A3C130F0D06392F); -// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 -CheckI( 15, $351F21030B363332) -{$IFEND} -end; - - - - -{ TDES_Reference_TestCase } - -class function TDES_Reference_TestCase.CipherId: string; -begin -result := DES_ProgId -end; - -procedure TDES_Reference_TestCase.NormalizeKeyStream; -var - NativeKey: uint64; -begin -FKeyStream.Read( NativeKey, 8); -FKeyStream.Position := 0; -SetParityBitsOnKey( NativeKey); -FKeyStream.Write( NativeKey, 8) -end; - - -class function T3DES_Reference_TestCase.CipherId: string; -begin -result := TripleDES_ProgId -end; - - - -class function TBlowfish_Reference_TestCase.CipherId: string; -begin -result := Blowfish_ProgId -end; - - -class function TTwofish_Reference_TestCase.CipherId: string; -begin -result := Twofish_ProgId -end; - - - -procedure TTwofish_Reference_TestCase.TwoFishPrimitives; -var - Key: TBytes; - Size: longword; - SubKeys: TSubKeys; - SBox: TSBox; - InData, OutData, RefOutData: T128; - I: integer; -begin -DCP_towfish_Precomp; -// This data from http://www.schneier.com/code/ecb_ival.txt -//KEYSIZE=128 -Size := 16; -SetLength( Key, Size); - -RefOutData[0] := $5C9F589F; // at I=1, CT=9F589F5CF6122C32B6BFEC2F2AE8C35A -RefOutData[1] := $322C12F6; -RefOutData[2] := $2FECBFB6; -RefOutData[3] := $5AC3E82A; - -FillChar( Key[0], Size, 0); -FillChar( InData, SizeOf( InData), 0); -for I := 1 to 49 do - begin - if I >= 2 then - begin - Move( InData , Key[0], 16); - Move( OutData, InData, 16) - end; - DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); - DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); - if I = 1 then - Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), - 'LockBox TwoFish primitives failed the 128 reference test at I=1. ' + - '(http://www.schneier.com/code/ecb_ival.txt)'); - end; - -RefOutData[0] := $EF4E9D5D; // at I=49, CT=5D9D4EEFFA9151575524F115815A12E0 -RefOutData[1] := $575191FA; -RefOutData[2] := $15F12455; -RefOutData[3] := $E0125A81; - -Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), - 'LockBox TwoFish primitives failed the 128 reference test at I=49. ' + - '(http://www.schneier.com/code/ecb_ival.txt)'); - - -//KEYSIZE=192 -//I=1 -//KEY=000000000000000000000000000000000000000000000000 -//PT=00000000000000000000000000000000 -//I=49 -//CT=E75449212BEEF9F4A390BD860A640941 -Size := 24; -SetLength( Key, Size); - -RefOutData[0] := $214954E7; // at I=49, CT=E75449212BEEF9F4A390BD860A640941 -RefOutData[1] := $F4F9EE2B; -RefOutData[2] := $86BD90A3; -RefOutData[3] := $4109640A; - -FillChar( Key[0], Size, 0); -FillChar( InData, SizeOf( InData), 0); -for I := 1 to 49 do - begin - if I >= 2 then - begin - Move( Key[0] , Key[16], Size-16); - Move( InData , Key[0], 16); - Move( OutData, InData, 16) - end; - DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); - DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); - end; -Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), - 'LockBox TwoFish primitives failed the 192 reference test at I=49. ' + - '(http://www.schneier.com/code/ecb_ival.txt)'); - -//KEYSIZE=256 -//I=1 -//KEY=0000000000000000000000000000000000000000000000000000000000000000 -//PT=00000000000000000000000000000000 -//I=49 -//CT=37FE26FF1CF66175F5DDF4C33B97A205 -Size := 32; -SetLength( Key, Size); - -RefOutData[0] := $FF26FE37; // at I=49, CT=37FE26FF1CF66175F5DDF4C33B97A205 -RefOutData[1] := $7561F61C; -RefOutData[2] := $C3F4DDF5; -RefOutData[3] := $05A2973B; - -FillChar( Key[0], Size, 0); -FillChar( InData, SizeOf( InData), 0); -for I := 1 to 49 do - begin - if I >= 2 then - begin - Move( Key[0] , Key[16], Size-16); - Move( InData , Key[0], 16); - Move( OutData, InData, 16) - end; - DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); - DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); - end; -Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), - 'LockBox TwoFish primitives failed the 256 reference test at I=49. ' + - '(http://www.schneier.com/code/ecb_ival.txt)'); - -end; - - - - -{ T3DES_KO1_Reference_TestCase } - -class function T3DES_KO1_Reference_TestCase.CipherId: string; -begin -result := TripleDES_KO1_ProgId -end; - - -procedure T3DES_Reference_TestCase.NormalizeKeyStream; -var - NativeKey: uint64; - SubKey: integer; -begin -for SubKey := 1 to 2 do - begin - FKeyStream.Position := (SubKey - 1) * 8; - if FKeyStream.Read( NativeKey, 8) < 8 then break; - FKeyStream.Position := (SubKey - 1) * 8; - SetParityBitsOnKey( NativeKey); - FKeyStream.Write( NativeKey, 8) - end -end; - - -procedure T3DES_KO1_Reference_TestCase.NormalizeKeyStream; -var - NativeKey: uint64; - SubKey: integer; -begin -for SubKey := 1 to 3 do - begin - FKeyStream.Position := (SubKey - 1) * 8; - if FKeyStream.Read( NativeKey, 8) < 8 then break; - FKeyStream.Position := (SubKey - 1) * 8; - SetParityBitsOnKey( NativeKey); - FKeyStream.Write( NativeKey, 8) - end -end; - -{ TMasBug_TestCase } - -procedure TMasBug_TestCase.SetUp; -begin -FRand := TRandomStream.Instance ; -Len := 32; -GetMem( P, Len); -end; - -procedure TMasBug_TestCase.TearDown; -begin -FreeMem( P, Len) -end; - - - -procedure TMasBug_TestCase.Mas_RandomStream_Bug; -var - j: Integer; - PreviousFirstByte: byte; - CollisionCount: integer; -begin -FRand.Randomize; -CollisionCount := 0; -PreviousFirstByte := 0; -for j := 1 to 20 do - begin - FRand.Read( P^, Len); - if (j >= 2) and (PreviousFirstByte = P^) then - Inc( CollisionCount); - PreviousFirstByte := P^ - end; -Check( CollisionCount < 4, 'Random number generator is suspect.') -end; - - - - -initialization -InitUnit_CipherTestCases; - - -finalization -DoneUnit_CipherTestCases; - - -end. +unit uLockBox_CipherTestCases; +interface + +uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, uLockBox_TestCases, TPLB3.Random; + +type + + +TBlockSizeCase = ( + scZero, // size = 0 + scSmall, // size ~= 0.3 blocks + scUnit, // size = 1 block + scSmallish, // size = 1.5 blocks + scRough, // size = large N + about 0.1 blocks + scRound); // size = exactly N blocks. N is a large number. + + +TBlockMode_TestCase = class( TTestCase) + protected + FLib: TCryptographicLibrary; + FCodec: TCodec; + FOriginal : TMemoryStream; + FCiphertext : TMemoryStream; + FKeyStream : TMemoryStream; + FReferenceStream : TMemoryStream; + FBlockSize: integer; + FFeatures: TAlgorithmicFeatureSet; + + procedure SetUp; override; + procedure TearDown; override; + class function CipherId: string; virtual; abstract; + procedure NormalizeKeyStream; virtual; + + procedure InversionTest( DataSize: TBlockSizeCase; const ChainMode: string); + + published + procedure Test_Reference; + procedure GeneralInversionTests; + end; + + +TAES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function KeySize: integer; virtual; abstract; + class function CipherId: string; override; + end; + + +TAES128_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + end; + +TAES192_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + end; + +TAES256_RefTestCase = class( TAES_Reference_TestCase) + protected + class function KeySize: integer; override; + end; + + + +TStreamModeInversion_TestCase = class( TTestCase) + protected + FLib: TCryptographicLibrary; + FCodec: TCodec; + FOriginal : TMemoryStream; + FCiphertext : TMemoryStream; + FReconstructed : TMemoryStream; + FFeatures: TAlgorithmicFeatureSet; + + procedure SetUp; override; + procedure TearDown; override; + class function CipherId: string; virtual; abstract; + class procedure TestSizeRange( var MinBytes, MaxBytes: integer); virtual; abstract; + + published + procedure GeneralInversionTest; virtual; + end; + + +TBase64_TestCases = class( TStreamModeInversion_TestCase) + private + FKAT_Source :TStream; + + protected + procedure SetUp; override; + procedure TearDown; override; + class function CipherId: string; override; + class procedure TestSizeRange( var MinBytes, MaxBytes: integer); override; + + published + procedure Marks_KAT; + end; + + + +TDES_TestCase = class( TTestCase) + published + procedure PC1; + procedure PC2; + procedure IP; + procedure Inverse_IP; + procedure ExpandKey; + procedure EncryptBlock; + procedure YourLipsAreSmoother; + end; + + +TDES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + end; + +T3DES_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + end; + +T3DES_KO1_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + procedure NormalizeKeyStream; override; + end; + +TBlowfish_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + end; + +TTwofish_Reference_TestCase = class( TBlockMode_TestCase) + protected + class function CipherId: string; override; + published + procedure TwoFishPrimitives; + end; + + +TMasBug_TestCase = class( TTestCase) + protected + FRand: TRandomStream; + P: PByte; + Len: integer; + + procedure SetUp; override; + procedure TearDown; override; + + published + procedure Mas_RandomStream_Bug; + end; +implementation + + + + + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.DES, TPLB3.Constants, + TPLB3.DCP.twofish_Modified, TPLB3.Compatibility; + + +{ TTestCaseFirst } + + +procedure InitUnit_CipherTestCases; +begin +TestFramework.RegisterTest( TAES128_RefTestCase.Suite); +TestFramework.RegisterTest( TAES192_RefTestCase.Suite); +TestFramework.RegisterTest( TAES256_RefTestCase.Suite); +TestFramework.RegisterTest( TBase64_TestCases.Suite); +TestFramework.RegisterTest( 'DES.Basic DES', TDES_TestCase.Suite); +TestFramework.RegisterTest( 'DES.Basic DES', TDES_Reference_TestCase.Suite); +TestFramework.RegisterTest( 'DES.3DES.KO2', T3DES_Reference_TestCase.Suite); +TestFramework.RegisterTest( 'DES.3DES.KO1', T3DES_KO1_Reference_TestCase.Suite); +TestFramework.RegisterTest( TBlowfish_Reference_TestCase.Suite); +TestFramework.RegisterTest( TTwofish_Reference_TestCase.Suite); +TestFramework.RegisterTest( TMasBug_TestCase.Suite); +end; + +procedure DoneUnit_CipherTestCases; +begin +end; + + + + + + +const sPure_ECB_Id = 'dunit.ECB'; + +type TPure_ECB = class( TECB) + protected + function ChainingFeatures: TChainingFeatureSet; override; + function ProgId: string; override; + end; + +function TPure_ECB.ChainingFeatures: TChainingFeatureSet; +begin +result := inherited ChainingFeatures + [cfKeyStream] +// The inclusion of cfKeyStream disables block padding. +// We can only use this class in situations where be plaintext size +// is an exact multiple of the block size. +end; + +function TPure_ECB.ProgId: string; +begin +result := sPure_ECB_Id +end; + + + +{ TStreamModeReference_TestCase } + +procedure TBlockMode_TestCase.GeneralInversionTests; + procedure TestChainMode( const ChainMode: string); + var + j: TBlockSizeCase; + begin + for j := Low( TBlockSizeCase) to High( TBlockSizeCase) do + InversionTest( j, ChainMode) + end; + +begin +TestChainMode( 'native.ECB'); +TestChainMode( 'native.CBC'); +TestChainMode( 'native.CFB'); +TestChainMode( 'native.CTR'); +TestChainMode( 'native.OFB'); +TestChainMode( 'native.CFB-8bit'); +TestChainMode( 'native.PCBC') +end; + + + +procedure TBlockMode_TestCase.InversionTest( + DataSize: TBlockSizeCase; const ChainMode: string); +var + TestSize, TestsCount: integer; + j: integer; + Ok: boolean; + + function RandomSizableNumber: integer; + begin + TRandomStream.Instance.Read( result, SizeOf( result)); + result := (abs( result) mod 200) + 50 + end; + +begin +FCodec.ChainModeId := ChainMode; +FCodec.Password := 'Monkey''s uncle'; +TestSize := 0; +TestsCount := 0; +case DataSize of + scZero: begin + TestSize := 0; + TestsCount := 1 + end; + + scSmall: begin + TestSize := Round( FBlockSize * 0.3); + TestsCount := 1 + end; + + scUnit: begin + TestSize := FBlockSize; + TestsCount := 1 + end; + + scSmallish: begin + TestSize := Round( FBlockSize * 1.5); + TestsCount := 10 + end; + + scRough: begin + TestSize := (RandomSizableNumber * FBlockSize) + RandomSizableNumber; + TestsCount := 100 + end; + + scRound: begin + TestSize := RandomSizableNumber * FBlockSize; + TestsCount := 10 + end; + end; +for j := 1 to TestsCount do + begin + FOriginal.Size := TestSize; + RandomFillStream( FOriginal); + FCiphertext.Size := 0; + FCodec.EncryptStream( FOriginal, FCiphertext); + FCodec.Reset; + FReferenceStream.Size := 0; + FCodec.DecryptStream( FReferenceStream, FCiphertext); + FCodec.Reset; + Ok := CompareMemoryStreams( FOriginal, FReferenceStream); + Check( Ok, + Format( '%s fails the general inversion test!', [FCodec.Cipher])); + if TestSize = 0 then + Check( FCiphertext.Size = 0, + Format( '%s fails the zero test!', [FCodec.Cipher])); + if not Ok then break + end +end; + + + +procedure TBlockMode_TestCase.NormalizeKeyStream; +begin +end; + + +procedure TBlockMode_TestCase.SetUp; +var + Codec_TestAccess: ICodec_TestAccess; + s: utf8string; +begin +FLib := TCryptographicLibrary.Create( nil); +FLib.RegisterBlockChainingModel( TPure_ECB.Create as IBlockChainingModel); + + +FCodec := TCodec.Create( nil); +FCodec.CryptoLibrary := FLib; +FCodec.StreamCipherId := 'native.StreamToBlock'; +FCodec.BlockCipherId := CipherId; +FCodec.ChainModeId := sPure_ECB_Id; + +FOriginal := TMemoryStream.Create; +FCiphertext := TMemoryStream.Create; +FKeyStream := TMemoryStream.Create; +FReferenceStream := TMemoryStream.Create; + +if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and + (Codec_TestAccess.GetCodecIntf.BlockCipher <> nil) then + with Codec_TestAccess.GetCodecIntf.BlockCipher do + begin + FFeatures := Features; + FBlockSize := BlockSize div 8; + {$WARNINGS OFF} + Read_BigEndien_u32_Hex( SelfTest_Key , FKeyStream); + FKeyStream.Position := 0; + NormalizeKeyStream; + FKeyStream.Position := 0; + s := SelfTest_Plaintext; + Read_BigEndien_u32_Hex( s , FOriginal); + // Original MUST be an exact multiple (probably 1) of the block size. + s := SelfTest_Ciphertext; + Read_BigEndien_u32_Hex( s, FReferenceStream) + {$WARNINGS ON} + end + else + begin + FFeatures := [afNotImplementedYet]; + FBlockSize := 1 + end +end; + + + +procedure TBlockMode_TestCase.TearDown; +begin +FCodec.Free; +FLib.Free; +FOriginal.Free; +FCiphertext.Free; +FKeyStream.Free; +FReferenceStream.Free +end; + + + +procedure TBlockMode_TestCase.Test_Reference; +begin +if FOriginal.Size = 0 then exit; // Reference test not available. +Check( not (afNotImplementedYet in FFeatures), + Format( '%s is not yet implemented!', [FCodec.Cipher])); +FKeyStream.Position := 0; +FCodec.InitFromStream( FKeyStream); +FCodec.EncryptStream( FOriginal, FCiphertext); +Check( CompareMemoryStreams( FCiphertext, FReferenceStream), + Format( '%s fails the reference check!', [FCodec.Cipher])) +end; + + + +{ TAES_Reference_TestCase } + +class function TAES_Reference_TestCase.CipherId: string; +begin +result := Format( 'native.AES-%d', [KeySize]) +end; + +{ TAES128_RefTestCase } + +class function TAES128_RefTestCase.KeySize: integer; +begin +result := 128 +end; + +{ TAES192_RefTestCase } + +class function TAES192_RefTestCase.KeySize: integer; +begin +result := 192 +end; + +{ TAES256_RefTestCase } + +class function TAES256_RefTestCase.KeySize: integer; +begin +result := 256 +end; + + + +{ TStreamModeInversion_TestCase } + +procedure TStreamModeInversion_TestCase.SetUp; +var + Codec_TestAccess: ICodec_TestAccess; +begin +FLib := TCryptographicLibrary.Create( nil); +FCodec := TCodec.Create( nil); +FCodec.CryptoLibrary := FLib; +FCodec.StreamCipherId := CipherId; + +FOriginal := TMemoryStream.Create; +FCiphertext := TMemoryStream.Create; +FReconstructed := TMemoryStream.Create; + +if Supports( FCodec, ICodec_TestAccess, Codec_TestAccess) and + (Codec_TestAccess.GetCodecIntf.StreamCipher <> nil) then + with Codec_TestAccess.GetCodecIntf.StreamCipher do + FFeatures := Features + else + FFeatures := [afNotImplementedYet]; +FCodec.Password := 'Fancy pants'; +end; + + + +procedure TStreamModeInversion_TestCase.TearDown; +begin +FLib.Free; +FCodec.Free; +FOriginal.Free; +FCiphertext.Free; +FReconstructed.Free +end; + + +procedure TStreamModeInversion_TestCase.GeneralInversionTest; +var + MinBytes, MaxBytes: integer; + TestSize: integer; + j: integer; + Ok: boolean; +begin +TestSizeRange( MinBytes, MaxBytes); +for j := 1 to 100 do + begin + TRandomStream.Instance.Read( TestSize, SizeOf( TestSize)); + TestSize := (abs( TestSize) mod (MaxBytes - MinBytes + 1)) + MinBytes; + FOriginal.Size := TestSize; + RandomFillStream( FOriginal); + FCiphertext.Size := 0; + FCodec.EncryptStream( FOriginal, FCiphertext); + FCodec.Reset; + FReconstructed.Size := 0; + FCodec.DecryptStream( FReconstructed, FCiphertext); + FCodec.Reset; + Ok := CompareMemoryStreams( FOriginal, FReconstructed); + Check( Ok, + Format( '%s fails the general inversion test!', [FCodec.Cipher])); + Check( (FCiphertext.Size >= FOriginal.Size) or + (([afCompressor,afConverter]*FFeatures) <> []), + 'Suspicious size of ciphertext.'); + if not Ok then break + end +end; + + +{ TBase64Inversion_TestCase } + +class function TBase64_TestCases.CipherId: string; +begin +result := 'native.base64' +end; + +procedure TBase64_TestCases.SetUp; +const +{$IF CompilerVersion > 19} + MarksVector: rawbytestring = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + + #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; +{$ELSE} + MarksVector: utf8string = #$1D#$F3#$71#$2D#$EC#$BE#$03#$77#$87#$1C + + #$80#$B8#$5B#$FD#$FE#$8A#$C7#$75#$D3#$B1; +{$IFEND} +begin +inherited; +FKAT_Source := TMemoryStream.Create; +FKAT_Source.WriteBuffer( MarksVector[1], Length( MarksVector)); +FKAT_Source.Position := 0 +end; + + +procedure TBase64_TestCases.Marks_KAT; +// Thanks to Mark for supplying this KAT. +// (Mark is user name odie34 on the lockbox forums). +begin +Check( Stream_to_Base64( FKAT_Source) = 'HfNxLey+A3eHHIC4W/3+isd107E=', + 'Mark''s KAT for base64 failed.'); +end; + +procedure TBase64_TestCases.TearDown; +begin +FKAT_Source.Free; +inherited +end; + +class procedure TBase64_TestCases.TestSizeRange( + var MinBytes, MaxBytes: integer); +begin +MinBytes := 0; +MaxBytes := 200 +end; + + + +{ TDES_TestCase } + +procedure TDES_TestCase.PC1; +var + K, res: uint64; +begin +//K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 (big-endien) +{$IF compilerversion <= 15} + // Delphi 7 case. +K := {}uint64( -$0E20436486A8CBED){}; // Little-endien encoding. +{$ELSE} +K := $F1DFBC9B79573413; // Little-endien encoding. +{$IFEND} + +res := PC_1( K); +//K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111 (big-endien 7-bit "rows") +// = 11110000 11001100 10101010 11110101 01010110 01100111 10001111 00000000 (little-endien 8-bit bytes) +// = F0 CC AA F5 56 67 8F 00 (big-endien) +// = +Check( res = $008F6756F5AACCF0, // Little-endien encoding. + 'PC-1 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') +end; + +const +{$IF compilerversion <= 15} + // Delphi 7 case. + IP_M: uint64 = {}uint64( -$1032547698BADCFF){}; +{$ELSE} + IP_M: uint64 = $EFCDAB8967452301; +{$IFEND} + IP_L: uint32 = $FFCC00CC; + IP_R: uint32 = $AAF0AAF0; + +procedure TDES_TestCase.IP; +var + Datum: uint64; + L, R: uint32; +begin +//M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (big-endien) +Datum := IP_M; // Little-endien encoding. +IP_Transform( Datum, L, R); +//IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) +// L = 1100 1100 0000 0000 1100 1100 1111 1111 (big-endien) +// R = 1111 0000 1010 1010 1111 0000 1010 1010 (big-endien) +Check( L = IP_L, 'IP.L J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); +Check( R = IP_R, 'IP.R J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.') +end; + + + + +procedure TDES_TestCase.Inverse_IP; +var + L, R: uint32; + Datum: uint64; +begin +L := IP_L; +R := IP_R; +IP_InverseTransform( L, R, Datum); +Check( Datum = IP_M, + 'INV-IP J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'); +end; + + +procedure TDES_TestCase.PC2; +var + L, R: uint32; + K: uint64; +const + TestMsg = 'PC-2 J. Orlin Grabbe (http://orlingrabbe.com/des.htm) example test datum failed.'; +begin +// Test C1D1 --> K1 +// C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (big-endien, 7-bit "rows") + // C1 = 1110000110011001010101011111 (big-endien 28) + // C1 = 11100001100110010101010111110000 (big-endien 32) + // C1 = 1110 0001 | 1001 1001 | 0101 0101 | 1111 0000 (big-endien 32) + // C1 = 1111 0000 | 0101 0101 | 1001 1001 | 1110 0001 (little-endien 32) + // = $F05599E1 (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) + // D1 = 1010101011001100111100011110 (big-endien 28) + // = $E0F1CCAA (Delphi, encoding by putting the 4 LSB of the 4th byte as zero.) +L := $F05599E1; // Little-endien encoding. +R := $E0F1CCAA; // Little-endien encoding. +K := TPLB3.DES.PC_2( L, R); +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (big-endien, 6-bit "rows") +Check( K = $3201073F2F0B3006, TestMsg); + +// Test C2D2 --> K2 +L := $F0AB32C3; +R := $D0E39955; +K := TPLB3.DES.PC_2( L, R); +Check( K = $25273C36193B1A1E, TestMsg) +end; + + + + +procedure TDES_TestCase.YourLipsAreSmoother; +var + PlaintextStr, Recon: utf8string; + Key: uint64; + Ex: TExpandedKey; + Plaintext: uint64; + Ciphertext: uint64; + + procedure CheckOneBlock( BlockIdx: integer; Expected: uint64); + begin + Move( PlaintextStr[ BlockIdx * 8 + 1], Plaintext, 8); + TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Ex); + Check( Ciphertext = Expected, Format('Your lips are smoother than ' + + 'vaseline [%d]',[BlockIdx])) + end; + +begin +// Case data from preliminary example of http://orlingrabbe.com/des.htm +PlaintextStr := 'Your lips are smoother than vaseline'#13#10#0#0; +SetLength( Recon, Length( PlaintextStr)); +Key := $730D6DEA3292320E; +TPLB3.DES.ExpandKey( Key, Ex); +{$IF compilerversion <= 15} + // Delphi 7 case. +CheckOneBlock( 0, {}uint64( -$1228871C22606640){}); +CheckOneBlock( 1, {}uint64( -$117BA535F45F828E){}); +CheckOneBlock( 2, {}uint64( -$6F7EBC295B960DB9){}); +CheckOneBlock( 3, {}uint64( -$667BCA0A87D02A27){}); + // Orlan says $998435F5782FD59D + // but I think this is wrong. +CheckOneBlock( 4, {}uint64( $53E6E053B4C98A82){}); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$1228871C22606640){}, Plaintext, Ex); +Move( Plaintext, Recon[1], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$117BA535F45F828E){}, Plaintext, Ex); +Move( Plaintext, Recon[9], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$6F7EBC295B960DB9){}, Plaintext, Ex); +Move( Plaintext, Recon[17], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( -$667BCA0A87D02A27){}, Plaintext, Ex); +Move( Plaintext, Recon[25], 8); +uTPLb_DES.DES_DecryptBlock( {}uint64( $53E6E053B4C98A82){}, Plaintext, Ex); + +{$ELSE} +CheckOneBlock( 0, $EDD778E3DD9F99C0); +CheckOneBlock( 1, $EE845ACA0BA07D72); +CheckOneBlock( 2, $908143D6A469F247); +CheckOneBlock( 3, $998435F5782FD5D9); // Orlan says $998435F5782FD59D + // but I think this is wrong. +CheckOneBlock( 4, $53E6E053B4C98A82); +TPLB3.DES.DES_DecryptBlock( $EDD778E3DD9F99C0, Plaintext, Ex); +Move( Plaintext, Recon[1], 8); +TPLB3.DES.DES_DecryptBlock( $EE845ACA0BA07D72, Plaintext, Ex); +Move( Plaintext, Recon[9], 8); +TPLB3.DES.DES_DecryptBlock( $908143D6A469F247, Plaintext, Ex); +Move( Plaintext, Recon[17], 8); +TPLB3.DES.DES_DecryptBlock( $998435F5782FD5D9, Plaintext, Ex); +Move( Plaintext, Recon[25], 8); +TPLB3.DES.DES_DecryptBlock( $53E6E053B4C98A82, Plaintext, Ex); +{$IFEND} + +Move( Plaintext, Recon[33], 8); +SetLength( Recon, 38); +Check( Recon = 'Your lips are smoother than vaseline'#13#10, + 'Inverse: Your lips are smoother than vaseline') +end; + + + +procedure TDES_TestCase.EncryptBlock; +var + Plaintext: uint64; + Ciphertext: uint64; + Key: TExpandedKey; +begin +// M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 +Plaintext := IP_M; +Key[ 0] := $3201073F2F0B3006; +Key[ 1] := $25273C36193B1A1E; +Key[ 2] := $193E2C100A321F15; +Key[ 3] := $1D14333616372A1C; +Key[ 4] := $280E353A07300E1F; +Key[ 5] := $2F2C07143E143A18; +Key[ 6] := $3C22213D3712083B; +Key[ 7] := $3B2F13303A28383D; +Key[ 8] := $011E1E3B2B2F0D38; +Key[ 9] := $0F19242E070D1F2C; +Key[10] := $060E2D37133F1508; +Key[11] := $291F06253507171D; +Key[12] := $01292B3E11173C25; +Key[13] := $3A1C2E3C370E3417; +Key[14] := $0A3C130F0D06392F; +Key[15] := $351F21030B363332; +TPLB3.DES.DES_EncryptBlock( Plaintext, Ciphertext, Key); +Check( Ciphertext = $05B40A0F5413E885, 'DES_EncryptBlock'); +TPLB3.DES.DES_DecryptBlock( Ciphertext, Plaintext, Key); +Check( Plaintext = IP_M, 'DES_DecryptBlock'); +end; + + +procedure TDES_TestCase.ExpandKey; +var + Key: uint64; + Ex: TExpandedKey; + R: uint32; + E: uint64; + + procedure CheckI( Idx: integer; Expected: uint64); + begin + Check( Ex[ Idx] = Expected, + Format( 'DES ExpandKey[%d]; Should have be' + + 'en $%x, but got $%x',[ Idx, Expected, Ex[ Idx]])) + end; + +begin +R := $AAF0AAF0; +E := E_Bit_Selection( R); + +{$IF compilerversion <= 15} + // Delphi 7 case. +Check( E = {}uint64( $1515211E1515211E){}, 'E-Bit'); +Key := {}uint64( -$0E20436486A8CBED){}; +uTPLb_DES.ExpandKey( Key, Ex); + +// Done: +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) +CheckI( 0, {}uint64( $3201073F2F0B3006){}); +// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) +CheckI( 1, {}uint64( $25273C36193B1A1E){}); +// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 +CheckI( 2, {}uint64( $193E2C100A321F15){}); +// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 +CheckI( 3, {}uint64( $1D14333616372A1C){}); +// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 +CheckI( 4, {}uint64( $280E353A07300E1F){}); +// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 +CheckI( 5, {}uint64( $2F2C07143E143A18){}); +// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 +CheckI( 6, {}uint64( $3C22213D3712083B){}); +// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 +CheckI( 7, {}uint64( $3B2F13303A28383D){}); +// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 +CheckI( 8, {}uint64( $011E1E3B2B2F0D38){}); +// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 +CheckI( 9, {}uint64( $0F19242E070D1F2C){}); +// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 +CheckI( 10, {}uint64( $060E2D37133F1508){}); +// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 +CheckI( 11, {}uint64( $291F06253507171D){}); +// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 +CheckI( 12, {}uint64( $01292B3E11173C25){}); +// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 +CheckI( 13, {}uint64( $3A1C2E3C370E3417){}); +// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 +CheckI( 14, {}uint64( $0A3C130F0D06392F){}); +// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 +CheckI( 15, {}uint64( $351F21030B363332){}) + +{$ELSE} +Check( E = $1515211E1515211E, 'E-Bit'); +Key := $F1DFBC9B79573413; +TPLB3.DES.ExpandKey( Key, Ex); + +// Done: +// K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (bigendien compact) +CheckI( 0, $3201073F2F0B3006); +// K2 = 011110 011010 111011 011001 110110 111100 100111 100101 (bigendien compact) +CheckI( 1, $25273C36193B1A1E); +// K3 = 010101 011111 110010 001010 010000 101100 111110 011001 +CheckI( 2, $193E2C100A321F15); +// K4 = 011100 101010 110111 010110 110110 110011 010100 011101 +CheckI( 3, $1D14333616372A1C); +// K5 = 011111 001110 110000 000111 111010 110101 001110 101000 +CheckI( 4, $280E353A07300E1F); +// K6 = 011000 111010 010100 111110 010100 000111 101100 101111 +CheckI( 5, $2F2C07143E143A18); +// K7 = 111011 001000 010010 110111 111101 100001 100010 111100 +CheckI( 6, $3C22213D3712083B); +// K8 = 111101 111000 101000 111010 110000 010011 101111 111011 +CheckI( 7, $3B2F13303A28383D); +// K9 = 111000 001101 101111 101011 111011 011110 011110 000001 +CheckI( 8, $011E1E3B2B2F0D38); +// K10 = 101100 011111 001101 000111 101110 100100 011001 001111 +CheckI( 9, $0F19242E070D1F2C); +// K11 = 001000 010101 111111 010011 110111 101101 001110 000110 +CheckI( 10, $060E2D37133F1508); +// K12 = 011101 010111 000111 110101 100101 000110 011111 101001 +CheckI( 11, $291F06253507171D); +// K13 = 100101 111100 010111 010001 111110 101011 101001 000001 +CheckI( 12, $01292B3E11173C25); +// K14 = 010111 110100 001110 110111 111100 101110 011100 111010 +CheckI( 13, $3A1C2E3C370E3417); +// K15 = 101111 111001 000110 001101 001111 010011 111100 001010 +CheckI( 14, $0A3C130F0D06392F); +// K16 = 110010 110011 110110 001011 000011 100001 011111 110101 +CheckI( 15, $351F21030B363332) +{$IFEND} +end; + + + + +{ TDES_Reference_TestCase } + +class function TDES_Reference_TestCase.CipherId: string; +begin +result := DES_ProgId +end; + +procedure TDES_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; +begin +FKeyStream.Read( NativeKey, 8); +FKeyStream.Position := 0; +SetParityBitsOnKey( NativeKey); +FKeyStream.Write( NativeKey, 8) +end; + + +class function T3DES_Reference_TestCase.CipherId: string; +begin +result := TripleDES_ProgId +end; + + + +class function TBlowfish_Reference_TestCase.CipherId: string; +begin +result := Blowfish_ProgId +end; + + +class function TTwofish_Reference_TestCase.CipherId: string; +begin +result := Twofish_ProgId +end; + + + +procedure TTwofish_Reference_TestCase.TwoFishPrimitives; +var + Key: TBytes; + Size: longword; + SubKeys: TSubKeys; + SBox: TSBox; + InData, OutData, RefOutData: T128; + I: integer; +begin +DCP_towfish_Precomp; +// This data from http://www.schneier.com/code/ecb_ival.txt +//KEYSIZE=128 +Size := 16; +SetLength( Key, Size); + +RefOutData[0] := $5C9F589F; // at I=1, CT=9F589F5CF6122C32B6BFEC2F2AE8C35A +RefOutData[1] := $322C12F6; +RefOutData[2] := $2FECBFB6; +RefOutData[3] := $5AC3E82A; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + if I = 1 then + Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), + 'LockBox TwoFish primitives failed the 128 reference test at I=1. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + end; + +RefOutData[0] := $EF4E9D5D; // at I=49, CT=5D9D4EEFFA9151575524F115815A12E0 +RefOutData[1] := $575191FA; +RefOutData[2] := $15F12455; +RefOutData[3] := $E0125A81; + +Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), + 'LockBox TwoFish primitives failed the 128 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + + +//KEYSIZE=192 +//I=1 +//KEY=000000000000000000000000000000000000000000000000 +//PT=00000000000000000000000000000000 +//I=49 +//CT=E75449212BEEF9F4A390BD860A640941 +Size := 24; +SetLength( Key, Size); + +RefOutData[0] := $214954E7; // at I=49, CT=E75449212BEEF9F4A390BD860A640941 +RefOutData[1] := $F4F9EE2B; +RefOutData[2] := $86BD90A3; +RefOutData[3] := $4109640A; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( Key[0] , Key[16], Size-16); + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + end; +Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), + 'LockBox TwoFish primitives failed the 192 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + +//KEYSIZE=256 +//I=1 +//KEY=0000000000000000000000000000000000000000000000000000000000000000 +//PT=00000000000000000000000000000000 +//I=49 +//CT=37FE26FF1CF66175F5DDF4C33B97A205 +Size := 32; +SetLength( Key, Size); + +RefOutData[0] := $FF26FE37; // at I=49, CT=37FE26FF1CF66175F5DDF4C33B97A205 +RefOutData[1] := $7561F61C; +RefOutData[2] := $C3F4DDF5; +RefOutData[3] := $05A2973B; + +FillChar( Key[0], Size, 0); +FillChar( InData, SizeOf( InData), 0); +for I := 1 to 49 do + begin + if I >= 2 then + begin + Move( Key[0] , Key[16], Size-16); + Move( InData , Key[0], 16); + Move( OutData, InData, 16) + end; + DCP_twofish_InitKey( Key[0], Size*8, SubKeys, SBox); + DCP_twofish_EncryptECB( SubKeys, SBox, InData, OutData); + end; +Check( CompareMem( @OutData, @RefOutData, SizeOf( T128)), + 'LockBox TwoFish primitives failed the 256 reference test at I=49. ' + + '(http://www.schneier.com/code/ecb_ival.txt)'); + +end; + + + + +{ T3DES_KO1_Reference_TestCase } + +class function T3DES_KO1_Reference_TestCase.CipherId: string; +begin +result := TripleDES_KO1_ProgId +end; + + +procedure T3DES_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; + SubKey: integer; +begin +for SubKey := 1 to 2 do + begin + FKeyStream.Position := (SubKey - 1) * 8; + if FKeyStream.Read( NativeKey, 8) < 8 then break; + FKeyStream.Position := (SubKey - 1) * 8; + SetParityBitsOnKey( NativeKey); + FKeyStream.Write( NativeKey, 8) + end +end; + + +procedure T3DES_KO1_Reference_TestCase.NormalizeKeyStream; +var + NativeKey: uint64; + SubKey: integer; +begin +for SubKey := 1 to 3 do + begin + FKeyStream.Position := (SubKey - 1) * 8; + if FKeyStream.Read( NativeKey, 8) < 8 then break; + FKeyStream.Position := (SubKey - 1) * 8; + SetParityBitsOnKey( NativeKey); + FKeyStream.Write( NativeKey, 8) + end +end; + +{ TMasBug_TestCase } + +procedure TMasBug_TestCase.SetUp; +begin +FRand := TRandomStream.Instance ; +Len := 32; +GetMem( P, Len); +end; + +procedure TMasBug_TestCase.TearDown; +begin +FreeMem( P, Len) +end; + + + +procedure TMasBug_TestCase.Mas_RandomStream_Bug; +var + j: Integer; + PreviousFirstByte: byte; + CollisionCount: integer; +begin +FRand.Randomize; +CollisionCount := 0; +PreviousFirstByte := 0; +for j := 1 to 20 do + begin + FRand.Read( P^, Len); + if (j >= 2) and (PreviousFirstByte = P^) then + Inc( CollisionCount); + PreviousFirstByte := P^ + end; +Check( CollisionCount < 4, 'Random number generator is suspect.') +end; + + + + +initialization +InitUnit_CipherTestCases; + + +finalization +DoneUnit_CipherTestCases; + + +end. diff --git a/unit-tests/dunit/uLockBox_Hashes.pas b/LockBox3/unit-tests/dunit/uLockBox_Hashes.pas similarity index 95% rename from unit-tests/dunit/uLockBox_Hashes.pas rename to LockBox3/unit-tests/dunit/uLockBox_Hashes.pas index c95d53a..e947347 100644 --- a/unit-tests/dunit/uLockBox_Hashes.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_Hashes.pas @@ -1,262 +1,262 @@ -unit uLockBox_Hashes; -interface -uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, - TPLB3.MemoryStreamPool; - -type - - -THash_TestCase = class( TTestCase) - protected - FHash: THash; - FLib: TCryptographicLibrary; - FReferenceTestSource: utf8string; - FReferenceTestRefrnc: utf8string; - FSource: TMemoryStream; - FRefValue: TMemoryStream; - FTestValue: TMemoryStream; - - procedure SetUp; override; - procedure TearDown; override; - class function HashId: string; virtual; abstract; - - published - procedure ReferenceTestVectors; - end; - - - -TMD5_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - end; - -TSHA1_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - end; - - -TSHA256_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - - published - procedure ExtraReferenceTests; - end; - - -TSHA224_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - - published - procedure ExtraReferenceTests; - end; - - -TSHA512_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - - published - procedure ExtraReferenceTests; - end; - -TSHA384_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - end; - -TSHA512_224_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - end; - -TSHA512_256_TestCase = class( THash_TestCase) - protected - class function HashId: string; override; - end; - - - -implementation - - - - - - - - - -uses TPLB3.SHA2, TPLB3.Constants, TPLB3.BinaryUtils, TPLB3.HashDsc, - SysUtils, TPLB3.StreamUtils; - -procedure InitUnit_Hashes; -begin -TestFramework.RegisterTest( TMD5_TestCase.Suite); -TestFramework.RegisterTest( TSHA1_TestCase.Suite); -TestFramework.RegisterTest( TSHA224_TestCase.Suite); -TestFramework.RegisterTest( TSHA256_TestCase.Suite); -TestFramework.RegisterTest( TSHA384_TestCase.Suite); -TestFramework.RegisterTest( TSHA512_TestCase.Suite); -TestFramework.RegisterTest( TSHA512_224_TestCase.Suite); -TestFramework.RegisterTest( TSHA512_256_TestCase.Suite); -end; - - - -procedure DoneUnit_Hashes; -begin -end; - - - - -{ THash_TestCase } - -procedure THash_TestCase.SetUp; -var - TestAccess: IHash_TestAccess; - Hasher: IHasher; -begin -FLib := TCryptographicLibrary.Create( nil); -FHash := THash.Create( nil); -FHash.CryptoLibrary := FLib; -FHash.HashId := HashId; -FHash.Begin_Hash; -if Supports( FHash, IHash_TestAccess, TestAccess) then - Hasher := TestAccess.GetHasher; -FHash.End_Hash; -if assigned( Hasher) then - begin - FReferenceTestSource := Hasher.SelfTest_Source; - FReferenceTestRefrnc := Hasher.SelfTest_ReferenceHashValue - end; -FSource := TMemoryStream.Create; -FRefValue := TMemoryStream.Create; -FTestValue := TMemoryStream.Create -end; - - - - -procedure TSHA256_TestCase.ExtraReferenceTests; -begin -FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; -FReferenceTestRefrnc := '248D6A61 D20638B8 ' + - 'E5C02693 0C3E6039 A33CE459 64FF2167 F6ECEDD4 19DB06C1'; -ReferenceTestVectors -end; - - -procedure TSHA224_TestCase.ExtraReferenceTests; -begin -FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; -FReferenceTestRefrnc := '75388B16 512776CC 5DBA5DA1 FD890150 B0C6455C B4F58B19 52522525'; -ReferenceTestVectors -end; - - -procedure THash_TestCase.TearDown; -begin -FHash.Free; -FLib.Free; -FSource.Free; -FRefValue.Free; -FTestValue.Free -end; - - - - -procedure THash_TestCase.ReferenceTestVectors; -begin -FSource.Write( FReferenceTestSource[1], Length( FReferenceTestSource) * SizeOf( AnsiChar)); -{$WARNINGS OFF} -Read_BigEndien_u32_Hex( FReferenceTestRefrnc, FRefValue); -{$WARNINGS ON} -FHash.HashStream( FSource); -FTestValue.CopyFrom( FHash.HashOutputValue, 0); -FHash.Burn; -Check( CompareMemoryStreams( FRefValue, FTestValue), Format( - 'Hash %s failed it''s standard reference test.',[FHash.Hash])) -end; - - - -{ TMD5_TestCase } - -class function TMD5_TestCase.HashId: string; -begin -result := 'native.hash.MD5' -end; - - - - -{ TSHA1_TestCase } - -class function TSHA1_TestCase.HashId: string; -begin -result := 'native.hash.SHA-1' -end; - -// Test vectors from -// http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA256.pdf - -{ TSHA2_TestCase } - -class function TSHA256_TestCase.HashId: string; -begin -result := SHA256_ProgId -end; - -class function TSHA224_TestCase.HashId: string; -begin -result := SHA224_ProgId -end; - - -procedure TSHA512_TestCase.ExtraReferenceTests; -begin -FReferenceTestSource := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijk' + - 'lmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'; -FReferenceTestRefrnc := '8E959B75 DAE313DA 8CF4F728 14FC143F ' + - '8F7779C6 EB9F7FA1 7299AEAD B6889018 501D289E 4900F7E4 ' + - '331B99DE C4B5433A C7D329EE B6DD2654 5E96E55B 874BE909'; -ReferenceTestVectors -end; - -class function TSHA512_TestCase.HashId: string; -begin -result := SHA512_ProgId -end; - - -class function TSHA384_TestCase.HashId: string; -begin -result := SHA384_ProgId -end; - - -class function TSHA512_224_TestCase.HashId: string; -begin -result := SHA512_224_ProgId -end; - -class function TSHA512_256_TestCase.HashId: string; -begin -result := SHA512_256_ProgId -end; - -initialization -InitUnit_Hashes; - - - -finalization -DoneUnit_Hashes; - -end. +unit uLockBox_Hashes; +interface +uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.MemoryStreamPool; + +type + + +THash_TestCase = class( TTestCase) + protected + FHash: THash; + FLib: TCryptographicLibrary; + FReferenceTestSource: utf8string; + FReferenceTestRefrnc: utf8string; + FSource: TMemoryStream; + FRefValue: TMemoryStream; + FTestValue: TMemoryStream; + + procedure SetUp; override; + procedure TearDown; override; + class function HashId: string; virtual; abstract; + + published + procedure ReferenceTestVectors; + end; + + + +TMD5_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + end; + +TSHA1_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + end; + + +TSHA256_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + + published + procedure ExtraReferenceTests; + end; + + +TSHA224_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + + published + procedure ExtraReferenceTests; + end; + + +TSHA512_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + + published + procedure ExtraReferenceTests; + end; + +TSHA384_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + end; + +TSHA512_224_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + end; + +TSHA512_256_TestCase = class( THash_TestCase) + protected + class function HashId: string; override; + end; + + + +implementation + + + + + + + + + +uses TPLB3.SHA2, TPLB3.Constants, TPLB3.BinaryUtils, TPLB3.HashDsc, + SysUtils, TPLB3.StreamUtils; + +procedure InitUnit_Hashes; +begin +TestFramework.RegisterTest( TMD5_TestCase.Suite); +TestFramework.RegisterTest( TSHA1_TestCase.Suite); +TestFramework.RegisterTest( TSHA224_TestCase.Suite); +TestFramework.RegisterTest( TSHA256_TestCase.Suite); +TestFramework.RegisterTest( TSHA384_TestCase.Suite); +TestFramework.RegisterTest( TSHA512_TestCase.Suite); +TestFramework.RegisterTest( TSHA512_224_TestCase.Suite); +TestFramework.RegisterTest( TSHA512_256_TestCase.Suite); +end; + + + +procedure DoneUnit_Hashes; +begin +end; + + + + +{ THash_TestCase } + +procedure THash_TestCase.SetUp; +var + TestAccess: IHash_TestAccess; + Hasher: IHasher; +begin +FLib := TCryptographicLibrary.Create( nil); +FHash := THash.Create( nil); +FHash.CryptoLibrary := FLib; +FHash.HashId := HashId; +FHash.Begin_Hash; +if Supports( FHash, IHash_TestAccess, TestAccess) then + Hasher := TestAccess.GetHasher; +FHash.End_Hash; +if assigned( Hasher) then + begin + FReferenceTestSource := Hasher.SelfTest_Source; + FReferenceTestRefrnc := Hasher.SelfTest_ReferenceHashValue + end; +FSource := TMemoryStream.Create; +FRefValue := TMemoryStream.Create; +FTestValue := TMemoryStream.Create +end; + + + + +procedure TSHA256_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; +FReferenceTestRefrnc := '248D6A61 D20638B8 ' + + 'E5C02693 0C3E6039 A33CE459 64FF2167 F6ECEDD4 19DB06C1'; +ReferenceTestVectors +end; + + +procedure TSHA224_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; +FReferenceTestRefrnc := '75388B16 512776CC 5DBA5DA1 FD890150 B0C6455C B4F58B19 52522525'; +ReferenceTestVectors +end; + + +procedure THash_TestCase.TearDown; +begin +FHash.Free; +FLib.Free; +FSource.Free; +FRefValue.Free; +FTestValue.Free +end; + + + + +procedure THash_TestCase.ReferenceTestVectors; +begin +FSource.Write( FReferenceTestSource[1], Length( FReferenceTestSource) * SizeOf( AnsiChar)); +{$WARNINGS OFF} +Read_BigEndien_u32_Hex( FReferenceTestRefrnc, FRefValue); +{$WARNINGS ON} +FHash.HashStream( FSource); +FTestValue.CopyFrom( FHash.HashOutputValue, 0); +FHash.Burn; +Check( CompareMemoryStreams( FRefValue, FTestValue), Format( + 'Hash %s failed it''s standard reference test.',[FHash.Hash])) +end; + + + +{ TMD5_TestCase } + +class function TMD5_TestCase.HashId: string; +begin +result := 'native.hash.MD5' +end; + + + + +{ TSHA1_TestCase } + +class function TSHA1_TestCase.HashId: string; +begin +result := 'native.hash.SHA-1' +end; + +// Test vectors from +// http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA256.pdf + +{ TSHA2_TestCase } + +class function TSHA256_TestCase.HashId: string; +begin +result := SHA256_ProgId +end; + +class function TSHA224_TestCase.HashId: string; +begin +result := SHA224_ProgId +end; + + +procedure TSHA512_TestCase.ExtraReferenceTests; +begin +FReferenceTestSource := 'abcdefghbcdefghicdefghijdefghijkefghijklfghijk' + + 'lmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'; +FReferenceTestRefrnc := '8E959B75 DAE313DA 8CF4F728 14FC143F ' + + '8F7779C6 EB9F7FA1 7299AEAD B6889018 501D289E 4900F7E4 ' + + '331B99DE C4B5433A C7D329EE B6DD2654 5E96E55B 874BE909'; +ReferenceTestVectors +end; + +class function TSHA512_TestCase.HashId: string; +begin +result := SHA512_ProgId +end; + + +class function TSHA384_TestCase.HashId: string; +begin +result := SHA384_ProgId +end; + + +class function TSHA512_224_TestCase.HashId: string; +begin +result := SHA512_224_ProgId +end; + +class function TSHA512_256_TestCase.HashId: string; +begin +result := SHA512_256_ProgId +end; + +initialization +InitUnit_Hashes; + + + +finalization +DoneUnit_Hashes; + +end. diff --git a/unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas similarity index 96% rename from unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas index 3ac4440..2cd17f3 100644 --- a/unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_HugeCardinalTestCases.pas @@ -1,620 +1,620 @@ -unit uLockBox_HugeCardinalTestCases; -interface -uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, - TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, - TPLB3.MemoryStreamPool; - - -type -THugeCardinal_TestCase = class( TTestCase) - protected - Fbig1234: THugeCardinal; - Fbig2313: THugeCardinal; - Fbig3547: THugeCardinal; - Temp1, Temp2, Temp3, Temp4: THugeCardinal; - Temp2000_1: THugeCardinal; - Temp2000_2: THugeCardinal; - T3, F100: THugeCardinal; - TmpStream: TMemoryStream; - - procedure SetUp; override; - procedure TearDown; override; - - published - procedure Test_CreateZero; - procedure CreateRandom; - procedure CreateSmall; - procedure Test_Clone; - procedure Test_Assign; - procedure Test_Zeroise; - procedure Test_CompareSmall; - procedure Test_Compare; - procedure Test_AssignSmall; - procedure Test_BitLength; - procedure Test_MaxBits; - procedure Test_Add; - procedure Test_Increment; - procedure Test_Subtract; - procedure Test_MulPower2; - procedure Test_MulSmall; - procedure Test_Multiply; - procedure Test_Modulo; - procedure Test_AddMod; - procedure Test_MultiplyMod; - procedure Test_isOdd; - procedure Test_CreateFromStreamIn; - procedure Test_CloneSized; - procedure Test_Resize; - procedure Test_AssignFromStreamIn; - procedure Test_Swap; - procedure Test_ExtactSmall; - procedure Test_StreamOut; - procedure Test_PowerMod; - procedure Test_SmallExponent_PowerMod; - end; - -implementation - - - - - - - -uses SysUtils; - - - - -procedure InitUnit_HugeCardinalTestCases; -begin -TestFramework.RegisterTest( THugeCardinal_TestCase.Suite) -end; - -procedure DoneUnit_HugeCardinalTestCases; -begin -end; - - -{ THugeCardinal_TestCase } - -procedure THugeCardinal_TestCase.SetUp; -var - j: integer; -begin -Temp1 := THugeCardinal.CreateSmall( 1234, 100, nil); -Temp2 := THugeCardinal.CreateSmall( 10000, 100, nil); -Temp3 := THugeCardinal.CreateSmall( 2313, 100, nil); -Temp4 := THugeCardinal.CreateSmall( 3547, 100, nil); -Fbig1234 := THugeCardinal.CreateZero( 2000, nil); -Fbig2313 := THugeCardinal.CreateZero( 2000, nil); -Fbig3547 := THugeCardinal.CreateZero( 2000, nil); -Temp2000_1 := THugeCardinal.CreateZero( 2000, nil); -Temp2000_2 := THugeCardinal.CreateZero( 2000, nil); -for j := 1 to 16 do - begin - T3 := Fbig1234.Multiply( Temp2); - FBig1234.Assign( T3); - FreeAndNil( T3); - Fbig1234.Add ( Temp1); - - T3 := Fbig2313.Multiply( Temp2); - Fbig2313.Assign( T3); - FreeAndNil( T3); - Fbig2313.Add ( Temp3); - - T3 := Fbig3547.Multiply( Temp2); - Fbig3547.Assign( T3); - FreeAndNil( T3); - Fbig3547.Add ( Temp4); - end; -F100 := THugeCardinal.CreateSmall( 100, 100, nil); -TmpStream := TMemoryStream.Create; -end; - - - -procedure THugeCardinal_TestCase.TearDown; -begin -FreeAndNil( Temp1); -FreeAndNil( Temp2); -FreeAndNil( Temp2000_1); -FreeAndNil( Temp2000_2); -FreeAndNil( FBig1234); -FreeAndNil( Fbig2313); -FreeAndNil( Fbig3547); -FreeAndNil( Temp3); -FreeAndNil( Temp4); -FreeAndNil( T3); -FreeAndNil( F100); -FreeAndNil( TmpStream) -end; - - - - -procedure THugeCardinal_TestCase.CreateRandom; -var - Rand: THugeCardinal; -begin -// Create a big random and make sure bits is not more than the specified length. -Rand := THugeCardinal.CreateRandom( 201, 300, False, nil); -try - Check( (Rand.BitLength <= 201) and - (Rand.BitLength >= 100), 'HugeCardinal Create Random failed.') -finally -Rand.Free -end end; - - - -procedure THugeCardinal_TestCase.CreateSmall; -begin -// Create 100 and check it is 100 -Check( F100.isSmall and (F100.ExtractSmall = 100), - 'HugeCardinal CreateSmall failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_Add; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 + -//2313231323132313231323132313231323132313231323132313231323132313 = -//---------------------------------------------------------------- -//3547354735473547354735473547354735473547354735473547354735473547 -//Construct these numbers by lots of small adds and multiplies (by 10). -Temp2000_1.Assign( Fbig1234); -Temp2000_1.Add( Fbig2313); -Check( Temp2000_1.Compare( Fbig3547) = rEqualTo, 'HugeCardinal addition failed.') -end; - - -procedure THugeCardinal_TestCase.Test_AddMod; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 + -//2313231323132313231323132313231323132313231323132313231323132313 mod -// 100 = -//---------------------------------------------------------------- -// 47 -Temp2000_1.Assign( Fbig1234); -Temp2000_1.AddMod( Fbig2313, F100); -Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 47), - 'HugeCardinal AddMod failed.') -end; - - -procedure THugeCardinal_TestCase.Test_Assign; -begin -// Start with a big random y. -// x := y -// check x = y -Temp2000_1.Assign( FBig1234); -Check( Temp2000_1.Compare( FBig1234) = rEqualTo, - 'Huge Cardinal Assign failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_AssignFromStreamIn; -begin -// Manually stream out x. -// Stream it back in. -// Check it is the same a sthe original -TmpStream.Clear; -FBig1234.StreamOut( LittleEndien, TmpStream); -FreeAndNil( Temp2000_1); -TmpStream.Position := 0; -Temp2000_1 := THugeCardinal.CreateFromStreamIn( FBig1234.MaxBits, LittleEndien, TmpStream, nil); -FreeAndNil( TmpStream); -Check( Temp2000_1.Compare( Fbig1234) = rEqualTo, 'HugeCardinal AssignFromStreamIn failed.') -end; - - -procedure THugeCardinal_TestCase.Test_AssignSmall; -begin -// x := 10000; -// check x = 10000 -Temp2000_1.AssignSmall( 10000); -Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 10000), - 'HugeCardinal AssignSmall failed.') -end; - - -procedure THugeCardinal_TestCase.Test_BitLength; -var - bl: integer; -begin -// check zero. bitlength = 0 -// x := 1234123412341234123412341234123412341234123412341234123412341234; -// check (x shl 1).BL = x.BL + 1 -// manually count bits in x by shl -1 for maxbits. -// check manual count = original BitLength property. -Temp2000_1.Zeroise; -Check( Temp2000_1.BitLength = 0, 'BitLength 0 failed.'); -bl := FBig1234.BitLength; -FBig1234.MulPower2( 1); -Check( (FBig1234.BitLength) - bl = 1, 'BitLength failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_Clone; -begin -// x := 1234123412341234123412341234123412341234123412341234123412341234; -// y := clone x; -// check x = y -// check x.maxbits = y.maxbits -FreeAndNil( Temp2000_1); -Temp2000_1 := FBig1234.Clone; -Check( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.Clone failed.'); -Check( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.Clone failed.'); -Check( Temp2000_1.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal.Clone failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_CloneSized; -begin -// x := clone y, but with a different size. -// check x = y -// check size x is corrrect. -FreeAndNil( Temp2000_1); -Temp2000_1 := FBig1234.CloneSized( 3999); -Check( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.CloneSized failed.'); -Check( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.CloneSized failed.'); -Check( Temp2000_1.MaxBits = 4000, 'THugeCardinal.CloneSized failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_Compare; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 compare to -//2313231323132313231323132313231323132313231323132313231323132313 = -//---------------------------------------------------------------- -// less than. - -//Check that ... -//2313231323132313231323132313231323132313231323132313231323132313 compare to -//1234123412341234123412341234123412341234123412341234123412341234 = -//---------------------------------------------------------------- -// greater than. - -//Check that ... -//2313231323132313231323132313231323132313231323132313231323132313 compare to -//2313231323132313231323132313231323132313231323132313231323132313 = -//---------------------------------------------------------------- -// equals. -Check( FBig2313.Compare( FBig1234) = rGreaterThan, 'THugeCardinal.Compare failed.'); -Check( FBig1234.Compare( FBig2313) = rLessThan , 'THugeCardinal.Compare failed.'); -Check( FBig2313.Compare( FBig2313) = rEqualTo , 'THugeCardinal.Compare failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_CompareSmall; -begin -// x := 999 -// compare x = 999 -// compare x = 665 -Temp2000_1.AssignSmall( 999); -Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 999), 'THugeCardinal.CompareSmall failed.'); -Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall <> 665), 'THugeCardinal.CompareSmall failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_CreateZero; -begin -// x := 0 -// compare x = 0 -FreeAndNil( Temp2000_1); -Temp2000_1 := THugeCardinal.CreateZero( 10, nil); -Check( Temp2000_1.isZero, 'THugeCardinal.CreateZero failed.'); -end; - -procedure THugeCardinal_TestCase.Test_ExtactSmall; -begin -// x is big. -// y := x + 44 - x -// check y = 44 -Temp2000_1.Assign( FBig1234); -Temp2000_1.Increment( 44); -Temp2000_1.Subtract( FBig1234); -Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 44), - 'THugeCardinal.ExtactSmall/isSmall failed.') -end; - -procedure THugeCardinal_TestCase.Test_Increment; -var - v: uint64; -begin -//Check that ... -// $FFFFFFFFFFFFFFFFFF + // 8 bytes of $FF -// 1 = -//--------------------- -//$1000000000000000000 // 9 bytes -int64rec( v).Lo := $FFFFFFFF; -int64rec( v).Hi := $FFFFFFFF; -Temp2000_1.AssignSmall( v); -Temp2000_1.Increment( 1); -Temp2000_2.AssignSmall( 1); -Temp2000_2.MulPower2( 64); -Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, - 'THugeCardinal Increment failed.') -end; - - -procedure THugeCardinal_TestCase.Test_isOdd; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 is even. - -// Check that ... -//2313231323132313231323132313231323132313231323132313231323132313 is odd. - -// Check that 0 is even. -Check( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); -FBig1234.Increment( -1); -Check( FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); -FBig1234.Zeroise; -Check( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); -end; - - -procedure THugeCardinal_TestCase.Test_MaxBits; -begin -// create x with 5 bits. -// check x.maxbits = 64 -// create x with 100 bits. -// check x.maxbits = 104 -FreeAndNil( Temp2000_1); -Temp2000_1 := THugeCardinal.CreateZero( 5, nil); -Check( Temp2000_1.MaxBits = 64, 'MaxBits failed.'); -FreeAndNil( Temp2000_1); -Temp2000_1 := THugeCardinal.CreateZero( 100, nil); -Check( Temp2000_1.MaxBits = 104, 'MaxBits failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_Modulo; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 mod -// 1000 = -//---------------------------------------------------------------- -// 234 -Temp2000_1.Assign( FBig1234); -Temp2000_2.AssignSmall( 1000); -FreeAndNil( T3); -T3 := Temp2000_1.Modulo( Temp2000_2); -Check( T3.isSmall and (T3.ExtractSmall = 234), - 'THugeCardinal Modulo failed.') -end; - - - -procedure THugeCardinal_TestCase.Test_MulPower2; -var - v: uint64; - s: string; - Method: boolean; -begin -for Method := False to True do - begin - doUseMulPower2_NewAlgorithm := Method; - - // Check that x + x = x shl 1 - // Check that x shl 88 shl -88 = x - Temp2000_1.Assign( FBig1234); - Temp2000_1.Add ( FBig1234); - Temp2000_2.Assign( FBig1234); - Temp2000_2.MulPower2( 1); - Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, - 'THugeCardinal MulPower2 failed - subtest 1.'); - - Temp2000_1.Assign( FBig1234); - Temp2000_1.MulPower2( 88); - Temp2000_1.MulPower2( -88); - Check( Temp2000_1.Compare( FBig1234) = rEqualTo, - 'THugeCardinal MulPower2 failed - subtest 1.'); - - int64rec( v).Lo := $FFFFFFFF; - int64rec( v).Hi := $0000FFFF; - Temp2000_1.AssignSmall( v); - Temp2000_2.AssignSmall( v); - Temp2000_2.MulPower2( 5); - s := Format( '%x', [Temp2000_2.ExtractSmall]); - Temp2000_1.MulPower2( 8); - s := Format( '%x', [Temp2000_1.ExtractSmall]); - Temp2000_1.MulPower2( -3); - s := Format( '%x', [Temp2000_1.ExtractSmall]); - Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, - 'THugeCardinal MulPower2 failed - subtest 3.') - end -end; - - - -procedure THugeCardinal_TestCase.Test_MulSmall; -begin -// check that x + x + x = 3 * x -Temp2000_1.Assign( FBig1234); -Temp2000_1.Add ( FBig1234); -Temp2000_1.Add ( FBig1234); -Temp2000_2.Assign( FBig1234); -Temp2000_2.MulSmall( 3); -Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, - 'THugeCardinal MulSmall failed.'); -end; - -procedure THugeCardinal_TestCase.Test_Subtract; -begin -// check x + y - y = x -Temp2000_1.Assign( FBig1234); -Temp2000_1.Add ( FBig2313); -Temp2000_1.Subtract( FBig2313); -Check( Temp2000_1.Compare( FBig1234) = rEqualTo, - 'THugeCardinal Subtract failed.'); -end; - - -procedure THugeCardinal_TestCase.Test_Zeroise; -begin -// x := 1234123412341234123412341234123412341234123412341234123412341234; -// zeroise x -// check that x = 0 -Temp2000_1.Assign( FBig1234); -Temp2000_1.Zeroise; -Check( Temp2000_1.IsZero,'THugeCardinal Zeroise failed.'); -end; - - -procedure THugeCardinal_TestCase.Test_Swap; -begin -// x and y big values. -// swap x & y -// check x = original y -// check x.maxbits = original y.maxbits -// check y = original x -// check y.maxbits = original x.maxbits -Temp2000_1.Assign( FBig1234); -Temp2000_2.Assign( Fbig2313); -FBig1234.Swap( Fbig2313); -Check( FBig1234.Compare( Temp2000_2) = rEqualTo, 'THugeCardinal Swap failed.'); -Check( FBig1234.MaxBits = Temp2000_2.MaxBits, 'THugeCardinal Swap failed (MaxBits).'); -Check( Fbig2313.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal Swap failed.'); -Check( FBig2313.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal Swap failed (MaxBits).') -end; - - -procedure THugeCardinal_TestCase.Test_CreateFromStreamIn; -var - Newbie: THugeCardinal; -begin -// Manually stream out x. -// Stream it back into constructor. -// Check it is the same as the original. -Fbig2313.StreamOut( LittleEndien, TmpStream); -TmpStream.Position := 0; -Newbie := THugeCardinal.CreateFromStreamIn( TmpStream.Size*8, LittleEndien, TmpStream, nil); -Check( Newbie.Compare( Fbig2313)= rEqualTo, 'THugeCardinal CreateFromStreamIn constructor failed.'); -Newbie.Free -end; - -procedure THugeCardinal_TestCase.Test_Multiply; -// Check that 10^33 * 10^44 = 10^77 - procedure Make10ToThePowerOf( var HC: THugeCardinal; Exponent: integer); - var - j: integer; - begin - // Assume Temp1 = 10 and Exponent >= 1 - HC.AssignSmall( 1); - for j := 1 to Exponent do - begin - T3 := HC.Multiply( Temp1); - HC.Assign( T3); - FreeAndNil( T3) - end; - // HC = 10 ^ Exponent - end; - -begin -Temp1.AssignSmall( 10); - -Make10ToThePowerOf( Fbig1234, 33); // Fbig1234 = 10^33 -Make10ToThePowerOf( Fbig2313, 44); // Fbig2313 = 10^44 -Make10ToThePowerOf( Fbig3547, 77); // Fbig1234 = 10^77 - -T3 := Fbig1234.Multiply( Fbig2313); -Check( T3.Compare( Fbig3547) = rEqualTo, - 'THugeCardinal Multiply failed (10^33 * 10^44 = 10^77).'); -FreeAndNil( T3) -end; - -procedure THugeCardinal_TestCase.Test_MultiplyMod; -begin -//Check that ... -//1234123412341234123412341234123412341234123412341234123412341234 * -//2313231323132313231323132313231323132313231323132313231323132313 mod -// 100 = -//---------------------------------------------------------------- -// 42 -Temp2.AssignSmall( 100); -FBig1234.MultiplyMod( FBig2313, Temp2); -Check( FBig1234.CompareSmall( 42) = rEqualTo, - 'THugeCardinal MultiplyMod failed.'); -end; - -procedure THugeCardinal_TestCase.Test_PowerMod; -begin -// 6529 ^ 2987 mod 100 = 9 -FBig1234.AssignSmall( 6529); -Temp2.AssignSmall( 2987); -Temp3.AssignSmall( 100); -FBig1234.PowerMod( Temp2, Temp3, nil); -Check( FBig1234.CompareSmall( 9) = rEqualTo, - 'THugeCardinal PowerMod failed (6529 ^ 2987 mod 100 = 9).') -end; - - -procedure THugeCardinal_TestCase.Test_Resize; -begin -// x create as 100 bits. random. -// resize to 200 bits. -// check x.size = 200 -// check x = original value. -T3 := THugeCardinal.CreateRandom( 100, 100, True, nil); -T3.Resize( 200); -Check( T3.CapacityInBits = 200, - 'THugeCardinal Resize failed .'); -FreeAndNil( T3) -end; - - -procedure THugeCardinal_TestCase.Test_SmallExponent_PowerMod; -begin -// 6529 ^ 2987 mod 100 = 9 -FBig1234.AssignSmall( 6529); -Temp3.AssignSmall( 100); -FBig1234.SmallExponent_PowerMod( 2987, Temp3); -Check( FBig1234.CompareSmall( 9) = rEqualTo, - 'THugeCardinal SmallExponent_PowerMod failed (6529 ^ 2987 mod 100 = 9).') -end; - - - - -procedure THugeCardinal_TestCase.Test_StreamOut; -var - Order: TByteOrder; -begin -// x big. -// stream out. -// stream in. -// check x = original value -for Order := LittleEndien to BigEndien do - begin - TmpStream.Size := 0; - Fbig2313.StreamOut( Order, TmpStream); - TmpStream.Position := 0; - Fbig1234.AssignFromStreamIn( Order, TmpStream); - Check( Fbig1234.Compare( Fbig2313)= rEqualTo, - 'THugeCardinal Test_StreamOut failed.') - end -end; - - -initialization -InitUnit_HugeCardinalTestCases; - - -finalization -DoneUnit_HugeCardinalTestCases; - -end. +unit uLockBox_HugeCardinalTestCases; +interface +uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, + TPLB3.MemoryStreamPool; + + +type +THugeCardinal_TestCase = class( TTestCase) + protected + Fbig1234: THugeCardinal; + Fbig2313: THugeCardinal; + Fbig3547: THugeCardinal; + Temp1, Temp2, Temp3, Temp4: THugeCardinal; + Temp2000_1: THugeCardinal; + Temp2000_2: THugeCardinal; + T3, F100: THugeCardinal; + TmpStream: TMemoryStream; + + procedure SetUp; override; + procedure TearDown; override; + + published + procedure Test_CreateZero; + procedure CreateRandom; + procedure CreateSmall; + procedure Test_Clone; + procedure Test_Assign; + procedure Test_Zeroise; + procedure Test_CompareSmall; + procedure Test_Compare; + procedure Test_AssignSmall; + procedure Test_BitLength; + procedure Test_MaxBits; + procedure Test_Add; + procedure Test_Increment; + procedure Test_Subtract; + procedure Test_MulPower2; + procedure Test_MulSmall; + procedure Test_Multiply; + procedure Test_Modulo; + procedure Test_AddMod; + procedure Test_MultiplyMod; + procedure Test_isOdd; + procedure Test_CreateFromStreamIn; + procedure Test_CloneSized; + procedure Test_Resize; + procedure Test_AssignFromStreamIn; + procedure Test_Swap; + procedure Test_ExtactSmall; + procedure Test_StreamOut; + procedure Test_PowerMod; + procedure Test_SmallExponent_PowerMod; + end; + +implementation + + + + + + + +uses SysUtils; + + + + +procedure InitUnit_HugeCardinalTestCases; +begin +TestFramework.RegisterTest( THugeCardinal_TestCase.Suite) +end; + +procedure DoneUnit_HugeCardinalTestCases; +begin +end; + + +{ THugeCardinal_TestCase } + +procedure THugeCardinal_TestCase.SetUp; +var + j: integer; +begin +Temp1 := THugeCardinal.CreateSmall( 1234, 100, nil); +Temp2 := THugeCardinal.CreateSmall( 10000, 100, nil); +Temp3 := THugeCardinal.CreateSmall( 2313, 100, nil); +Temp4 := THugeCardinal.CreateSmall( 3547, 100, nil); +Fbig1234 := THugeCardinal.CreateZero( 2000, nil); +Fbig2313 := THugeCardinal.CreateZero( 2000, nil); +Fbig3547 := THugeCardinal.CreateZero( 2000, nil); +Temp2000_1 := THugeCardinal.CreateZero( 2000, nil); +Temp2000_2 := THugeCardinal.CreateZero( 2000, nil); +for j := 1 to 16 do + begin + T3 := Fbig1234.Multiply( Temp2); + FBig1234.Assign( T3); + FreeAndNil( T3); + Fbig1234.Add ( Temp1); + + T3 := Fbig2313.Multiply( Temp2); + Fbig2313.Assign( T3); + FreeAndNil( T3); + Fbig2313.Add ( Temp3); + + T3 := Fbig3547.Multiply( Temp2); + Fbig3547.Assign( T3); + FreeAndNil( T3); + Fbig3547.Add ( Temp4); + end; +F100 := THugeCardinal.CreateSmall( 100, 100, nil); +TmpStream := TMemoryStream.Create; +end; + + + +procedure THugeCardinal_TestCase.TearDown; +begin +FreeAndNil( Temp1); +FreeAndNil( Temp2); +FreeAndNil( Temp2000_1); +FreeAndNil( Temp2000_2); +FreeAndNil( FBig1234); +FreeAndNil( Fbig2313); +FreeAndNil( Fbig3547); +FreeAndNil( Temp3); +FreeAndNil( Temp4); +FreeAndNil( T3); +FreeAndNil( F100); +FreeAndNil( TmpStream) +end; + + + + +procedure THugeCardinal_TestCase.CreateRandom; +var + Rand: THugeCardinal; +begin +// Create a big random and make sure bits is not more than the specified length. +Rand := THugeCardinal.CreateRandom( 201, 300, False, nil); +try + Check( (Rand.BitLength <= 201) and + (Rand.BitLength >= 100), 'HugeCardinal Create Random failed.') +finally +Rand.Free +end end; + + + +procedure THugeCardinal_TestCase.CreateSmall; +begin +// Create 100 and check it is 100 +Check( F100.isSmall and (F100.ExtractSmall = 100), + 'HugeCardinal CreateSmall failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Add; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 + +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +//3547354735473547354735473547354735473547354735473547354735473547 +//Construct these numbers by lots of small adds and multiplies (by 10). +Temp2000_1.Assign( Fbig1234); +Temp2000_1.Add( Fbig2313); +Check( Temp2000_1.Compare( Fbig3547) = rEqualTo, 'HugeCardinal addition failed.') +end; + + +procedure THugeCardinal_TestCase.Test_AddMod; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 + +//2313231323132313231323132313231323132313231323132313231323132313 mod +// 100 = +//---------------------------------------------------------------- +// 47 +Temp2000_1.Assign( Fbig1234); +Temp2000_1.AddMod( Fbig2313, F100); +Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 47), + 'HugeCardinal AddMod failed.') +end; + + +procedure THugeCardinal_TestCase.Test_Assign; +begin +// Start with a big random y. +// x := y +// check x = y +Temp2000_1.Assign( FBig1234); +Check( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'Huge Cardinal Assign failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_AssignFromStreamIn; +begin +// Manually stream out x. +// Stream it back in. +// Check it is the same a sthe original +TmpStream.Clear; +FBig1234.StreamOut( LittleEndien, TmpStream); +FreeAndNil( Temp2000_1); +TmpStream.Position := 0; +Temp2000_1 := THugeCardinal.CreateFromStreamIn( FBig1234.MaxBits, LittleEndien, TmpStream, nil); +FreeAndNil( TmpStream); +Check( Temp2000_1.Compare( Fbig1234) = rEqualTo, 'HugeCardinal AssignFromStreamIn failed.') +end; + + +procedure THugeCardinal_TestCase.Test_AssignSmall; +begin +// x := 10000; +// check x = 10000 +Temp2000_1.AssignSmall( 10000); +Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 10000), + 'HugeCardinal AssignSmall failed.') +end; + + +procedure THugeCardinal_TestCase.Test_BitLength; +var + bl: integer; +begin +// check zero. bitlength = 0 +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// check (x shl 1).BL = x.BL + 1 +// manually count bits in x by shl -1 for maxbits. +// check manual count = original BitLength property. +Temp2000_1.Zeroise; +Check( Temp2000_1.BitLength = 0, 'BitLength 0 failed.'); +bl := FBig1234.BitLength; +FBig1234.MulPower2( 1); +Check( (FBig1234.BitLength) - bl = 1, 'BitLength failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Clone; +begin +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// y := clone x; +// check x = y +// check x.maxbits = y.maxbits +FreeAndNil( Temp2000_1); +Temp2000_1 := FBig1234.Clone; +Check( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.Clone failed.'); +Check( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.Clone failed.'); +Check( Temp2000_1.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal.Clone failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CloneSized; +begin +// x := clone y, but with a different size. +// check x = y +// check size x is corrrect. +FreeAndNil( Temp2000_1); +Temp2000_1 := FBig1234.CloneSized( 3999); +Check( Temp2000_1.Compare( FBig1234) = rEqualTo, 'THugeCardinal.CloneSized failed.'); +Check( FBig1234.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal.CloneSized failed.'); +Check( Temp2000_1.MaxBits = 4000, 'THugeCardinal.CloneSized failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Compare; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 compare to +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +// less than. + +//Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 compare to +//1234123412341234123412341234123412341234123412341234123412341234 = +//---------------------------------------------------------------- +// greater than. + +//Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 compare to +//2313231323132313231323132313231323132313231323132313231323132313 = +//---------------------------------------------------------------- +// equals. +Check( FBig2313.Compare( FBig1234) = rGreaterThan, 'THugeCardinal.Compare failed.'); +Check( FBig1234.Compare( FBig2313) = rLessThan , 'THugeCardinal.Compare failed.'); +Check( FBig2313.Compare( FBig2313) = rEqualTo , 'THugeCardinal.Compare failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CompareSmall; +begin +// x := 999 +// compare x = 999 +// compare x = 665 +Temp2000_1.AssignSmall( 999); +Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 999), 'THugeCardinal.CompareSmall failed.'); +Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall <> 665), 'THugeCardinal.CompareSmall failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_CreateZero; +begin +// x := 0 +// compare x = 0 +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 10, nil); +Check( Temp2000_1.isZero, 'THugeCardinal.CreateZero failed.'); +end; + +procedure THugeCardinal_TestCase.Test_ExtactSmall; +begin +// x is big. +// y := x + 44 - x +// check y = 44 +Temp2000_1.Assign( FBig1234); +Temp2000_1.Increment( 44); +Temp2000_1.Subtract( FBig1234); +Check( Temp2000_1.isSmall and (Temp2000_1.ExtractSmall = 44), + 'THugeCardinal.ExtactSmall/isSmall failed.') +end; + +procedure THugeCardinal_TestCase.Test_Increment; +var + v: uint64; +begin +//Check that ... +// $FFFFFFFFFFFFFFFFFF + // 8 bytes of $FF +// 1 = +//--------------------- +//$1000000000000000000 // 9 bytes +int64rec( v).Lo := $FFFFFFFF; +int64rec( v).Hi := $FFFFFFFF; +Temp2000_1.AssignSmall( v); +Temp2000_1.Increment( 1); +Temp2000_2.AssignSmall( 1); +Temp2000_2.MulPower2( 64); +Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal Increment failed.') +end; + + +procedure THugeCardinal_TestCase.Test_isOdd; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 is even. + +// Check that ... +//2313231323132313231323132313231323132313231323132313231323132313 is odd. + +// Check that 0 is even. +Check( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +FBig1234.Increment( -1); +Check( FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +FBig1234.Zeroise; +Check( not FBig1234.isOdd, 'THugeCardinal IsOdd failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_MaxBits; +begin +// create x with 5 bits. +// check x.maxbits = 64 +// create x with 100 bits. +// check x.maxbits = 104 +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 5, nil); +Check( Temp2000_1.MaxBits = 64, 'MaxBits failed.'); +FreeAndNil( Temp2000_1); +Temp2000_1 := THugeCardinal.CreateZero( 100, nil); +Check( Temp2000_1.MaxBits = 104, 'MaxBits failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_Modulo; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 mod +// 1000 = +//---------------------------------------------------------------- +// 234 +Temp2000_1.Assign( FBig1234); +Temp2000_2.AssignSmall( 1000); +FreeAndNil( T3); +T3 := Temp2000_1.Modulo( Temp2000_2); +Check( T3.isSmall and (T3.ExtractSmall = 234), + 'THugeCardinal Modulo failed.') +end; + + + +procedure THugeCardinal_TestCase.Test_MulPower2; +var + v: uint64; + s: string; + Method: boolean; +begin +for Method := False to True do + begin + doUseMulPower2_NewAlgorithm := Method; + + // Check that x + x = x shl 1 + // Check that x shl 88 shl -88 = x + Temp2000_1.Assign( FBig1234); + Temp2000_1.Add ( FBig1234); + Temp2000_2.Assign( FBig1234); + Temp2000_2.MulPower2( 1); + Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 1.'); + + Temp2000_1.Assign( FBig1234); + Temp2000_1.MulPower2( 88); + Temp2000_1.MulPower2( -88); + Check( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 1.'); + + int64rec( v).Lo := $FFFFFFFF; + int64rec( v).Hi := $0000FFFF; + Temp2000_1.AssignSmall( v); + Temp2000_2.AssignSmall( v); + Temp2000_2.MulPower2( 5); + s := Format( '%x', [Temp2000_2.ExtractSmall]); + Temp2000_1.MulPower2( 8); + s := Format( '%x', [Temp2000_1.ExtractSmall]); + Temp2000_1.MulPower2( -3); + s := Format( '%x', [Temp2000_1.ExtractSmall]); + Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulPower2 failed - subtest 3.') + end +end; + + + +procedure THugeCardinal_TestCase.Test_MulSmall; +begin +// check that x + x + x = 3 * x +Temp2000_1.Assign( FBig1234); +Temp2000_1.Add ( FBig1234); +Temp2000_1.Add ( FBig1234); +Temp2000_2.Assign( FBig1234); +Temp2000_2.MulSmall( 3); +Check( Temp2000_1.Compare( Temp2000_2) = rEqualTo, + 'THugeCardinal MulSmall failed.'); +end; + +procedure THugeCardinal_TestCase.Test_Subtract; +begin +// check x + y - y = x +Temp2000_1.Assign( FBig1234); +Temp2000_1.Add ( FBig2313); +Temp2000_1.Subtract( FBig2313); +Check( Temp2000_1.Compare( FBig1234) = rEqualTo, + 'THugeCardinal Subtract failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_Zeroise; +begin +// x := 1234123412341234123412341234123412341234123412341234123412341234; +// zeroise x +// check that x = 0 +Temp2000_1.Assign( FBig1234); +Temp2000_1.Zeroise; +Check( Temp2000_1.IsZero,'THugeCardinal Zeroise failed.'); +end; + + +procedure THugeCardinal_TestCase.Test_Swap; +begin +// x and y big values. +// swap x & y +// check x = original y +// check x.maxbits = original y.maxbits +// check y = original x +// check y.maxbits = original x.maxbits +Temp2000_1.Assign( FBig1234); +Temp2000_2.Assign( Fbig2313); +FBig1234.Swap( Fbig2313); +Check( FBig1234.Compare( Temp2000_2) = rEqualTo, 'THugeCardinal Swap failed.'); +Check( FBig1234.MaxBits = Temp2000_2.MaxBits, 'THugeCardinal Swap failed (MaxBits).'); +Check( Fbig2313.Compare( Temp2000_1) = rEqualTo, 'THugeCardinal Swap failed.'); +Check( FBig2313.MaxBits = Temp2000_1.MaxBits, 'THugeCardinal Swap failed (MaxBits).') +end; + + +procedure THugeCardinal_TestCase.Test_CreateFromStreamIn; +var + Newbie: THugeCardinal; +begin +// Manually stream out x. +// Stream it back into constructor. +// Check it is the same as the original. +Fbig2313.StreamOut( LittleEndien, TmpStream); +TmpStream.Position := 0; +Newbie := THugeCardinal.CreateFromStreamIn( TmpStream.Size*8, LittleEndien, TmpStream, nil); +Check( Newbie.Compare( Fbig2313)= rEqualTo, 'THugeCardinal CreateFromStreamIn constructor failed.'); +Newbie.Free +end; + +procedure THugeCardinal_TestCase.Test_Multiply; +// Check that 10^33 * 10^44 = 10^77 + procedure Make10ToThePowerOf( var HC: THugeCardinal; Exponent: integer); + var + j: integer; + begin + // Assume Temp1 = 10 and Exponent >= 1 + HC.AssignSmall( 1); + for j := 1 to Exponent do + begin + T3 := HC.Multiply( Temp1); + HC.Assign( T3); + FreeAndNil( T3) + end; + // HC = 10 ^ Exponent + end; + +begin +Temp1.AssignSmall( 10); + +Make10ToThePowerOf( Fbig1234, 33); // Fbig1234 = 10^33 +Make10ToThePowerOf( Fbig2313, 44); // Fbig2313 = 10^44 +Make10ToThePowerOf( Fbig3547, 77); // Fbig1234 = 10^77 + +T3 := Fbig1234.Multiply( Fbig2313); +Check( T3.Compare( Fbig3547) = rEqualTo, + 'THugeCardinal Multiply failed (10^33 * 10^44 = 10^77).'); +FreeAndNil( T3) +end; + +procedure THugeCardinal_TestCase.Test_MultiplyMod; +begin +//Check that ... +//1234123412341234123412341234123412341234123412341234123412341234 * +//2313231323132313231323132313231323132313231323132313231323132313 mod +// 100 = +//---------------------------------------------------------------- +// 42 +Temp2.AssignSmall( 100); +FBig1234.MultiplyMod( FBig2313, Temp2); +Check( FBig1234.CompareSmall( 42) = rEqualTo, + 'THugeCardinal MultiplyMod failed.'); +end; + +procedure THugeCardinal_TestCase.Test_PowerMod; +begin +// 6529 ^ 2987 mod 100 = 9 +FBig1234.AssignSmall( 6529); +Temp2.AssignSmall( 2987); +Temp3.AssignSmall( 100); +FBig1234.PowerMod( Temp2, Temp3, nil); +Check( FBig1234.CompareSmall( 9) = rEqualTo, + 'THugeCardinal PowerMod failed (6529 ^ 2987 mod 100 = 9).') +end; + + +procedure THugeCardinal_TestCase.Test_Resize; +begin +// x create as 100 bits. random. +// resize to 200 bits. +// check x.size = 200 +// check x = original value. +T3 := THugeCardinal.CreateRandom( 100, 100, True, nil); +T3.Resize( 200); +Check( T3.CapacityInBits = 200, + 'THugeCardinal Resize failed .'); +FreeAndNil( T3) +end; + + +procedure THugeCardinal_TestCase.Test_SmallExponent_PowerMod; +begin +// 6529 ^ 2987 mod 100 = 9 +FBig1234.AssignSmall( 6529); +Temp3.AssignSmall( 100); +FBig1234.SmallExponent_PowerMod( 2987, Temp3); +Check( FBig1234.CompareSmall( 9) = rEqualTo, + 'THugeCardinal SmallExponent_PowerMod failed (6529 ^ 2987 mod 100 = 9).') +end; + + + + +procedure THugeCardinal_TestCase.Test_StreamOut; +var + Order: TByteOrder; +begin +// x big. +// stream out. +// stream in. +// check x = original value +for Order := LittleEndien to BigEndien do + begin + TmpStream.Size := 0; + Fbig2313.StreamOut( Order, TmpStream); + TmpStream.Position := 0; + Fbig1234.AssignFromStreamIn( Order, TmpStream); + Check( Fbig1234.Compare( Fbig2313)= rEqualTo, + 'THugeCardinal Test_StreamOut failed.') + end +end; + + +initialization +InitUnit_HugeCardinalTestCases; + + +finalization +DoneUnit_HugeCardinalTestCases; + +end. diff --git a/unit-tests/dunit/uLockBox_OpenSSLTestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_OpenSSLTestCases.pas similarity index 96% rename from unit-tests/dunit/uLockBox_OpenSSLTestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_OpenSSLTestCases.pas index 51cd04c..6623eba 100644 --- a/unit-tests/dunit/uLockBox_OpenSSLTestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_OpenSSLTestCases.pas @@ -1,173 +1,173 @@ -unit uLockBox_OpenSSLTestCases; -interface -uses TestFramework, Classes, TPLB3.Signatory, TPLB3.OpenSSL, SysUtils, - TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random; - -type -TOpenSSL_TestCase = class( TTestCase) - protected - FcodecOpenSSL: TOpenSSL_Codec; - FSig: TOpenSSL_Signatory; - FKey, FIV: TBytes; - FBlockSize: integer; - FPlain, FCipher, FRecon: TMemoryStream; - - procedure SetUp; override; - procedure TearDown; override; - - published - procedure OpenSSL_AES_Encryption; - procedure TwoGenerations; - procedure Signature; - end; - -implementation - - - - - -uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; - - - -procedure InitUnit_OpenSSLTestCases_TestCases; -begin -TestFramework.RegisterTest( TOpenSSL_TestCase.Suite) -end; - -procedure DoneUnit_OpenSSLTestCases_TestCases; -begin -end; - -{ TOpenSSL_TestCase } -type -TBlock=array[0..15] of byte; -PBlock=^TBlock; -procedure TOpenSSL_TestCase.OpenSSL_AES_Encryption; -var - I: Integer; - b: byte; -begin -for I := 0 to 7 do - begin - b := i; - FPlain.Write( b, 1); - end; -FPlain.Position := 0; -FcodecOpenSSL.Encrypt( FPlain, FCipher); -FCipher.Position := 0; -FcodecOpenSSL.Decrypt( FRecon, FCipher); -Check( CompareMemoryStreams( FPlain, FRecon), 'Failed general inversion') -end; - -procedure TOpenSSL_TestCase.SetUp; -var - i: Integer; -begin -FcodecOpenSSL := TOpenSSL_Codec.Create( nil); -FcodecOpenSSL.RequiredVersion := '0.9.0.0'; -FcodecOpenSSL.isLoaded := True; -Check( FcodecOpenSSL.isLoaded, 'Failed to load Libeay32'); -FcodecOpenSSL.Cipher := cipher_aes_256_cbc; -FcodecOpenSSL.PaddingScheme := padPKCS; -FBlockSize := 16; -SetLength( FKey, FBlockSize); -SetLength( FIV, FBlockSize); -for i := 0 to FBlockSize - 1 do - begin - FKey[i] := 0; - FIV [i] := 0; - end; -FPlain := TMemoryStream.Create; -FCipher := TMemoryStream.Create; -FRecon := TMemoryStream.Create; -FcodecOpenSSL.SetKey( FKey); -FcodecOpenSSL.SetIV ( FIV); -FSig := TOpenSSL_Signatory.Create( nil); -FSig.RequiredVersion := '0.9.0.0'; -FSig.isLoaded := True; -Check( FSig.isLoaded, 'Failed to load Libeay32'); -end; - -const - PrivateKey1: utf8string = - '-----BEGIN RSA PRIVATE KEY-----'#$A + - 'MIIEowIBAAKCAQEAvrcFyDAAU6IyOiXiPaTuAe9CTZtwwLdkDSzb6IzBYwFUH+88'#$A + - 'QAklxLlHSsK3P/UKzDScG1bDHa3Ry8LZcU/LmIuFyoPAx5kJEeP5Auk/NGSsFbIw'#$A + - '+bYuMXWU2EVMXhJqQpezJKNc+x03dgZLTBgNuH0E1SO1Reu/4FKYA29zSN5qdYeG'#$A + - '8nrk45e46lm835HYzrDl69IwgB1daZ3/mrvik6qY2JjfiGxHDMqCUtWWuvA6Ayoi'#$A + - 'G4EFpU8ej3MElt7kKjJJrx5A4wx+hbr0BzVPWsIoYtffEhTBnEWR3pGe2R1pKy9l'#$A + - 'zgklFbp7984gqBOXVigHrRXq0pSdVOhW9ZjSqwIDAQABAoIBADPiDKOiU2RtOqbR'#$A + - 'CZRlmw5RrcL5J5p2CbT/4C+Ko02w3db2OXjeRDUZhoiTIlE286IMKe/SEbCwSePZ'#$A + - '9Ve7MpMkWdh3MWnbezkvwN2G4Nf7D0mzuVkls7lm2IBhkd4BuoC1TloIS1JRZ3Yn'#$A + - 'TjK8VHc9I6RsW3NTKFb5gTtmBYHr7s/wsptT2QNFmK194AbIGAcb4WWtS34YktDT'#$A + - 'gXCdMEqZhASnmShgQhiyL8s5BgacpCBkuVEfBRqrL2MsV2ceSbyuTZUabNFMReOX'#$A + - 'BqrGWGbNebFUce1stFhShi9np6cUj3EL1bErC/RZJuXJONDxNEuVutriglInZ9D+'#$A + - 'g4vY9YkCgYEA/MtEvlO7ptfaw+9Bb/S+aEFYQTo/C8T0ELV3wW8Pj399OVhmxV8s'#$A + - 'ZEUdSYyB6cCJukLPJyGAokSktLBF+sOgxJkGY7dlei9jbUfKa1UGMwKYbxKQX2hA'#$A + - 'UGEbRR1Pt/+pNrNgAfMbiwnz+ir5i2gBRXyZvzbfuzs0RbElqpDH7/0CgYEAwSI0'#$A + - 'nkMEgOXdm/TBPJUEXLv8AjBlBWjI8KxrefGgZNRBYU64rIiKs68w7Suv4hw77fBj'#$A + - 'HIyc1io6W6bOzwx3W9+vEzEG5xHzxcoRESJ0N1195sLuU/F4aCRHioMsSouR02tm'#$A + - 'ea4ltqg2DkHSos1ulbnhWxN5/AFu36roAy/A6ccCgYB7WgiKQrt/VzbFgvrQUYGT'#$A + - 'x8bz1SMscAeUG6h69+GE6PXGxK8pQh6cMulumSRPVoceHzmL45osFAi2rokHKuxI'#$A + - '4k6u26+lpngCvBQ2uX9T5sFQ+aL/GxS+5BN1by8WHqeILJD9go3/E3U8rjmkX7S3'#$A + - 'Hmy7VGBpsSL5ms5BY3JcVQKBgQCdPWkTlMKc4wkLCTkuRrC3g4FIkvgccFRwxh/2'#$A + - 't0d77+eO/tWR+tTaN/8giVn4QD52mSlIPB8Qqm664dMsdRzUWwgiGt9gz5fl537/'#$A + - 'sUpnLSHs97Wr+EOsniT025j61CkUtTNITAV+cfMYpnSEgbbQBfc4/GFrUAth5LZi'#$A + - 'qcVpTwKBgCfrNoD1KB+hWnJoFtFoObzYz/O1dKO7PbxyeMUEV5QLc96emE5W8p9w'#$A + - '8r48LhBgq3Ma2ghmnise9zCaNIjb/DTqoyfD+ZdZat6y+bc2zyWu0tZimSGw5rgs'#$A + - '4XJeUpxr7Gm8p8tS1nUBWmooqiR18ORZEtVxdBAxUl2VRnekYnQG'#$A + - '-----END RSA PRIVATE KEY-----'; - -procedure TOpenSSL_TestCase.Signature; -var - sSecret: utf8string; - Secret: TStream; -begin -FSig.PrivateKey := PrivateKey1; -FSig.PrivateKeyStoragePassword := 'honey'; -FSig.PrivateKeyStorageCipher := cipher_aes_256_cbc; -Secret := TMemoryStream.Create; -FSig.StoreKeysToStream( Secret, [partPrivate]); -Secret.Position := 0; -SetLength( sSecret, Secret.Size); -if Secret.Size > 0 then - Secret.ReadBuffer( sSecret[1], Secret.Size); -Secret.Position := 0; -Check( Pos('-----BEGIN RSA PRIVATE KEY-----', sSecret) > 0, 'OpenSSL key not properly stored.'); -Check( Pos('ENCRYPTED', sSecret) > 0, 'OpenSSL key not properly encrypted.'); -FSig.LoadKeysFromStream( Secret, [partPrivate]); -Secret.Free; -Check( FSig.SignVerify_SelfTest); -end; - -procedure TOpenSSL_TestCase.TearDown; -begin -FcodecOpenSSL.Free; -FPlain.Free; -FCipher.Free; -FRecon.Free; -FSig.Free -end; - - - - -procedure TOpenSSL_TestCase.TwoGenerations; -begin -Check( FSig.GenerateKeys); -Check( FSig.GenerateKeys); -end; - - - - -initialization -InitUnit_OpenSSLTestCases_TestCases; - - -finalization -DoneUnit_OpenSSLTestCases_TestCases; - -end. +unit uLockBox_OpenSSLTestCases; +interface +uses TestFramework, Classes, TPLB3.Signatory, TPLB3.OpenSSL, SysUtils, + TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random; + +type +TOpenSSL_TestCase = class( TTestCase) + protected + FcodecOpenSSL: TOpenSSL_Codec; + FSig: TOpenSSL_Signatory; + FKey, FIV: TBytes; + FBlockSize: integer; + FPlain, FCipher, FRecon: TMemoryStream; + + procedure SetUp; override; + procedure TearDown; override; + + published + procedure OpenSSL_AES_Encryption; + procedure TwoGenerations; + procedure Signature; + end; + +implementation + + + + + +uses TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; + + + +procedure InitUnit_OpenSSLTestCases_TestCases; +begin +TestFramework.RegisterTest( TOpenSSL_TestCase.Suite) +end; + +procedure DoneUnit_OpenSSLTestCases_TestCases; +begin +end; + +{ TOpenSSL_TestCase } +type +TBlock=array[0..15] of byte; +PBlock=^TBlock; +procedure TOpenSSL_TestCase.OpenSSL_AES_Encryption; +var + I: Integer; + b: byte; +begin +for I := 0 to 7 do + begin + b := i; + FPlain.Write( b, 1); + end; +FPlain.Position := 0; +FcodecOpenSSL.Encrypt( FPlain, FCipher); +FCipher.Position := 0; +FcodecOpenSSL.Decrypt( FRecon, FCipher); +Check( CompareMemoryStreams( FPlain, FRecon), 'Failed general inversion') +end; + +procedure TOpenSSL_TestCase.SetUp; +var + i: Integer; +begin +FcodecOpenSSL := TOpenSSL_Codec.Create( nil); +FcodecOpenSSL.RequiredVersion := '0.9.0.0'; +FcodecOpenSSL.isLoaded := True; +Check( FcodecOpenSSL.isLoaded, 'Failed to load Libeay32'); +FcodecOpenSSL.Cipher := cipher_aes_256_cbc; +FcodecOpenSSL.PaddingScheme := padPKCS; +FBlockSize := 16; +SetLength( FKey, FBlockSize); +SetLength( FIV, FBlockSize); +for i := 0 to FBlockSize - 1 do + begin + FKey[i] := 0; + FIV [i] := 0; + end; +FPlain := TMemoryStream.Create; +FCipher := TMemoryStream.Create; +FRecon := TMemoryStream.Create; +FcodecOpenSSL.SetKey( FKey); +FcodecOpenSSL.SetIV ( FIV); +FSig := TOpenSSL_Signatory.Create( nil); +FSig.RequiredVersion := '0.9.0.0'; +FSig.isLoaded := True; +Check( FSig.isLoaded, 'Failed to load Libeay32'); +end; + +const + PrivateKey1: utf8string = + '-----BEGIN RSA PRIVATE KEY-----'#$A + + 'MIIEowIBAAKCAQEAvrcFyDAAU6IyOiXiPaTuAe9CTZtwwLdkDSzb6IzBYwFUH+88'#$A + + 'QAklxLlHSsK3P/UKzDScG1bDHa3Ry8LZcU/LmIuFyoPAx5kJEeP5Auk/NGSsFbIw'#$A + + '+bYuMXWU2EVMXhJqQpezJKNc+x03dgZLTBgNuH0E1SO1Reu/4FKYA29zSN5qdYeG'#$A + + '8nrk45e46lm835HYzrDl69IwgB1daZ3/mrvik6qY2JjfiGxHDMqCUtWWuvA6Ayoi'#$A + + 'G4EFpU8ej3MElt7kKjJJrx5A4wx+hbr0BzVPWsIoYtffEhTBnEWR3pGe2R1pKy9l'#$A + + 'zgklFbp7984gqBOXVigHrRXq0pSdVOhW9ZjSqwIDAQABAoIBADPiDKOiU2RtOqbR'#$A + + 'CZRlmw5RrcL5J5p2CbT/4C+Ko02w3db2OXjeRDUZhoiTIlE286IMKe/SEbCwSePZ'#$A + + '9Ve7MpMkWdh3MWnbezkvwN2G4Nf7D0mzuVkls7lm2IBhkd4BuoC1TloIS1JRZ3Yn'#$A + + 'TjK8VHc9I6RsW3NTKFb5gTtmBYHr7s/wsptT2QNFmK194AbIGAcb4WWtS34YktDT'#$A + + 'gXCdMEqZhASnmShgQhiyL8s5BgacpCBkuVEfBRqrL2MsV2ceSbyuTZUabNFMReOX'#$A + + 'BqrGWGbNebFUce1stFhShi9np6cUj3EL1bErC/RZJuXJONDxNEuVutriglInZ9D+'#$A + + 'g4vY9YkCgYEA/MtEvlO7ptfaw+9Bb/S+aEFYQTo/C8T0ELV3wW8Pj399OVhmxV8s'#$A + + 'ZEUdSYyB6cCJukLPJyGAokSktLBF+sOgxJkGY7dlei9jbUfKa1UGMwKYbxKQX2hA'#$A + + 'UGEbRR1Pt/+pNrNgAfMbiwnz+ir5i2gBRXyZvzbfuzs0RbElqpDH7/0CgYEAwSI0'#$A + + 'nkMEgOXdm/TBPJUEXLv8AjBlBWjI8KxrefGgZNRBYU64rIiKs68w7Suv4hw77fBj'#$A + + 'HIyc1io6W6bOzwx3W9+vEzEG5xHzxcoRESJ0N1195sLuU/F4aCRHioMsSouR02tm'#$A + + 'ea4ltqg2DkHSos1ulbnhWxN5/AFu36roAy/A6ccCgYB7WgiKQrt/VzbFgvrQUYGT'#$A + + 'x8bz1SMscAeUG6h69+GE6PXGxK8pQh6cMulumSRPVoceHzmL45osFAi2rokHKuxI'#$A + + '4k6u26+lpngCvBQ2uX9T5sFQ+aL/GxS+5BN1by8WHqeILJD9go3/E3U8rjmkX7S3'#$A + + 'Hmy7VGBpsSL5ms5BY3JcVQKBgQCdPWkTlMKc4wkLCTkuRrC3g4FIkvgccFRwxh/2'#$A + + 't0d77+eO/tWR+tTaN/8giVn4QD52mSlIPB8Qqm664dMsdRzUWwgiGt9gz5fl537/'#$A + + 'sUpnLSHs97Wr+EOsniT025j61CkUtTNITAV+cfMYpnSEgbbQBfc4/GFrUAth5LZi'#$A + + 'qcVpTwKBgCfrNoD1KB+hWnJoFtFoObzYz/O1dKO7PbxyeMUEV5QLc96emE5W8p9w'#$A + + '8r48LhBgq3Ma2ghmnise9zCaNIjb/DTqoyfD+ZdZat6y+bc2zyWu0tZimSGw5rgs'#$A + + '4XJeUpxr7Gm8p8tS1nUBWmooqiR18ORZEtVxdBAxUl2VRnekYnQG'#$A + + '-----END RSA PRIVATE KEY-----'; + +procedure TOpenSSL_TestCase.Signature; +var + sSecret: utf8string; + Secret: TStream; +begin +FSig.PrivateKey := PrivateKey1; +FSig.PrivateKeyStoragePassword := 'honey'; +FSig.PrivateKeyStorageCipher := cipher_aes_256_cbc; +Secret := TMemoryStream.Create; +FSig.StoreKeysToStream( Secret, [partPrivate]); +Secret.Position := 0; +SetLength( sSecret, Secret.Size); +if Secret.Size > 0 then + Secret.ReadBuffer( sSecret[1], Secret.Size); +Secret.Position := 0; +Check( Pos('-----BEGIN RSA PRIVATE KEY-----', sSecret) > 0, 'OpenSSL key not properly stored.'); +Check( Pos('ENCRYPTED', sSecret) > 0, 'OpenSSL key not properly encrypted.'); +FSig.LoadKeysFromStream( Secret, [partPrivate]); +Secret.Free; +Check( FSig.SignVerify_SelfTest); +end; + +procedure TOpenSSL_TestCase.TearDown; +begin +FcodecOpenSSL.Free; +FPlain.Free; +FCipher.Free; +FRecon.Free; +FSig.Free +end; + + + + +procedure TOpenSSL_TestCase.TwoGenerations; +begin +Check( FSig.GenerateKeys); +Check( FSig.GenerateKeys); +end; + + + + +initialization +InitUnit_OpenSSLTestCases_TestCases; + + +finalization +DoneUnit_OpenSSLTestCases_TestCases; + +end. diff --git a/unit-tests/dunit/uLockBox_RSA_TestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_RSA_TestCases.pas similarity index 96% rename from unit-tests/dunit/uLockBox_RSA_TestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_RSA_TestCases.pas index 3b0e68b..bc7f0ca 100644 --- a/unit-tests/dunit/uLockBox_RSA_TestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_RSA_TestCases.pas @@ -1,520 +1,520 @@ -unit uLockBox_RSA_TestCases; -interface -uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, - TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, - TPLB3.MemoryStreamPool; - -type -TRSA_TestCase = class( TTestCase) - protected - FPool: IMemoryStreamPool; - FwasAborted: boolean; - FdoAbort: boolean; - - procedure SetUp; override; - procedure TearDown; override; - procedure OnProgress( Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); - procedure CheckPowerModWithCRT( - m, d, n, p, q, dp, dq, qinv: THugeCardinal; - const Msg: string); - - published - procedure ChineseRemainderTheorem; - procedure Test_Compute_RSA_Fundamentals; - procedure Test_RSA_Primitives; - procedure Cardinal2Stream_InversionTests; - procedure RSAES_OAEP_ENCDECRYPT; - end; - - -TRSA_Crypto_TestCase = class( TTestCase) - protected - FPool: IMemoryStreamPool; - FwasAborted: boolean; - FdoAbort: boolean; - - Lib: TCryptographicLibrary; - Codec: TCodec; - - procedure SetUp; override; - procedure TearDown; override; - - published - procedure Test_Encrypt; - end; - -implementation - - - - - - -uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, - TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, - TPLB3.IntegerUtils, TPLB3.RSA_Primitives, Forms; - - -{ TTestCaseFirst } - -// Output from a run of Make Sample Key -// ================================== BEGIN ===================== -//Now generating an RSA-1024 key pair -//Generation completed. -//Generation took 34s. -//318 primality tests were conducted to reach this goal, -//at a rate of 9.4 tests per second. -// -//n has 1024 bits. -//e has 17 bits. -//d has 1022 bits. -//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; -// -//e (little-endien; base64) = "AQAB"; -// -//e (decimal) = 65537 -// -//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; -// -// -//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; -//Now generating an RSA-1024 key pair -//Generation completed. -//Generation took 34s. -//318 primality tests were conducted to reach this goal, -//at a rate of 9.4 tests per second. -// -//n has 1024 bits. -//e has 17 bits. -//d has 1022 bits. -//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; -// -//e (little-endien; base64) = "AQAB"; -// -//e (decimal) = 65537 -// -//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; -// -// -//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; -// ================================== END ===================== - -const - Test_n: utf8string = // n (little-endien; base64) - 'u9GFdi6di8zy/ZoPVdyNjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTNneme' + - 'V5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZOrz80SfVals7e+/cIAxIi4v/n1OP2VVG' + - 'l6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k='; - Test_n_bits = 1024; - - Test_e: utf8string = // e (little-endien; base64) - 'AQAB'; - Test_e_bits = 17; - - Test_d: utf8string = // d (little-endien; base64) - 'cY9AhO6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR' + - '3fXxpRI2IibOEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lNfO1OIC' + - 'jlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic='; - Test_d_bits = 1022; - - Test_AES256Key: utf8string = // (base64; LoadFromStream) - '+KcK4snvh88mf8OxcdU3ri1HSPyqRu1pb0+pEB511jE='; - -procedure InitUnit_RSA_TestCases; -begin -TestFramework.RegisterTest( TRSA_TestCase.Suite); -TestFramework.RegisterTest( TRSA_Crypto_TestCase.Suite); -end; - -procedure DoneUnit_RSA_TestCases; -begin -end; - - - - -{ TRSA_TestCase } - -procedure TRSA_TestCase.Cardinal2Stream_InversionTests; -var - i1, i2: THugeCardinal; - s1, s2: TMemoryStream; -begin -TRandomStream.Instance.Seed := 1; - -// 1. Create a Huge Cardinal of 64 bits (8 bytes). -i1 := THugeCardinal.CreateRandom( 64, 64, True, FPool); - -// 2. Stream it out to a 9 byte stream. -s1 := FPool.NewMemoryStream( 0); -i1.StreamOut( BigEndien, s1, 9); - -// 3. Stream it back in -s1.Position := 0; -i2 := THugeCardinal.CreateFromStreamIn( 64, BigEndien, s1, FPool); - -// 4. Compare cardinal with the original -Check( i1.Compare( i2) = rEqualTo, 'Cardinal --> Stream inversion test.'); - -// 1. Create a random stream with 4 bytes -s1.Size := 4; -RandomFillStream( s1); - -// 2. Stream it in. MaxBits = 32 -i1.Free; -s1.Position := 0; -i1 := THugeCardinal.CreateFromStreamIn( 32, BigEndien, s1, FPool); - -// 3. Stream it out. -s2 := FPool.NewMemoryStream( 4); -s2.Position := 0; -i1.StreamOut( BigEndien, s2, 4); - -// 4. Compare stream with the original. -Check( CompareMemoryStreams( s1, s2), 'Stream --> Cardinal inversion test.'); - -i1.Free; i2.Free; -s1.Free; s2.Free -end; - - - -procedure TRSA_TestCase.OnProgress( - Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); -begin -// Application.ProcessMessages -if FdoAbort then - doAbort := True -end; - - - -procedure TRSA_TestCase.RSAES_OAEP_ENCDECRYPT; -var - n, e, d, Totient: THugeCardinal; - Count1, j, i: integer; - Plaintext, Ciphertext, Recon: TMemoryStream; - p, q, dp, dq, qinv: THugeCardinal; -begin -TRandomStream.Instance.Seed := 1; -for j := 1 to 3 do - begin - Count1 := 0; - Compute_RSA_Fundamentals_2Factors( - 480, StandardExponent, n, e, d, Totient, - p, q, dp, dq, qinv, - nil, nil, 20, FPool, Count1, FwasAborted); - Check( Validate_RSA_Fundamentals( n, e, d, Totient), 'Failed to generate RSA key pair.'); - for i := 1 to 10 do - begin - Plaintext := TMemoryStream.Create; - Plaintext.Size := RSAES_OAEP_ENCRYPT_MaxByteLen( n); - RandomFillStream( Plaintext); - Plaintext.Position := 0; - Ciphertext := TMemoryStream.Create; - Check( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), 'RSAES_OAEP_ENCRYPT'); - Ciphertext.Position := 0; - Recon := TMemoryStream.Create; - Check( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), 'RSAES_OAEP_DECRYPT'); - Check( CompareMemoryStreams( Plaintext, Recon), 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT inversion.'); - Plaintext.Free; - Ciphertext.Free; - recon.Free; - Application.ProcessMessages; - end; - n.Free; - d.Free; - e.Free; - Totient.Free; - p.Free; q.Free; dp.Free; dq.Free; qinv.Free; - end; -end; - - - - -procedure TRSA_TestCase.SetUp; -begin -FPool := NewPool; -FwasAborted := False; -FdoAbort := False; -end; - -procedure TRSA_TestCase.TearDown; -begin -FPool := nil; -FwasAborted := False; -FdoAbort := False; -end; - -procedure TRSA_TestCase.Test_Compute_RSA_Fundamentals; -var - n, e, d, Totient: THugeCardinal; - Count1: integer; -// j, Sz, Current, Peak: integer; -// s: string; - p, q, dp, dq, qinv: THugeCardinal; -begin -GreatestPassCount := 0; - -Count1 := 0; -Compute_RSA_Fundamentals_2Factors( - 512, StandardExponent, n, e, d, Totient, - p, q, dp, dq, qinv, - OnProgress, nil, 20, FPool, Count1, FwasAborted); - -if not FwasAborted then - Check( Validate_RSA_Fundamentals( n, e, d, Totient), - 'Failed to generate RSA key pair.'); -Totient.Free; -n.Free; -e.Free; -d.Free; -p.Free; q.Free; dp.Free; dq.Free; qinv.Free; -//for j := 0 to FPool.BayCount - 1 do -// begin -// Sz := FPool.GetSize( j); -// FPool.GetUsage( Sz, Current, Peak); -// s := Format( 'MemSize=%d; Final=%d; Peak=%d; Passes=%d', [Sz, Current, Peak, GreatestPassCount]); -// s := s + ' ' -// end -end; - - -procedure TRSA_TestCase.CheckPowerModWithCRT( - m, d, n, p, q, dp, dq, qinv: THugeCardinal; - const Msg: string); -var - m1, m2: THugeCardinal; -begin - m1 := m.Clone; - m2 := m.Clone; - m1.PowerMod( d, n, nil); - m2.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil); - Check( m1.Compare( m2) = rEqualTo, Msg); - m1.Free; - m2.Free -end; - -procedure TRSA_TestCase.ChineseRemainderTheorem; -var - n, e, d, Totient: THugeCardinal; - Count1: integer; - p, q, dp, dq, qinv: THugeCardinal; - m0: THugeCardinal; - c: THugeCardinal; -begin - TRandomStream.Instance.Seed := 55; - - // result(=m==65) == pre_self(=c=2790) ** Exponent(=d=2753) mod Modulus(=n=3233) - c := THugeCardinal.CreateSimple( 2790); - d := THugeCardinal.CreateSimple( 2753); - n := THugeCardinal.CreateSimple( 3233); - dp := THugeCardinal.CreateSimple( 53); - dq := THugeCardinal.CreateSimple( 49); - qinv := THugeCardinal.CreateSimple( 38); - p := THugeCardinal.CreateSimple( 61); - q := THugeCardinal.CreateSimple( 53); - CheckPowerModWithCRT( c, d, n, p, q, dp, dq, qinv, 'PowerMod failed Wikipedia example.'); - FreeAndNil( c); - FreeAndNil( d); - FreeAndNil( n); - FreeAndNil( dp); - FreeAndNil( dq); - FreeAndNil( qinv); - FreeAndNil( p); - FreeAndNil( q); - -GreatestPassCount := 0; -Count1 := 0; -Compute_RSA_Fundamentals_2Factors( - 512, StandardExponent, n, e, d, Totient, - p, q, dp, dq, qinv, - OnProgress, nil, 20, FPool, Count1, FwasAborted); - -m0 := THugeCardinal.CreateRandom( n.BitLength, n.BitLength, False, nil); -if not FwasAborted then - CheckPowerModWithCRT( m0, d, n, p, q, dp, dq, qinv, 'PowerMod failed.'); -m0.Free; -Totient.Free; -n.Free; -e.Free; -d.Free; -p.Free; q.Free; dp.Free; dq.Free; qinv.Free; -end; - - - - -procedure TRSA_TestCase.Test_RSA_Primitives; -var - Tmp: TStream; - n, e, d: THugeCardinal; - p, q, dp, dq, qinv: THugeCardinal; - - PlainText, Ciphertext, Recon: TMemoryStream; - - function MakeHuge( const Definition: utf8string; BitLen: cardinal) - : THugeCardinal; - begin - Tmp.Size := 0; - Base64_to_stream( Definition, Tmp); - Tmp.Position := 0; - result := THugeCardinal.CreateFromStreamIn( BitLen, LittleEndien, Tmp, FPool) - end; - -begin -// 1. Create n -// 2. Create d -// 3. Create e -// 4. Create test plaintext stream -// 5. Encrypt -// 6. Check encryption result -// 7. Decyrpt -// 8. Check decryption result -// 9. Compare and check plaintext with reconstruction -// 10. Clean-up (n, d, e, plaintext, ciphertext, recon) - -TRandomStream.Instance.Seed := 1; -Tmp := FPool.NewMemoryStream( 0); -PlainText := TMemoryStream.Create; -Ciphertext := TMemoryStream.Create; -Recon := TMemoryStream.Create; -n := MakeHuge( Test_n, Test_n_bits); -e := MakeHuge( Test_e, Test_e_bits); -d := MakeHuge( Test_d, Test_d_bits); -p := nil; -q := nil; -dp := nil; -dq := nil; -qinv := nil; -PlainText.Size := 40; -RandomFillStream( Plaintext); - -try -Check( PlainText.Size <= RSAES_OAEP_ENCRYPT_MaxByteLen( n), - Format('Plaintext too big (%d) for RSA keys.',[PlainText.Size])); - -Check( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), - 'RSAES_OAEP_ENCRYPT'); - -Check( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), - 'RSAES_OAEP_DECRYPT'); - -Check( CompareMemoryStreams( Plaintext, Recon), - 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT general inversion test failed!') - -finally -Tmp.Free; -Plaintext.Free; -Ciphertext.Free; -Recon.Free; -n.Free; e.Free; d.Free; -p.Free; q.Free; dp.Free; dq.Free; qinv.Free; -end end; - - - -//PAllocationRecord(fpool.fallocrecord.[0])^.fpeakusage -// -//KeySize Trial PeakUsage -//512 1 21 -//512 2 18 -//512 3 19 -//512 4 18 -//512 5 18 -//512 6 19 -//512 7 18 -//512 8 18 -//1024 1 20 -//1024 2 19 -//1024 3 18 -//1024 4 18 -//1024 5 21 -//4096 1 -//4096 2 - -const - RSA_512_SampleKey1: utf8string = - 'QAAAADfRWmA3nhVOOvqB0CLoy1lvP6VwuPRY0gYMtGjS+G3vPVZG/adCkgcAuhduuzR' + - 'af42JCz75O8vrSS66owu2OWRAAAAA0YnbSszKdiN+s9zNiJizwIjK11cvNISf3jmFqB' + - 'iDCVKojcmJbnPEPsAbUlHx1oqpI4EpQuooNIC/3eELq0gZFAMAAAABAAE='; - - RSA_512_SampleKey2: utf8string = - 'QAAAAB90ZOa8vuzPpmWuWReBRuE12r/oAfFMJdBk8XfTIHB26+o1u1VtwV0NRYaqR/N' + - '4dkvhfF8Eb1LgzRZzf1vh9JlAAAAAcenoFSj7DtDGUByUhN3zcB+eOD0/sNn1Fqaizm' + - '+qUv1RUUg+iXnQw1qZVlLliNzvZw3k01M2myXAsJNOLVXYDwMAAAABAAE='; - - RSA_1024_SampleKey1: utf8string = - 'gAAAAIWILE/fqXIjMtXbxffzixJ3T71Kg+JsSzwuEuqbwP5y/D2f7XluAC4cYoCU3qA' + - 'WfRy23JaR+rXAWFMw2J/MSEO43Vbq1RHis0jeb4JD44Y9D1zV+sJ8CIWhzp38QzqhGb' + - 'PMDAFDQXwd9Hf5Ch9qoh7NJR7KWFBWZuA5kK/eiF2CgAAAABMwrc8ZDRGbb8uWsTNcm' + - 'sV0DoQ6gLZTLwSNAsjadAmPHviXRleVIQaBeruwuWSYUBbNJOQrPb095KM9s7BDlxSN' + - 'WJnvBkGYQx9ZXbHdwrMDlKQEkpkoetkbGSWZGLBRRCW3muhQIIXOtQ1ABUASi9HKuno' + - 'zojA3/qbs5HHn1Y0gAwAAAAEAAQ=='; - - RSA_1024_SampleKey2: utf8string = - 'gAAAAC9TuThwZQG596+UXAwLGLR5gdhOns4RmB4a/QBq0PLfaX8QiLhx4ziihWRHh2u' + - 'AtYM7TgWFegIv5ZJ75uNjpyNHOx/qOhrUwRUzCi5NT5Atl7iDwPz42uqUjJOoDNpsBx' + - 'lXhWIZUFrer3jY5b/ZJiNrt+A+I7LhaEmCbLsb9MB8gAAAAO3PcBC72KBGVQXgZJWQw' + - 'U24e9cGKYu3h4J6ujTqfdWR21QQJGbWjbl9UG6JdLSxsESxQ2FcPa0s/UWfQEdmmRhK' + - 'OjGYvSiLnlNjoUdJiXjrQ1n0lUcR/Z7+pYFdtY3P12JQ9Oml7jBwYbMFvddqh4qgPkJ' + - 'GcJLw1+G5w8DPez0BAwAAAAEAAQ=='; - - -{ TRSA_Crypto_TestCase } - -procedure TRSA_Crypto_TestCase.SetUp; -var - Store: TStream; - s: utf8string; -begin -Lib := TCryptographicLibrary.Create( nil); -Codec := TCodec.Create( nil); -Codec.CryptoLibrary := Lib; -Codec.StreamCipherId := 'native.RSA'; -Codec.AsymetricKeySizeInBits := 1024; -Store := TMemoryStream.Create; -try -case Codec.AsymetricKeySizeInBits of - 512: s := RSA_512_SampleKey1; - 1024: s := RSA_1024_SampleKey1; - else Check( False, 'No test case yet for this key size.'); - end; -Base64_to_stream( s, Store); -Store.Position := 0; -Codec.InitFromStream( Store); -finally -Store.Free; -end end; - - - -procedure TRSA_Crypto_TestCase.TearDown; -begin -Codec.Free; -Lib.Free -end; - - -procedure TRSA_Crypto_TestCase.Test_Encrypt; -const - sTestPlaintext: string = 'Test me!'; -var - x, y, recon_x: string; -begin -x := sTestPlaintext; -Codec.EncryptString( x, y, TEncoding.UTF8); -Codec.Reset; -Codec.DecryptString( recon_x, y, TEncoding.UTF8); -Check( x = recon_x, 'RSA Crypto'); -end; - - -initialization -InitUnit_RSA_TestCases; - - -finalization -DoneUnit_RSA_TestCases; - -end. +unit uLockBox_RSA_TestCases; +interface +uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, + TPLB3.MemoryStreamPool; + +type +TRSA_TestCase = class( TTestCase) + protected + FPool: IMemoryStreamPool; + FwasAborted: boolean; + FdoAbort: boolean; + + procedure SetUp; override; + procedure TearDown; override; + procedure OnProgress( Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); + procedure CheckPowerModWithCRT( + m, d, n, p, q, dp, dq, qinv: THugeCardinal; + const Msg: string); + + published + procedure ChineseRemainderTheorem; + procedure Test_Compute_RSA_Fundamentals; + procedure Test_RSA_Primitives; + procedure Cardinal2Stream_InversionTests; + procedure RSAES_OAEP_ENCDECRYPT; + end; + + +TRSA_Crypto_TestCase = class( TTestCase) + protected + FPool: IMemoryStreamPool; + FwasAborted: boolean; + FdoAbort: boolean; + + Lib: TCryptographicLibrary; + Codec: TCodec; + + procedure SetUp; override; + procedure TearDown; override; + + published + procedure Test_Encrypt; + end; + +implementation + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.RSA_Primitives, Forms; + + +{ TTestCaseFirst } + +// Output from a run of Make Sample Key +// ================================== BEGIN ===================== +//Now generating an RSA-1024 key pair +//Generation completed. +//Generation took 34s. +//318 primality tests were conducted to reach this goal, +//at a rate of 9.4 tests per second. +// +//n has 1024 bits. +//e has 17 bits. +//d has 1022 bits. +//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; +// +//e (little-endien; base64) = "AQAB"; +// +//e (decimal) = 65537 +// +//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; +// +// +//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; +//Now generating an RSA-1024 key pair +//Generation completed. +//Generation took 34s. +//318 primality tests were conducted to reach this goal, +//at a rate of 9.4 tests per second. +// +//n has 1024 bits. +//e has 17 bits. +//d has 1022 bits. +//n (little-endien; base64) = "u9GFdi6di8zy/ZoPVdyOjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTOnemeV5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZNrz80SfVals7e+/cIAxIi4v/n1NP2VVGl6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k="; +// +//e (little-endien; base64) = "AQAB"; +// +//e (decimal) = 65537 +// +//d (little-endien; base64) = "cY9AhN6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR3fXxpRI2IibNEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lOfN1NICjlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic="; +// +// +//AES-256 key (base64) = "+KcK4snvh88mf8NxcdU3ri1HSPyqRu1pb0+pEB511jE="; +// ================================== END ===================== + +const + Test_n: utf8string = // n (little-endien; base64) + 'u9GFdi6di8zy/ZoPVdyNjtXdozDgVWXPCkHYIZ1DDsLI+rwhkY9CdnlJ6kjAtTNneme' + + 'V5n/+l9xuzrI4d1x+UlQegAkQSgLbhWp9XZOrz80SfVals7e+/cIAxIi4v/n1OP2VVG' + + 'l6ABfZr+qnv3EZVhf+nwqwForIgsdEuVmSy8k='; + Test_n_bits = 1024; + + Test_e: utf8string = // e (little-endien; base64) + 'AQAB'; + Test_e_bits = 17; + + Test_d: utf8string = // d (little-endien; base64) + 'cY9AhO6Jz6bQ0DVeoifJWTgMl5U6qvoDQX/d+Jsi8Tw2PfUP0RaAuHiiCP2qPS7ScxR' + + '3fXxpRI2IibOEcClGklXzXyKm3Q2p20/dz2LDjB8125fRF3i/jabGqZQEv2lNfO1OIC' + + 'jlZxyM9e19IRlJHg3TItmr2ELAjRYUjQWjqic='; + Test_d_bits = 1022; + + Test_AES256Key: utf8string = // (base64; LoadFromStream) + '+KcK4snvh88mf8OxcdU3ri1HSPyqRu1pb0+pEB511jE='; + +procedure InitUnit_RSA_TestCases; +begin +TestFramework.RegisterTest( TRSA_TestCase.Suite); +TestFramework.RegisterTest( TRSA_Crypto_TestCase.Suite); +end; + +procedure DoneUnit_RSA_TestCases; +begin +end; + + + + +{ TRSA_TestCase } + +procedure TRSA_TestCase.Cardinal2Stream_InversionTests; +var + i1, i2: THugeCardinal; + s1, s2: TMemoryStream; +begin +TRandomStream.Instance.Seed := 1; + +// 1. Create a Huge Cardinal of 64 bits (8 bytes). +i1 := THugeCardinal.CreateRandom( 64, 64, True, FPool); + +// 2. Stream it out to a 9 byte stream. +s1 := FPool.NewMemoryStream( 0); +i1.StreamOut( BigEndien, s1, 9); + +// 3. Stream it back in +s1.Position := 0; +i2 := THugeCardinal.CreateFromStreamIn( 64, BigEndien, s1, FPool); + +// 4. Compare cardinal with the original +Check( i1.Compare( i2) = rEqualTo, 'Cardinal --> Stream inversion test.'); + +// 1. Create a random stream with 4 bytes +s1.Size := 4; +RandomFillStream( s1); + +// 2. Stream it in. MaxBits = 32 +i1.Free; +s1.Position := 0; +i1 := THugeCardinal.CreateFromStreamIn( 32, BigEndien, s1, FPool); + +// 3. Stream it out. +s2 := FPool.NewMemoryStream( 4); +s2.Position := 0; +i1.StreamOut( BigEndien, s2, 4); + +// 4. Compare stream with the original. +Check( CompareMemoryStreams( s1, s2), 'Stream --> Cardinal inversion test.'); + +i1.Free; i2.Free; +s1.Free; s2.Free +end; + + + +procedure TRSA_TestCase.OnProgress( + Sender: TObject; BitsProcessed, TotalBits: int64; var doAbort: boolean); +begin +// Application.ProcessMessages +if FdoAbort then + doAbort := True +end; + + + +procedure TRSA_TestCase.RSAES_OAEP_ENCDECRYPT; +var + n, e, d, Totient: THugeCardinal; + Count1, j, i: integer; + Plaintext, Ciphertext, Recon: TMemoryStream; + p, q, dp, dq, qinv: THugeCardinal; +begin +TRandomStream.Instance.Seed := 1; +for j := 1 to 3 do + begin + Count1 := 0; + Compute_RSA_Fundamentals_2Factors( + 480, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + nil, nil, 20, FPool, Count1, FwasAborted); + Check( Validate_RSA_Fundamentals( n, e, d, Totient), 'Failed to generate RSA key pair.'); + for i := 1 to 10 do + begin + Plaintext := TMemoryStream.Create; + Plaintext.Size := RSAES_OAEP_ENCRYPT_MaxByteLen( n); + RandomFillStream( Plaintext); + Plaintext.Position := 0; + Ciphertext := TMemoryStream.Create; + Check( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), 'RSAES_OAEP_ENCRYPT'); + Ciphertext.Position := 0; + Recon := TMemoryStream.Create; + Check( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), 'RSAES_OAEP_DECRYPT'); + Check( CompareMemoryStreams( Plaintext, Recon), 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT inversion.'); + Plaintext.Free; + Ciphertext.Free; + recon.Free; + Application.ProcessMessages; + end; + n.Free; + d.Free; + e.Free; + Totient.Free; + p.Free; q.Free; dp.Free; dq.Free; qinv.Free; + end; +end; + + + + +procedure TRSA_TestCase.SetUp; +begin +FPool := NewPool; +FwasAborted := False; +FdoAbort := False; +end; + +procedure TRSA_TestCase.TearDown; +begin +FPool := nil; +FwasAborted := False; +FdoAbort := False; +end; + +procedure TRSA_TestCase.Test_Compute_RSA_Fundamentals; +var + n, e, d, Totient: THugeCardinal; + Count1: integer; +// j, Sz, Current, Peak: integer; +// s: string; + p, q, dp, dq, qinv: THugeCardinal; +begin +GreatestPassCount := 0; + +Count1 := 0; +Compute_RSA_Fundamentals_2Factors( + 512, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + OnProgress, nil, 20, FPool, Count1, FwasAborted); + +if not FwasAborted then + Check( Validate_RSA_Fundamentals( n, e, d, Totient), + 'Failed to generate RSA key pair.'); +Totient.Free; +n.Free; +e.Free; +d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +//for j := 0 to FPool.BayCount - 1 do +// begin +// Sz := FPool.GetSize( j); +// FPool.GetUsage( Sz, Current, Peak); +// s := Format( 'MemSize=%d; Final=%d; Peak=%d; Passes=%d', [Sz, Current, Peak, GreatestPassCount]); +// s := s + ' ' +// end +end; + + +procedure TRSA_TestCase.CheckPowerModWithCRT( + m, d, n, p, q, dp, dq, qinv: THugeCardinal; + const Msg: string); +var + m1, m2: THugeCardinal; +begin + m1 := m.Clone; + m2 := m.Clone; + m1.PowerMod( d, n, nil); + m2.PowerMod_WithChineseRemainderAlgorithm( d, n, p, q, dp, dq, qinv, nil); + Check( m1.Compare( m2) = rEqualTo, Msg); + m1.Free; + m2.Free +end; + +procedure TRSA_TestCase.ChineseRemainderTheorem; +var + n, e, d, Totient: THugeCardinal; + Count1: integer; + p, q, dp, dq, qinv: THugeCardinal; + m0: THugeCardinal; + c: THugeCardinal; +begin + TRandomStream.Instance.Seed := 55; + + // result(=m==65) == pre_self(=c=2790) ** Exponent(=d=2753) mod Modulus(=n=3233) + c := THugeCardinal.CreateSimple( 2790); + d := THugeCardinal.CreateSimple( 2753); + n := THugeCardinal.CreateSimple( 3233); + dp := THugeCardinal.CreateSimple( 53); + dq := THugeCardinal.CreateSimple( 49); + qinv := THugeCardinal.CreateSimple( 38); + p := THugeCardinal.CreateSimple( 61); + q := THugeCardinal.CreateSimple( 53); + CheckPowerModWithCRT( c, d, n, p, q, dp, dq, qinv, 'PowerMod failed Wikipedia example.'); + FreeAndNil( c); + FreeAndNil( d); + FreeAndNil( n); + FreeAndNil( dp); + FreeAndNil( dq); + FreeAndNil( qinv); + FreeAndNil( p); + FreeAndNil( q); + +GreatestPassCount := 0; +Count1 := 0; +Compute_RSA_Fundamentals_2Factors( + 512, StandardExponent, n, e, d, Totient, + p, q, dp, dq, qinv, + OnProgress, nil, 20, FPool, Count1, FwasAborted); + +m0 := THugeCardinal.CreateRandom( n.BitLength, n.BitLength, False, nil); +if not FwasAborted then + CheckPowerModWithCRT( m0, d, n, p, q, dp, dq, qinv, 'PowerMod failed.'); +m0.Free; +Totient.Free; +n.Free; +e.Free; +d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +end; + + + + +procedure TRSA_TestCase.Test_RSA_Primitives; +var + Tmp: TStream; + n, e, d: THugeCardinal; + p, q, dp, dq, qinv: THugeCardinal; + + PlainText, Ciphertext, Recon: TMemoryStream; + + function MakeHuge( const Definition: utf8string; BitLen: cardinal) + : THugeCardinal; + begin + Tmp.Size := 0; + Base64_to_stream( Definition, Tmp); + Tmp.Position := 0; + result := THugeCardinal.CreateFromStreamIn( BitLen, LittleEndien, Tmp, FPool) + end; + +begin +// 1. Create n +// 2. Create d +// 3. Create e +// 4. Create test plaintext stream +// 5. Encrypt +// 6. Check encryption result +// 7. Decyrpt +// 8. Check decryption result +// 9. Compare and check plaintext with reconstruction +// 10. Clean-up (n, d, e, plaintext, ciphertext, recon) + +TRandomStream.Instance.Seed := 1; +Tmp := FPool.NewMemoryStream( 0); +PlainText := TMemoryStream.Create; +Ciphertext := TMemoryStream.Create; +Recon := TMemoryStream.Create; +n := MakeHuge( Test_n, Test_n_bits); +e := MakeHuge( Test_e, Test_e_bits); +d := MakeHuge( Test_d, Test_d_bits); +p := nil; +q := nil; +dp := nil; +dq := nil; +qinv := nil; +PlainText.Size := 40; +RandomFillStream( Plaintext); + +try +Check( PlainText.Size <= RSAES_OAEP_ENCRYPT_MaxByteLen( n), + Format('Plaintext too big (%d) for RSA keys.',[PlainText.Size])); + +Check( RSAES_OAEP_ENCRYPT( n, e, Plaintext, Ciphertext), + 'RSAES_OAEP_ENCRYPT'); + +Check( RSAES_OAEP_DECRYPT( d, n, Ciphertext, Recon, p, q, dp, dq, qinv), + 'RSAES_OAEP_DECRYPT'); + +Check( CompareMemoryStreams( Plaintext, Recon), + 'RSAES_OAEP_ENCRYPT/RSAES_OAEP_DECRYPT general inversion test failed!') + +finally +Tmp.Free; +Plaintext.Free; +Ciphertext.Free; +Recon.Free; +n.Free; e.Free; d.Free; +p.Free; q.Free; dp.Free; dq.Free; qinv.Free; +end end; + + + +//PAllocationRecord(fpool.fallocrecord.[0])^.fpeakusage +// +//KeySize Trial PeakUsage +//512 1 21 +//512 2 18 +//512 3 19 +//512 4 18 +//512 5 18 +//512 6 19 +//512 7 18 +//512 8 18 +//1024 1 20 +//1024 2 19 +//1024 3 18 +//1024 4 18 +//1024 5 21 +//4096 1 +//4096 2 + +const + RSA_512_SampleKey1: utf8string = + 'QAAAADfRWmA3nhVOOvqB0CLoy1lvP6VwuPRY0gYMtGjS+G3vPVZG/adCkgcAuhduuzR' + + 'af42JCz75O8vrSS66owu2OWRAAAAA0YnbSszKdiN+s9zNiJizwIjK11cvNISf3jmFqB' + + 'iDCVKojcmJbnPEPsAbUlHx1oqpI4EpQuooNIC/3eELq0gZFAMAAAABAAE='; + + RSA_512_SampleKey2: utf8string = + 'QAAAAB90ZOa8vuzPpmWuWReBRuE12r/oAfFMJdBk8XfTIHB26+o1u1VtwV0NRYaqR/N' + + '4dkvhfF8Eb1LgzRZzf1vh9JlAAAAAcenoFSj7DtDGUByUhN3zcB+eOD0/sNn1Fqaizm' + + '+qUv1RUUg+iXnQw1qZVlLliNzvZw3k01M2myXAsJNOLVXYDwMAAAABAAE='; + + RSA_1024_SampleKey1: utf8string = + 'gAAAAIWILE/fqXIjMtXbxffzixJ3T71Kg+JsSzwuEuqbwP5y/D2f7XluAC4cYoCU3qA' + + 'WfRy23JaR+rXAWFMw2J/MSEO43Vbq1RHis0jeb4JD44Y9D1zV+sJ8CIWhzp38QzqhGb' + + 'PMDAFDQXwd9Hf5Ch9qoh7NJR7KWFBWZuA5kK/eiF2CgAAAABMwrc8ZDRGbb8uWsTNcm' + + 'sV0DoQ6gLZTLwSNAsjadAmPHviXRleVIQaBeruwuWSYUBbNJOQrPb095KM9s7BDlxSN' + + 'WJnvBkGYQx9ZXbHdwrMDlKQEkpkoetkbGSWZGLBRRCW3muhQIIXOtQ1ABUASi9HKuno' + + 'zojA3/qbs5HHn1Y0gAwAAAAEAAQ=='; + + RSA_1024_SampleKey2: utf8string = + 'gAAAAC9TuThwZQG596+UXAwLGLR5gdhOns4RmB4a/QBq0PLfaX8QiLhx4ziihWRHh2u' + + 'AtYM7TgWFegIv5ZJ75uNjpyNHOx/qOhrUwRUzCi5NT5Atl7iDwPz42uqUjJOoDNpsBx' + + 'lXhWIZUFrer3jY5b/ZJiNrt+A+I7LhaEmCbLsb9MB8gAAAAO3PcBC72KBGVQXgZJWQw' + + 'U24e9cGKYu3h4J6ujTqfdWR21QQJGbWjbl9UG6JdLSxsESxQ2FcPa0s/UWfQEdmmRhK' + + 'OjGYvSiLnlNjoUdJiXjrQ1n0lUcR/Z7+pYFdtY3P12JQ9Oml7jBwYbMFvddqh4qgPkJ' + + 'GcJLw1+G5w8DPez0BAwAAAAEAAQ=='; + + +{ TRSA_Crypto_TestCase } + +procedure TRSA_Crypto_TestCase.SetUp; +var + Store: TStream; + s: utf8string; +begin +Lib := TCryptographicLibrary.Create( nil); +Codec := TCodec.Create( nil); +Codec.CryptoLibrary := Lib; +Codec.StreamCipherId := 'native.RSA'; +Codec.AsymetricKeySizeInBits := 1024; +Store := TMemoryStream.Create; +try +case Codec.AsymetricKeySizeInBits of + 512: s := RSA_512_SampleKey1; + 1024: s := RSA_1024_SampleKey1; + else Check( False, 'No test case yet for this key size.'); + end; +Base64_to_stream( s, Store); +Store.Position := 0; +Codec.InitFromStream( Store); +finally +Store.Free; +end end; + + + +procedure TRSA_Crypto_TestCase.TearDown; +begin +Codec.Free; +Lib.Free +end; + + +procedure TRSA_Crypto_TestCase.Test_Encrypt; +const + sTestPlaintext: string = 'Test me!'; +var + x, y, recon_x: string; +begin +x := sTestPlaintext; +Codec.EncryptString( x, y, TEncoding.UTF8); +Codec.Reset; +Codec.DecryptString( recon_x, y, TEncoding.UTF8); +Check( x = recon_x, 'RSA Crypto'); +end; + + +initialization +InitUnit_RSA_TestCases; + + +finalization +DoneUnit_RSA_TestCases; + +end. diff --git a/unit-tests/dunit/uLockBox_Signatory_TestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_Signatory_TestCases.pas similarity index 96% rename from unit-tests/dunit/uLockBox_Signatory_TestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_Signatory_TestCases.pas index 2ca4480..aa25e13 100644 --- a/unit-tests/dunit/uLockBox_Signatory_TestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_Signatory_TestCases.pas @@ -1,204 +1,204 @@ -unit uLockBox_Signatory_TestCases; -interface -uses TestFramework, TPLB3.MemoryStreamPool, Classes, TPLB3.Signatory, - TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random; - -const - -Key1_v0: utf8string = -'gAAAABVmVoAtVC4GNZi1ue+wlopkpnPkpp00bgzW5fphnOmG8ulfRoPPe9l1Asp+kfZEikoh' + -'SRmcPOW3yNKwOMyqZCFY0CWNjnChXgytOPaMYyYbWZZ/v9LOv6zZ0ucpThUuw4Prz5JJP7a7' + -'o5ODlIWD73gYCixJqJD5a0aXkWYqUG+EAwAAAAEAAYAAAADnwM7wBHZVUpEi9H+N5urr7+1q' + -'YuJtH57gYHDtw/O6I+FC2BxQhYIGydxvKNx87+z6aPYUVaLVc4OmSCL02DeN1vOlF5lRYhA0' + -'/nMChN9nCtdvF39NdD7qbSVWlnyl/tEUXRAFsxC7DzgKyrFck0rJAaEvRspL+eNZXcOCJeUU' + -'FYAAAADl+xGZxpkIb/VWE2943aqWQRpTET/3sjHXG+/ckZ1heGoXwtrUeQ5iztVT7oIg1mbE' + -'cl9b2Y6q2jjGynNMT6VOYDpQUqneDQ7e6LQXtukkJTNrT0SAF/2QYLxJ8fs5BE5ImeDRwb90' + -'WlkHWYGXQklRF71NOBXyvMTzwVYxKjuXiwMAAAABAAF/AAAAxWlONs6snpUASKl0Q+iGbTF9' + -'sxEkQx/+d4Vb9kJ4GuyfRGC74yd7zgz9r5P/cwezX6jNjJqws8ZV9IeOb+UhepJ0rrAeFB1p' + -'0IIOXXS6u8cw4PDZ7bwJUt/nYLH+tt14ZhYO9Lf1LXq6trqnXbA5CBwvseS7zkcDwvGMefWR' + -'wQ=='; - -Key2_v1: utf8string = -'TgpMb2NrQm94MwEAAAAPgAAAAEGFoI9kf0jiiNFG9EwOA4OCe31UgeYiCo5o+tGuW0aY5AUr' + -'L+hlZn5TuZAsLXc5jegyT3aqgQZgIb0/9/J/Xog1TCucvRurQ5FvmK7THqODi7m8q9f1v28N' + -'t9EqPATYdkJZlpplOnylW8dTwxsflQ0FWzdQMS2nTa/apv65sv6uAwAAAAEAAYAAAAD5/6/A' + -'Xw4Hn86czZJuiaZZ7J86nfzTq6jZv0ytY2/60JLDRfTEt7UHWRZbn5OYSDY/6uqUAyqn1HWT' + -'tb/eR8uyOsYaJRfT8RSFpwdYNpktdqHJoK9i/9tMGqYyYEXM0EX0H8QndHQKjFIKS0gS2wvD' + -'2mSYK+BigEtp8GZ5FI1OSUEAAADfv58/cruaW29nVgQHe79vThxJk0BjbAdP7b10SNUjcp2q' + -'9a6NbTYFC+OEkicxiW+O6PjMYOe/Qn/J2Ipyq5YEA0AAAADf3oszxOLVhKFEBSb4tXIEQ73b' + -'jlALC1ZW8uGcMxPwlEPGqvQEQzE+dFAdHkc7nj3OjczOmWPHNsgCaQTCNfw5QQAAADP6Lz5T' + -'xKvaLnPu4U+/ofhoMI9jqQbV67fvaK1v+gH59N3b+ZsCQmCmR4rQWlyKbA5uIFcHE5Md217i' + -'LNGqmsYCQAAAAEWhiRykobdu7mTOe4TVoPB+TpLfijY/e+992Mh1R02HnSqil3OM45lEoawb' + -'RUp2+/hBI+sG6ThICFi9G+Rp7AFAAAAAfUaWk66hjVdvH1Z/y52CI2Xh8yoafToIBH+TkEqR' + -'DSqz2MX9bndkQCUx1S1/kbM16IZcrpnWyPZY2Fv8vComp04KTG9ja0JveDMBAAAAD4AAAACD' + -'z9tWaMOeYID0V9zKzWYVk0yDmw8cGtyNYKOujgVa23VYg3Kzr0WTLVRk1FQfy+OmDu09zUz1' + -'VfNN7gMBwkMz3Vr4g45qEcPEkFOizzIDI/O6uoioIVDP3SJU3Mn5cQqjQ7N50Qz31A2mAksd' + -'HHgCPFzXATf0h1CVWpJMGzgCZgMAAAABAAGAAAAA/T1FuYxHzWDyAK5YM2PazZY+BhgkPskA' + -'7fwBxfF2imackHqX7CTsU/i6NJ57jdoAyGU+hjqocBPrgml6mSAOKbk8rT1JdtoPzGaFlVcH' + -'LSHyvfTD166GdyLnG37zWEiGswFkjQE8LCxXeSbxHBY9k9H+hQhhrpILA8svr6hAQSRBAAAA' + -'9zUbH29H9X/U93cHhJ8otE+hBjE1hhralqoCsVLiFlhQv/7Pa3YG6L59SDzQ5SiuY5P6nZGV' + -'QmmDg+1DfjlMogJAAAAA1R8J3HZjIfU/R3ypQ3/psJ98EcVi9WTNrs2WfB3Su9+UCjUHn+FM' + -'DPnDSGZeQP/QpkiHkpOOwuLQqX/Gvl+6JkEAAABl/X6i6YwGMmfM5ziZxQMbsSohq1MqblGZ' + -'+OzrnsZvAJxpOtkGYca5g3NMux7g8V4KPW3u1Bzk6hPenWrAvHRKAUAAAAAlBKizOa53K8D+' + -'bUENbDSE7Ums8p4+zi+oZZo0M5wf10FBy5W21ABcdg3QmOzGNt1qgAW11cMKtk2gp5DBHL4j' + -'QQAAAKQHxCLfZ1B6nryWxUxbtCPjWNZckoGb4t5Tp5vKZ+l2F2H3qtfbl6iDbMvo1iijoEKu' + -'fu4VhjGk6IcWlvNIJn4B'; - - -type -TRSASignatory_TestCase = class( TTestCase) - private - FSeed_StandardTest: integer; - FDocumentSize_StandardTest: integer; - - protected - FKey: TStream; - FKey_v1: TStream; - FSig: TSignatory; - FcodecRSA: TCodec; - FLib: TCryptographicLibrary; - FDocument: TMemoryStream; - FSignature: TStream; - FRand: TRandomStream; - - procedure SetUp; override; - procedure TearDown; override; - function OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; - procedure Generic_Signatory_InversionTests( Seed: uint64{=-1 for random}; DocumentSize, KeyFormatVersion: integer); - - published - procedure Signatory_InversionTests_Version0Keys; - procedure Signatory_InversionTests_Version1Keys; - end; - -implementation - - - - - - - - - - - - - - - - - - - - -uses SysUtils, TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; - - -procedure InitUnit_Signatory_TestCases; -begin -TestFramework.RegisterTest( TRSASignatory_TestCase.Suite) -end; - - - -procedure DoneUnit_Signatory_TestCases; -begin -end; - - - -{ TRSASignatory_TestCase } - -procedure TRSASignatory_TestCase.SetUp; -begin -FRand := TRandomStream.Instance; -FSeed_StandardTest := 1; -FDocumentSize_StandardTest := 4000; -FKey := TMemoryStream.Create; -FKey_v1 := TMemoryStream.Create; -Base64_to_stream( Key1_v0, FKey); -Base64_to_stream( Key2_v1, FKey_v1); -FKey.Position := 0; -FKey_v1.Position := 0; -FSig := TSignatory.Create( nil); -FcodecRSA := TCodec.Create( nil); -FLib := TCryptographicLibrary.Create( nil); -FcodecRSA.CryptoLibrary := FLib; -FcodecRSA.StreamCipherId := RSA_ProgId; -FcodecRSA.OnProgress := OnProgress; -FSig.Codec := FcodecRSA; -FDocument := TMemoryStream.Create; -FSignature := TMemoryStream.Create; -end; - - - - -procedure TRSASignatory_TestCase.Signatory_InversionTests_Version0Keys; -begin -Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 0) -end; - - -procedure TRSASignatory_TestCase.Signatory_InversionTests_Version1Keys; -begin -Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 1) -end; - -procedure TRSASignatory_TestCase.Generic_Signatory_InversionTests( - Seed: uint64; DocumentSize, KeyFormatVersion: integer); -begin -if Seed = -1 then - FRand.Randomize - else - FRand.Seed := Seed; -FDocument.Size := DocumentSize; -RandomFillStream( FDocument); -FDocument.Position := 0; -FSignature.Size := 0; -if KeyFormatVersion = 0 then - FSig.LoadKeysFromStream( FKey, [partPublic, partPrivate]) - else - FSig.LoadKeysFromStream( FKey_v1, [partPublic, partPrivate]); -Check( FSig.Sign( FDocument, FSignature), 'RSA signature generation failed.'); -DisplayStream( FSignature); -Check( FSig.Verify( FDocument, FSignature)<>vFail, 'RSA signature verification failed.') -end; - - - - - -function TRSASignatory_TestCase.OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; -begin -result := True -end; - - - - - -procedure TRSASignatory_TestCase.TearDown; -begin -FreeAndNil( FSig); -FreeAndNil( FcodecRSA); -FreeAndNil( FLib); -FreeAndNil( FKey); -FreeAndNil( FKey_v1); -FreeAndNil( FDocument); -FreeAndNil( FSignature) -end; - - - - - -initialization -InitUnit_Signatory_TestCases; - - -finalization -DoneUnit_Signatory_TestCases; - -end. +unit uLockBox_Signatory_TestCases; +interface +uses TestFramework, TPLB3.MemoryStreamPool, Classes, TPLB3.Signatory, + TPLB3.Codec, TPLB3.CryptographicLibrary, TPLB3.Random; + +const + +Key1_v0: utf8string = +'gAAAABVmVoAtVC4GNZi1ue+wlopkpnPkpp00bgzW5fphnOmG8ulfRoPPe9l1Asp+kfZEikoh' + +'SRmcPOW3yNKwOMyqZCFY0CWNjnChXgytOPaMYyYbWZZ/v9LOv6zZ0ucpThUuw4Prz5JJP7a7' + +'o5ODlIWD73gYCixJqJD5a0aXkWYqUG+EAwAAAAEAAYAAAADnwM7wBHZVUpEi9H+N5urr7+1q' + +'YuJtH57gYHDtw/O6I+FC2BxQhYIGydxvKNx87+z6aPYUVaLVc4OmSCL02DeN1vOlF5lRYhA0' + +'/nMChN9nCtdvF39NdD7qbSVWlnyl/tEUXRAFsxC7DzgKyrFck0rJAaEvRspL+eNZXcOCJeUU' + +'FYAAAADl+xGZxpkIb/VWE2943aqWQRpTET/3sjHXG+/ckZ1heGoXwtrUeQ5iztVT7oIg1mbE' + +'cl9b2Y6q2jjGynNMT6VOYDpQUqneDQ7e6LQXtukkJTNrT0SAF/2QYLxJ8fs5BE5ImeDRwb90' + +'WlkHWYGXQklRF71NOBXyvMTzwVYxKjuXiwMAAAABAAF/AAAAxWlONs6snpUASKl0Q+iGbTF9' + +'sxEkQx/+d4Vb9kJ4GuyfRGC74yd7zgz9r5P/cwezX6jNjJqws8ZV9IeOb+UhepJ0rrAeFB1p' + +'0IIOXXS6u8cw4PDZ7bwJUt/nYLH+tt14ZhYO9Lf1LXq6trqnXbA5CBwvseS7zkcDwvGMefWR' + +'wQ=='; + +Key2_v1: utf8string = +'TgpMb2NrQm94MwEAAAAPgAAAAEGFoI9kf0jiiNFG9EwOA4OCe31UgeYiCo5o+tGuW0aY5AUr' + +'L+hlZn5TuZAsLXc5jegyT3aqgQZgIb0/9/J/Xog1TCucvRurQ5FvmK7THqODi7m8q9f1v28N' + +'t9EqPATYdkJZlpplOnylW8dTwxsflQ0FWzdQMS2nTa/apv65sv6uAwAAAAEAAYAAAAD5/6/A' + +'Xw4Hn86czZJuiaZZ7J86nfzTq6jZv0ytY2/60JLDRfTEt7UHWRZbn5OYSDY/6uqUAyqn1HWT' + +'tb/eR8uyOsYaJRfT8RSFpwdYNpktdqHJoK9i/9tMGqYyYEXM0EX0H8QndHQKjFIKS0gS2wvD' + +'2mSYK+BigEtp8GZ5FI1OSUEAAADfv58/cruaW29nVgQHe79vThxJk0BjbAdP7b10SNUjcp2q' + +'9a6NbTYFC+OEkicxiW+O6PjMYOe/Qn/J2Ipyq5YEA0AAAADf3oszxOLVhKFEBSb4tXIEQ73b' + +'jlALC1ZW8uGcMxPwlEPGqvQEQzE+dFAdHkc7nj3OjczOmWPHNsgCaQTCNfw5QQAAADP6Lz5T' + +'xKvaLnPu4U+/ofhoMI9jqQbV67fvaK1v+gH59N3b+ZsCQmCmR4rQWlyKbA5uIFcHE5Md217i' + +'LNGqmsYCQAAAAEWhiRykobdu7mTOe4TVoPB+TpLfijY/e+992Mh1R02HnSqil3OM45lEoawb' + +'RUp2+/hBI+sG6ThICFi9G+Rp7AFAAAAAfUaWk66hjVdvH1Z/y52CI2Xh8yoafToIBH+TkEqR' + +'DSqz2MX9bndkQCUx1S1/kbM16IZcrpnWyPZY2Fv8vComp04KTG9ja0JveDMBAAAAD4AAAACD' + +'z9tWaMOeYID0V9zKzWYVk0yDmw8cGtyNYKOujgVa23VYg3Kzr0WTLVRk1FQfy+OmDu09zUz1' + +'VfNN7gMBwkMz3Vr4g45qEcPEkFOizzIDI/O6uoioIVDP3SJU3Mn5cQqjQ7N50Qz31A2mAksd' + +'HHgCPFzXATf0h1CVWpJMGzgCZgMAAAABAAGAAAAA/T1FuYxHzWDyAK5YM2PazZY+BhgkPskA' + +'7fwBxfF2imackHqX7CTsU/i6NJ57jdoAyGU+hjqocBPrgml6mSAOKbk8rT1JdtoPzGaFlVcH' + +'LSHyvfTD166GdyLnG37zWEiGswFkjQE8LCxXeSbxHBY9k9H+hQhhrpILA8svr6hAQSRBAAAA' + +'9zUbH29H9X/U93cHhJ8otE+hBjE1hhralqoCsVLiFlhQv/7Pa3YG6L59SDzQ5SiuY5P6nZGV' + +'QmmDg+1DfjlMogJAAAAA1R8J3HZjIfU/R3ypQ3/psJ98EcVi9WTNrs2WfB3Su9+UCjUHn+FM' + +'DPnDSGZeQP/QpkiHkpOOwuLQqX/Gvl+6JkEAAABl/X6i6YwGMmfM5ziZxQMbsSohq1MqblGZ' + +'+OzrnsZvAJxpOtkGYca5g3NMux7g8V4KPW3u1Bzk6hPenWrAvHRKAUAAAAAlBKizOa53K8D+' + +'bUENbDSE7Ums8p4+zi+oZZo0M5wf10FBy5W21ABcdg3QmOzGNt1qgAW11cMKtk2gp5DBHL4j' + +'QQAAAKQHxCLfZ1B6nryWxUxbtCPjWNZckoGb4t5Tp5vKZ+l2F2H3qtfbl6iDbMvo1iijoEKu' + +'fu4VhjGk6IcWlvNIJn4B'; + + +type +TRSASignatory_TestCase = class( TTestCase) + private + FSeed_StandardTest: integer; + FDocumentSize_StandardTest: integer; + + protected + FKey: TStream; + FKey_v1: TStream; + FSig: TSignatory; + FcodecRSA: TCodec; + FLib: TCryptographicLibrary; + FDocument: TMemoryStream; + FSignature: TStream; + FRand: TRandomStream; + + procedure SetUp; override; + procedure TearDown; override; + function OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; + procedure Generic_Signatory_InversionTests( Seed: uint64{=-1 for random}; DocumentSize, KeyFormatVersion: integer); + + published + procedure Signatory_InversionTests_Version0Keys; + procedure Signatory_InversionTests_Version1Keys; + end; + +implementation + + + + + + + + + + + + + + + + + + + + +uses SysUtils, TPLB3.StreamUtils, TPLB3.Constants, TPLB3.Asymetric; + + +procedure InitUnit_Signatory_TestCases; +begin +TestFramework.RegisterTest( TRSASignatory_TestCase.Suite) +end; + + + +procedure DoneUnit_Signatory_TestCases; +begin +end; + + + +{ TRSASignatory_TestCase } + +procedure TRSASignatory_TestCase.SetUp; +begin +FRand := TRandomStream.Instance; +FSeed_StandardTest := 1; +FDocumentSize_StandardTest := 4000; +FKey := TMemoryStream.Create; +FKey_v1 := TMemoryStream.Create; +Base64_to_stream( Key1_v0, FKey); +Base64_to_stream( Key2_v1, FKey_v1); +FKey.Position := 0; +FKey_v1.Position := 0; +FSig := TSignatory.Create( nil); +FcodecRSA := TCodec.Create( nil); +FLib := TCryptographicLibrary.Create( nil); +FcodecRSA.CryptoLibrary := FLib; +FcodecRSA.StreamCipherId := RSA_ProgId; +FcodecRSA.OnProgress := OnProgress; +FSig.Codec := FcodecRSA; +FDocument := TMemoryStream.Create; +FSignature := TMemoryStream.Create; +end; + + + + +procedure TRSASignatory_TestCase.Signatory_InversionTests_Version0Keys; +begin +Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 0) +end; + + +procedure TRSASignatory_TestCase.Signatory_InversionTests_Version1Keys; +begin +Generic_Signatory_InversionTests( FSeed_StandardTest, FDocumentSize_StandardTest, 1) +end; + +procedure TRSASignatory_TestCase.Generic_Signatory_InversionTests( + Seed: uint64; DocumentSize, KeyFormatVersion: integer); +begin +if Seed = -1 then + FRand.Randomize + else + FRand.Seed := Seed; +FDocument.Size := DocumentSize; +RandomFillStream( FDocument); +FDocument.Position := 0; +FSignature.Size := 0; +if KeyFormatVersion = 0 then + FSig.LoadKeysFromStream( FKey, [partPublic, partPrivate]) + else + FSig.LoadKeysFromStream( FKey_v1, [partPublic, partPrivate]); +Check( FSig.Sign( FDocument, FSignature), 'RSA signature generation failed.'); +DisplayStream( FSignature); +Check( FSig.Verify( FDocument, FSignature)<>vFail, 'RSA signature verification failed.') +end; + + + + + +function TRSASignatory_TestCase.OnProgress( Sender: TObject; CountBytesProcessed: Int64): Boolean; +begin +result := True +end; + + + + + +procedure TRSASignatory_TestCase.TearDown; +begin +FreeAndNil( FSig); +FreeAndNil( FcodecRSA); +FreeAndNil( FLib); +FreeAndNil( FKey); +FreeAndNil( FKey_v1); +FreeAndNil( FDocument); +FreeAndNil( FSignature) +end; + + + + + +initialization +InitUnit_Signatory_TestCases; + + +finalization +DoneUnit_Signatory_TestCases; + +end. diff --git a/unit-tests/dunit/uLockBox_TestCases.pas b/LockBox3/unit-tests/dunit/uLockBox_TestCases.pas similarity index 95% rename from unit-tests/dunit/uLockBox_TestCases.pas rename to LockBox3/unit-tests/dunit/uLockBox_TestCases.pas index 48a208b..686dad2 100644 --- a/unit-tests/dunit/uLockBox_TestCases.pas +++ b/LockBox3/unit-tests/dunit/uLockBox_TestCases.pas @@ -1,236 +1,236 @@ -unit uLockBox_TestCases; -interface -uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, - TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, - TPLB3.MemoryStreamPool; - -type - -// This test suite is down for maintenance. - -TEnvironment_TestCase = class( TTestCase) - published - procedure Test_Environment; - end; - - - - - - -implementation - - - - - - - - - - -uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, - TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, - TPLB3.IntegerUtils, TPLB3.SVN_Keywords, Dialogs, TPLB3.PointerArithmetic; - - -{ TTestCaseFirst } - - -procedure InitUnit_TestCases; -begin - // TestFramework.RegisterTest( TEnvironment_TestCase.Suite); - // Uncomment the above when the new version is ready. -end; - -procedure DoneUnit_TestCases; -begin -end; - - - - -function rcs_version_AsInteger: integer; -var - s, Pattern: string; - P, Code: integer; -begin -s := TestFramework.rcs_version; -// s like '$Revision: 27 $' or '$Revision: 41 $' -Pattern := '$Revision: '; -P := Pos( Pattern, s); -if P > 0 then - Delete( s, P, Length( Pattern)); -Pattern := ' '; -P := Pos( Pattern, s); -if P > 0 then - SetLength( s, P-1); -Val( s, result, Code); -if (s = '') or (Code <> 0) then - result := -1 // Signifying unknown version -end; - - -function DelphiVersion_DisplayName: string; -begin -result := ''; -{$ifdef VER210} -result := 'Delphi 2010'; -{$endif} - -{$ifdef VER200} -result := 'Delphi 2009'; -{$endif} - -{$ifdef VER190} -result := 'Delphi 2007 for .NET'; -{$endif} - -{$ifdef VER180} - {$ifdef VER185} - result := 'Delphi 2007'; - {$else} - result := 'Delphi 2006'; - {$endif} -{$endif} - -{$ifdef VER170} -result := 'Delphi 2005'; -{$endif} - -{$ifdef VER160} -result := 'Delphi 8 for .NET'; -{$endif} - -{$ifdef VER150} -result := 'Delphi 7'; -{$endif} - -{$IF compilerversion < 15} - // Delphi 6 or earlier -result := 'Archaic version of Delphi (not supported).'; -{$IFEND} - -{$IF (compilerversion >= 22.0) and (compilerversion < 23.0)} -result := 'Delphi XE'; -{$IFEND} - -{$IF (compilerversion >= 23.0) and (compilerversion < 24.0)} - result := 'Delphi XE2'; -{$IFEND} - -{$IF (compilerversion >= 24.0) and (compilerversion < 25.0)} - result := 'Delphi XE3'; -{$IFEND} - -{$IF (compilerversion >= 25.0) and (compilerversion < 26.0)} - result := 'Delphi XE4'; -{$IFEND} - -{$IF (compilerversion >= 26.0) and (compilerversion < 27.0)} - result := 'Delphi XE5'; -{$IFEND} - -{$IF (compilerversion >= 27.0) and (compilerversion < 28.0)} - result := 'Delphi XE6'; -{$IFEND} - -{$IF (compilerversion >= 23.0) and (compilerversion < 28.0)} - {$IFDEF WIN32} - result := result + ' Win 32-bit'; - {$ENDIF} - - {$IFDEF WIN64} - result := result + ' Win 64-bit';; - {$ENDIF} - - {$IFDEF IOS} - result := result + ' iOX'; - {$ENDIF} - - {$IFDEF MACOS} - result := result + ' OS X'; - {$ENDIF} - - {$IFDEF ANDROID} - result := result + ' Android'; - {$ENDIF} -{$IFEND} - - -{$IF compilerversion >= 28.0} -result := 'Unrecognised version of Delphi later than Delphi XE6'; -{$IFEND} - -if result = '' then - result := 'Unrecognised version of Delphi'; -end; - - -{ TEnvironment_TestCase } - -procedure TEnvironment_TestCase.Test_Environment; -var - Ver: integer; - Announcement: string; - -begin -Ver := rcs_version_AsInteger; -if System.RTLVersion >= 19.00 then - Check( (Ver >= 27) and (Ver <= 41), - 'These unit tests were ONLY made for revisions 27 through to 41 of D-Unit.') - else - Check( Ver = 36, - 'For D7 and D2007 these unit tests were ONLY made for revision 36 of D-Unit.'); - // Nota bene: revision 41 is not compatible with Delphi 7. - -Check( (System.RTLVersion = 15.00) or - (System.RTLVersion = 17.00) or - (System.RTLVersion = 18.00) or - (System.RTLVersion = 21.00) or - (System.RTLVersion = 23.00), - 'These unit tests were ONLY made for Delphi 7, Delphi 2005, Delphi 2007 for win32 ' + - '(Enterprise edition), Delphi 2010, Delphi XE2 win 32-bit and Delphi win XE 64-bit.'); - -if SizeOf( TrueNativeInt ) <> SizeOf( pointer) then - ShowMessageFmt( 'Integer = %d bytes'#13#10 + - 'NativeInt = %d bytes'#13#10 + - 'TrueNativeInt = %d bytes'#13#10 + - 'Pointer = %d bytes'#13#10 + - 'Compiler = %.2f bytes', - [SizeOf(Integer), SizeOf( NativeInt), SizeOf( TrueNativeInt), SizeOf( pointer), CompilerVersion]); -Check( (SizeOf( TrueNativeInt ) = SizeOf( pointer)) and - (SizeOf( TrueNativeUInt) = SizeOf( pointer)), - 'uTPLb_PointerArithmetic Native Integer definitions wrong.'); - -Announcement := Format( 'You are running DUnit at SVN revision %d.', [Ver]); -Announcement := Announcement + #13#10; -Announcement := Announcement + Format( 'The SVN revision of the ' + - 'uTPLb_SVN_Keywords unit of the TPLB3 run-time package is %d.'#13#10 + - 'Check the TPLB3 project options for the run-time package library version.', - [TPLB3Runtime_SVN_Revision]); - - -Announcement := Announcement + #13#10; -Announcement := Announcement + Format( 'You are testing with compiler %s', - [DelphiVersion_DisplayName]); - -ShowMessage( Announcement); -end; - - - - - - -initialization -InitUnit_TestCases; - - -finalization -DoneUnit_TestCases; - - - -end. - +unit uLockBox_TestCases; +interface +uses TestFramework, TPLB3.Hash, TPLB3.CryptographicLibrary, Classes, + TPLB3.Codec, TPLB3.StreamCipher, TPLB3.HugeCardinal, + TPLB3.MemoryStreamPool; + +type + +// This test suite is down for maintenance. + +TEnvironment_TestCase = class( TTestCase) + published + procedure Test_Environment; + end; + + + + + + +implementation + + + + + + + + + + +uses SysUtils, TPLB3.HashDsc, TPLB3.BinaryUtils, TPLB3.StreamUtils, + TPLB3.ECB, TPLB3.BlockCipher, TPLB3.Random, TPLB3.HugeCardinalUtils, + TPLB3.IntegerUtils, TPLB3.SVN_Keywords, Dialogs, TPLB3.PointerArithmetic; + + +{ TTestCaseFirst } + + +procedure InitUnit_TestCases; +begin + // TestFramework.RegisterTest( TEnvironment_TestCase.Suite); + // Uncomment the above when the new version is ready. +end; + +procedure DoneUnit_TestCases; +begin +end; + + + + +function rcs_version_AsInteger: integer; +var + s, Pattern: string; + P, Code: integer; +begin +s := TestFramework.rcs_version; +// s like '$Revision: 27 $' or '$Revision: 41 $' +Pattern := '$Revision: '; +P := Pos( Pattern, s); +if P > 0 then + Delete( s, P, Length( Pattern)); +Pattern := ' '; +P := Pos( Pattern, s); +if P > 0 then + SetLength( s, P-1); +Val( s, result, Code); +if (s = '') or (Code <> 0) then + result := -1 // Signifying unknown version +end; + + +function DelphiVersion_DisplayName: string; +begin +result := ''; +{$ifdef VER210} +result := 'Delphi 2010'; +{$endif} + +{$ifdef VER200} +result := 'Delphi 2009'; +{$endif} + +{$ifdef VER190} +result := 'Delphi 2007 for .NET'; +{$endif} + +{$ifdef VER180} + {$ifdef VER185} + result := 'Delphi 2007'; + {$else} + result := 'Delphi 2006'; + {$endif} +{$endif} + +{$ifdef VER170} +result := 'Delphi 2005'; +{$endif} + +{$ifdef VER160} +result := 'Delphi 8 for .NET'; +{$endif} + +{$ifdef VER150} +result := 'Delphi 7'; +{$endif} + +{$IF compilerversion < 15} + // Delphi 6 or earlier +result := 'Archaic version of Delphi (not supported).'; +{$IFEND} + +{$IF (compilerversion >= 22.0) and (compilerversion < 23.0)} +result := 'Delphi XE'; +{$IFEND} + +{$IF (compilerversion >= 23.0) and (compilerversion < 24.0)} + result := 'Delphi XE2'; +{$IFEND} + +{$IF (compilerversion >= 24.0) and (compilerversion < 25.0)} + result := 'Delphi XE3'; +{$IFEND} + +{$IF (compilerversion >= 25.0) and (compilerversion < 26.0)} + result := 'Delphi XE4'; +{$IFEND} + +{$IF (compilerversion >= 26.0) and (compilerversion < 27.0)} + result := 'Delphi XE5'; +{$IFEND} + +{$IF (compilerversion >= 27.0) and (compilerversion < 28.0)} + result := 'Delphi XE6'; +{$IFEND} + +{$IF (compilerversion >= 23.0) and (compilerversion < 28.0)} + {$IFDEF WIN32} + result := result + ' Win 32-bit'; + {$ENDIF} + + {$IFDEF WIN64} + result := result + ' Win 64-bit';; + {$ENDIF} + + {$IFDEF IOS} + result := result + ' iOX'; + {$ENDIF} + + {$IFDEF MACOS} + result := result + ' OS X'; + {$ENDIF} + + {$IFDEF ANDROID} + result := result + ' Android'; + {$ENDIF} +{$IFEND} + + +{$IF compilerversion >= 28.0} +result := 'Unrecognised version of Delphi later than Delphi XE6'; +{$IFEND} + +if result = '' then + result := 'Unrecognised version of Delphi'; +end; + + +{ TEnvironment_TestCase } + +procedure TEnvironment_TestCase.Test_Environment; +var + Ver: integer; + Announcement: string; + +begin +Ver := rcs_version_AsInteger; +if System.RTLVersion >= 19.00 then + Check( (Ver >= 27) and (Ver <= 41), + 'These unit tests were ONLY made for revisions 27 through to 41 of D-Unit.') + else + Check( Ver = 36, + 'For D7 and D2007 these unit tests were ONLY made for revision 36 of D-Unit.'); + // Nota bene: revision 41 is not compatible with Delphi 7. + +Check( (System.RTLVersion = 15.00) or + (System.RTLVersion = 17.00) or + (System.RTLVersion = 18.00) or + (System.RTLVersion = 21.00) or + (System.RTLVersion = 23.00), + 'These unit tests were ONLY made for Delphi 7, Delphi 2005, Delphi 2007 for win32 ' + + '(Enterprise edition), Delphi 2010, Delphi XE2 win 32-bit and Delphi win XE 64-bit.'); + +if SizeOf( TrueNativeInt ) <> SizeOf( pointer) then + ShowMessageFmt( 'Integer = %d bytes'#13#10 + + 'NativeInt = %d bytes'#13#10 + + 'TrueNativeInt = %d bytes'#13#10 + + 'Pointer = %d bytes'#13#10 + + 'Compiler = %.2f bytes', + [SizeOf(Integer), SizeOf( NativeInt), SizeOf( TrueNativeInt), SizeOf( pointer), CompilerVersion]); +Check( (SizeOf( TrueNativeInt ) = SizeOf( pointer)) and + (SizeOf( TrueNativeUInt) = SizeOf( pointer)), + 'uTPLb_PointerArithmetic Native Integer definitions wrong.'); + +Announcement := Format( 'You are running DUnit at SVN revision %d.', [Ver]); +Announcement := Announcement + #13#10; +Announcement := Announcement + Format( 'The SVN revision of the ' + + 'uTPLb_SVN_Keywords unit of the TPLB3 run-time package is %d.'#13#10 + + 'Check the TPLB3 project options for the run-time package library version.', + [TPLB3Runtime_SVN_Revision]); + + +Announcement := Announcement + #13#10; +Announcement := Announcement + Format( 'You are testing with compiler %s', + [DelphiVersion_DisplayName]); + +ShowMessage( Announcement); +end; + + + + + + +initialization +InitUnit_TestCases; + + +finalization +DoneUnit_TestCases; + + + +end. + diff --git a/unit-tests/dunit/umfmLockboxTests.dfm b/LockBox3/unit-tests/dunit/umfmLockboxTests.dfm similarity index 95% rename from unit-tests/dunit/umfmLockboxTests.dfm rename to LockBox3/unit-tests/dunit/umfmLockboxTests.dfm index c955565..89e138d 100644 --- a/unit-tests/dunit/umfmLockboxTests.dfm +++ b/LockBox3/unit-tests/dunit/umfmLockboxTests.dfm @@ -1,77 +1,77 @@ -object mfmLockboxTests: TmfmLockboxTests - Left = 0 - Top = 0 - Caption = 'TurboPower LockBox 3 Tests' - ClientHeight = 193 - ClientWidth = 412 - Color = clBtnFace - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - OldCreateOrder = False - Position = poScreenCenter - DesignSize = ( - 412 - 193) - PixelsPerInch = 96 - TextHeight = 13 - object Button1: TButton - Left = 8 - Top = 24 - Width = 153 - Height = 25 - Caption = 'Run AES tests' - TabOrder = 0 - OnClick = Button1Click - end - object Button2: TButton - Left = 8 - Top = 88 - Width = 75 - Height = 25 - Caption = 'MD5 test' - Enabled = False - TabOrder = 1 - end - object Memo1: TMemo - Left = 145 - Top = 90 - Width = 259 - Height = 89 - Anchors = [akLeft, akTop, akRight, akBottom] - TabOrder = 2 - end - object Edit1: TEdit - Left = 8 - Top = 119 - Width = 121 - Height = 21 - TabOrder = 3 - Text = 'message digest' - end - object Hash1: THash - CryptoLibrary = CryptographicLibrary1 - Left = 200 - Top = 16 - HashId = 'native.hash.SHA-1' - end - object CryptographicLibrary1: TCryptographicLibrary - ParentLibrary = CryptographicLibrary2 - Left = 240 - Top = 16 - end - object Codec1: TCodec - CryptoLibrary = CryptographicLibrary1 - Left = 288 - Top = 56 - StreamCipherId = 'native.StreamToBlock' - BlockCipherId = 'native.AES-256' - ChainId = 'native.CTR' - end - object CryptographicLibrary2: TCryptographicLibrary - Left = 336 - Top = 32 - end -end +object mfmLockboxTests: TmfmLockboxTests + Left = 0 + Top = 0 + Caption = 'TurboPower LockBox 3 Tests' + ClientHeight = 193 + ClientWidth = 412 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + DesignSize = ( + 412 + 193) + PixelsPerInch = 96 + TextHeight = 13 + object Button1: TButton + Left = 8 + Top = 24 + Width = 153 + Height = 25 + Caption = 'Run AES tests' + TabOrder = 0 + OnClick = Button1Click + end + object Button2: TButton + Left = 8 + Top = 88 + Width = 75 + Height = 25 + Caption = 'MD5 test' + Enabled = False + TabOrder = 1 + end + object Memo1: TMemo + Left = 145 + Top = 90 + Width = 259 + Height = 89 + Anchors = [akLeft, akTop, akRight, akBottom] + TabOrder = 2 + end + object Edit1: TEdit + Left = 8 + Top = 119 + Width = 121 + Height = 21 + TabOrder = 3 + Text = 'message digest' + end + object Hash1: THash + CryptoLibrary = CryptographicLibrary1 + Left = 200 + Top = 16 + HashId = 'native.hash.SHA-1' + end + object CryptographicLibrary1: TCryptographicLibrary + ParentLibrary = CryptographicLibrary2 + Left = 240 + Top = 16 + end + object Codec1: TCodec + CryptoLibrary = CryptographicLibrary1 + Left = 288 + Top = 56 + StreamCipherId = 'native.StreamToBlock' + BlockCipherId = 'native.AES-256' + ChainId = 'native.CTR' + end + object CryptographicLibrary2: TCryptographicLibrary + Left = 336 + Top = 32 + end +end diff --git a/unit-tests/dunit/umfmLockboxTests.pas b/LockBox3/unit-tests/dunit/umfmLockboxTests.pas similarity index 96% rename from unit-tests/dunit/umfmLockboxTests.pas rename to LockBox3/unit-tests/dunit/umfmLockboxTests.pas index bf20f4e..abb8d0c 100644 --- a/unit-tests/dunit/umfmLockboxTests.pas +++ b/LockBox3/unit-tests/dunit/umfmLockboxTests.pas @@ -1,64 +1,64 @@ -unit umfmLockboxTests; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, uTPLb_Hash, uTPLb_BaseNonVisualComponent, uTPLb_CryptographicLibrary, - StdCtrls, uTPLb_Codec; - -type - TmfmLockboxTests = class(TForm) - Hash1: THash; - Button1: TButton; - CryptographicLibrary1: TCryptographicLibrary; - Button2: TButton; - Memo1: TMemo; - Edit1: TEdit; - Codec1: TCodec; - CryptographicLibrary2: TCryptographicLibrary; - procedure Button1Click(Sender: TObject); - private - { Private declarations } - public - { Public declarations } - end; - -var - mfmLockboxTests: TmfmLockboxTests; - -implementation - - - - -uses uTPLb_StreamUtils, uTPLb_AES, uTPLb_BlockCipher, uTPLb_StreamCipher; -{$R *.dfm} - -procedure TmfmLockboxTests.Button1Click( Sender: TObject); -const sBoolStrs: array[ boolean ] of string = ('Failed','Passed'); -var - Ok: boolean; -begin -// This test passes ... -//Codec1.StreamCipherId := 'native.StreamToBlock'; -//Codec1.BlockCipherId := 'native.AES-128'; -//Codec1.ChainModeId := 'native.ECB'; -//Codec1.Password := 'a'; -//Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Codec1.SelfTest]])); - -Codec1.StreamCipherId := 'native.StreamToBlock'; -Codec1.BlockCipherId := 'native.AES-192'; -Codec1.ChainModeId := 'native.CBC'; -Codec1.Password := 'ab'; -Ok := Codec1.SelfTest; -Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Ok]])); - -//Codec1.StreamCipherId := 'native.StreamToBlock'; -//Codec1.BlockCipherId := 'native.AES-256'; -//Codec1.ChainModeId := 'native.CTR'; -//Codec1.Password := 'abc'; -//Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Codec1.SelfTest]])); -end; - -end. +unit umfmLockboxTests; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, uTPLb_Hash, uTPLb_BaseNonVisualComponent, uTPLb_CryptographicLibrary, + StdCtrls, uTPLb_Codec; + +type + TmfmLockboxTests = class(TForm) + Hash1: THash; + Button1: TButton; + CryptographicLibrary1: TCryptographicLibrary; + Button2: TButton; + Memo1: TMemo; + Edit1: TEdit; + Codec1: TCodec; + CryptographicLibrary2: TCryptographicLibrary; + procedure Button1Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + mfmLockboxTests: TmfmLockboxTests; + +implementation + + + + +uses uTPLb_StreamUtils, uTPLb_AES, uTPLb_BlockCipher, uTPLb_StreamCipher; +{$R *.dfm} + +procedure TmfmLockboxTests.Button1Click( Sender: TObject); +const sBoolStrs: array[ boolean ] of string = ('Failed','Passed'); +var + Ok: boolean; +begin +// This test passes ... +//Codec1.StreamCipherId := 'native.StreamToBlock'; +//Codec1.BlockCipherId := 'native.AES-128'; +//Codec1.ChainModeId := 'native.ECB'; +//Codec1.Password := 'a'; +//Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Codec1.SelfTest]])); + +Codec1.StreamCipherId := 'native.StreamToBlock'; +Codec1.BlockCipherId := 'native.AES-192'; +Codec1.ChainModeId := 'native.CBC'; +Codec1.Password := 'ab'; +Ok := Codec1.SelfTest; +Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Ok]])); + +//Codec1.StreamCipherId := 'native.StreamToBlock'; +//Codec1.BlockCipherId := 'native.AES-256'; +//Codec1.ChainModeId := 'native.CTR'; +//Codec1.Password := 'abc'; +//Memo1.Lines.Add( Format( '%s self test %s', [ Codec1.Cipher, sBoolStrs[ Codec1.SelfTest]])); +end; + +end.