Skip to content

Commit c80d0e1

Browse files
committed
Cleanse KBPK buffer in tr31-tool
This is mostly to make security scanning tools happy. Although the tr31 library is intended for actual security products and cleanses sensitive buffers accordingly, tr31-tool is intended for debugging and development that doesn't involve live cryptographic keys.
1 parent 03be066 commit c80d0e1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##############################################################################
2-
# Copyright 2020-2023 Leon Lynch
2+
# Copyright 2020-2023, 2025 Leon Lynch
33
#
44
# This file is licensed under the terms of the LGPL v2.1 license.
55
# See LICENSE file.
@@ -154,7 +154,7 @@ install(
154154
# TR-31 command line tool
155155
if(BUILD_TR31_TOOL)
156156
add_executable(tr31-tool tr31-tool.c)
157-
target_link_libraries(tr31-tool PRIVATE tr31)
157+
target_link_libraries(tr31-tool PRIVATE crypto_mem tr31)
158158
if(TARGET libargp::argp)
159159
target_link_libraries(tr31-tool PRIVATE libargp::argp)
160160
endif()

src/tr31-tool.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "tr31.h"
2222
#include "tr31_strings.h"
2323

24+
#include "crypto_mem.h"
25+
2426
#include <stddef.h>
2527
#include <stdbool.h>
2628
#include <stdint.h>
@@ -1541,6 +1543,9 @@ int main(int argc, char** argv)
15411543
options.export_opt_block_CT = NULL;
15421544
options.export_opt_block_CT_count = 0;
15431545
}
1546+
if (options.kbpk) {
1547+
crypto_cleanse(options.kbpk_buf, sizeof(options.kbpk_buf));
1548+
}
15441549

15451550
return r;
15461551
}

0 commit comments

Comments
 (0)