Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls_api.h"
...
...
nx_secure_module_hash_compute(NX_CRYPTO_METHOD *, UINT, UINT, UCHAR *, UINT, void *, UINT, UCHAR *, UINT, UINT *)
Files
loading (4/7)...
SourceVuSTM32 Libraries and Samplesnetxduonx_secure/src/nx_secure_module_hash_compute.c
 
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Secure Component */ /** */ /** Transport Layer Security (TLS) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SECURE_SOURCE_CODE /* Include necessary system files. */ #include "nx_secure_tls.h" #define NX_SECURE_SOURCE_CODE #include "nx_secure_tls_api.h" .../**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* nx_secure_module_hash_compute PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function uses user-supplied HMAC-SHA256 function (in the */ /* proper NX_CRYPTO_METHOD structure) to compute the hash value of */ /* the program memory marked by the symbols EL_SECURE_PROGRAM_BEGIN */ /* and EL_SECURE_PROGRAM_END. */ /* */ /* INPUT */ /* */ /* hmac_sha2_ptr Pointer to NX_CRYPTO_METHOD */ /* structure that contains */ /* HMAC-SHA256 */ /* key User-specified key for */ /* computing the hash */ /* key_length Size of the key, in bytes */ /* output_buffer Output buffer space for */ /* storing the computed HMAC */ /* output_buffer_size Size of the output buffer */ /* actual_size Size of the HMAC message, in */ /* bytes */ /* */ /* OUTPUT */ /* */ /* status Completion status */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* Application Code */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ UINT nx_secure_module_hash_compute(NX_CRYPTO_METHOD *hmac_ptr, UINT start_address, UINT end_address, UCHAR *key, UINT key_length, VOID *metadata, UINT metadata_size, UCHAR *output_buffer, UINT output_buffer_size, UINT *actual_size) { #ifdef NX_SECURE_POWER_ON_SELF_TEST_MODULE_INTEGRITY_CHECK VOID *handler = NX_NULL; UINT status; if(output_buffer_size < 32) return(1); /* Validate the crypto table. */ if(hmac_ptr == NX_NULL) return(1); if(hmac_ptr -> nx_crypto_algorithm != NX_CRYPTO_AUTHENTICATION_HMAC_SHA2_256) return(1); if (hmac_ptr -> nx_crypto_init) { status = hmac_ptr -> nx_crypto_init(hmac_ptr, key, (key_length << 3), &handler, metadata, metadata_size); if (status != NX_CRYPTO_SUCCESS) { return(1); }if (status != NX_CRYPTO_SUCCESS) { ... } }if (hmac_ptr -> nx_crypto_init) { ... } if (hmac_ptr -> nx_crypto_operation == NX_NULL) { return(1); }if (hmac_ptr -> nx_crypto_operation == NX_NULL) { ... } /* Now compute the hash */ status = hmac_ptr -> nx_crypto_operation(NX_CRYPTO_AUTHENTICATE, handler, /* handle, not used */ hmac_ptr, /* Method, not used */ key, (key_length << 3), (UCHAR*)start_address, /* Data start */ end_address - start_address, /* Data Length */ NX_NULL, /* iv_ptr, not used */ output_buffer, output_buffer_size, metadata, metadata_size, NX_NULL, /* packet_ptr, not used. */ NX_NULL);/* HW process callback, not used. */ if (status) { return(1); }if (status) { ... } if (hmac_ptr -> nx_crypto_cleanup) { status = hmac_ptr -> nx_crypto_cleanup(metadata); if (status) { return(1); }if (status) { ... } }if (hmac_ptr -> nx_crypto_cleanup) { ... } *actual_size = (hmac_ptr -> nx_crypto_ICV_size_in_bits >> 3); return(0);/* ... */ #else NX_PARAMETER_NOT_USED(hmac_ptr); NX_PARAMETER_NOT_USED(start_address); NX_PARAMETER_NOT_USED(end_address); NX_PARAMETER_NOT_USED(key); NX_PARAMETER_NOT_USED(key_length); NX_PARAMETER_NOT_USED(metadata); NX_PARAMETER_NOT_USED(metadata_size); NX_PARAMETER_NOT_USED(output_buffer); NX_PARAMETER_NOT_USED(output_buffer_size); NX_PARAMETER_NOT_USED(actual_size); return(0);/* ... */ #endif }{ ... }
Details