Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow supplying Sa/Key/Mc interfaces that have not been compiled with CryptoLib #257

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 49 additions & 43 deletions src/core/crypto_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,62 +176,68 @@ int32_t Crypto_Init(void)
// #endif

/* Key Interface */
if (crypto_config.key_type == KEY_TYPE_CUSTOM)
{
key_if = get_key_interface_custom();
}
else if (crypto_config.key_type == KEY_TYPE_INTERNAL)
{
key_if = get_key_interface_internal();
}
else // KEY_TYPE_KMC
{
key_if = get_key_interface_kmc();
if (key_if == NULL) {
if (crypto_config.key_type == KEY_TYPE_CUSTOM)
{
key_if = get_key_interface_custom();
}
else if (crypto_config.key_type == KEY_TYPE_INTERNAL)
{
key_if = get_key_interface_internal();
}
else // KEY_TYPE_KMC
{
key_if = get_key_interface_kmc();
}
}
key_if->key_init();
// TODO: Check and return status on error

/* MC Interface */
if (crypto_config.mc_type == MC_TYPE_CUSTOM)
{
mc_if = get_mc_interface_custom();
}
else if (crypto_config.mc_type == MC_TYPE_DISABLED)
{
mc_if = get_mc_interface_disabled();
}
else // MC_TYPE_INTERNAL
{
mc_if = get_mc_interface_internal();
if (mc_if == NULL) {
if (crypto_config.mc_type == MC_TYPE_CUSTOM)
{
mc_if = get_mc_interface_custom();
}
else if (crypto_config.mc_type == MC_TYPE_DISABLED)
{
mc_if = get_mc_interface_disabled();
}
else // MC_TYPE_INTERNAL
{
mc_if = get_mc_interface_internal();
}
}
mc_if->mc_initialize();
// TODO: Check and return status on error

/* SA Interface */
// Prepare SA type from config
if (crypto_config.sa_type == SA_TYPE_CUSTOM)
{
sa_if = get_sa_interface_custom();
}
else if (crypto_config.sa_type == SA_TYPE_INMEMORY)
{
sa_if = get_sa_interface_inmemory();
}
else if (crypto_config.sa_type == SA_TYPE_MARIADB)
{
if (sa_mariadb_config == NULL)
if (sa_if == NULL) {
// Prepare SA type from config
if (crypto_config.sa_type == SA_TYPE_CUSTOM)
{
sa_if = get_sa_interface_custom();
}
else if (crypto_config.sa_type == SA_TYPE_INMEMORY)
{
sa_if = get_sa_interface_inmemory();
}
else if (crypto_config.sa_type == SA_TYPE_MARIADB)
{
status = CRYPTO_MARIADB_CONFIGURATION_NOT_COMPLETE;
printf(KRED "ERROR: CryptoLib MariaDB must be configured before intializing!\n" RESET);
return status; // MariaDB connection specified but no configuration exists, return!
if (sa_mariadb_config == NULL)
{
status = CRYPTO_MARIADB_CONFIGURATION_NOT_COMPLETE;
printf(KRED "ERROR: CryptoLib MariaDB must be configured before intializing!\n" RESET);
return status; // MariaDB connection specified but no configuration exists, return!
}
sa_if = get_sa_interface_mariadb();
}
sa_if = get_sa_interface_mariadb();
else
{
status = SADB_INVALID_SADB_TYPE;
return status;
} // TODO: Error stack
}
else
{
status = SADB_INVALID_SADB_TYPE;
return status;
} // TODO: Error stack

/* Crypto Interface */
// Determine which cryptographic module is in use
Expand Down
Loading