linux-stable/net/sunrpc/auth_gss
Ard Biesheuvel af97b7dfb0 SUNRPC: Avoid relying on crypto API to derive CBC-CTS output IV
Scott reports SUNRPC self-test failures regarding the output IV on arm64
when using the SIMD accelerated implementation of AES in CBC mode with
ciphertext stealing ("cts(cbc(aes))" in crypto API speak).

These failures are the result of the fact that, while RFC 3962 does
specify what the output IV should be and includes test vectors for it,
the general concept of an output IV is poorly defined, and generally,
not specified by the various algorithms implemented by the crypto API.
Only algorithms that support transparent chaining (e.g., CBC mode on a
block boundary) have requirements on the output IV, but ciphertext
stealing (CTS) is fundamentally about how to encapsulate CBC in a way
where the length of the entire message may not be an integral multiple
of the cipher block size, and the concept of an output IV does not exist
here because it has no defined purpose past the end of the message.

The generic CTS template takes advantage of this chaining capability of
the CBC implementations, and as a result, happens to return an output
IV, simply because it passes its IV buffer directly to the encapsulated
CBC implementation, which operates on full blocks only, and always
returns an IV. This output IV happens to match how RFC 3962 defines it,
even though the CTS template itself does not contain any output IV logic
whatsoever, and, for this reason, lacks any test vectors that exercise
this accidental output IV generation.

The arm64 SIMD implementation of cts(cbc(aes)) does not use the generic
CTS template at all, but instead, implements the CBC mode and ciphertext
stealing directly, and therefore does not encapsule a CBC implementation
that returns an output IV in the same way. The arm64 SIMD implementation
complies with the specification and passes all internal tests, but when
invoked by the SUNRPC code, fails to produce the expected output IV and
causes its selftests to fail.

Given that the output IV is defined as the penultimate block (where the
final block may smaller than the block size), we can quite easily derive
it in the caller by copying the appropriate slice of ciphertext after
encryption.

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Anna Schumaker <anna@kernel.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Jeff Layton <jlayton@kernel.org>
Reported-by: Scott Mayhew <smayhew@redhat.com>
Tested-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2023-05-02 11:35:04 -04:00
..
Makefile SUNRPC: Add KUnit tests for rpcsec_krb5.ko 2023-02-20 09:20:46 -05:00
auth_gss.c SUNRPC: Move remaining internal definitions to gss_krb5_internal.h 2023-02-20 09:20:46 -05:00
auth_gss_internal.h SUNRPC/auth_gss: Convert GFP_NOFS to GFP_KERNEL 2022-02-25 18:50:12 -05:00
gss_generic_token.c sunrpc: Remove unneeded null check 2022-01-06 14:00:20 -05:00
gss_krb5_crypto.c SUNRPC: Avoid relying on crypto API to derive CBC-CTS output IV 2023-05-02 11:35:04 -04:00
gss_krb5_internal.h SUNRPC: Add encryption self-tests 2023-02-20 09:20:51 -05:00
gss_krb5_keys.c SUNRPC: Add KUnit tests for rpcsec_krb5.ko 2023-02-20 09:20:46 -05:00
gss_krb5_mech.c SUNRPC: Export get_gss_krb5_enctype() 2023-02-20 09:20:48 -05:00
gss_krb5_seal.c SUNRPC: Enable rpcsec_gss_krb5.ko to be built without CRYPTO_DES 2023-02-20 09:20:41 -05:00
gss_krb5_seqnum.c SUNRPC: Remove ->encrypt and ->decrypt methods from struct gss_krb5_enctype 2023-02-20 09:20:41 -05:00
gss_krb5_test.c SUNRPC: Fix failures of checksum Kunit tests 2023-04-17 09:42:54 -04:00
gss_krb5_unseal.c SUNRPC: Enable rpcsec_gss_krb5.ko to be built without CRYPTO_DES 2023-02-20 09:20:41 -05:00
gss_krb5_wrap.c SUNRPC: Rename .encrypt_v2 and .decrypt_v2 methods 2023-02-20 09:20:42 -05:00
gss_mech_switch.c sunrpc: clean up properly in gss_mech_unregister() 2020-05-28 18:15:00 -04:00
gss_rpc_upcall.c SUNRPC: Ensure that the gssproxy client can start in a connected state 2022-05-07 14:31:15 -04:00
gss_rpc_upcall.h SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files 2019-02-14 09:54:37 -05:00
gss_rpc_xdr.c SUNRPC: Remove XDRBUF_SPARSE_PAGES flag in gss_proxy upcall 2020-12-09 09:38:34 -05:00
gss_rpc_xdr.h SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files 2019-02-14 09:54:37 -05:00
svcauth_gss.c SUNRPC: return proper error from get_expiry() 2023-04-26 09:05:00 -04:00
trace.c SUNRPC: remove duplicate include 2020-08-19 13:19:42 -04:00