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 | /* IOCTL support */ |
45 | struct cap_ioc_get_endpoint_uid { |
46 | __u8 uid[8]; |
47 | } __packed; |
48 | |
49 | struct cap_ioc_get_ims_certificate { |
50 | __u32 certificate_class; |
51 | __u32 certificate_id; |
52 | |
53 | __u8 result_code; |
54 | __u32 cert_size; |
55 | __u8 certificate[CAP_CERTIFICATE_MAX_SIZE]; |
56 | } __packed; |
57 | |
58 | struct cap_ioc_authenticate { |
59 | __u32 auth_type; |
60 | __u8 uid[8]; |
61 | __u8 challenge[32]; |
62 | |
63 | __u8 result_code; |
64 | __u8 response[64]; |
65 | __u32 signature_size; |
66 | __u8 signature[CAP_SIGNATURE_MAX_SIZE]; |
67 | } __packed; |
68 | |
69 | #define CAP_IOCTL_BASE 'C' |
70 | #define CAP_IOC_GET_ENDPOINT_UID _IOR(CAP_IOCTL_BASE, 0, struct cap_ioc_get_endpoint_uid) |
71 | #define CAP_IOC_GET_IMS_CERTIFICATE _IOWR(CAP_IOCTL_BASE, 1, struct cap_ioc_get_ims_certificate) |
72 | #define CAP_IOC_AUTHENTICATE _IOWR(CAP_IOCTL_BASE, 2, struct cap_ioc_authenticate) |
73 | |
74 | #endif /* __GREYBUS_AUTHENTICATION_USER_H */ |
75 | |