git: b15636233845 - main - geliboot: Use the multi-block functions for AES-XTS.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 11 Jan 2022 22:38:10 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=b156362338456023956446f0f354ad8b3a35e5ad

commit b156362338456023956446f0f354ad8b3a35e5ad
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-01-11 22:18:12 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-01-11 22:18:12 +0000

    geliboot: Use the multi-block functions for AES-XTS.
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33530
---
 stand/libsa/geli/geliboot_crypto.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/stand/libsa/geli/geliboot_crypto.c b/stand/libsa/geli/geliboot_crypto.c
index fcc5d7bcd7fb..766f908d9037 100644
--- a/stand/libsa/geli/geliboot_crypto.c
+++ b/stand/libsa/geli/geliboot_crypto.c
@@ -42,7 +42,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
 	cipherInstance cipher;
 	struct aes_xts_ctx xtsctx, *ctxp;
 	size_t xts_len;
-	int err, blks, i;
+	int err, blks;
 
 	switch (algo) {
 	case CRYPTO_AES_CBC:
@@ -85,16 +85,12 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
 
 		switch (enc) {
 		case GELI_DECRYPT:
-			for (i = 0; i < datasize; i += AES_XTS_BLOCKSIZE) {
-				enc_xform_aes_xts.decrypt(ctxp, data + i,
-				    data + i);
-			}
+			enc_xform_aes_xts.decrypt_multi(ctxp, data, data,
+			    datasize);
 			break;
 		case GELI_ENCRYPT:
-			for (i = 0; i < datasize; i += AES_XTS_BLOCKSIZE) {
-				enc_xform_aes_xts.encrypt(ctxp, data + i,
-				    data + i);
-			}
+			enc_xform_aes_xts.encrypt_multi(ctxp, data, data,
+			    datasize);
 			break;
 		}
 		break;