GNU libmicrohttpd
1.0.6
Toggle main menu visibility
Loading...
Searching...
No Matches
md5_ext.c
Go to the documentation of this file.
1
/*
2
This file is part of GNU libmicrohttpd
3
Copyright (C) 2022-2023 Evgeny Grin (Karlson2k)
4
5
GNU libmicrohttpd is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
License along with GNU libmicrohttpd.
17
If not, see <http://www.gnu.org/licenses/>.
18
*/
19
25
26
#include <gnutls/crypto.h>
27
#include "
md5_ext.h
"
28
#include "
mhd_assert.h
"
29
30
38
void
39
MHD_MD5_init_one_time
(
struct
Md5CtxExt
*ctx)
40
{
41
ctx->
handle
=
NULL
;
42
ctx->
ext_error
= gnutls_hash_init (&ctx->
handle
,
43
GNUTLS_DIG_MD5);
44
if
((0 != ctx->
ext_error
) && (
NULL
!= ctx->
handle
))
45
{
46
/* GnuTLS may return initialisation error and set the handle at the
47
same time. Such handle cannot be used for calculations.
48
Note: GnuTLS may also return an error and NOT set the handle. */
49
gnutls_free (ctx->
handle
);
50
ctx->
handle
=
NULL
;
51
}
52
53
/* If handle is NULL, the error must be set */
54
mhd_assert
((
NULL
!= ctx->
handle
) || (0 != ctx->
ext_error
));
55
/* If error is set, the handle must be NULL */
56
mhd_assert
((0 == ctx->
ext_error
) || (
NULL
== ctx->
handle
));
57
}
58
59
67
void
68
MHD_MD5_update
(
struct
Md5CtxExt
*ctx,
69
const
uint8_t *
data
,
70
size_t
length)
71
{
72
if
(0 == ctx->
ext_error
)
73
ctx->
ext_error
= gnutls_hash (ctx->
handle
,
data
, length);
74
}
75
76
83
void
84
MHD_MD5_finish_reset
(
struct
Md5CtxExt
*ctx,
85
uint8_t digest[
MD5_DIGEST_SIZE
])
86
{
87
if
(0 == ctx->
ext_error
)
88
gnutls_hash_output (ctx->
handle
, digest);
89
}
90
91
97
void
98
MHD_MD5_deinit
(
struct
Md5CtxExt
*ctx)
99
{
100
if
(
NULL
!= ctx->
handle
)
101
gnutls_hash_deinit (ctx->
handle
,
NULL
);
102
}
MD5_DIGEST_SIZE
#define MD5_DIGEST_SIZE
Definition
md5.h:61
MHD_MD5_update
void MHD_MD5_update(struct Md5CtxExt *ctx, const uint8_t *data, size_t length)
Definition
md5_ext.c:68
md5_ext.h
Wrapper declarations for MD5 calculation performed by TLS library.
mhd_assert.h
macros for mhd_assert()
mhd_assert
#define mhd_assert(ignore)
Definition
mhd_assert.h:45
MHD_MD5_finish_reset
#define MHD_MD5_finish_reset(ctx, digest)
Definition
mhd_md5_wrap.h:81
MHD_MD5_deinit
#define MHD_MD5_deinit(ignore)
Definition
mhd_md5_wrap.h:89
MHD_MD5_init_one_time
#define MHD_MD5_init_one_time(ctx)
Definition
mhd_md5_wrap.h:70
NULL
#define NULL
Definition
mhd_mono_clock.c:66
data
void * data
Definition
microhttpd.h:4030
Md5CtxExt
Definition
md5_ext.h:51
Md5CtxExt::ext_error
int ext_error
Definition
md5_ext.h:53
Md5CtxExt::handle
struct hash_hd_st * handle
Definition
md5_ext.h:52
src
microhttpd
md5_ext.c
Generated by
1.17.0