Home | History | Annotate | Download | only in libkeymaster
      1 /**
      2  * @file   tci.h
      3  * @brief  Contains TCI (Trustlet Control
      4  * Interface) definitions and data structures
      5  *
      6  * Copyright Giesecke & Devrient GmbH 2012
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. The name of the author may not be used to endorse or promote
     17  *    products derived from this software without specific prior
     18  *    written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     21  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     24  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     26  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifndef __TCI_H__
     34 #define __TCI_H__
     35 
     36 
     37 typedef uint32_t tciCommandId_t;
     38 typedef uint32_t tciResponseId_t;
     39 typedef uint32_t tciReturnCode_t;
     40 
     41 
     42 /**< Responses have bit 31 set */
     43 #define RSP_ID_MASK (1U << 31)
     44 #define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
     45 #define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0)
     46 #define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK)
     47 
     48 
     49 /**
     50  * Return codes
     51  */
     52 #define RET_OK                    0
     53 #define RET_ERR_UNKNOWN_CMD       1
     54 #define RET_ERR_NOT_SUPPORTED     2
     55 #define RET_ERR_INVALID_BUFFER    3
     56 #define RET_ERR_INVALID_KEY_SIZE  4
     57 #define RET_ERR_INVALID_KEY_TYPE  5
     58 #define RET_ERR_INVALID_LENGTH    6
     59 #define RET_ERR_INVALID_EXPONENT  7
     60 #define RET_ERR_KEY_GENERATION    8
     61 #define RET_ERR_SIGN              9
     62 #define RET_ERR_VERIFY            10
     63 #define RET_ERR_DIGEST            11
     64 #define RET_ERR_SECURE_OBJECT     12
     65 #define RET_ERR_INTERNAL_ERROR    13
     66 /* ... add more error codes when needed */
     67 
     68 
     69 /**
     70  * TCI command header.
     71  */
     72 typedef struct{
     73     tciCommandId_t commandId; /**< Command ID */
     74 } tciCommandHeader_t;
     75 
     76 
     77 /**
     78  * TCI response header.
     79  */
     80 typedef struct{
     81     tciResponseId_t     responseId; /**< Response ID (must be command ID | RSP_ID_MASK )*/
     82     tciReturnCode_t     returnCode; /**< Return code of command */
     83 } tciResponseHeader_t;
     84 
     85 #endif // __TCI_H__
     86