1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include <nvtypes.h>
27 
28 //
29 // This file was generated with FINN, an NVIDIA coding tool.
30 // Source file:      cc_drv.finn
31 //
32 
33 
34 
35 #include "nvtypes.h"
36 #include "nvcfg_sdk.h"
37 
38 // CLASS NV_CONF_COMPUTE
39 #define CC_AES_256_GCM_IV_SIZE_BYTES   (0xcU) /* finn: Evaluated from "(96 / 8)" */
40 #define CC_AES_256_GCM_IV_SIZE_DWORD   (0x3U) /* finn: Evaluated from "(CC_AES_256_GCM_IV_SIZE_BYTES / 4)" */
41 #define CC_AES_256_GCM_KEY_SIZE_BYTES  (0x20U) /* finn: Evaluated from "(256 / 8)" */
42 #define CC_AES_256_GCM_KEY_SIZE_DWORD  (0x8U) /* finn: Evaluated from "(CC_AES_256_GCM_KEY_SIZE_BYTES / 4)" */
43 
44 #define CC_HMAC_NONCE_SIZE_BYTES       (0x20U) /* finn: Evaluated from "(256 / 8)" */
45 #define CC_HMAC_NONCE_SIZE_DWORD       (0x8U) /* finn: Evaluated from "(CC_HMAC_NONCE_SIZE_BYTES / 4)" */
46 #define CC_HMAC_KEY_SIZE_BYTES         (0x20U) /* finn: Evaluated from "(256 / 8)" */
47 #define CC_HMAC_KEY_SIZE_DWORD         (0x8U) /* finn: Evaluated from "(CC_HMAC_KEY_SIZE_BYTES / 4)" */
48 
49 #define APM_AES_128_CTR_IV_SIZE_BYTES  (0xcU) /* finn: Evaluated from "(96 / 8)" */
50 #define APM_AES_128_CTR_IV_SIZE_DWORD  (0x3U) /* finn: Evaluated from "(APM_AES_128_CTR_IV_SIZE_BYTES / 4)" */
51 #define APM_AES_128_CTR_KEY_SIZE_BYTES (0x10U) /* finn: Evaluated from "(128 / 8)" */
52 #define APM_AES_128_CTR_KEY_SIZE_DWORD (0x4U) /* finn: Evaluated from "(APM_AES_128_CTR_KEY_SIZE_BYTES / 4)" */
53 
54 // Type is shared between CC control calls and RMKeyStore
55 typedef enum ROTATE_IV_TYPE {
56     ROTATE_IV_ENCRYPT = 0,  // Rotate the IV for encryptBundle
57     ROTATE_IV_DECRYPT = 1,  // Rotate the IV for decryptBundle
58     ROTATE_IV_HMAC = 2,     // Rotate the IV for hmacBundle
59     ROTATE_IV_ALL_VALID = 3, // Rotate the IV for all valid bundles in the KMB
60 } ROTATE_IV_TYPE;
61 
62 typedef struct CC_AES_CRYPTOBUNDLE {
63     NvU32 iv[CC_AES_256_GCM_IV_SIZE_DWORD];
64     NvU32 key[CC_AES_256_GCM_KEY_SIZE_DWORD];
65     NvU32 ivMask[CC_AES_256_GCM_IV_SIZE_DWORD];
66 } CC_AES_CRYPTOBUNDLE;
67 typedef struct CC_AES_CRYPTOBUNDLE *PCC_AES_CRYPTOBUNDLE;
68 
69 typedef struct CC_HMAC_CRYPTOBUNDLE {
70     NvU32 nonce[CC_HMAC_NONCE_SIZE_DWORD];
71     NvU32 key[CC_HMAC_KEY_SIZE_DWORD];
72 } CC_HMAC_CRYPTOBUNDLE;
73 typedef struct CC_HMAC_CRYPTOBUNDLE *PCC_HMAC_CRYPTOBUNDLE;
74 
75 typedef struct CC_KMB {
76     CC_AES_CRYPTOBUNDLE encryptBundle;           // Bundle of encyption material
77 
78     union {
79         CC_HMAC_CRYPTOBUNDLE hmacBundle;  // HMAC bundle used for method stream authenticity
80         CC_AES_CRYPTOBUNDLE  decryptBundle;   // Bundle of decryption material
81     };
82     NvBool bIsWorkLaunch;                        // False if decryption parameters are valid
83 } CC_KMB;
84 typedef struct CC_KMB *PCC_KMB;
85 
86