1. Fixed using wolfSSL_EVP_CipherFinal() when a message's size is a round multiple of a block size. It wasn't adding the appropriate padding.
2. Update the EVP_Cipher test to call CipherUpdate and CipherFinal instead. It checks a message that is 24 bytes long and a second that is 16 bytes long.
This commit is contained in:
John Safranek
2017-10-10 13:06:30 -07:00
parent 35141c335d
commit 09f8ddd0f0
2 changed files with 49 additions and 7 deletions

View File

@@ -342,7 +342,10 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
return 1;
}
if (ctx->enc) {
if (ctx->bufUsed > 0) {
if (ctx->block_size == 1){
*outl = 0; return 1;
}
if ((ctx->bufUsed >= 0) && (ctx->block_size != 1)) {
padBlock(ctx);
PRINT_BUF(ctx->buf, ctx->block_size);
if (evpCipherBlock(ctx, out, ctx->buf, ctx->block_size) == 0)
@@ -351,6 +354,9 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
*outl = ctx->block_size;
}
} else {
if (ctx->block_size == 1){
*outl = 0; return 1;
}
if (ctx->lastUsed){
PRINT_BUF(ctx->lastBlock, ctx->block_size);
if ((fl = checkPad(ctx, ctx->lastBlock)) >= 0) {