aboutsummaryrefslogtreecommitdiff
path: root/lib/sec_library/include/sec_crypto_mac.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sec_library/include/sec_crypto_mac.h')
-rwxr-xr-x[-rw-r--r--]lib/sec_library/include/sec_crypto_mac.h72
1 files changed, 34 insertions, 38 deletions
diff --git a/lib/sec_library/include/sec_crypto_mac.h b/lib/sec_library/include/sec_crypto_mac.h
index 233ebdc4..dd82105f 100644..100755
--- a/lib/sec_library/include/sec_crypto_mac.h
+++ b/lib/sec_library/include/sec_crypto_mac.h
@@ -15,15 +15,15 @@
#include "sec_crypto_errcode.h"
#include "sec_crypto_sha.h"
-#define SC_MAC_KEY_LEN_MAX 64
-#define HMAC_SHA1_BLOCK_SIZE 64
-#define HMAC_SHA224_BLOCK_SIZE 64
-#define HMAC_SM3_BLOCK_SIZE 64
-#define HMAC_SHA256_BLOCK_SIZE 64
-#define HMAC_MD5_BLOCK_SIZE 64
-#define HMAC_SHA384_BLOCK_SIZE 128
-#define HMAC_SHA512_BLOCK_SIZE 128
-#define HMAC_MAX_BLOCK_SIZE 128
+#define SC_MAC_KEY_LEN_MAX (64)
+#define HMAC_SHA1_BLOCK_SIZE (64)
+#define HMAC_SHA224_BLOCK_SIZE (64)
+#define HMAC_SM3_BLOCK_SIZE (64)
+#define HMAC_SHA256_BLOCK_SIZE (64)
+#define HMAC_MD5_BLOCK_SIZE (64)
+#define HMAC_SHA384_BLOCK_SIZE (128)
+#define HMAC_SHA512_BLOCK_SIZE (128)
+#define HMAC_MAX_BLOCK_SIZE (128)
#ifdef __cplusplus
extern "C" {
@@ -44,7 +44,7 @@ typedef struct {
/**
\brief Initialize MAC Interface. Initializes the resources needed for the MAC interface
\param[in] mac operate handle.
- \param[in] idx index of mac
+ \param[in] idx index of mac
\return error code \ref uint32_t
*/
uint32_t sc_mac_init(sc_mac_t *mac, uint32_t idx);
@@ -57,23 +57,22 @@ uint32_t sc_mac_init(sc_mac_t *mac, uint32_t idx);
void sc_mac_uninit(sc_mac_t *mac);
/**
- \brief MAC set key function.
- \param[in] mac mac handle to operate.
- \param[in] key Pointer to the mac key.
- \param[in] key_len Length of key.
+ \brief MAC set key function.
+ \param[in] mac mac handle to operate.
+ \param[in] key Pointer to the mac key.
+ \param[in] key_len Length of key.
\return error code
*/
uint32_t sc_mac_set_key(sc_mac_t *mac, uint8_t *key, uint32_t key_len);
/**
\brief MAC operation function.
- \param[in] mac mac handle to operate.
- \param[in] mode sc_sha_mode_t.
- \param[in] msg Pointer to the mac input message.
- \param[in] msg_len Length of msg.
- \param[out] out mac buffer, malloc by caller.
- \param[out] out_len, out mac length,
- should 32 bytes if HMAC_SHA256 mode.
+ \param[in] mac mac handle to operate.
+ \param[in] mode sc_sha_mode_t.
+ \param[in] msg Pointer to the mac input message.
+ \param[in] msg_len Length of msg.
+ \param[out] out mac buffer, malloc by caller.
+ \param[out] out_len out mac length, should 32 bytes if HMAC_SHA256 mode.
\return error code
*/
uint32_t sc_mac_calc(sc_mac_t *mac, sc_sha_mode_t mode, uint8_t *msg,
@@ -81,35 +80,32 @@ uint32_t sc_mac_calc(sc_mac_t *mac, sc_sha_mode_t mode, uint8_t *msg,
/**
\brief MAC start operation function.
- \param[in] mac mac handle to operate.
- \param[in] context mac context pointer.
- \param[in] mode sc_sha_mode_t.
+ \param[in] mac mac handle to operate.
+ \param[in] context mac context pointer.
+ \param[in] mode sc_sha_mode_t.
\return error code
*/
-uint32_t sc_mac_start(sc_mac_t *mac, sc_mac_context_t *context,
- sc_sha_mode_t mode);
+uint32_t sc_mac_start(sc_mac_t *mac, sc_mac_context_t *context, sc_sha_mode_t mode);
/**
\brief MAC start operation function.
- \param[in] mac mac handle to operate.
- \param[in] context mac context pointer.
- \param[in] msg Pointer to the mac input message.
- \param[in] msg_len Length of msg.
+ \param[in] mac mac handle to operate.
+ \param[in] context mac context pointer.
+ \param[in] msg Pointer to the mac input message.
+ \param[in] msg_len Length of msg.
\return error code
*/
-uint32_t sc_mac_update(sc_mac_t *mac, sc_mac_context_t *context, uint8_t *msg,
- uint32_t msg_len);
+uint32_t sc_mac_update(sc_mac_t *mac, sc_mac_context_t *context, uint8_t *msg, uint32_t msg_len);
/**
\brief MAC start operation function.
- \param[in] mac mac handle to operate.
- \param[in] context mac context pointer.
- \param[out] out mac buffer, malloc by caller.
- \param[out] out_len, out mac length,
+ \param[in] mac mac handle to operate.
+ \param[in] context mac context.
+ \param[out] out mac buffer, malloc by caller.
+ \param[out] out_len out mac length,
\return error code
*/
-uint32_t sc_mac_finish(sc_mac_t *mac, sc_mac_context_t *context, uint8_t *out,
- uint32_t *out_len);
+uint32_t sc_mac_finish(sc_mac_t *mac, sc_mac_context_t *context, uint8_t *out, uint32_t *out_len);
#ifdef __cplusplus
}
#endif