1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Crypto Component                                                 */
16 /**                                                                       */
17 /**   NULL Cipher                                                         */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #include "nx_crypto_null.h"
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  FUNCTION                                               RELEASE        */
27 /*                                                                        */
28 /*    _nx_crypto_method_null_init                          PORTABLE C     */
29 /*                                                           6.1          */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Timothy Stapko, Microsoft Corporation                               */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*     This function acts as a placeholder for TLS ciphersuites that do   */
37 /*     not use a ciper for a particular operation. For example, the PSK   */
38 /*     ciphersuite TLS_PSK_WITH_AES_128_CBC_SHA uses AES and SHA-1 but    */
39 /*     no public cipher (e.g. RSA).                                       */
40 /*                                                                        */
41 /*  INPUT                                                                 */
42 /*                                                                        */
43 /*    method                                Crypto Method Object          */
44 /*    key                                   Key                           */
45 /*    key_size_in_bits                      Size of the key, in bits      */
46 /*    handle                                Handle, specified by user     */
47 /*    crypto_metadata                       Metadata area                 */
48 /*    crypto_metadata_size                  Size of the metadata area     */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    None                                                                */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
67 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
_nx_crypto_method_null_init(struct NX_CRYPTO_METHOD_STRUCT * method,UCHAR * key,NX_CRYPTO_KEY_SIZE key_size_in_bits,VOID ** handle,VOID * crypto_metadata,ULONG crypto_metadata_size)71 NX_CRYPTO_KEEP UINT  _nx_crypto_method_null_init(struct NX_CRYPTO_METHOD_STRUCT *method,
72                                                  UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits,
73                                                  VOID **handle,
74                                                  VOID *crypto_metadata,
75                                                  ULONG crypto_metadata_size)
76 {
77     NX_CRYPTO_PARAMETER_NOT_USED(method);
78     NX_CRYPTO_PARAMETER_NOT_USED(key);
79     NX_CRYPTO_PARAMETER_NOT_USED(key_size_in_bits);
80     NX_CRYPTO_PARAMETER_NOT_USED(handle);
81     NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata);
82     NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata_size);
83 
84     return(NX_CRYPTO_SUCCESS);
85 }
86 
87 
88 /**************************************************************************/
89 /*                                                                        */
90 /*  FUNCTION                                               RELEASE        */
91 /*                                                                        */
92 /*    _nx_crypto_method_null_cleanup                      PORTABLE C      */
93 /*                                                           6.1          */
94 /*  AUTHOR                                                                */
95 /*                                                                        */
96 /*    Timothy Stapko, Microsoft Corporation                               */
97 /*                                                                        */
98 /*  DESCRIPTION                                                           */
99 /*                                                                        */
100 /*    This function cleans up the crypto metadata.                        */
101 /*                                                                        */
102 /*  INPUT                                                                 */
103 /*                                                                        */
104 /*    crypto_metadata                       Crypto metadata               */
105 /*                                                                        */
106 /*  OUTPUT                                                                */
107 /*                                                                        */
108 /*    status                                Completion status             */
109 /*                                                                        */
110 /*  CALLS                                                                 */
111 /*                                                                        */
112 /*    None                                                                */
113 /*                                                                        */
114 /*  CALLED BY                                                             */
115 /*                                                                        */
116 /*    Application Code                                                    */
117 /*                                                                        */
118 /*  RELEASE HISTORY                                                       */
119 /*                                                                        */
120 /*    DATE              NAME                      DESCRIPTION             */
121 /*                                                                        */
122 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
123 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
124 /*                                            resulting in version 6.1    */
125 /*                                                                        */
126 /**************************************************************************/
_nx_crypto_method_null_cleanup(VOID * crypto_metadata)127 NX_CRYPTO_KEEP UINT  _nx_crypto_method_null_cleanup(VOID *crypto_metadata)
128 {
129     NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata);
130 
131     return(NX_CRYPTO_SUCCESS);
132 }
133 
134 
135 /**************************************************************************/
136 /*                                                                        */
137 /*  FUNCTION                                               RELEASE        */
138 /*                                                                        */
139 /*    _nx_crypto_method_aes_operation                    PORTABLE C       */
140 /*                                                           6.1          */
141 /*  AUTHOR                                                                */
142 /*                                                                        */
143 /*    Timothy Stapko, Microsoft Corporation                               */
144 /*                                                                        */
145 /*  DESCRIPTION                                                           */
146 /*                                                                        */
147 /*    This function encrypts and decrypts a message using                 */
148 /*    the AES algorithm.                                                  */
149 /*                                                                        */
150 /*  INPUT                                                                 */
151 /*                                                                        */
152 /*    op                                    AES operation                 */
153 /*    handle                                Crypto handle                 */
154 /*    method                                Cryption Method Object        */
155 /*    key                                   Encryption Key                */
156 /*    key_size_in_bits                      Key size in bits              */
157 /*    input                                 Input data                    */
158 /*    input_length_in_byte                  Input data size               */
159 /*    iv_ptr                                Initial vector                */
160 /*    output                                Output buffer                 */
161 /*    output_length_in_byte                 Output buffer size            */
162 /*    crypto_metadata                       Metadata area                 */
163 /*    crypto_metadata_size                  Metadata area size            */
164 /*    packet_ptr                            Pointer to packet             */
165 /*    nx_crypto_hw_process_callback         Callback function pointer     */
166 /*                                                                        */
167 /*  OUTPUT                                                                */
168 /*                                                                        */
169 /*    status                                Completion status             */
170 /*                                                                        */
171 /*  CALLS                                                                 */
172 /*                                                                        */
173 /*    None                                                                */
174 /*                                                                        */
175 /*  CALLED BY                                                             */
176 /*                                                                        */
177 /*    Application Code                                                    */
178 /*                                                                        */
179 /*  RELEASE HISTORY                                                       */
180 /*                                                                        */
181 /*    DATE              NAME                      DESCRIPTION             */
182 /*                                                                        */
183 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
184 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
185 /*                                            resulting in version 6.1    */
186 /*                                                                        */
187 /**************************************************************************/
_nx_crypto_method_null_operation(UINT op,VOID * handle,struct NX_CRYPTO_METHOD_STRUCT * method,UCHAR * key,NX_CRYPTO_KEY_SIZE key_size_in_bits,UCHAR * input,ULONG input_length_in_byte,UCHAR * iv_ptr,UCHAR * output,ULONG output_length_in_byte,VOID * crypto_metadata,ULONG crypto_metadata_size,VOID * packet_ptr,VOID (* nx_crypto_hw_process_callback)(VOID * packet_ptr,UINT status))188 NX_CRYPTO_KEEP UINT  _nx_crypto_method_null_operation(UINT op,      /* Encrypt, Decrypt, Authenticate */
189                                                       VOID *handle, /* Crypto handler */
190                                                       struct NX_CRYPTO_METHOD_STRUCT *method,
191                                                       UCHAR *key,
192                                                       NX_CRYPTO_KEY_SIZE key_size_in_bits,
193                                                       UCHAR *input,
194                                                       ULONG input_length_in_byte,
195                                                       UCHAR *iv_ptr,
196                                                       UCHAR *output,
197                                                       ULONG output_length_in_byte,
198                                                       VOID *crypto_metadata,
199                                                       ULONG crypto_metadata_size,
200                                                       VOID *packet_ptr,
201                                                       VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status))
202 {
203     NX_CRYPTO_PARAMETER_NOT_USED(op);
204     NX_CRYPTO_PARAMETER_NOT_USED(handle);
205     NX_CRYPTO_PARAMETER_NOT_USED(method);
206     NX_CRYPTO_PARAMETER_NOT_USED(key);
207     NX_CRYPTO_PARAMETER_NOT_USED(key_size_in_bits);
208     NX_CRYPTO_PARAMETER_NOT_USED(input);
209     NX_CRYPTO_PARAMETER_NOT_USED(input_length_in_byte);
210     NX_CRYPTO_PARAMETER_NOT_USED(iv_ptr);
211     NX_CRYPTO_PARAMETER_NOT_USED(output);
212     NX_CRYPTO_PARAMETER_NOT_USED(output_length_in_byte);
213     NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata);
214     NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata_size);
215     NX_CRYPTO_PARAMETER_NOT_USED(packet_ptr);
216     NX_CRYPTO_PARAMETER_NOT_USED(nx_crypto_hw_process_callback);
217 
218     return(NX_CRYPTO_SUCCESS);
219 }
220 
221