Git Product home page Git Product logo

Comments (1)

trumank avatar trumank commented on June 15, 2024

AES always operates on blocks of 16 bytes so inputs must be padded if they don't land on a block boundary. OpenSSL has some clever tricks to do this automatically without having to store the unpadded length externally, but it can be disabled with -nopad to operate on raw blocks. I'm not sure where 6c cc cd c8 60 8c 80 or 6c cc cd c8 60 8c 80 ef 69 8c 99 e4 a4 9a d5 ad came from as I get neither of those from encrypting foo-bar with the given key.

I can verify bbe8d48c0f5b9aca2e460ed3253a67e3 does decrypt to foo-bar (plus padding) however:

# decrypting
echo 'bbe8d48c0f5b9aca2e460ed3253a67e3' | xxd -r -p | openssl enc -d -nopad -aes-256-ecb -K $(echo 'aWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWk=' | base64 -d | xxd -p -c 0) | xxd
# 00000000: 666f 6f2d 6261 7209 0909 0909 0909 0909  foo-bar.........
# NOTE the trailing 09s: these are special bytes telling OpenSSL to remove the last 9 bytes because they are padding
# they only appear in the output because -nopad is specified

# encrypting
echo -n 'foo-bar' | openssl enc -nopad -aes-256-ecb -K $(echo 'aWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWlpaWk=' | base64 -d | xxd -p -c 0) | xxd
# 00000000: bbe8 d48c 0f5b 9aca 2e46 0ed3 253a 67e3  .....[...F..%:g.

from repak.

Related Issues (16)

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.