Page 1 of 1

AESDecoder() padding bytes

Posted: Tue May 08, 2018 3:12 pm
by infratec
Hi,

with which bytes is the data padded when the data is larger then 16 but smaller then 32 :?:

I'm not able to read a PB AES code in C#
I tried 00 padding, 1,2,3,4... padding and missing length to 16 padding.

Any idea?

Bernd

Re: AESDecoder() padding bytes

Posted: Tue May 08, 2018 9:15 pm
by said
Hi Bernd,

I dont think there is any padding!

There are other factors that affect AES but i am sure you know all of them :!:

I wish i could help once (in return to your many many helpful replies/contributions :D )

Said

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 6:54 am
by infratec
The problem is that the C# AES throws an error if the data ends not on a 16 byte boundary :cry:
So I have to pad it with something.
Unfortunately I don't padded the PB AES stuff (manually), so I'm not able at the moment to decode this.

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 8:47 am
by walbus
@Bernd
Primary you should ever use AES with a 16 byte padding, ever, never without.
A padding can are very different, the simplest are zero bytes, but all other bytes are available.
The used bytes for the padding change the encrypted block absolutelly.
One other bit in the padding and you can not decrypt this block.
The PB documentation treats AES only superficially.
The use of AES by users therefore often resembles a chaos.
Even the inventor of AES saw these problems.
He said it's not good to leave it to the developers how they want to implement AES.
He wanted to offer a solution in the future, as far as I know...
It is simply not good if there is no standardized way.
The problem you have there is nothing unusual.
It can take a lot of time and nerves.

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 7:40 pm
by JHPJHP
Hi infratec,

See if there is anything here that can help: Services, Stuff & Shellhook
- \Stuff\AESEncryption\AES_EncoderDecoder.pb

NB*: Various parts of the package can be downloaded separately.

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 8:19 pm
by walbus
Sorry, no offense, but your implementation is flawed

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 9:34 pm
by infratec
Hi,

for new stuff I'll pad it manually with zeroes to the 16 byte border.
Then it's no problem to decode it with C#.

But there are a lot of encoded ini files at our customers and I have to decode them with a new
program written in C# (cause of using list and labels).

So best is Fred tell us which padding is used by the PB AESEncoder.

Bernd

Re: AESDecoder() padding bytes

Posted: Wed May 09, 2018 9:54 pm
by walbus
There is no reason not to use zeros per se Bernd
You don't get a higher security if you don't use zeros
But often weird things are done because people think it would be safer