Skip to content

Commit

Permalink
Update sm3.h
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed Dec 13, 2023
1 parent 85e81d2 commit 6ed99b4
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions include/gmssl/sm3.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 {
Expand All @@ -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];
Expand All @@ -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
Expand Down

0 comments on commit 6ed99b4

Please sign in to comment.