1 /********************************************************************** 2 Copyright(c) 2024 Intel Corporation All rights reserved. 3 4 Redistribution and use in source and binary forms, with or without 5 modification, are permitted provided that the following conditions 6 are met: 7 * Redistributions of source code must retain the above copyright 8 notice, this list of conditions and the following disclaimer. 9 * Redistributions in binary form must reproduce the above copyright 10 notice, this list of conditions and the following disclaimer in 11 the documentation and/or other materials provided with the 12 distribution. 13 * Neither the name of Intel Corporation nor the names of its 14 contributors may be used to endorse or promote products derived 15 from this software without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 **********************************************************************/ 29 30 #ifndef _SM3_MB_INTERNAL_H_ 31 #define _SM3_MB_INTERNAL_H_ 32 33 /** 34 * @file sm3_mb_internal.h 35 * @brief Internal multi-buffer CTX API SM3 function prototypes and structures 36 */ 37 38 #include <stdint.h> 39 #include "multi_buffer.h" 40 #include "types.h" 41 42 #ifndef _MSC_VER 43 #include <stdbool.h> 44 #endif 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 #define ISAL_SM3_X8_LANES 8 51 #define ISAL_SM3_LOG2_BLOCK_SIZE 6 52 #define ISAL_SM3_PADLENGTHFIELD_SIZE 8 53 #define ISAL_SM3_INITIAL_DIGEST \ 54 0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600, 0xa96f30bc, 0x163138aa, 0xe38dee4d, \ 55 0xb0fb0e4e 56 57 typedef uint32_t ISAL_SM3_WORD_T; 58 59 /** 60 * @brief Initialize the SM3 multi-buffer manager structure. 61 * 62 * @param mgr Structure holding context level state info 63 * @returns void 64 */ 65 void 66 _sm3_ctx_mgr_init(ISAL_SM3_HASH_CTX_MGR *mgr); 67 68 /** 69 * @brief Submit a new SM3 job to the multi-buffer manager. 70 * 71 * @param mgr Structure holding context level state info 72 * @param ctx Structure holding ctx job info 73 * @param buffer Pointer to buffer to be processed 74 * @param len Length of buffer (in bytes) to be processed 75 * @param flags Input flag specifying job type (first, update, last or entire) 76 * @returns NULL if no jobs complete or pointer to jobs structure. 77 */ 78 ISAL_SM3_HASH_CTX * 79 _sm3_ctx_mgr_submit(ISAL_SM3_HASH_CTX_MGR *mgr, ISAL_SM3_HASH_CTX *ctx, const void *buffer, 80 uint32_t len, ISAL_HASH_CTX_FLAG flags); 81 82 /** 83 * @brief Finish all submitted SM3 jobs and return when complete. 84 * 85 * @param mgr Structure holding context level state info 86 * @returns NULL if no jobs to complete or pointer to jobs structure. 87 */ 88 ISAL_SM3_HASH_CTX * 89 _sm3_ctx_mgr_flush(ISAL_SM3_HASH_CTX_MGR *mgr); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 #endif 95