Skip to content

Commit 8f5d3f1

Browse files
committed
Use the client name in the print messages
This helps keeping track of who is doing what.
1 parent 7baae16 commit 8f5d3f1

File tree

6 files changed

+37
-105
lines changed

6 files changed

+37
-105
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ This number can only be written by one box, but read by all boxes.
1212

1313
This demo contains three secure boxes:
1414

15-
1. The secure number vault. This box stores one number that can only be written to by client A, but read by everyone.
15+
1. The secure number vault. This box stores one number that can only be written to by Client A, but read by everyone.
1616
1. Client A, which attempts to write (and succeeds) and read the secure number.
1717
1. Client B, which attempts to write (but fails) and read the secure number.
1818

19-
The insecure box 0 also attempts to write (but fails) and read the secure number.
19+
As usual, all the code/data that is not protected by a secure box ends up in the public box (also known as box 0), which is visible by all other boxes and, hence, insecure. The public box also attempts to write (but fails) and read the secure number.
2020

2121
Supported devices:
2222

2323
| Target | Toolchain | Baud rate |
2424
|--------|-----------|-----------|
2525
| `K64F` | `GCC_ARM` | 9600 |
2626

27-
Latest release: [mbed-os-5.3.0](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/tag/mbed-os-5.3.0). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).
27+
Latest release: [mbed-os-5.3.x](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/tag/latest). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).
2828

2929
## Quickstart
3030

@@ -45,18 +45,16 @@ $ screen /dev/tty.usbmodem1422 9600
4545
You will see an output similar to the following one:
4646

4747
```
48-
**** uVisor secure number store example *****
49-
Trusted client a has box id 2
50-
2: Wrote '0xfffffed4'
51-
1: Read '0xfffffed4'
52-
1: Permission denied. This client cannot write the secure number '0xfffffe0c'
53-
0: Read '0xfffffed4'
54-
0: Permission denied. This client cannot write the secure number '0x00000019'
55-
2: Read '0xfffffed4'
56-
2: Wrote '0xfffffda8'
57-
2: Read '0xfffffda8'
58-
1: Permission denied. This client cannot write the secure number '0xfffffc18'
59-
2: Wrote '0xfffffc7c'
48+
***** uVisor secure number store example *****
49+
vault : Only client_a can write into the vault
50+
vault : All clients can read the vault
51+
client_b: Attempt to write 0xFFFFFED4 (denied)
52+
client_a: Attempt to read : 0x00000000 (granted)
53+
client_a: Attempt to write 0xFFFFFE0C (granted)
54+
public : Attempt to read : 0xFFFFFE0C (granted)
55+
public : Attempt to write 0x00000019 (denied)
56+
client_b: Attempt to read : 0xFFFFFE0C (granted)
57+
client_a: Attempt to read : 0xFFFFFE0C (granted)
6058
...
6159
```
6260

