You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd say for WRAP ciphers you need inl + 16
Interesting is that this test case is invalid
to make it work in 1.1.1 you have to add
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
as follows:
#include <openssl/evp.h>
#define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; }
#define CF_CHECK_GTE(expr, res) if ( (expr) < (res) ) { goto end; }
int main(void)
{
const unsigned char key[16] = { 0 };
const unsigned char iv[8] = { 0 };
unsigned char cleartext[16] = { 0 };
unsigned char out[23];
int len = -1;
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
const EVP_CIPHER* cipher = EVP_aes_128_wrap();
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
CF_CHECK_EQ(EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL), 1);
CF_CHECK_EQ(EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv), 1);
/* "the amount of data written may be anything from zero bytes to (inl + cipher_block_size - 1)" */
CF_CHECK_GTE(sizeof(out), sizeof(cleartext) + EVP_CIPHER_block_size(cipher) - 1);
CF_CHECK_EQ(EVP_EncryptUpdate(ctx, out, &len, cleartext, sizeof(cleartext)), 1);
end:
return 0;
}
Closing as the issue was labeled as inactive for extended period of time and there was no additional input.
Please add a comment if you have any further information to support reopening the issue.
Activity
paulidale commentedon Jun 2, 2020
Digging deeper, this looks like a documentation error.
bernd-edlinger commentedon Jun 2, 2020
I'd say for WRAP ciphers you need inl + 16
Interesting is that this test case is invalid
to make it work in 1.1.1 you have to add
EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
as follows:
bernd-edlinger commentedon Jun 2, 2020
That check for EVP_CIPHER_CTX_FLAG_WRAP_ALLOW was obviously
dropped in master. Most likely accidentally?
paulidale commentedon Jun 2, 2020
There is still a check in master, it must be avoided somehow.
nhorman commentedon Jun 13, 2024
Marking as inactive, to be closed at the end of 3.4 dev, barring further input
t8m commentedon Aug 20, 2025
Closing as the issue was labeled as inactive for extended period of time and there was no additional input.
Please add a comment if you have any further information to support reopening the issue.