xref: /aosp_15_r20/external/vboot_reference/firmware/2lib/include/2hmac.h (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2016 The ChromiumOS Authors
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef VBOOT_REFERENCE_2HMAC_H_
7 #define VBOOT_REFERENCE_2HMAC_H_
8 
9 #include <stdint.h>
10 #include "2crypto.h"
11 #include "2sha.h"
12 
13 /**
14  * Compute HMAC
15  *
16  * @param allow_hwcrypto	false to forbid HW crypto by policy; true to allow.
17  * @param alg			Hash algorithm ID
18  * @param key			HMAC key
19  * @param key_size		HMAC key size
20  * @param msg			Message to compute HMAC for
21  * @param msg_size		Message size
22  * @param mac			vb2_hash structure to fill with the mac of |msg|
23  * @return
24  */
25 int vb2_hmac_calculate(bool allow_hwcrypto, enum vb2_hash_algorithm alg, const void *key,
26 		       uint32_t key_size, const void *msg, uint32_t msg_size,
27 		       struct vb2_hash *mac);
28 
29 #endif  /* VBOOT_REFERENCE_2HMAC_H_ */
30