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 /** CBC Mode */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /**************************************************************************/ 24 /* */ 25 /* APPLICATION INTERFACE DEFINITION RELEASE */ 26 /* */ 27 /* nx_crypto_cbc.h PORTABLE C */ 28 /* 6.1 */ 29 /* AUTHOR */ 30 /* */ 31 /* Timothy Stapko, Microsoft Corporation */ 32 /* */ 33 /* DESCRIPTION */ 34 /* */ 35 /* This file defines the basic Application Interface (API) to the */ 36 /* NetX Crypto CBC module. */ 37 /* */ 38 /* RELEASE HISTORY */ 39 /* */ 40 /* DATE NAME DESCRIPTION */ 41 /* */ 42 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 43 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 44 /* resulting in version 6.1 */ 45 /* */ 46 /**************************************************************************/ 47 48 #ifndef NX_CRYPTO_CBC_H 49 #define NX_CRYPTO_CBC_H 50 51 /* Determine if a C++ compiler is being used. If so, ensure that standard 52 C is used to process the API information. */ 53 #ifdef __cplusplus 54 55 /* Yes, C++ compiler is present. Use standard C. */ 56 extern "C" { 57 58 #endif 59 60 /* Include the ThreadX and port-specific data type file. */ 61 62 #include "nx_crypto.h" 63 64 #ifndef NX_CRYPTO_CBC_MAX_BLOCK_SIZE 65 #define NX_CRYPTO_CBC_MAX_BLOCK_SIZE 16 66 #endif /* NX_CRYPTO_CBC_MAX_BLOCK_SIZE */ 67 68 typedef struct NX_CRYPTO_CBC_STRUCT 69 { 70 71 /* Initial Vector for next round. */ 72 UCHAR nx_crypto_cbc_last_block[NX_CRYPTO_CBC_MAX_BLOCK_SIZE]; 73 } NX_CRYPTO_CBC; 74 75 NX_CRYPTO_KEEP UINT _nx_crypto_cbc_encrypt(VOID *crypto_metadata, NX_CRYPTO_CBC *cbc_metadata, 76 UINT (*crypto_function)(VOID *, UCHAR *, UCHAR *, UINT), 77 UCHAR *input, UCHAR *output, UINT length, UCHAR block_size); 78 79 NX_CRYPTO_KEEP UINT _nx_crypto_cbc_decrypt(VOID *crypto_metadata, NX_CRYPTO_CBC *cbc_metadata, 80 UINT (*crypto_function)(VOID *, UCHAR *, UCHAR *, UINT), 81 UCHAR *input, UCHAR *output, UINT length, UCHAR block_size); 82 83 NX_CRYPTO_KEEP UINT _nx_crypto_cbc_encrypt_init(NX_CRYPTO_CBC *cbc_metadata, UCHAR *iv, UINT iv_len); 84 85 #define _nx_crypto_cbc_decrypt_init _nx_crypto_cbc_encrypt_init 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 92 #endif /* NX_CRYPTO_CBC_H */ 93 94