roll: third_party/pigweed/src ea07dec..99c33b1 (61 commits) 99c33b1:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/373112 roll: luci f7f08e9:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/373052 roll: fuchsia-infra-bazel-rules 48bea91..235ee6d (57 commits) c0ac743:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372812 pw_snapshot: Add build_origin field to pw.snapshot.Metadata 103fa7e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372793 pw_channel: Remove basic_proxy.cc a562484:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372292 pw_memory: Change pw_memory to cc_library_static in Android.bp d01bd7a:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372693 pw_containers: Remove InlineAsyncQueue and InlineAsyncDeque a5256bb:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372692 pw_channel: Remove packet proxy fd0e4be:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372652 pw_bluetooth_proxy: Remove comms2 code 4a8c1d1:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369813 pw_tokenizer: Accept extra databases 9117cc2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372432 pw_multibuf: Add checks for MultiBuf move-assignment 6036f00:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370520 pw_allocator: Refactor shared pointer constructors and casts 098dc71:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370012 pw_build: Cleanup and test coverage for pw_pylint.bzl d536942:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/361612 pw_malloc: Add pw_malloc tests to the CMake build 222eb88:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371832 pw_async2: Expand informed poll doc with further rationale c9711b2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372232 pw_async2: Remove unnecessary std::optional<Future> db548ff:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372613 pw_async2: Separate FutureState's pending state from ready state 67917fe:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372353 pw_presubmit: Remove bazel_includes from the local presubmit check 3999bb2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372213 pw_async2: Merge :poll and :func_task into //pw_async2 5827cc5:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370519 pw_allocator: Fix shared pointer copy assignment fcc47e4:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/362058 pw_multibuf: Remove uses of InlineAsyncQueue 02fa1dc:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370518 pw_multibuf: Refactor v2 iterators and loops 2a44a4f:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371992 pw_async2: Fix occasional crashes in timeout example 021386c:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372293 pw_build_android: Add rationale to cc_library_static use 35c7136:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/372072 pw_async2: RunOnceTask helper 0c1ebb7:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371774 pw_async2: Create closed SendFutures in an pendable state; fix move e789c6e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371612 pw_multibuf: Mark test packages `testonly` in BUILD.gn 350c711:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371672 roll: toolchain manually a1090c6:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371776 pw_compilation_testing: Fix typo 2711f8e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/360394 pw_multibuf: Disallow adding partial owned chunks 3b7dcda:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371773 bazel: Update MODULE.bazel.lock f4e0867:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371734 py_env_setup: Update platform constraints 384c5f8:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369097 pw_async2: FutureTask wrapper cf8e04e:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371252 pw_async2: Return PendingType from Unschedule 8e93283:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371272 pw_async2: Mark as stable, update main docs page 4c3cd8d:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371153 pw_async2: Modernize basic example ce33309:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/361818 pw_multibuf: Move examples namespace out of 'pw' 0a0197f:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371276 pw_kernel: Local workaround for clippy crash 8e3a5a4:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371152 pw_toolchain: Allow configuration of pw_rust_toolchain cf48aee:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/367600 pw_async2: Remove backwards compatibility aliases for PendFuncTask 2c43d12:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/359634 pw_multibuf: Reorganize module by version a801306:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371193 pw_presubmit: Enable bluetooth_sapphire coverage f520596:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/364732 pw_i2c_mcuxpresso: Add support for flexio in i2c mode ae089d5:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371293 pw_async2: Remove -Wno-deprecated-declarations from codelab d4466f2:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369812 pw_i2c: Update RegisterDevice documentation beb2831:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/368952 pw_kernel: Clairify kernel context switching contracts 4be3c11:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/371192 pw_i2c_mcuxpresso: Add retry loop to handle arbitration loss f997e38:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/329492 pw_transfer: Switch to using IntrusiveForwardList 4396cdb:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370432 pw_clock_tree: Introduce ExernalClockSource clock tree element dbd49ac:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/368332 pw_kernel: Update object_wait to return a WaitReturn e2c2c55:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369852 pw_presubmit: Enable pw_bluetooth_proxy coverage 1729a32:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370892 pw_bluetooth_proxy: Correct RFCOMM emb build rule d642b2d:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370352 pw_clock_tree: Introduce ClockSourceNoOpBlocking clock tree element 66001ac:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370813 Revert "roll: toolchain clang only" dc60615:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370812 pw_build: Address buildifier warnings 1540c70:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369099 pw_protobuf: Allow building with -Wsign-conversion a9ef4f1:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370653 pw_async2: Make OwnedTask internal c456833:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/369473 pw_async2: Remove EnqueueHeapFunc b9c992f:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370632 roll: toolchain clang only cfe4afc:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370672 pw_bluetooth_proxy: Add pw_async2 to hci/Android.bp 4c6d6de:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/370492 roll: buildifier 5dbeba6:https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/355592 pw_containers: Add pw::Hash functor Rolled-Repo: https://pigweed.googlesource.com/pigweed/pigweed Rolled-Commits: ea07decce2ea96..99c33b10743d24 Roll-Count: 1 Roller-URL: https://cr-buildbucket.appspot.com/build/8690387621727960321 GitWatcher: ignore CQ-Do-Not-Cancel-Tryjobs: true Change-Id: Ie4e2350f9e3f903e68a6c016e3c369e635f584dd Reviewed-on: https://pigweed-review.googlesource.com/c/open-dice/+/373332
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.