implemented wrap around of registered IKEv1 algorithm names
This commit is contained in:
@@ -36,8 +36,6 @@
|
|||||||
#define CRL_WARNING_INTERVAL 7 /* days */
|
#define CRL_WARNING_INTERVAL 7 /* days */
|
||||||
#define AC_WARNING_INTERVAL 1 /* day */
|
#define AC_WARNING_INTERVAL 1 /* day */
|
||||||
|
|
||||||
#define MAX_ALG_LINE 120 /* characters */
|
|
||||||
|
|
||||||
typedef struct private_stroke_list_t private_stroke_list_t;
|
typedef struct private_stroke_list_t private_stroke_list_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1069,7 +1067,7 @@ static void print_alg(FILE *out, int *len, enum_name_t *alg_names, int alg_type,
|
|||||||
int alg_name_len;
|
int alg_name_len;
|
||||||
|
|
||||||
alg_name_len = sprintf(alg_name, " %N[%s]", alg_names, alg_type, plugin_name);
|
alg_name_len = sprintf(alg_name, " %N[%s]", alg_names, alg_type, plugin_name);
|
||||||
if (*len + alg_name_len > MAX_ALG_LINE)
|
if (*len + alg_name_len > CRYPTO_MAX_ALG_LINE)
|
||||||
{
|
{
|
||||||
fprintf(out, "\n ");
|
fprintf(out, "\n ");
|
||||||
*len = 13;
|
*len = 13;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ typedef struct crypto_factory_t crypto_factory_t;
|
|||||||
#include <crypto/diffie_hellman.h>
|
#include <crypto/diffie_hellman.h>
|
||||||
#include <crypto/transform.h>
|
#include <crypto/transform.h>
|
||||||
|
|
||||||
|
#define CRYPTO_MAX_ALG_LINE 120 /* characters */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor function for crypters
|
* Constructor function for crypters
|
||||||
*/
|
*/
|
||||||
|
|||||||
+35
-51
@@ -304,6 +304,26 @@ fail:
|
|||||||
return db_ctx;
|
return db_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the name of an algorithm plus the name of the plugin that registered it
|
||||||
|
*/
|
||||||
|
static void print_alg(char *buf, int *len, enum_names *alg_names, int alg_type,
|
||||||
|
const char *plugin_name)
|
||||||
|
{
|
||||||
|
char alg_name[BUF_LEN];
|
||||||
|
int alg_name_len;
|
||||||
|
|
||||||
|
alg_name_len = sprintf(alg_name, " %s[%s]", enum_name(alg_names, alg_type),
|
||||||
|
plugin_name);
|
||||||
|
if (*len + alg_name_len > CRYPTO_MAX_ALG_LINE)
|
||||||
|
{
|
||||||
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
*len = sprintf(buf, " ");
|
||||||
|
}
|
||||||
|
sprintf(buf + *len, "%s", alg_name);
|
||||||
|
*len += alg_name_len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show registered IKE algorithms
|
* Show registered IKE algorithms
|
||||||
*/
|
*/
|
||||||
@@ -312,80 +332,44 @@ void ike_alg_list(void)
|
|||||||
rng_quality_t quality;
|
rng_quality_t quality;
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
const char *plugin_name;
|
const char *plugin_name;
|
||||||
char buf[1024];
|
char buf[BUF_LEN];
|
||||||
char *pos;
|
int len;
|
||||||
int n, len;
|
|
||||||
struct ike_alg *a;
|
struct ike_alg *a;
|
||||||
|
|
||||||
whack_log(RC_COMMENT, " ");
|
whack_log(RC_COMMENT, " ");
|
||||||
whack_log(RC_COMMENT, "List of registered IKEv1 Algorithms:");
|
whack_log(RC_COMMENT, "List of registered IKEv1 Algorithms:");
|
||||||
whack_log(RC_COMMENT, " ");
|
whack_log(RC_COMMENT, " ");
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " encryption:");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
for (a = ike_alg_base[IKE_ALG_ENCRYPT]; a != NULL; a = a->algo_next)
|
for (a = ike_alg_base[IKE_ALG_ENCRYPT]; a != NULL; a = a->algo_next)
|
||||||
{
|
{
|
||||||
n = snprintf(pos, len, " %s[%s]", enum_name(&oakley_enc_names,
|
print_alg(buf, &len, &oakley_enc_names, a->algo_id, a->plugin_name);
|
||||||
a->algo_id), a->plugin_name);
|
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
whack_log(RC_COMMENT, " encryption:%s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " integrity: ");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
for (a = ike_alg_base[IKE_ALG_HASH]; a != NULL; a = a->algo_next)
|
for (a = ike_alg_base[IKE_ALG_HASH]; a != NULL; a = a->algo_next)
|
||||||
{
|
{
|
||||||
n = snprintf(pos, len, " %s[%s]", enum_name(&oakley_hash_names,
|
print_alg(buf, &len, &oakley_hash_names, a->algo_id, a->plugin_name);
|
||||||
a->algo_id), a->plugin_name);
|
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
whack_log(RC_COMMENT, " integrity: %s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " dh-group: ");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
for (a = ike_alg_base[IKE_ALG_DH_GROUP]; a != NULL; a = a->algo_next)
|
for (a = ike_alg_base[IKE_ALG_DH_GROUP]; a != NULL; a = a->algo_next)
|
||||||
{
|
{
|
||||||
n = snprintf(pos, len, " %s[%s]", enum_name(&oakley_group_names,
|
print_alg(buf, &len, &oakley_group_names, a->algo_id, a->plugin_name);
|
||||||
a->algo_id), a->plugin_name);
|
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
whack_log(RC_COMMENT, " dh-group: %s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " random-gen:");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
enumerator = lib->crypto->create_rng_enumerator(lib->crypto);
|
enumerator = lib->crypto->create_rng_enumerator(lib->crypto);
|
||||||
while (enumerator->enumerate(enumerator, &quality, &plugin_name))
|
while (enumerator->enumerate(enumerator, &quality, &plugin_name))
|
||||||
{
|
{
|
||||||
n = snprintf(pos, len, " %N[%s]", rng_quality_names, quality,
|
len += sprintf(buf + len, " %N[%s]", rng_quality_names, quality,
|
||||||
plugin_name);
|
plugin_name);
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
whack_log(RC_COMMENT, " random-gen:%s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+25
-25
@@ -397,55 +397,55 @@ struct sadb_alg* kernel_alg_esp_sadb_alg(u_int alg_id)
|
|||||||
return sadb_alg;
|
return sadb_alg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the name of a kernel algorithm
|
||||||
|
*/
|
||||||
|
static void print_alg(char *buf, int *len, enum_names *alg_names, int alg_type)
|
||||||
|
{
|
||||||
|
char alg_name[BUF_LEN];
|
||||||
|
int alg_name_len;
|
||||||
|
|
||||||
|
alg_name_len = sprintf(alg_name, " %s", enum_name(alg_names, alg_type));
|
||||||
|
if (*len + alg_name_len > CRYPTO_MAX_ALG_LINE)
|
||||||
|
{
|
||||||
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
*len = sprintf(buf, " ");
|
||||||
|
}
|
||||||
|
sprintf(buf + *len, "%s", alg_name);
|
||||||
|
*len += alg_name_len;
|
||||||
|
}
|
||||||
|
|
||||||
void kernel_alg_list(void)
|
void kernel_alg_list(void)
|
||||||
{
|
{
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
char *pos;
|
int len;
|
||||||
int n, len;
|
|
||||||
u_int sadb_id;
|
u_int sadb_id;
|
||||||
|
|
||||||
whack_log(RC_COMMENT, " ");
|
whack_log(RC_COMMENT, " ");
|
||||||
whack_log(RC_COMMENT, "List of registered ESP Algorithms:");
|
whack_log(RC_COMMENT, "List of registered ESP Algorithms:");
|
||||||
whack_log(RC_COMMENT, " ");
|
whack_log(RC_COMMENT, " ");
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " encryption:");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
for (sadb_id = 1; sadb_id <= SADB_EALG_MAX; sadb_id++)
|
for (sadb_id = 1; sadb_id <= SADB_EALG_MAX; sadb_id++)
|
||||||
{
|
{
|
||||||
if (ESP_EALG_PRESENT(sadb_id))
|
if (ESP_EALG_PRESENT(sadb_id))
|
||||||
{
|
{
|
||||||
n = snprintf(pos, len, " %s",
|
print_alg(buf, &len, &esp_transform_names, sadb_id);
|
||||||
enum_name(&esp_transform_names, sadb_id));
|
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
whack_log(RC_COMMENT, " encryption:%s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
|
|
||||||
pos = buf;
|
len = sprintf(buf, " integrity: ");
|
||||||
*pos = '\0';
|
|
||||||
len = BUF_LEN;
|
|
||||||
for (sadb_id = 1; sadb_id <= SADB_AALG_MAX; sadb_id++)
|
for (sadb_id = 1; sadb_id <= SADB_AALG_MAX; sadb_id++)
|
||||||
{
|
{
|
||||||
if (ESP_AALG_PRESENT(sadb_id))
|
if (ESP_AALG_PRESENT(sadb_id))
|
||||||
{
|
{
|
||||||
u_int aaid = alg_info_esp_sadb2aa(sadb_id);
|
u_int aaid = alg_info_esp_sadb2aa(sadb_id);
|
||||||
|
|
||||||
n = snprintf(pos, len, " %s", enum_name(&auth_alg_names, aaid));
|
print_alg(buf, &len, &auth_alg_names, aaid);
|
||||||
pos += n;
|
|
||||||
len -= n;
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
whack_log(RC_COMMENT, " integrity: %s", buf);
|
whack_log(RC_COMMENT, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernel_alg_show_connection(connection_t *c, const char *instance)
|
void kernel_alg_show_connection(connection_t *c, const char *instance)
|
||||||
|
|||||||
Reference in New Issue
Block a user