• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
kmdcodec.h
1/*
2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
3 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
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 General Public License for more details.
13
14 You should have received a copy of the GNU Library 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.
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
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.
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 _KMDBASE_H
35#define _KMDBASE_H
36
37#define KBase64 KCodecs
38
39#include <tqglobal.h>
40#include <tqstring.h>
41#include <tqiodevice.h>
42#include "tdelibs_export.h"
43
74class TDECORE_EXPORT KCodecs
75{
76public:
77
87 static TQCString quotedPrintableEncode(const TQByteArray & in,
88 bool useCRLF = true);
89
102 static TQCString quotedPrintableEncode(const TQCString & str,
103 bool useCRLF = true);
104
123 static void quotedPrintableEncode(const TQByteArray & in, TQByteArray& out,
124 bool useCRLF);
125
134 static TQCString quotedPrintableDecode(const TQByteArray & in);
135
145 static TQCString quotedPrintableDecode(const TQCString & str);
146
164 static void quotedPrintableDecode(const TQByteArray & in, TQByteArray& out);
165
166
178 static TQCString uuencode( const TQByteArray& in );
179
189 static TQCString uuencode( const TQCString& str );
190
206 static void uuencode( const TQByteArray& in, TQByteArray& out );
207
218 static TQCString uudecode( const TQByteArray& in );
219
229 static TQCString uudecode( const TQCString& str );
230
250 static void uudecode( const TQByteArray& in, TQByteArray& out );
251
252
266 static TQCString base64Encode( const TQByteArray& in, bool insertLFs = false);
267
278 static TQCString base64Encode( const TQCString& str, bool insertLFs = false );
279
301 static void base64Encode( const TQByteArray& in, TQByteArray& out,
302 bool insertLFs = false );
303
311 static TQCString base64Decode( const TQByteArray& in );
312
322 static TQCString base64Decode( const TQCString& str );
323
341 static void base64Decode( const TQByteArray& in, TQByteArray& out );
342
343
344private:
345 KCodecs();
346
347private:
348 static const char UUEncMap[64];
349 static const char UUDecMap[128];
350 static const char Base64EncMap[64];
351 static const char Base64DecMap[128];
352 static const char hexChars[16];
353 static const unsigned int maxQPLineLength;
354};
355
356class KMD5Private;
402class TDECORE_EXPORT KMD5
403{
404public:
405
406 typedef unsigned char Digest[16];
407
408 KMD5();
409
418 KMD5(const char* in, int len = -1);
419
425 KMD5(const TQByteArray& a );
426
432 KMD5(const TQCString& a );
433
442 void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
443
447 void update(const unsigned char* in, int len = -1);
448
454 void update(const TQByteArray& in );
455
461 void update(const TQCString& in );
462
474 bool update(TQIODevice& file);
475
481 void reset();
482
486 const Digest& rawDigest ();
487
497 void rawDigest( KMD5::Digest& bin );
498
503 TQCString hexDigest ();
504
508 void hexDigest(TQCString&);
509
514 TQCString base64Digest ();
515
520 bool verify( const KMD5::Digest& digest);
521
525 bool verify(const TQCString&);
526
527protected:
532 void transform( const unsigned char buffer[64] );
533
537 void finalize();
538
539private:
540 KMD5(const KMD5& u);
541 KMD5& operator=(const KMD5& md);
542
543 void init();
544 void encode( unsigned char* output, TQ_UINT32 *in, TQ_UINT32 len );
545 void decode( TQ_UINT32 *output, const unsigned char* in, TQ_UINT32 len );
546
547 TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n );
548 TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
549 TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
550 TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
551 TQ_UINT32 I( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
552 void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
553 TQ_UINT32 s, TQ_UINT32 ac );
554 void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
555 TQ_UINT32 s, TQ_UINT32 ac );
556 void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
557 TQ_UINT32 s, TQ_UINT32 ac );
558 void II( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
559 TQ_UINT32 s, TQ_UINT32 ac );
560
561private:
562 TQ_UINT32 m_state[4];
563 TQ_UINT32 m_count[2];
564 TQ_UINT8 m_buffer[64];
565 Digest m_digest;
566 bool m_finalized;
567
568 KMD5Private* d;
569};
570
577class TDECORE_EXPORT KMD4
578{
579public:
580
581 typedef unsigned char Digest[16];
582
583 KMD4();
584
593 KMD4(const char* in, int len = -1);
594
600 KMD4(const TQByteArray& a );
601
607 KMD4(const TQCString& a );
608
617 void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
618
622 void update(const unsigned char* in, int len = -1);
623
629 void update(const TQByteArray& in );
630
636 void update(const TQCString& in );
637
649 bool update(TQIODevice& file);
650
656 void reset();
657
661 const Digest& rawDigest ();
662
672 void rawDigest( KMD4::Digest& bin );
673
678 TQCString hexDigest ();
679
683 void hexDigest(TQCString&);
684
689 TQCString base64Digest ();
690
695 bool verify( const KMD4::Digest& digest);
696
700 bool verify(const TQCString&);
701
702protected:
707 void transform( TQ_UINT32 buf[4], TQ_UINT32 const in[16] );
708
712 void finalize();
713
714private:
715 KMD4(const KMD4& u);
716 KMD4& operator=(const KMD4& md);
717
718 void init();
719
720 void byteReverse( unsigned char *buf, TQ_UINT32 len );
721
722 TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n );
723 TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
724 TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
725 TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
726 void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
727 TQ_UINT32 s );
728 void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
729 TQ_UINT32 s );
730 void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
731 TQ_UINT32 s );
732
733private:
734 TQ_UINT32 m_state[4];
735 TQ_UINT32 m_count[2];
736 TQ_UINT8 m_buffer[64];
737 Digest m_digest;
738 bool m_finalized;
739
740 class KMD4Private;
741 KMD4Private* d;
742};
743
744
745#endif
KCodecs
A wrapper class for the most commonly used encoding and decoding algorithms.
Definition: kmdcodec.h:75
KMD4
An adapted C++ implementation of the MD4 Message-Digest algorithm.
Definition: kmdcodec.h:578
KMD4::update
void update(const char *in, int len=-1)
Updates the message to be digested.
Definition: kmdcodec.h:617
KMD5
An adapted C++ implementation of RSA Data Securities MD5 algorithm.
Definition: kmdcodec.h:403
KMD5::update
void update(const char *in, int len=-1)
Updates the message to be digested.
Definition: kmdcodec.h:442

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.