105799ae0SJuan Castillo /* 205799ae0SJuan Castillo * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 305799ae0SJuan Castillo * 405799ae0SJuan Castillo * Redistribution and use in source and binary forms, with or without 505799ae0SJuan Castillo * modification, are permitted provided that the following conditions are met: 605799ae0SJuan Castillo * 705799ae0SJuan Castillo * Redistributions of source code must retain the above copyright notice, this 805799ae0SJuan Castillo * list of conditions and the following disclaimer. 905799ae0SJuan Castillo * 1005799ae0SJuan Castillo * Redistributions in binary form must reproduce the above copyright notice, 1105799ae0SJuan Castillo * this list of conditions and the following disclaimer in the documentation 1205799ae0SJuan Castillo * and/or other materials provided with the distribution. 1305799ae0SJuan Castillo * 1405799ae0SJuan Castillo * Neither the name of ARM nor the names of its contributors may be used 1505799ae0SJuan Castillo * to endorse or promote products derived from this software without specific 1605799ae0SJuan Castillo * prior written permission. 1705799ae0SJuan Castillo * 1805799ae0SJuan Castillo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1905799ae0SJuan Castillo * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2005799ae0SJuan Castillo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2105799ae0SJuan Castillo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2205799ae0SJuan Castillo * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2305799ae0SJuan Castillo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2405799ae0SJuan Castillo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2505799ae0SJuan Castillo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2605799ae0SJuan Castillo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2705799ae0SJuan Castillo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2805799ae0SJuan Castillo * POSSIBILITY OF SUCH DAMAGE. 2905799ae0SJuan Castillo */ 3005799ae0SJuan Castillo 3105799ae0SJuan Castillo #ifndef __AUTH_MOD_H__ 3205799ae0SJuan Castillo #define __AUTH_MOD_H__ 3305799ae0SJuan Castillo 3405799ae0SJuan Castillo #if TRUSTED_BOARD_BOOT 3505799ae0SJuan Castillo 3605799ae0SJuan Castillo #include <auth_common.h> 3705799ae0SJuan Castillo #include <cot_def.h> 3805799ae0SJuan Castillo #include <img_parser_mod.h> 3905799ae0SJuan Castillo 4005799ae0SJuan Castillo /* 4105799ae0SJuan Castillo * Image flags 4205799ae0SJuan Castillo */ 4305799ae0SJuan Castillo #define IMG_FLAG_AUTHENTICATED (1 << 0) 4405799ae0SJuan Castillo 4505799ae0SJuan Castillo 4605799ae0SJuan Castillo /* 4705799ae0SJuan Castillo * Authentication image descriptor 4805799ae0SJuan Castillo */ 4905799ae0SJuan Castillo typedef struct auth_img_desc_s { 5005799ae0SJuan Castillo unsigned int img_id; 5105799ae0SJuan Castillo const struct auth_img_desc_s *parent; 5205799ae0SJuan Castillo img_type_t img_type; 5305799ae0SJuan Castillo auth_method_desc_t img_auth_methods[AUTH_METHOD_NUM]; 5405799ae0SJuan Castillo auth_param_desc_t authenticated_data[COT_MAX_VERIFIED_PARAMS]; 5505799ae0SJuan Castillo } auth_img_desc_t; 5605799ae0SJuan Castillo 5705799ae0SJuan Castillo /* Public functions */ 5805799ae0SJuan Castillo void auth_mod_init(void); 5905799ae0SJuan Castillo int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id); 6005799ae0SJuan Castillo int auth_mod_verify_img(unsigned int img_id, 6105799ae0SJuan Castillo void *img_ptr, 6205799ae0SJuan Castillo unsigned int img_len); 6305799ae0SJuan Castillo 6405799ae0SJuan Castillo /* Macro to register a CoT defined as an array of auth_img_desc_t */ 6505799ae0SJuan Castillo #define REGISTER_COT(_cot) \ 6605799ae0SJuan Castillo const auth_img_desc_t *const cot_desc_ptr = \ 6705799ae0SJuan Castillo (const auth_img_desc_t *const)&_cot[0]; \ 68*aa856917SSandrine Bailleux unsigned int auth_img_flags[sizeof(_cot)/sizeof(_cot[0])] 6905799ae0SJuan Castillo 7005799ae0SJuan Castillo #endif /* TRUSTED_BOARD_BOOT */ 7105799ae0SJuan Castillo 7205799ae0SJuan Castillo #endif /* __AUTH_MOD_H__ */ 73