1*05799ae0SJuan Castillo /* 2*05799ae0SJuan Castillo * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3*05799ae0SJuan Castillo * 4*05799ae0SJuan Castillo * Redistribution and use in source and binary forms, with or without 5*05799ae0SJuan Castillo * modification, are permitted provided that the following conditions are met: 6*05799ae0SJuan Castillo * 7*05799ae0SJuan Castillo * Redistributions of source code must retain the above copyright notice, this 8*05799ae0SJuan Castillo * list of conditions and the following disclaimer. 9*05799ae0SJuan Castillo * 10*05799ae0SJuan Castillo * Redistributions in binary form must reproduce the above copyright notice, 11*05799ae0SJuan Castillo * this list of conditions and the following disclaimer in the documentation 12*05799ae0SJuan Castillo * and/or other materials provided with the distribution. 13*05799ae0SJuan Castillo * 14*05799ae0SJuan Castillo * Neither the name of ARM nor the names of its contributors may be used 15*05799ae0SJuan Castillo * to endorse or promote products derived from this software without specific 16*05799ae0SJuan Castillo * prior written permission. 17*05799ae0SJuan Castillo * 18*05799ae0SJuan Castillo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*05799ae0SJuan Castillo * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*05799ae0SJuan Castillo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*05799ae0SJuan Castillo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*05799ae0SJuan Castillo * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*05799ae0SJuan Castillo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*05799ae0SJuan Castillo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*05799ae0SJuan Castillo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*05799ae0SJuan Castillo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*05799ae0SJuan Castillo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*05799ae0SJuan Castillo * POSSIBILITY OF SUCH DAMAGE. 29*05799ae0SJuan Castillo */ 30*05799ae0SJuan Castillo 31*05799ae0SJuan Castillo #ifndef __AUTH_MOD_H__ 32*05799ae0SJuan Castillo #define __AUTH_MOD_H__ 33*05799ae0SJuan Castillo 34*05799ae0SJuan Castillo #if TRUSTED_BOARD_BOOT 35*05799ae0SJuan Castillo 36*05799ae0SJuan Castillo #include <auth_common.h> 37*05799ae0SJuan Castillo #include <cot_def.h> 38*05799ae0SJuan Castillo #include <img_parser_mod.h> 39*05799ae0SJuan Castillo 40*05799ae0SJuan Castillo /* 41*05799ae0SJuan Castillo * Image flags 42*05799ae0SJuan Castillo */ 43*05799ae0SJuan Castillo #define IMG_FLAG_AUTHENTICATED (1 << 0) 44*05799ae0SJuan Castillo 45*05799ae0SJuan Castillo 46*05799ae0SJuan Castillo /* 47*05799ae0SJuan Castillo * Authentication image descriptor 48*05799ae0SJuan Castillo */ 49*05799ae0SJuan Castillo typedef struct auth_img_desc_s { 50*05799ae0SJuan Castillo unsigned int img_id; 51*05799ae0SJuan Castillo const struct auth_img_desc_s *parent; 52*05799ae0SJuan Castillo img_type_t img_type; 53*05799ae0SJuan Castillo auth_method_desc_t img_auth_methods[AUTH_METHOD_NUM]; 54*05799ae0SJuan Castillo auth_param_desc_t authenticated_data[COT_MAX_VERIFIED_PARAMS]; 55*05799ae0SJuan Castillo } auth_img_desc_t; 56*05799ae0SJuan Castillo 57*05799ae0SJuan Castillo /* Public functions */ 58*05799ae0SJuan Castillo void auth_mod_init(void); 59*05799ae0SJuan Castillo int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id); 60*05799ae0SJuan Castillo int auth_mod_verify_img(unsigned int img_id, 61*05799ae0SJuan Castillo void *img_ptr, 62*05799ae0SJuan Castillo unsigned int img_len); 63*05799ae0SJuan Castillo 64*05799ae0SJuan Castillo /* Macro to register a CoT defined as an array of auth_img_desc_t */ 65*05799ae0SJuan Castillo #define REGISTER_COT(_cot) \ 66*05799ae0SJuan Castillo const auth_img_desc_t *const cot_desc_ptr = \ 67*05799ae0SJuan Castillo (const auth_img_desc_t *const)&_cot[0]; \ 68*05799ae0SJuan Castillo unsigned int auth_img_flags[sizeof(_cot)/sizeof(_cot[0])]; 69*05799ae0SJuan Castillo 70*05799ae0SJuan Castillo #endif /* TRUSTED_BOARD_BOOT */ 71*05799ae0SJuan Castillo 72*05799ae0SJuan Castillo #endif /* __AUTH_MOD_H__ */ 73