return s;
}
+u8 *
+format_crypto_engine (u8 * s, va_list * args)
+{
+ u32 engine = va_arg (*args, u32);
+ switch (engine)
+ {
+ case CRYPTO_ENGINE_NONE:
+ return format (s, "none");
+ case CRYPTO_ENGINE_MBEDTLS:
+ return format (s, "mbedtls");
+ case CRYPTO_ENGINE_OPENSSL:
+ return format (s, "openssl");
+ case CRYPTO_ENGINE_PICOTLS:
+ return format (s, "picotls");
+ case CRYPTO_ENGINE_VPP:
+ return format (s, "vpp");
+ default:
+ return format (s, "unknown engine");
+ }
+ return s;
+}
+
+uword
+unformat_crypto_engine (unformat_input_t * input, va_list * args)
+{
+ u8 *a = va_arg (*args, u8 *);
+ if (unformat (input, "mbedtls"))
+ *a = CRYPTO_ENGINE_MBEDTLS;
+ else if (unformat (input, "openssl"))
+ *a = CRYPTO_ENGINE_OPENSSL;
+ else if (unformat (input, "picotls"))
+ *a = CRYPTO_ENGINE_PICOTLS;
+ else if (unformat (input, "vpp"))
+ *a = CRYPTO_ENGINE_VPP;
+ else
+ return 0;
+ return 1;
+}
+
+u8 *
+format_crypto_context (u8 * s, va_list * args)
+{
+ crypto_context_t *crctx = va_arg (*args, crypto_context_t *);
+ s =
+ format (s, "[0x%x][sub%d,ckpair%x]", crctx->ctx_index,
+ crctx->n_subscribers, crctx->ckpair_index);
+ s = format (s, "[%U]", format_crypto_engine, crctx->crypto_engine);
+ return s;
+}
+
u8 *
format_application (u8 * s, va_list * args)
{
return 0;
}
-/*
- * Certificate store
- *
- */
+/* Certificate store */
static app_cert_key_pair_t *
app_cert_key_pair_alloc ()
}
int
-vent_app_add_cert_key_interest (u32 index, u32 app_index)
+vnet_app_add_cert_key_interest (u32 index, u32 app_index)
{
app_cert_key_pair_t *ckpair;
if (!(ckpair = app_cert_key_pair_get_if_valid (index)))
return -1;
- vec_add1 (ckpair->app_interests, app_index);
+ if (vec_search (ckpair->app_interests, app_index) != ~0)
+ vec_add1 (ckpair->app_interests, app_index);
return 0;
}
}
clib_error_t *
-cert_key_pair_store_init (vlib_main_t * vm)
+application_init (vlib_main_t * vm)
{
/* Add a certificate with index 0 to support legacy apis */
(void) app_cert_key_pair_alloc ();
+ app_main.last_crypto_engine = CRYPTO_ENGINE_LAST;
return 0;
}
/* *INDENT-OFF* */
-VLIB_INIT_FUNCTION (cert_key_pair_store_init) =
-{
- .runs_after = VLIB_INITS("unix_physmem_init"),
-};
+VLIB_INIT_FUNCTION (application_init);
VLIB_CLI_COMMAND (show_app_command, static) =
{
};
/* *INDENT-ON* */
+crypto_engine_type_t
+app_crypto_engine_type_add (void)
+{
+ return (++app_main.last_crypto_engine);
+}
+
+u8
+app_crypto_engine_n_types (void)
+{
+ return (app_main.last_crypto_engine + 1);
+}
+
/*
* fd.io coding-style-patch-verification: ON
*