#1 2021-01-29 01:23:49

Leslie7
Member
Registered: 2015-06-25
Posts: 248

AES-128 ECB decrypt

Hi,

I have not found how to do this with mORMot.  A simple example would be useful if somebody has one.
Any quick solution outside mORMot is welcome too.

Offline

#2 2021-01-29 09:11:46

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

Re: AES-128 ECB decrypt

First note: ECB block chaining is not secure. You should better use another mode, like OFB which is optimized in speed in our framework.
Second note: you need to consider which padding you want to use, because AES works on whole 16 bytes blocks.

So you can use SynCrypto.pas and TAESECB.EncryptPKCS7().

Online

#3 2021-01-29 10:08:40

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: AES-128 ECB decrypt

I am aware of the weakness, but thanks for the warning. This is something from an outside source.

The string's length is 87.
I have already tried DecryptPKCS7Buffer with TAESECB and TAESECB_API yesterday but I got "Invalid input length."

I figured that copy-pasting an example would be least time consuming help.

Last edited by Leslie7 (2021-01-29 10:08:53)

Offline

#4 2021-01-29 10:15:52

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

Re: AES-128 ECB decrypt

So you have to know which padding was involved in the outside reference code.

Online

#5 2021-01-29 11:07:12

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: AES-128 ECB decrypt

Yes, of course. smile
Unfortunately this info is not in the documentation currently available. "No info" suggests to me that it is probably the most basic/standardish/frequently used option.  I assume there are things I could try.

Last edited by Leslie7 (2021-01-29 11:19:53)

Offline

#6 2021-01-29 13:30:15

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: AES-128 ECB decrypt

The problem was something else: after base64 decoding first TAESECB.DecryptPKCS7 works PERFECTLY.:) smile smile

Last edited by Leslie7 (2021-01-29 20:53:35)

Offline

Board footer

Powered by FluxBB