aboutsummaryrefslogtreecommitdiff
path: root/hmac-sha2.h
blob: 46908d2208f30161e787918ccab4457f860e6a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef HMAC_SHA2_H_
#define HMAC_SHA2_H_

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <stdint.h> // uint8_t
#include "sha2.h"

typedef struct {
  uint8_t key[64];
  sha256_t ctx;
} hmac_sha256_t;

void hmac_sha256_init(
  hmac_sha256_t * const ctx,
  const uint8_t * const key,
  const size_t key_len
);

void hmac_sha256_push(
  hmac_sha256_t * const ctx,
  const uint8_t * const buf,
  const size_t buf_len
);

void hmac_sha256_fini(
  hmac_sha256_t * const ctx,
  uint8_t * const out
);

void hmac_sha256(
  const uint8_t * const key,
  const size_t key_len,
  const uint8_t * const buf,
  const size_t buf_len,
  uint8_t * const out
);

_Bool hmac_check(
  const uint8_t * const a,
  const uint8_t * const b,
  const size_t len
);

#ifdef __cplusplus
};
#endif /* __cplusplus */

#endif /* HMAC_SHA2_H_ */