• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

md5.h

Go to the documentation of this file.
00001 //  Declaration of functions and data types used for MD5 sum computing
00002 //  library functions.
00003 //  Copyright (C) 1995-1997,1999,2000,2001,2004,2005, 2009
00004 //  Free Software Foundation, Inc.
00005 //  This file is part of the GNU C Library.
00006 //  The GNU C Library is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU Lesser General Public
00008 //  License as published by the Free Software Foundation; either
00009 //  version 2.1 of the License, or (at your option) any later version.
00010 
00011 //  The GNU C Library is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //  Lesser General Public License for more details.
00015 
00016 //  You should have received a copy of the GNU Lesser General Public
00017 //  License along with the GNU C Library; if not, write to the Free
00018 //  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019 //  02111-1307 USA.
00020 
00021 // Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
00022 // Trimmed by Rob Savoye for Gnash, and converted to C++ <rob@welcomehome.org>, 2007.
00023 
00024 #ifndef _MD5_H
00025 #define _MD5_H 1
00026 
00027 #include <cstdio>
00028 #include <string>
00029 #include <boost/cstdint.hpp>
00030 
00031 // #if defined HAVE_LIMITS_H
00032 // # include <limits.h>
00033 // #endif
00034 
00035 #define MD5_DIGEST_SIZE 16
00036 #define MD5_BLOCK_SIZE 64
00037 
00038 typedef unsigned long md5_uintptr;
00039 
00040 // Structure to save state of computation between the single steps. 
00041 struct md5_ctx
00042 {
00043   uint32_t A;
00044   uint32_t B;
00045   uint32_t C;
00046   uint32_t D;
00047 
00048   uint32_t total[2];
00049   uint32_t buflen;
00050   char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
00051 };
00052 
00053 // The following three functions are build up the low level used in
00054 // the functions `md5_stream' and `md5_buffer'.
00055 
00056 // Initialize structure containing state of computation.
00057 // (RFC 1321, 3.3: Step 3)
00058 void md5_init_ctx (struct md5_ctx *ctx);
00059 
00060 // Starting with the result of former calls of this function (or the
00061 // initialization function update the context for the next LEN bytes
00062 // starting at BUFFER.
00063 // It is necessary that LEN is a multiple of 64!!!
00064 void md5_process_block (const void *buffer, size_t len,
00065                                  struct md5_ctx *ctx);
00066 
00067 // Starting with the result of former calls of this function (or the
00068 // initialization function update the context for the next LEN bytes
00069 // starting at BUFFER.
00070 // It is NOT required that LEN is a multiple of 64.
00071 void md5_process_bytes (const void *buffer, size_t len,
00072                                  struct md5_ctx *ctx);
00073 
00074 // Process the remaining bytes in the buffer and put result from CTX
00075 // in first 16 bytes following RESBUF.  The result is always in little
00076 // endian byte order, so that a byte-wise output yields to the wanted
00077 // ASCII representation of the message digest.
00078 
00079 // IMPORTANT: On some systems it is required that RESBUF is correctly
00080 // aligned for a 32 bits value.
00081 void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
00082 
00083 
00084 // Put result from CTX in first 16 bytes following RESBUF.  The result is
00085 // always in little endian byte order, so that a byte-wise output yields
00086 // to the wanted ASCII representation of the message digest.
00087 
00088 // IMPORTANT: On some systems it is required that RESBUF is correctly
00089 // aligned for a 32 bits value.
00090 void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
00091 
00092 // Compute MD5 message digest for bytes read from STREAM.  The
00093 // resulting message digest number will be written into the 16 bytes
00094 // beginning at RESBLOCK.
00095 int md5_stream (FILE *stream, void *resblock);
00096 
00097 // Compute MD5 message digest for bytes read from filespec. The
00098 // resulting message digest number will be written into the 16 bytes
00099 // beginning at RESBLOCK.
00100 bool md5_filespec(std::string &filespec, void *resblock);
00101 
00102 // Compute MD5 message digest for bytes read from filespec. The result
00103 // is compared to the ascii version of the MD5 (as produced by the
00104 // shell utility md5sum).
00105 bool md5_filespec_check(std::string &filespec, std::string &md5);
00106 
00107 // Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
00108 // result is always in little endian byte order, so that a byte-wise
00109 // output yields to the wanted ASCII representation of the message
00110 // digest.
00111 void *md5_buffer (const char *buffer, size_t len,
00112                            void *resblock);
00113 
00114 #endif /* md5.h */
00115 // Local Variables:
00116 // mode: C++
00117 // indent-tabs-mode: t
00118 // End:

Generated on Thu Sep 2 2010 for Gnash by  doxygen 1.7.1