The utility namespace.
More...
|
| void | clear () |
| | Clear the screen.
|
| |
| template<typename T = bool> |
| T | input (const std::string &title, const T &error_ret=T()) |
| | std::cin can be a little difficult to use, particularly handling bad input. This sanitized it.
|
| |
| void | prompt (const std::string &message) |
| | Prompt the user and wait until they have confirmed it.
|
| |
| void | construct_shared_key (std::array< uint64_t, 4 > &sk, const bool &server) |
| | Genreate a shared key over a connection.
|
| |
| void | receive_message (const std::array< uint64_t, 4 > &sk) |
| | Receive an encrypted message from the peer.
|
| |
| void | send_message (const std::array< uint64_t, 4 > &sk) |
| | Send an encrypted message to a peer.
|
| |
| bool | acknowledge (const std::string &what) |
| | Acknowledge a request from a peer.
|
| |
◆ acknowledge()
| bool util::acknowledge |
( |
const std::string & | what | ) |
|
Acknowledge a request from a peer.
- Parameters
-
| what | What is the acknowledgement for? |
- Returns
- The return code of the send_packet.
◆ clear()
◆ construct_shared_key()
| void util::construct_shared_key |
( |
std::array< uint64_t, 4 > & | sk, |
|
|
const bool & | server ) |
Genreate a shared key over a connection.
- Parameters
-
| sk | The shared key array to populate. |
| server | Whether we are the server or not. |
- Warning
- Selecting different modes of AES merely truncates this key (IE AES-128 uses sk[0,1], AES-192 uses sk[0,1,2], AES-256 uses all of them).
-
This is not the cryptographically secure way of doing things. We should almost certainly Exchange a single, massive 256 bit prime instead of four 64 bit ones, but for the sake of not needing to create our own 256 bit number classes, we just key exchange quadrice.
◆ input()
template<typename T = bool>
| T util::input |
( |
const std::string & | title, |
|
|
const T & | error_ret = T() ) |
|
inline |
std::cin can be a little difficult to use, particularly handling bad input. This sanitized it.
- Template Parameters
-
| T | The type of input to be returned. |
- Parameters
-
| title | A title to be drawn for the input |
| error_ret | If something causes an error, what we should return to let the caller know. |
- Returns
- The user input, or the error return.
- Warning
- This function is blocking.
◆ prompt()
| void util::prompt |
( |
const std::string & | message | ) |
|
|
inline |
Prompt the user and wait until they have confirmed it.
- Parameters
-
| message | The message to display. |
- Warning
- This function is blocking.
◆ receive_message()
| void util::receive_message |
( |
const std::array< uint64_t, 4 > & | sk | ) |
|
Receive an encrypted message from the peer.
- Parameters
-
◆ send_message()
| void util::send_message |
( |
const std::array< uint64_t, 4 > & | sk | ) |
|
Send an encrypted message to a peer.
- Parameters
-