Software APIs
sw
device
lib
crypto
impl
integrity.c
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
#include "sw/device/lib/crypto/impl/integrity.h"
6
7
#include "
sw/device/lib/base/hardened.h
"
8
9
uint32_t integrity_unblinded_checksum(
const
otcrypto_unblinded_key_t
*key) {
10
// TODO: decide on a checksum algorithm and implement integrity checks.
11
// TODO: maybe check the key length to make sure it's not pushing UINT32_MAX,
12
// as an overflow protection.
13
return
0;
14
}
15
16
uint32_t integrity_blinded_checksum(
const
otcrypto_blinded_key_t
*key) {
17
// TODO: decide on a checksum algorithm and implement integrity checks.
18
// TODO: maybe check the key length to make sure it's not pushing UINT32_MAX,
19
// as an overflow protection.
20
return
0;
21
}
22
23
hardened_bool_t
integrity_unblinded_key_check(
24
const
otcrypto_unblinded_key_t
*key) {
25
if
(key->checksum == launder32(integrity_unblinded_checksum(key))) {
26
HARDENED_CHECK_EQ
(key->checksum, integrity_unblinded_checksum(key));
27
return
kHardenedBoolTrue
;
28
}
29
return
kHardenedBoolFalse
;
30
}
31
32
hardened_bool_t
integrity_blinded_key_check(
const
otcrypto_blinded_key_t
*key) {
33
if
(key->checksum == launder32(integrity_blinded_checksum(key))) {
34
HARDENED_CHECK_EQ
(key->checksum, integrity_blinded_checksum(key));
35
return
kHardenedBoolTrue
;
36
}
37
return
kHardenedBoolFalse
;
38
}
Return to
OpenTitan Documentation