Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7065b10
Feat: add defmt_test example
WilliamTakeshi Nov 27, 2025
f3d602f
chore: make testvector no_std so we can use on nrf54l15
WilliamTakeshi Nov 27, 2025
b259f87
feat: add sha256 for nrf54l15
WilliamTakeshi Nov 28, 2025
d5fbb8b
feat: real incrementing api
WilliamTakeshi Nov 30, 2025
82c3e7d
chore: change the logic from block_bytes_left to block_bytes_used
WilliamTakeshi Nov 30, 2025
aebe560
clippy suggestions
WilliamTakeshi Nov 30, 2025
e4f1e85
chore: remove embedded-cal-nrf54l15 from ci tests
WilliamTakeshi Dec 1, 2025
751bdf1
fix: bug where state was updated more than once
WilliamTakeshi Dec 5, 2025
3dbafbb
feat: more testvectors for sha256
WilliamTakeshi Dec 5, 2025
3a085c2
feat: add descriptorchain idea to simplify the code
WilliamTakeshi Dec 5, 2025
b8817e8
chore: move descriptor and descriptorchain to its own file
WilliamTakeshi Dec 5, 2025
7471dc6
feat: add verify on flash cmd
WilliamTakeshi Dec 6, 2025
2c6b454
chore: start working on sha512
WilliamTakeshi Dec 6, 2025
e0bcfa2
feat: add test state so they can share the same cal obj
WilliamTakeshi Dec 6, 2025
08855d5
feat: add support to sha512
WilliamTakeshi Dec 6, 2025
977f4ec
feat: add support to sha384 on nrf54l15
WilliamTakeshi Dec 6, 2025
2de0a9f
chore: add comment on HashAlgorithm
WilliamTakeshi Dec 14, 2025
9b8c4e6
chore: remove cargo.lock
WilliamTakeshi Dec 11, 2025
107489c
chore: remove not needed dependencies, move then to dev-dependencies
WilliamTakeshi Dec 11, 2025
83ce3b2
chore: make descriptor and descriptor chain pub(crate)
WilliamTakeshi Dec 14, 2025
19e6611
chore: compile time checks for BLOCK_SIZE
WilliamTakeshi Dec 14, 2025
76f6492
chore: add to do comment on peripherals ownership
WilliamTakeshi Dec 14, 2025
ac7b381
fix: memory.x values
WilliamTakeshi Dec 15, 2025
f69ba3b
chore: some documentation on descriptors
WilliamTakeshi Dec 15, 2025
ebf0973
fix: off by one error
WilliamTakeshi Dec 16, 2025
ae5c31d
improv: reduce the number of peripherals used on nrf54
WilliamTakeshi Dec 16, 2025
4c7c0b6
improv: remove pub(crates) when not needed
WilliamTakeshi Dec 16, 2025
3af1f96
chore: dont repeat execute_cryptomaster_dma
WilliamTakeshi Dec 17, 2025
3770858
doc: add disclaimer about NIST testvectors
WilliamTakeshi Dec 17, 2025
f12e61b
Link to COSE Algorithms registry in .from_cose_number()
chrysn Dec 10, 2025
93a74d0
Architecture: Align with implementation progress
chrysn Nov 20, 2025
1e6c87d
Clarifications from Jonas's chat questions
chrysn Dec 11, 2025
de6b0e3
Architecture: point to issue
chrysn Dec 11, 2025
675b81f
COSE: Fix hash algorithm numbers
chrysn Dec 15, 2025
99c5a5c
Reference architecture choices in code documentation
chrysn Dec 11, 2025
192920d
fix: cose hash256 value
WilliamTakeshi Dec 18, 2025
7d88fbd
chore: use embassy nrf pac
WilliamTakeshi Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: run `cargo doc`
run: RUSTDOCFLAGS="-D warnings" cargo doc
- name: run `cargo test`
run: cargo test --all
run: cargo test --all --exclude embedded-cal-nrf54l15

