• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /*
3  * Greybus Component Authentication User Header
4  *
5  * Copyright(c) 2016 Google Inc. All rights reserved.
6  * Copyright(c) 2016 Linaro Ltd. All rights reserved.
7  */
8 
9 #ifndef __GREYBUS_AUTHENTICATION_USER_H
10 #define __GREYBUS_AUTHENTICATION_USER_H
11 
12 #include <linux/ioctl.h>
13 #include <linux/types.h>
14 
15 #define CAP_CERTIFICATE_MAX_SIZE	1600
16 #define CAP_SIGNATURE_MAX_SIZE		320
17 
18 /* Certificate class types */
19 #define CAP_CERT_IMS_EAPC		0x00000001
20 #define CAP_CERT_IMS_EASC		0x00000002
21 #define CAP_CERT_IMS_EARC		0x00000003
22 #define CAP_CERT_IMS_IAPC		0x00000004
23 #define CAP_CERT_IMS_IASC		0x00000005
24 #define CAP_CERT_IMS_IARC		0x00000006
25 
26 /* IMS Certificate response result codes */
27 #define CAP_IMS_RESULT_CERT_FOUND	0x00
28 #define CAP_IMS_RESULT_CERT_CLASS_INVAL	0x01
29 #define CAP_IMS_RESULT_CERT_CORRUPT	0x02
30 #define CAP_IMS_RESULT_CERT_NOT_FOUND	0x03
31 
32 /* Authentication types */
33 #define CAP_AUTH_IMS_PRI		0x00000001
34 #define CAP_AUTH_IMS_SEC		0x00000002
35 #define CAP_AUTH_IMS_RSA		0x00000003
36 
37 /* Authenticate response result codes */
38 #define CAP_AUTH_RESULT_CR_SUCCESS	0x00
39 #define CAP_AUTH_RESULT_CR_BAD_TYPE	0x01
40 #define CAP_AUTH_RESULT_CR_WRONG_EP	0x02
41 #define CAP_AUTH_RESULT_CR_NO_KEY	0x03
42 #define CAP_AUTH_RESULT_CR_SIG_FAIL	0x04
43 
44 
45 /* IOCTL support */
46 struct cap_ioc_get_endpoint_uid {
47 	__u8			uid[8];
48 } __attribute__ ((__packed__));
49 
50 struct cap_ioc_get_ims_certificate {
51 	__u32			certificate_class;
52 	__u32			certificate_id;
53 
54 	__u8			result_code;
55 	__u32			cert_size;
56 	__u8			certificate[CAP_CERTIFICATE_MAX_SIZE];
57 } __attribute__ ((__packed__));
58 
59 struct cap_ioc_authenticate {
60 	__u32			auth_type;
61 	__u8			uid[8];
62 	__u8			challenge[32];
63 
64 	__u8			result_code;
65 	__u8			response[64];
66 	__u32			signature_size;
67 	__u8			signature[CAP_SIGNATURE_MAX_SIZE];
68 } __attribute__ ((__packed__));
69 
70 #define CAP_IOCTL_BASE			'C'
71 #define CAP_IOC_GET_ENDPOINT_UID	_IOR(CAP_IOCTL_BASE, 0, struct cap_ioc_get_endpoint_uid)
72 #define CAP_IOC_GET_IMS_CERTIFICATE	_IOWR(CAP_IOCTL_BASE, 1, struct cap_ioc_get_ims_certificate)
73 #define CAP_IOC_AUTHENTICATE		_IOWR(CAP_IOCTL_BASE, 2, struct cap_ioc_authenticate)
74 
75 #endif /* __GREYBUS_AUTHENTICATION_USER_H */
76