crypto/testmgr.c

Source file repositories/reference/linux-study-clean/crypto/testmgr.c

File Facts

System
Linux kernel
Corpus path
crypto/testmgr.c
Extension
.c
Size
151526 bytes
Lines
5723
Domain
Kernel Services
Bucket
crypto
Inferred role
Kernel Services: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

struct aead_test_suite {
	const struct aead_testvec *vecs;
	unsigned int count;

	/*
	 * Set if trying to decrypt an inauthentic ciphertext with this
	 * algorithm might result in EINVAL rather than EBADMSG, due to other
	 * validation the algorithm does on the inputs such as length checks.
	 */
	unsigned int einval_allowed : 1;

	/*
	 * Set if this algorithm requires that the IV be located at the end of
	 * the AAD buffer, in addition to being given in the normal way.  The
	 * behavior when the two IV copies differ is implementation-defined.
	 */
	unsigned int aad_iv : 1;
};

struct cipher_test_suite {
	const struct cipher_testvec *vecs;
	unsigned int count;
};

struct comp_test_suite {
	struct {
		const struct comp_testvec *vecs;
		unsigned int count;
	} comp, decomp;
};

struct hash_test_suite {
	const struct hash_testvec *vecs;
	unsigned int count;
};

struct drbg_test_suite {
	const struct drbg_testvec *vecs;
	unsigned int count;
};

struct akcipher_test_suite {
	const struct akcipher_testvec *vecs;
	unsigned int count;
};

struct sig_test_suite {
	const struct sig_testvec *vecs;
	unsigned int count;
};

struct kpp_test_suite {
	const struct kpp_testvec *vecs;
	unsigned int count;
};

struct alg_test_desc {
	const char *alg;
	const char *generic_driver;
	int (*test)(const struct alg_test_desc *desc, const char *driver,
		    u32 type, u32 mask);
	int fips_allowed;	/* set if alg is allowed in fips mode */

	union {
		struct aead_test_suite aead;
		struct cipher_test_suite cipher;
		struct comp_test_suite comp;
		struct hash_test_suite hash;
		struct drbg_test_suite drbg;
		struct akcipher_test_suite akcipher;
		struct sig_test_suite sig;
		struct kpp_test_suite kpp;
	} suite;
};

static void hexdump(unsigned char *buf, unsigned int len)
{
	print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
			16, 1,
			buf, len, false);
}

static int __testmgr_alloc_buf(char *buf[XBUFSIZE], int order)
{
	int i;

	for (i = 0; i < XBUFSIZE; i++) {
		buf[i] = (char *)__get_free_pages(GFP_KERNEL, order);
		if (!buf[i])
			goto err_free_buf;

Annotation

Implementation Notes