2 * Greybus Component Authentication User Header
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * Copyright(c) 2016 Google Inc. All rights reserved.
10 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License version 2 for more details.
23 * Copyright(c) 2016 Google Inc. All rights reserved.
24 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
30 * * Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * * Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in
34 * the documentation and/or other materials provided with the
36 * * Neither the name of Google Inc. or Linaro Ltd. nor the names of
37 * its contributors may be used to endorse or promote products
38 * derived from this software without specific prior written
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
42 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
43 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
44 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
45 * LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
46 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
47 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
48 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
49 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
51 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 #ifndef __GREYBUS_AUTHENTICATION_USER_H
55 #define __GREYBUS_AUTHENTICATION_USER_H
57 #include <linux/ioctl.h>
58 #include <linux/types.h>
60 #define CAP_CERTIFICATE_MAX_SIZE 1600
61 #define CAP_SIGNATURE_MAX_SIZE 320
63 /* Certificate class types */
64 #define CAP_CERT_IMS_EAPC 0x00000001
65 #define CAP_CERT_IMS_EASC 0x00000002
66 #define CAP_CERT_IMS_EARC 0x00000003
67 #define CAP_CERT_IMS_IAPC 0x00000004
68 #define CAP_CERT_IMS_IASC 0x00000005
69 #define CAP_CERT_IMS_IARC 0x00000006
71 /* IMS Certificate response result codes */
72 #define CAP_IMS_RESULT_CERT_FOUND 0x00
73 #define CAP_IMS_RESULT_CERT_CLASS_INVAL 0x01
74 #define CAP_IMS_RESULT_CERT_CORRUPT 0x02
75 #define CAP_IMS_RESULT_CERT_NOT_FOUND 0x03
77 /* Authentication types */
78 #define CAP_AUTH_IMS_PRI 0x00000001
79 #define CAP_AUTH_IMS_SEC 0x00000002
80 #define CAP_AUTH_IMS_RSA 0x00000003
82 /* Authenticate response result codes */
83 #define CAP_AUTH_RESULT_CR_SUCCESS 0x00
84 #define CAP_AUTH_RESULT_CR_BAD_TYPE 0x01
85 #define CAP_AUTH_RESULT_CR_WRONG_EP 0x02
86 #define CAP_AUTH_RESULT_CR_NO_KEY 0x03
87 #define CAP_AUTH_RESULT_CR_SIG_FAIL 0x04
91 struct cap_ioc_get_endpoint_uid {
93 } __attribute__ ((__packed__));
95 struct cap_ioc_get_ims_certificate {
96 __u32 certificate_class;
101 __u8 certificate[CAP_CERTIFICATE_MAX_SIZE];
102 } __attribute__ ((__packed__));
104 struct cap_ioc_authenticate {
111 __u32 signature_size;
112 __u8 signature[CAP_SIGNATURE_MAX_SIZE];
113 } __attribute__ ((__packed__));
115 #define CAP_IOCTL_BASE 'C'
116 #define CAP_IOC_GET_ENDPOINT_UID _IOR(CAP_IOCTL_BASE, 0, struct cap_ioc_get_endpoint_uid)
117 #define CAP_IOC_GET_IMS_CERTIFICATE _IOWR(CAP_IOCTL_BASE, 1, struct cap_ioc_get_ims_certificate)
118 #define CAP_IOC_AUTHENTICATE _IOWR(CAP_IOCTL_BASE, 2, struct cap_ioc_authenticate)
120 #endif /* __GREYBUS_AUTHENTICATION_USER_H */