]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/crypto/siphash.h
providers: Add SM4 XTS implementation
[thirdparty/openssl.git] / include / crypto / siphash.h
CommitLineData
3f5616d7 1/*
a28d06f3 2 * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
3f5616d7 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
3f5616d7
TS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
80ce21fe
F
10#ifndef OSSL_CRYPTO_SIPHASH_H
11# define OSSL_CRYPTO_SIPHASH_H
12# pragma once
3f5616d7 13
80ce21fe
F
14# include <stddef.h>
15
16# define SIPHASH_BLOCK_SIZE 8
17# define SIPHASH_KEY_SIZE 16
18# define SIPHASH_MIN_DIGEST_SIZE 8
19# define SIPHASH_MAX_DIGEST_SIZE 16
3f5616d7
TS
20
21typedef struct siphash_st SIPHASH;
22
23size_t SipHash_ctx_size(void);
24size_t SipHash_hash_size(SIPHASH *ctx);
d74f23d2
RL
25int SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size);
26int SipHash_Init(SIPHASH *ctx, const unsigned char *k,
3f5616d7
TS
27 int crounds, int drounds);
28void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen);
29int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen);
80ce21fe 30
5db68273
MC
31/* Based on https://131002.net/siphash C reference implementation */
32
33struct siphash_st {
34 uint64_t total_inlen;
35 uint64_t v0;
36 uint64_t v1;
37 uint64_t v2;
38 uint64_t v3;
39 unsigned int len;
40 unsigned int hash_size;
41 unsigned int crounds;
42 unsigned int drounds;
43 unsigned char leavings[SIPHASH_BLOCK_SIZE];
44};
45
46/* default: SipHash-2-4 */
47# define SIPHASH_C_ROUNDS 2
48# define SIPHASH_D_ROUNDS 4
49
80ce21fe 50#endif