How can I create OpenSSL output that compares to OpenSSL C++ output to generate unit tests?

后端 未结 1 1183
难免孤独
难免孤独 2021-01-20 13:34

I\'m using a C++ wrapper for OpenSSL\'s AES-256-CBC encryption that follows the recipe from OpenSSL docs. It\'s meant to take some data to encrypt, a key and an initializati

相关标签:
1条回答
  • 2021-01-20 14:12

    I figured it out. The problem was that I'm using the wrong command line parameter. It should be -K for the key, not -k. This is the correct format:

    printf '%s' '48656c6c6f20776f726c6421' | xxd -r -ps | openssl aes-256-cbc -iv 00000000000000000000000000000000 -K 0000000000000000000000000000000000000000000000000000000000000000 -nosalt | xxd -ps
    

    and this gives the exact same result as OpenSSL in C++.

    0 讨论(0)
提交回复
热议问题