From patchwork Tue Dec 2 08:37:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Spelvin X-Patchwork-Id: 5417871 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 94E149F1CD for ; Tue, 2 Dec 2014 08:37:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB4B82027D for ; Tue, 2 Dec 2014 08:37:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F37242026C for ; Tue, 2 Dec 2014 08:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309AbaLBIhv (ORCPT ); Tue, 2 Dec 2014 03:37:51 -0500 Received: from ns.horizon.com ([71.41.210.147]:21489 "HELO ns.horizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751047AbaLBIhu (ORCPT ); Tue, 2 Dec 2014 03:37:50 -0500 Received: (qmail 18040 invoked by uid 1000); 2 Dec 2014 03:37:49 -0500 Date: 2 Dec 2014 03:37:49 -0500 Message-ID: <20141202083749.18039.qmail@ns.horizon.com> From: "George Spelvin" To: herbert@gondor.apana.org.au, nhorman@tuxdriver.com Subject: PATCH 04/17] crypto: ansi_cprng - simplify xor_vectors() to xor_block() Cc: linux-crypto@vger.kernel.org, linux@horizon.com, smueller@chronox.de In-Reply-To: <20141202083314.17647.qmail@ns.horizon.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It doesn't need a second input or a length parameter. Signed-off-by: George Spelvin --- crypto/ansi_cprng.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c index 6b844f13..4856c84c7 100644 --- a/crypto/ansi_cprng.c +++ b/crypto/ansi_cprng.c @@ -74,14 +74,12 @@ if (dbg)\ printk(format, ##args);\ } while (0) -static void xor_vectors(unsigned char *in1, unsigned char *in2, - unsigned char *out, unsigned int size) +static void xor_block(unsigned char const *in, unsigned char *out) { int i; - for (i = 0; i < size; i++) - out[i] = in1[i] ^ in2[i]; - + for (i = 0; i < DEFAULT_BLK_SZ; i++) + out[i] ^= in[i]; } /* * Returns DEFAULT_BLK_SZ bytes of random data per call @@ -123,7 +121,7 @@ static int _get_more_prng_bytes(struct prng_context *ctx, int cont_test) * in (no longer used) V until we have done the * anti-repetition compare. */ - xor_vectors(tmp, ctx->V, ctx->V, DEFAULT_BLK_SZ); + xor_block(tmp, ctx->V); hexdump("input stage 1: ", ctx->V, DEFAULT_BLK_SZ); input = output = ctx->V; break; @@ -151,7 +149,7 @@ static int _get_more_prng_bytes(struct prng_context *ctx, int cont_test) * Lastly xor the random data with I * and encrypt that to obtain a new secret vector V */ - xor_vectors(tmp, ctx->V, ctx->V, DEFAULT_BLK_SZ); + xor_block(tmp, ctx->V); hexdump("input stage 2: ", ctx->V, DEFAULT_BLK_SZ); input = output = ctx->V; break;