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 Copyright (C) The Internet Society (2001). All Rights Reserved. 15 16 This document and translations of it may be copied and furnished to 17 others, and derivative works that comment on or otherwise explain it 18 or assist in its implementation may be prepared, copied, published 19 and distributed, in whole or in part, without restriction of any 20 kind, provided that the above copyright notice and this paragraph are 21 included on all such copies and derivative works. However, this 22 document itself may not be modified in any way, such as by removing 23 the copyright notice or references to the Internet Society or other 24 Internet organizations, except as needed for the purpose of 25 developing Internet standards in which case the procedures for 26 copyrights defined in the Internet Standards process must be 27 followed, or as required to translate it into languages other than 28 English. 29 30 The limited permissions granted above are perpetual and will not be 31 revoked by the Internet Society or its successors or assigns. 32 33 This document and the information contained herein is provided on an 34 ""AS IS"" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING 35 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 36 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 37 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 38 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 39 */ 40 /**************************************************************************/ 41 42 43 /**************************************************************************/ 44 /**************************************************************************/ 45 /** */ 46 /** NetX Component */ 47 /** */ 48 /** SHA1 Digest Algorithm (SHA1) */ 49 /** */ 50 /**************************************************************************/ 51 /**************************************************************************/ 52 53 54 /**************************************************************************/ 55 /* */ 56 /* COMPONENT DEFINITION RELEASE */ 57 /* */ 58 /* nx_sha1.h PORTABLE C */ 59 /* 6.1 */ 60 /* AUTHOR */ 61 /* */ 62 /* Yuxin Zhou, Microsoft Corporation */ 63 /* */ 64 /* DESCRIPTION */ 65 /* */ 66 /* This file defines the NetX SHA1 algorithm, derived principally from */ 67 /* RFC3174. From a user-specified number of input bytes, this routine */ 68 /* produces a 20-byte (160-bit) digest or sometimes called a hash */ 69 /* value. The resulting digest is returned in a 20-byte array supplied */ 70 /* by the caller. */ 71 /* */ 72 /* It is assumed that nx_api.h and nx_port.h have already been */ 73 /* included. */ 74 /* */ 75 /* RELEASE HISTORY */ 76 /* */ 77 /* DATE NAME DESCRIPTION */ 78 /* */ 79 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 80 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 81 /* resulting in version 6.1 */ 82 /* */ 83 /**************************************************************************/ 84 85 #ifndef NX_SHA1_H 86 #define NX_SHA1_H 87 88 89 /* Define the SHA1 context structure. */ 90 91 typedef struct NX_SHA1_STRUCT 92 { 93 94 ULONG nx_sha1_states[5]; /* Contains each state (A,B,C,D) */ 95 ULONG nx_sha1_bit_count[2]; /* Contains the 64-bit total bit */ 96 /* count, where index 0 holds the */ 97 /* least significant bit count and*/ 98 /* index 1 contains the most */ 99 /* significant portion of the bit */ 100 /* count */ 101 UCHAR nx_sha1_buffer[64]; /* Working buffer for SHA1 algorithm*/ 102 /* where partial buffers are */ 103 /* accumulated until a full block */ 104 /* can be processed */ 105 ULONG nx_sha1_word_array[80]; /* Working 80 word array */ 106 } NX_SHA1; 107 108 109 /* Define the function prototypes for SHA1. */ 110 111 UINT _nx_sha1_initialize(NX_SHA1 *context); 112 UINT _nx_sha1_update(NX_SHA1 *context, UCHAR *input_ptr, UINT input_length); 113 UINT _nx_sha1_digest_calculate(NX_SHA1 *context, UCHAR digest[20]); 114 VOID _nx_sha1_process_buffer(NX_SHA1 *context, UCHAR buffer[64]); 115 116 #endif 117