crypto/testmgr.h

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

File Facts

System
Linux kernel
Corpus path
crypto/testmgr.h
Extension
.h
Size
1446569 bytes
Lines
37445
Domain
Kernel Services
Bucket
crypto
Inferred role
Kernel Services: implementation source
Status
source 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 hash_testvec {
	const char *key;
	const char *plaintext;
	const char *digest;
	unsigned int psize;
	unsigned short ksize;
	int setkey_error;
	int digest_error;
	bool fips_skip;
};

/*
 * cipher_testvec:	structure to describe a symmetric cipher test
 * @key:	Pointer to key
 * @klen:	Length of @key in bytes
 * @iv:		Pointer to IV.  If NULL, an all-zeroes IV is used.
 * @iv_out:	Pointer to output IV, if applicable for the cipher.
 * @ptext:	Pointer to plaintext
 * @ctext:	Pointer to ciphertext
 * @len:	Length of @ptext and @ctext in bytes
 * @wk:		Does the test need CRYPTO_TFM_REQ_FORBID_WEAK_KEYS?
 * 		( e.g. test needs to fail due to a weak key )
 * @fips_skip:	Skip the test vector in FIPS mode
 * @setkey_error: Expected error from setkey()
 * @crypt_error: Expected error from encrypt() and decrypt()
 */
struct cipher_testvec {
	const char *key;
	const char *iv;
	const char *iv_out;
	const char *ptext;
	const char *ctext;
	unsigned char wk; /* weak key flag */
	unsigned short klen;
	unsigned int len;
	bool fips_skip;
	int setkey_error;
	int crypt_error;
};

/*
 * aead_testvec:	structure to describe an AEAD test
 * @key:	Pointer to key
 * @iv:		Pointer to IV.  If NULL, an all-zeroes IV is used.
 * @ptext:	Pointer to plaintext
 * @assoc:	Pointer to associated data
 * @ctext:	Pointer to the full authenticated ciphertext.  For AEADs that
 *		produce a separate "ciphertext" and "authentication tag", these
 *		two parts are concatenated: ciphertext || tag.
 * @novrfy:	If set, this is an inauthentic input test: only decryption is
 *		tested, and it is expected to fail with either -EBADMSG or
 *		@crypt_error if it is nonzero.
 * @wk:		Does the test need CRYPTO_TFM_REQ_FORBID_WEAK_KEYS?
 *		(e.g. setkey() needs to fail due to a weak key)
 * @klen:	Length of @key in bytes
 * @plen:	Length of @ptext in bytes
 * @alen:	Length of @assoc in bytes
 * @clen:	Length of @ctext in bytes
 * @setkey_error: Expected error from setkey().  If set, neither encryption nor
 *		  decryption is tested.
 * @setauthsize_error: Expected error from setauthsize().  If set, neither
 *		       encryption nor decryption is tested.
 * @crypt_error: When @novrfy=0, the expected error from encrypt().  When
 *		 @novrfy=1, an optional alternate error code that is acceptable
 *		 for decrypt() to return besides -EBADMSG.
 */
struct aead_testvec {
	const char *key;
	const char *iv;
	const char *ptext;
	const char *assoc;
	const char *ctext;
	unsigned char novrfy;
	unsigned char wk;
	unsigned char klen;
	unsigned int plen;
	unsigned int clen;
	unsigned int alen;
	int setkey_error;
	int setauthsize_error;
	int crypt_error;
};

struct drbg_testvec {
	/* Instantiate */
	const unsigned char *entropy;
	size_t entropylen;
	const unsigned char *pers;
	size_t perslen;

Annotation

Implementation Notes