summaryrefslogtreecommitdiffstats
path: root/net/rxrpc/tests
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-19 10:09:22 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-19 10:09:22 -0700
commitf4cdf7ca9a1fdcca413157df19753f388a5a224e (patch)
tree60a31895b2446cd7fa27514e8c2843534a0de0da /net/rxrpc/tests
downloadlinux-stable-f4cdf7ca9a1fdcca413157df19753f388a5a224e.tar.gz
linux-stable-f4cdf7ca9a1fdcca413157df19753f388a5a224e.zip
Merge tag 'media/v7.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-mediagrafted
Pull media updates from Mauro Carvalho Chehab: - v4l2-core: added ISP statistics support and per-block validation - v4l2-core: Allow unknown HDR10 white point and luminance - New camera sensors: Sony IMX678 and IMX471m, Himax HM1092 IR sensor - New codec: Milos: VPU v2.0 codec support - isp driver: gained support for Dreamchip RPPX1 ISP framework - vsp1 driver: gained support for RZ/T2H and RZ/N2H - Novalake driver: gained CVS support for new NVL hardware - dvb-core: fix feed leak on failed DMX_ADD_PID - several driver fixes, cleanups and minor improvements * tag 'media/v7.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (308 commits) media: ipu-bridge: check all DMI entries when overriding sensor rotation media: v4l2-async: avoid deleting unlinked ASC entry on link error media: rzg2l-cru: Align bytesperline to hardware DMA stride requirement media: intel/ipu6: fix async notifier cleanup leak on parse error media: staging/ipu7: fix async notifier UAF on probe error path media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem() media: rcar-isp: Fix VSPX reference leaks media: rcar-isp: Release ISPCORE resources media: i2c: imx415: Release runtime PM reference on VBLANK error media: i2c: imx415: Return test pattern write errors media: renesas: vsp1: Declare index variables in for loop statement media: renesas: vsp1: Make reset control optional to support platforms without a reset line media: dt-bindings: media: renesas,vsp1: Document RZ/T2H and RZ/N2H SoCs media: dt-bindings: media: renesas,fcp: Document RZ/T2H and RZ/N2H SoCs media: nxp: imx8-isi: Add additional 32-bit RGB format support media: nxp: imx8-isi: Add 16-bit raw Bayer format support media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams media: nxp: imx8-isi: Use BIT_ULL() for 64-bit stream masks media: nxp: imx8-isi: Correct color map between V4L2 and ISI ...
Diffstat (limited to 'net/rxrpc/tests')
-rw-r--r--net/rxrpc/tests/Makefile3
-rw-r--r--net/rxrpc/tests/rxrpc_kunit.c140
2 files changed, 143 insertions, 0 deletions
diff --git a/net/rxrpc/tests/Makefile b/net/rxrpc/tests/Makefile
new file mode 100644
index 000000000..4f5100880
--- /dev/null
+++ b/net/rxrpc/tests/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_AF_RXRPC_KUNIT_TEST) += rxrpc_kunit.o
diff --git a/net/rxrpc/tests/rxrpc_kunit.c b/net/rxrpc/tests/rxrpc_kunit.c
new file mode 100644
index 000000000..95fd05a07
--- /dev/null
+++ b/net/rxrpc/tests/rxrpc_kunit.c
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Unit tests for RxRPC crypto functions
+ *
+ * Copyright 2026 Google LLC
+ */
+#include "../ar-internal.h"
+#include <crypto/des.h>
+#include <kunit/test.h>
+
+struct fcrypt_pcbc_testvec {
+ u8 key[FCRYPT_BSIZE];
+ u8 iv[FCRYPT_BSIZE];
+ const u8 *ptext; /* plaintext */
+ const u8 *ctext; /* ciphertext */
+ size_t nblocks; /* length of ptext and ctext in blocks */
+};
+
+/* FCrypt-PCBC test vectors */
+static const struct fcrypt_pcbc_testvec fcrypt_pcbc_testvecs[] = {
+ {
+ /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
+ .key = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ptext = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ctext = "\x0E\x09\x00\xC7\x3E\xF7\xED\x41",
+ .nblocks = 1,
+ },
+ {
+ .key = "\x11\x44\x77\xAA\xDD\x00\x33\x66",
+ .iv = "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ptext = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0",
+ .ctext = "\xD8\xED\x78\x74\x77\xEC\x06\x80",
+ .nblocks = 1,
+ },
+ {
+ /* From Arla */
+ .key = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .iv = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .ptext = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ctext = "\x00\xf0\x0e\x11\x75\xe6\x23\x82"
+ "\xee\xac\x98\x62\x44\x51\xe4\x84"
+ "\xc3\x59\xd8\xaa\x64\x60\xae\xf7"
+ "\xd2\xd9\x13\x79\x72\xa3\x45\x03"
+ "\x23\xb5\x62\xd7\x0c\xf5\x27\xd1"
+ "\xf8\x91\x3c\xac\x44\x22\x92\xef",
+ .nblocks = 6,
+ },
+ {
+ .key = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
+ .iv = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
+ .ptext = "The quick brown fox jumps over the lazy dogs.\0\0",
+ .ctext = "\xca\x90\xf5\x9d\xcb\xd4\xd2\x3c"
+ "\x01\x88\x7f\x3e\x31\x6e\x62\x9d"
+ "\xd8\xe0\x57\xa3\x06\x3a\x42\x58"
+ "\x2a\x28\xfe\x72\x52\x2f\xdd\xe0"
+ "\x19\x89\x09\x1c\x2a\x8e\x8c\x94"
+ "\xfc\xc7\x68\xe4\x88\xaa\xde\x0f",
+ .nblocks = 6,
+ }
+};
+
+static void test_fcrypt_pcbc(struct kunit *test)
+{
+ u8 data[48];
+
+ for (size_t i = 0; i < ARRAY_SIZE(fcrypt_pcbc_testvecs); i++) {
+ const struct fcrypt_pcbc_testvec *tv = &fcrypt_pcbc_testvecs[i];
+ const size_t nblocks = tv->nblocks;
+ const size_t len = nblocks * FCRYPT_BSIZE;
+ struct fcrypt_key key;
+
+ KUNIT_ASSERT_GE(test, sizeof(data), len);
+
+ fcrypt_preparekey(&key, tv->key);
+
+ /* out-of-place encryption */
+ fcrypt_pcbc_encrypt(&key, tv->iv, tv->ptext, data, nblocks);
+ KUNIT_ASSERT_MEMEQ(test, tv->ctext, data, len);
+
+ /* in-place encryption */
+ memcpy(data, tv->ptext, len);
+ fcrypt_pcbc_encrypt(&key, tv->iv, data, data, nblocks);
+ KUNIT_ASSERT_MEMEQ(test, tv->ctext, data, len);
+
+ /* out-of-place decryption */
+ fcrypt_pcbc_decrypt(&key, tv->iv, tv->ctext, data, nblocks);
+ KUNIT_ASSERT_MEMEQ(test, tv->ptext, data, len);
+
+ /* in-place decryption */
+ memcpy(data, tv->ctext, len);
+ fcrypt_pcbc_decrypt(&key, tv->iv, data, data, nblocks);
+ KUNIT_ASSERT_MEMEQ(test, tv->ptext, data, len);
+ }
+}
+
+static void test_des_pcbc(struct kunit *test)
+{
+ /* This was generated from the original pcbc(des) crypto API code. */
+ static const u8 expected_ptext[24] =
+ "\xc8\xe2\x3c\xdf\x80\x61\x8a\xad\xa5\x52\xb4\x20"
+ "\x74\x32\x1f\xe4\x2c\x15\x7d\x21\x57\xda\x3f\x31";
+ u8 key[8];
+ union {
+ __le64 w;
+ u8 b[8];
+ } iv;
+ u8 data[24];
+ struct des_ctx ctx;
+ int err;
+
+ for (int i = 0; i < 8; i++) {
+ key[i] = i;
+ iv.b[i] = 255 - i;
+ }
+ for (int i = 0; i < sizeof(data); i++)
+ data[i] = i;
+
+ err = des_expand_key(&ctx, key, sizeof(key));
+ KUNIT_ASSERT_EQ(test, 0, err);
+
+ des_pcbc_decrypt_inplace(&ctx, iv.w, data, sizeof(data));
+ KUNIT_ASSERT_MEMEQ(test, expected_ptext, data, sizeof(data));
+}
+
+static struct kunit_case rxrpc_test_cases[] = {
+ KUNIT_CASE(test_fcrypt_pcbc),
+ KUNIT_CASE(test_des_pcbc),
+ {},
+};
+
+static struct kunit_suite rxrpc_test_suite = {
+ .name = "rxrpc",
+ .test_cases = rxrpc_test_cases,
+};
+kunit_test_suite(rxrpc_test_suite);
+
+MODULE_DESCRIPTION("Unit tests for RxRPC crypto functions");
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+MODULE_LICENSE("GPL");