Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
SHA3HashAlgorithm.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* SHA3HashAlgorithm.h (C) 2000-2023 */
9/* */
10/* Calculates the SHA-3 hashing function (224, 256, 384 or 512). */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_SHA3HASHALGORITHM_H
13#define ARCANE_UTILS_SHA3HASHALGORITHM_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/IHashAlgorithm.h"
18#include "arcane/utils/String.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::SHA3Algorithm
24{
25class SHA3;
26}
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
37class ARCANE_UTILS_EXPORT SHA3HashAlgorithm
38: public IHashAlgorithm
39{
40 public:
41
42 void computeHash(ByteConstArrayView input, ByteArray& output) final;
43 void computeHash64(Span<const Byte> input, ByteArray& output) final;
44 void computeHash64(Span<const std::byte> input, ByteArray& output) final;
45
46 protected:
47
48 virtual void _initialize(SHA3Algorithm::SHA3&) = 0;
49
50 private:
51
52 void _computeHash64(Span<const std::byte> input, ByteArray& output);
53};
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
59class ARCANE_UTILS_EXPORT SHA3_256HashAlgorithm
60: public SHA3HashAlgorithm
61{
62 public:
63
64 String name() const override { return "SHA3_256"; }
65 Int32 hashSize() const override { return 32; }
66
67 protected:
68
69 void _initialize(SHA3Algorithm::SHA3&) override;
70};
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
76class ARCANE_UTILS_EXPORT SHA3_224HashAlgorithm
77: public SHA3HashAlgorithm
78{
79 public:
80
81 String name() const override { return "SHA3_224"; }
82 Int32 hashSize() const override { return 28; }
83
84 protected:
85
86 void _initialize(SHA3Algorithm::SHA3&) override;
87};
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
93class ARCANE_UTILS_EXPORT SHA3_384HashAlgorithm
94: public SHA3HashAlgorithm
95{
96 public:
97
98 String name() const override { return "SHA3_384"; }
99 Int32 hashSize() const override { return 48; }
100
101 protected:
102
103 void _initialize(SHA3Algorithm::SHA3&) override;
104};
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
110class ARCANE_UTILS_EXPORT SHA3_512HashAlgorithm
111: public SHA3HashAlgorithm
112{
113 public:
114
115 String name() const override { return "SHA3_512"; }
116 Int32 hashSize() const override { return 64; }
117
118 protected:
119
120 void _initialize(SHA3Algorithm::SHA3&) override;
121};
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126} // namespace Arcane
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
131#endif
Interface of a hashing algorithm.
Base class for SHA-3 algorithms.
void computeHash64(Span< const Byte > input, ByteArray &output) final
Calculates the hash value for the array input.
void computeHash(ByteConstArrayView input, ByteArray &output) final
Calculates the hash value for the array input.
Hash for the SHA-3 224 algorithm.
String name() const override
Name of the algorithm.
Int32 hashSize() const override
Size (in bytes) of the hash key.
Hash for the SHA-3 256 algorithm.
Int32 hashSize() const override
Size (in bytes) of the hash key.
String name() const override
Name of the algorithm.
Hash for the SHA-3 384 algorithm.
String name() const override
Name of the algorithm.
Int32 hashSize() const override
Size (in bytes) of the hash key.
Hash for the SHA-3 512 algorithm.
Int32 hashSize() const override
Size (in bytes) of the hash key.
String name() const override
Name of the algorithm.
View of an array of elements of type T.
Definition Span.h:635
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
Definition UtilsTypes.h:476
std::int32_t Int32
Signed integer type of 32 bits.