avb_rsa.h 1.5 KB

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