mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-09 07:23:56 +08:00
Update sm3.h
This commit is contained in:
@@ -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
|
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
* not use this file except in compliance with the License.
|
* not use this file except in compliance with the License.
|
||||||
@@ -18,32 +18,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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_DIGEST_SIZE 32
|
||||||
#define SM3_BLOCK_SIZE 64
|
#define SM3_BLOCK_SIZE 64
|
||||||
#define SM3_STATE_WORDS 8
|
#define SM3_STATE_WORDS 8
|
||||||
#define SM3_HMAC_SIZE (SM3_DIGEST_SIZE)
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
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);
|
void sm3_compress_blocks(uint32_t digest[8], const uint8_t *data, size_t blocks);
|
||||||
|
|
||||||
|
|
||||||
|
#define SM3_HMAC_SIZE (SM3_DIGEST_SIZE)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SM3_CTX sm3_ctx;
|
SM3_CTX sm3_ctx;
|
||||||
uint8_t key[SM3_BLOCK_SIZE];
|
uint8_t key[SM3_BLOCK_SIZE];
|
||||||
@@ -79,8 +60,12 @@ typedef struct {
|
|||||||
} SM3_KDF_CTX;
|
} SM3_KDF_CTX;
|
||||||
|
|
||||||
void sm3_kdf_init(SM3_KDF_CTX *ctx, size_t outlen);
|
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);
|
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
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user