1 /*
2  * SPDX-License-Identifier: Apache-2.0
3  *
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21 
22 #ifndef __BOOTUTIL_SIGN_KEY_H_
23 #define __BOOTUTIL_SIGN_KEY_H_
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 /* mcuboot_config.h is needed for MCUBOOT_HW_KEY to work */
29 #include "mcuboot_config/mcuboot_config.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #ifndef MCUBOOT_HW_KEY
36 struct bootutil_key {
37     const uint8_t *key;
38     const unsigned int *len;
39 };
40 
41 extern const struct bootutil_key bootutil_keys[];
42 #else
43 struct bootutil_key {
44     uint8_t *key;
45     unsigned int *len;
46 };
47 
48 extern struct bootutil_key bootutil_keys[];
49 
50 /**
51  * Retrieve the hash of the corresponding public key for image authentication.
52  *
53  * @param[in]      image_index      Index of the image to be authenticated.
54  * @param[out]     public_key_hash  Buffer to store the key-hash in.
55  * @param[in,out]  key_hash_size    As input the size of the buffer. As output
56  *                                  the actual key-hash length.
57  *
58  * @return                          0 on success; nonzero on failure.
59  */
60 int boot_retrieve_public_key_hash(uint8_t image_index,
61                                   uint8_t *public_key_hash,
62                                   size_t *key_hash_size);
63 #endif /* !MCUBOOT_HW_KEY */
64 
65 extern const int bootutil_key_cnt;
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* __BOOTUTIL_SIGN_KEY_H_ */
72