1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Crypto Component                                                 */
17 /**                                                                       */
18 /**   HMAC MD5 Digest Algorithm (MD5)                                     */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  COMPONENT DEFINITION                                   RELEASE        */
27 /*                                                                        */
28 /*    nx_crypto_hmac_md5.h                                PORTABLE C      */
29 /*                                                           6.1          */
30 /*                                                                        */
31 /*  AUTHOR                                                                */
32 /*                                                                        */
33 /*    Timothy Stapko, Microsoft Corporation                               */
34 /*                                                                        */
35 /*  DESCRIPTION                                                           */
36 /*                                                                        */
37 /*    This file defines the NetX HMAC MD5 algorithm, derived from         */
38 /*    RFC2104. From a user-specified number of input bytes and key, this  */
39 /*    produces a 16-byte (128-bit) digest or sometimes called a hash      */
40 /*    value. The resulting digest is returned in a 16-byte array supplied */
41 /*    by the caller.                                                      */
42 /*                                                                        */
43 /*    It is assumed that nx_api.h and nx_port.h have already been         */
44 /*    included.                                                           */
45 /*                                                                        */
46 /*  RELEASE HISTORY                                                       */
47 /*                                                                        */
48 /*    DATE              NAME                      DESCRIPTION             */
49 /*                                                                        */
50 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
51 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
52 /*                                            resulting in version 6.1    */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef  NX_HMAC_MD5_H
57 #define  NX_HMAC_MD5_H
58 
59 /* Determine if a C++ compiler is being used.  If so, ensure that standard
60    C is used to process the API information.  */
61 #ifdef __cplusplus
62 
63 /* Yes, C++ compiler is present.  Use standard C.  */
64 extern   "C" {
65 
66 #endif
67 
68 #include "nx_crypto.h"
69 #include "nx_crypto_md5.h"
70 #include "nx_crypto_hmac.h"
71 
72 #define NX_CRYPTO_HMAC_MD5_KEY_LEN_IN_BITS      128
73 #define NX_CRYPTO_HMAC_MD5_ICV_FULL_LEN_IN_BITS NX_CRYPTO_MD5_ICV_LEN_IN_BITS
74 
75 /* Define the control block structure for backward compatibility. */
76 #define NX_MD5_HMAC                             NX_CRYPTO_MD5_HMAC
77 
78 typedef struct NX_CRYPTO_MD5_HMAC_STRUCT
79 {
80     NX_MD5 nx_md5_hmac_context;
81     NX_CRYPTO_HMAC nx_md5_hmac_metadata;
82 } NX_CRYPTO_MD5_HMAC;
83 
84 /* Define the function prototypes for HMAC MD5.  */
85 
86 UINT _nx_crypto_method_hmac_md5_init(struct  NX_CRYPTO_METHOD_STRUCT *method,
87                                      UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits,
88                                      VOID  **handle,
89                                      VOID  *crypto_metadata,
90                                      ULONG crypto_metadata_size);
91 
92 UINT _nx_crypto_method_hmac_md5_cleanup(VOID *crypto_metadata);
93 
94 UINT _nx_crypto_method_hmac_md5_operation(UINT op,      /* Encrypt, Decrypt, Authenticate */
95                                           VOID *handle, /* Crypto handler */
96                                           struct NX_CRYPTO_METHOD_STRUCT *method,
97                                           UCHAR *key,
98                                           NX_CRYPTO_KEY_SIZE key_size_in_bits,
99                                           UCHAR *input,
100                                           ULONG input_length_in_byte,
101                                           UCHAR *iv_ptr,
102                                           UCHAR *output,
103                                           ULONG output_length_in_byte,
104                                           VOID *crypto_metadata,
105                                           ULONG crypto_metadata_size,
106                                           VOID *packet_ptr,
107                                           VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status));
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif
114 
115