generate-fstar:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
Cargo.lock
66 changes: 65 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,75 @@ At any rate, a provider of cryptographic primitives can offer any subset of them
* Backends can use references to keys and thus not create them in memory.
* Secrets handled by the library are handled though zeroizing or similar interfaces.
* Instances are accessed through an exclusive reference.
* A wrapper generic over a Mutex provides shared access (optional)
* A wrapper generic over a Mutex provides shared access ([#10](https://github.com/lake-rs/embedded-cal/issues/10), optional)
* Incomplete operations should not block the system:
Not all operations are expected to be complted before an operation of the same kind is started.

Note that this is not about preemption or multi-core support (the exclusive reference ensures that operations are serialized),
but about operatins receiving partial data (eg. hashing some part of a file) and continuing that operation after calculating a different item's hash.

This is limited to where split operation is supported conceptually -- AEAD operations do require the plain-/ciphertext to be present throughout the operation.
* It can provide the required cryptographic operations for
* EDHOC (Lakers)
* OSCORE (libOSCORE)
* SUIT (as to be used in Ariel OS)
* TLS (no concrete implementation planned)

Providing high-level COSE operations is an optional goal outside of the immediate scope of the trait.

## Implementation

The interface is implemented by a family of traits,
which reside in [`embedded_cal`](./embedded-cal/src/lib.rs).

Currently, a subset of the primitives is implemented there,
but adhering to all the generic principles.

## Usage

Practical use requires setting up an Cal instances;
the one currently provided is [`embedded_cal_rustcrypto::RustcryptoCal`](./embedded-cal-rustcrypto/src/lib.rs).
While that instance can be constructed at any point,
hardware based instances will come with their own non-trivial `::new()` function,
and will best be used augmented by (i.e., wrapped in) the formally verified implementation.

Once an exclusive reference to such an object exists,
its methods guide its use;
the test vectors have an [example of how to use hashing](./testvectors/src/lib.rs).

## FAQ

* Q: Why are key, hash encryption states statically sized, rather than using generics to minimize stack usage?

embedded-cal is designed for alogrithm agility.
The concrete choice of algorithms is a run-time decision, allowing to switch off an unusable algorithm at any time.

This apparently wastes resources (mostly in terms of stack size), but gives returns in reliability beyond the security gains of multiple algorithmns:
If an operation can complete without a stack overflow on one algorithm, the stack is sufficiently sized for any algorithm.
(And especially on microcontrollers, while stack space is limited, there is no harm in using more of it as long as the maximum is not exceeded).

Moreover, this avoids the cost in program size (flash memory) of monomorphizing parts of a program to different algorithms.

Applications that do need to minimize sizes in some part of the program are encourated to explore three possibilities in that order:

* In storage, work with algorithm specific outputs.
For example, if a particular part of the application only admits two concrete kinds of hashes that have the same size,
it can use dynnamic sizes during computation, but store only the fixed-size bytes.
* If the larger algorithms are completely unused, do not enable them globally.
In general, embedded applications will need to opt into a selected subset of the supported algorithms anyway,
and then, the selection focus can be on a diverse subset of the algorithms with smaller footprint.
* There can be different instances of a `Cal` in a system.
For cases when the run-time size is critical but the system needs to support larger algorithms in other parts,
a differently parametrized `Cal` (that, for example, only supports the single algorithm) can be used.

* Q: The interfaces for starting operations are not parametrized.
How does this, for example, support algorithms such as SHAKE that can have different output sizes?

A: The interfaces for selecting an algorithm are currently based on COSE and TLS,
both of which prefer to assign a single identifier to a fully parametrized algortihm (eg. SHAKE256).
If constructors from other ecosystems are added where there are extra parameters, those constructors will need to account for them.

Note that this is purely a constructor thing:
If an implementation has a general algorithm for SHAKE,
its `HashAlgorithm` item can be an enum with a `Shake(usize)` variant,
even if only a limited subset of those can be crated with the portable constructors.
Loading
Loading