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