root / Community Core Vision / Linux / libs / poco / include / Poco / MD4Engine.h @ 9

View | Annotate | Download (3.7 KB)

1 9 amit
//
2 9 amit
// MD4Engine.h
3 9 amit
//
4 9 amit
// $Id: //poco/1.3/Foundation/include/Poco/MD4Engine.h#2 $
5 9 amit
//
6 9 amit
// Library: Foundation
7 9 amit
// Package: Crypt
8 9 amit
// Module:  MD4Engine
9 9 amit
//
10 9 amit
// Definition of class MD4Engine.
11 9 amit
//
12 9 amit
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13 9 amit
// and Contributors.
14 9 amit
//
15 9 amit
// Permission is hereby granted, free of charge, to any person or organization
16 9 amit
// obtaining a copy of the software and accompanying documentation covered by
17 9 amit
// this license (the "Software") to use, reproduce, display, distribute,
18 9 amit
// execute, and transmit the Software, and to prepare derivative works of the
19 9 amit
// Software, and to permit third-parties to whom the Software is furnished to
20 9 amit
// do so, all subject to the following:
21 9 amit
//
22 9 amit
// The copyright notices in the Software and this entire statement, including
23 9 amit
// the above license grant, this restriction and the following disclaimer,
24 9 amit
// must be included in all copies of the Software, in whole or in part, and
25 9 amit
// all derivative works of the Software, unless such copies or derivative
26 9 amit
// works are solely in the form of machine-executable object code generated by
27 9 amit
// a source language processor.
28 9 amit
//
29 9 amit
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 9 amit
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 9 amit
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32 9 amit
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33 9 amit
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34 9 amit
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35 9 amit
// DEALINGS IN THE SOFTWARE.
36 9 amit
//
37 9 amit
//
38 9 amit
// MD4 (RFC 1320) algorithm:
39 9 amit
// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
40 9 amit
// rights reserved.
41 9 amit
//
42 9 amit
// License to copy and use this software is granted provided that it
43 9 amit
// is identified as the "RSA Data Security, Inc. MD4 Message-Digest
44 9 amit
// Algorithm" in all material mentioning or referencing this software
45 9 amit
// or this function.
46 9 amit
//
47 9 amit
// License is also granted to make and use derivative works provided
48 9 amit
// that such works are identified as "derived from the RSA Data
49 9 amit
// Security, Inc. MD4 Message-Digest Algorithm" in all material
50 9 amit
// mentioning or referencing the derived work.
51 9 amit
//
52 9 amit
// RSA Data Security, Inc. makes no representations concerning either
53 9 amit
// the merchantability of this software or the suitability of this
54 9 amit
// software for any particular purpose. It is provided "as is"
55 9 amit
// without express or implied warranty of any kind.
56 9 amit
//
57 9 amit
// These notices must be retained in any copies of any part of this
58 9 amit
// documentation and/or software.
59 9 amit
//
60 9 amit
61 9 amit
62 9 amit
#ifndef Foundation_MD4Engine_INCLUDED
63 9 amit
#define Foundation_MD4Engine_INCLUDED
64 9 amit
65 9 amit
66 9 amit
#include "Poco/Foundation.h"
67 9 amit
#include "Poco/DigestEngine.h"
68 9 amit
69 9 amit
70 9 amit
namespace Poco {
71 9 amit
72 9 amit
73 9 amit
class Foundation_API MD4Engine: public DigestEngine
74 9 amit
        /// This class implementes the MD4 message digest algorithm,
75 9 amit
        /// described in RFC 1320.
76 9 amit
{
77 9 amit
public:
78 9 amit
        enum
79 9 amit
        {
80 9 amit
                BLOCK_SIZE  = 64,
81 9 amit
                DIGEST_SIZE = 16
82 9 amit
        };
83 9 amit
84 9 amit
        MD4Engine();
85 9 amit
        ~MD4Engine();
86 9 amit
87 9 amit
        unsigned digestLength() const;
88 9 amit
        void reset();
89 9 amit
        const DigestEngine::Digest& digest();
90 9 amit
91 9 amit
protected:
92 9 amit
        void updateImpl(const void* data, unsigned length);
93 9 amit
94 9 amit
private:
95 9 amit
        static void transform(UInt32 state[4], const unsigned char block[64]);
96 9 amit
        static void encode(unsigned char* output, const UInt32* input, unsigned int len);
97 9 amit
        static void decode(UInt32* output, const unsigned char* input, unsigned int len);
98 9 amit
99 9 amit
        struct Context
100 9 amit
        {
101 9 amit
                UInt32 state[4];          // state (ABCD)
102 9 amit
                UInt32 count[2];          // number of bits, modulo 2^64 (lsb first)
103 9 amit
                unsigned char buffer[64]; // input buffer
104 9 amit
        };
105 9 amit
106 9 amit
        Context _context;
107 9 amit
        DigestEngine::Digest _digest;
108 9 amit
109 9 amit
        MD4Engine(const MD4Engine&);
110 9 amit
        MD4Engine& operator = (const MD4Engine&);
111 9 amit
};
112 9 amit
113 9 amit
114 9 amit
} // namespace Poco
115 9 amit
116 9 amit
117 9 amit
#endif // Foundation_MD5Engine_INCLUDED