nsc.h
2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**********************************************************
*
* @file : nsc.h
* @author : HaewonSeo
*
* @note : Non-Secure callable
**********************************************************/
#ifndef __NSC_H__
#define __NSC_H__
#include <arm_cmse.h>
#include <stdio.h>
#include <stdlib.h>
#include "NuMicro.h"
#include "M2351_crypto.h"
#include "MAX30102.h"
#define DEMO 1
#define SUCCESS 1
#define FAIL 0
// Raw HR & SPo2 data from FIFO
extern volatile int32_t hr_val;
extern volatile int32_t spo2_val;
/* typedef for NonSecure callback functions */
typedef __NONSECURE_CALL void (*NonSecure_funcptr)(uint32_t);
extern volatile uint32_t millis_counter;
extern float beatsPerMinute;
extern uint32_t beatAvg;
typedef struct s_netData
{
char *data;
int len;
} t_netData;
typedef struct s_digitallySignedData
{
uint8_t data[17];
uint8_t pubKey1[25];
uint8_t pubKey2[25];
uint8_t R[25];
uint8_t S[25];
} t_digitallySignedData;
__NONSECURE_ENTRY
uint32_t GetSystemCoreClock(void);
/*----------------------------------------------------------------------------
NonSecure callable function for NonSecure callback
*----------------------------------------------------------------------------*/
__NONSECURE_ENTRY
int32_t Secure_OLED_On_callback(NonSecure_funcptr *callback);
__NONSECURE_ENTRY
int32_t Secure_OLED_On_callback(NonSecure_funcptr *callback);
/*----------------------------------------------------------------------------
MAX30102 Heart-Rate Sensor functions exported to NonSecure application
Must place in Non-secure Callable
*----------------------------------------------------------------------------*/
__NONSECURE_ENTRY
uint32_t Get_BPM();
__NONSECURE_ENTRY
uint32_t Get_EncryptedDigitallySignedData();
/*----------------------------------------------------------------------------
CRYPTO functions exported to NonSecure application
Must place in Non-secure Callable
*----------------------------------------------------------------------------*/
__NONSECURE_ENTRY
int32_t Encrypt_data(uint8_t *,uint8_t *, uint32_t);
__NONSECURE_ENTRY
int32_t Decrypt_data(uint8_t *,uint8_t *, uint32_t);
__NONSECURE_ENTRY
void M2351_LoadKey();
__NONSECURE_ENTRY
void M2351_DeleteKey();
/*----------------------------------------------------------------------------
PRINT functions exported to NonSecure application
Must place in Non-secure Callable
*----------------------------------------------------------------------------*/
__NONSECURE_ENTRY
int32_t printBlock(uint8_t *);
__NONSECURE_ENTRY
int32_t printSecure(char *,void *,uint8_t);
__NONSECURE_ENTRY
int32_t printDigitallySignedData(t_digitallySignedData *dsd);
#endif /* __NSC_H__ */