16801b27bSTomasz Kantecki /********************************************************************** 26801b27bSTomasz Kantecki Copyright(c) 2024 Intel Corporation All rights reserved. 36801b27bSTomasz Kantecki 46801b27bSTomasz Kantecki Redistribution and use in source and binary forms, with or without 56801b27bSTomasz Kantecki modification, are permitted provided that the following conditions 66801b27bSTomasz Kantecki are met: 76801b27bSTomasz Kantecki * Redistributions of source code must retain the above copyright 86801b27bSTomasz Kantecki notice, this list of conditions and the following disclaimer. 96801b27bSTomasz Kantecki * Redistributions in binary form must reproduce the above copyright 106801b27bSTomasz Kantecki notice, this list of conditions and the following disclaimer in 116801b27bSTomasz Kantecki the documentation and/or other materials provided with the 126801b27bSTomasz Kantecki distribution. 136801b27bSTomasz Kantecki * Neither the name of Intel Corporation nor the names of its 146801b27bSTomasz Kantecki contributors may be used to endorse or promote products derived 156801b27bSTomasz Kantecki from this software without specific prior written permission. 166801b27bSTomasz Kantecki 176801b27bSTomasz Kantecki THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186801b27bSTomasz Kantecki "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196801b27bSTomasz Kantecki LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206801b27bSTomasz Kantecki A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216801b27bSTomasz Kantecki OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226801b27bSTomasz Kantecki SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236801b27bSTomasz Kantecki LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246801b27bSTomasz Kantecki DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256801b27bSTomasz Kantecki THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266801b27bSTomasz Kantecki (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276801b27bSTomasz Kantecki OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286801b27bSTomasz Kantecki **********************************************************************/ 296801b27bSTomasz Kantecki 306801b27bSTomasz Kantecki #ifndef _SM3_MB_INTERNAL_H_ 316801b27bSTomasz Kantecki #define _SM3_MB_INTERNAL_H_ 326801b27bSTomasz Kantecki 336801b27bSTomasz Kantecki /** 346801b27bSTomasz Kantecki * @file sm3_mb_internal.h 356801b27bSTomasz Kantecki * @brief Internal multi-buffer CTX API SM3 function prototypes and structures 366801b27bSTomasz Kantecki */ 376801b27bSTomasz Kantecki 386801b27bSTomasz Kantecki #include <stdint.h> 396801b27bSTomasz Kantecki #include "multi_buffer.h" 406801b27bSTomasz Kantecki #include "types.h" 416801b27bSTomasz Kantecki 426801b27bSTomasz Kantecki #ifndef _MSC_VER 436801b27bSTomasz Kantecki #include <stdbool.h> 446801b27bSTomasz Kantecki #endif 456801b27bSTomasz Kantecki 466801b27bSTomasz Kantecki #ifdef __cplusplus 476801b27bSTomasz Kantecki extern "C" { 486801b27bSTomasz Kantecki #endif 496801b27bSTomasz Kantecki 50*3080abdaSTomasz Kantecki #define ISAL_SM3_X8_LANES 8 51*3080abdaSTomasz Kantecki #define ISAL_SM3_LOG2_BLOCK_SIZE 6 52*3080abdaSTomasz Kantecki #define ISAL_SM3_PADLENGTHFIELD_SIZE 8 53*3080abdaSTomasz Kantecki #define ISAL_SM3_INITIAL_DIGEST \ 54*3080abdaSTomasz Kantecki 0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600, 0xa96f30bc, 0x163138aa, 0xe38dee4d, \ 55*3080abdaSTomasz Kantecki 0xb0fb0e4e 56*3080abdaSTomasz Kantecki 57*3080abdaSTomasz Kantecki typedef uint32_t ISAL_SM3_WORD_T; 58*3080abdaSTomasz Kantecki 596801b27bSTomasz Kantecki /** 606801b27bSTomasz Kantecki * @brief Initialize the SM3 multi-buffer manager structure. 616801b27bSTomasz Kantecki * 626801b27bSTomasz Kantecki * @param mgr Structure holding context level state info 636801b27bSTomasz Kantecki * @returns void 646801b27bSTomasz Kantecki */ 656801b27bSTomasz Kantecki void 666801b27bSTomasz Kantecki _sm3_ctx_mgr_init(ISAL_SM3_HASH_CTX_MGR *mgr); 676801b27bSTomasz Kantecki 686801b27bSTomasz Kantecki /** 696801b27bSTomasz Kantecki * @brief Submit a new SM3 job to the multi-buffer manager. 706801b27bSTomasz Kantecki * 716801b27bSTomasz Kantecki * @param mgr Structure holding context level state info 726801b27bSTomasz Kantecki * @param ctx Structure holding ctx job info 736801b27bSTomasz Kantecki * @param buffer Pointer to buffer to be processed 746801b27bSTomasz Kantecki * @param len Length of buffer (in bytes) to be processed 756801b27bSTomasz Kantecki * @param flags Input flag specifying job type (first, update, last or entire) 766801b27bSTomasz Kantecki * @returns NULL if no jobs complete or pointer to jobs structure. 776801b27bSTomasz Kantecki */ 786801b27bSTomasz Kantecki ISAL_SM3_HASH_CTX * 796801b27bSTomasz Kantecki _sm3_ctx_mgr_submit(ISAL_SM3_HASH_CTX_MGR *mgr, ISAL_SM3_HASH_CTX *ctx, const void *buffer, 806801b27bSTomasz Kantecki uint32_t len, ISAL_HASH_CTX_FLAG flags); 816801b27bSTomasz Kantecki 826801b27bSTomasz Kantecki /** 836801b27bSTomasz Kantecki * @brief Finish all submitted SM3 jobs and return when complete. 846801b27bSTomasz Kantecki * 856801b27bSTomasz Kantecki * @param mgr Structure holding context level state info 866801b27bSTomasz Kantecki * @returns NULL if no jobs to complete or pointer to jobs structure. 876801b27bSTomasz Kantecki */ 886801b27bSTomasz Kantecki ISAL_SM3_HASH_CTX * 896801b27bSTomasz Kantecki _sm3_ctx_mgr_flush(ISAL_SM3_HASH_CTX_MGR *mgr); 906801b27bSTomasz Kantecki 916801b27bSTomasz Kantecki #ifdef __cplusplus 926801b27bSTomasz Kantecki } 936801b27bSTomasz Kantecki #endif 946801b27bSTomasz Kantecki #endif 95