source/client_a.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ static void box_async_runner(void)
5656
while (1) {
5757
uint32_t ret;
5858
int status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
59-
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n",
60-
(char) uvisor_box_id_self() + '0',
61-
(ret == 0) ? "Wrote" :
62-
"Permission denied. This client cannot write the secure number",
63-
(unsigned int) number);
59+
uvisor_ctx->pc->printf("client_a: Attempt to write 0x%08X (%s)\r\n",
60+
(unsigned int) number, (ret == 0) ? "granted" : "denied");
6461
/* FIXME: Add better error handling. */
6562
if (!status) {
6663
break;
@@ -76,7 +73,7 @@ static void box_sync_runner(void)
7673
while (1) {
7774
/* Synchronous access to the number. */
7875
const uint32_t number = secure_number_get_number();
79-
uvisor_ctx->pc->printf("%c: Read '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (unsigned int) number);
76+
uvisor_ctx->pc->printf("client_a: Attempt to read : 0x%08X (granted)\r\n", (unsigned int) number);
8077

8178
Thread::wait(7000);
8279
}

source/client_b.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,16 @@ static void client_b_main(const void *)
6565
while (1) {
6666
uint32_t ret;
6767
int status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
68-
uvisor_ctx->pc->printf("%c: %s '0x%08x'\r\n",
69-
(char) uvisor_box_id_self() + '0',
70-
(ret == 0) ? "Wrote" :
71-
"Permission denied. This client cannot write the secure number",
72-
(unsigned int) number);
68+
uvisor_ctx->pc->printf("client_b: Attempt to write 0x%08X (%s)\r\n",
69+
(unsigned int) number, (ret == 0) ? "granted" : "denied");
7370
if (!status) {
7471
break;
7572
}
7673
}
7774

7875
/* Synchronous access to the number. */
7976
number = secure_number_get_number();
80-
uvisor_ctx->pc->printf("%c: Read '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (unsigned int) number);
77+
uvisor_ctx->pc->printf("client_b: Attempt to read : 0x%08X (granted)\r\n", (unsigned int) number);
8178

8279
Thread::wait(3000);
8380
}

source/main.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ static void main_async_runner(void)
5353
/* TODO typesafe return codes */
5454
uint32_t ret;
5555
status = rpc_fncall_wait(result, UVISOR_WAIT_FOREVER, &ret);
56-
printf("%c: %s '0x%08x'\r\n",
57-
(char) uvisor_box_id_self() + '0',
58-
(ret == 0) ? "Wrote" :
59-
"Permission denied. This client cannot write the secure number",
60-
(unsigned int) number);
56+
printf("public : Attempt to write 0x%08X (%s)\r\n",
57+
(unsigned int) number, (ret == 0) ? "granted" : "denied");
6158
if (!status) {
6259
break;
6360
}
@@ -72,7 +69,7 @@ static void main_sync_runner(void)
7269
while (1) {
7370
/* Synchronous access to the number. */
7471
const uint32_t number = secure_number_get_number();
75-
printf("%c: Read '0x%08x'\r\n", (char) uvisor_box_id_self() + '0', (unsigned int) number);
72+
printf("public : Attempt to read : 0x%08X (granted)\r\n", (unsigned int) number);
7673

7774
Thread::wait(11000);
7875
}

source/secure_number.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static int set_number(uint32_t number)
8282
static const char * trusted_namespace = "client_a";
8383
if (memcmp(name, trusted_namespace, sizeof(*trusted_namespace)) == 0) {
8484
uvisor_ctx->trusted_id = id;
85-
uvisor_ctx->pc->printf("Trusted client a has box id %u\r\n", id);
8685
} else {
8786
return 1;
8887
}
@@ -119,6 +118,8 @@ static void number_store_main(const void *)
119118
(TFN_Ptr) set_number
120119
};
121120

121+
uvisor_ctx->pc->printf("vault : Only client_a can write into the vault\r\n");
122+
uvisor_ctx->pc->printf("vault : All clients can read the vault\r\n");
122123
while (1) {
123124
int status;
124125

test/log.txt

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,13 @@
1-
2-
**** uVisor secure number store example *****
3-
Trusted client a has box id 2
4-
2: Wrote '0xfffffed4'
5-
1: Read '0xfffffed4'
6-
1: Failed to write '0xfffffe0c'
7-
0: Read '0xfffffed4'
8-
0: Failed to write '0x00000019'
9-
2: Read '0xfffffed4'
10-
2: Wrote '0xfffffda8'
11-
2: Read '0xfffffda8'
12-
1: Failed to write '0xfffffc18'
13-
2: Wrote '0xfffffc7c'
14-
1: Read '0xfffffc7c'
15-
2: Read '0xfffffc7c'
16-
2: Wrote '0xfffffb50'
17-
1: Failed to write '0xfffffa24'
18-
2: Read '0xfffffb50'
19-
0: Read '0xfffffb50'
20-
0: Failed to write '0xfffffe89'
21-
2: Wrote '0xfffffa24'
22-
2: Read '0xfffffa24'
23-
1: Read '0xfffffa24'
24-
1: Failed to write '0xfffff830'
25-
2: Wrote '0xfffff8f8'
26-
2: Read '0xfffff8f8'
27-
2: Wrote '0xfffff7cc'
28-
2: Read '0xfffff7cc'
29-
1: Failed to write '0xfffff63c'
30-
1: Read '0xfffff7cc'
31-
0: Read '0xfffff7cc'
32-
2: Wrote '0xfffff6a0'
33-
2: Read '0xfffff6a0'
34-
1: Failed to write '0xfffff448'
35-
0: Failed to write '0xfffffcf9'
36-
2: Wrote '0xfffff574'
37-
2: Read '0xfffff574'
38-
1: Read '0xfffff574'
39-
2: Wrote '0xfffff448'
40-
2: Read '0xfffff448'
41-
1: Failed to write '0xfffff254'
42-
0: Read '0xfffff448'
43-
2: Wrote '0xfffff31c'
44-
2: Read '0xfffff31c'
45-
1: Read '0xfffff31c'
46-
1: Failed to write '0xfffff060'
47-
2: Wrote '0xfffff1f0'
48-
2: Read '0xfffff1f0'
49-
0: Failed to write '0xfffffb69'
50-
2: Wrote '0xfffff0c4'
51-
2: Read '0xfffff0c4'
52-
1: Failed to write '0xffffee6c'
53-
1: Read '0xfffff0c4'
54-
2: Wrote '0xffffef98'
55-
2: Read '0xffffef98'
56-
0: Read '0xffffef98'
57-
1: Failed to write '0xffffec78'
58-
2: Wrote '0xffffee6c'
59-
2: Read '0xffffee6c'
60-
1: Read '0xffffee6c'
61-
2: Wrote '0xffffed40'
62-
2: Read '0xffffed40'
63-
1: Failed to write '0xffffea84'
64-
0: Failed to write '0xfffff9d9'
65-
2: Wrote '0xffffec14'
66-
2: Read '0xffffec14'
67-
0: Read '0xffffec14'
68-
1: Failed to write '0xffffe890'
69-
1: Read '0xffffec14'
70-
2: Wrote '0xffffeae8'
71-
2: Read '0xffffeae8'
1+
2+
***** uVisor secure number store example *****
3+
vault : Only client_a can write into the vault
4+
vault : All clients can read the vault
5+
client_b: Attempt to write 0xFFFFFED4 (denied)
6+
client_a: Attempt to read : 0x00000000 (granted)
7+
client_a: Attempt to write 0xFFFFFE0C (granted)
8+
public : Attempt to read : 0xFFFFFE0C (granted)
9+
public : Attempt to write 0x00000019 (denied)
10+
client_b: Attempt to read : 0xFFFFFE0C (granted)
11+
client_a: Attempt to read : 0xFFFFFE0C (granted)
12+
client_a: Attempt to write 0xFFFFFC18 (granted)
13+
public : Attempt to read : 0xFFFFFC18 (granted)

0 commit comments

Comments
 (0)