Skip to content

Commit

Permalink
Changes to avoid an error when EVP_EncryptFinal_ex() calls QAT engine…
Browse files Browse the repository at this point in the history
… function qat_chained_ciphers_do_cipher() with a NULL input buffer pointer. This happens when OpenSSL speed makes its final encryption request during a cipher performance speed test.

Change-Id: I90eec97dd7f5f7c6ff75e39e856d0411dab74bab
Signed-off-by: Steve Linsell <stevenx.linsell@intel.com>
  • Loading branch information
paulturx authored and stevelinsell committed Nov 10, 2017
1 parent 6856c4f commit f6f262f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions qat_ciphers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,18 +1090,31 @@ int qat_chained_ciphers_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
* are supplied through ctrl messages.
*/
if (PIPELINE_INCOMPLETE_INIT(qctx) ||
(!PIPELINE_SET(qctx) && (in == NULL || out == NULL
(!PIPELINE_SET(qctx) && (out == NULL
|| (len % AES_BLOCK_SIZE)))) {
WARN("%s \n",
PIPELINE_INCOMPLETE_INIT(qctx) ?
"Pipeline not initialised completely" : len % AES_BLOCK_SIZE
? "Buffer Length not multiple of AES block size"
: "in/out buffer null");
: "out buffer null");
return -1;
}

enc = EVP_CIPHER_CTX_encrypting(ctx);

/* If we are encrypting and EVP_EncryptFinal_ex is called with a NULL
input buffer then return 0. Note: we don't actually support partial
requests in the engine but this workaround avoids an error from OpenSSL
speed on the last request when measuring cipher performance. Speed is
written to measure performance using partial requests.*/
if (!PIPELINE_SET(qctx) &&
in == NULL &&
out != NULL &&
enc) {
DEBUG("QAT partial requests work-around: NULL input buffer passed.\n");
return 0;
}

if (!INIT_SEQ_IS_FLAG_SET(qctx, INIT_SEQ_QAT_SESSION_INIT)) {
/* The qat session is initialized when HMAC key is set. In case
* HMAC key is not explicitly set, use default HMAC key of all zeros
Expand Down

0 comments on commit f6f262f

Please sign in to comment.