roll: third_party/pigweed/src e7cf4b9..c12f89e (63 commits) c12f89e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315872 roll: luci 111f46a:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315812 roll: fuchsia-infra-bazel-rules 05c81c4..bbe2807 (55 commits) c9c9a0a:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315115 pw_bluetooth_sapphire: Create FIDL helpers for Periodic Synchronization ac874aa:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315393 pw_kernel: list: Make Adapter more type-safe d257e42:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315592 pw_kernel: Update code_size target ignore bin output a31cc49:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315392 pw_kernel: list: Use immutable references d3d6785:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/307964 pw_presubmit: Avoid using PW_PROJECT_ROOT in presubmit_context.py 21d5810:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315192 third_party_fuschia: Fix dependencies 2a9a8b2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314393 pw_kernel: list: Refactor for safety and binary size e88938e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/311258 pw_bluetooth_sapphire: Support PA synchronization in Adapter 69cfc37:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314678 pw_async2: Update try.h for consistency; fix merge issue 641ab9e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314955 pw_async2: Implement socket-based comms layer for web UI 21ae3e7:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/315292 pw_env_setup: Roll cipd af8ba6c:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314058 pw_protobuf_compiler: Remove deprecated pw_proto_library rule d6eb5ed:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/309761 pw_bluetooth_sapphire: Create PeriodicAdvertisingSyncManager 7997384:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314732 workflows: Change some tools to GENERAL type 1272c8a:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314997 pw_kernel: Remove forcing opt mode a75fe59:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314993 pw_containers: C++ polyfill of constexpr pw::fill and pw::fill_n 8282c33:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313652 pw_thread: Avoid creating thread stacks on other stacks 1f9ad05:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/312695 pw_kernel: Add object declaration to system manifest 266056a:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313452 pw_trace_tokenized: Add facade for locking 2345710:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314741 pw_env_setup: Respect CIPD_CACHE_DIR in Bazel c5cb259:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314635 pw_kernel: Add helpers for declaring static ForeignBox and ForeingRc 9ab3e0c:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314634 pw_kernel: Add upcasting support for ForeignRc 7dc5bad:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/311137 pw_bluetooth_sapphire: Support PA synchronization in FakeController 17f9b04:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314958 pw_unit_test: Use native_binary and native_test for pw_golden_test 1bb87c5:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314954 pw_stream: Check all possible addresses in SocketStream::Connect() 32458c0:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313653 pw: Avoid cursor overlap with first character in initializing message dea0295:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/307275 pw_channel: PacketChannel PendingWrite fixes 60ab312:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314734 pw_kernel: Remove semihosting exit from rp2350 target 44003c8:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314574 pw_build: Add `describe --dump-build-request` 1aed1eb:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314573 pw_build: Add rerun_shortcut to Workflow tools/builds 35d8cec:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314457 pw_kernel: Update kernel_only demo app to return success/failure 3f90f3f:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314580 pw_kernel: Make Event::new const and fix signalers count f95a020:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314021 pw_async2: Write codelab step 2 d88f40c:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/302833 pw_numeric: Test constexpr of checked_arithmetic 38d7504:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314321 pw_protobuf: Callback API for encoding bytes fields c786b58:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314478 pw_chrono: Use Message.FromString() rather than ParseFromString() fbeb306:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314477 pw_thread: Use Message.FromString() rather than ParseFromString() 523fffe:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313132 pw_containers: Mutable access to InlineVarLenEntryQueue 03fce0f:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314476 pw_cpu_exception_risc_v: Use Message.FromString() 1a484a0:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/304795 pw_trace: Add Zephyr backend for trace time f3e8472:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/304458 pw_thread_zephyr: Move sleep_until to inline header 887dd01:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314475 pw_cpu_exception_cortex_m: Use Message.FromString() 4222575:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314474 pw_snapshot: Use Message.FromString() rather than ParseFromString() a007cbf:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314473 pw_transfer: Use Message.FromString() rather than ParseFromString() 4c3c65e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314472 pw_rpc: Use Message.FromString() rather than ParseFromString() c60232c:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313574 pw_unit_test: pw_golden_test for testing an executable's output d26913d:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314059 pw_async2: Tidy docs a3967c7:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313752 doxygen: Migrate modules 8c06947:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314057 pw_toolchain: Clear pw_unit_test_AUTOMATIC_RUNNER for static analysis c2fae23:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313572 roll: nanopb to 4.9.1.bcr.2 64c3be2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314412 pw_ide: Release v1.9.7 bee389b:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/310299 pw_ide: Release v1.9.6 ca67c39:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313712 pw_thread: Reserve field numbers in Thread message 5ebe0c7:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314027 pw_checksum: Correct CRC16 docs 7bae5b9:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313272 pw_containers: Remove //pw_containers:pw_container 8fc0602:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313496 pw_kernel: Add emulated atomics support to pw_atomic fb0038e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/312696 doxygen: Migrate pw_async2 b0387c4:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314053 pw_toolchain: Make compiler-specific flags usable 905ec38:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/314019 pw_ide: Mention right targets for currently untracked files 70a7885:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313832 pw_kernel: Remove trait impls on Timer e6c4f74:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/313892 roll: go Rolled-Repo: https://pigweed.googlesource.com/pigweed/pigweed Rolled-Commits: e7cf4b9d58d1ce..c12f89eb321a9d Roll-Count: 1 Roller-URL: https://cr-buildbucket.appspot.com/build/8705607912164899617 GitWatcher: ignore CQ-Do-Not-Cancel-Tryjobs: true Change-Id: I6fa33faaeeeb698b773e3f81a75c4807abfc1030 Reviewed-on: https://pigweed-review.googlesource.com/c/open-dice/+/315993 Commit-Queue: Pigweed Roller <pigweed-roller@pigweed-service-accounts.iam.gserviceaccount.com> Bot-Commit: Pigweed Roller <pigweed-roller@pigweed-service-accounts.iam.gserviceaccount.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
This repository contains the specification for the Open Profile for DICE along with production-quality code. This profile is a specialization of the Hardware Requirements for a Device Identifier Composition Engine and DICE Layering Architecture specifications published by the Trusted Computing Group (TCG). For readers already familiar with those specs, notable distinctives of this profile include:
You can find us (and join us!) at https://groups.google.com/g/open-profile-for-dice. We're happy to answer questions and discuss proposed changes or features.
The specification can be found here. It is versioned using a major.minor scheme. Compatibility is maintained across minor versions but not necessarily across major versions.
Production quality, portable C code is included. The main code is in dice.h and dice.c. Cryptographic and certificate generation operations are injected via a set of callbacks. Multiple implementations of these operations are provided, all equally acceptable. Integrators should choose just one of these, or write their own.
Tests are included for all code and the build files in this repository can be used to build and run these tests.
Disclaimer: This is not an officially supported Google product.
Different implementations use different third party libraries. The third_party directory contains build files and git submodules for each of these. The submodules must be initialized once after cloning the repo, using git submodule update --init, and updated after pulling commits that roll the submodules using git submodule update.
To setup the build environment the first time:
$ git submodule update --init --recursive $ source bootstrap.sh $ gn gen out
To build and run tests:
$ ninja -C out
The easiest way, and currently the only supported way, to build and run tests is from a Pigweed environment on Linux. Pigweed does support other host platforms so it shouldn't be too hard to get this running on Windows for example, but we use Linux.
There are two scripts to help set this up:
bootstrap.sh will initialize submodules, bootstrap a Pigweed environment, and generate build files. This can take some time and may download on the order of 1GB of dependencies so the normal workflow is to just do this once.
activate.sh quickly reactivates an environment that has been previously bootstrapped.
These scripts must be sourced into the current session: source activate.sh.
In the environment, from the base directory of the dice-profile checkout, run ninja -C out to build everything and run all tests. You can also run pw watch which will build, run tests, and continue to watch for changes.
This will build and run tests on the host using the clang toolchain. Pigweed makes it easy to configure other targets and toolchains. See toolchains/BUILD.gn and the Pigweed documentation.
The code is designed to be portable and should work with a variety of modern toolchains and in a variety of environments. The main code in dice.h and dice.c is C99; it uses uint8_t, size_t, and memcpy from the C standard library. The various ops implementations are as portable as their dependencies (often not C99 but still very portable). Notably, this code uses designated initializers for readability. This is a feature available in C since C99 but missing from C++ until C++20 where it appears in a stricter form.
The Google C++ Style Guide is used. A .clang-format file is provided for convenience.
To incorporate the code into another project, there are a few options:
Copy only the necessary code. For example:
Take the main code as is: include/dice/dice.h, src/dice.c
Choose an implementation for crypto and certificate generation or choose to write your own. If you choose the boringssl implementation, for example, take include/dice/utils.h, include/dice/boringssl_ops.h, src/utils.c, and src/boringssl_ops.c. Taking a look at the library targets in BUILD.gn may be helpful.
Add this repository as a git submodule and integrate into the project build, optionally using the gn library targets provided.
Integrate into a project already using Pigweed using the gn build files provided.
The build reports code size using Bloaty McBloatface via the pw_bloat Pigweed module. There are two reports generated:
Library sizes - This report includes just the library code in this repository. It shows the baseline DICE code with no ops selected, and it shows the delta introduced by choosing various ops implementations. This report does not include the size of the third party dependencies.
Executable sizes - This report includes sizes for the library code in this repository plus all dependencies linked into a simple main function which makes a single DICE call with all-zero input. It shows the baseline DICE code with no ops (and therefore no dependencies other than libc), and it shows the delta introduced by choosing various ops implementations. This report does include the size of the third party dependencies. Note that rows specialized from ‘Boringssl Ops’ use that as a baseline for sizing.
The reports will be in the build output, but you can also find the reports in .txt files in the build output. For example, cat out/host_optimized/gen/*.txt | less will display all reports.
This code does not itself use mutable global variables, or any other type of shared data structure so there is no thread-safety concerns. However, additional care is needed to ensure dependencies are configured to be thread-safe. For example, the current boringssl configuration defines OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED, and that would need to be changed before running in a threaded environment.
This code makes a reasonable effort to clear memory holding sensitive data. This may help with a broader strategy to clear sensitive data but it is not sufficient on its own. Here are a few things to consider.