From f97d956f0408423f065a3551e7e33e711277a00a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Aug 2015 15:17:05 +1000 Subject: [PATCH] Release v3.6.3.0 1. updated read-me for XE7 2. modernise string and tbytes treatment in demo 3. harden Blowfish self-test for D2009 compiler --- How_to_build_LockBox3.txt | 71 ++---- demo/D2010+/umfmLockbox3_Demo.dfm | 35 +-- demo/D2010+/umfmLockbox3_Demo.pas | 6 +- demo/uDemoBlockModeCipher.pas | 14 +- packages/XE7/Lockbox3_Demo.dpr | 4 +- packages/XE7/Lockbox3_Demo.dproj | 346 +++++++++++++++++++++++++++++- packages/XE7/TP_LockBox3.dproj | 4 +- packages/XE7/dclTP_LockBox3.dproj | 4 +- run/TPLB3.BlowFish.pas | 16 +- 9 files changed, 396 insertions(+), 104 deletions(-) diff --git a/How_to_build_LockBox3.txt b/How_to_build_LockBox3.txt index 8aaf1ea..f6b23fb 100644 --- a/How_to_build_LockBox3.txt +++ b/How_to_build_LockBox3.txt @@ -7,72 +7,41 @@ To build TurboPower LockBox 3, follow these steps. as you prefer for your development environment. (See notes about Environment Variables below). -2. Compile the main run-time package. +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. Compile the main design-time package. +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. -4. Install the main design-time package. +5. Install the main design-time package. -5. Use and enjoy ! +6. Use and enjoy ! Package, Application and Group heads ==================================== -Here is listed the package heads and thier purposes. +Here is listed the package heads and their purposes. -\packages\d2010\TP_LockBox3_d2010.groupproj - The project group for Delphi 2010 without SmartInspect +\packages\XE7\TP_LockBox3_XE7.groupproj + The project group for Delphi XE7 -\packages\d2010\TP_LockBox3.dpk - The main run-time package for Delphi 2010 without SmartInspect +\packages\XE7\dclTP_LockBox3.dpk + The main design-time package for Delphi XE6 -\packages\d2010\dclTP_LockBox3.dpk - The main design-time package for Delphi 2010 without SmartInspect +\packages\XE7\Lockbox3_Demo.dpr + The demonstration program for Delphi XE7 -\packages\d2010\Lockbox3_Demo.dpr - The demonstration program for Delphi 2010 without SmartInspect - -\packages\d2010\LockBox_DUnit_Tests.dpr +\packages\XE7\LockBox_DUnit_Tests.dpr The D-Unit test suite running under Delphi 2010 without SmartInpect support. -\packages\d2010\MakeSampleKey.dpr +\packages\XE7\MakeSampleKey.dpr A demonstration program for Delphi 2010 without SmartInspect, to create an RSA key. -\packages\d2010\Precompute.dpr +\packages\XE7\Precompute.dpr Program which show how the AES look-up tables were precomputed. -And similary for Delphi 2010 WITH SmartInspect support ... -\packages\d2010 with SmartInspect\TP_LockBox3_d2010.groupproj -\packages\d2010 with SmartInspect\TP_LockBox3.dpk -\packages\d2010 with SmartInspect\dclTP_LockBox3.dpk -\packages\d2010 with SmartInspect\LockBox_DUnit_Tests.dpr -\packages\d2010 with SmartInspect\MakeSampleKey.dpr -\packages\d2010 with SmartInspect\Precompute.dpr - - -And similary for Delphi 2007 ... -\packages\d2007\TP_LockBox3_d2007.groupproj -\packages\d2007\TP_LockBox3.dpk -\packages\d2007\dclTP_LockBox3.dpk -\packages\d2007\Precompute.dpr - - -Environment Variables -====================== -In used the following environment variables in the project options. -Free free to clear the directory settings in the Project Options and -not use these: - -$(DCU) ---- directory for compiled units (.dcu files). -$(DCP) ---- directory for comiled packages (.dcp files). -$(BPL) ---- directory for packages (.bpl files). -$(EXE) ---- directory for applications (.exe files). - -Conditional Defines -=================== -I used the following custom conditional defines. -{$SI} ==== Means that SmartInspect is supported. Requires SmartInspect - to be installed. - - diff --git a/demo/D2010+/umfmLockbox3_Demo.dfm b/demo/D2010+/umfmLockbox3_Demo.dfm index 5f5c943..074516d 100644 --- a/demo/D2010+/umfmLockbox3_Demo.dfm +++ b/demo/D2010+/umfmLockbox3_Demo.dfm @@ -35,16 +35,12 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo Top = 0 Width = 520 Height = 569 - ActivePage = tbSymetric + ActivePage = tbSignature Align = alClient MultiLine = True TabOrder = 1 object tbSymetric: TTabSheet Caption = '1. Symetric basics' - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -235,10 +231,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbSeeding: TTabSheet Caption = '2. Seeding' ImageIndex = 1 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 object bvlScriblePad: TBevel Left = 4 Top = 342 @@ -361,10 +353,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbSymetricExtent: TTabSheet Caption = '3. Symetric extensions' ImageIndex = 2 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -573,10 +561,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbKeyGen: TTabSheet Caption = '4. RSA - Key generation and storage' ImageIndex = 3 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -669,10 +653,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbSignature: TTabSheet Caption = '5. RSA - Signature && Verification' ImageIndex = 4 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -879,10 +859,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbHashes: TTabSheet Caption = '6. Hashes' ImageIndex = 5 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -967,10 +943,6 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo object tbOpenSSL: TTabSheet Caption = '7. RSA via OpenSSL' ImageIndex = 6 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 DesignSize = ( 512 523) @@ -1465,7 +1437,7 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo Left = 576 Top = 88 Bitmap = { - 494C010103000A00040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600 + 494C010103000A000C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000001000000001002000000000000010 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -1601,7 +1573,8 @@ object mfmLockbox3_Demo: TmfmLockbox3_Demo 001FE00F001F0000000FE00F000F00000007E007000700000003E00700030000 0001E007000100000000800300000000001F0000001F0000001F0000001F0000 001F0000001F00008FF100018FF10000FFF98001FFF90000FF75C003FF750000 - FF8FC007FF8F0000FFFFFF9FFFFF0000} + FF8FC007FF8F0000FFFFFF9FFFFF000000000000000000000000000000000000 + 000000000000} end object CryptographicLibrary1: TCryptographicLibrary Left = 592 diff --git a/demo/D2010+/umfmLockbox3_Demo.pas b/demo/D2010+/umfmLockbox3_Demo.pas index c20176c..23d8967 100644 --- a/demo/D2010+/umfmLockbox3_Demo.pas +++ b/demo/D2010+/umfmLockbox3_Demo.pas @@ -1391,7 +1391,7 @@ procedure TmfmLockbox3_Demo.actVerifyUpdate( Sender: TObject ); procedure TmfmLockbox3_Demo.btnComputeHashClick( Sender: TObject ); var - a: ansistring; + a: string; s: string; HashWord: uint32; Xfer: Integer; @@ -1399,9 +1399,9 @@ procedure TmfmLockbox3_Demo.btnComputeHashClick( Sender: TObject ); if rgHashSource.ItemIndex <= 0 then begin a := edtHashSource.Text; - StringHash.HashAnsiString( a ); + StringHash.HashString( a, TEncoding.UTF8); LogFmt - ( 'SHA-384 of ansistring ''%s'' rendered in little-endien base64 is:', + ( 'SHA-384 of utf-8 string ''%s'' rendered in little-endien base64 is:', [a] ) end else diff --git a/demo/uDemoBlockModeCipher.pas b/demo/uDemoBlockModeCipher.pas index f62fc5d..60cd61d 100644 --- a/demo/uDemoBlockModeCipher.pas +++ b/demo/uDemoBlockModeCipher.pas @@ -1,6 +1,6 @@ unit uDemoBlockModeCipher; interface -uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher, +uses Classes, TPLB3.StreamCipher, TPLB3.BlockCipher, SysUtils, TPLB3.SimpleBlockCipher, TPLB3.CryptographicLibrary; const @@ -12,9 +12,9 @@ interface TDemoBlockModeCipher = class( TSimpleBlockCipher) protected function Encrypt( - const Buffer: RawByteString; + const Buffer: TBytes; Key: TSimpleBlockCipherKey; - doEncrypt: boolean): RawByteString; override; + doEncrypt: boolean): TBytes; override; public class procedure SelfRegister( Lib: TCryptographicLibrary); @@ -35,14 +35,14 @@ implementation { TDemoBlockModeCipher } function TDemoBlockModeCipher.Encrypt( - const Buffer: RawByteString; - Key: TSimpleBlockCipherKey; doEncrypt: boolean): RawByteString; + const Buffer: TBytes; + Key: TSimpleBlockCipherKey; doEncrypt: boolean): TBytes; var j: integer; begin SetLength( result, DemoBlockSize); -for j := 1 to DemoBlockSize do - result[ j] := ansichar( byte( Buffer[ j]) xor byte( Key.FKeyData[ j])) +for j := 0 to DemoBlockSize - 1 do + result[ j] := byte( Buffer[ j]) xor byte( Key.FKeyData[ j]) end; diff --git a/packages/XE7/Lockbox3_Demo.dpr b/packages/XE7/Lockbox3_Demo.dpr index 67484ca..b8d0031 100644 --- a/packages/XE7/Lockbox3_Demo.dpr +++ b/packages/XE7/Lockbox3_Demo.dpr @@ -2,8 +2,8 @@ program Lockbox3_Demo; uses Forms, - uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas', - umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}; + umfmLockbox3_Demo in '..\..\demo\D2010+\umfmLockbox3_Demo.pas' {mfmLockbox3_Demo}, + uDemoBlockModeCipher in '..\..\demo\uDemoBlockModeCipher.pas'; {$R *.res} diff --git a/packages/XE7/Lockbox3_Demo.dproj b/packages/XE7/Lockbox3_Demo.dproj index 7a54c9d..e2443ab 100644 --- a/packages/XE7/Lockbox3_Demo.dproj +++ b/packages/XE7/Lockbox3_Demo.dproj @@ -69,18 +69,21 @@ false + 6 + 3 + 3 true 1033 - CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= MainSource -
mfmLockbox3_Demo
+ Cfg_2 Base @@ -110,9 +113,348 @@ 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/TP_LockBox3.dproj b/packages/XE7/TP_LockBox3.dproj index 154f879..0ce6090 100644 --- a/packages/XE7/TP_LockBox3.dproj +++ b/packages/XE7/TP_LockBox3.dproj @@ -186,11 +186,11 @@ true - 2 + 3 false 6 1033 - CompanyName=;FileDescription=;FileVersion=3.6.2.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= + CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= 1 diff --git a/packages/XE7/dclTP_LockBox3.dproj b/packages/XE7/dclTP_LockBox3.dproj index db34937..58c8ceb 100644 --- a/packages/XE7/dclTP_LockBox3.dproj +++ b/packages/XE7/dclTP_LockBox3.dproj @@ -121,8 +121,8 @@ 0 - 2 - CompanyName=;FileDescription=;FileVersion=3.6.2.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= + 3 + CompanyName=;FileDescription=;FileVersion=3.6.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=3.6.2.0;Comments= 1033 diff --git a/run/TPLB3.BlowFish.pas b/run/TPLB3.BlowFish.pas index 5df8ead..ae24e9d 100644 --- a/run/TPLB3.BlowFish.pas +++ b/run/TPLB3.BlowFish.pas @@ -710,14 +710,22 @@ function TBlowFish.SelfTest_Key: string; 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 -begin -result := BytesToBigEndienHex( TEncoding.UTF8.GetBytes( '12345678')) -end; + {$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