From patchwork Tue Jun 16 09:46:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 6616371 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 18DF89F358 for ; Tue, 16 Jun 2015 09:46:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BD5520552 for ; Tue, 16 Jun 2015 09:46:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58891203F7 for ; Tue, 16 Jun 2015 09:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756792AbbFPJqy (ORCPT ); Tue, 16 Jun 2015 05:46:54 -0400 Received: from down.free-electrons.com ([37.187.137.238]:56060 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756500AbbFPJqx (ORCPT ); Tue, 16 Jun 2015 05:46:53 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 058E52430; Tue, 16 Jun 2015 11:46:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost.localdomain (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 5FED62422; Tue, 16 Jun 2015 11:46:50 +0200 (CEST) From: Boris Brezillon To: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Boris Brezillon Subject: [PATCH 1/2] crypto: testmgr: test IV value after a cipher operation Date: Tue, 16 Jun 2015 11:46:46 +0200 Message-Id: <1434448007-9537-2-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434448007-9537-1-git-send-email-boris.brezillon@free-electrons.com> References: <1434448007-9537-1-git-send-email-boris.brezillon@free-electrons.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The crypto drivers are supposed to update the IV passed to the crypto request before calling the completion callback. Test for the IV value before considering the test as successful. Signed-off-by: Boris Brezillon --- crypto/testmgr.c | 12 +++++++++++- crypto/testmgr.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index f9bce3d..e6b5f24 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1013,12 +1013,22 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, q = data; if (memcmp(q, template[i].result, template[i].rlen)) { - pr_err("alg: skcipher%s: Test %d failed on %s for %s\n", + pr_err("alg: skcipher%s: Test %d failed (invalid result) on %s for %s\n", d, j, e, algo); hexdump(q, template[i].rlen); ret = -EINVAL; goto out; } + + if (template[i].iv_out && + memcmp(iv, template[i].iv_out, + crypto_ablkcipher_ivsize(tfm))) { + pr_err("alg: skcipher%s: Test %d failed (invalid output IV) on %s for %s\n", + d, j, e, algo); + hexdump(iv, crypto_ablkcipher_ivsize(tfm)); + ret = -EINVAL; + goto out; + } } j = 0; diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 62e2485..03320f9 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -49,6 +49,7 @@ struct hash_testvec { struct cipher_testvec { char *key; char *iv; + char *iv_out; char *input; char *result; unsigned short tap[MAX_TAP];