Giter VIP home page Giter VIP logo

Comments (4)

namreeb avatar namreeb commented on August 19, 2024

Is the OpenSSL version including a null terminator?

Edit: Nevermind. It's because you have the wrong size for 'in'. You specify 13 bytes but give it a size of 16, so you're passing three random bytes into the AES encrypt routine.

Edit 2: Same for 'key' and 'iv'.

from tiny-aes-c.

ardiri avatar ardiri commented on August 19, 2024

OPENSSL uses PKCS7 padding.

PKCS7 padding does not pad with zeros; instead, it pads with the remainder. so, if there are 4 bytes missing to make it modulus 16; the input will be padded with 4 bytes containing the number 4. PKCS7 also requires at least ONE padding byte; so if your input length is exactly modulus 16 - you need to add 16 bytes, containing the value 16.

i implemented AES-128/192/256 working against openSSL (within PHP) initially based on the code in this repository; but in order to support 192/256 i had to make some minor changes in addition to dealing with PKCS7 padding.

http://ardiri.com/blog/utls_defining_lightweight_security_for_iot_part_5

from tiny-aes-c.

wvengen avatar wvengen commented on August 19, 2024

The fork by triangulum-com-au implements PKCS7 padding (look at the tests). I've used it with success.

from tiny-aes-c.

daiziyi avatar daiziyi commented on August 19, 2024

Thanks to @namreeb @ardiri @wvengen helps , I did not consider the padding at the first time and the program appears different result. Thank you!

from tiny-aes-c.

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.