/* * datablob_parse - parse the keyctl data and fill in the * payload structure * * On success returns 0, otherwise -EINVAL.
*/ staticint datablob_parse(char **datablob, struct trusted_key_payload *p)
{
substring_t args[MAX_OPT_ARGS]; long keylen; int ret = -EINVAL; int key_cmd; char *c;
/* main command */
c = strsep(datablob, " \t"); if (!c) return -EINVAL;
key_cmd = match_token(c, key_tokens, args); switch (key_cmd) { case Opt_new: /* first argument is key size */
c = strsep(datablob, " \t"); if (!c) return -EINVAL;
ret = kstrtol(c, 10, &keylen); if (ret < 0 || keylen < MIN_KEY_SIZE || keylen > MAX_KEY_SIZE) return -EINVAL;
p->key_len = keylen;
ret = Opt_new; break; case Opt_load: /* first argument is sealed blob */
c = strsep(datablob, " \t"); if (!c) return -EINVAL;
p->blob_len = strlen(c) / 2; if (p->blob_len > MAX_BLOB_SIZE) return -EINVAL;
ret = hex2bin(p->blob, c, p->blob_len); if (ret < 0) return -EINVAL;
ret = Opt_load; break; case Opt_update:
ret = Opt_update; break; case Opt_err: return -EINVAL;
} return ret;
}
ret = key_payload_reserve(key, sizeof(*p)); if (ret < 0) goto err;
p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) goto err;
p->migratable = migratable;
err: return p;
}
/* * trusted_instantiate - create a new trusted key * * Unseal an existing trusted blob or, for a new key, get a * random key, then seal and create a trusted key-type key, * adding it to the specified keyring. * * On success, return 0. Otherwise return errno.
*/ staticint trusted_instantiate(struct key *key, struct key_preparsed_payload *prep)
{ struct trusted_key_payload *payload = NULL;
size_t datalen = prep->datalen; char *datablob, *orig_datablob; int ret = 0; int key_cmd;
size_t key_len;
staticint __init init_trusted(void)
{ int (*get_random)(unsignedchar *key, size_t key_len); int i, ret = 0;
for (i = 0; i < ARRAY_SIZE(trusted_key_sources); i++) { if (trusted_key_source &&
strncmp(trusted_key_source, trusted_key_sources[i].name,
strlen(trusted_key_sources[i].name))) continue;
/* * We always support trusted.rng="kernel" and "default" as * well as trusted.rng=$trusted.source if the trust source * defines its own get_random callback.
*/
get_random = trusted_key_sources[i].ops->get_random; if (trusted_rng && strcmp(trusted_rng, "default")) { if (!strcmp(trusted_rng, "kernel")) {
get_random = kernel_get_random;
} elseif (strcmp(trusted_rng, trusted_key_sources[i].name) ||
!get_random) {
pr_warn("Unsupported RNG. Supported: kernel"); if (get_random)
pr_cont(", %s", trusted_key_sources[i].name);
pr_cont(", default\n"); return -EINVAL;
}
}
if (!get_random)
get_random = kernel_get_random;
ret = trusted_key_sources[i].ops->init(); if (!ret) {
static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal);
static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal);
static_call_update(trusted_key_get_random, get_random);
¤ 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.0.26Bemerkung:
(vorverarbeitet)
¤
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.