KDELibs4Support

kmd5.h
1 /*
2  Copyright (C) 2000-2001 Dawit Alemayehu <[email protected]>
3  Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License (LGPL)
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 
18  RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. // krazy:exclude=copyright
19  RSA Data Security, Inc. Created 1991. All rights reserved.
20 
21  The KMD5 class is based on a C++ implementation of
22  "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by
23  Mordechai T. Abzug, Copyright (c) 1995. This implementation // krazy:exclude=copyright
24  passes the test-suite as defined in RFC 1321.
25 
26  The encoding and decoding utilities in KCodecs with the exception of
27  quoted-printable are based on the java implementation in HTTPClient
28  package by Ronald Tschalär Copyright (C) 1996-1999. // krazy:exclude=copyright
29 
30  The quoted-printable codec as described in RFC 2045, section 6.7. is by
31  Rik Hemsley (C) 2001.
32 */
33 
34 #ifndef KMD5_H
35 #define KMD5_H
36 
37 #include <kdelibs4support_export.h>
38 #include <qglobal.h>
39 
40 class QByteArray;
41 class QIODevice;
42 
43 class KMD5Private;
94 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KMD5
95 {
96 public:
97 
98  typedef unsigned char Digest[16];
99 
100  KMD5();
101  ~KMD5();
102 
111  KDELIBS4SUPPORT_DEPRECATED explicit KMD5(const char *in, int len = -1);
112 
118  KDELIBS4SUPPORT_DEPRECATED explicit KMD5(const QByteArray &a);
119 
130  void update(const char *in, int len = -1);
131 
137  void update(const unsigned char *in, int len = -1);
138 
146  void update(const QByteArray &in);
147 
161  bool update(QIODevice &file);
162 
170  void reset();
171 
176  const Digest &rawDigest(); //krazy:exclude=constref (simple array)
177 
187  void rawDigest(KMD5::Digest &bin);
188 
194  QByteArray hexDigest();
195 
199  void hexDigest(QByteArray &);
200 
206  QByteArray base64Digest();
207 
212  bool verify(const KMD5::Digest &digest);
213 
217  bool verify(const QByteArray &);
218 
219 protected:
224  void transform(const unsigned char buffer[64]);
225 
229  void finalize();
230 
231 private:
232  KMD5(const KMD5 &u);
233  KMD5 &operator=(const KMD5 &md);
234 
235  void init();
236  void encode(unsigned char *output, quint32 *in, quint32 len);
237  void decode(quint32 *output, const unsigned char *in, quint32 len);
238 
239  quint32 rotate_left(quint32 x, quint32 n);
240  quint32 F(quint32 x, quint32 y, quint32 z);
241  quint32 G(quint32 x, quint32 y, quint32 z);
242  quint32 H(quint32 x, quint32 y, quint32 z);
243  quint32 I(quint32 x, quint32 y, quint32 z);
244  void FF(quint32 &a, quint32 b, quint32 c, quint32 d, quint32 x,
245  quint32 s, quint32 ac);
246  void GG(quint32 &a, quint32 b, quint32 c, quint32 d, quint32 x,
247  quint32 s, quint32 ac);
248  void HH(quint32 &a, quint32 b, quint32 c, quint32 d, quint32 x,
249  quint32 s, quint32 ac);
250  void II(quint32 &a, quint32 b, quint32 c, quint32 d, quint32 x,
251  quint32 s, quint32 ac);
252 
253 private:
254  quint32 m_state[4];
255  quint32 m_count[2];
256  quint8 m_buffer[64];
257  Digest m_digest;
258  bool m_finalized;
259 
260  KMD5Private *d;
261 };
262 
263 #endif // KCODECS_H
An adapted C++ implementation of RSA Data Securities MD5 algorithm.
Definition: kmd5.h:94
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jul 6 2020 22:57:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.