rsa_pss.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include "sdkconfig.h"
  15. #ifdef CONFIG_ESP32_REV_MIN_3
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include <stddef.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define ETS_SIG_LEN 384 /* Bytes */
  23. #define ETS_DIGEST_LEN 32 /* SHA-256, bytes */
  24. /* Secure Boot Version 2 - Public Key format */
  25. typedef struct {
  26. uint8_t n[384]; /* Public key modulus */
  27. uint32_t e; /* Public key exponent */
  28. uint8_t rinv[384];
  29. uint32_t mdash;
  30. } ets_rsa_pubkey_t;
  31. bool ets_rsa_pss_verify(const ets_rsa_pubkey_t *key, const uint8_t *sig, const uint8_t *digest, uint8_t *verified_digest);
  32. void ets_mgf1_sha256(const uint8_t *mgfSeed, size_t seedLen, size_t maskLen, uint8_t *mask);
  33. bool ets_emsa_pss_verify(const uint8_t *encoded_message, const uint8_t *mhash, uint8_t *verified_digest);
  34. #ifdef __cplusplus
  35. }
  36. #endif
  37. #endif // CONFIG_ESP32_REV_MIN_3