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 /**   HMAC SHA5 Digest Algorithm (SHA5)                                   */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    nx_crypto_hmac_sha1.h                                PORTABLE C     */
28 /*                                                           6.1          */
29 /*                                                                        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Timothy Stapko, Microsoft Corporation                               */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file defines the NetX HMAC SHA512 algorithm, derived from      */
37 /*    RFC2202. From a user-specified number of input bytes and key, this  */
38 /*    produces a 64-byte (512-bit) digest or sometimes called a hash      */
39 /*    value. The resulting digest is returned in a 64-byte array supplied */
40 /*    by the caller.                                                      */
41 /*                                                                        */
42 /*    It is assumed that nx_api.h and nx_port.h have already been         */
43 /*    included.                                                           */
44 /*                                                                        */
45 /*  RELEASE HISTORY                                                       */
46 /*                                                                        */
47 /*    DATE              NAME                      DESCRIPTION             */
48 /*                                                                        */
49 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
50 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
51 /*                                            resulting in version 6.1    */
52 /*                                                                        */
53 /**************************************************************************/
54 
55 #ifndef  NX_HMAC_SHA5_H
56 #define  NX_HMAC_SHA5_H
57 
58 /* Determine if a C++ compiler is being used.  If so, ensure that standard
59    C is used to process the API information.  */
60 #ifdef __cplusplus
61 
62 /* Yes, C++ compiler is present.  Use standard C.  */
63 extern   "C" {
64 
65 #endif
66 
67 #include "nx_crypto.h"
68 #include "nx_crypto_sha5.h"
69 #include "nx_crypto_hmac.h"
70 
71 #define NX_CRYPTO_HMAC_SHA512_ICV_FULL_LEN_IN_BITS      NX_CRYPTO_SHA512_ICV_LEN_IN_BITS
72 #define NX_CRYPTO_HMAC_SHA384_ICV_FULL_LEN_IN_BITS      NX_CRYPTO_SHA384_ICV_LEN_IN_BITS
73 #define NX_CRYPTO_HMAC_SHA512_224_ICV_FULL_LEN_IN_BITS  NX_CRYPTO_SHA512_224_ICV_LEN_IN_BITS
74 #define NX_CRYPTO_HMAC_SHA512_256_ICV_FULL_LEN_IN_BITS  NX_CRYPTO_SHA512_256_ICV_LEN_IN_BITS
75 
76 /* Define the control block structure for backward compatibility. */
77 #define NX_SHA512_HMAC                          NX_CRYPTO_SHA512_HMAC
78 
79 typedef struct NX_CRYPTO_SHA512_HMAC_STRUCT
80 {
81     NX_CRYPTO_SHA512    nx_sha512_hmac_context;
82     NX_CRYPTO_HMAC      nx_sha512_hmac_metadata;
83 } NX_CRYPTO_SHA512_HMAC;
84 
85 /* Define the function prototypes for HMAC SHA512.  */
86 
87 UINT _nx_crypto_method_hmac_sha512_init(struct  NX_CRYPTO_METHOD_STRUCT *method,
88                                         UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits,
89                                         VOID  **handle,
90                                         VOID  *crypto_metadata,
91                                         ULONG crypto_metadata_size);
92 
93 UINT _nx_crypto_method_hmac_sha512_cleanup(VOID *crypto_metadata);
94 
95 UINT _nx_crypto_method_hmac_sha512_operation(UINT op,      /* Encrypt, Decrypt, Authenticate */
96                                              VOID *handle, /* Crypto handler */
97                                              struct NX_CRYPTO_METHOD_STRUCT *method,
98                                              UCHAR *key,
99                                              NX_CRYPTO_KEY_SIZE key_size_in_bits,
100                                              UCHAR *input,
101                                              ULONG input_length_in_byte,
102                                              UCHAR *iv_ptr,
103                                              UCHAR *output,
104                                              ULONG output_length_in_byte,
105                                              VOID *crypto_metadata,
106                                              ULONG crypto_metadata_size,
107                                              VOID *packet_ptr,
108                                              VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status));
109 
110 #endif
111 
112 
113 #ifdef __cplusplus
114 }
115 #endif
116