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 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 15 rights reserved. 16 17 License to copy and use this software is granted provided that it 18 is identified as the ""RSA Data Security, Inc. MD5 Message-Digest 19 Algorithm"" in all material mentioning or referencing this software 20 or this function. 21 22 License is also granted to make and use derivative works provided 23 that such works are identified as ""derived from the RSA Data 24 Security, Inc. MD5 Message-Digest Algorithm"" in all material 25 mentioning or referencing the derived work. 26 27 RSA Data Security, Inc. makes no representations concerning either 28 the merchantability of this software or the suitability of this 29 software for any particular purpose. It is provided ""as is"" 30 without express or implied warranty of any kind. 31 32 These notices must be retained in any copies of any part of this 33 documentation and/or software. 34 */ 35 /**************************************************************************/ 36 37 /**************************************************************************/ 38 /**************************************************************************/ 39 /** */ 40 /** NetX Crypto Component */ 41 /** */ 42 /** MD5 Digest Algorithm (MD5) */ 43 /** */ 44 /**************************************************************************/ 45 /**************************************************************************/ 46 47 48 /**************************************************************************/ 49 /* */ 50 /* COMPONENT DEFINITION RELEASE */ 51 /* */ 52 /* nx_md5.h PORTABLE C */ 53 /* 6.1 */ 54 /* AUTHOR */ 55 /* */ 56 /* Timothy Stapko, Microsoft Corporation */ 57 /* */ 58 /* DESCRIPTION */ 59 /* */ 60 /* This file defines the NetX MD5 algorithm, derived principally from */ 61 /* RFC1321. */ 62 /* */ 63 /* It is assumed that nx_api.h and nx_port.h have already been */ 64 /* included. */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 71 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ 75 76 #ifndef NX_MD5_H 77 #define NX_MD5_H 78 79 /* Determine if a C++ compiler is being used. If so, ensure that standard 80 C is used to process the API information. */ 81 #ifdef __cplusplus 82 83 /* Yes, C++ compiler is present. Use standard C. */ 84 extern "C" { 85 86 #endif 87 88 #include "nx_crypto.h" 89 90 #define NX_CRYPTO_MD5_BLOCK_SIZE_IN_BYTES 64 91 #define NX_CRYPTO_MD5_ICV_LEN_IN_BITS 128 92 93 /* Define the control block structure for backward compatibility. */ 94 #define NX_MD5 NX_CRYPTO_MD5 95 96 /* Define the MD5 context structure. */ 97 98 typedef struct NX_CRYPTO_MD5_STRUCT 99 { 100 101 ULONG nx_md5_states[4]; /* Contains each state (A,B,C,D) */ 102 ULONG nx_md5_bit_count[2]; /* Contains the 64-bit total bit */ 103 /* count, where index 0 holds the */ 104 /* least significant bit count and*/ 105 /* index 1 contains the most */ 106 /* significant portion of the bit */ 107 /* count */ 108 UCHAR nx_md5_buffer[64]; /* Working buffer for MD5 algorithm */ 109 /* where partial buffers are */ 110 /* accumulated until a full block */ 111 /* can be processed */ 112 } NX_CRYPTO_MD5; 113 114 115 /* Define the function prototypes for MD5. */ 116 117 UINT _nx_crypto_md5_initialize(NX_CRYPTO_MD5 *context, UINT algorithm); 118 UINT _nx_crypto_md5_update(NX_CRYPTO_MD5 *context, UCHAR *input_ptr, UINT input_length); 119 UINT _nx_crypto_md5_digest_calculate(NX_CRYPTO_MD5 * context, UCHAR digest[16], UINT algorithm); 120 VOID _nx_crypto_md5_process_buffer(NX_CRYPTO_MD5 * context, UCHAR buffer[64]); 121 122 UINT _nx_crypto_method_md5_init(struct NX_CRYPTO_METHOD_STRUCT *method, 123 UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, 124 VOID **handle, 125 VOID *crypto_metadata, 126 ULONG crypto_metadata_size); 127 128 UINT _nx_crypto_method_md5_cleanup(VOID *crypto_metadata); 129 130 UINT _nx_crypto_method_md5_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ 131 VOID *handle, /* Crypto handler */ 132 struct NX_CRYPTO_METHOD_STRUCT *method, 133 UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, 134 UCHAR *input, ULONG input_length_in_byte, 135 UCHAR *iv_ptr, 136 UCHAR *output, ULONG output_length_in_byte, 137 VOID *crypto_metadata, ULONG crypto_metadata_size, 138 VOID *packet_ptr, 139 VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); 140 #endif 141 142 143 #ifdef __cplusplus 144 } 145 #endif 146