Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp440100pxu; Fri, 4 Dec 2020 07:03:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwptRDYXoqzGs8sf/1jyW8QakMJxghuG7OOsBDC2YxO5NmwE3tdJl78T5AT/u5jR4dQD4zM X-Received: by 2002:a17:906:358e:: with SMTP id o14mr7252686ejb.526.1607094200610; Fri, 04 Dec 2020 07:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607094200; cv=none; d=google.com; s=arc-20160816; b=BKCWfPswPjljDyP5RO23VmM9l/9rLV7DftoLibn4XWYv+/iCyUUhZnQx9WGwmJn6qv avBBNt0FADBsi8WzHlin0746PQIRPRtCRxNMSGNLPwq4u14vZLsRnYpxM7V9Xw5t5DRP L06mbnZ3+ZrwoeaVuP7vcy6Yx3JXdgvM7z7RUonvyKhef/wKjipH96ekzul2V5K4GAPk C7nZ6TFQRdW3xgn/5oorefjUpLHN1ueZqwtDzATJsazjJsOSTx9QtfHVaAa1CIa/Jiv2 wVR4KnaY/HC+YvuRFQrjGYXpiBSc8BMPObqBJdcvyRqEWOTmlUOePzwhhxaYuLcXmoCP h7oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=OTBOnyE1n+B2er0y+QuZYiU0VZBSiLUvAG5osfhcmQc=; b=qdkPnim6BpbDejE/KFZQX4vMgEUVEyCPsMFj2HmderJVqSnjLzdKS9XHAjB6H3LZmq Zumfcl7Hzgm7DERuJ1ZXHN0tHsMXt8A6c9O9XetsV6ECjDj+VbZCkZNPei9+NiYm73Gy 4UIcjoH6IKiwsvHDoqNZkju4kQTtYMY3Zzbo5UtW6xkvN/rjl2vQ26rrpFx7/2z7hJEi R/GNrq89+ECq6GsnfHt1F6E7PkrY+Vj9oF8Zgt9Oo/ip9t7n1tc2ERqDBCepqLNH2Mx+ n1qAbsltm7VZlSHvsLc+F2TOmTuadNYfb+NC7TVtqRt8rzDt95nmP5xsTAASG8JCq+rZ d88A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gPWG0q4t; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si1525718ejk.743.2020.12.04.07.02.46; Fri, 04 Dec 2020 07:03:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gPWG0q4t; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730412AbgLDPBK (ORCPT + 99 others); Fri, 4 Dec 2020 10:01:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41557 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730410AbgLDPBJ (ORCPT ); Fri, 4 Dec 2020 10:01:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607093983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OTBOnyE1n+B2er0y+QuZYiU0VZBSiLUvAG5osfhcmQc=; b=gPWG0q4t20Ry4+O/ui8q22rrjqbd99D4pGBAxMWTThYGZo6S51VSvDbd9+UwRrSyzYyVCh 10zuCQbXp9rIojvimcRxEyWvqGuxFEQ52/c3IjIs3FQ88ixBQpMtDgN7CO92UFo/J1ih35 XoHx06vb+U3Q/VIK5s0O9Amtxo/TWzQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-PzPPozy8PUqmAMwzJKEjCw-1; Fri, 04 Dec 2020 09:59:41 -0500 X-MC-Unique: PzPPozy8PUqmAMwzJKEjCw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FE30107ACE3; Fri, 4 Dec 2020 14:59:39 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-116-67.rdu2.redhat.com [10.10.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B307A18AD4; Fri, 4 Dec 2020 14:59:36 +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 From: David Howells In-Reply-To: <2F96670A-58DC-43A6-A20E-696803F0BFBA@oracle.com> References: <2F96670A-58DC-43A6-A20E-696803F0BFBA@oracle.com> <160518586534.2277919.14475638653680231924.stgit@warthog.procyon.org.uk> To: Chuck Lever , Bruce Fields Cc: dhowells@redhat.com, CIFS , Linux NFS Mailing List , Herbert Xu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Trond Myklebust , linux-crypto@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org Subject: Why the auxiliary cipher in gss_krb5_crypto.c? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <118875.1607093975.1@warthog.procyon.org.uk> Date: Fri, 04 Dec 2020 14:59:35 +0000 Message-ID: <118876.1607093975@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Chuck, Bruce, Why is gss_krb5_crypto.c using an auxiliary cipher? For reference, the gss_krb5_aes_encrypt() code looks like the attached. From what I can tell, in AES mode, the difference between the main cipher and the auxiliary cipher is that the latter is "cbc(aes)" whereas the former is "cts(cbc(aes))" - but they have the same key. Reading up on CTS, I'm guessing the reason it's like this is that CTS is the same as the non-CTS, except for the last two blocks, but the non-CTS one is more efficient. David --- nbytes = buf->len - offset - GSS_KRB5_TOK_HDR_LEN; nblocks = (nbytes + blocksize - 1) / blocksize; cbcbytes = 0; if (nblocks > 2) cbcbytes = (nblocks - 2) * blocksize; memset(desc.iv, 0, sizeof(desc.iv)); if (cbcbytes) { SYNC_SKCIPHER_REQUEST_ON_STACK(req, aux_cipher); desc.pos = offset + GSS_KRB5_TOK_HDR_LEN; desc.fragno = 0; desc.fraglen = 0; desc.pages = pages; desc.outbuf = buf; desc.req = req; skcipher_request_set_sync_tfm(req, aux_cipher); skcipher_request_set_callback(req, 0, NULL, NULL); sg_init_table(desc.infrags, 4); sg_init_table(desc.outfrags, 4); err = xdr_process_buf(buf, offset + GSS_KRB5_TOK_HDR_LEN, cbcbytes, encryptor, &desc); skcipher_request_zero(req); if (err) goto out_err; } /* Make sure IV carries forward from any CBC results. */ err = gss_krb5_cts_crypt(cipher, buf, offset + GSS_KRB5_TOK_HDR_LEN + cbcbytes, desc.iv, pages, 1); if (err) { err = GSS_S_FAILURE; goto out_err; }