// SPDX-License-Identifier: GPL-2.0 /* * Functions corresponding to secure platform management object type * attributes under BIOS PASSWORD for use with hp-bioscfg driver * * Copyright (c) 2022 HP Development Company, L.P.
*/
/** * 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, constchar *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;
/* * status_show - Reads SPM status
*/ static ssize_t status_show(struct kobject *kobj, struct kobj_attribute
*attr, char *buf)
{ int ret, i; int len = 0; struct secureplatform_provisioning_data data;
ret = statusbin(kobj, attr, &data); if (ret < 0) return ret;
/* * 'status' is a read-only file that returns ASCII text in * JSON format reporting the status information. * * "State": "not provisioned | provisioned | provisioning in progress ", * "Version": " Major. Minor ", * "Nonce": <16-bit unsigned number display in base 10>, * "FeaturesInUse": <16-bit unsigned number display in base 10>, * "EndorsementKeyMod": "<256 bytes in base64>", * "SigningKeyMod": "<256 bytes in base64>"
*/
len += sysfs_emit_at(buf, len, "{\n");
len += sysfs_emit_at(buf, len, "\t\"State\": \"%s\",\n",
spm_state_types[data.state]);
len += sysfs_emit_at(buf, len, "\t\"Version\": \"%d.%d\"",
data.version[0], data.version[1]);
/* * state == 0 means secure platform management * feature is not configured in BIOS.
*/ if (data.state == 0) {
len += sysfs_emit_at(buf, len, "\n"); goto status_exit;
} else {
len += sysfs_emit_at(buf, len, ",\n");
}
len += sysfs_emit_at(buf, len, "\t\"Nonce\": %d,\n", data.nonce);
len += sysfs_emit_at(buf, len, "\t\"FeaturesInUse\": %d,\n", data.features);
len += sysfs_emit_at(buf, len, "\t\"EndorsementKeyMod\": \"");
for (i = 255; i >= 0; i--)
len += sysfs_emit_at(buf, len, " %u", data.kek_mod[i]);
len += sysfs_emit_at(buf, len, " \",\n");
len += sysfs_emit_at(buf, len, "\t\"SigningKeyMod\": \"");
for (i = 255; i >= 0; i--)
len += sysfs_emit_at(buf, len, " %u", data.sk_mod[i]);
static ssize_t sk_store(struct kobject *kobj, struct kobj_attribute *attr, constchar *buf, size_t count)
{ int ret; int length;
length = count; if (buf[length - 1] == '\n')
length--;
/* allocate space and copy current signing key */
bioscfg_drv.spm_data.signing_key = kmemdup(buf, length, GFP_KERNEL); if (!bioscfg_drv.spm_data.signing_key) return -ENOMEM;
static ssize_t kek_store(struct kobject *kobj, struct kobj_attribute *attr, constchar *buf, size_t count)
{ int ret; int length;
length = count; if (buf[length - 1] == '\n')
length--;
/* allocate space and copy current signing key */
bioscfg_drv.spm_data.endorsement_key = kmemdup(buf, length, GFP_KERNEL); if (!bioscfg_drv.spm_data.endorsement_key) {
ret = -ENOMEM; goto exit_kek;
}
ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_KEK,
HPWMI_SECUREPLATFORM,
(void *)bioscfg_drv.spm_data.endorsement_key,
count, 0);
if (!ret) {
bioscfg_drv.spm_data.mechanism = ENDORSEMENT_KEY;
hp_set_reboot_and_signal_event();
}
static ssize_t auth_token_store(struct kobject *kobj, struct kobj_attribute *attr, constchar *buf, size_t count)
{ int ret = 0; int length;
length = count; if (buf[length - 1] == '\n')
length--;
/* allocate space and copy current auth token */
bioscfg_drv.spm_data.auth_token = kmemdup(buf, length, GFP_KERNEL); if (!bioscfg_drv.spm_data.auth_token) {
ret = -ENOMEM; goto exit_token;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.