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 /** Transport Layer Security (TLS) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #ifndef SRC_NX_SECURE_PHASH_H_ 24 #define SRC_NX_SECURE_PHASH_H_ 25 26 /* Determine if a C++ compiler is being used. If so, ensure that standard 27 C is used to process the API information. */ 28 #ifdef __cplusplus 29 30 /* Yes, C++ compiler is present. Use standard C. */ 31 extern "C" { 32 33 #endif 34 35 #include "nx_crypto.h" 36 #include "nx_crypto_hmac_sha2.h" 37 #include "nx_crypto_hmac_sha5.h" 38 39 /**************************************************************************/ 40 /* */ 41 /* COMPONENT DEFINITION RELEASE */ 42 /* */ 43 /* nx_crypto_phash.h PORTABLE C */ 44 /* 6.1 */ 45 /* AUTHOR */ 46 /* */ 47 /* Timothy Stapko, Microsoft Corporation */ 48 /* */ 49 /* DESCRIPTION */ 50 /* */ 51 /* This file defines the TLS P-HASH function described in RFCs 2246, */ 52 /* 4346, and 5246. It is used in the TLS PRF function as a wrapper to */ 53 /* various hash routines to generate arbitrary-length data. */ 54 /* */ 55 /* RELEASE HISTORY */ 56 /* */ 57 /* DATE NAME DESCRIPTION */ 58 /* */ 59 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 60 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 61 /* resulting in version 6.1 */ 62 /* */ 63 /**************************************************************************/ 64 typedef struct NX_CRYPTO_PHASH_STRUCT 65 { 66 UCHAR *nx_crypto_phash_secret; /* secret */ 67 NX_CRYPTO_KEY_SIZE nx_crypto_phash_secret_length; 68 UCHAR *nx_crypto_phash_seed; /* seed */ 69 UINT nx_crypto_phash_seed_length; 70 UCHAR *nx_crypto_phash_temp_A; /* the buffer for A(i) */ 71 UINT nx_crypto_phash_temp_A_size; 72 NX_CRYPTO_METHOD *nx_crypto_hmac_method; /* hmac method */ 73 UCHAR *nx_crypto_hmac_metadata; /* hash_metadata */ 74 UINT nx_crypto_hmac_metadata_size; 75 UCHAR *nx_crypto_hmac_output; 76 UINT nx_crypto_hmac_output_size; 77 } NX_CRYPTO_PHASH; 78 79 extern NX_CRYPTO_METHOD crypto_method_hmac_md5; 80 extern NX_CRYPTO_METHOD crypto_method_hmac_sha1; 81 extern NX_CRYPTO_METHOD crypto_method_hmac_sha256; 82 extern NX_CRYPTO_METHOD crypto_method_hmac_sha384; 83 extern NX_CRYPTO_METHOD crypto_method_hmac_sha512; 84 85 UINT _nx_crypto_phash(NX_CRYPTO_PHASH *phash, UCHAR *output, UINT desired_length); 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 #endif 92 93