ECC cc511187 not working on 64Bit

TMS Crypt ECC cc511187 seems not to be working on 64bit Windows.
I receive the following error ...

Metermasterxdataapisandbox

error : in AES MAC, the tag is not the right one!

OK

I uncommented the needed part in the inc.file ... and also rebuild the package ...

Use the following form and unit to test ...
object Form2: TForm2
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Form2'
ClientHeight = 653
ClientWidth = 1233
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
DesignSize = (
1233
653)
TextHeight = 15
object RzDialogButtons1: TRzDialogButtons
Left = 0
Top = 617
Width = 1233
HotTrack = True
TabOrder = 0
end
object RzPageControl1: TRzPageControl
Left = 8
Top = 8
Width = 1217
Height = 609
Hint = ''
ActivePage = TabSheet9
Anchors = [akLeft, akTop, akRight, akBottom]
TabIndex = 8
TabOrder = 1
FixedDimension = 21
object TabSheet1: TRzTabSheet
Caption = 'User'
end
object TabSheet2: TRzTabSheet
Caption = 'MeterType'
end
object TabSheet3: TRzTabSheet
Caption = 'Meter'
end
object TabSheet4: TRzTabSheet
Caption = 'MeterReading'
end
object TabSheet5: TRzTabSheet
Caption = 'MeterTypeUnit'
end
object TabSheet6: TRzTabSheet
Caption = 'Geocluster'
end
object TabSheet7: TRzTabSheet
Caption = 'UservalidationCred'
end
object TabSheet8: TRzTabSheet
Caption = 'ReadingImage'
end
object TabSheet9: TRzTabSheet
Caption = 'RSA'
object LbPrivateExponent: TLabel
Left = 32
Top = 208
Width = 68
Height = 15
Caption = 'LbPrivateKey'
end
object LbPublicExponent: TLabel
Left = 608
Top = 208
Width = 65
Height = 15
Caption = 'LbPublicKey'
end
object BtEncrypt: TButton
Left = 32
Top = 32
Width = 281
Height = 25
Caption = 'Generate Keys and encrypt'
TabOrder = 0
OnClick = BtGenerateKeysAndEncryptClick
end
object MemoRSA: TMemo
Left = 32
Top = 264
Width = 1153
Height = 121
Lines.Strings = (
'MemoRSA')
TabOrder = 1
end
object EdTextToBeCiphered: TEdit
Left = 336
Top = 22
Width = 849
Height = 23
TabOrder = 2
Text = 'EdTextToBeCiphered'
end
object EdPrivateKey: TEdit
Left = 32
Top = 229
Width = 561
Height = 23
TabOrder = 3
Text = 'EdPrivateKey'
end
object EdPublicKey: TEdit
Left = 608
Top = 229
Width = 577
Height = 23
TabOrder = 4
Text = 'EdPublicKey'
end
object BtDecryptWithPrivatePublicKey: TButton
Left = 32
Top = 80
Width = 281
Height = 25
Caption = 'Decrypt with private and public key'
TabOrder = 5
OnClick = BtDecryptWithPrivatePublicKeyClick
end
object BtEncryptWithPublicKey: TButton
Left = 336
Top = 80
Width = 281
Height = 25
Caption = 'Encrypt with public key'
TabOrder = 6
OnClick = BtEncryptWithPublicKeyClick
end
object EdTextToBeDeciphered: TEdit
Left = 336
Top = 51
Width = 849
Height = 23
TabOrder = 7
Text = 'EdTextToBeDeciphered'
end
end
end
object ECC: TECCEncSign
Version = '4.3.1.0'
ECCType = cc511187
outputFormat = base64
Left = 785
Top = 166
end
end

unit Form.Main.ApiSandbox.MeterMaster;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzTabs, Vcl.ExtCtrls, RzPanel, RzDlgBtn, Vcl.StdCtrls, MiscObj, CryptBase, ECCObj;

