File tree Expand file tree Collapse file tree 5 files changed +17
-29
lines changed
examples/tutorials/root_of_trust
encryption_service_milestone_one
encryption_service_milestone_three
encryption_service_milestone_two
questionable_service_milestone_one
suspicious_service_milestone_one Expand file tree Collapse file tree 5 files changed +17
-29
lines changed Original file line number Diff line number Diff line change 4
4
// plaintexts over UART and encrypts them, logging status over IPC back to the screen
5
5
// application.
6
6
7
- #include "libtock/tock.h"
8
7
#include <stdio.h>
9
8
#include <stdlib.h>
9
+ #include <string.h>
10
10
11
11
#include <libtock-sync/interface/console.h>
12
12
#include <libtock/kernel/ipc.h>
13
+ #include <libtock/tock.h>
13
14
14
15
#define LOG_WIDTH 32
15
16
@@ -63,12 +64,8 @@ static int setup_logging() {
63
64
static int log_to_screen (const char * message ) {
64
65
returncode_t ret ;
65
66
66
- // Copy up to the log buffer's size of the message, with room for a null byte.
67
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
68
- memcpy (log_buf , message , len );
69
-
70
- // Add the null byte.
71
- log_buf [len ] = '\0' ;
67
+ // Load the log buffer with our message
68
+ strlcpy (log_buf , message , LOG_WIDTH );
72
69
73
70
// Start the logging process.
74
71
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change 4
4
// plaintexts over UART and encrypts them, logging status over IPC back to the screen
5
5
// application.
6
6
7
- #include "libtock/tock.h"
8
7
#include <stdio.h>
9
8
#include <stdlib.h>
9
+ #include <string.h>
10
10
11
11
#include <libtock-sync/interface/console.h>
12
12
#include <libtock/kernel/ipc.h>
13
+ #include <libtock/tock.h>
13
14
14
15
#include "oracle.h"
15
16
@@ -66,12 +67,8 @@ static int setup_logging() {
66
67
static int log_to_screen (const char * message ) {
67
68
returncode_t ret ;
68
69
69
- // Copy up to the log buffer's size of the message, with room for a null byte.
70
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
71
- memcpy (log_buf , message , len );
72
-
73
- // Add the null byte.
74
- log_buf [len ] = '\0' ;
70
+ // Load the log buffer with our message
71
+ strlcpy (log_buf , message , LOG_WIDTH );
75
72
76
73
// Start the logging process.
77
74
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change 4
4
// plaintexts over UART and encrypts them, logging status over IPC back to the screen
5
5
// application.
6
6
7
- #include "libtock/tock.h"
8
7
#include <stdio.h>
9
8
#include <stdlib.h>
9
+ #include <string.h>
10
10
11
11
#include <libtock-sync/interface/console.h>
12
12
#include <libtock/kernel/ipc.h>
13
+ #include <libtock/tock.h>
13
14
14
15
#define LOG_WIDTH 32
15
16
@@ -63,12 +64,8 @@ static int setup_logging() {
63
64
static int log_to_screen (const char * message ) {
64
65
returncode_t ret ;
65
66
66
- // Copy up to the log buffer's size of the message, with room for a null byte.
67
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
68
- memcpy (log_buf , message , len );
69
-
70
- // Add the null byte.
71
- log_buf [len ] = '\0' ;
67
+ // Load the log buffer with our message
68
+ strlcpy (log_buf , message , LOG_WIDTH );
72
69
73
70
// Start the logging process.
74
71
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ int main(void) {
99
99
}
100
100
101
101
// Bring everything down!
102
- syscall_return_t cr = command (0x99998 , 1 , 0 , 0 );
102
+ syscall_return_t cr = command (0x99999 , 2 , 0 , 0 );
103
103
if (cr .type != TOCK_SYSCALL_SUCCESS ) {
104
104
return tock_command_return_novalue_to_returncode (cr );
105
105
}
Original file line number Diff line number Diff line change 3
3
// When selected by the main screen HWRoT Demo application, attempts to dump its
4
4
// own SRAM, followed by the SRAM of the encryption service application.
5
5
6
- #include "libtock/tock.h"
7
6
#include <stdio.h>
8
7
#include <stdlib.h>
8
+ #include <string.h>
9
9
10
10
#include <libtock/kernel/ipc.h>
11
+ #include <libtock/tock.h>
11
12
12
13
#define ENCRYPTION_SRAM_START 0x2000A000
13
14
#define ENCRYPTION_SRAM_END 0x2000BFFF
@@ -64,12 +65,8 @@ static int setup_logging() {
64
65
static int log_to_screen (const char * message ) {
65
66
returncode_t ret ;
66
67
67
- // Copy up to the log buffer's size of the message, with room for a null byte.
68
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
69
- memcpy (log_buf , message , len );
70
-
71
- // Add the null byte.
72
- log_buf [len ] = '\0' ;
68
+ // Load the log buffer with our message
69
+ strlcpy (log_buf , message , LOG_WIDTH );
73
70
74
71
// Start the logging process.
75
72
ret = ipc_notify_service (screen_service );
You can’t perform that action at this time.
0 commit comments