Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers update-client-manifest-types.h Source File

update-client-manifest-types.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #ifndef UPDATE_CLIENT_MANIFEST_MANAGER_TYPES_H
00020 #define UPDATE_CLIENT_MANIFEST_MANAGER_TYPES_H
00021 
00022 #include "update-client-common/arm_uc_error.h"
00023 #include "update-client-common/arm_uc_common.h"
00024 
00025 #include <limits.h>
00026 #include <stdint.h>
00027 
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 
00034 #define RFC_4122_BYTES (128/CHAR_BIT)
00035 #define RFC_4122_WORDS (RFC_4122_BYTES/sizeof(uint32_t))
00036 #define ARM_UC_MANIFEST_HANDLE_BUFFER_BYTES (256/CHAR_BIT)
00037 
00038 // NOTE: Manifest Handles are not used yet
00039 typedef uint8_t arm_uc_manifest_handle_t[ARM_UC_MANIFEST_HANDLE_BUFFER_BYTES];
00040 
00041 
00042 /**
00043  * @brief RFC 4122 GUID container
00044  * GUIDs are a fixed size, so this container provides a consistent storage for them. Accessors are provided for both
00045  * byte-wise and word-wise access.
00046  */
00047 typedef struct manifest_guid_t {
00048     union {
00049         uint8_t  bytes[RFC_4122_BYTES];
00050         uint32_t words[RFC_4122_WORDS];
00051     };
00052 } manifest_guid_t;
00053 
00054 /**
00055  * @brief Allowed cryptographic modes
00056  * This list must be kept in sync with the manifest generator.
00057  * Only a minimum set of cryptographic modes should be permitted
00058  */
00059 enum manifest_crypto_mode {
00060     MFST_CRYPT_UNINIT = 0,             //!< Uninitialized mode. This mode will always fail
00061     MFST_CRYPT_SHA256_ECC_AES128_PSK,  /*!< Manifest is signed with ECDSA. Firmware is encrypted with AES128-CTR, using a
00062                                         *   pre-shared key. Firmware plaintext is hashed with SHA256. */
00063     MFST_CRYPT_SHA256_ECC,             //!< Manifest is signed with ECDSA. Firmware is hashed with SHA256
00064     MFST_CRYPT_SHA256,                 //!< Manifest and firmware are hashed with SHA256. Not recommended for production
00065     // MFST_CRYPT_SHA256_HMAC,            //!< Manifest is signed with HMAC. Firmware is hashed with SHA256
00066     // MFST_CRYPT_SHA256_HMAC_AES128_PSK, /*!< Manifest is signed with HMAC. Firmware is encrypted with AES128-CTR, using a
00067     //                                     *   pre-shared key. Firmware plaintext is hashed with SHA256. */
00068     MFST_CRYPT_MAX,
00069 };
00070 
00071 /**
00072  * @brief Helper structure
00073  * This structure converts the cryptomode to testable flags
00074  */
00075 typedef struct arm_uc_mm_crypto_flags_t {
00076     unsigned hash:2;
00077     unsigned hmac:1;
00078     unsigned rsa:2;
00079     unsigned ecc:2;
00080     unsigned aes:2;
00081     unsigned psk:1;
00082 } arm_uc_mm_crypto_flags_t;
00083 
00084 enum arm_uc_mmCipherMode_t {
00085     ARM_UC_MM_CIPHERMODE_NONE,
00086     ARM_UC_MM_CIPHERMODE_PSK,
00087     ARM_UC_MM_CIPHERMODE_CERT_CIPHERKEY,
00088     ARM_UC_MM_CIPHERMODE_CERT_KEYTABLE,
00089 };
00090 
00091 /**
00092  * @brief   Firmware Information
00093  * @details Contains the details about the firmware image referenced by the manifest
00094  */
00095 struct manifest_firmware_info_t {
00096     uint64_t        timestamp;  ///< Root Manifest timestamp.
00097     manifest_guid_t format;     /**< The format used for the firmware. This is either an enum when the first 96 bits
00098                                  *   are 0. Otherwise, this is a RFC4122 GUID. */
00099 
00100     uint32_t            cryptoMode;
00101     uint32_t            size;       ///< The size of the firmware in bytes
00102     arm_uc_buffer_t     hash;       ///< The hash of the firmware image
00103     arm_uc_buffer_t     uri;        ///< The location of the firmware
00104     arm_uc_buffer_t     strgId;     ///< The location of the firmware
00105 
00106     uint32_t            cipherMode;
00107     arm_uc_buffer_t     initVector; ///< AES initialization vector. 0 is not permitted.
00108     union {
00109         struct {
00110             arm_uc_buffer_t keyID;      ///< Identifier for a locally stored AES key
00111             arm_uc_buffer_t cipherKey;        ///< An encrypted AES key
00112         } psk;
00113         struct {
00114             arm_uc_buffer_t certFingerPrint;
00115             arm_uc_buffer_t certURL;
00116             arm_uc_buffer_t cipherKey;
00117         } certCK;
00118         struct {
00119             arm_uc_buffer_t certFingerPrint;
00120             arm_uc_buffer_t certURL;
00121             arm_uc_buffer_t keyTableURL;
00122         } certKT;
00123     };
00124     uint32_t manifestSize;
00125     uint8_t  manifestBuffer[640];
00126 };
00127 typedef struct manifest_firmware_info_t manifest_firmware_info_t;
00128 
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 #endif // UPDATE_CLIENT_MANIFEST_MANAGER_TYPES_H