1 /* 2 * This file is part of the openHiTLS project. 3 * 4 * openHiTLS is licensed under the Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * 8 * http://license.coscl.org.cn/MulanPSL2 9 * 10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13 * See the Mulan PSL v2 for more details. 14 */ 15 16 #ifndef SLH_DSA_HASH_H 17 #define SLH_DSA_HASH_H 18 19 #include "hitls_build.h" 20 #ifdef HITLS_CRYPTO_SLH_DSA 21 22 #include <stdint.h> 23 #include "bsl_params.h" 24 #include "crypt_slh_dsa.h" 25 26 // The length "out" is n, the max length is SLH_DSA_MAX_N 27 typedef int32_t (*SlhDsaPrf)(const CryptSlhDsaCtx *ctx, const SlhDsaAdrs *adrs, uint8_t *out); 28 29 typedef int32_t (*SlhDsaTl)(const CryptSlhDsaCtx *ctx, const SlhDsaAdrs *adrs, const uint8_t *msg, uint32_t msgLen, 30 uint8_t *out); 31 32 typedef int32_t (*SlhDsaH)(const CryptSlhDsaCtx *ctx, const SlhDsaAdrs *adrs, const uint8_t *msg, uint32_t msgLen, 33 uint8_t *out); 34 35 typedef int32_t (*SlhDsaF)(const CryptSlhDsaCtx *ctx, const SlhDsaAdrs *adrs, const uint8_t *msg, uint32_t msgLen, 36 uint8_t *out); 37 38 // The length of "prf", "rand" and "out" is n, the max length is SLH_DSA_MAX_N 39 typedef int32_t (*SlhDsaPrfMsg)(const CryptSlhDsaCtx *ctx, const uint8_t *rand, const uint8_t *msg, uint32_t msgLen, 40 uint8_t *out); 41 42 // The length of "r", "seed" and "root" is n, the max length is SLH_DSA_MAX_N 43 // the max length of "out" is SLH_DSA_MAX_M 44 typedef int32_t (*SlhDsaHmsg)(const CryptSlhDsaCtx *ctx, const uint8_t *r, const uint8_t *msg, uint32_t msgLen, 45 uint8_t *out); 46 struct HashFuncs { 47 SlhDsaPrf prf; 48 SlhDsaTl tl; 49 SlhDsaH h; 50 SlhDsaF f; 51 SlhDsaPrfMsg prfmsg; 52 SlhDsaHmsg hmsg; 53 }; 54 55 void SlhDsaInitHashFuncs(CryptSlhDsaCtx *ctx); 56 57 #endif // HITLS_CRYPTO_SLH_DSA 58 #endif // SLH_DSA_HASH_H