MySQL 8.0.40
Source Code Documentation
keyring_frontend.cc File Reference
#include "keyring_frontend.h"
#include <algorithm>
#include <cctype>
#include <fstream>
#include <sstream>
#include <vector>
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>
#include "keyring/keyring_file.h"
#include "keyring/master_key_file.h"
#include "mysql/harness/arg_handler.h"
#include "mysql/harness/utility/string.h"
#include "mysqlrouter/keyring_info.h"
#include "mysqlrouter/utils.h"
#include "print_version.h"
#include "random_generator.h"
#include "router_config.h"
#include "welcome_copyright_notice.h"

Functions

static bool master_key_file_load (mysql_harness::MasterKeyFile &mkf)
 load the masterkeyfile. More...
 
static std::pair< bool, std::string > keyring_file_prepare (mysql_harness::KeyringFile &kf, const std::string &keyring_filename)
 prepare the keyring. More...
 
static bool keyring_file_load (mysql_harness::KeyringFile &kf, const std::string &keyring_filename, const std::string &kf_key)
 
static std::pair< bool, std::string > master_key_file_prepare (mysql_harness::MasterKeyFile &mkf, mysql_harness::KeyringFile &kf, const std::string &keyring_filename, const std::string &kf_random)
 prepare master-key-file for keyring. More...
 
static void cmd_init_with_master_key_file (const std::string &keyring_filename, const std::string &master_keyring_filename)
 
static std::pair< bool, std::string > master_key_reader_load (const std::string &master_key_reader, const std::string &keyring_filename)
 
static void cmd_init_with_master_key_reader (const std::string &keyring_filename, const std::string &master_key_reader, const std::string &master_key_writer)
 
static void cmd_init_with_master_key (const std::string &keyring_filename, const std::string &kf_key)
 
static void cmd_master_delete (const std::string &master_keyring_filename, const std::string &keyring_filename)
 
static void cmd_master_list (std::ostream &cout, const std::string &master_keyring_filename)
 
static void cmd_master_rename (const std::string &master_keyring_filename, const std::string &old_key, const std::string &new_key)
 
static void cmd_export (std::ostream &os, const mysql_harness::KeyringFile &kf)
 
static bool cmd_list (std::ostream &os, mysql_harness::KeyringFile &kf, const std::string &username)
 
static bool cmd_delete (mysql_harness::KeyringFile &kf, const std::string &username, const std::string &field)
 
static void cmd_set (mysql_harness::KeyringFile &kf, const std::string &username, const std::string &field, const std::string &value)
 
static void cmd_get (std::ostream &os, mysql_harness::KeyringFile &kf, const std::string &username, const std::string &field)
 

Variables

static const unsigned kKeyLength {32}
 

Function Documentation

◆ cmd_delete()

static bool cmd_delete ( mysql_harness::KeyringFile kf,
const std::string &  username,
const std::string &  field 
)
static

◆ cmd_export()

static void cmd_export ( std::ostream &  os,
const mysql_harness::KeyringFile kf 
)
static

◆ cmd_get()

static void cmd_get ( std::ostream &  os,
mysql_harness::KeyringFile kf,
const std::string &  username,
const std::string &  field 
)
static

◆ cmd_init_with_master_key()

static void cmd_init_with_master_key ( const std::string &  keyring_filename,
const std::string &  kf_key 
)
static

◆ cmd_init_with_master_key_file()

static void cmd_init_with_master_key_file ( const std::string &  keyring_filename,
const std::string &  master_keyring_filename 
)
static

◆ cmd_init_with_master_key_reader()

static void cmd_init_with_master_key_reader ( const std::string &  keyring_filename,
const std::string &  master_key_reader,
const std::string &  master_key_writer 
)
static

◆ cmd_list()

static bool cmd_list ( std::ostream &  os,
mysql_harness::KeyringFile kf,
const std::string &  username 
)
static

◆ cmd_master_delete()

static void cmd_master_delete ( const std::string &  master_keyring_filename,
const std::string &  keyring_filename 
)
static

◆ cmd_master_list()

static void cmd_master_list ( std::ostream &  cout,
const std::string &  master_keyring_filename 
)
static

◆ cmd_master_rename()

static void cmd_master_rename ( const std::string &  master_keyring_filename,
const std::string &  old_key,
const std::string &  new_key 
)
static

◆ cmd_set()

static void cmd_set ( mysql_harness::KeyringFile kf,
const std::string &  username,
const std::string &  field,
const std::string &  value 
)
static

◆ keyring_file_load()

static bool keyring_file_load ( mysql_harness::KeyringFile kf,
const std::string &  keyring_filename,
const std::string &  kf_key 
)
static

◆ keyring_file_prepare()

static std::pair< bool, std::string > keyring_file_prepare ( mysql_harness::KeyringFile kf,
const std::string &  keyring_filename 
)
static

prepare the keyring.

if keyring doesn't exist, generates a new random

Exceptions
FrontendErroron anything else
Returns
if keyring changed and the keyrings random

◆ master_key_file_load()

static bool master_key_file_load ( mysql_harness::MasterKeyFile mkf)
static

load the masterkeyfile.

Exceptions
FrontendErroron anything else.
Returns
success
Return values
trueif loaded
falseif file didn't exist

◆ master_key_file_prepare()

static std::pair< bool, std::string > master_key_file_prepare ( mysql_harness::MasterKeyFile mkf,
mysql_harness::KeyringFile kf,
const std::string &  keyring_filename,
const std::string &  kf_random 
)
static

prepare master-key-file for keyring.

if keyring-file isn't known in master-key-file:

  • generates encryption-key for keyring
  • adds keyring to master-key-file

otherwise, gets encryption-key from master-key-file

Returns
if-master-key-file-changed and the encryption-key for the keyring

◆ master_key_reader_load()

static std::pair< bool, std::string > master_key_reader_load ( const std::string &  master_key_reader,
const std::string &  keyring_filename 
)
static

Variable Documentation

◆ kKeyLength

const unsigned kKeyLength {32}
static