type
TForm2 = class(TForm)
RzDialogButtons1: TRzDialogButtons;
RzPageControl1: TRzPageControl;
TabSheet1: TRzTabSheet;
TabSheet2: TRzTabSheet;
TabSheet3: TRzTabSheet;
TabSheet4: TRzTabSheet;
TabSheet5: TRzTabSheet;
TabSheet6: TRzTabSheet;
TabSheet7: TRzTabSheet;
TabSheet8: TRzTabSheet;
TabSheet9: TRzTabSheet;
BtEncrypt: TButton;
MemoRSA: TMemo;
EdTextToBeCiphered: TEdit;
LbPrivateExponent: TLabel;
LbPublicExponent: TLabel;
EdPrivateKey: TEdit;
EdPublicKey: TEdit;
BtDecryptWithPrivatePublicKey: TButton;
BtEncryptWithPublicKey: TButton;
EdTextToBeDeciphered: TEdit;
ECC: TECCEncSign;
procedure BtDecryptWithPrivatePublicKeyClick(Sender: TObject);
procedure BtGenerateKeysAndEncryptClick(Sender: TObject);
procedure BtEncryptWithPublicKeyClick(Sender: TObject);
private
{ Private-Deklarationen }
Conv: TConvert;
public
{ Public-Deklarationen }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.BtDecryptWithPrivatePublicKeyClick(Sender: TObject);
var
deciphered: string;
// ECC: TECCEncSign;
begin
// ECC := TECCEncSign.Create();
// ECC.ECCType := TECCType.cc511187;
// ECC.outputFormat := base64;
ECC.publicKey := EdPublicKey.Text;
ECC.PrivateKey := EdPrivateKey.Text;
// ECC.Unicode := TUnicode.yesUni;
deciphered := ECC.Decrypt(EdTextToBeDeciphered.Text);
MemoRSA.Lines.Clear;
MemoRSA.Lines.Add('Private Key: ' + QuotedStr(ECC.PrivateKey));
MemoRSA.Lines.Add('Public Key: ' + QuotedStr(ECC.PublicKey));
MemoRSA.Lines.Add('Text to be deciphered: ' + EdTextToBeDeciphered.Text);
MemoRSA.Lines.Add('Deciphered Text: ' + deciphered);
// ECC.Free;
end;

procedure TForm2.BtGenerateKeysAndEncryptClick(Sender: TObject);
var
cipher: string;
// ECC: TECCEncSign;
begin
// ECC := TECCEncSign.Create();
// ECC.ECCType := TECCType.cc511187;
// ECC.outputFormat := base64;
ECC.GenerateKeys;
EdPrivateKey.Text := ECC.PrivateKey;
EdPublicKey.Text := ECC.PublicKey;
// ECC.Unicode := TUnicode.yesUni;
cipher := ECC.Encrypt(EdTextToBeCiphered.Text);
MemoRSA.Lines.Clear;
MemoRSA.Lines.Add('Private Key: ' + QuotedStr(ECC.PrivateKey));
MemoRSA.Lines.Add('Public Key: ' + QuotedStr(ECC.PublicKey));
MemoRSA.Lines.Add('Text to be ciphered: ' + EdTextToBeCiphered.Text);
MemoRSA.Lines.Add('Ciphered Text: ' + cipher);
// ECC.Free;
end;

procedure TForm2.BtEncryptWithPublicKeyClick(Sender: TObject);
var
ciphered: string;
// ECC: TECCEncSign;
begin
// ECC := TECCEncSign.Create();
// ECC.ECCType := TECCType.cc511187;
// ECC.outputFormat := base64;
ECC.PublicKey := EdPublicKey.Text;
// ECC.Unicode := TUnicode.yesUni;
ciphered := ECC.Encrypt(EdTextToBeCiphered.Text);
MemoRSA.Lines.Clear;
MemoRSA.Lines.Add('Public Key: ' + QuotedStr(ECC.PublicKey));
MemoRSA.Lines.Add('Text to be ciphered: ' + EdTextToBeCiphered.Text);
MemoRSA.Lines.Add('Ciphered Text: ' + ciphered);
// ECC.Free;
end;

end.

It is working on 32Bit ...

You can also use the Demo which comes with the library and compile it for 64Bit after changing the inc file - and see the same error.

BTW as a workaround I use now the cc25519 type, which is working like a charm, but anyhow - I would like to know if it also should be working with cc511187 and this is a bug, which I would guess it is.

Hi Roland,
This is clearly a bug (looks like an internal format issue) and I will have a look at it.
ed25519 is however secure enough for any professional use.
bernard

Hi Bernard, thanks a lot for your fast and informative response.