From 1c0b84d47d79eb370780dd0bf966bb3282809f46 Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Sun, 1 Apr 2018 12:13:18 +0900 Subject: [PATCH] openSSL compatibility, EVP_CipherUpdate, if(inlen == 0)return 1; --- wolfcrypt/src/evp.c | 5 +++-- wolfcrypt/test/test.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 502e8a3bf..2686aae81 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -315,12 +315,13 @@ WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx, int blocks; int fill; - *outl = 0; if ((ctx == NULL) || (inl < 0) || (outl == NULL)|| (out == NULL) || (in == NULL)) return BAD_FUNC_ARG; WOLFSSL_ENTER("wolfSSL_EVP_CipherUpdate"); - if (inl == 0) return WOLFSSL_FAILURE; + *outl = 0; + if (inl == 0) return WOLFSSL_SUCCESS; + if (ctx->bufUsed > 0) { /* concatinate them if there is anything */ fill = fillBuff(ctx, in, inl); inl -= fill; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 2cd25546d..be0b1967a 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -12146,6 +12146,15 @@ int openssl_test(void) int outlen ; int total = 0; + EVP_CIPHER_CTX_init(&en); + if (EVP_CipherInit(&en, EVP_aes_128_cbc(), + (unsigned char*)key, (unsigned char*)iv, 1) == 0) + return -5960; + /* openSSL compatibility, if(inlen == 0)return 1; */ + if (EVP_CipherUpdate(&en, (byte*)cipher, &outlen, + (byte*)cbcPlain, 0) == 0) + return -5960; + EVP_CIPHER_CTX_init(&en); if (EVP_CipherInit(&en, EVP_aes_128_cbc(), (unsigned char*)key, (unsigned char*)iv, 1) == 0) @@ -12269,6 +12278,7 @@ int openssl_test(void) if (XMEMCMP(plain, cbcPlain, 18)) return -3448; + } #endif /* WOLFSSL_AES_128 */ #endif /* ifndef NO_AES */