linux/drivers/staging/greybus/greybus_authentication.h
<<
>>
Prefs
   1/*
   2 * Greybus Component Authentication User Header
   3 *
   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.
   6 *
   7 * GPL LICENSE SUMMARY
   8 *
   9 * Copyright(c) 2016 Google Inc. All rights reserved.
  10 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
  11 *
  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.
  15 *
  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.
  20 *
  21 * BSD LICENSE
  22 *
  23 * Copyright(c) 2016 Google Inc. All rights reserved.
  24 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
  25 *
  26 * Redistribution and use in source and binary forms, with or without
  27 * modification, are permitted provided that the following conditions
  28 * are met:
  29 *
  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
  35 *    distribution.
  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
  39 *    permission.
  40 *
  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.
  52 */
  53
  54#ifndef __GREYBUS_AUTHENTICATION_USER_H
  55#define __GREYBUS_AUTHENTICATION_USER_H
  56
  57#include <linux/ioctl.h>
  58#include <linux/types.h>
  59
  60#define CAP_CERTIFICATE_MAX_SIZE        1600
  61#define CAP_SIGNATURE_MAX_SIZE          320
  62
  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
  70
  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
  76
  77/* Authentication types */
  78#define CAP_AUTH_IMS_PRI                0x00000001
  79#define CAP_AUTH_IMS_SEC                0x00000002
  80#define CAP_AUTH_IMS_RSA                0x00000003
  81
  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
  88
  89
  90/* IOCTL support */
  91struct cap_ioc_get_endpoint_uid {
  92        __u8                    uid[8];
  93} __attribute__ ((__packed__));
  94
  95struct cap_ioc_get_ims_certificate {
  96        __u32                   certificate_class;
  97        __u32                   certificate_id;
  98
  99        __u8                    result_code;
 100        __u32                   cert_size;
 101        __u8                    certificate[CAP_CERTIFICATE_MAX_SIZE];
 102} __attribute__ ((__packed__));
 103
 104struct cap_ioc_authenticate {
 105        __u32                   auth_type;
 106        __u8                    uid[8];
 107        __u8                    challenge[32];
 108
 109        __u8                    result_code;
 110        __u8                    response[64];
 111        __u32                   signature_size;
 112        __u8                    signature[CAP_SIGNATURE_MAX_SIZE];
 113} __attribute__ ((__packed__));
 114
 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)
 119
 120#endif /* __GREYBUS_AUTHENTICATION_USER_H */
 121