Imt.Base C++ API V4.1.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MD5.h
Go to the documentation of this file.
1// (c) IMT - Information Management Technology AG, CH-9470 Buchs, www.imt.ch.
2//
3// ActiveParts (AP) and the corresponding Data Flow Framework (DFF) is invented and designed by Jakob Daescher.
4// ANY USE OF THIS CODE CONSTITUTES ACCEPTANCE OF THE TERMS OF THE COPYRIGHT NOTICE.
5// ===================================================================================================
6// COPYRIGHT NOTICE
7// ===================================================================================================
8// Copyright (C) 2005-2075, IMT Information Management Technology AG, 9470 Buchs, Switzerland
9// All rights reserved.
10// This code is proprietary software of IMT Information Management Technology AG (hereinafter: "IMT").
11// Proprietary software is computer software licensed under exclusive legal right of IMT.
12//
13// The licensee is given the irrevocable, perpetual, worldwide, non-exclusive right and license to use,
14// execute and reproduce the software in binary form within the licensed products.
15//
16// Redistribution and use in source forms, without modification, are permitted provided that the following conditions are met:
17// (1) Copying of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18// (2) Copying of source code is only allowed for regulatory documentation and archiving purposes
19// (3) Redistributions in binary form must reproduce the above copyright notice,
20// this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
21//
22// IMT provide no reassurances that the source code provided does not infringe
23// any patent, copyright, or any other intellectual property rights of third parties.
24// IMT disclaim any liability to any recipient for claims brought against
25// recipient by any third party for infringement of that parties intellectual property rights.
26//
27// THIS SOFTWARE IS PROVIDED BY IMT AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
28// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29// IN NO EVENT SHALL IMT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCURE-MENT OF SUBSTITUTE GOODS OR SERVICES;
31// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34// ===================================================================================================
35
36#ifndef IMT_BASE_CORE_UTIL_MD5_H
37#define IMT_BASE_CORE_UTIL_MD5_H
38
39#include <array>
42
43namespace imt {
44namespace base {
45namespace core {
46namespace util {
47
52
53public:
54
58 static constexpr uint32_t MD5_HASH_SIZE {16U};
59
63 MD5();
64
72 // AXIVION Next Codeline AutosarC++19_03-A8.4.7: Pass by value not possible for byte array.
73 // AXIVION Next Codeline AutosarC++19_03-A18.1.1: use C-style array for compatibility
74 void update(uint8_t const pData[], uint32_t const dataSize);
75
82 // AXIVION Next Codeline AutosarC++19_03-A8.4.7: Pass by value not possible for byte array.
83 // AXIVION Next Codeline AutosarC++19_03-A18.1.1: use C-style array for compatibility
85
92 // AXIVION Next Codeline AutosarC++19_03-A8.4.7: Pass by value not possible for byte array.
93 // AXIVION Next Codeline AutosarC++19_03-A18.1.1: use C-style array for compatibility
94 static bool areEqual(uint8_t const expected[MD5_HASH_SIZE], uint8_t const current[MD5_HASH_SIZE]);
95
100 // AXIVION Next Codeline AutosarC++19_03-A18.1.1: use C-style array for compatibility
101 static void resetMd5Hash(uint8_t md5Hash[MD5_HASH_SIZE]);
102
103 static constexpr size_t STATE_SIZE {4};
104 static constexpr size_t COUNT_SIZE {2};
105 static constexpr size_t BUFFER_SIZE {64};
106
107private:
108
109 // resets the internal state
110 void reset();
111
112 // state (ABCD)
113 std::array<uint32_t, STATE_SIZE> m_state;
114 // number of bits, modulo 2^64 (lsb first)
115 std::array<uint32_t, COUNT_SIZE> m_count;
116 // input buffer
117 std::array<uint8_t, BUFFER_SIZE> m_buffer;
118};
119
120} // namespace util
121} // namespace core
122} // namespace base
123} // namespace imt
124
125#endif // IMT_BASE_CORE_UTIL_MD5_H
Base class for a not movable class that disables copy, assignment and move of instances.
Definition Nonmovable.h:51
This class provides the MD5 checksum calculation routines.
Definition MD5.h:51
void finalize(uint8_t digest[MD5_HASH_SIZE])
Finalization ends the md5 message-digest operation, writing the the message digest and zeroizing the ...
static void resetMd5Hash(uint8_t md5Hash[MD5_HASH_SIZE])
Resets the MD5 hash array.
static constexpr uint32_t MD5_HASH_SIZE
Defines the size of an md5 hash.
Definition MD5.h:58
static constexpr size_t STATE_SIZE
Definition MD5.h:103
static constexpr size_t BUFFER_SIZE
Definition MD5.h:105
void update(uint8_t const pData[], uint32_t const dataSize)
Block update operation.
static bool areEqual(uint8_t const expected[MD5_HASH_SIZE], uint8_t const current[MD5_HASH_SIZE])
Compares two MD5 hashes and returns true if they are equal.
static constexpr size_t COUNT_SIZE
Definition MD5.h:104
This is a application specific file which is used to configure Imt.Base.Core.Math.
unsigned __int32 uint32_t
Definition stdint.h:64
unsigned __int8 uint8_t
Definition stdint.h:62