Jetson Linux API Reference

32.6.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tegra_se.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2021, NVIDIA Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10 
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13 
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
35 #ifndef __TEGRA_SE_H__
36 #define __TEGRA_SE_H__
37 
38 #include <tegra_se_internal.h>
39 
143 /*
144  * @brief acquires SE hardware mutex and initializes SE driver
145  *
146  * @return NO_ERROR if successful
147  *
148  * @note This function should ALWAYS be called BEFORE interacting
149  * with SE
150  */
151 uint32_t se_acquire(void);
152 
153 /*
154  * @brief releases SE hardware
155  *
156  * @return NO_ERROR if successful
157  *
158  * @note This function should ALWAYS be called AFTER interacting
159  * with SE
160  */
161 void se_release(void);
162 
163 /*
164  * @brief derives root key from SE keyslot
165  *
166  * @param *root_key [out] root key will be written to this buffer
167  * @param root_key_len [in] length of root_key buffer
168  * @param *fv [in] base address of fixed vector (fv)
169  * @param fv_len [in] length of fixed vector
170  * @param keyslot [in] keyslot index of the root key source
171  *
172  * @return NO_ERROR if successful
173  */
174 uint32_t se_derive_root_key(uint8_t *root_key, size_t root_key_len, uint8_t *fv,
175  size_t fv_len, uint32_t keyslot);
176 
177 /*
178  * @brief: Write a key into a SE keyslot
179  *
180  * @param *key_in [in] base address of the key
181  * @param keylen [in] key length
182  * @param key_quad_sel [in] key QUAD selection
183  * @param keyslot [in] keyslot index
184  *
185  * @return NO_ERROR if successful
186  */
187 int se_write_keyslot(uint8_t *key_in, uint32_t keylen, uint32_t key_quad_sel, uint32_t keyslot);
188 
189 /*
190  * @brief Clear SE keyslots that hold secret keys
191  *
192  * @return NO_ERROR if successful
193  *
194  * @note This function should ALWAYS be called so secret keys do
195  * not persist in SE keyslots.
196  */
197 uint32_t se_clear_aes_keyslots(void);
198 
199 typedef struct tegra_se_cmac_context se_cmac_ctx;
200 
207 
213 void tegra_se_cmac_free(se_cmac_ctx *se_cmac);
214 
227 int tegra_se_cmac_init(se_cmac_ctx *se_cmac, se_aes_keyslot_t keyslot,
228  uint32_t keylen);
241 int tegra_se_cmac_update(se_cmac_ctx *se_cmac, void *data, uint32_t dlen);
242 
257 int tegra_se_cmac_final(se_cmac_ctx *se_cmac, uint8_t *out, uint32_t *poutlen);
258 
301 int se_nist_sp_800_108_with_cmac(se_aes_keyslot_t keyslot,
302  uint32_t key_len,
303  char const *context,
304  char const *label,
305  uint32_t dk_len,
306  uint8_t *out_dk);
307 
310 #endif /* __TEGRA_SE_H__ */
void se_release(void)
int tegra_se_cmac_init(se_cmac_ctx *se_cmac, se_aes_keyslot_t keyslot, uint32_t keylen)
Initialize the SE CMAC from a user-provided key.
uint32_t se_acquire(void)
int se_write_keyslot(uint8_t *key_in, uint32_t keylen, uint32_t key_quad_sel, uint32_t keyslot)
int se_nist_sp_800_108_with_cmac(se_aes_keyslot_t keyslot, uint32_t key_len, char const *context, char const *label, uint32_t dk_len, uint8_t *out_dk)
A hardware-based NIST-SP-800-108 KDF; derives keys from the SE keyslot.
int tegra_se_cmac_update(se_cmac_ctx *se_cmac, void *data, uint32_t dlen)
Caches input data in an SE CMAC.
se_cmac_ctx * tegra_se_cmac_new(void)
Creates an SE CMAC context.
void tegra_se_cmac_free(se_cmac_ctx *se_cmac)
Frees an SE CMAC context.
uint32_t se_clear_aes_keyslots(void)
struct tegra_se_cmac_context se_cmac_ctx
Definition: tegra_se.h:199
uint32_t se_derive_root_key(uint8_t *root_key, size_t root_key_len, uint8_t *fv, size_t fv_len, uint32_t keyslot)
int tegra_se_cmac_final(se_cmac_ctx *se_cmac, uint8_t *out, uint32_t *poutlen)
Finalizes a SE CMAC.