00001 /* md5.hpp 00002 * 00003 * Copyright (C) 2003 Sawtooth Consulting Ltd. 00004 * 00005 * This file is part of yaSSL. 00006 * 00007 * yaSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * There are special exceptions to the terms and conditions of the GPL as it 00013 * is applied to yaSSL. View the full text of the exception in the file 00014 * FLOSS-EXCEPTIONS in the directory of this software distribution. 00015 * 00016 * yaSSL is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00024 */ 00025 00026 /* md5.hpp provides MD5 digest support, see RFC 1321 00027 */ 00028 00029 #ifndef TAO_CRYPT_MD5_HPP 00030 #define TAO_CRYPT_MD5_HPP 00031 00032 #include "hash.hpp" 00033 00034 namespace TaoCrypt { 00035 00036 00037 // MD5 digest 00038 class MD5 : public HASHwithTransform { 00039 public: 00040 enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56, 00041 TAO_BYTE_ORDER = LittleEndianOrder }; // in Bytes 00042 MD5() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE) 00043 { Init(); } 00044 ByteOrder getByteOrder() const { return ByteOrder(TAO_BYTE_ORDER); } 00045 word32 getBlockSize() const { return BLOCK_SIZE; } 00046 word32 getDigestSize() const { return DIGEST_SIZE; } 00047 word32 getPadSize() const { return PAD_SIZE; } 00048 00049 MD5(const MD5&); 00050 MD5& operator= (const MD5&); 00051 00052 void Update(const byte*, word32); 00053 00054 void Init(); 00055 void Swap(MD5&); 00056 private: 00057 void Transform(); 00058 void AsmTransform(const byte* data, word32 times); 00059 }; 00060 00061 inline void swap(MD5& a, MD5& b) 00062 { 00063 a.Swap(b); 00064 } 00065 00066 00067 } // namespace 00068 00069 #endif // TAO_CRYPT_MD5_HPP 00070
1.4.7

