]>
Commit | Line | Data |
---|---|---|
b4d0d230 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
a9681bf3 DH |
2 | /* Asymmetric public-key algorithm definitions |
3 | * | |
0efaaa86 | 4 | * See Documentation/crypto/asymmetric-keys.rst |
a9681bf3 DH |
5 | * |
6 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. | |
7 | * Written by David Howells (dhowells@redhat.com) | |
a9681bf3 DH |
8 | */ |
9 | ||
10 | #ifndef _LINUX_PUBLIC_KEY_H | |
11 | #define _LINUX_PUBLIC_KEY_H | |
12 | ||
5a307718 | 13 | #include <linux/keyctl.h> |
f1774cb8 | 14 | #include <linux/oid_registry.h> |
21552563 | 15 | #include <crypto/akcipher.h> |
5a307718 | 16 | |
a9681bf3 DH |
17 | /* |
18 | * Cryptographic data for the public-key subtype of the asymmetric key type. | |
19 | * | |
20 | * Note that this may include private part of the key as well as the public | |
21 | * part. | |
22 | */ | |
23 | struct public_key { | |
db6c43bd TS |
24 | void *key; |
25 | u32 keylen; | |
f1774cb8 VC |
26 | enum OID algo; |
27 | void *params; | |
28 | u32 paramlen; | |
f7c4e06e | 29 | bool key_is_private; |
4e8ae72a DH |
30 | const char *id_type; |
31 | const char *pkey_algo; | |
a9681bf3 DH |
32 | }; |
33 | ||
3b764563 | 34 | extern void public_key_free(struct public_key *key); |
a9681bf3 DH |
35 | |
36 | /* | |
37 | * Public key cryptography signature data | |
38 | */ | |
39 | struct public_key_signature { | |
a022ec02 | 40 | struct asymmetric_key_id *auth_ids[2]; |
db6c43bd TS |
41 | u8 *s; /* Signature */ |
42 | u32 s_size; /* Number of bytes in signature */ | |
a9681bf3 | 43 | u8 *digest; |
d846e78e | 44 | u8 digest_size; /* Number of bytes in digest */ |
4e8ae72a DH |
45 | const char *pkey_algo; |
46 | const char *hash_algo; | |
5a307718 | 47 | const char *encoding; |
21552563 TZ |
48 | const void *data; |
49 | unsigned int data_size; | |
a9681bf3 DH |
50 | }; |
51 | ||
3b764563 DH |
52 | extern void public_key_signature_free(struct public_key_signature *sig); |
53 | ||
db6c43bd | 54 | extern struct asymmetric_key_subtype public_key_subtype; |
3b764563 | 55 | |
4ae71c1d | 56 | struct key; |
a511e1af DH |
57 | struct key_type; |
58 | union key_payload; | |
59 | ||
aaf66c88 | 60 | extern int restrict_link_by_signature(struct key *dest_keyring, |
a511e1af | 61 | const struct key_type *type, |
aaf66c88 MM |
62 | const union key_payload *payload, |
63 | struct key *trust_keyring); | |
a511e1af | 64 | |
7e3c4d22 MM |
65 | extern int restrict_link_by_key_or_keyring(struct key *dest_keyring, |
66 | const struct key_type *type, | |
67 | const union key_payload *payload, | |
68 | struct key *trusted); | |
69 | ||
8e323a02 MM |
70 | extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring, |
71 | const struct key_type *type, | |
72 | const union key_payload *payload, | |
73 | struct key *trusted); | |
74 | ||
5a307718 DH |
75 | extern int query_asymmetric_key(const struct kernel_pkey_params *, |
76 | struct kernel_pkey_query *); | |
77 | ||
78 | extern int encrypt_blob(struct kernel_pkey_params *, const void *, void *); | |
79 | extern int decrypt_blob(struct kernel_pkey_params *, const void *, void *); | |
80 | extern int create_signature(struct kernel_pkey_params *, const void *, void *); | |
81 | extern int verify_signature(const struct key *, | |
82 | const struct public_key_signature *); | |
4ae71c1d | 83 | |
db6c43bd TS |
84 | int public_key_verify_signature(const struct public_key *pkey, |
85 | const struct public_key_signature *sig); | |
86 | ||
a9681bf3 | 87 | #endif /* _LINUX_PUBLIC_KEY_H */ |