Blame view

include/crypto/public_key.h 2.34 KB
b4d0d230c   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
a9681bf3d   David Howells   KEYS: Asymmetric ...
2
3
4
5
6
7
  /* Asymmetric public-key algorithm definitions
   *
   * See Documentation/crypto/asymmetric-keys.txt
   *
   * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
   * Written by David Howells (dhowells@redhat.com)
a9681bf3d   David Howells   KEYS: Asymmetric ...
8
9
10
11
   */
  
  #ifndef _LINUX_PUBLIC_KEY_H
  #define _LINUX_PUBLIC_KEY_H
5a3077183   David Howells   KEYS: Provide mis...
12
  #include <linux/keyctl.h>
f1774cb89   Vitaly Chikunov   X.509: parse publ...
13
  #include <linux/oid_registry.h>
5a3077183   David Howells   KEYS: Provide mis...
14

a9681bf3d   David Howells   KEYS: Asymmetric ...
15
16
17
18
19
20
21
  /*
   * Cryptographic data for the public-key subtype of the asymmetric key type.
   *
   * Note that this may include private part of the key as well as the public
   * part.
   */
  struct public_key {
db6c43bd2   Tadeusz Struk   crypto: KEYS: con...
22
23
  	void *key;
  	u32 keylen;
f1774cb89   Vitaly Chikunov   X.509: parse publ...
24
25
26
  	enum OID algo;
  	void *params;
  	u32 paramlen;
f7c4e06e0   David Howells   KEYS: Allow the p...
27
  	bool key_is_private;
4e8ae72a7   David Howells   X.509: Make algo ...
28
29
  	const char *id_type;
  	const char *pkey_algo;
a9681bf3d   David Howells   KEYS: Asymmetric ...
30
  };
3b7645631   David Howells   KEYS: Allow authe...
31
  extern void public_key_free(struct public_key *key);
a9681bf3d   David Howells   KEYS: Asymmetric ...
32
33
34
35
36
  
  /*
   * Public key cryptography signature data
   */
  struct public_key_signature {
a022ec026   David Howells   KEYS: Add identif...
37
  	struct asymmetric_key_id *auth_ids[2];
db6c43bd2   Tadeusz Struk   crypto: KEYS: con...
38
39
  	u8 *s;			/* Signature */
  	u32 s_size;		/* Number of bytes in signature */
a9681bf3d   David Howells   KEYS: Asymmetric ...
40
  	u8 *digest;
d846e78e4   Tadeusz Struk   crypto: public_ke...
41
  	u8 digest_size;		/* Number of bytes in digest */
4e8ae72a7   David Howells   X.509: Make algo ...
42
43
  	const char *pkey_algo;
  	const char *hash_algo;
5a3077183   David Howells   KEYS: Provide mis...
44
  	const char *encoding;
a9681bf3d   David Howells   KEYS: Asymmetric ...
45
  };
3b7645631   David Howells   KEYS: Allow authe...
46
  extern void public_key_signature_free(struct public_key_signature *sig);
db6c43bd2   Tadeusz Struk   crypto: KEYS: con...
47
  extern struct asymmetric_key_subtype public_key_subtype;
3b7645631   David Howells   KEYS: Allow authe...
48

4ae71c1dc   David Howells   KEYS: Provide sig...
49
  struct key;
a511e1af8   David Howells   KEYS: Move the po...
50
51
  struct key_type;
  union key_payload;
aaf66c883   Mat Martineau   KEYS: Split role ...
52
  extern int restrict_link_by_signature(struct key *dest_keyring,
a511e1af8   David Howells   KEYS: Move the po...
53
  				      const struct key_type *type,
aaf66c883   Mat Martineau   KEYS: Split role ...
54
55
  				      const union key_payload *payload,
  				      struct key *trust_keyring);
a511e1af8   David Howells   KEYS: Move the po...
56

7e3c4d220   Mat Martineau   KEYS: Restrict as...
57
58
59
60
  extern int restrict_link_by_key_or_keyring(struct key *dest_keyring,
  					   const struct key_type *type,
  					   const union key_payload *payload,
  					   struct key *trusted);
8e323a02e   Mat Martineau   KEYS: Keyring asy...
61
62
63
64
  extern int restrict_link_by_key_or_keyring_chain(struct key *trust_keyring,
  						 const struct key_type *type,
  						 const union key_payload *payload,
  						 struct key *trusted);
5a3077183   David Howells   KEYS: Provide mis...
65
66
67
68
69
70
71
72
  extern int query_asymmetric_key(const struct kernel_pkey_params *,
  				struct kernel_pkey_query *);
  
  extern int encrypt_blob(struct kernel_pkey_params *, const void *, void *);
  extern int decrypt_blob(struct kernel_pkey_params *, const void *, void *);
  extern int create_signature(struct kernel_pkey_params *, const void *, void *);
  extern int verify_signature(const struct key *,
  			    const struct public_key_signature *);
4ae71c1dc   David Howells   KEYS: Provide sig...
73

db6c43bd2   Tadeusz Struk   crypto: KEYS: con...
74
75
  int public_key_verify_signature(const struct public_key *pkey,
  				const struct public_key_signature *sig);
a9681bf3d   David Howells   KEYS: Asymmetric ...
76
  #endif /* _LINUX_PUBLIC_KEY_H */