28 行
769 B
C
28 行
769 B
C
#ifndef PAZE_POLY1305_H
|
|
#define PAZE_POLY1305_H
|
|
#include "paze/paze_types.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
uint32_t r[5]; /* r 已截断,小端 26+26+26+26+24 位拆分 */
|
|
uint32_t s[5]; /* s1..s4 = r*5 预计算 */
|
|
uint32_t h[5]; /* 累加器 */
|
|
uint32_t pad[4]; /* key[16..32] */
|
|
uint8_t buf[16];
|
|
size_t blen;
|
|
} paze_poly1305_ctx_t;
|
|
|
|
void paze_poly1305_init(paze_poly1305_ctx_t *c, const uint8_t key[32]);
|
|
void paze_poly1305_update(paze_poly1305_ctx_t *c, const uint8_t *data, size_t len);
|
|
void paze_poly1305_final(paze_poly1305_ctx_t *c, uint8_t tag[16]);
|
|
|
|
/* 单次 */
|
|
void paze_poly1305(const uint8_t key[32], const uint8_t *msg, size_t len, uint8_t tag[16]);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|