blob: e1b8c0db2979a749c6fa5007eede7e71333ecd29 [file] [log] [blame]
David Brown902d6172017-05-05 09:37:41 -06001/*
2 * Copyright (c) 2017 Linaro Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <bootutil/caps.h>
Marti Bolivarf91bca52018-04-12 12:40:46 -040018#include "mcuboot_config/mcuboot_config.h"
David Brown902d6172017-05-05 09:37:41 -060019
20uint32_t bootutil_get_caps(void)
21{
David Brown74b161e2019-04-16 15:41:07 -060022 uint32_t res = 0;
David Brown902d6172017-05-05 09:37:41 -060023
Fabio Utzig3488eef2017-06-12 10:25:43 -030024#if defined(MCUBOOT_SIGN_RSA)
Fabio Utzig39297432019-05-08 18:51:10 -030025#if MCUBOOT_SIGN_RSA_LEN == 2048
David Brown74b161e2019-04-16 15:41:07 -060026 res |= BOOTUTIL_CAP_RSA2048;
David Brown902d6172017-05-05 09:37:41 -060027#endif
Fabio Utzig39297432019-05-08 18:51:10 -030028#if MCUBOOT_SIGN_RSA_LEN == 3072
29 res |= BOOTUTIL_CAP_RSA3072;
30#endif
31#endif
Fabio Utzig3488eef2017-06-12 10:25:43 -030032#if defined(MCUBOOT_SIGN_EC)
David Brown74b161e2019-04-16 15:41:07 -060033 res |= BOOTUTIL_CAP_ECDSA_P224;
David Brown902d6172017-05-05 09:37:41 -060034#endif
Fabio Utzig3488eef2017-06-12 10:25:43 -030035#if defined(MCUBOOT_SIGN_EC256)
David Brown74b161e2019-04-16 15:41:07 -060036 res |= BOOTUTIL_CAP_ECDSA_P256;
David Brown902d6172017-05-05 09:37:41 -060037#endif
Fabio Utzig97710282019-05-24 17:44:49 -030038#if defined(MCUBOOT_SIGN_ED25519)
39 res |= BOOTUTIL_CAP_ED25519;
40#endif
Fabio Utzig3488eef2017-06-12 10:25:43 -030041#if defined(MCUBOOT_OVERWRITE_ONLY)
David Brown74b161e2019-04-16 15:41:07 -060042 res |= BOOTUTIL_CAP_OVERWRITE_UPGRADE;
David Brown902d6172017-05-05 09:37:41 -060043#else
David Brown74b161e2019-04-16 15:41:07 -060044 res |= BOOTUTIL_CAP_SWAP_UPGRADE;
David Brown902d6172017-05-05 09:37:41 -060045#endif
David Brownc4a60a32019-01-11 12:27:51 -070046#if defined(MCUBOOT_ENCRYPT_RSA)
David Brown74b161e2019-04-16 15:41:07 -060047 res |= BOOTUTIL_CAP_ENC_RSA;
David Brownc4a60a32019-01-11 12:27:51 -070048#endif
49#if defined(MCUBOOT_ENCRYPT_KW)
David Brown74b161e2019-04-16 15:41:07 -060050 res |= BOOTUTIL_CAP_ENC_KW;
David Brownc4a60a32019-01-11 12:27:51 -070051#endif
Fabio Utzig5ef883a2019-10-22 10:10:01 -030052#if defined(MCUBOOT_ENCRYPT_EC256)
53 res |= BOOTUTIL_CAP_ENC_EC256;
54#endif
David Vincze2d736ad2019-02-18 11:50:22 +010055#if defined(MCUBOOT_VALIDATE_PRIMARY_SLOT)
David Brown74b161e2019-04-16 15:41:07 -060056 res |= BOOTUTIL_CAP_VALIDATE_PRIMARY_SLOT;
David Brown8d0afa72019-01-11 12:31:55 -070057#endif
David Brown902d6172017-05-05 09:37:41 -060058
David Brown74b161e2019-04-16 15:41:07 -060059 return res;
David Brown902d6172017-05-05 09:37:41 -060060}
David Brown4c9883b2019-03-05 12:13:33 -070061
62uint32_t bootutil_get_num_images(void)
63{
64#if defined(MCUBOOT_IMAGE_NUMBER)
65 return MCUBOOT_IMAGE_NUMBER;
66#else
67 return 1;
68#endif
69}