Giter VIP home page Giter VIP logo

Comments (9)

bricke avatar bricke commented on August 18, 2024

The encrypted block has to be a multiple of 16, in your case being 17 bytes it adds 15 bytes of padding to make it 32 (16*2).

I'll look into a solution asap.

from qt-aes.

ricox78 avatar ricox78 commented on August 18, 2024

I could add 2 info:
1- If I use PKCS5Padding in Java, after 17 corrects bytes, 15 bytes @ 0xff are added at the byte array
2- the problem is present also when I send from qt to Java ...
Thank’s again for all

from qt-aes.

bricke avatar bricke commented on August 18, 2024

Let me understand, AES says that the lenght of the block to decipher has to be a multiple of 16, you can handle the padding yourself by adding something to match this requirement or let the software do it (if you are using a string with termination char let the class handle it works well).

I don't use Java since a while, if you cipher the string in java, how many bytes in total you end up with? 32 or 17?

from qt-aes.

ricox78 avatar ricox78 commented on August 18, 2024

I try to explain better:

in Java I could init Chiper in this way:

m_encChiper = Cipher.getInstance("AES/CFB/NoPadding");
so no padding is managed and if I crypt something that out of the encrypt function result an array of 17 bytes, this is my result.
If I pass this array to java decrypt function I obtain the original String.
If I pass this array to your
encryption->decode(xMsg, hashKey, iv)
where xMsg is the 17 lenght byte array, I have my original string followed by 15bytes of non sense added as I indicated in the initial post.

So I could not find a way to manage padding in your library so I try to init my java Chiper to:
m_encChiper = Cipher.getInstance("AES/CFB/PKCS5PADDING");
I'm not sure CFB with padding have sense.. but I tried and when I decode in Qt the result is my original String followed bt 15 bytes all at 0x00ff.

I don't handle padding by myself, Java api did it for me .. but in NoPadding mode, the result of encrypt is not an array with a lenght multiple of 16 bytes.
Is there a way to set your library to NoPadding??
Thank's again.

from qt-aes.

bricke avatar bricke commented on August 18, 2024

Can't you tell Java to use a zero-filled padding?

I think I can add PKCS5PADDING and other form of padding.

from qt-aes.

ricox78 avatar ricox78 commented on August 18, 2024

Thank's very much, very nice suggestion,
initializing Chiper as following:

m_encChiper = Cipher.getInstance("AES/CFB/ZeroBytePadding");

java pad the coded string in the way in witch your library works!
Thank's againg, probably padd management could be added to your wonderful work!
Bye

from qt-aes.

bricke avatar bricke commented on August 18, 2024

Happy that it worked.

Please remember that my AES code is not audited or tested.

from qt-aes.

ricox78 avatar ricox78 commented on August 18, 2024

Yes for sure, I’ve used it to study a server simulator that works behind my app... first tests works, If can my experience with it contribute to test I’m happy..

from qt-aes.

bricke avatar bricke commented on August 18, 2024

I added PKCS7 and ISO padding, can you check them against Java?

from qt-aes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.