Software APIs
sw
device
lib
crypto
impl
integrity.h
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
#ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_IMPL_INTEGRITY_H_
6
#define OPENTITAN_SW_DEVICE_LIB_CRYPTO_IMPL_INTEGRITY_H_
7
8
#include <
stddef.h
>
9
#include <
stdint.h
>
10
11
#include "
sw/device/lib/base/hardened.h
"
12
#include "
sw/device/lib/base/macros.h
"
13
#include "
sw/device/lib/crypto/include/datatypes.h
"
14
15
#ifdef __cplusplus
16
extern
"C"
{
17
#endif
// __cplusplus
18
19
/**
20
* Compute the checksum of an unblinded key.
21
*
22
* The current key checksum is ignored. Call this routine after modifying
23
* blinded key material (e.g. for re-masking).
24
*
25
* @param key Unblinded key.
26
* @returns Checksum value.
27
*/
28
uint32_t integrity_unblinded_checksum(
const
otcrypto_unblinded_key_t
*key);
29
30
/**
31
* Compute the checksum of a blinded key.
32
*
33
* The current key checksum is ignored. Call this routine after modifying
34
* blinded key material (e.g. for re-masking).
35
*
36
* @param key Blinded key.
37
* @returns Checksum value.
38
*/
39
uint32_t integrity_blinded_checksum(
const
otcrypto_blinded_key_t
*key);
40
41
/**
42
* Perform an integrity check on the unblinded key.
43
*
44
* Returns `kHardenedBoolTrue` if the check passed and `kHardenedBoolFalse`
45
* otherwise.
46
*
47
* @param key Unblinded key.
48
* @returns Whether the integrity check passed.
49
*/
50
OT_WARN_UNUSED_RESULT
51
hardened_bool_t
integrity_unblinded_key_check(
52
const
otcrypto_unblinded_key_t
*key);
53
54
/**
55
* Perform an integrity check on the blinded key.
56
*
57
* Returns `kHardenedBoolTrue` if the check passed and `kHardenedBoolFalse`
58
* otherwise.
59
*
60
* @param key Blinded key.
61
* @returns Whether the integrity check passed.
62
*/
63
OT_WARN_UNUSED_RESULT
64
hardened_bool_t
integrity_blinded_key_check(
const
otcrypto_blinded_key_t
*key);
65
66
#ifdef __cplusplus
67
}
// extern "C"
68
#endif
// __cplusplus
69
70
#endif
// OPENTITAN_SW_DEVICE_LIB_CRYPTO_IMPL_INTEGRITY_H_
Return to
OpenTitan Documentation