1 #ifdef APPLE_NETWORK_LIBRARIES
3 #ifndef HEADER_CRYPTO_CRYPTOKIT_HPP
4 #define HEADER_CRYPTO_CRYPTOKIT_HPP
23 static std::string m_client_key;
25 static std::string m_client_iv;
27 std::array<uint8_t, 12> m_iv;
29 std::atomic_uint m_packet_counter;
31 std::vector<uint8_t> m_key;
35 static std::string base64(
const std::vector<uint8_t>& input);
37 static std::vector<uint8_t> decode64(std::string input);
39 static std::array<uint8_t, 32>
sha256(
const std::string& input);
41 static std::unique_ptr<Crypto> getClientCrypto(
size_t tag_size)
43 assert(!m_client_key.empty());
44 assert(!m_client_iv.empty());
45 assert(tag_size == 16);
46 auto c = std::unique_ptr<Crypto>(
new Crypto(decode64(m_client_key),
47 decode64(m_client_iv), tag_size));
48 c->m_packet_counter = 0;
52 static void initClientAES();
54 static void resetClientAES()
60 static const std::string& getClientKey() {
return m_client_key; }
62 static const std::string& getClientIV() {
return m_client_iv; }
64 Crypto(
const std::vector<uint8_t>& key,
65 const std::vector<uint8_t>& iv,
68 assert(key.size() == 16);
69 assert(iv.size() == 12);
70 assert(tag_size == 16);
71 std::copy_n(iv.begin(), 12, m_iv.begin());
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
CScriptArray * sha256(std::string *input)
Return a sha256 checksum of string in an array of integers of size 32.
Definition: script_utils.cpp:163