Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
David Vincze | e32483f | 2019-06-13 10:46:24 +0200 | [diff] [blame] | 20 | /* |
| 21 | * Modifications are Copyright (c) 2019 Arm Limited. |
| 22 | */ |
| 23 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 24 | #include <assert.h> |
| 25 | #include <stddef.h> |
| 26 | #include <inttypes.h> |
| 27 | #include <string.h> |
| 28 | |
Andrzej Puzdrowski | b788c71 | 2018-04-12 12:42:49 +0200 | [diff] [blame] | 29 | #include <flash_map_backend/flash_map_backend.h> |
| 30 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 31 | #include "bootutil/image.h" |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 32 | #include "bootutil/sha256.h" |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 33 | #include "bootutil/sign_key.h" |
| 34 | |
Fabio Utzig | ba1fbe6 | 2017-07-21 14:01:20 -0300 | [diff] [blame] | 35 | #include "mcuboot_config/mcuboot_config.h" |
Fabio Utzig | eed80b6 | 2017-06-10 08:03:05 -0300 | [diff] [blame] | 36 | |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 37 | #ifdef MCUBOOT_ENC_IMAGES |
| 38 | #include "bootutil/enc_key.h" |
| 39 | #endif |
| 40 | #if defined(MCUBOOT_SIGN_RSA) |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 41 | #include "mbedtls/rsa.h" |
David Brown | d7e350d | 2017-04-24 13:29:28 -0600 | [diff] [blame] | 42 | #endif |
Fabio Utzig | 19356bf | 2017-05-11 16:19:36 -0300 | [diff] [blame] | 43 | #if defined(MCUBOOT_SIGN_EC) || defined(MCUBOOT_SIGN_EC256) |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 44 | #include "mbedtls/ecdsa.h" |
David Brown | d7e350d | 2017-04-24 13:29:28 -0600 | [diff] [blame] | 45 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 46 | #include "mbedtls/asn1.h" |
| 47 | |
| 48 | #include "bootutil_priv.h" |
| 49 | |
| 50 | /* |
| 51 | * Compute SHA256 over the image. |
| 52 | */ |
| 53 | static int |
| 54 | bootutil_img_hash(struct image_header *hdr, const struct flash_area *fap, |
| 55 | uint8_t *tmp_buf, uint32_t tmp_buf_sz, |
| 56 | uint8_t *hash_result, uint8_t *seed, int seed_len) |
| 57 | { |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 58 | bootutil_sha256_context sha256_ctx; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 59 | uint32_t blk_sz; |
| 60 | uint32_t size; |
Fabio Utzig | 2fc80df | 2018-12-14 06:47:38 -0200 | [diff] [blame] | 61 | uint16_t hdr_size; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 62 | uint32_t off; |
| 63 | int rc; |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 64 | #ifdef MCUBOOT_ENC_IMAGES |
| 65 | uint32_t blk_off; |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 66 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 67 | |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 68 | bootutil_sha256_init(&sha256_ctx); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 69 | |
| 70 | /* in some cases (split image) the hash is seeded with data from |
| 71 | * the loader image */ |
Fabio Utzig | 5398604 | 2017-12-12 14:57:07 -0200 | [diff] [blame] | 72 | if (seed && (seed_len > 0)) { |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 73 | bootutil_sha256_update(&sha256_ctx, seed, seed_len); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 74 | } |
| 75 | |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 76 | #ifdef MCUBOOT_ENC_IMAGES |
David Vincze | 2d736ad | 2019-02-18 11:50:22 +0100 | [diff] [blame] | 77 | /* Encrypted images only exist in the secondary slot */ |
| 78 | if (fap->fa_id == FLASH_AREA_IMAGE_SECONDARY && |
| 79 | IS_ENCRYPTED(hdr) && |
| 80 | !boot_enc_valid(fap)) { |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 81 | return -1; |
| 82 | } |
| 83 | #endif |
| 84 | |
David Vincze | e32483f | 2019-06-13 10:46:24 +0200 | [diff] [blame] | 85 | /* Hash is computed over image header and image itself. */ |
Fabio Utzig | 2fc80df | 2018-12-14 06:47:38 -0200 | [diff] [blame] | 86 | hdr_size = hdr->ih_hdr_size; |
| 87 | size = hdr->ih_img_size + hdr_size; |
David Vincze | e32483f | 2019-06-13 10:46:24 +0200 | [diff] [blame] | 88 | |
| 89 | #if (MCUBOOT_IMAGE_NUMBER > 1) |
| 90 | /* If dependency TLVs are present then the TLV info header and the |
| 91 | * dependency TLVs are also protected and have to be included in the hash |
| 92 | * calculation. |
| 93 | */ |
| 94 | if (hdr->ih_protect_tlv_size != 0) { |
| 95 | size += hdr->ih_protect_tlv_size; |
| 96 | } |
| 97 | #endif |
| 98 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 99 | for (off = 0; off < size; off += blk_sz) { |
| 100 | blk_sz = size - off; |
| 101 | if (blk_sz > tmp_buf_sz) { |
| 102 | blk_sz = tmp_buf_sz; |
| 103 | } |
Fabio Utzig | 2fc80df | 2018-12-14 06:47:38 -0200 | [diff] [blame] | 104 | #ifdef MCUBOOT_ENC_IMAGES |
| 105 | /* Avoid reading header data together with other image data |
| 106 | * because the header is not encrypted, so maintain correct |
| 107 | * bounds when sending encrypted data to decrypt routine. |
| 108 | */ |
| 109 | if ((off < hdr_size) && ((off + blk_sz) > hdr_size)) { |
| 110 | blk_sz = hdr_size - off; |
| 111 | } |
| 112 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 113 | rc = flash_area_read(fap, off, tmp_buf, blk_sz); |
| 114 | if (rc) { |
| 115 | return rc; |
| 116 | } |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 117 | #ifdef MCUBOOT_ENC_IMAGES |
David Vincze | 2d736ad | 2019-02-18 11:50:22 +0100 | [diff] [blame] | 118 | if (fap->fa_id == FLASH_AREA_IMAGE_SECONDARY && |
| 119 | IS_ENCRYPTED(hdr) && |
| 120 | off >= hdr_size) { |
Fabio Utzig | 2fc80df | 2018-12-14 06:47:38 -0200 | [diff] [blame] | 121 | blk_off = (off - hdr_size) & 0xf; |
| 122 | boot_encrypt(fap, off - hdr_size, blk_sz, blk_off, tmp_buf); |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 123 | } |
| 124 | #endif |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 125 | bootutil_sha256_update(&sha256_ctx, tmp_buf, blk_sz); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 126 | } |
David Brown | e629bf3 | 2017-04-24 13:37:33 -0600 | [diff] [blame] | 127 | bootutil_sha256_finish(&sha256_ctx, hash_result); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 128 | |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | /* |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 133 | * Currently, we only support being able to verify one type of |
| 134 | * signature, because there is a single verification function that we |
| 135 | * call. List the type of TLV we are expecting. If we aren't |
| 136 | * configured for any signature, don't define this macro. |
| 137 | */ |
Fabio Utzig | 4876484 | 2019-05-10 19:28:24 -0300 | [diff] [blame] | 138 | #if (defined(MCUBOOT_SIGN_RSA) + \ |
| 139 | defined(MCUBOOT_SIGN_EC) + \ |
| 140 | defined(MCUBOOT_SIGN_EC256) + \ |
| 141 | defined(MCUBOOT_SIGN_ED25519)) > 1 |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 142 | #error "Only a single signature type is supported!" |
| 143 | #endif |
| 144 | |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 145 | #if defined(MCUBOOT_SIGN_RSA) |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 146 | # if MCUBOOT_SIGN_RSA_LEN == 2048 |
| 147 | # define EXPECTED_SIG_TLV IMAGE_TLV_RSA2048_PSS |
| 148 | # elif MCUBOOT_SIGN_RSA_LEN == 3072 |
| 149 | # define EXPECTED_SIG_TLV IMAGE_TLV_RSA3072_PSS |
| 150 | # else |
| 151 | # error "Unsupported RSA signature length" |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 152 | # endif |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 153 | # define SIG_BUF_SIZE (MCUBOOT_SIGN_RSA_LEN / 8) |
| 154 | # define EXPECTED_SIG_LEN(x) ((x) == SIG_BUF_SIZE) /* 2048 bits */ |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 155 | #elif defined(MCUBOOT_SIGN_EC) |
| 156 | # define EXPECTED_SIG_TLV IMAGE_TLV_ECDSA224 |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 157 | # define SIG_BUF_SIZE 128 |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 158 | # define EXPECTED_SIG_LEN(x) ((x) >= 64) /* oids + 2 * 28 bytes */ |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 159 | #elif defined(MCUBOOT_SIGN_EC256) |
| 160 | # define EXPECTED_SIG_TLV IMAGE_TLV_ECDSA256 |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 161 | # define SIG_BUF_SIZE 128 |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 162 | # define EXPECTED_SIG_LEN(x) ((x) >= 72) /* oids + 2 * 32 bytes */ |
Fabio Utzig | 4876484 | 2019-05-10 19:28:24 -0300 | [diff] [blame] | 163 | #elif defined(MCUBOOT_SIGN_ED25519) |
| 164 | # define EXPECTED_SIG_TLV IMAGE_TLV_ED25519 |
| 165 | # define SIG_BUF_SIZE 64 |
| 166 | # define EXPECTED_SIG_LEN(x) ((x) == SIG_BUF_SIZE) |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 167 | #else |
| 168 | # define SIG_BUF_SIZE 32 /* no signing, sha256 digest only */ |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 169 | #endif |
| 170 | |
| 171 | #ifdef EXPECTED_SIG_TLV |
| 172 | static int |
| 173 | bootutil_find_key(uint8_t *keyhash, uint8_t keyhash_len) |
| 174 | { |
| 175 | bootutil_sha256_context sha256_ctx; |
| 176 | int i; |
| 177 | const struct bootutil_key *key; |
| 178 | uint8_t hash[32]; |
| 179 | |
Fabio Utzig | 9911b18 | 2017-09-05 20:29:42 -0300 | [diff] [blame] | 180 | assert(keyhash_len <= 32); |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 181 | |
| 182 | for (i = 0; i < bootutil_key_cnt; i++) { |
| 183 | key = &bootutil_keys[i]; |
| 184 | bootutil_sha256_init(&sha256_ctx); |
| 185 | bootutil_sha256_update(&sha256_ctx, key->key, *key->len); |
| 186 | bootutil_sha256_finish(&sha256_ctx, hash); |
| 187 | if (!memcmp(hash, keyhash, keyhash_len)) { |
| 188 | return i; |
| 189 | } |
| 190 | } |
| 191 | return -1; |
| 192 | } |
| 193 | #endif |
| 194 | |
| 195 | /* |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 196 | * Verify the integrity of the image. |
| 197 | * Return non-zero if image could not be validated/does not validate. |
| 198 | */ |
| 199 | int |
| 200 | bootutil_img_validate(struct image_header *hdr, const struct flash_area *fap, |
| 201 | uint8_t *tmp_buf, uint32_t tmp_buf_sz, |
| 202 | uint8_t *seed, int seed_len, uint8_t *out_hash) |
| 203 | { |
| 204 | uint32_t off; |
David Brown | 3eaa2a1 | 2017-09-01 11:19:03 -0600 | [diff] [blame] | 205 | uint32_t end; |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 206 | int sha256_valid = 0; |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 207 | struct image_tlv_info info; |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 208 | #ifdef EXPECTED_SIG_TLV |
| 209 | int valid_signature = 0; |
| 210 | int key_id = -1; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 211 | #endif |
| 212 | struct image_tlv tlv; |
Fabio Utzig | 3501c01 | 2019-05-13 15:07:25 -0700 | [diff] [blame] | 213 | uint8_t buf[SIG_BUF_SIZE]; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 214 | uint8_t hash[32]; |
| 215 | int rc; |
| 216 | |
Fabio Utzig | ba82904 | 2018-09-18 08:29:34 -0300 | [diff] [blame] | 217 | rc = bootutil_img_hash(hdr, fap, tmp_buf, tmp_buf_sz, hash, seed, seed_len); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 218 | if (rc) { |
| 219 | return rc; |
| 220 | } |
| 221 | |
| 222 | if (out_hash) { |
| 223 | memcpy(out_hash, hash, 32); |
| 224 | } |
| 225 | |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 226 | /* The TLVs come after the image. */ |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 227 | off = hdr->ih_img_size + hdr->ih_hdr_size; |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 228 | |
| 229 | rc = flash_area_read(fap, off, &info, sizeof(info)); |
| 230 | if (rc) { |
Fabio Utzig | de6edc3 | 2017-09-04 14:35:49 -0300 | [diff] [blame] | 231 | return rc; |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 232 | } |
| 233 | if (info.it_magic != IMAGE_TLV_INFO_MAGIC) { |
Fabio Utzig | de6edc3 | 2017-09-04 14:35:49 -0300 | [diff] [blame] | 234 | return -1; |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 235 | } |
David Brown | 3eaa2a1 | 2017-09-01 11:19:03 -0600 | [diff] [blame] | 236 | end = off + info.it_tlv_tot; |
David Brown | f5b33d8 | 2017-09-01 10:58:27 -0600 | [diff] [blame] | 237 | off += sizeof(info); |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 238 | |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 239 | /* |
| 240 | * Traverse through all of the TLVs, performing any checks we know |
| 241 | * and are able to do. |
| 242 | */ |
David Brown | 3eaa2a1 | 2017-09-01 11:19:03 -0600 | [diff] [blame] | 243 | for (; off < end; off += sizeof(tlv) + tlv.it_len) { |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 244 | rc = flash_area_read(fap, off, &tlv, sizeof tlv); |
| 245 | if (rc) { |
| 246 | return rc; |
| 247 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 248 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 249 | if (tlv.it_type == IMAGE_TLV_SHA256) { |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 250 | /* |
| 251 | * Verify the SHA256 image hash. This must always be |
| 252 | * present. |
| 253 | */ |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 254 | if (tlv.it_len != sizeof(hash)) { |
| 255 | return -1; |
| 256 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 257 | rc = flash_area_read(fap, off + sizeof(tlv), buf, sizeof hash); |
| 258 | if (rc) { |
Fabio Utzig | de6edc3 | 2017-09-04 14:35:49 -0300 | [diff] [blame] | 259 | return rc; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 260 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 261 | if (memcmp(hash, buf, sizeof(hash))) { |
Fabio Utzig | de6edc3 | 2017-09-04 14:35:49 -0300 | [diff] [blame] | 262 | return -1; |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 263 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 264 | |
| 265 | sha256_valid = 1; |
| 266 | #ifdef EXPECTED_SIG_TLV |
| 267 | } else if (tlv.it_type == IMAGE_TLV_KEYHASH) { |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 268 | /* |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 269 | * Determine which key we should be checking. |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 270 | */ |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 271 | if (tlv.it_len > 32) { |
| 272 | return -1; |
| 273 | } |
| 274 | rc = flash_area_read(fap, off + sizeof tlv, buf, tlv.it_len); |
| 275 | if (rc) { |
| 276 | return rc; |
| 277 | } |
| 278 | key_id = bootutil_find_key(buf, tlv.it_len); |
| 279 | /* |
| 280 | * The key may not be found, which is acceptable. There |
| 281 | * can be multiple signatures, each preceded by a key. |
| 282 | */ |
| 283 | } else if (tlv.it_type == EXPECTED_SIG_TLV) { |
| 284 | /* Ignore this signature if it is out of bounds. */ |
| 285 | if (key_id < 0 || key_id >= bootutil_key_cnt) { |
| 286 | key_id = -1; |
| 287 | continue; |
| 288 | } |
| 289 | if (!EXPECTED_SIG_LEN(tlv.it_len) || tlv.it_len > sizeof(buf)) { |
| 290 | return -1; |
| 291 | } |
| 292 | rc = flash_area_read(fap, off + sizeof(tlv), buf, tlv.it_len); |
| 293 | if (rc) { |
| 294 | return -1; |
| 295 | } |
| 296 | rc = bootutil_verify_sig(hash, sizeof(hash), buf, tlv.it_len, key_id); |
| 297 | if (rc == 0) { |
| 298 | valid_signature = 1; |
| 299 | } |
| 300 | key_id = -1; |
| 301 | #endif |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 302 | } |
| 303 | } |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 304 | |
| 305 | if (!sha256_valid) { |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 306 | return -1; |
| 307 | } |
| 308 | |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 309 | #ifdef EXPECTED_SIG_TLV |
| 310 | if (!valid_signature) { |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 311 | return -1; |
| 312 | } |
| 313 | #endif |
David Brown | 43cda33 | 2017-09-01 09:53:23 -0600 | [diff] [blame] | 314 | |
Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame] | 315 | return 0; |
| 316 | } |