From nobody Fri Jan 14 01:22:27 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D392A1940871; Fri, 14 Jan 2022 01:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZk7758kwz3DD8; Fri, 14 Jan 2022 01:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642123347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pY25IEHgYHo4RUY/dD7ek7p+njW7eyi6C1ursGhlwEk=; b=ALk9N5RLzBQigAwpKFuXDAU9XX0WMU1bskbhJ5ViZJYbAPQuTjKRk4uzK6LLrerao7LzAm f4nlU+m1jyswiPes0THSTsH1tDVC6+/GoQGSSyfl5LqeVKPSKWJXSnilrHpgFbXfotoBi7 B0cgSCTbbFq15azMS+Y92E8gBVafdSZS6/iaqThh2Q6wUdsX2irinfO1BdqfBieaoF96rZ rNP3noypy6RpAsSacwe2A4onobWiwbIIA5afbkhOKxIJcq0QnYtXsmxDOKU44798eqRkGw gAS43lXHR6Ac/2FILqX8fAoLkeYLnVBnmZc9FmKEo+6EMt8vqb1z5tO7nkXRsg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 916552BE7; Fri, 14 Jan 2022 01:22:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20E1MRB5049935; Fri, 14 Jan 2022 01:22:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20E1MRkS049934; Fri, 14 Jan 2022 01:22:27 GMT (envelope-from git) Date: Fri, 14 Jan 2022 01:22:27 GMT Message-Id: <202201140122.20E1MRkS049934@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: c7721958ffa1 - main - geliboot: Use the correct IV length for AES-XTS. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7721958ffa1aa81064b74b884e81efbe11d7fe4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642123347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pY25IEHgYHo4RUY/dD7ek7p+njW7eyi6C1ursGhlwEk=; b=IcFe+d3nlMyNnm0qVzrcCRxihn5wcDIHlYx/UHszWJU0dVG6N3ddfqnJppDAvT83yF3VJP 2ltH2/0yCgHggrSqpUJhZG7dAK2rXhlKq2YgAY4p8D8Ea2zWonq8xvc6ZRZuiv6Rkj0vSa Vdcy6d1B/TacHjvBcOLmJkF9jbdp5EsRbXS2RHF86vLytsG/bZEl50u8kN59v9hOd8hefi es6kXHCtBN3ZF6DcyCy0h31fQMaOeIJHKcGNGnVGtvZyWjVPaHqGKJrJR57TBTZaxZnxpm wpGCQvJo9TkYrEmVnrMWKqYKTVfPVbQvJGyuBajBagPv+TVXUsBEQJVz55/pDQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642123347; a=rsa-sha256; cv=none; b=QvgE0FMeXi1oTs5hJOvh5BAS7S6ga4tdudvG5OfGHY8osnE/3v8NV2TN/HD3/rPFA1NWAj 8olx9OgBR2xbDwOrfl2rp5UX5rlRNSGTIhILw4z1AzusC8IJHBiGmzlolfPyfNHpz7OUOc JJf52+iDjkv0ItM9ZiF6MHS6KUpE0v4LFqIPqERVUuGp8NWHBUQYpolrvMrNFUNOqpxwa4 pdFuZzNVAScytDKJrUsIkG3OuGaeyiyv28OgHbL+99I6p4kMmYpAtg3+v6c2yYdOQE5b2m Cxfz2jXyMV9qMpL1ILUcDtEG1REw1aiwVyudUcN5N4FKy6Eta3whmeglXEv39Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c7721958ffa1aa81064b74b884e81efbe11d7fe4 commit c7721958ffa1aa81064b74b884e81efbe11d7fe4 Author: John Baldwin AuthorDate: 2022-01-14 01:19:54 +0000 Commit: John Baldwin CommitDate: 2022-01-14 01:19:54 +0000 geliboot: Use the correct IV length for AES-XTS. - Use AES_XTS_IV_LEN instead of the key length as the IV length. - Use G_ELI_IVKEYLEN as the size of the zeroed iv[] array in g_eli_crypto_cipher() to match geli_io(). PR: 261172 Reported by: Malcolm Matalka , mikael Reviewed by: markj Sponsored by: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33884 --- stand/libsa/geli/geliboot.c | 2 +- stand/libsa/geli/geliboot_crypto.c | 9 ++++----- stand/libsa/geli/geliboot_internal.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/stand/libsa/geli/geliboot.c b/stand/libsa/geli/geliboot.c index 56499e96b295..954a3ec34044 100644 --- a/stand/libsa/geli/geliboot.c +++ b/stand/libsa/geli/geliboot.c @@ -345,7 +345,7 @@ geli_io(struct geli_dev *gdev, geli_op_t enc, off_t offset, u_char *buf, g_eli_key_fill(&gdev->sc, &gkey, keyno); error = geliboot_crypt(gdev->sc.sc_ealgo, enc, pbuf, secsize, - gkey.gek_key, gdev->sc.sc_ekeylen, iv, sizeof(iv)); + gkey.gek_key, gdev->sc.sc_ekeylen, iv); if (error != 0) { explicit_bzero(&gkey, sizeof(gkey)); diff --git a/stand/libsa/geli/geliboot_crypto.c b/stand/libsa/geli/geliboot_crypto.c index 766f908d9037..90c9be30cf03 100644 --- a/stand/libsa/geli/geliboot_crypto.c +++ b/stand/libsa/geli/geliboot_crypto.c @@ -36,7 +36,7 @@ int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, - const u_char *key, size_t keysize, u_char *iv, size_t ivlen) + const u_char *key, size_t keysize, u_char *iv) { keyInstance aeskey; cipherInstance cipher; @@ -81,7 +81,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, ctxp = &xtsctx; enc_xform_aes_xts.setkey(ctxp, key, xts_len / 8); - enc_xform_aes_xts.reinit(ctxp, iv, ivlen); + enc_xform_aes_xts.reinit(ctxp, iv, AES_XTS_IV_LEN); switch (enc) { case GELI_DECRYPT: @@ -106,11 +106,10 @@ static int g_eli_crypto_cipher(u_int algo, geli_op_t enc, u_char *data, size_t datasize, const u_char *key, size_t keysize) { - u_char iv[keysize]; + u_char iv[G_ELI_IVKEYLEN]; explicit_bzero(iv, sizeof(iv)); - return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv, - sizeof(iv))); + return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv)); } int diff --git a/stand/libsa/geli/geliboot_internal.h b/stand/libsa/geli/geliboot_internal.h index 2318690297f8..2af74466179f 100644 --- a/stand/libsa/geli/geliboot_internal.h +++ b/stand/libsa/geli/geliboot_internal.h @@ -68,6 +68,6 @@ struct geli_dev { }; int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, - const u_char *key, size_t keysize, u_char *iv, size_t ivlen); + const u_char *key, size_t keysize, u_char *iv); #endif /* _GELIBOOT_INTERNAL_H_ */