|
37 | 37 | #include <linux/key-type.h> |
38 | 38 | #include <keys/user-type.h> |
39 | 39 | #include <keys/encrypted-type.h> |
| 40 | +#include <keys/trusted-type.h> |
40 | 41 |
|
41 | 42 | #include <linux/device-mapper.h> |
42 | 43 |
|
@@ -2452,6 +2453,22 @@ static int set_key_encrypted(struct crypt_config *cc, struct key *key) |
2452 | 2453 | return 0; |
2453 | 2454 | } |
2454 | 2455 |
|
| 2456 | +static int set_key_trusted(struct crypt_config *cc, struct key *key) |
| 2457 | +{ |
| 2458 | + const struct trusted_key_payload *tkp; |
| 2459 | + |
| 2460 | + tkp = key->payload.data[0]; |
| 2461 | + if (!tkp) |
| 2462 | + return -EKEYREVOKED; |
| 2463 | + |
| 2464 | + if (cc->key_size != tkp->key_len) |
| 2465 | + return -EINVAL; |
| 2466 | + |
| 2467 | + memcpy(cc->key, tkp->key, cc->key_size); |
| 2468 | + |
| 2469 | + return 0; |
| 2470 | +} |
| 2471 | + |
2455 | 2472 | static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string) |
2456 | 2473 | { |
2457 | 2474 | char *new_key_string, *key_desc; |
@@ -2484,6 +2501,10 @@ static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string |
2484 | 2501 | !strncmp(key_string, "encrypted:", key_desc - key_string + 1)) { |
2485 | 2502 | type = &key_type_encrypted; |
2486 | 2503 | set_key = set_key_encrypted; |
| 2504 | + } else if (IS_ENABLED(CONFIG_TRUSTED_KEYS) && |
| 2505 | + !strncmp(key_string, "trusted:", key_desc - key_string + 1)) { |
| 2506 | + type = &key_type_trusted; |
| 2507 | + set_key = set_key_trusted; |
2487 | 2508 | } else { |
2488 | 2509 | return -EINVAL; |
2489 | 2510 | } |
@@ -3555,7 +3576,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits) |
3555 | 3576 |
|
3556 | 3577 | static struct target_type crypt_target = { |
3557 | 3578 | .name = "crypt", |
3558 | | - .version = {1, 22, 0}, |
| 3579 | + .version = {1, 23, 0}, |
3559 | 3580 | .module = THIS_MODULE, |
3560 | 3581 | .ctr = crypt_ctr, |
3561 | 3582 | .dtr = crypt_dtr, |
|
0 commit comments