CsCrypto  1.0.1
traits.h
1 /***********************************************************************
2 *
3 * Copyright (c) 2021-2024 Tim van Deurzen
4 * Copyright (c) 2021-2024 Barbara Geller
5 * Copyright (c) 2021-2024 Ansel Sermersheim
6 *
7 * This file is part of CsCrypto.
8 *
9 * CsCrypto is free software, released under the BSD 2-Clause license.
10 * For license details refer to LICENSE provided with this project.
11 *
12 * CsCrypto is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 *
16 * https://opensource.org/licenses/BSD-2-Clause
17 *
18 ***********************************************************************/
19 
20 #ifndef CS_CRYPTO_DRIVERS_TRAITS_H
21 #define CS_CRYPTO_DRIVERS_TRAITS_H
22 
23 #include <drivers/base/drivers.h>
24 #include <util/tools/crypto_traits.h>
25 #include <util/tools/is_detected_traits.h>
26 
27 #include <type_traits>
28 
29 namespace cs_crypto::drivers::traits {
30 
31 template <implementation>
32 struct have_driver
33  : std::false_type
34 {
35 };
36 
37 template <>
38 struct have_driver<implementation::base>
39  : std::true_type
40 {
41 };
42 
43 #if CSCRYPTO_HAVE_BOTAN
44  template <>
45  struct have_driver<implementation::botan>
46  : std::true_type
47  {
48  };
49 #endif
50 
51 #if CSCRYPTO_HAVE_OPENSSL
52  template <>
53  struct have_driver<implementation::openssl>
54  : std::true_type
55  {
56  };
57 #endif
58 
59 template <implementation I>
60 [[maybe_unused]] constexpr static const bool have_driver_v = have_driver<I>::value;
61 
62 template <implementation I>
63 struct driver_for {
64  using hash = cs_crypto::traits::nonesuch;
65  using symmetric_encryption = cs_crypto::traits::nonesuch;
66 };
67 
68 } // namespace cs_crypto::drivers::traits
69 
70 #endif