BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
security_tool_box.hpp
1#ifndef BLUETOE_BINDING_NORDIC_NRF52_SECURITY_TOOL_BOX_HPP
2#define BLUETOE_BINDING_NORDIC_NRF52_SECURITY_TOOL_BOX_HPP
3
4#include <bluetoe/security_manager.hpp>
5
6#include <tuple>
7#include <algorithm>
8
9namespace bluetoe
10{
11 namespace nrf52_details
12 {
13 std::uint32_t random_number32();
14 std::uint64_t random_number64();
15 bluetoe::details::uint128_t aes_le( const bluetoe::details::uint128_t& key, const bluetoe::details::uint128_t& data );
16
22 class security_tool_box
23 {
24 public:
28 bluetoe::details::uint128_t create_srand();
29
30 bluetoe::details::longterm_key_t create_long_term_key();
31
32 bluetoe::details::uint128_t c1(
33 const bluetoe::details::uint128_t& temp_key,
34 const bluetoe::details::uint128_t& rand,
35 const bluetoe::details::uint128_t& p1,
36 const bluetoe::details::uint128_t& p2 ) const;
37
38 bluetoe::details::uint128_t s1(
39 const bluetoe::details::uint128_t& temp_key,
40 const bluetoe::details::uint128_t& srand,
41 const bluetoe::details::uint128_t& mrand );
42
46 bool is_valid_public_key( const std::uint8_t* public_key ) const;
47
51 std::pair< bluetoe::details::ecdh_public_key_t, bluetoe::details::ecdh_private_key_t > generate_keys();
52
56 bluetoe::details::uint128_t select_random_nonce();
57
61 bluetoe::details::ecdh_shared_secret_t p256( const std::uint8_t* private_key, const std::uint8_t* public_key );
62
66 bluetoe::details::uint128_t f4( const std::uint8_t* u, const std::uint8_t* v, const std::array< std::uint8_t, 16 >& k, std::uint8_t z );
67
71 std::pair< bluetoe::details::uint128_t, bluetoe::details::uint128_t > f5(
72 const bluetoe::details::ecdh_shared_secret_t dh_key,
73 const bluetoe::details::uint128_t& nonce_central,
74 const bluetoe::details::uint128_t& nonce_periperal,
75 const bluetoe::link_layer::device_address& addr_controller,
76 const bluetoe::link_layer::device_address& addr_peripheral );
77
81 bluetoe::details::uint128_t f6(
82 const bluetoe::details::uint128_t& key,
83 const bluetoe::details::uint128_t& n1,
84 const bluetoe::details::uint128_t& n2,
85 const bluetoe::details::uint128_t& r,
86 const bluetoe::details::io_capabilities_t& io_caps,
87 const bluetoe::link_layer::device_address& addr_controller,
88 const bluetoe::link_layer::device_address& addr_peripheral );
89
93 std::uint32_t g2(
94 const std::uint8_t* u,
95 const std::uint8_t* v,
96 const bluetoe::details::uint128_t& x,
97 const bluetoe::details::uint128_t& y );
98
102 bluetoe::details::uint128_t create_passkey();
103 };
104
105 }
106}
107
108#endif