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 SHA1 Digest Algorithm (SHA1) */ 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 SHA1 algorithm, derived from */ 37 /* RFC2202. From a user-specified number of input bytes and key, this */ 38 /* produces a 20-byte (160-bit) digest or sometimes called a hash */ 39 /* value. The resulting digest is returned in a 20-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_SHA1_H 56 #define NX_HMAC_SHA1_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_sha1.h" 69 #include "nx_crypto_hmac.h" 70 71 #define NX_CRYPTO_HMAC_SHA1_KEY_LEN_IN_BITS 160 72 #define NX_CRYPTO_HMAC_SHA1_ICV_FULL_LEN_IN_BITS NX_CRYPTO_SHA1_ICV_LEN_IN_BITS 73 74 /* Define the control block structure for backward compatibility. */ 75 #define NX_SHA1_HMAC NX_CRYPTO_SHA1_HMAC 76 77 typedef struct NX_CRYPTO_SHA1_HMAC_STRUCT 78 { 79 NX_CRYPTO_SHA1 nx_sha1_hmac_context; 80 NX_CRYPTO_HMAC nx_sha1_hmac_metadata; 81 } NX_CRYPTO_SHA1_HMAC; 82 83 /* Define the function prototypes for HMAC SHA1. */ 84 85 UINT _nx_crypto_method_hmac_sha1_init(struct NX_CRYPTO_METHOD_STRUCT *method, 86 UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, 87 VOID **handle, 88 VOID *crypto_metadata, 89 ULONG crypto_metadata_size); 90 91 UINT _nx_crypto_method_hmac_sha1_cleanup(VOID *crypto_metadata); 92 93 UINT _nx_crypto_method_hmac_sha1_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ 94 VOID *handle, /* Crypto handler */ 95 struct NX_CRYPTO_METHOD_STRUCT *method, 96 UCHAR *key, 97 NX_CRYPTO_KEY_SIZE key_size_in_bits, 98 UCHAR *input, 99 ULONG input_length_in_byte, 100 UCHAR *iv_ptr, 101 UCHAR *output, 102 ULONG output_length_in_byte, 103 VOID *crypto_metadata, 104 ULONG crypto_metadata_size, 105 VOID *packet_ptr, 106 VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 #endif 113 114