libsidplayfp
2.6.0
Main Page
Classes
Files
Examples
File List
src
utils
md5Gcrypt.h
1
/*
2
* This file is part of libsidplayfp, a SID player engine.
3
*
4
* Copyright 2013 Leandro Nini <drfiemost@users.sourceforge.net>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*/
20
21
#ifndef MD5_GCRYPT_H
22
#define MD5_GCRYPT_H
23
24
#define GCRYPT_NO_MPI_MACROS
25
#define GCRYPT_NO_DEPRECATED
26
27
#include "iMd5.h"
28
29
#include "sidcxx11.h"
30
31
#include <gcrypt.h>
32
33
namespace
libsidplayfp
34
{
35
36
class
md5Gcrypt
final :
public
iMd5
37
{
38
private
:
39
gcry_md_hd_t
hd;
40
41
public
:
42
md5Gcrypt
()
43
{
44
if
(
gcry_check_version
(
GCRYPT_VERSION
) == 0)
45
throw
md5Error
();
46
47
// Disable secure memory.
48
if
(
gcry_control
(
GCRYCTL_DISABLE_SECMEM
, 0) != 0)
49
throw
md5Error
();
50
51
// Tell Libgcrypt that initialization has completed.
52
if
(
gcry_control
(
GCRYCTL_INITIALIZATION_FINISHED
, 0) != 0)
53
throw
md5Error
();
54
55
if
(
gcry_md_open
(&hd,
GCRY_MD_MD5
, 0) != 0)
56
throw
md5Error
();
57
}
58
59
~md5Gcrypt
() {
gcry_md_close
(hd); }
60
61
void
append(
const
void
* data,
int
nbytes
)
override
{
gcry_md_write
(hd, data,
nbytes
); }
62
63
void
finish()
override
{
gcry_md_final
(hd); }
64
65
const
unsigned
char
* getDigest()
override
{
return
gcry_md_read
(hd, 0); }
66
67
void
reset()
override
{
gcry_md_reset
(hd); }
68
};
69
70
}
71
72
#endif
libsidplayfp::EventCallback
Definition
EventCallback.h:36
libsidplayfp::iMd5
Definition
iMd5.h:28
libsidplayfp::md5Error
Definition
iMd5.h:37
libsidplayfp::md5Gcrypt
Definition
md5Gcrypt.h:37
Generated on Thu Jan 25 2024 00:00:00 for libsidplayfp by
1.10.0