Skip to content

Commit 918e00c

Browse files
committed
Rebased, addressed comments
1 parent 49106ca commit 918e00c

File tree

6 files changed

+92
-5
lines changed

6 files changed

+92
-5
lines changed

include/hal_otp.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/* hal_otp.h
2+
*
3+
* OTP helper definitions.
4+
*
5+
* Copyright (C) 2026 wolfSSL Inc.
6+
*
7+
* This file is part of wolfBoot.
8+
*
9+
* wolfBoot is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* wolfBoot is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
22+
*/
23+
124
#ifndef WOLFBOOT_HAL_OTP_H
225
#define WOLFBOOT_HAL_OTP_H
326

src/tpm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,16 +1539,19 @@ int wolfBoot_tpm2_clear(void)
15391539
int wolfBoot_check_rot(int key_slot, uint8_t* pubkey_hint)
15401540
{
15411541
int rc;
1542+
size_t auth_sz;
15421543
uint8_t digest[WOLFBOOT_SHA_DIGEST_SIZE];
15431544
uint32_t digestSz = WOLFBOOT_SHA_DIGEST_SIZE;
15441545
WOLFTPM2_NV nv;
15451546

15461547
memset(&nv, 0, sizeof(nv));
15471548
nv.handle.hndl = WOLFBOOT_TPM_KEYSTORE_NV_BASE + key_slot;
15481549
#ifdef WOLFBOOT_TPM_KEYSTORE_AUTH
1549-
nv.handle.auth.size = (UINT16)strlen(WOLFBOOT_TPM_KEYSTORE_AUTH);
1550-
if (nv.handle.auth.size > sizeof(nv.handle.auth.buffer))
1550+
auth_sz = strlen(WOLFBOOT_TPM_KEYSTORE_AUTH);
1551+
if (auth_sz > (size_t)UINT16_MAX ||
1552+
auth_sz > sizeof(nv.handle.auth.buffer))
15511553
return BAD_FUNC_ARG;
1554+
nv.handle.auth.size = (UINT16)auth_sz;
15521555
memcpy(nv.handle.auth.buffer, WOLFBOOT_TPM_KEYSTORE_AUTH,
15531556
nv.handle.auth.size);
15541557
#endif

tools/tpm/rot.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static int TPM2_Boot_SecureROT_Example(TPMI_RH_NV_AUTH authHandle, word32 nvBase
148148
/* Setup a read/lock structure */
149149
XMEMSET(&nv, 0, sizeof(nv));
150150
nv.handle.hndl = handle;
151-
if (authBufSz > (int)sizeof(nv.handle.auth.buffer))
152-
return BAD_FUNC_ARG;
151+
if (authBufSz > (int)sizeof(nv.handle.auth.buffer)) {
152+
rc = BAD_FUNC_ARG;
153+
goto exit;
154+
}
153155
nv.handle.auth.size = authBufSz;
154156
XMEMCPY(nv.handle.auth.buffer, authBuf, nv.handle.auth.size);
155157

tools/unit-tests/unit-fdt.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
/* unit-fdt.c
22
*
33
* Unit tests for flattened device tree helpers.
4+
*
5+
* Copyright (C) 2026 wolfSSL Inc.
6+
*
7+
* This file is part of wolfBoot.
8+
*
9+
* wolfBoot is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* wolfBoot is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
422
*/
523

624
#include <check.h>

tools/unit-tests/unit-rot-auth.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/* unit-rot-auth.c
2+
*
3+
* Unit tests for TPM ROT auth validation.
4+
*
5+
* Copyright (C) 2026 wolfSSL Inc.
6+
*
7+
* This file is part of wolfBoot.
8+
*
9+
* wolfBoot is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* wolfBoot is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
22+
*/
23+
124
#include <check.h>
225
#include <stdlib.h>
326
#include <stdint.h>
@@ -231,7 +254,7 @@ int main(void)
231254

232255
s = rot_auth_suite();
233256
sr = srunner_create(s);
234-
srunner_run_all(sr, CK_ENV);
257+
srunner_run_all(sr, CK_NORMAL);
235258
failures = srunner_ntests_failed(sr);
236259
srunner_free(sr);
237260

tools/unit-tests/unit-tpm-check-rot-auth.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
/* unit-tpm-check-rot-auth.c
22
*
33
* Unit tests for TPM root-of-trust auth validation.
4+
*
5+
* Copyright (C) 2026 wolfSSL Inc.
6+
*
7+
* This file is part of wolfBoot.
8+
*
9+
* wolfBoot is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* wolfBoot is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
422
*/
523

624
#include <check.h>

0 commit comments

Comments
 (0)