Skip to content

Commit c05595b

Browse files
Add final documentation (#62)
* Add README, delete flash.md * Improve building of design document * More changes * Add some macros to improve code readability * Update docs * Add final docs * Revert code to main * Remove building.md
1 parent 07ffa57 commit c05595b

21 files changed

+450
-899
lines changed

README.md

Lines changed: 62 additions & 274 deletions
Large diffs are not rendered by default.

attest_guide.md

Lines changed: 0 additions & 246 deletions
This file was deleted.

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mermaid-filter.err
2+
img/

docs/1-overview.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
\title{Medical Device (MISC) Design for MITRE eCTF 2024}
2+
\author{SIGPwny at the University of Illinois Urbana-Champaign (UIUC)}
3+
4+
\maketitle
5+
6+
# Overview
7+
This Design Document describes UIUC's implementation of the MISC system as defined by MITRE for eCTF 2024. The MISC system builds the platform for secure communication between medical devices through the use of a central Application Processor (AP) and various Components. While the reference design is considered insecure, our implementation aims to provide a secure and robust system that meets the security requirements outlined by MITRE.
8+
9+
We started our design by analyzing the security requirements and creating the conceptual protocols and cryptographic schemes that would meet these requirements.
10+
11+
## Rust
12+
13+
Our design is built using Rust, a systems programming language that provides memory safety, a strong type system, and a minimal runtime. Crucially, Rust protects us from common security vulnerabilities such as buffer overflows. That being said, Rust is not a silver bullet, and we must still be careful to avoid other security pitfalls.
14+
15+
There were quite a few challenges related to using Rust. In particular, the embedded platform that we are building on (Analog Devices MAX78000FTHR) did not have a stable, public Rust toolchain available online. To solve this, we implemented the peripheral drivers and built our own Hardware Abstraction Layer (HAL) from scratch.
16+
17+
Another challenge was that we were required to support the execution of post boot code which is written in C. Not only that, but the C code needed to be able to call back into our Rust code in order to use our secure communication layer. This post boot code also requires the availability of functions from both the standard C library and the MSDK. We rewrote these functions in Rust and provided a C ABI for them so the linker could provide them to the post boot C code.

docs/2-hide_protocol.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# HIDE Protocol Communication Layer
2+
We implement an extra communication layer between the I2C layer and the application layer, which we refer to as the HIDE protocol. The HIDE protocol ensures that all messages maintain confidentiality, integrity, authenticity, and non-replayability. We require all messages sent between the AP and the Component to use HIDE.
3+
4+
HIDE effectively turns each application message into a three-way challenge-response handshake. The sender first initiates a message request. The receiver will then send a random, encrypted challenge. The sender will then decrypt the challenge, solve it, and encrypt the challenge response to be sent along with the actual message. To solve the challenge nonce, the sender must perform a bitwise XOR of `0x55` with each byte in the challenge nonce.
5+
6+
We use the Authenticated Encryption (AE) cipher, [Ascon-128](https://ascon.iaik.tugraz.at/), for our cryptographic scheme. We chose Ascon since it was selected in the NIST Lightweight Cryptography competition and has a masked software implementation that has been tested against various power analysis and hardware attacks.
7+
8+
We use Ascon's associated data feature to validate each message that uses encryption. The associated data is 8 bytes long, with the first 4 bytes being the component ID, the fifth byte being the HIDE message magic byte, and the last three bytes being null bytes.
9+
10+
Each direction of communication uses a different symmetric encryption key, meaning there are two encryption keys:
11+
12+
- $K_{AP,C}$ is the key for messages sent from the Application Processor to the Component.
13+
- $K_{C,AP}$ is the key for messages sent from the Component to the AP.
14+
15+
Every AP and Component built from the same deployment will share the same keys. This allows any Component to communicate with an AP from the same deployment.
16+
17+
## HIDE Secure Protocol
18+
19+
```{.mermaid loc=img #fig:hide-secure caption="HIDE secure communications protocol"}
20+
sequenceDiagram
21+
participant AP as Device A<br />Application Processor<br />(or Component)
22+
participant C as Device B<br />Component<br />(or Application Processor)
23+
24+
AP ->> C: HIDE_PKT_REQ_SECURE
25+
26+
Note over C: Generates a challenge nonce
27+
28+
C ->> AP: (HIDE_PKT_CHAL_SEND)
29+
C -->> AP: (Unencrypted): Ascon Nonce A
30+
C -->> AP: (Encrypted): Challenge Nonce
31+
C -->> AP: (Encrypted): Random bytes
32+
C -->> AP: (Unencrypted): Ascon Tag
33+
34+
Note over AP: Receives, decrypts, and <br/>solves the challenge nonce
35+
36+
AP ->> C: (HIDE_PKT_CHAL_RESP)
37+
AP -->> C: (Unencrypted): Ascon Nonce B
38+
AP -->> C: (Encrypted): Solved Challenge Nonce
39+
AP -->> C: (Encrypted): Message, padded with random bytes
40+
AP -->> C: (Unencrypted): Ascon Tag
41+
42+
alt Challenge Nonce Solve is Incorrect
43+
Note over C: Reset transaction
44+
end
45+
```
46+
47+
If at any point the encryption or decryption of a HIDE message using the Ascon cipher fails (such as invalidation due to message bit-flips or incorrect associated data), our secure communication functions will return an error.
48+
49+
Messages sent using HIDE can have a length up to 80 bytes. When HIDE interfaces are being used in the post boot code, the message length is limited to 64 bytes and the message length is encoded as an 8-bit integer in the first byte of the message. The remaining bytes are padded with random bytes. MISC messages are also limited to 64 bytes in length.
50+
51+
### HIDE_PKT_REQ_SECURE
52+
Sent by any device to initial a secure communication session with another device. This packet is unencrypted and contains the magic bytes corresponding to a secure request.
53+
54+
| Name | Offset | Size (bytes) | Content |
55+
| --------- | ------ | ------------ | ----------- |
56+
| Magic | `0x00` | 10 | `\x40` * 10 |
57+
58+
### HIDE_PKT_CHAL_SEND
59+
Sent by the receiver of a secure request to initiate the challenge-response handshake. This packet contains the Ascon Nonce, the encrypted challenge nonce, and random bytes for padding.
60+
61+
| Name | Offset | Size (bytes) | Content |
62+
| ------------------------- | ------ | ------------ | ----------- |
63+
| Ascon Nonce | `0x00` | 16 | `\x?? * 16` |
64+
| Encrypted Challenge Nonce | `0x10` | 16 | `\x?? * 16` |
65+
| Encrypted Random Bytes | `0x20` | 80 | `\x?? * 80` |
66+
| Ascon Tag | `0x70` | 16 | `\x?? * 16` |
67+
68+
> [!WARNING]
69+
> Ascon Nonce should be randomly uniquely generated for all messages
70+
71+
### CHAL_RESP
72+
Sent by the sender of a secure request to complete the challenge-response handshake. This packet contains the Ascon Nonce, the encrypted solved challenge nonce, and the message to be sent.
73+
74+
| Name | Offset | Size (bytes) | Content |
75+
| -------------------------- | ------ | ------------ | ----------- |
76+
| Ascon Nonce | `0x00` | 16 | `\x?? * 16` |
77+
| Encrypted Solved Nonce | `0x10` | 16 | `\x?? * 16` |
78+
| Encrypted Message + Random | `0x20` | 80 | `\x?? * 80` |
79+
| Ascon Tag | `0x70` | 16 | `\x?? * 16` |
80+
81+
> [!WARNING]
82+
> Ascon Nonce should be randomly uniquely generated for all messages
83+
84+
## HIDE List Protocol
85+
86+
As part of the MISC system, we also must implement functionality to list all Components connected to the AP. We would use the HIDE secure protocol to enumerate I2C addresses and discover components, however, the HIDE secure protocol uses a Component's full ID as associated data during the encryption and decryption process. During this discovery process, we do not know the full ID of any Component with the exception of the Components which are provisioned for the AP. Even then, we cannot use these provisioned Component IDs in the case that a different valid Component shares the same I2C address. So, we decided to implement an extension to the HIDE protocol, which we refer to as the HIDE list protocol. This is only supported when the AP is communicating with a Component.
87+
88+
The AP will send an unencrypted request packet which contains the magic bytes corresponding to a list request. The Component will then respond immediately with its 4-byte Component ID.
89+
90+
```{.mermaid loc=img #fig:hide-list caption="HIDE list protocol"}
91+
sequenceDiagram
92+
participant AP as Application Processor
93+
AP ->> C: (Unencrypted): HIDE_PKT_REQ_LIST
94+
C ->> AP: (Unencrypted): Component ID
95+
participant C as Component
96+
```
480 KB
Binary file not shown.

0 commit comments

Comments
 (0)