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 /** 3DES Encryption Standard (Triple DES) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* nx_crypto_3des.h PORTABLE C */ 29 /* 6.1 */ 30 /* AUTHOR */ 31 /* */ 32 /* Timothy Stapko, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file defines the NetX 3DES encryption algorithm. */ 37 /* It is assumed that nx_api.h and nx_port.h have already been */ 38 /* included. */ 39 /* */ 40 /* RELEASE HISTORY */ 41 /* */ 42 /* DATE NAME DESCRIPTION */ 43 /* */ 44 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 45 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 46 /* resulting in version 6.1 */ 47 /* */ 48 /**************************************************************************/ 49 50 #ifndef _NX_CRYPTO_3DES_H_ 51 #define _NX_CRYPTO_3DES_H_ 52 53 /* Determine if a C++ compiler is being used. If so, ensure that standard 54 C is used to process the API information. */ 55 #ifdef __cplusplus 56 57 /* Yes, C++ compiler is present. Use standard C. */ 58 extern "C" { 59 60 #endif 61 62 #include "nx_crypto.h" 63 #include "nx_crypto_des.h" 64 #include "nx_crypto_cbc.h" 65 66 67 #define NX_CRYPTO_3DES_KEY_LEN_IN_BITS 192 68 #define NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS 64 69 #define NX_CRYPTO_3DES_IV_LEN_IN_BITS 64 70 71 UINT _nx_crypto_method_3des_init(struct NX_CRYPTO_METHOD_STRUCT *method, 72 UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, 73 VOID **handle, 74 VOID *crypto_metadata, 75 ULONG crypto_metadata_size); 76 77 UINT _nx_crypto_method_3des_cleanup(VOID *crypto_metadata); 78 79 UINT _nx_crypto_method_3des_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ 80 VOID *handle, /* Crypto handler */ 81 struct NX_CRYPTO_METHOD_STRUCT *method, 82 UCHAR *key, 83 NX_CRYPTO_KEY_SIZE key_size_in_bits, 84 UCHAR *input, 85 ULONG input_length_in_byte, 86 UCHAR *iv_ptr, 87 UCHAR *output, 88 ULONG output_length_in_byte, 89 VOID *crypto_metadata, 90 ULONG crypto_metadata_size, 91 VOID *packet_ptr, 92 VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); 93 94 95 /* Define the 3DES context structure. */ 96 97 typedef struct NX_CRYPTO_3DES_STRUCT 98 { 99 100 NX_CRYPTO_DES des_1; 101 NX_CRYPTO_DES des_2; 102 NX_CRYPTO_DES des_3; 103 NX_CRYPTO_CBC nx_crypto_cbc_context; 104 } NX_CRYPTO_3DES; 105 106 107 /* Define the function prototypes for DES. */ 108 109 UINT _nx_crypto_3des_key_set(NX_CRYPTO_3DES * context, UCHAR key[24]); 110 UINT _nx_crypto_3des_encrypt(NX_CRYPTO_3DES * context, UCHAR source[8], UCHAR destination[8], UINT length); 111 UINT _nx_crypto_3des_decrypt(NX_CRYPTO_3DES * context, UCHAR source[8], UCHAR destination[8], UINT length); 112 113 114 #ifdef __cplusplus 115 } 116 #endif 117 118 #endif 119 120