Added option to write SRTP keys to log

pull/653/head
Tor Petterson 7 years ago
parent e9f9ae75ad
commit 590b752bbd

@ -14,6 +14,7 @@
#include "log.h" #include "log.h"
#include "rtplib.h" #include "rtplib.h"
#include "rtcplib.h" #include "rtcplib.h"
#include "main.h"
@ -699,7 +700,7 @@ static int null_crypt_rtcp(struct crypto_context *c, struct rtcp_packet *r, str
return 0; return 0;
} }
static void dump_key(struct crypto_context *c) { static void dump_key(struct crypto_context *c, int log_level) {
char *k, *s; char *k, *s;
if (!c->params.crypto_suite) if (!c->params.crypto_suite)
@ -708,20 +709,25 @@ static void dump_key(struct crypto_context *c) {
k = g_base64_encode(c->params.master_key, c->params.crypto_suite->master_key_len); k = g_base64_encode(c->params.master_key, c->params.crypto_suite->master_key_len);
s = g_base64_encode(c->params.master_salt, c->params.crypto_suite->master_salt_len); s = g_base64_encode(c->params.master_salt, c->params.crypto_suite->master_salt_len);
ilog(LOG_DEBUG, "--- %s key %s salt %s", c->params.crypto_suite->name, k, s); ilog(log_level, "--- %s key %s salt %s", c->params.crypto_suite->name, k, s);
g_free(k); g_free(k);
g_free(s); g_free(s);
} }
void crypto_dump_keys(struct crypto_context *in, struct crypto_context *out) { void crypto_dump_keys(struct crypto_context *in, struct crypto_context *out) {
if (get_log_level() < LOG_DEBUG) int log_level = LOG_DEBUG;
if (rtpe_config.log_keys)
log_level = LOG_ERROR;
if (get_log_level() < log_level)
return; return;
ilog(LOG_DEBUG, "SRTP keys, incoming:"); ilog(log_level, "SRTP keys, incoming:");
dump_key(in); dump_key(in, log_level);
ilog(LOG_DEBUG, "SRTP keys, outgoing:"); ilog(log_level, "SRTP keys, outgoing:");
dump_key(out); dump_key(out, log_level);
} }
void crypto_init_main() { void crypto_init_main() {

@ -362,6 +362,7 @@ static void options(int *argc, char ***argv) {
{ "priority", 0, 0, G_OPTION_ARG_INT, &rtpe_config.priority, "Thread scheduling priority", "INT" }, { "priority", 0, 0, G_OPTION_ARG_INT, &rtpe_config.priority, "Thread scheduling priority", "INT" },
{ "idle-scheduling",0, 0,G_OPTION_ARG_STRING, &rtpe_config.idle_scheduling,"Idle thread scheduling policy", "default|none|fifo|rr|other|batch|idle" }, { "idle-scheduling",0, 0,G_OPTION_ARG_STRING, &rtpe_config.idle_scheduling,"Idle thread scheduling policy", "default|none|fifo|rr|other|batch|idle" },
{ "idle-priority",0, 0, G_OPTION_ARG_INT, &rtpe_config.idle_priority,"Idle thread scheduling priority", "INT" }, { "idle-priority",0, 0, G_OPTION_ARG_INT, &rtpe_config.idle_priority,"Idle thread scheduling priority", "INT" },
{ "log-rtp-keys",'F', 0, G_OPTION_ARG_NONE, &rtpe_config.log_keys, "Log rtp keys", NULL },
{ NULL, } { NULL, }
}; };

@ -76,6 +76,7 @@ struct rtpengine_config {
int priority; int priority;
char *idle_scheduling; char *idle_scheduling;
int idle_priority; int idle_priority;
int log_keys;
}; };

Loading…
Cancel
Save