core/md5.h
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/core/md5.h	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,106 +0,0 @@
     1.4 -// MD5.CC - source code for the C++/object oriented translation and 
     1.5 -//          modification of MD5.
     1.6 -
     1.7 -// Translation and modification (c) 1995 by Mordechai T. Abzug 
     1.8 -
     1.9 -// This translation/ modification is provided "as is," without express or 
    1.10 -// implied warranty of any kind.
    1.11 -
    1.12 -// The translator/ modifier does not claim (1) that MD5 will do what you think 
    1.13 -// it does; (2) that this translation/ modification is accurate; or (3) that 
    1.14 -// this software is "merchantible."  (Language for this disclaimer partially 
    1.15 -// copied from the disclaimer below).
    1.16 -
    1.17 -/* based on:
    1.18 -
    1.19 -   MD5.H - header file for MD5C.C
    1.20 -   MDDRIVER.C - test driver for MD2, MD4 and MD5
    1.21 -
    1.22 -   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
    1.23 -rights reserved.
    1.24 -
    1.25 -License to copy and use this software is granted provided that it
    1.26 -is identified as the "RSA Data Security, Inc. MD5 Message-Digest
    1.27 -Algorithm" in all material mentioning or referencing this software
    1.28 -or this function.
    1.29 -
    1.30 -License is also granted to make and use derivative works provided
    1.31 -that such works are identified as "derived from the RSA Data
    1.32 -Security, Inc. MD5 Message-Digest Algorithm" in all material
    1.33 -mentioning or referencing the derived work.
    1.34 -
    1.35 -RSA Data Security, Inc. makes no representations concerning either
    1.36 -the merchantability of this software or the suitability of this
    1.37 -software for any particular purpose. It is provided "as is"
    1.38 -without express or implied warranty of any kind.
    1.39 -
    1.40 -These notices must be retained in any copies of any part of this
    1.41 -documentation and/or software.
    1.42 -
    1.43 -*/
    1.44 -
    1.45 -#include <stdio.h>
    1.46 -//#include <fstream.h>
    1.47 -//#include <iostream.h>
    1.48 -
    1.49 -class MD5 {
    1.50 -
    1.51 -public:
    1.52 -// methods for controlled operation:
    1.53 -  MD5              ();  // simple initializer
    1.54 -  void  update     (unsigned char *input, unsigned int input_length);
    1.55 -  void  update     (FILE *file);
    1.56 -  void  finalize   ();
    1.57 -
    1.58 -// constructors for special circumstances.  All these constructors finalize
    1.59 -// the MD5 context.
    1.60 -  MD5              (unsigned char *string); // digest string, finalize
    1.61 -  MD5              (FILE *file);            // digest file, close, finalize
    1.62 -
    1.63 -// methods to acquire finalized result
    1.64 -  unsigned char    *raw_digest ();  // digest as a 16-byte binary array
    1.65 -  unsigned char		*raw_digest(unsigned char buffer[16]);
    1.66 -  char *            hex_digest ();  // digest as a 33-byte ascii-hex string
    1.67 -  char *			hex_digest (char buffer[33]); //same as above, passing buffer
    1.68 -
    1.69 -
    1.70 -
    1.71 -private:
    1.72 -
    1.73 -// first, some types:
    1.74 -  typedef unsigned       int uint4; // assumes integer is 4 words long
    1.75 -  typedef unsigned short int uint2; // assumes short integer is 2 words long
    1.76 -  typedef unsigned      char uint1; // assumes char is 1 word long
    1.77 -
    1.78 -// next, the private data:
    1.79 -  uint4 state[4];
    1.80 -  uint4 count[2];     // number of *bits*, mod 2^64
    1.81 -  uint1 buffer[64];   // input buffer
    1.82 -  uint1 digest[16];
    1.83 -  uint1 finalized;
    1.84 -
    1.85 -// last, the private methods, mostly static:
    1.86 -  void init             ();               // called by all constructors
    1.87 -  void transform        (uint1 *buffer);  // does the real update work.  Note 
    1.88 -                                          // that length is implied to be 64.
    1.89 -
    1.90 -  static void encode    (uint1 *dest, uint4 *src, uint4 length);
    1.91 -  static void decode    (uint4 *dest, uint1 *src, uint4 length);
    1.92 -  static void memcpy    (uint1 *dest, uint1 *src, uint4 length);
    1.93 -  static void memset    (uint1 *start, uint1 val, uint4 length);
    1.94 -
    1.95 -  static inline uint4  rotate_left (uint4 x, uint4 n);
    1.96 -  static inline uint4  F           (uint4 x, uint4 y, uint4 z);
    1.97 -  static inline uint4  G           (uint4 x, uint4 y, uint4 z);
    1.98 -  static inline uint4  H           (uint4 x, uint4 y, uint4 z);
    1.99 -  static inline uint4  I           (uint4 x, uint4 y, uint4 z);
   1.100 -  static inline void   FF  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
   1.101 -			    uint4 s, uint4 ac);
   1.102 -  static inline void   GG  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
   1.103 -			    uint4 s, uint4 ac);
   1.104 -  static inline void   HH  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
   1.105 -			    uint4 s, uint4 ac);
   1.106 -  static inline void   II  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
   1.107 -			    uint4 s, uint4 ac);
   1.108 -
   1.109 -};