• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 12805544433

16 Jan 2025 09:08AM UTC coverage: 90.876% (-0.4%) from 91.245%
12805544433

Pull #4540

github

web-flow
Merge cc1ceff51 into 9b798efbb
Pull Request #4540: PKCS #11 Version 3.2 Support

93425 of 102805 relevant lines covered (90.88%)

11409241.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/src/lib/prov/pkcs11/p11_randomgenerator.h
1
/*
2
* PKCS#11 Random Generator
3
* (C) 2016 Daniel Neus, Sirrix AG
4
* (C) 2016 Philipp Weber, Sirrix AG
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8

9
#ifndef BOTAN_P11_RNG_H_
10
#define BOTAN_P11_RNG_H_
11

12
#include <botan/p11_types.h>
13
#include <botan/rng.h>
14

15
#include <functional>
16
#include <string>
17

18
namespace Botan::PKCS11 {
19

20
class Module;
21

22
/// A random generator that only fetches random from the PKCS#11 RNG
23
class BOTAN_PUBLIC_API(2, 0) PKCS11_RNG final : public Hardware_RNG {
3✔
24
   public:
25
      /// Initialize the RNG with the PKCS#11 session that provides access to the cryptoki functions
26
      explicit PKCS11_RNG(Session& session);
27

28
      std::string name() const override { return "PKCS11_RNG"; }
×
29

30
      /// Always returns true
31
      bool is_seeded() const override { return true; }
×
32

33
      /// No operation - always returns 0
34
      size_t reseed(Entropy_Sources&, size_t, std::chrono::milliseconds) override { return 0; }
×
35

36
      /// @return the module used by this RNG
37
      inline Module& module() const { return m_session.get().module(); }
3✔
38

39
      // C_SeedRandom may suceed
40
      bool accepts_input() const override { return true; }
×
41

42
   private:
43
      /// Calls `C_GenerateRandom` to generate random data
44
      /// Calls `C_SeedRandom` to add entropy to the random generation function of the token/middleware
45
      void fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> input) override;
46

47
   private:
48
      const std::reference_wrapper<Session> m_session;
49
};
50
}  // namespace Botan::PKCS11
51

52
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc