SemiDrive SSDK Appication Program Interface PTG3.0
hmac.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 *
4 *Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
5 *Software License Agreement
6 *
7 ******************************************************************************
8 */
9#ifndef HMAC_H
10#define HMAC_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#include "hash.h"
17
18#define HMAC_IPAD (0x36363636)
19#define HMAC_OPAD (0x5c5c5c5c)
20#define HMAC_IPAD_XOR_OPAD (HMAC_IPAD ^ HMAC_OPAD)
21
22/*HMAC context*/
23typedef struct {
25 uint32_t key_flag;
27 hash_ctx_t hash_ctx[1];
29
30/*HMAC DMA context*/
31#ifdef HASH_DMA_FUNCTION
32typedef struct {
33 hmac_ctx_t hmac_ctx[1];
34 hash_dma_ctx_t hash_dma_ctx[1];
35} hmac_dma_ctx_t;
36#endif
37
38uint32_t hmac_init(hmac_ctx_t *ctx, HASH_ALG hash_alg, uint8_t *key,
39 uint16_t sp_key_idx, uint32_t key_bytes);
40
41uint32_t hmac_update(hmac_ctx_t *ctx, const uint8_t *msg, uint32_t msg_bytes);
42
43uint32_t hmac_final(hmac_ctx_t *ctx, uint8_t *mac);
44
45uint32_t hmac(HASH_ALG hash_alg, uint8_t *key, uint16_t sp_key_idx,
46 uint32_t key_bytes, uint8_t *msg, uint32_t msg_bytes,
47 uint8_t *mac);
48
49#ifdef HASH_DMA_FUNCTION
50uint32_t hmac_dma_init(hmac_dma_ctx_t *ctx, HASH_ALG hash_alg,
51 const uint8_t *key, uint16_t sp_key_idx,
52 uint32_t key_bytes, HASH_CALLBACK callback);
53
54uint32_t hmac_dma_update_blocks(hmac_dma_ctx_t *ctx, uint32_t *msg,
55 uint32_t msg_words, uint32_t *tmp_iterator);
56
57uint32_t hmac_dma_final(hmac_dma_ctx_t *ctx, uint32_t *remainder_msg,
58 uint32_t remainder_bytes, uint32_t *tmp_iterator,
59 uint8_t *mac);
60
61uint32_t hmac_dma(HASH_ALG hash_alg, uint8_t *key, uint16_t sp_key_idx,
62 uint32_t key_bytes, uint32_t *msg, uint32_t msg_bytes,
63 uint32_t *tmp_iterator, uint8_t *mac, HASH_CALLBACK callback);
64#endif
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif
HASH_ALG
Definition: hash_basic.h:131
void(* HASH_CALLBACK)(void)
Definition: hash_basic.h:195
#define HASH_BLOCK_MAX_WORD_LEN
Definition: hash_basic.h:104
uint32_t hmac_final(hmac_ctx_t *ctx, uint8_t *mac)
uint32_t hmac_init(hmac_ctx_t *ctx, HASH_ALG hash_alg, uint8_t *key, uint16_t sp_key_idx, uint32_t key_bytes)
uint32_t hmac_update(hmac_ctx_t *ctx, const uint8_t *msg, uint32_t msg_bytes)
uint32_t hmac(HASH_ALG hash_alg, uint8_t *key, uint16_t sp_key_idx, uint32_t key_bytes, uint8_t *msg, uint32_t msg_bytes, uint8_t *mac)
Definition: hash.h:24
Definition: hmac.h:23
HASH_ALG hash_alg
Definition: hmac.h:26
uint32_t key_flag
Definition: hmac.h:25