avb_rsa.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2016 The Android Open Source Project
  3. *
  4. * SPDX-License-Identifier: (MIT or BSD-3-Clause)
  5. */
  6. /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
  7. * Use of this source code is governed by a BSD-style license that can be
  8. * found in the LICENSE file.
  9. */
  10. #ifdef AVB_INSIDE_LIBAVB_H
  11. #error "You can't include avb_rsa.h in the public header libavb.h."
  12. #endif
  13. #ifndef AVB_COMPILATION
  14. #error "Never include this file, it may only be used from internal avb code."
  15. #endif
  16. #ifndef AVB_RSA_H_
  17. #define AVB_RSA_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include "avb_crypto.h"
  22. #include "avb_sysdeps.h"
  23. /* Using the key given by |key|, verify a RSA signature |sig| of
  24. * length |sig_num_bytes| against an expected |hash| of length
  25. * |hash_num_bytes|. The padding to expect must be passed in using
  26. * |padding| of length |padding_num_bytes|.
  27. *
  28. * The data in |key| must match the format defined in
  29. * |AvbRSAPublicKeyHeader|, including the two large numbers
  30. * following. The |key_num_bytes| must be the size of the entire
  31. * serialized key.
  32. *
  33. * Returns false if verification fails, true otherwise.
  34. */
  35. bool avb_rsa_verify(const uint8_t* key,
  36. size_t key_num_bytes,
  37. const uint8_t* sig,
  38. size_t sig_num_bytes,
  39. const uint8_t* hash,
  40. size_t hash_num_bytes,
  41. const uint8_t* padding,
  42. size_t padding_num_bytes) AVB_ATTR_WARN_UNUSED_RESULT;
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /* AVB_RSA_H_ */