From patchwork Tue Aug 21 15:58:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10571965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF5C6921 for ; Tue, 21 Aug 2018 15:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFF02A521 for ; Tue, 21 Aug 2018 15:58:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B02032A529; Tue, 21 Aug 2018 15:58:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58D352A521 for ; Tue, 21 Aug 2018 15:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbeHUTTC (ORCPT ); Tue, 21 Aug 2018 15:19:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43508 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726967AbeHUTTC (ORCPT ); Tue, 21 Aug 2018 15:19:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E626D40216E8; Tue, 21 Aug 2018 15:58:18 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-147.rdu2.redhat.com [10.10.123.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA7251010413; Tue, 21 Aug 2018 15:58:17 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 13/23] TPMLIB: Rename store8() and storebytes() From: David Howells To: denkenz@gmail.com, jarkko.sakkinen@linux.intel.com, jejb@linux.vnet.ibm.com Cc: keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org Date: Tue, 21 Aug 2018 16:58:17 +0100 Message-ID: <153486709741.13066.7109350297231028843.stgit@warthog.procyon.org.uk> In-Reply-To: <153486700916.13066.12870860668352070081.stgit@warthog.procyon.org.uk> References: <153486700916.13066.12870860668352070081.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 15:58:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 21 Aug 2018 15:58:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Rename store8() and storebytes() so that the names are the same length as for store16() and store32() and their parameters line up, making blocks of them easier to read. Signed-off-by: David Howells --- drivers/char/tpm/tpm-library.c | 28 ++++++++++++++-------------- drivers/char/tpm/tpm-library.h | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/char/tpm/tpm-library.c b/drivers/char/tpm/tpm-library.c index 1c64282d1d0d..1eea483cf36b 100644 --- a/drivers/char/tpm/tpm-library.c +++ b/drivers/char/tpm/tpm-library.c @@ -427,7 +427,7 @@ static int tpm_create_osap(struct tpm_chip *chip, store32(tb, TPM_ORD_OSAP); store16(tb, keytype); store32(tb, keyhandle); - storebytes(tb, ononce.data, TPM_NONCE_SIZE); + store_s(tb, ononce.data, TPM_NONCE_SIZE); ret = tpm_send_dump(chip, tb->data, MAX_BUF_SIZE, "creating OSAP session"); @@ -579,15 +579,15 @@ int tpm_seal(struct tpm_chip *chip, store32(tb, TPM_SEAL_SIZE + pcrinfosize + rawlen); store32(tb, TPM_ORD_SEAL); store32(tb, keyhandle); - storebytes(tb, td->encauth, SHA1_DIGEST_SIZE); + store_s(tb, td->encauth, SHA1_DIGEST_SIZE); store32(tb, pcrinfosize); - storebytes(tb, pcrinfo, pcrinfosize); + store_s(tb, pcrinfo, pcrinfosize); store32(tb, rawlen); - storebytes(tb, rawdata, rawlen); + store_s(tb, rawdata, rawlen); store32(tb, sess.handle); - storebytes(tb, td->ononce.data, TPM_NONCE_SIZE); - store8(tb, cont); - storebytes(tb, td->pubauth, SHA1_DIGEST_SIZE); + store_s(tb, td->ononce.data, TPM_NONCE_SIZE); + store_8(tb, cont); + store_s(tb, td->pubauth, SHA1_DIGEST_SIZE); ret = tpm_send_dump(chip, tb->data, MAX_BUF_SIZE, "sealing data"); @@ -688,15 +688,15 @@ int tpm_unseal(struct tpm_chip *chip, struct tpm_buf *tb, store32(tb, TPM_UNSEAL_SIZE + enclen); store32(tb, TPM_ORD_UNSEAL); store32(tb, keyhandle); - storebytes(tb, encdata, enclen); + store_s(tb, encdata, enclen); store32(tb, authhandle1); - storebytes(tb, ononce.data, TPM_NONCE_SIZE); - store8(tb, cont); - storebytes(tb, authdata1, SHA1_DIGEST_SIZE); + store_s(tb, ononce.data, TPM_NONCE_SIZE); + store_8(tb, cont); + store_s(tb, authdata1, SHA1_DIGEST_SIZE); store32(tb, authhandle2); - storebytes(tb, ononce.data, TPM_NONCE_SIZE); - store8(tb, cont); - storebytes(tb, authdata2, SHA1_DIGEST_SIZE); + store_s(tb, ononce.data, TPM_NONCE_SIZE); + store_8(tb, cont); + store_s(tb, authdata2, SHA1_DIGEST_SIZE); ret = tpm_send_dump(chip, tb->data, MAX_BUF_SIZE, "unsealing data"); diff --git a/drivers/char/tpm/tpm-library.h b/drivers/char/tpm/tpm-library.h index ceb0ea1cd2bb..c1af99dba08d 100644 --- a/drivers/char/tpm/tpm-library.h +++ b/drivers/char/tpm/tpm-library.h @@ -29,25 +29,25 @@ struct tpm_osapsess { struct tpm_even_nonce enonce; }; -static inline void store8(struct tpm_buf *buf, const unsigned char value) +static inline void store_8(struct tpm_buf *buf, unsigned char value) { buf->data[buf->len++] = value; } -static inline void store16(struct tpm_buf *buf, const uint16_t value) +static inline void store16(struct tpm_buf *buf, uint16_t value) { - *(uint16_t *) & buf->data[buf->len] = htons(value); + *(uint16_t *)&buf->data[buf->len] = htons(value); buf->len += sizeof value; } -static inline void store32(struct tpm_buf *buf, const uint32_t value) +static inline void store32(struct tpm_buf *buf, uint32_t value) { - *(uint32_t *) & buf->data[buf->len] = htonl(value); + *(uint32_t *)&buf->data[buf->len] = htonl(value); buf->len += sizeof value; } -static inline void storebytes(struct tpm_buf *buf, const unsigned char *in, - const int len) +static inline void store_s(struct tpm_buf *buf, const unsigned char *in, + int len) { memcpy(buf->data + buf->len, in, len); buf->len += len;