summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/m_sha3.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/evp/m_sha3.c177
1 files changed, 0 insertions, 177 deletions
diff --git a/src/lib/libcrypto/evp/m_sha3.c b/src/lib/libcrypto/evp/m_sha3.c
deleted file mode 100644
index a21833b605..0000000000
--- a/src/lib/libcrypto/evp/m_sha3.c
+++ /dev/null
@@ -1,177 +0,0 @@
1/* $OpenBSD: m_sha3.c,v 1.4 2024/04/09 13:52:41 beck Exp $ */
2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <openssl/evp.h>
19
20#include "evp_local.h"
21#include "sha3_internal.h"
22
23static int
24sha3_224_init(EVP_MD_CTX *ctx)
25{
26 return sha3_init(ctx->md_data, SHA3_224_DIGEST_LENGTH);
27}
28
29static int
30sha3_224_update(EVP_MD_CTX *ctx, const void *data, size_t count)
31{
32 return sha3_update(ctx->md_data, data, count);
33}
34
35static int
36sha3_224_final(EVP_MD_CTX *ctx, unsigned char *md)
37{
38 return sha3_final(md, ctx->md_data);
39}
40
41static const EVP_MD sha3_224_md = {
42 .type = NID_sha3_224,
43 .pkey_type = NID_RSA_SHA3_224,
44 .md_size = SHA3_224_DIGEST_LENGTH,
45 .flags = EVP_MD_FLAG_DIGALGID_ABSENT,
46 .init = sha3_224_init,
47 .update = sha3_224_update,
48 .final = sha3_224_final,
49 .copy = NULL,
50 .cleanup = NULL,
51 .block_size = SHA3_224_BLOCK_SIZE,
52 .ctx_size = sizeof(EVP_MD *) + sizeof(sha3_ctx),
53};
54
55const EVP_MD *
56EVP_sha3_224(void)
57{
58 return &sha3_224_md;
59}
60LCRYPTO_ALIAS(EVP_sha3_224);
61
62static int
63sha3_256_init(EVP_MD_CTX *ctx)
64{
65 return sha3_init(ctx->md_data, SHA3_256_DIGEST_LENGTH);
66}
67
68static int
69sha3_256_update(EVP_MD_CTX *ctx, const void *data, size_t count)
70{
71 return sha3_update(ctx->md_data, data, count);
72}
73
74static int
75sha3_256_final(EVP_MD_CTX *ctx, unsigned char *md)
76{
77 return sha3_final(md, ctx->md_data);
78}
79
80static const EVP_MD sha3_256_md = {
81 .type = NID_sha3_256,
82 .pkey_type = NID_RSA_SHA3_256,
83 .md_size = SHA3_256_DIGEST_LENGTH,
84 .flags = EVP_MD_FLAG_DIGALGID_ABSENT,
85 .init = sha3_256_init,
86 .update = sha3_256_update,
87 .final = sha3_256_final,
88 .copy = NULL,
89 .cleanup = NULL,
90 .block_size = SHA3_256_BLOCK_SIZE,
91 .ctx_size = sizeof(EVP_MD *) + sizeof(sha3_ctx),
92};
93
94const EVP_MD *
95EVP_sha3_256(void)
96{
97 return &sha3_256_md;
98}
99LCRYPTO_ALIAS(EVP_sha3_256);
100
101static int
102sha3_384_init(EVP_MD_CTX *ctx)
103{
104 return sha3_init(ctx->md_data, SHA3_384_DIGEST_LENGTH);
105}
106
107static int
108sha3_384_update(EVP_MD_CTX *ctx, const void *data, size_t count)
109{
110 return sha3_update(ctx->md_data, data, count);
111}
112
113static int
114sha3_384_final(EVP_MD_CTX *ctx, unsigned char *md)
115{
116 return sha3_final(md, ctx->md_data);
117}
118
119static const EVP_MD sha3_384_md = {
120 .type = NID_sha3_384,
121 .pkey_type = NID_RSA_SHA3_384,
122 .md_size = SHA3_384_DIGEST_LENGTH,
123 .flags = EVP_MD_FLAG_DIGALGID_ABSENT,
124 .init = sha3_384_init,
125 .update = sha3_384_update,
126 .final = sha3_384_final,
127 .copy = NULL,
128 .cleanup = NULL,
129 .block_size = SHA3_384_BLOCK_SIZE,
130 .ctx_size = sizeof(EVP_MD *) + sizeof(sha3_ctx),
131};
132
133const EVP_MD *
134EVP_sha3_384(void)
135{
136 return &sha3_384_md;
137}
138LCRYPTO_ALIAS(EVP_sha3_384);
139
140static int
141sha3_512_init(EVP_MD_CTX *ctx)
142{
143 return sha3_init(ctx->md_data, SHA3_512_DIGEST_LENGTH);
144}
145
146static int
147sha3_512_update(EVP_MD_CTX *ctx, const void *data, size_t count)
148{
149 return sha3_update(ctx->md_data, data, count);
150}
151
152static int
153sha3_512_final(EVP_MD_CTX *ctx, unsigned char *md)
154{
155 return sha3_final(md, ctx->md_data);
156}
157
158static const EVP_MD sha3_512_md = {
159 .type = NID_sha3_512,
160 .pkey_type = NID_RSA_SHA3_512,
161 .md_size = SHA3_512_DIGEST_LENGTH,
162 .flags = EVP_MD_FLAG_DIGALGID_ABSENT,
163 .init = sha3_512_init,
164 .update = sha3_512_update,
165 .final = sha3_512_final,
166 .copy = NULL,
167 .cleanup = NULL,
168 .block_size = SHA3_512_BLOCK_SIZE,
169 .ctx_size = sizeof(EVP_MD *) + sizeof(sha3_ctx),
170};
171
172const EVP_MD *
173EVP_sha3_512(void)
174{
175 return &sha3_512_md;
176}
177LCRYPTO_ALIAS(EVP_sha3_512);