diff --git a/daemon/crypto.c b/daemon/crypto.c index 9611f229f..fe627698e 100644 --- a/daemon/crypto.c +++ b/daemon/crypto.c @@ -336,7 +336,7 @@ const unsigned int num_crypto_suites = G_N_ELEMENTS(__crypto_suites); -const struct crypto_suite *crypto_find_suite(const str *s) { +const struct crypto_suite * crypto_find_suite(const str *s) { int i, l; const struct crypto_suite *cs; @@ -358,8 +358,6 @@ const struct crypto_suite *crypto_find_suite(const str *s) { return NULL; } - - /* rfc 3711 section 4.1 and 4.1.1 * "in" and "out" MAY point to the same buffer */ static void aes_ctr(unsigned char *out, str *in, EVP_CIPHER_CTX *ecc, const unsigned char *iv) { diff --git a/include/crypto.h b/include/crypto.h index 014d2c9e1..3b7536df5 100644 --- a/include/crypto.h +++ b/include/crypto.h @@ -9,7 +9,6 @@ #include "str.h" #include "aux.h" - #define SRTP_MAX_MASTER_KEY_LEN 32 #define SRTP_MAX_MASTER_SALT_LEN 14 #define SRTP_MAX_SESSION_KEY_LEN 32 @@ -107,11 +106,22 @@ extern __thread GString *crypto_debug_string; void crypto_init_main(void); -const struct crypto_suite *crypto_find_suite(const str *); +const struct crypto_suite * crypto_find_suite(const str *); int crypto_gen_session_key(struct crypto_context *, str *, unsigned char, int); void crypto_dump_keys(struct crypto_context *in, struct crypto_context *out); char *crypto_params_sdes_dump(const struct crypto_params_sdes *, char **); +/** + * A function which compares two crypto suite names in str format. + * Recommended to be used in combination with: + * g_queue_find_custom() or g_list_find_custom() + */ +INLINE int crypto_params_sdes_cmp(gconstpointer a, gconstpointer b) +{ + const struct crypto_params_sdes * cs = a; + + return str_cmp_str(&cs->params.crypto_suite->name_str, (str *) b); +} INLINE int crypto_encrypt_rtp(struct crypto_context *c, struct rtp_header *rtp,