drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
Extension
.c
Size
9499 bytes
Lines
381
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct secureplatform_provisioning_data {
	u8 state;
	u8 version[2];
	u8 reserved1;
	u32 features;
	u32 nonce;
	u8 reserved2[28];
	u8 sk_mod[MAX_KEY_MOD_SIZE];
	u8 kek_mod[MAX_KEY_MOD_SIZE];
};

/**
 * hp_calculate_security_buffer() - determines size of security buffer
 * for authentication scheme
 *
 * @authentication: the authentication content
 *
 * Currently only supported type is Admin password
 */
size_t hp_calculate_security_buffer(const char *authentication)
{
	size_t size, authlen;

	if (!authentication)
		return sizeof(u16) * 2;

	authlen = strlen(authentication);
	if (!authlen)
		return sizeof(u16) * 2;

	size = sizeof(u16) + authlen * sizeof(u16);
	if (!strstarts(authentication, BEAM_PREFIX))
		size += strlen(UTF_PREFIX) * sizeof(u16);

	return size;
}

/**
 * hp_populate_security_buffer() - builds a security buffer for
 * authentication scheme
 *
 * @authbuf: the security buffer
 * @authentication: the authentication content
 *
 * Currently only supported type is PLAIN TEXT
 */
int hp_populate_security_buffer(u16 *authbuf, const char *authentication)
{
	u16 *auth = authbuf;
	char *strprefix = NULL;
	int ret = 0;

	if (strstarts(authentication, BEAM_PREFIX)) {
		/*
		 * BEAM_PREFIX is append to authbuf when a signature
		 * is provided and Sure Admin is enabled in BIOS
		 */
		/* BEAM_PREFIX found, convert part to unicode */
		auth = hp_ascii_to_utf16_unicode(auth, authentication);
		if (!auth)
			return -EINVAL;

	} else {
		/*
		 * UTF-16 prefix is append to the * authbuf when a BIOS
		 * admin password is configured in BIOS
		 */

		/* append UTF_PREFIX to part and then convert it to unicode */
		strprefix = kasprintf(GFP_KERNEL, "%s%s", UTF_PREFIX,
				      authentication);
		if (!strprefix)
			return -ENOMEM;

		auth = hp_ascii_to_utf16_unicode(auth, strprefix);
		kfree(strprefix);

		if (!auth) {
			ret = -EINVAL;
			goto out_buffer;
		}
	}

out_buffer:
	return ret;
}

static ssize_t update_spm_state(void)
{
	struct secureplatform_provisioning_data data;

Annotation

Implementation Notes