Skip to content

Commit

Permalink
Update sm3_kdf.c
Browse files Browse the repository at this point in the history
Do not use endian.h
  • Loading branch information
guanzhi committed Dec 13, 2023
1 parent 07b077d commit 85e81d2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/sm3_kdf.c
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 @@ -8,13 +8,17 @@
*/



#include <string.h>
#include <gmssl/sm3.h>
#include <gmssl/endian.h>
#include <gmssl/error.h>


#define PUTU32(ptr,a) \
((ptr)[0] = (uint8_t)((a) >> 24), \
(ptr)[1] = (uint8_t)((a) >> 16), \
(ptr)[2] = (uint8_t)((a) >> 8), \
(ptr)[3] = (uint8_t)(a))

void sm3_kdf_init(SM3_KDF_CTX *ctx, size_t outlen)
{
sm3_init(&ctx->sm3_ctx);
Expand Down Expand Up @@ -52,3 +56,15 @@ void sm3_kdf_finish(SM3_KDF_CTX *ctx, uint8_t *out)
memset(&sm3_ctx, 0, sizeof(SM3_CTX));
memset(dgst, 0, sizeof(dgst));
}

#if 0
// add until v3.2.0
void sm3_kdf(const uint8_t *in, size_t inlen, size_t outlen, uint8_t *out)
{
SM3_KDF_CTX ctx;
sm3_kdf_init(&ctx, outlen);
sm3_kdf_update(&ctx, in, inlen);
sm3_kdf_finish(&ctx, out);
memset(&ctx, 0, sizeof(ctx));
}
#endif

0 comments on commit 85e81d2

Please sign in to comment.