Coverage Report

Created: 2026-06-07 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poco/Crypto/include/Poco/Crypto/DigestEngine.h
Line
Count
Source
1
//
2
// DigestEngine.h
3
//
4
// Library: Crypto
5
// Package: Digest
6
// Module:  DigestEngine
7
//
8
// Definition of the DigestEngine class.
9
//
10
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
11
// and Contributors.
12
//
13
// SPDX-License-Identifier: BSL-1.0
14
//
15
16
17
#ifndef Crypto_DigestEngine_INCLUDED
18
#define Crypto_DigestEngine_INCLUDED
19
20
21
#include "Poco/Crypto/Crypto.h"
22
#include "Poco/Crypto/OpenSSLInitializer.h"
23
#include "Poco/DigestEngine.h"
24
#include <openssl/evp.h>
25
26
27
namespace Poco::Crypto {
28
29
30
class Crypto_API DigestEngine: public Poco::DigestEngine
31
  /// This class implements a Poco::DigestEngine for all
32
  /// digest algorithms supported by OpenSSL.
33
{
34
public:
35
  DigestEngine(const std::string& name);
36
    /// Creates a DigestEngine using the digest with the given name
37
    /// (e.g., "MD5", "SHA1", "SHA256", "SHA512", etc.).
38
    /// See the OpenSSL documentation for a list of supported digest algorithms.
39
    ///
40
    /// Throws a Poco::NotFoundException if no algorithm with the given name exists.
41
42
  ~DigestEngine();
43
    /// Destroys the DigestEngine.
44
45
  const std::string& algorithm() const;
46
    /// Returns the name of the digest algorithm.
47
48
  int nid() const;
49
    /// Returns the NID (OpenSSL object identifier) of the digest algorithm.
50
51
  // DigestEngine
52
  std::size_t digestLength() const;
53
  void reset();
54
  const Poco::DigestEngine::Digest& digest();
55
56
protected:
57
  void updateImpl(const void* data, std::size_t length);
58
59
private:
60
  std::string _name;
61
  EVP_MD_CTX* _pContext;
62
  Poco::DigestEngine::Digest _digest;
63
  OpenSSLInitializer _openSSLInitializer;
64
};
65
66
67
//
68
// inlines
69
//
70
inline const std::string& DigestEngine::algorithm() const
71
0
{
72
0
  return _name;
73
0
}
74
75
76
} // namespace Poco::Crypto
77
78
79
#endif // Crypto_DigestEngine_INCLUDED