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

tdecore

kmdcodec.h

00001 /*
00002    Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
00003    Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU Lesser General Public License (LGPL)
00007    version 2 as published by the Free Software Foundation.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018    RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992.
00019    RSA Data Security, Inc. Created 1991. All rights reserved.
00020 
00021    The KMD5 class is based on a C++ implementation of
00022    "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by
00023    Mordechai T. Abzug,  Copyright (c) 1995.  This implementation
00024    passes the test-suite as defined in RFC 1321.
00025 
00026    The encoding and decoding utilities in KCodecs with the exception of
00027    quoted-printable are based on the java implementation in HTTPClient
00028    package by Ronald Tschalär Copyright (C) 1996-1999.
00029 
00030    The quoted-printable codec as described in RFC 2045, section 6.7. is by
00031    Rik Hemsley (C) 2001.
00032 */
00033 
00034 #ifndef _KMDBASE_H
00035 #define _KMDBASE_H
00036 
00037 #define KBase64 KCodecs
00038 
00039 #include <tqglobal.h>
00040 #include <tqstring.h>
00041 #include <tqiodevice.h>
00042 #include "tdelibs_export.h"
00043 
00074 class TDECORE_EXPORT KCodecs
00075 {
00076 public:
00077 
00087   static TQCString quotedPrintableEncode(const TQByteArray & in,
00088                                         bool useCRLF = true);
00089 
00102   static TQCString quotedPrintableEncode(const TQCString & str,
00103                                         bool useCRLF = true);
00104 
00123   static void quotedPrintableEncode(const TQByteArray & in, TQByteArray& out,
00124                                     bool useCRLF);
00125 
00134   static TQCString quotedPrintableDecode(const TQByteArray & in);
00135 
00145   static TQCString quotedPrintableDecode(const TQCString & str);
00146 
00164   static void quotedPrintableDecode(const TQByteArray & in, TQByteArray& out);
00165 
00166 
00178   static TQCString uuencode( const TQByteArray& in );
00179 
00189   static TQCString uuencode( const TQCString& str );
00190 
00206   static void uuencode( const TQByteArray& in, TQByteArray& out );
00207 
00218   static TQCString uudecode( const TQByteArray& in );
00219 
00229   static TQCString uudecode( const TQCString& str );
00230 
00250   static void uudecode( const TQByteArray& in, TQByteArray& out );
00251 
00252 
00266   static TQCString base64Encode( const TQByteArray& in, bool insertLFs = false);
00267 
00278   static TQCString base64Encode( const TQCString& str, bool insertLFs = false );
00279 
00301   static void base64Encode( const TQByteArray& in, TQByteArray& out,
00302                             bool insertLFs = false );
00303 
00311   static TQCString base64Decode( const TQByteArray& in );
00312 
00322   static TQCString base64Decode( const TQCString& str );
00323 
00341   static void base64Decode( const TQByteArray& in, TQByteArray& out );
00342 
00343 
00344 private:
00345   KCodecs();
00346 
00347 private:
00348   static const char UUEncMap[64];
00349   static const char UUDecMap[128];
00350   static const char Base64EncMap[64];
00351   static const char Base64DecMap[128];
00352   static const char hexChars[16];
00353   static const unsigned int maxQPLineLength;
00354 };
00355 
00356 class KMD5Private;
00402 class TDECORE_EXPORT KMD5
00403 {
00404 public:
00405 
00406   typedef unsigned char Digest[16];
00407 
00408   KMD5();
00409 
00418   KMD5(const char* in, int len = -1);
00419 
00425   KMD5(const TQByteArray& a );
00426 
00432   KMD5(const TQCString& a );
00433 
00442   void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
00443 
00447   void update(const unsigned char* in, int len = -1);
00448 
00454   void update(const TQByteArray& in );
00455 
00461   void update(const TQCString& in );
00462 
00474   bool update(TQIODevice& file);
00475 
00481   void reset();
00482 
00486   const Digest& rawDigest ();
00487 
00497   void rawDigest( KMD5::Digest& bin );
00498 
00503   TQCString hexDigest ();
00504 
00508   void hexDigest(TQCString&);
00509 
00514   TQCString base64Digest ();
00515 
00520   bool verify( const KMD5::Digest& digest);
00521 
00525   bool verify(const TQCString&);
00526 
00527 protected:
00532   void transform( const unsigned char buffer[64] );
00533 
00537   void finalize();
00538 
00539 private:
00540   KMD5(const KMD5& u);
00541   KMD5& operator=(const KMD5& md);
00542 
00543   void init();
00544   void encode( unsigned char* output, TQ_UINT32 *in, TQ_UINT32 len );
00545   void decode( TQ_UINT32 *output, const unsigned char* in, TQ_UINT32 len );
00546 
00547   TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n );
00548   TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00549   TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00550   TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00551   TQ_UINT32 I( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00552   void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00553                TQ_UINT32  s, TQ_UINT32 ac );
00554   void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00555                 TQ_UINT32 s, TQ_UINT32 ac );
00556   void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00557                 TQ_UINT32 s, TQ_UINT32 ac );
00558   void II( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00559              TQ_UINT32 s, TQ_UINT32 ac );
00560 
00561 private:
00562   TQ_UINT32 m_state[4];
00563   TQ_UINT32 m_count[2];
00564   TQ_UINT8 m_buffer[64];
00565   Digest m_digest;
00566   bool m_finalized;
00567 
00568   KMD5Private* d;
00569 };
00570 
00577 class TDECORE_EXPORT KMD4
00578 {
00579 public:
00580 
00581   typedef unsigned char Digest[16];
00582 
00583   KMD4();
00584 
00593   KMD4(const char* in, int len = -1);
00594 
00600   KMD4(const TQByteArray& a );
00601 
00607   KMD4(const TQCString& a );
00608 
00617   void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
00618 
00622   void update(const unsigned char* in, int len = -1);
00623 
00629   void update(const TQByteArray& in );
00630 
00636   void update(const TQCString& in );
00637 
00649   bool update(TQIODevice& file);
00650 
00656   void reset();
00657 
00661   const Digest& rawDigest ();
00662 
00672   void rawDigest( KMD4::Digest& bin );
00673 
00678   TQCString hexDigest ();
00679 
00683   void hexDigest(TQCString&);
00684 
00689   TQCString base64Digest ();
00690 
00695   bool verify( const KMD4::Digest& digest);
00696 
00700   bool verify(const TQCString&);
00701 
00702 protected:
00707   void transform( TQ_UINT32 buf[4], TQ_UINT32 const in[16] );
00708 
00712   void finalize();
00713 
00714 private:
00715   KMD4(const KMD4& u);
00716   KMD4& operator=(const KMD4& md);
00717 
00718   void init();
00719 
00720   void byteReverse( unsigned char *buf, TQ_UINT32 len );
00721 
00722   TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n );
00723   TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00724   TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00725   TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z );
00726   void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00727                TQ_UINT32  s );
00728   void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00729                 TQ_UINT32 s );
00730   void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x,
00731                 TQ_UINT32 s );
00732 
00733 private:
00734   TQ_UINT32 m_state[4];
00735   TQ_UINT32 m_count[2];
00736   TQ_UINT8 m_buffer[64];
00737   Digest m_digest;
00738   bool m_finalized;
00739 
00740   class KMD4Private;
00741   KMD4Private* d;
00742 };
00743 
00744 
00745 #endif

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.6.3
This website is maintained by Timothy Pearson.