1 /* 2 * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "sdkconfig.h" 10 #if CONFIG_ESP32_REV_MIN_FULL >= 300 11 12 #include <stdint.h> 13 #include <stdbool.h> 14 #include <stddef.h> 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #define ETS_SIG_LEN 384 /* Bytes */ 21 #define ETS_DIGEST_LEN 32 /* SHA-256, bytes */ 22 23 /* Secure Boot Version 2 - Public Key format */ 24 typedef struct { 25 uint8_t n[384]; /* Public key modulus */ 26 uint32_t e; /* Public key exponent */ 27 uint8_t rinv[384]; 28 uint32_t mdash; 29 } ets_rsa_pubkey_t; 30 31 32 bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest, uint8_t *verified_digest); 33 34 void ets_mgf1_sha256(const uint8_t *mgfSeed, size_t seedLen, size_t maskLen, uint8_t *mask); 35 36 bool ets_emsa_pss_verify(const uint8_t *encoded_message, const uint8_t *mhash, uint8_t *verified_digest); 37 38 #ifdef __cplusplus 39 } 40 #endif 41 42 #endif // CONFIG_ESP32_REV_MIN_FULL >= 300 43