00001 /* sha.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 /* sha.hpp provides SHA-1 digests, see RFC 3174 00027 */ 00028 00029 #ifndef TAO_CRYPT_SHA_HPP 00030 #define TAO_CRYPT_SHA_HPP 00031 00032 #include "hash.hpp" 00033 00034 namespace TaoCrypt { 00035 00036 00037 // SHA-1 digest 00038 class SHA : public HASHwithTransform { 00039 public: 00040 enum { BLOCK_SIZE = 64, DIGEST_SIZE = 20, PAD_SIZE = 56, 00041 TAO_BYTE_ORDER = BigEndianOrder}; // in Bytes 00042 SHA() : 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 void Update(const byte* data, word32 len); 00050 void Init(); 00051 00052 SHA(const SHA&); 00053 SHA& operator= (const SHA&); 00054 00055 void Swap(SHA&); 00056 private: 00057 void Transform(); 00058 void AsmTransform(const byte* data, word32 times); 00059 }; 00060 00061 00062 inline void swap(SHA& a, SHA& b) 00063 { 00064 a.Swap(b); 00065 } 00066 00067 } // namespace 00068 00069 00070 #endif // TAO_CRYPT_SHA_HPP 00071
1.4.7

