Skip to content

rpifwcrypto: Initial revision #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timg236
Copy link

@timg236 timg236 commented Aug 12, 2025

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.

@timg236
Copy link
Author

timg236 commented Aug 12, 2025

@roliver-rpi Adding early draft PR here so that we can start integrating this in parallel with firmware dependencies.

@timg236 timg236 marked this pull request as ready for review August 14, 2025 10:08
@timg236
Copy link
Author

timg236 commented Aug 14, 2025

Firmware changes are now merged (but not released)

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 P-256 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)
  e.g. LUKS passphrase = HMAC(device-unique-ley, serial64 + EMMC CID)

 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.
# Find GnuTLS package
find_package(GnuTLS REQUIRED)

add_compile_definitions(LIBRARY_BUILD=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a hangover from the original - pinctrl or piolib, I imagine - and appears not to be used here.

install(TARGETS rpi-fw-crypto RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS rpifwcrypto
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a newline.

mbox_close(mb);

return (rc < 0) ? rc : RPI_FW_CRYPTO_SUCCESS;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline.

}
#endif

#endif /* RPI_FW_CRYPTO_H */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline.

@@ -74,7 +74,6 @@ static void mbox_close(int file_desc) {
close(file_desc);
}


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? If so, there's another double-blank on lines 57-58.

return rc;

if (msg.resp.length > sig_max_len)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brace usage doesn't match the rest of this code, but there are other examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants