Skip to content

Commit 9999548

Browse files
committed
rpifwcrypto: Initial revision
Client side library and application for the Raspberry Pi firmware cryptography service. The firmware mailbox based crypto service provides limited support for cryptographic operations using a ECDSA p256 private core stored in OTP (using rpi-otp-private-key). The current operations are * Get number of OTP keys * Get status for key * Set status for a key (runtime lock) * ECDSA SHA256 signature * HMAC SHA256 (max message size 2KB) rpifwcrypto is a command line application designed to allow the crypto operations to be easily used in shell scripts. rpifwcrypto.h provides a library interface so that this can be embedded in other applications. Direct usage of mailbox API (vcmailbox) is not recommended because this is a new feature and the mailbox API is not frozen.
1 parent b7651d8 commit 9999548

File tree

8 files changed

+833
-3
lines changed

8 files changed

+833
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ add_subdirectory(raspinfo)
1515
add_subdirectory(vcgencmd)
1616
add_subdirectory(vclog)
1717
add_subdirectory(vcmailbox)
18+
add_subdirectory(rpifwcrypto)

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ A collection of scripts and simple applications
1818
* [piolib](piolib/) - A library for accessing the Pi 5's PIO hardware.
1919
* [raspinfo](raspinfo/) - A short script to dump information about the Pi. Intended for
2020
the submission of bug reports.
21+
* [rpifwcrypto](rpifwcrypto/) - A command line application and library for the
22+
firmware cryptography services. Intended for use with Raspberry Pi Connect and
23+
secure-boot provisioner.
2124
* [vclog](vclog/) - A tool to get VideoCore 'assert' or 'msg' logs
2225
with optional -f to wait for new logs to arrive.
2326

2427

2528
**Build Instructions**
2629

27-
Install the prerequisites with "sudo apt install cmake device-tree-compiler libfdt-dev" - you need at least version 3.10 of cmake. Run the following commands to build and install everything, or see the README files in the subdirectories to just build utilities individually:
30+
Install the prerequisites with "sudo apt install cmake device-tree-compiler libfdt-dev libgnutls28-dev" - you need at least version 3.10 of cmake. Run the following commands to build and install everything, or see the README files in the subdirectories to just build utilities individually:
2831

2932
- *cmake .*
30-
N.B. Use *cmake -DBUILD_SHARED_LIBS=1 .* to build the libraries in the subprojects (libdtovl, gpiolib and piolib) as shared (as opposed to static) libraries.
33+
N.B. Use *cmake -DBUILD_SHARED_LIBS=1 .* to build the libraries in the subprojects (libdtovl, gpiolib, librpifwcrypto and piolib) as shared (as opposed to static) libraries.
3134
- *make*
3235
- *sudo make install*

rpifwcrypto/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

rpifwcrypto/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.10...3.27)
2+
include(GNUInstallDirs)
3+
4+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
5+
6+
# Set project name
7+
project(rpifwcrypto)
8+
9+
# Find GnuTLS package
10+
find_package(GnuTLS REQUIRED)
11+
12+
add_compile_definitions(LIBRARY_BUILD=1)
13+
14+
# Create the shared library
15+
add_library(rpifwcrypto rpifwcrypto.c)
16+
target_sources(rpifwcrypto PUBLIC rpifwcrypto.h)
17+
set_target_properties(rpifwcrypto PROPERTIES PUBLIC_HEADER rpifwcrypto.h)
18+
set_target_properties(rpifwcrypto PROPERTIES SOVERSION 0)
19+
20+
# Create the executable
21+
add_executable(rpi-fw-crypto main.c)
22+
target_link_libraries(rpi-fw-crypto rpifwcrypto ${GNUTLS_LIBRARIES})
23+
target_include_directories(rpi-fw-crypto PRIVATE ${GNUTLS_INCLUDE_DIRS})
24+
25+
# Install rules
26+
install(TARGETS rpi-fw-crypto RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
27+
install(TARGETS rpifwcrypto
28+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
29+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

0 commit comments

Comments
 (0)