summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPing Yu <ping.yu@intel.com>2019-08-22 13:43:00 -0400
committerDamjan Marion <dmarion@me.com>2019-09-02 18:24:41 +0000
commitdd0cc9ec3df81485f19fc6b1126d0b4307bf9fa4 (patch)
tree7f374e3107370595168683b2b53e0fa4eedd34d7
parentbe2c2a82d817decc3b8e58239e8c6828f349b97b (diff)
tls: some rework based on TLS openssl C API
Type: fix Change-Id: I5d0ac1fe6a6770ab8b3a9c366d10387718391199 Signed-off-by: Ping Yu <ping.yu@intel.com>
-rw-r--r--src/plugins/tlsopenssl/tls_openssl.api12
-rw-r--r--src/plugins/tlsopenssl/tls_openssl_api.c37
-rw-r--r--src/plugins/tlsopenssl/tls_openssl_test.c10
3 files changed, 33 insertions, 26 deletions
diff --git a/src/plugins/tlsopenssl/tls_openssl.api b/src/plugins/tlsopenssl/tls_openssl.api
index 7de77522c9c..8111f51065c 100644
--- a/src/plugins/tlsopenssl/tls_openssl.api
+++ b/src/plugins/tlsopenssl/tls_openssl.api
@@ -2,7 +2,7 @@
option version = "2.0.0";
-define tls_openssl_set_engine {
+autoreply define tls_openssl_set_engine {
/* Client identifier, set from api_main.my_client_index */
u32 client_index;
@@ -10,7 +10,7 @@ define tls_openssl_set_engine {
u32 context;
/* if async is enabled */
- u32 async;
+ u32 async_enable;
/* engine name */
u8 engine[64];
@@ -21,11 +21,3 @@ define tls_openssl_set_engine {
/* cipher */
u8 ciphers[64];
};
-
-define tls_openssl_set_engine_reply {
- /* From the request */
- u32 context;
-
- /* Return value, zero means all OK */
- i32 retval;
-};
diff --git a/src/plugins/tlsopenssl/tls_openssl_api.c b/src/plugins/tlsopenssl/tls_openssl_api.c
index 9474aae2faf..99ef3fe27c3 100644
--- a/src/plugins/tlsopenssl/tls_openssl_api.c
+++ b/src/plugins/tlsopenssl/tls_openssl_api.c
@@ -55,32 +55,37 @@ extern openssl_main_t openssl_main;
/* API message handler */
static void
-vl_api_tls_openssl_set_engine_t_handler (vl_api_tls_openssl_set_engine_t *mp)
+vl_api_tls_openssl_set_engine_t_handler (vl_api_tls_openssl_set_engine_t * mp)
{
vl_api_tls_openssl_set_engine_reply_t *rmp;
openssl_main_t *om = &openssl_main;
- char *engine, *alg, *ciphers;
+ char *engine, *alg;
+ char *ciphers;
int rv;
- engine = (char *)&mp->engine;
- alg = (char *)&mp->algorithm;
- ciphers = (char *)&mp->ciphers;
-
- if (mp->async)
+ if (mp->async_enable)
{
om->async = 1;
openssl_async_node_enable_disable (1);
}
+ ciphers = (char *) &mp->ciphers;
+ ciphers[63] = '\0';
if (ciphers[0])
tls_openssl_set_ciphers (ciphers);
+
+ engine = (char *) mp->engine;
+ engine[63] = '\0';
+ alg = (char *) mp->algorithm;
+ alg[63] = '\0';
rv = openssl_engine_register (engine, alg);
REPLY_MACRO (VL_API_TLS_OPENSSL_SET_ENGINE_REPLY);
}
/* Set up the API message handling tables */
-static clib_error_t *tls_openssl_plugin_api_hookup (vlib_main_t *vm)
+static clib_error_t *
+tls_openssl_plugin_api_hookup (vlib_main_t * vm)
{
openssl_main_t *om = &openssl_main;
#define _(N, n) \
@@ -98,7 +103,8 @@ static clib_error_t *tls_openssl_plugin_api_hookup (vlib_main_t *vm)
#include <tlsopenssl/tls_openssl_all_api_h.h>
#undef vl_msg_name_crc_list
-static void setup_message_id_table (openssl_main_t *om, api_main_t *am)
+static void
+setup_message_id_table (openssl_main_t * om, api_main_t * am)
{
#define _(id, n, crc) \
vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + om->msg_id_base);
@@ -106,7 +112,8 @@ static void setup_message_id_table (openssl_main_t *om, api_main_t *am)
#undef _
}
-clib_error_t *tls_openssl_api_init (vlib_main_t *vm)
+clib_error_t *
+tls_openssl_api_init (vlib_main_t * vm)
{
openssl_main_t *om = &openssl_main;
clib_error_t *error = 0;
@@ -116,7 +123,7 @@ clib_error_t *tls_openssl_api_init (vlib_main_t *vm)
/* Ask for a correctly-sized block of API message decode slots */
om->msg_id_base =
- vl_msg_api_get_msg_ids ((char *)name, VL_MSG_FIRST_AVAILABLE);
+ vl_msg_api_get_msg_ids ((char *) name, VL_MSG_FIRST_AVAILABLE);
error = tls_openssl_plugin_api_hookup (vm);
@@ -126,3 +133,11 @@ clib_error_t *tls_openssl_api_init (vlib_main_t *vm)
return error;
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/tlsopenssl/tls_openssl_test.c b/src/plugins/tlsopenssl/tls_openssl_test.c
index 1c810c9a7f8..aa64fb86bbb 100644
--- a/src/plugins/tlsopenssl/tls_openssl_test.c
+++ b/src/plugins/tlsopenssl/tls_openssl_test.c
@@ -127,24 +127,24 @@ api_tls_openssl_set_engine (vat_main_t * vam)
engine_alg = format (0, "ALL");
else
{
- for (int i = 0; i < strnlen ((char *) engine_alg, 64); i++)
+ for (int i = 0; i < strnlen ((char *) engine_alg, 63); i++)
engine_alg[i] = toupper (engine_alg[i]);
}
/* Construct the API message */
M (TLS_OPENSSL_SET_ENGINE, mp);
- mp->async = async;
+ mp->async_enable = async;
clib_memcpy_fast (mp->engine, engine_name,
- strnlen ((const char *) engine_name, 64));
+ strnlen ((const char *) engine_name, 63));
clib_memcpy_fast (mp->algorithm, engine_alg,
- strnlen ((const char *) engine_alg, 64));
+ strnlen ((const char *) engine_alg, 63));
if (ciphers)
clib_memcpy_fast (mp->ciphers, ciphers,
- strnlen ((const char *) ciphers, 64));
+ strnlen ((const char *) ciphers, 63));
/* send it... */
S (mp);