#1 2018-08-26 22:58:04

Albert43
Member
Registered: 2018-08-26
Posts: 3

AESAbstract.SimpleEncryptFile access violation

Using Delphi 10.1 Berlin and
mORMot-master (version 1.18, July 2018):
  SynCommons.pas
  SynCrypto.pas
  SynLZ.pas.

-----------------
procedure TForm1.bnEncrypt1Click(Sender: TObject);
var Key:RawUTF8;
begin
  Key:=StringToUTF8('ThisIsAsimplePassword');
  try
    if AESAbstract.SimpleEncryptFile(ed1.Text,ed2.Text,Key,true) then showmessage('1 OK') else showmessage('1 Error');

    // Using win32 platform this results in 'Debugger Exception notification':
    //   'Project Project1.exe raised exception class $C0000005 with message 'access violation at 0x006288ff: read of address 0x00000000'
    // Using 'Continue' results in a Project1 message:
    //   'Access violation at address 006288ff in module 'Project.exe'. Read of address 00000000'
    // Using win64 platform similar messages.

  except
    on E:Exception do showmessage(E.message);

      // However: no such exception is raised...
  end;
end;
------------------------------------------------------------------------
The problems encountered are described in the lines with double shashes.

Please help: what did i do wrong?
Thanks!

Offline

#2 2018-08-26 23:12:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: AESAbstract.SimpleEncryptFile access violation

What is AESAbstract????

You need to use a proper class corresponding to a given block chaining mode.
For instance, TAESOFB.SimpleEncryptFile().

Please read the documentation and study the code.

Offline

#3 2018-08-27 20:10:28

Albert43
Member
Registered: 2018-08-26
Posts: 3

Re: AESAbstract.SimpleEncryptFile access violation

-1-
Of course it must be TAESAbstract.
In a previous try-out version I used TAESAbstract and forgot the T here, sorry.
Now the exception is correctly raised.
However: i still receive the exception 'Abstract Error'.

-2-
(below all line numbers are in SynCrypto.pas, version 1.18, July 2018)
TAESAbstract is defined on line 533 of SynScrypto.pas:
  TAESAbstract = class(TSynPersistent)
line 739 defines it's class function SimpleEncryptFile()
lines 12110-12523  gives the details of { TAESAbstract }
line 12487 gives the function i use: class function TAESAbstract.SimpleEncryptFile()

I understand I do not have to initialize AESAbstract as
the function which is encapsulated, class function TAESAbstract.SimpleEncrypt(),
initiates the instance itself.

When I go step by step into TAESbstract.SimpleEncryptFile()
all goes well until, inside TAESAbstract.EncryptPKCS7Buffer()
line 12264 is reached: Encrypt(Output,Output,InputLen+padding);
Stepping inside Encrypt results in procedure _AbstractError

Maybe this is caused by the fact that
line 591 defines: procedure Encrypt(BufIn, BufOut: pointer; Count: cardinal); virtual; abstract;
but the details of TAESAbstract.Encrypt() itself are not given.
I could not find this procedure/method in Delphi itself either.

Please help me a step further.
Thank you in advance.

Offline

#4 2018-08-28 11:56:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: AESAbstract.SimpleEncryptFile access violation

Did you read my previous answer?

ab wrote:

You need to use a proper class corresponding to a given block chaining mode.
For instance, TAESOFB.SimpleEncryptFile().

A TAESAbract is an abstract class, and should not be used directly - it is clearly documented as such!

documentation wrote:

use any of the inherited implementation, corresponding to the chaining mode required - TAESECB, TAESCBC, TAESCFB, TAESOFB and TAESCTR classes to handle in ECB, CBC, CFB, OFB and CTR mode (including PKCS7-like padding)
https://synopse.info/files/html/api-1.1 … ESABSTRACT

Offline

#5 2018-08-28 14:46:24

Albert43
Member
Registered: 2018-08-26
Posts: 3

Re: AESAbstract.SimpleEncryptFile access violation

Thanks.
I did read your previous answer, but not interprete it correctly.
Now I understand what you meant. Sorry to have disturbed you.
All works fine now.
Merci beaucoup

Offline

Board footer

Powered by FluxBB