Browse Source

replace hardcoded use of OpenSSL with UCLEncryption unit

Dmitry Boyarintsev 6 years ago
parent
commit
d04b081f78

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

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

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

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

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

@@ -293,8 +293,8 @@ implementation
   {$R *.lfm}
   {$R *.lfm}
 {$ENDIF}
 {$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;
   UFRMAbout, UFRMOperation, UFRMWalletKeys, UFRMPayloadDecoder, UFRMNodesIp, UFRMMemoText;
 
 
 Type
 Type

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

@@ -218,7 +218,7 @@ implementation
 
 
 uses
 uses
   UFRMAbout, UFRMNodesIp, UFRMPascalCoinWalletConfig, UFRMPayloadDecoder, UFRMMemoText,
   UFRMAbout, UFRMNodesIp, UFRMPascalCoinWalletConfig, UFRMPayloadDecoder, UFRMMemoText,
-  UOpenSSL, UFileStorage, UTime, USettings, UCoreUtils, UMemory,
+  UFileStorage, UTime, USettings, UCoreUtils, UMemory,
   UWIZOperation, UWIZSendPASC, UWIZChangeKey, UWIZEnlistAccountForSale, UWIZDelistAccountFromSale, UWIZChangeAccountInfo, UWIZBuyAccount, UCoreObjects;
   UWIZOperation, UWIZSendPASC, UWIZChangeKey, UWIZEnlistAccountForSale, UWIZDelistAccountFromSale, UWIZChangeAccountInfo, UWIZBuyAccount, UCoreObjects;
 
 
 {%region UI Lifecyle}
 {%region UI Lifecyle}

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

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

+ 4 - 0
src/pascalcoin_wallet_experimental.dpr

@@ -9,7 +9,9 @@ uses
   {$ENDIF}{$ENDIF}
   {$ENDIF}{$ENDIF}
   Interfaces,
   Interfaces,
   sysutils,
   sysutils,
+  {$ifdef Use_OpenSSL}
   UOpenSSL,
   UOpenSSL,
+  {$endif}
   UCrypto,
   UCrypto,
   Forms,
   Forms,
   UUserInterface,
   UUserInterface,
@@ -21,9 +23,11 @@ var
    mainForm : TFRMMainForm;
    mainForm : TFRMMainForm;
 begin
 begin
   // Start OpenSSL dll
   // Start OpenSSL dll
+  {$ifdef Use_OpenSSL}
   if Not LoadSSLCrypt then
   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');
     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;
   TCrypto.InitCrypto;
+  {$endif}
   // Load application
   // Load application
   Application.Initialize;
   Application.Initialize;
   {$IFDEF WINDOWS}{$Warnings OFF}
   {$IFDEF WINDOWS}{$Warnings OFF}