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 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 14 rights reserved. 15 16 License to copy and use this software is granted provided that it 17 is identified as the ""RSA Data Security, Inc. MD5 Message-Digest 18 Algorithm"" in all material mentioning or referencing this software 19 or this function. 20 21 License is also granted to make and use derivative works provided 22 that such works are identified as ""derived from the RSA Data 23 Security, Inc. MD5 Message-Digest Algorithm"" in all material 24 mentioning or referencing the derived work. 25 26 RSA Data Security, Inc. makes no representations concerning either 27 the merchantability of this software or the suitability of this 28 software for any particular purpose. It is provided ""as is"" 29 without express or implied warranty of any kind. 30 31 These notices must be retained in any copies of any part of this 32 documentation and/or software. 33 */ 34 /**************************************************************************/ 35 36 /**************************************************************************/ 37 /**************************************************************************/ 38 /** */ 39 /** NetX Component */ 40 /** */ 41 /** MD5 Digest Algorithm (MD5) */ 42 /** */ 43 /**************************************************************************/ 44 /**************************************************************************/ 45 46 47 /**************************************************************************/ 48 /* */ 49 /* COMPONENT DEFINITION RELEASE */ 50 /* */ 51 /* nx_md5.h PORTABLE C */ 52 /* 6.1.9 */ 53 /* AUTHOR */ 54 /* */ 55 /* Yuxin Zhou, Microsoft Corporation */ 56 /* */ 57 /* DESCRIPTION */ 58 /* */ 59 /* This file defines the NetX MD5 algorithm, derived principally from */ 60 /* RFC1321. From a user-specified number of input bytes, this routine */ 61 /* produces a 16-byte (128-bit) digest or sometimes called a hash */ 62 /* value. The resulting digest is returned in a 16-byte array supplied */ 63 /* by the caller. */ 64 /* */ 65 /* It is assumed that nx_api.h and nx_port.h have already been */ 66 /* included. */ 67 /* */ 68 /* RELEASE HISTORY */ 69 /* */ 70 /* DATE NAME DESCRIPTION */ 71 /* */ 72 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 73 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 74 /* resulting in version 6.1 */ 75 /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ 76 /* necessary header file, */ 77 /* resulting in version 6.1.9 */ 78 /* */ 79 /**************************************************************************/ 80 81 #ifndef NX_MD5_H 82 #define NX_MD5_H 83 84 #include "nx_api.h" 85 86 87 /* Define the MD5 context structure. */ 88 89 typedef struct NX_MD5_STRUCT 90 { 91 92 ULONG nx_md5_states[4]; /* Contains each state (A,B,C,D) */ 93 ULONG nx_md5_bit_count[2]; /* Contains the 64-bit total bit */ 94 /* count, where index 0 holds the */ 95 /* least significant bit count and*/ 96 /* index 1 contains the most */ 97 /* significant portion of the bit */ 98 /* count */ 99 UCHAR nx_md5_buffer[64]; /* Working buffer for MD5 algorithm */ 100 /* where partial buffers are */ 101 /* accumulated until a full block */ 102 /* can be processed */ 103 } NX_MD5; 104 105 106 /* Define the function prototypes for MD5. */ 107 108 UINT _nx_md5_initialize(NX_MD5 *context); 109 UINT _nx_md5_update(NX_MD5 *context, UCHAR *input_ptr, UINT input_length); 110 UINT _nx_md5_digest_calculate(NX_MD5 *context, UCHAR digest[16]); 111 VOID _nx_md5_process_buffer(NX_MD5 *context, UCHAR buffer[64]); 112 113 #endif 114