API参考
载入中...
搜索中...
未找到
crypt_siphash.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16#ifndef CRYPT_SIPHASH_H
17#define CRYPT_SIPHASH_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_SIPHASH
21
22#include <stdint.h>
23#include <stdlib.h>
24#include "crypt_local_types.h"
25
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cpluscplus */
30
31#define SIPHASH_KEY_SIZE 16 // 128 bit
32#define SIPHASH_WORD_SIZE 8 // 64 bit
33#define DEFAULT_COMPRESSION_ROUND 2
34#define DEFAULT_FINALIZATION_ROUND 4
35// The siphash has only two output lengths: 8-byte and 16-byte.
36#define SIPHASH_MIN_DIGEST_SIZE 8
37#define SIPHASH_MAX_DIGEST_SIZE 16
38
39typedef struct SIPHASH_Ctx CRYPT_SIPHASH_Ctx;
40
41#define CRYPT_SIPHASH_SetParam NULL
42
48CRYPT_SIPHASH_Ctx *CRYPT_SIPHASH_NewCtx(CRYPT_MAC_AlgId id);
49
56CRYPT_SIPHASH_Ctx *CRYPT_SIPHASH_NewCtxEx(void *libCtx, CRYPT_MAC_AlgId id);
57
67int32_t CRYPT_SIPHASH_Init(CRYPT_SIPHASH_Ctx *ctx, const uint8_t *key, uint32_t keyLen);
68
79int32_t CRYPT_SIPHASH_InitEx(CRYPT_SIPHASH_Ctx *ctx, const uint8_t *key, uint32_t keyLen, void *param);
80
89int32_t CRYPT_SIPHASH_Update(CRYPT_SIPHASH_Ctx *ctx, const uint8_t *in, uint32_t inlen);
90
100int32_t CRYPT_SIPHASH_Final(CRYPT_SIPHASH_Ctx *ctx, uint8_t *out, uint32_t *outlen);
101
108int32_t CRYPT_SIPHASH_Reinit(CRYPT_SIPHASH_Ctx *ctx);
109
116int32_t CRYPT_SIPHASH_Deinit(CRYPT_SIPHASH_Ctx *ctx);
117
128int32_t CRYPT_SIPHASH_Ctrl(CRYPT_SIPHASH_Ctx *ctx, uint32_t opt, void *val, uint32_t len);
129
134void CRYPT_SIPHASH_FreeCtx(CRYPT_SIPHASH_Ctx *ctx);
135
141CRYPT_SIPHASH_Ctx *CRYPT_SIPHASH_DupCtx(const CRYPT_SIPHASH_Ctx *ctx);
142
143#ifdef __cplusplus
144}
145#endif
146
147#endif /* HITLS_CRYPTO_SIPHASH */
148
149#endif
CRYPT_MAC_AlgId
定义 crypt_algid.h:91