1#ifndef BLUETOE_ENCRYPTION_HPP
2#define BLUETOE_ENCRYPTION_HPP
5#include <bluetoe/meta_types.hpp>
9 template <
typename ... Options >
12 template <
typename ... Options >
15 template <
typename ... Options >
19 struct requires_encryption_meta_type {};
20 struct no_encryption_required_meta_type {};
21 struct may_require_encryption_meta_type {};
78 details::requires_encryption_meta_type,
79 details::valid_server_option_meta_type,
80 details::valid_service_option_meta_type,
81 details::valid_characteristic_option_meta_type {};
100 details::no_encryption_required_meta_type,
101 details::valid_server_option_meta_type,
102 details::valid_service_option_meta_type,
103 details::valid_characteristic_option_meta_type {};
126 details::may_require_encryption_meta_type,
127 details::valid_server_option_meta_type,
128 details::valid_service_option_meta_type,
129 details::valid_characteristic_option_meta_type {};
135 template <
typename Server,
bool Default = false >
136 struct requires_encryption_support_t
138 static bool constexpr value = Default;
141 template <
typename ... Options,
typename T >
142 struct requires_encryption_support_t< std::tuple< T, Options... >, false >
144 static bool constexpr value =
145 requires_encryption_support_t< T, false >::value
146 || requires_encryption_support_t< std::tuple< Options... >,
false >::value;
149 template <
typename ... Options,
typename T >
150 struct requires_encryption_support_t< std::tuple< T, Options... >, true >
152 static bool constexpr value =
153 requires_encryption_support_t< T, true >::value
154 && requires_encryption_support_t< std::tuple< Options... >,
true >::value;
157 template <
bool Default,
typename ... Options >
158 struct encryption_default
160 static bool constexpr require_encryption =
161 details::has_option< requires_encryption, Options... >::value;
163 static bool constexpr may_require =
164 details::has_option< may_require_encryption, Options... >::value;
166 static bool constexpr require_not_encryption =
167 details::has_option< no_encryption_required, Options... >::value;
176 static bool constexpr value =
177 ( require_encryption && !require_not_encryption )
178 || ( !require_encryption && !require_not_encryption && Default );
180 static bool constexpr maybe = value || may_require;
183 template <
typename ... Options,
bool Default >
184 struct requires_encryption_support_t< bluetoe::server< Options... >, Default > {
185 static bool constexpr default_val = encryption_default< Default, Options... >::maybe;
187 static bool constexpr value =
188 requires_encryption_support_t<
190 default_val >::value;
193 template <
typename ... Options,
bool Default >
194 struct requires_encryption_support_t< bluetoe::service< Options... >, Default > {
195 static bool constexpr default_val = encryption_default< Default, Options... >::maybe;
197 static bool constexpr value =
198 requires_encryption_support_t<
200 default_val >::value;
203 template <
typename ... Options,
bool Default >
204 struct requires_encryption_support_t< bluetoe::characteristic< Options... >, Default > {
206 static bool constexpr value = encryption_default< Default, Options... >::maybe;
209 template <
typename Characteristic,
typename Service,
typename Server >
210 struct characteristic_requires_encryption;
212 template <
typename ... CharacteristicOptions,
typename ... ServiceOptions,
typename ... ServerOptions >
213 struct characteristic_requires_encryption<
214 bluetoe::characteristic< CharacteristicOptions... >,
219 static bool constexpr server_requires_encryption = encryption_default<
false, ServerOptions... >::value;
220 static bool constexpr service_requires_encryption = encryption_default< server_requires_encryption, ServiceOptions... >::value;
222 static bool constexpr value = encryption_default< service_requires_encryption, CharacteristicOptions... >::value;
Root of the declaration of a GATT server.
Definition: server.hpp:85
a service with zero or more characteristics
Definition: service.hpp:150
defines that a characteristic may require encyption
Definition: encryption.hpp:123
defines that access to characteristic(s) does not require an encrypted link.
Definition: encryption.hpp:97
defines that access to characteristic(s) require an encrypted link without MITM Protection.
Definition: encryption.hpp:75