Commit | Line | Data |
---|---|---|
964f3b3b DH |
1 | /* Asymmetric public-key cryptography key subtype |
2 | * | |
5fb94e9c | 3 | * See Documentation/crypto/asymmetric-keys.txt |
964f3b3b DH |
4 | * |
5 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. | |
6 | * Written by David Howells (dhowells@redhat.com) | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public Licence | |
10 | * as published by the Free Software Foundation; either version | |
11 | * 2 of the Licence, or (at your option) any later version. | |
12 | */ | |
13 | ||
14 | #ifndef _KEYS_ASYMMETRIC_SUBTYPE_H | |
15 | #define _KEYS_ASYMMETRIC_SUBTYPE_H | |
16 | ||
17 | #include <linux/seq_file.h> | |
18 | #include <keys/asymmetric-type.h> | |
19 | ||
5a307718 DH |
20 | struct kernel_pkey_query; |
21 | struct kernel_pkey_params; | |
964f3b3b DH |
22 | struct public_key_signature; |
23 | ||
24 | /* | |
25 | * Keys of this type declare a subtype that indicates the handlers and | |
26 | * capabilities. | |
27 | */ | |
28 | struct asymmetric_key_subtype { | |
29 | struct module *owner; | |
30 | const char *name; | |
31 | unsigned short name_len; /* length of name */ | |
32 | ||
33 | /* Describe a key of this subtype for /proc/keys */ | |
34 | void (*describe)(const struct key *key, struct seq_file *m); | |
35 | ||
36 | /* Destroy a key of this subtype */ | |
3b764563 | 37 | void (*destroy)(void *payload_crypto, void *payload_auth); |
964f3b3b | 38 | |
5a307718 DH |
39 | int (*query)(const struct kernel_pkey_params *params, |
40 | struct kernel_pkey_query *info); | |
41 | ||
42 | /* Encrypt/decrypt/sign data */ | |
43 | int (*eds_op)(struct kernel_pkey_params *params, | |
44 | const void *in, void *out); | |
45 | ||
964f3b3b DH |
46 | /* Verify the signature on a key of this subtype (optional) */ |
47 | int (*verify_signature)(const struct key *key, | |
48 | const struct public_key_signature *sig); | |
49 | }; | |
50 | ||
51 | /** | |
52 | * asymmetric_key_subtype - Get the subtype from an asymmetric key | |
53 | * @key: The key of interest. | |
54 | * | |
55 | * Retrieves and returns the subtype pointer of the asymmetric key from the | |
56 | * type-specific data attached to the key. | |
57 | */ | |
58 | static inline | |
59 | struct asymmetric_key_subtype *asymmetric_key_subtype(const struct key *key) | |
60 | { | |
146aa8b1 | 61 | return key->payload.data[asym_subtype]; |
964f3b3b DH |
62 | } |
63 | ||
64 | #endif /* _KEYS_ASYMMETRIC_SUBTYPE_H */ |