Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
0002 /*
0003  * Greybus Component Authentication User Header
0004  *
0005  * Copyright(c) 2016 Google Inc. All rights reserved.
0006  * Copyright(c) 2016 Linaro Ltd. All rights reserved.
0007  */
0008 
0009 #ifndef __GREYBUS_AUTHENTICATION_USER_H
0010 #define __GREYBUS_AUTHENTICATION_USER_H
0011 
0012 #include <linux/ioctl.h>
0013 #include <linux/types.h>
0014 
0015 #define CAP_CERTIFICATE_MAX_SIZE    1600
0016 #define CAP_SIGNATURE_MAX_SIZE      320
0017 
0018 /* Certificate class types */
0019 #define CAP_CERT_IMS_EAPC       0x00000001
0020 #define CAP_CERT_IMS_EASC       0x00000002
0021 #define CAP_CERT_IMS_EARC       0x00000003
0022 #define CAP_CERT_IMS_IAPC       0x00000004
0023 #define CAP_CERT_IMS_IASC       0x00000005
0024 #define CAP_CERT_IMS_IARC       0x00000006
0025 
0026 /* IMS Certificate response result codes */
0027 #define CAP_IMS_RESULT_CERT_FOUND   0x00
0028 #define CAP_IMS_RESULT_CERT_CLASS_INVAL 0x01
0029 #define CAP_IMS_RESULT_CERT_CORRUPT 0x02
0030 #define CAP_IMS_RESULT_CERT_NOT_FOUND   0x03
0031 
0032 /* Authentication types */
0033 #define CAP_AUTH_IMS_PRI        0x00000001
0034 #define CAP_AUTH_IMS_SEC        0x00000002
0035 #define CAP_AUTH_IMS_RSA        0x00000003
0036 
0037 /* Authenticate response result codes */
0038 #define CAP_AUTH_RESULT_CR_SUCCESS  0x00
0039 #define CAP_AUTH_RESULT_CR_BAD_TYPE 0x01
0040 #define CAP_AUTH_RESULT_CR_WRONG_EP 0x02
0041 #define CAP_AUTH_RESULT_CR_NO_KEY   0x03
0042 #define CAP_AUTH_RESULT_CR_SIG_FAIL 0x04
0043 
0044 
0045 /* IOCTL support */
0046 struct cap_ioc_get_endpoint_uid {
0047     __u8            uid[8];
0048 } __attribute__ ((__packed__));
0049 
0050 struct cap_ioc_get_ims_certificate {
0051     __u32           certificate_class;
0052     __u32           certificate_id;
0053 
0054     __u8            result_code;
0055     __u32           cert_size;
0056     __u8            certificate[CAP_CERTIFICATE_MAX_SIZE];
0057 } __attribute__ ((__packed__));
0058 
0059 struct cap_ioc_authenticate {
0060     __u32           auth_type;
0061     __u8            uid[8];
0062     __u8            challenge[32];
0063 
0064     __u8            result_code;
0065     __u8            response[64];
0066     __u32           signature_size;
0067     __u8            signature[CAP_SIGNATURE_MAX_SIZE];
0068 } __attribute__ ((__packed__));
0069 
0070 #define CAP_IOCTL_BASE          'C'
0071 #define CAP_IOC_GET_ENDPOINT_UID    _IOR(CAP_IOCTL_BASE, 0, struct cap_ioc_get_endpoint_uid)
0072 #define CAP_IOC_GET_IMS_CERTIFICATE _IOWR(CAP_IOCTL_BASE, 1, struct cap_ioc_get_ims_certificate)
0073 #define CAP_IOC_AUTHENTICATE        _IOWR(CAP_IOCTL_BASE, 2, struct cap_ioc_authenticate)
0074 
0075 #endif /* __GREYBUS_AUTHENTICATION_USER_H */