azure-core
Loading...
Searching...
No Matches
sha_hash.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
10#pragma once
11
13
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace Azure { namespace Core { namespace Cryptography { namespace _internal {
19
29 class Sha1Hash final : public Azure::Core::Cryptography::Hash {
30 public:
35 Sha1Hash();
36
41 ~Sha1Hash() {}
42
43 private:
48 std::unique_ptr<Azure::Core::Cryptography::Hash> m_portableImplementation;
49
58 std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length) override
59 {
60 return m_portableImplementation->Final(data, length);
61 }
62
71 void OnAppend(const uint8_t* data, size_t length) override
72 {
73 return m_portableImplementation->Append(data, length);
74 }
75 };
80 class Sha256Hash final : public Azure::Core::Cryptography::Hash {
81 public:
86 Sha256Hash();
87
92 ~Sha256Hash() {}
93
94 private:
99 std::unique_ptr<Azure::Core::Cryptography::Hash> m_portableImplementation;
100
109 std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length) override
110 {
111 return m_portableImplementation->Final(data, length);
112 }
113
122 void OnAppend(const uint8_t* data, size_t length) override
123 {
124 return m_portableImplementation->Append(data, length);
125 }
126 };
127
132 class Sha384Hash final : public Azure::Core::Cryptography::Hash {
133 public:
138 Sha384Hash();
139
144 ~Sha384Hash() {}
145
146 private:
151 std::unique_ptr<Azure::Core::Cryptography::Hash> m_portableImplementation;
152
161 std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length) override
162 {
163 return m_portableImplementation->Final(data, length);
164 }
165
174 void OnAppend(const uint8_t* data, size_t length) override
175 {
176 return m_portableImplementation->Append(data, length);
177 }
178 };
179
184 class Sha512Hash final : public Azure::Core::Cryptography::Hash {
185 public:
190 Sha512Hash();
191
196 ~Sha512Hash() {}
197
198 private:
203 std::unique_ptr<Azure::Core::Cryptography::Hash> m_portableImplementation;
204
213 std::vector<uint8_t> OnFinal(const uint8_t* data, size_t length) override
214 {
215 return m_portableImplementation->Final(data, length);
216 }
217
226 void OnAppend(const uint8_t* data, size_t length) override
227 {
228 return m_portableImplementation->Append(data, length);
229 }
230 };
231
232}}}} // namespace Azure::Core::Cryptography::_internal
Represents the base class for hash algorithms which map binary data of an arbitrary length to small b...
Definition hash.hpp:26
Utility functions to help compute the hash value for the input binary data, using algorithms such as ...
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57