randen_hwaes.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2017 The Abseil Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_
  15. #define ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_
  16. #include "absl/base/config.h"
  17. // HERMETIC NOTE: The randen_hwaes target must not introduce duplicate
  18. // symbols from arbitrary system and other headers, since it may be built
  19. // with different flags from other targets, using different levels of
  20. // optimization, potentially introducing ODR violations.
  21. namespace absl {
  22. ABSL_NAMESPACE_BEGIN
  23. namespace random_internal {
  24. // RANDen = RANDom generator or beetroots in Swiss High German.
  25. // 'Strong' (well-distributed, unpredictable, backtracking-resistant) random
  26. // generator, faster in some benchmarks than std::mt19937_64 and pcg64_c32.
  27. //
  28. // RandenHwAes implements the basic state manipulation methods.
  29. class RandenHwAes {
  30. public:
  31. static void Generate(const void* keys, void* state_void);
  32. static void Absorb(const void* seed_void, void* state_void);
  33. static const void* GetKeys();
  34. };
  35. // HasRandenHwAesImplementation returns true when there is an accelerated
  36. // implementation, and false otherwise. If there is no implementation,
  37. // then attempting to use it will abort the program.
  38. bool HasRandenHwAesImplementation();
  39. } // namespace random_internal
  40. ABSL_NAMESPACE_END
  41. } // namespace absl
  42. #endif // ABSL_RANDOM_INTERNAL_RANDEN_HWAES_H_