Browse Source

Experimental GUI: core integration fixes

Herman Schoenfeld 6 years ago
parent
commit
5627518d0e

+ 1 - 1
src/gui-experimental/UFRMOperation.lfm

@@ -16,7 +16,7 @@ object FRMOperation: TFRMOperation
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
-  LCLVersion = '2.0.2.0'
+  LCLVersion = '2.1.0.0'
   object lblAccountCaption: TLabel
     Left = 25
     Height = 13

+ 6 - 5
src/gui-experimental/UFRMOperation.pas

@@ -177,7 +177,8 @@ type
 implementation
 
 uses
-  UECIES, UCoreUtils, UConst, UOpTransaction, UAES, UFRMWalletKeys, UUserInterface, UPCDataTypes;
+  UPCEncryption,
+  UCoreUtils, UConst, UOpTransaction, UFRMWalletKeys, UUserInterface, UPCDataTypes;
 
 {$R *.lfm}
 
@@ -1257,7 +1258,7 @@ begin
       // Use sender
       errors := 'Error encrypting';
       account := FNode.GetAccount(SenderAccount.account);
-      payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
+      TPCEncryption.DoPascalCoinECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u), payload_encrypted);
       valid := Length(payload_encrypted)>0;
     end else if (rbEncryptedWithEC.Checked) then begin
       errors := 'Error encrypting';
@@ -1293,7 +1294,7 @@ begin
           exit;
         end;
         account := FNode.GetAccount(dest_account_number);
-        payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
+        TPCEncryption.DoPascalCoinECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u),payload_encrypted);
         valid := Length(payload_encrypted)>0;
       end else if (PageControlOpType.ActivePage=tsChangePrivateKey) then begin
         if (rbChangeKeyWithAnother.Checked) then begin
@@ -1315,7 +1316,7 @@ begin
           exit;
         end;
         if public_key.EC_OpenSSL_NID<>CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then begin
-          payload_encrypted := ECIESEncrypt(public_key,TEncoding.ANSI.GetBytes(payload_u));
+          TPCEncryption.DoPascalCoinECIESEncrypt(public_key,TEncoding.ANSI.GetBytes(payload_u),payload_encrypted);
           valid := Length(payload_encrypted)>0;
         end else begin
           valid := false;
@@ -1326,7 +1327,7 @@ begin
         errors := 'This operation does not allow this kind of payload';
       end;
     end else if (rbEncrptedWithPassword.Checked) then begin
-      payload_encrypted := TAESComp.EVP_Encrypt_AES256(TEncoding.ANSI.GetBytes(payload_u),TEncoding.ANSI.GetBytes(ebEncryptPassword.Text));
+      payload_encrypted := TPCEncryption.DoPascalCoinAESEncrypt(TEncoding.ANSI.GetBytes(payload_u),TEncoding.ANSI.GetBytes(ebEncryptPassword.Text));
       valid := Length(payload_encrypted)>0;
     end else if (rbNotEncrypted.Checked) then begin
       payload_encrypted := TEncoding.ANSI.GetBytes(payload_u);

+ 1 - 1
src/gui-experimental/UFRMPayloadDecoder.lfm

@@ -15,7 +15,7 @@ object FRMPayloadDecoder: TFRMPayloadDecoder
   Font.Name = 'Tahoma'
   OnCreate = FormCreate
   Position = poOwnerFormCenter
-  LCLVersion = '2.0.2.0'
+  LCLVersion = '2.1.0.0'
   object Label1: TLabel
     Left = 20
     Height = 13

+ 1 - 1
src/gui-experimental/UFRMPayloadDecoder.pas

@@ -97,7 +97,7 @@ implementation
 {$R *.lfm}
 
 Uses
-  UNode, UTime, UECIES, UAES, UAccounts, UCommon, USettings, UBaseTypes,
+  UNode, UTime, UAccounts, UCommon, USettings, UBaseTypes,
   UPCEncryption, UFRMMemoText;
 
 { TFRMPayloadDecoder }

+ 2 - 2
src/gui-experimental/UFRMWallet.pas

@@ -293,8 +293,8 @@ implementation
   {$R *.lfm}
 {$ENDIF}
 
-Uses UFolderHelper, UOpenSSL, UOpenSSLdef, UConst, UTime, UFileStorage,
-  UThread, UOpTransaction, UECIES, UFRMPascalCoinWalletConfig,
+Uses UFolderHelper, UConst, UTime, UFileStorage,
+  UThread, UOpTransaction, UFRMPascalCoinWalletConfig,
   UFRMAbout, UFRMOperation, UFRMWalletKeys, UFRMPayloadDecoder, UFRMNodesIp, UFRMMemoText;
 
 Type

+ 4 - 1
src/gui-experimental/UUserInterface.pas

@@ -218,7 +218,7 @@ implementation
 
 uses
   UFRMAbout, UFRMNodesIp, UFRMPascalCoinWalletConfig, UFRMPayloadDecoder, UFRMMemoText,
-  UOpenSSL, UFileStorage, UTime, USettings, UCoreUtils, UMemory,
+  UFileStorage, UTime, USettings, UCoreUtils, UMemory,
   UWIZOperation, UWIZSendPASC, UWIZChangeKey, UWIZEnlistAccountForSale, UWIZDelistAccountFromSale, UWIZChangeAccountInfo, UWIZBuyAccount, UCoreObjects;
 
 {%region UI Lifecyle}
@@ -231,6 +231,9 @@ begin
   if FIsActivated then exit;
   FIsActivated := true;
   try
+    // Initialize crypto module
+    TCrypto.InitCrypto;
+
     // Create UI lock
     FUILock := TPCCriticalSection.Create('TUserInterface.UILock');
 

+ 7 - 6
src/gui-experimental/core.utils/UCoreUtils.pas

@@ -131,9 +131,8 @@ implementation
 
 uses
   ULog,
-  UAES,
+  UPCEncryption,
   UConst,
-  UECIES,
   UCrypto,
   UMemory,
   UNetProtocol,
@@ -806,14 +805,14 @@ begin
       pemEncryptWithSender:
       begin
         // Use sender public key
-        AEncodedPayloadBytes := ECIESEncrypt(ASenderPublicKey, TEncoding.ANSI.GetBytes(APayloadContent));
+        TPCEncryption.DoPascalCoinECIESEncrypt(ASenderPublicKey, TEncoding.ANSI.GetBytes(APayloadContent), AEncodedPayloadBytes);
         LValid := AEncodedPayloadBytes <> nil;
       end;
 
       pemEncryptWithRecipient:
       begin
         // With destination public key
-        AEncodedPayloadBytes := ECIESEncrypt(ADestinationPublicKey, TEncoding.ANSI.GetBytes(APayloadContent));
+        TPCEncryption.DoPascalCoinECIESEncrypt(ADestinationPublicKey, TEncoding.ANSI.GetBytes(APayloadContent), AEncodedPayloadBytes);
         LValid := AEncodedPayloadBytes <> nil;
       end;
 
@@ -825,8 +824,10 @@ begin
           AErrorMessage := 'Payload Encryption Password Cannot Be Empty With The Chosen Option : "Encrypt With Password."';
           Exit(False);
         end;
-        AEncodedPayloadBytes := TAESComp.EVP_Encrypt_AES256(
-          TEncoding.ANSI.GetBytes(APayloadContent), TEncoding.ANSI.GetBytes(APayloadEncryptionPassword));
+        AEncodedPayloadBytes := TPCEncryption.DoPascalCoinAESEncrypt(
+          TEncoding.ANSI.GetBytes(APayloadContent),
+          TEncoding.ANSI.GetBytes(APayloadEncryptionPassword)
+        );
         LValid := AEncodedPayloadBytes <> nil;
       end;
 

+ 2 - 4
src/pascalcoin_wallet_experimental.dpr

@@ -9,7 +9,9 @@ uses
   {$ENDIF}{$ENDIF}
   Interfaces,
   sysutils,
+  {$ifdef Use_OpenSSL}
   UOpenSSL,
+  {$endif}
   UCrypto,
   Forms,
   UUserInterface,
@@ -20,10 +22,6 @@ uses
 var
    mainForm : TFRMMainForm;
 begin
-  // Start OpenSSL dll
-  if Not LoadSSLCrypt then
-    raise Exception.Create('Cannot load '+SSL_C_LIB+#10+'To use this software make sure this file is available on you system or reinstall the application');
-  TCrypto.InitCrypto;
   // Load application
   Application.Initialize;
   {$IFDEF WINDOWS}{$Warnings OFF}

+ 1 - 11
src/pascalcoin_wallet_experimental.lpi

@@ -28,24 +28,14 @@
           </Target>
           <SearchPaths>
             <IncludeFiles Value="$(ProjOutDir);libraries\generics.collections\inc"/>
-            <OtherUnitFiles Value="core;gui-experimental;libraries\synapse;libraries\sphere10;libraries\hashlib4pascal;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;gui-classic;libraries\paszlib"/>
+            <OtherUnitFiles Value="core;gui-experimental;libraries\synapse;libraries\sphere10;libraries\simplebaselib4pascal;libraries\cryptolib4pascal;libraries\hashlib4pascal;libraries\generics.collections;libraries\pascalcoin;gui-experimental\core.utils;gui-experimental\wizards\wallet;gui-experimental\wizards\operations;gui-classic;libraries\paszlib"/>
             <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
           </SearchPaths>
           <Parsing>
             <SyntaxOptions>
               <SyntaxMode Value="Delphi"/>
-              <IncludeAssertionCode Value="True"/>
             </SyntaxOptions>
           </Parsing>
-          <CodeGeneration>
-            <Checks>
-              <IOChecks Value="True"/>
-              <RangeChecks Value="True"/>
-              <OverflowChecks Value="True"/>
-              <StackChecks Value="True"/>
-            </Checks>
-            <VerifyObjMethodCallValidity Value="True"/>
-          </CodeGeneration>
           <Linking>
             <Debugging>
               <DebugInfoType Value="dsDwarf2Set"/>