diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2016-05-05 17:21:29 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-10 19:41:46 -0700 |
commit | f3f9e00ef037695c4e792948effa1253f680c118 (patch) | |
tree | cb60549b87c41f99138ec69b7a9a403b048c612c /firmware/2lib/include/2hmac.h | |
parent | 5319565988fc5b1862d649fad985859929946a91 (diff) | |
download | vboot-f3f9e00ef037695c4e792948effa1253f680c118.tar.gz |
hmac: Add HMAC to 2lib library
This patch adds HMAC. HMAC will be used to sign/verify NVM structures.
Hash algorithms can be selected from those supported
by enum vb2_hash_algorithm (i.e. SHA1, SHA256, or SHA512).
BUG=chrome-os-partner:51907
BRANCH=tot
TEST=make runtests
Change-Id: I6d349bc807874fe2a5512aabcd7fbf67a4eaa40a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/342880
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'firmware/2lib/include/2hmac.h')
-rw-r--r-- | firmware/2lib/include/2hmac.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/firmware/2lib/include/2hmac.h b/firmware/2lib/include/2hmac.h new file mode 100644 index 00000000..1df19397 --- /dev/null +++ b/firmware/2lib/include/2hmac.h @@ -0,0 +1,29 @@ +/* Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef VBOOT_REFERENCE_VBOOT_2HMAC_H_ +#define VBOOT_REFERENCE_VBOOT_2HMAC_H_ + +#include <stdint.h> +#include "2crypto.h" + +/** + * Compute HMAC + * + * @param alg Hash algorithm ID + * @param key HMAC key + * @param key_size HMAC key size + * @param msg Message to compute HMAC for + * @param msg_size Message size + * @param mac Computed message authentication code + * @param mac_size Size of the buffer pointed by <mac> + * @return + */ +int hmac(enum vb2_hash_algorithm alg, + const void *key, uint32_t key_size, + const void *msg, uint32_t msg_size, + uint8_t *mac, uint32_t mac_size); + +#endif |