From 6ed99b4ee558d215a45d9d1a39ac39ee8623d55b Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Wed, 13 Dec 2023 20:49:47 +0800 Subject: [PATCH] Update sm3.h --- include/gmssl/sm3.h | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/include/gmssl/sm3.h b/include/gmssl/sm3.h index ba02da80a..ec08c8a8f 100644 --- a/include/gmssl/sm3.h +++ b/include/gmssl/sm3.h @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. + * Copyright 2014-2023 The GmSSL Project. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. @@ -18,32 +18,10 @@ extern "C" { #endif -/* -SM3 Public API - - SM3_DIGEST_SIZE - SM3_HMAC_SIZE - - SM3_CTX - sm3_init - sm3_update - sm3_finish - - SM3_HMAC_CTX - sm3_hmac_init - sm3_hmac_update - sm3_hmac_finish - - sm3_digest - sm3_hmac -*/ - -#define SM3_IS_BIG_ENDIAN 1 #define SM3_DIGEST_SIZE 32 #define SM3_BLOCK_SIZE 64 #define SM3_STATE_WORDS 8 -#define SM3_HMAC_SIZE (SM3_DIGEST_SIZE) typedef struct { @@ -60,6 +38,9 @@ void sm3_digest(const uint8_t *data, size_t datalen, uint8_t dgst[SM3_DIGEST_SIZ void sm3_compress_blocks(uint32_t digest[8], const uint8_t *data, size_t blocks); + +#define SM3_HMAC_SIZE (SM3_DIGEST_SIZE) + typedef struct { SM3_CTX sm3_ctx; uint8_t key[SM3_BLOCK_SIZE]; @@ -79,8 +60,12 @@ typedef struct { } SM3_KDF_CTX; void sm3_kdf_init(SM3_KDF_CTX *ctx, size_t outlen); -void sm3_kdf_update(SM3_KDF_CTX *ctx, const uint8_t *data, size_t datalen); +void sm3_kdf_update(SM3_KDF_CTX *ctx, const uint8_t *in, size_t inlen); void sm3_kdf_finish(SM3_KDF_CTX *ctx, uint8_t *out); +#if 0 +// add until v3.2.0 +void sm3_kdf(const uint8_t *in, size_t inlen, size_t outlen, uint8_t *out); +#endif #ifdef __cplusplus