Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Algorithm.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Cryptography_Digest_Algorithm_Algorithm_h_
5#define _Stroika_Foundation_Cryptography_Digest_Algorithm_Algorithm_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <cstdint>
10
11#include "Stroika/Foundation/Common/Common.h"
12
13/*
14 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
15 *
16 * TODO:
17 * @todo Consider losing IDigester, and IDigestAlgorithm - not REALLY used. We just want to have something like
18 * concepts here - to validate that the algorithms comply to this pattern.
19 */
20
21namespace Stroika::Foundation::Cryptography::Digest::Algorithm {
22
23 /**
24 * No definition provided. It must be specialized for each algorithm.
25 */
26 template <typename ALGORITHM>
28
29 /**
30 * @todo we may not really need base class, nor virtuals, just just concepts
31 */
32 class IDigester {
33 public:
34 virtual ~IDigester () = default;
35
36 public:
37 virtual void Write (const byte* start, const byte* end) = 0;
38 };
39
40 /**
41 * @todo we may not really need base class, nor virtuals, just just concepts
42 */
43 template <typename RESULT_TYPE>
44 class IDigestAlgorithm : public IDigester {
45 public:
46 virtual RESULT_TYPE Complete () = 0;
47 };
48
49 /**
50 * \brief DigesterAlgorithm is specialized for each algorithm; generally don't use this directly, but use the wrapper Digest::IncrementalDigester<> (or Digest::Digester or Digest::ComputeDigest)
51 *
52 * No definition provided. It must be specialized for each algorithm.
53 */
54 template <typename ALGORITHM, typename RETURN_TYPE = typename Algorithm::DigesterDefaultTraitsForAlgorithm<ALGORITHM>::ReturnType>
56
57// @todo add concepts or some such to enforce DigesterAlgorithm follows this pattern.
58#if 0
59 template <typename ALGORITHM, typename RETURN_TYPE = typename Algorithm::DigesterDefaultTraitsForAlgorithm<ALGORITHM>::ReturnType>
60 class DigesterAlgorithm : public IDigestAlgorithm<RETURN_TYPE> {
61 using ReturnType = RETURN_TYPE;
62
63 // static_assert (false, "must specialize this ");
64
65 public:
66 DigesterAlgorithm () = default;
67 DigesterAlgorithm (const DigesterAlgorithm& src) = default;
68
69 public:
70 virtual void Write (const byte* start, const byte* end) override;
71
72 public:
73 virtual ReturnType Complete () override;
74 };
75#endif
76
77}
78
79/*
80 ********************************************************************************
81 ***************************** Implementation Details ***************************
82 ********************************************************************************
83 */
84//#include "Algorithm.inl"
85
86#endif /*_Stroika_Foundation_Cryptography_Digest_Algorithm_Algorithm_h_*/
DigesterAlgorithm is specialized for each algorithm; generally don't use this directly,...
Definition Algorithm.h:55