Message ID | 20230501140408.2648535-1-ardb@kernel.org |
---|---|
State | Accepted |
Commit | af97b7dfb0d4636d58f2341346fffce30c6c2259 |
Headers | show |
Series | SUNRPC: Avoid relying on crypto API to derive CBC-CTS output IV | expand |
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index 212c5d57465a1bf5..22dca4647ee66b3e 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -639,6 +639,13 @@ gss_krb5_cts_crypt(struct crypto_sync_skcipher *cipher, struct xdr_buf *buf, ret = write_bytes_to_xdr_buf(buf, offset, data, len); + /* + * CBC-CTS does not define an output IV but RFC 3962 defines it as the + * penultimate block of ciphertext, so copy that into the IV buffer + * before returning. + */ + if (encrypt) + memcpy(iv, data, crypto_sync_skcipher_ivsize(cipher)); out: kfree(data); return ret;