aboutsummaryrefslogtreecommitdiffstats
path: root/include/keys
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-09-13 10:17:21 -0400
committerRusty Russell <rusty@rustcorp.com.au>2012-10-07 23:20:12 -0400
commit964f3b3bf49eb84b5831121446a28b76de3fb23a (patch)
tree7d299f690c8323c931b59bc142c45ac75097963f /include/keys
parent9a83b46578df149160b1da057656d2f0cfcbb5b6 (diff)
KEYS: Implement asymmetric key type
Create a key type that can be used to represent an asymmetric key type for use in appropriate cryptographic operations, such as encryption, decryption, signature generation and signature verification. The key type is "asymmetric" and can provide access to a variety of cryptographic algorithms. Possibly, this would be better as "public_key" - but that has the disadvantage that "public key" is an overloaded term. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/keys')
-rw-r--r--include/keys/asymmetric-subtype.h55
-rw-r--r--include/keys/asymmetric-type.h25
2 files changed, 80 insertions, 0 deletions
diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
new file mode 100644
index 000000000000..4b840e822209
--- /dev/null
+++ b/include/keys/asymmetric-subtype.h
@@ -0,0 +1,55 @@
1/* Asymmetric public-key cryptography key subtype
2 *
3 * See Documentation/security/asymmetric-keys.txt
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
20struct public_key_signature;
21
22/*
23 * Keys of this type declare a subtype that indicates the handlers and
24 * capabilities.
25 */
26struct asymmetric_key_subtype {
27 struct module *owner;
28 const char *name;
29 unsigned short name_len; /* length of name */
30
31 /* Describe a key of this subtype for /proc/keys */
32 void (*describe)(const struct key *key, struct seq_file *m);
33
34 /* Destroy a key of this subtype */
35 void (*destroy)(void *payload);
36
37 /* Verify the signature on a key of this subtype (optional) */
38 int (*verify_signature)(const struct key *key,
39 const struct public_key_signature *sig);
40};
41
42/**
43 * asymmetric_key_subtype - Get the subtype from an asymmetric key
44 * @key: The key of interest.
45 *
46 * Retrieves and returns the subtype pointer of the asymmetric key from the
47 * type-specific data attached to the key.
48 */
49static inline
50struct asymmetric_key_subtype *asymmetric_key_subtype(const struct key *key)
51{
52 return key->type_data.p[0];
53}
54
55#endif /* _KEYS_ASYMMETRIC_SUBTYPE_H */
diff --git a/include/keys/asymmetric-type.h b/include/keys/asymmetric-type.h
new file mode 100644
index 000000000000..7dd473496180
--- /dev/null
+++ b/include/keys/asymmetric-type.h
@@ -0,0 +1,25 @@
1/* Asymmetric Public-key cryptography key type interface
2 *
3 * See Documentation/security/asymmetric-keys.txt
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_TYPE_H
15#define _KEYS_ASYMMETRIC_TYPE_H
16
17#include <linux/key-type.h>
18
19extern struct key_type key_type_asymmetric;
20
21/*
22 * The payload is at the discretion of the subtype.
23 */
24
25#endif /* _KEYS_ASYMMETRIC_TYPE_H */